Skip to content

Commit

Permalink
Merge pull request #221 from walkero-gr/chipset-filter
Browse files Browse the repository at this point in the history
Chipset filter
  • Loading branch information
walkero-gr authored Jul 19, 2023
2 parents 105ebe8 + 7d2977b commit abbe647
Show file tree
Hide file tree
Showing 13 changed files with 341 additions and 30 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
## iGame VERSION_TAG - [RELEASE_DATE]
### Added
- 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
- 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

### Changed
- 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.
- Removed the filtering options from the Genre list and moved to its own select box above entries list
- 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.
- If the "Prefer igame.data files" is not enabled those files are not used during the scan of repositories

### Fixed
- Fixed a hit when the entry properties are requested without having a selected entry
Expand Down
12 changes: 8 additions & 4 deletions Makefile.docker
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ endif

igame_OBJS = src/funcs_$(CPU).o src/iGameGUI_$(CPU).o \
src/iGameMain_$(CPU).o src/strfuncs_$(CPU).o src/fsfuncs_$(CPU).o \
src/slavesList_$(CPU).o src/genresList_$(CPU).o
src/slavesList_$(CPU).o src/genresList_$(CPU).o \
src/chipsetList_$(CPU).o

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

src/funcs_$(CPU).o: src/funcs.c src/iGame_strings.h src/strfuncs.h \
src/fsfuncs.h src/iGameExtern.h src/slavesList.h src/genresList.h
src/fsfuncs.h src/iGameExtern.h src/slavesList.h src/genresList.h \
src/chipsetList.h

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

src/fsfuncs_$(CPU).o: src/fsfuncs.c src/fsfuncs.h src/funcs.h \
src/iGameExtern.h src/slavesList.h src/genresList.h
src/iGameExtern.h src/slavesList.h src/genresList.h src/chipsetList.h

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

src/genresList_$(CPU).o: src/genresList.c src/genresList.h
src/genresList_$(CPU).o: src/genresList.c src/genresList.h src/strfuncs.h

src/chipsetList_$(CPU).o: src/chipsetList.c src/chipsetList.h src/strfuncs.h

##########################################################################
# generic rules
Expand Down
4 changes: 2 additions & 2 deletions catalogs/iGame.cd
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ MSG_FilterShowAll (//)
--Show All--
;
MSG_FilterFavorites (//)
--Favorites--
--Favourites--
;
MSG_FilterLastPlayed (//)
--Last Played--
Expand Down Expand Up @@ -299,7 +299,7 @@ MSG_DirectoryNotFound (//)
Game Directory not found!
;
MSG_LA_StartWithFavorites (//)
Display favorites on start
Display favourites on start
;
MSG_MNMainOpenCurrentDir (//)
Open game folder
Expand Down
6 changes: 5 additions & 1 deletion required_files/iGame.guide
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,14 @@ The entries list holds the entries (games, demos etc.) based on the filtering. W

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}.

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.
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.

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.

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.

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.

@ENDNODE
@NODE "WINADDG" "Add a Game Window..."
@{lindent 3}
Expand Down
146 changes: 146 additions & 0 deletions src/chipsetList.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/*
chipsetList.c
chipset list functions source for iGame
Copyright (c) 2018-2023, Emmanuel Vasilakis
This file is part of iGame.
iGame is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
iGame is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with iGame. If not, see <http://www.gnu.org/licenses/>.
*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include <exec/types.h>

#include "iGameExtern.h"
#include "chipsetList.h"
#include "strfuncs.h"

chipsetList *chipsetListHead = NULL;

static int isListEmpty(const void *head)
{
return head == NULL;
}

void chipsetListAddTail(chipsetList *node)
{
if (node != NULL)
{
node->next = NULL;

if (isListEmpty(chipsetListHead))
{
chipsetListHead = node;
}
else
{
// find the last node
chipsetList *currPtr = chipsetListHead;
while (currPtr->next != NULL)
{
currPtr = currPtr->next;
}

currPtr->next = node;
}
}
}

static BOOL chipsetListRemoveHead(void) {

if (isListEmpty(chipsetListHead)) {
return FALSE;
}

chipsetList *nextPtr = chipsetListHead->next;
free(chipsetListHead);
chipsetListHead = nextPtr;
return TRUE;
}

void chipsetListPrint(void)
{
int cnt = 0;
chipsetList *currPtr = chipsetListHead;
while (currPtr != NULL)
{
printf("----> %s\n", currPtr->title);
currPtr = currPtr->next;
cnt++;
}
printf("END OF LIST: %d items\n", cnt);
}

chipsetList *chipsetListSearchByTitle(char *title, unsigned int titleSize)
{
if (isListEmpty(chipsetListHead))
{
return NULL;
}

chipsetList *currPtr = chipsetListHead;
while (
currPtr != NULL &&
strncmp(currPtr->title, title, titleSize)
) {
currPtr = currPtr->next;
}

return currPtr;
}

chipsetList *getChipsetListHead(void)
{
return chipsetListHead;
}

void emptyChipsetList(void)
{
while(chipsetListRemoveHead())
{}
}

int chipsetListNodeCount(int cnt)
{
static int nodeCount = 0;

if (cnt == -1)
{
return nodeCount;
}

nodeCount = cnt;
return nodeCount;
}

void addChipsetInList(char *title)
{
if (isStringEmpty(title))
return;

if (chipsetListSearchByTitle(title, sizeof(char) * MAX_CHIPSET_SIZE) == NULL)
{
chipsetList *node = malloc(sizeof(chipsetList));
if(node == NULL)
{
return;
}
strncpy(node->title, title, sizeof(char) * MAX_CHIPSET_SIZE);
chipsetListAddTail(node);
}
}
34 changes: 34 additions & 0 deletions src/chipsetList.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
chipsetList.h
chipset list functions header for iGame
Copyright (c) 2018-2023, Emmanuel Vasilakis
This file is part of iGame.
iGame is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
iGame is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with iGame. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _CHIPSET_LIST_H
#define _CHIPSET_LIST_H

void chipsetListAddTail(chipsetList *);
void chipsetListPrint(void);
chipsetList *chipsetListSearchByTitle(char *, unsigned int);
chipsetList *getChipsetListHead(void);
void emptyChipsetList(void);
int chipsetListNodeCount(int);
void addChipsetInList(char *);

#endif
22 changes: 20 additions & 2 deletions src/fsfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include "strfuncs.h"
#include "slavesList.h"
#include "genresList.h"
#include "chipsetList.h"
#include "funcs.h"
#include "fsfuncs.h"

Expand Down Expand Up @@ -267,6 +268,18 @@ void slavesListLoadFromCSV(char *filename)
if (buf)
node->players = atoi(buf);

buf = strtok(NULL, ";");
node->chipset[0] = '\0';
if (strncmp(buf, "\n", sizeof(char)))
{
sprintf(node->chipset, "%s", buf);
}
if (strcasestr(buf, "\""))
{
sprintf(node->chipset, "%s", substring(buf, 1, -2));
}
addChipsetInList(node->chipset);

slavesListAddTail(node);
}
Close(fpgames);
Expand Down Expand Up @@ -298,12 +311,12 @@ void slavesListSaveToCSV(const char *filename)
{
fprintf(
fpgames,
"%d;\"%s\";\"%s\";\"%s\";%d;%d;%d;%d;%d;\"%s\";%d;%d;\n",
"%d;\"%s\";\"%s\";\"%s\";%d;%d;%d;%d;%d;\"%s\";%d;%d;\"%s\";\n",
currPtr->instance, currPtr->title,
currPtr->genre, currPtr->path, currPtr->favourite,
currPtr->times_played, currPtr->last_played, currPtr->hidden,
currPtr->deleted, currPtr->user_title,
currPtr->year, currPtr->players
currPtr->year, currPtr->players, currPtr->chipset
);
currPtr = currPtr->next;
}
Expand Down Expand Up @@ -670,6 +683,11 @@ void getIGameDataInfo(char *igameDataPath, slavesList *node)
strncpy(node->title, tmpTbl[1], MAX_SLAVE_TITLE_SIZE);
}

if(!strcmp(tmpTbl[0], "chipset"))
{
strncpy(node->chipset, tmpTbl[1], MAX_CHIPSET_SIZE);
}

if(!strcmp(tmpTbl[0], "genre"))
{
strncpy(node->genre, tmpTbl[1], MAX_GENRE_NAME_SIZE);
Expand Down
Loading

0 comments on commit abbe647

Please sign in to comment.