Skip to content

Commit

Permalink
Merge pull request #232 from walkero-gr/issue-215
Browse files Browse the repository at this point in the history
Fixing the issue 215 and make the scan better on changes
  • Loading branch information
walkero-gr authored Nov 3, 2023
2 parents 03a5595 + b302754 commit ab35f1a
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Fixed the generated genre list titles after a rescan of the repository
- Fixed more memory leaks
- Fixed the load of the list of items when the side panel is hidden
- Fixed the title change of the items in the list (#215)

## iGame 2.4.3 - [2023-09-01]
### Fixed
Expand Down
42 changes: 40 additions & 2 deletions src/funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ BOOL sidepanelChanged = FALSE; // This is temporary until settings are revamped
static int get_cycle_index(Object *);
static void showSlavesList(void);
static LONG xget(Object *, ULONG);
static void setLastScanBitfield(void);

repos_list *item_repos = NULL, *repos = NULL;
igame_settings *current_settings = NULL;
Expand Down Expand Up @@ -143,6 +144,7 @@ static void setDefaultSettings(igame_settings *settings)
current_settings->screenshot_width = 160;
current_settings->screenshot_height = 128;
current_settings->start_with_favorites = FALSE;
current_settings->lastScanSetup = 0;
}

static void getPrefsPath(STRPTR prefsPath, STRPTR prefsFile)
Expand Down Expand Up @@ -221,13 +223,18 @@ igame_settings *load_settings(const char* filename)
current_settings->start_with_favorites = atoi((const char*)file_line + 21);
if (!strncmp(file_line, "use_igame.data_title=", 21))
current_settings->useIgameDataTitle = atoi((const char*)file_line + 21);
if (!strncmp(file_line, "last_scan_setup=", 16))
current_settings->lastScanSetup = atoi((const char*)file_line + 16);
}
while (1);

Close(fpsettings);
}
}

if (current_settings->lastScanSetup == 0)
setLastScanBitfield();

if (prefsPath)
FreeVec(prefsPath);

Expand Down Expand Up @@ -740,6 +747,23 @@ static void generateItemName(char *path, char *result, int resultSize)
}
}

static int calcLastScanBitfield(void)
{
int scanBitfield = 0;
scanBitfield = 1 * current_settings->useIgameDataTitle;
scanBitfield += 2 * current_settings->titles_from_dirs;
if(current_settings->titles_from_dirs)
{
scanBitfield += 4 * current_settings->no_smart_spaces;
}
return scanBitfield;
}

static void setLastScanBitfield(void)
{
current_settings->lastScanSetup = calcLastScanBitfield();
}

static BOOL examineFolder(char *path)
{
BOOL success = TRUE;
Expand Down Expand Up @@ -966,6 +990,13 @@ static BOOL examineFolder(char *path)

getIGameDataInfo(igameDataPath, node);

strncpy(existingNode->title, node->title, MAX_SLAVE_TITLE_SIZE);
if (isStringEmpty(existingNode->title))
{
// Fallback generation of the title and addition in the list
generateItemName(existingNode->path, existingNode->title, sizeof(existingNode->title));
}

if (!isStringEmpty(node->genre))
{
strncpy(existingNode->genre, node->genre, MAX_GENRE_NAME_SIZE);
Expand All @@ -982,8 +1013,12 @@ static BOOL examineFolder(char *path)
free(igameDataPath);
}

// Generate title and add in the list
generateItemName(existingNode->path, existingNode->title, sizeof(existingNode->title));
// If the current scan settings are different from last scan settings and
// the igame.data file is not used, get the title from the file
if (!current_settings->useIgameDataTitle && current_settings->lastScanSetup != calcLastScanBitfield())
{
generateItemName(existingNode->path, existingNode->title, sizeof(existingNode->title));
}
}
}
}
Expand Down Expand Up @@ -1016,6 +1051,7 @@ void scan_repositories(void)
showSlavesList();
populateGenresList();
populateChipsetList();
setLastScanBitfield();
set(app->WI_MainWindow, MUIA_Window_Sleep, FALSE);
}
}
Expand Down Expand Up @@ -1641,6 +1677,8 @@ void settings_save(void)
FPuts(fpsettings, (CONST_STRPTR)file_line);
snprintf(file_line, buffer_size, "use_igame.data_title=%d\n", current_settings->useIgameDataTitle);
FPuts(fpsettings, (CONST_STRPTR)file_line);
snprintf(file_line, buffer_size, "last_scan_setup=%d\n", current_settings->lastScanSetup);
FPuts(fpsettings, (CONST_STRPTR)file_line);

Close(fpsettings);

Expand Down
8 changes: 8 additions & 0 deletions src/iGameExtern.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ typedef struct settings
int no_guigfx;
int start_with_favorites;
int useIgameDataTitle;
int lastScanSetup; // It keeps info of the settings on the last scan
// that influence the item data
// It is a bitfield with the following structure
// ------------ no_smart_spaces
// | --------- titles_from_dirs
// | | ------ useIgameDataTitle
// | | |
// 0 0 0
} igame_settings;

typedef struct genresList
Expand Down

0 comments on commit ab35f1a

Please sign in to comment.