Skip to content

Commit abbe647

Browse files
authored
Merge pull request #221 from walkero-gr/chipset-filter
Chipset filter
2 parents 105ebe8 + 7d2977b commit abbe647

File tree

13 files changed

+341
-30
lines changed

13 files changed

+341
-30
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
## iGame VERSION_TAG - [RELEASE_DATE]
22
### Added
33
- Now the Genre list is populated from the igame.data files and the genre file, if it exists, although it is not necessary. The genre filtering is working with these new values
4+
- Added a new cycle box that lets the user to filter the results based on the chipset. This requires in settings the "Prefer igame.data files" to be enabled
45

56
### Changed
67
- When realtime filtering is enabled at least 3 characters are required so as to be initiated. Less than 3 characters are ignored, unless the filtering by pressing the enter button is enabled.
78
- Removed the filtering options from the Genre list and moved to its own select box above entries list
9+
- Now, even if the list entries list is populated a new repository scan will update the Chipset and Genre information based on the data found in igame.data files.
10+
- If the "Prefer igame.data files" is not enabled those files are not used during the scan of repositories
811

912
### Fixed
1013
- Fixed a hit when the entry properties are requested without having a selected entry

Makefile.docker

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ endif
9999

100100
igame_OBJS = src/funcs_$(CPU).o src/iGameGUI_$(CPU).o \
101101
src/iGameMain_$(CPU).o src/strfuncs_$(CPU).o src/fsfuncs_$(CPU).o \
102-
src/slavesList_$(CPU).o src/genresList_$(CPU).o
102+
src/slavesList_$(CPU).o src/genresList_$(CPU).o \
103+
src/chipsetList_$(CPU).o
103104

104105
##########################################################################
105106
# Rule for building
@@ -127,7 +128,8 @@ catalogs/%/iGame.catalog: catalogs/%/iGame.ct catalogs/iGame.cd
127128
@$(CC) -c $< -o $*_$(CPU).o $(CFLAGS) $(INCLUDES)
128129

129130
src/funcs_$(CPU).o: src/funcs.c src/iGame_strings.h src/strfuncs.h \
130-
src/fsfuncs.h src/iGameExtern.h src/slavesList.h src/genresList.h
131+
src/fsfuncs.h src/iGameExtern.h src/slavesList.h src/genresList.h \
132+
src/chipsetList.h
131133

132134
src/iGameGUI_$(CPU).o: src/iGameGUI.c src/iGameGUI.h src/iGame_strings.h \
133135
src/fsfuncs.h src/iGameExtern.h
@@ -137,11 +139,13 @@ src/iGameMain_$(CPU).o: src/iGameMain.c src/iGameExtern.h
137139
src/strfuncs_$(CPU).o: src/strfuncs.c src/iGameExtern.h src/strfuncs.h
138140

139141
src/fsfuncs_$(CPU).o: src/fsfuncs.c src/fsfuncs.h src/funcs.h \
140-
src/iGameExtern.h src/slavesList.h src/genresList.h
142+
src/iGameExtern.h src/slavesList.h src/genresList.h src/chipsetList.h
141143

142144
src/slavesList_$(CPU).o: src/slavesList.c src/slavesList.h
143145

144-
src/genresList_$(CPU).o: src/genresList.c src/genresList.h
146+
src/genresList_$(CPU).o: src/genresList.c src/genresList.h src/strfuncs.h
147+
148+
src/chipsetList_$(CPU).o: src/chipsetList.c src/chipsetList.h src/strfuncs.h
145149

146150
##########################################################################
147151
# generic rules

catalogs/iGame.cd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ MSG_FilterShowAll (//)
248248
--Show All--
249249
;
250250
MSG_FilterFavorites (//)
251-
--Favorites--
251+
--Favourites--
252252
;
253253
MSG_FilterLastPlayed (//)
254254
--Last Played--
@@ -299,7 +299,7 @@ MSG_DirectoryNotFound (//)
299299
Game Directory not found!
300300
;
301301
MSG_LA_StartWithFavorites (//)
302-
Display favorites on start
302+
Display favourites on start
303303
;
304304
MSG_MNMainOpenCurrentDir (//)
305305
Open game folder

required_files/iGame.guide

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,14 @@ The entries list holds the entries (games, demos etc.) based on the filtering. W
247247

248248
At the top right side, there is a screenshot of the selected entry. For the screenshot, iGame uses an image file, which must be in the same folder as the game/demo, named @{b}igame.iff@{ub}. If no screenshot is available then the entry icon is shown. You can disable the screenshots from the @{" Settings Window " LINK "WINSETS" 0}.
249249

250-
Under the screenshot, there is the "Genres" list which helps you filter the games based on the "Genre". There is also an "Unknown" selection which shows the entries that do not have any Genre assigned.
250+
Under the screenshot, there is the Chipset cycle box. Using that the user can filter the games based on the required chipset, for example show only the AGA games.
251+
252+
Then the "Genres" list helps the user to filter the games based on the "Genre". There is also an "Unknown" selection which shows the entries that do not have any Genre assigned.
251253

252254
At the bottom, there is a read-only field which shows information about iGame, based on what you are doing. It is like a status bar, where useful information will be shown while you use iGame.
253255

256+
The Genre and Chipset lists get the information from the @{b}gameslist.csv@{ub} file. It can be automatically populated if the @{" igame.data files " LINK "IGDF" 0} are used and this is enabled in the settings window.
257+
254258
@ENDNODE
255259
@NODE "WINADDG" "Add a Game Window..."
256260
@{lindent 3}

src/chipsetList.c

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
/*
2+
chipsetList.c
3+
chipset list functions source for iGame
4+
5+
Copyright (c) 2018-2023, Emmanuel Vasilakis
6+
7+
This file is part of iGame.
8+
9+
iGame is free software: you can redistribute it and/or modify
10+
it under the terms of the GNU General Public License as published by
11+
the Free Software Foundation, either version 3 of the License, or
12+
(at your option) any later version.
13+
14+
iGame is distributed in the hope that it will be useful,
15+
but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
GNU General Public License for more details.
18+
19+
You should have received a copy of the GNU General Public License
20+
along with iGame. If not, see <http://www.gnu.org/licenses/>.
21+
*/
22+
23+
#include <stdio.h>
24+
#include <string.h>
25+
#include <stdlib.h>
26+
27+
#include <exec/types.h>
28+
29+
#include "iGameExtern.h"
30+
#include "chipsetList.h"
31+
#include "strfuncs.h"
32+
33+
chipsetList *chipsetListHead = NULL;
34+
35+
static int isListEmpty(const void *head)
36+
{
37+
return head == NULL;
38+
}
39+
40+
void chipsetListAddTail(chipsetList *node)
41+
{
42+
if (node != NULL)
43+
{
44+
node->next = NULL;
45+
46+
if (isListEmpty(chipsetListHead))
47+
{
48+
chipsetListHead = node;
49+
}
50+
else
51+
{
52+
// find the last node
53+
chipsetList *currPtr = chipsetListHead;
54+
while (currPtr->next != NULL)
55+
{
56+
currPtr = currPtr->next;
57+
}
58+
59+
currPtr->next = node;
60+
}
61+
}
62+
}
63+
64+
static BOOL chipsetListRemoveHead(void) {
65+
66+
if (isListEmpty(chipsetListHead)) {
67+
return FALSE;
68+
}
69+
70+
chipsetList *nextPtr = chipsetListHead->next;
71+
free(chipsetListHead);
72+
chipsetListHead = nextPtr;
73+
return TRUE;
74+
}
75+
76+
void chipsetListPrint(void)
77+
{
78+
int cnt = 0;
79+
chipsetList *currPtr = chipsetListHead;
80+
while (currPtr != NULL)
81+
{
82+
printf("----> %s\n", currPtr->title);
83+
currPtr = currPtr->next;
84+
cnt++;
85+
}
86+
printf("END OF LIST: %d items\n", cnt);
87+
}
88+
89+
chipsetList *chipsetListSearchByTitle(char *title, unsigned int titleSize)
90+
{
91+
if (isListEmpty(chipsetListHead))
92+
{
93+
return NULL;
94+
}
95+
96+
chipsetList *currPtr = chipsetListHead;
97+
while (
98+
currPtr != NULL &&
99+
strncmp(currPtr->title, title, titleSize)
100+
) {
101+
currPtr = currPtr->next;
102+
}
103+
104+
return currPtr;
105+
}
106+
107+
chipsetList *getChipsetListHead(void)
108+
{
109+
return chipsetListHead;
110+
}
111+
112+
void emptyChipsetList(void)
113+
{
114+
while(chipsetListRemoveHead())
115+
{}
116+
}
117+
118+
int chipsetListNodeCount(int cnt)
119+
{
120+
static int nodeCount = 0;
121+
122+
if (cnt == -1)
123+
{
124+
return nodeCount;
125+
}
126+
127+
nodeCount = cnt;
128+
return nodeCount;
129+
}
130+
131+
void addChipsetInList(char *title)
132+
{
133+
if (isStringEmpty(title))
134+
return;
135+
136+
if (chipsetListSearchByTitle(title, sizeof(char) * MAX_CHIPSET_SIZE) == NULL)
137+
{
138+
chipsetList *node = malloc(sizeof(chipsetList));
139+
if(node == NULL)
140+
{
141+
return;
142+
}
143+
strncpy(node->title, title, sizeof(char) * MAX_CHIPSET_SIZE);
144+
chipsetListAddTail(node);
145+
}
146+
}

src/chipsetList.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
chipsetList.h
3+
chipset list functions header for iGame
4+
5+
Copyright (c) 2018-2023, Emmanuel Vasilakis
6+
7+
This file is part of iGame.
8+
9+
iGame is free software: you can redistribute it and/or modify
10+
it under the terms of the GNU General Public License as published by
11+
the Free Software Foundation, either version 3 of the License, or
12+
(at your option) any later version.
13+
14+
iGame is distributed in the hope that it will be useful,
15+
but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
GNU General Public License for more details.
18+
19+
You should have received a copy of the GNU General Public License
20+
along with iGame. If not, see <http://www.gnu.org/licenses/>.
21+
*/
22+
23+
#ifndef _CHIPSET_LIST_H
24+
#define _CHIPSET_LIST_H
25+
26+
void chipsetListAddTail(chipsetList *);
27+
void chipsetListPrint(void);
28+
chipsetList *chipsetListSearchByTitle(char *, unsigned int);
29+
chipsetList *getChipsetListHead(void);
30+
void emptyChipsetList(void);
31+
int chipsetListNodeCount(int);
32+
void addChipsetInList(char *);
33+
34+
#endif

src/fsfuncs.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#include "strfuncs.h"
5656
#include "slavesList.h"
5757
#include "genresList.h"
58+
#include "chipsetList.h"
5859
#include "funcs.h"
5960
#include "fsfuncs.h"
6061

@@ -267,6 +268,18 @@ void slavesListLoadFromCSV(char *filename)
267268
if (buf)
268269
node->players = atoi(buf);
269270

271+
buf = strtok(NULL, ";");
272+
node->chipset[0] = '\0';
273+
if (strncmp(buf, "\n", sizeof(char)))
274+
{
275+
sprintf(node->chipset, "%s", buf);
276+
}
277+
if (strcasestr(buf, "\""))
278+
{
279+
sprintf(node->chipset, "%s", substring(buf, 1, -2));
280+
}
281+
addChipsetInList(node->chipset);
282+
270283
slavesListAddTail(node);
271284
}
272285
Close(fpgames);
@@ -298,12 +311,12 @@ void slavesListSaveToCSV(const char *filename)
298311
{
299312
fprintf(
300313
fpgames,
301-
"%d;\"%s\";\"%s\";\"%s\";%d;%d;%d;%d;%d;\"%s\";%d;%d;\n",
314+
"%d;\"%s\";\"%s\";\"%s\";%d;%d;%d;%d;%d;\"%s\";%d;%d;\"%s\";\n",
302315
currPtr->instance, currPtr->title,
303316
currPtr->genre, currPtr->path, currPtr->favourite,
304317
currPtr->times_played, currPtr->last_played, currPtr->hidden,
305318
currPtr->deleted, currPtr->user_title,
306-
currPtr->year, currPtr->players
319+
currPtr->year, currPtr->players, currPtr->chipset
307320
);
308321
currPtr = currPtr->next;
309322
}
@@ -670,6 +683,11 @@ void getIGameDataInfo(char *igameDataPath, slavesList *node)
670683
strncpy(node->title, tmpTbl[1], MAX_SLAVE_TITLE_SIZE);
671684
}
672685

686+
if(!strcmp(tmpTbl[0], "chipset"))
687+
{
688+
strncpy(node->chipset, tmpTbl[1], MAX_CHIPSET_SIZE);
689+
}
690+
673691
if(!strcmp(tmpTbl[0], "genre"))
674692
{
675693
strncpy(node->genre, tmpTbl[1], MAX_GENRE_NAME_SIZE);

0 commit comments

Comments
 (0)