Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion source/settings/CGameSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ GameCFG * CGameSettings::GetGameCFG(const char * id)
if(!id)
{
DefaultConfig.id[0] = '\0';
DefaultConfig.GameTitle.clear();
return &DefaultConfig;
}

Expand All @@ -59,6 +60,8 @@ GameCFG * CGameSettings::GetGameCFG(const char * id)
}

memcpy(DefaultConfig.id, id, 6);
// Ensure the default config doesn't carry over a title from a previous lookup
DefaultConfig.GameTitle.clear();

return &DefaultConfig;
}
Expand Down Expand Up @@ -252,7 +255,8 @@ bool CGameSettings::Save()
fprintf(f, "DEVODiscDelay:%d; ", GameList[i].DEVODiscDelay);
fprintf(f, "PrivateServer:%d; ", GameList[i].PrivateServer);
fprintf(f, "CustomAddress:%s; ", GameList[i].CustomAddress.c_str());
fprintf(f, "Locked:%d;\n", GameList[i].Locked);
fprintf(f, "Locked:%d; ", GameList[i].Locked);
fprintf(f, "gametitle:%s;\n", GameList[i].GameTitle.c_str());
}
fprintf(f, "# END\n");
fclose(f);
Expand Down Expand Up @@ -608,6 +612,11 @@ bool CGameSettings::SetSetting(GameCFG & game, const char *name, const char *val
game.CustomAddress = value;
return true;
}
else if(strcmp(name, "gametitle") == 0)
{
game.GameTitle = value;
return true;
}

return false;
}
Expand Down Expand Up @@ -778,4 +787,5 @@ void CGameSettings::SetDefault(GameCFG &game)
game.PrivateServer = INHERIT;
game.CustomAddress.clear();
game.Locked = OFF;
game.GameTitle.clear();
}
9 changes: 9 additions & 0 deletions source/settings/CGameSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ typedef struct _GameCFG
short PrivateServer;
std::string CustomAddress;
short Locked;
std::string GameTitle;

_GameCFG() {}

_GameCFG(const struct _GameCFG &game)
{
*this = game;
}

void operator=(const struct _GameCFG &game)
{
Expand Down Expand Up @@ -152,6 +160,7 @@ typedef struct _GameCFG
this->PrivateServer = game.PrivateServer;
this->CustomAddress = game.CustomAddress;
this->Locked = game.Locked;
this->GameTitle = game.GameTitle;
}
} GameCFG;

Expand Down
11 changes: 11 additions & 0 deletions source/settings/GameTitles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "GameTitles.h"
#include "CSettings.h"
#include "CGameSettings.h"
#include "usbloader/GameList.h"
#include "Channels/channels.h"
#include "xml/GameTDB.hpp"
Expand Down Expand Up @@ -58,6 +59,11 @@ const char *CGameTitles::GetTitle(const char *id, bool allow_access) const
if (!id)
return "";

// Check manual override from CGameSettings first
GameCFG *cfg = GameSettings.GetGameCFG(id);
if(cfg && !cfg->GameTitle.empty())
return cfg->GameTitle.c_str();

auto game = std::lower_bound(TitleList.begin(), TitleList.end(), id, [](const GameTitle &gt, const char *gameid)
{ return (strncasecmp(gt.GameID, gameid, 6) < 0); });
if (game != TitleList.end())
Expand All @@ -83,6 +89,11 @@ const char *CGameTitles::GetTitle(const struct discHdr *header) const
if (!header)
return "";

// Check manual override from CGameSettings first
GameCFG *cfg = GameSettings.GetGameCFG(header->id);
if(cfg && !cfg->GameTitle.empty())
return cfg->GameTitle.c_str();

auto game = std::lower_bound(TitleList.begin(), TitleList.end(), (const char *)header->id, [](const GameTitle &gt, const char *gameid)
{ return (strncasecmp(gt.GameID, gameid, 6) < 0); });
if (game != TitleList.end())
Expand Down
44 changes: 44 additions & 0 deletions source/settings/menus/GameSettingsMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void GameSettingsMenu::SetupMainButtons()
int pos = 0;

SetMainButton(pos++, tr( "Game Load" ), MainButtonImgData, MainButtonImgOverData);
SetMainButton(pos++, tr( "Rename Game" ), MainButtonImgData, MainButtonImgOverData);
SetMainButton(pos++, tr( "Ocarina" ), MainButtonImgData, MainButtonImgOverData);
SetMainButton(pos++, tr( "Categories" ), MainButtonImgData, MainButtonImgOverData);
if( DiscHeader->type == TYPE_GAME_WII_IMG
Expand Down Expand Up @@ -107,6 +108,49 @@ void GameSettingsMenu::CreateSettingsMenu(int menuNr)
Append(CurrentMenu);
}

//! Rename Game
else if(menuNr == Idx++)
{
if (!Settings.godmode && (Settings.ParentalBlocks & BLOCK_GAME_SETTINGS))
{
WindowPrompt(tr( "Permission denied." ), tr( "Console must be unlocked for this option." ), tr( "OK" ));
return;
}

char entered[100];
snprintf(entered, sizeof(entered), "%s", GameTitles.GetTitle(DiscHeader));

int ret = OnScreenKeyboard(entered, sizeof(entered), 0);
if(ret)
{
GameCFG * game = GameSettings.GetGameCFG(DiscHeader->id);
if(game)
{
// Create a copy to ensure we don't modify the DefaultConfig pointer directly
// and to ensure we add the new config to the persistent list.
GameCFG GameConfig = *game;
GameConfig.GameTitle = entered;

GameSettings.AddGame(GameConfig);
GameSettings.Save();

// Update the title in memory immediately so it reflects in the GUI
GameTitles.SetGameTitle((const char *)DiscHeader->id, entered, TITLETYPE_MANUAL_OVERRIDE, "NULL", -1, 1);

// Update the menu header
MenuTitle = entered;
if(titleTxt)
titleTxt->SetText(entered);

// Sort the list so the new name moves to the correct alphabetical position
gameList.SortList();

// Refresh browser list on exit
browserMenu->ReloadBrowser();
}
}
}

//! Ocarina
else if(menuNr == Idx++)
{
Expand Down