-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic TextureReplacement UI options. #8821
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1084,6 +1084,12 @@ void DeveloperToolsScreen::CreateViews() { | |
list->Add(new ItemHeader(dev->T("Language"))); | ||
list->Add(new Choice(dev->T("Load language ini")))->OnClick.Handle(this, &DeveloperToolsScreen::OnLoadLanguageIni); | ||
list->Add(new Choice(dev->T("Save language ini")))->OnClick.Handle(this, &DeveloperToolsScreen::OnSaveLanguageIni); | ||
list->Add(new ItemHeader(dev->T("Texture Replacement"))); | ||
list->Add(new CheckBox(&g_Config.bSaveNewTextures, dev->T("Save new textures"))); | ||
list->Add(new CheckBox(&g_Config.bReplaceTextures, dev->T("Replace textures"))); | ||
#if !defined(MOBILE_DEVICE) | ||
list->Add(new Choice(dev->T("Create/Open textures.ini file for current game")))->OnClick.Handle(this, &DeveloperToolsScreen::OnOpenTexturesIniFile); | ||
#endif | ||
list->Add(new ItemHeader("")); | ||
list->Add(new Choice(di->T("Back")))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack); | ||
} | ||
|
@@ -1137,6 +1143,74 @@ UI::EventReturn DeveloperToolsScreen::OnLoadLanguageIni(UI::EventParams &e) { | |
return UI::EVENT_DONE; | ||
} | ||
|
||
UI::EventReturn DeveloperToolsScreen::OnOpenTexturesIniFile(UI::EventParams &e) { | ||
std::string gameID = g_paramSFO.GetValueString("DISC_ID"); | ||
std::string texturesDirectory = GetSysDirectory(DIRECTORY_TEXTURES) + gameID + "/"; | ||
bool enabled_ = !gameID.empty(); | ||
if (enabled_) { | ||
if (!File::Exists(texturesDirectory)) { | ||
File::CreateFullPath(texturesDirectory); | ||
} | ||
if (!File::Exists(texturesDirectory + "textures.ini")) { | ||
FILE *f = File::OpenCFile(texturesDirectory + "textures.ini", "wb"); | ||
if (f) { | ||
fwrite("\xEF\xBB\xBF", 0, 3, f); | ||
fclose(f); | ||
} | ||
} | ||
enabled_ = File::Exists(texturesDirectory + "textures.ini"); | ||
} | ||
if (enabled_) { | ||
std::string texturesIniFile; | ||
#if defined(_WIN32) | ||
texturesIniFile = texturesDirectory + "textures.ini"; | ||
// Can't rely on a .txt file extension to auto-open in the right editor, | ||
// so let's find notepad | ||
wchar_t notepad_path[MAX_PATH + 1]; | ||
GetSystemDirectory(notepad_path, MAX_PATH); | ||
wcscat(notepad_path, L"\\notepad.exe"); | ||
|
||
wchar_t ini_path[MAX_PATH + 1] = { 0 }; | ||
wcsncpy(ini_path, ConvertUTF8ToWString(texturesIniFile).c_str(), MAX_PATH); | ||
// Flip any slashes... | ||
for (size_t i = 0; i < wcslen(ini_path); i++) { | ||
if (ini_path[i] == '/') | ||
ini_path[i] = '\\'; | ||
} | ||
|
||
// One for the space, one for the null. | ||
wchar_t command_line[MAX_PATH * 2 + 1 + 1]; | ||
wsprintf(command_line, L"%s %s", notepad_path, ini_path); | ||
|
||
STARTUPINFO si; | ||
memset(&si, 0, sizeof(si)); | ||
si.cb = sizeof(si); | ||
si.wShowWindow = SW_SHOW; | ||
PROCESS_INFORMATION pi; | ||
memset(&pi, 0, sizeof(pi)); | ||
UINT retval = CreateProcess(0, command_line, 0, 0, 0, 0, 0, 0, &si, &pi); | ||
if (!retval) { | ||
ERROR_LOG(COMMON, "Failed creating notepad process"); | ||
} | ||
CloseHandle(pi.hThread); | ||
CloseHandle(pi.hProcess); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should ideally factor this out into a common function for opening a text file, probably... I'm guessing this is repeated code from cheat inis. -[Unknown] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hopefully done correctly in #8822 |
||
#elif !defined(MOBILE_DEVICE) | ||
#if defined(__APPLE__) | ||
texturesIniFile = "open "; | ||
#else | ||
texturesIniFile = "xdg-open "; | ||
#endif | ||
texturesIniFile.append(texturesDirectory + "textures.ini"); | ||
NOTICE_LOG(BOOT, "Launching %s", texturesIniFile.c_str()); | ||
int retval = system(texturesIniFile.c_str()); | ||
if (retval != 0) { | ||
ERROR_LOG(COMMON, "Failed to launch textures.ini file"); | ||
} | ||
#endif | ||
} | ||
return UI::EVENT_DONE; | ||
} | ||
|
||
UI::EventReturn DeveloperToolsScreen::OnLogConfig(UI::EventParams &e) { | ||
screenManager()->push(new LogConfigScreen()); | ||
return UI::EVENT_DONE; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line should be outside the
#if
for Linux and friends.Nevermind, I see it's handled differently... okay.
-[Unknown]