@@ -1084,6 +1084,12 @@ void DeveloperToolsScreen::CreateViews() {
1084
1084
list->Add (new ItemHeader (dev->T (" Language" )));
1085
1085
list->Add (new Choice (dev->T (" Load language ini" )))->OnClick .Handle (this , &DeveloperToolsScreen::OnLoadLanguageIni);
1086
1086
list->Add (new Choice (dev->T (" Save language ini" )))->OnClick .Handle (this , &DeveloperToolsScreen::OnSaveLanguageIni);
1087
+ list->Add (new ItemHeader (dev->T (" Texture Replacement" )));
1088
+ list->Add (new CheckBox (&g_Config.bSaveNewTextures , dev->T (" Save new textures" )));
1089
+ list->Add (new CheckBox (&g_Config.bReplaceTextures , dev->T (" Replace textures" )));
1090
+ #if !defined(MOBILE_DEVICE)
1091
+ list->Add (new Choice (dev->T (" Create/Open textures.ini file for current game" )))->OnClick .Handle (this , &DeveloperToolsScreen::OnOpenTexturesIniFile);
1092
+ #endif
1087
1093
list->Add (new ItemHeader (" " ));
1088
1094
list->Add (new Choice (di->T (" Back" )))->OnClick .Handle <UIScreen>(this , &UIScreen::OnBack);
1089
1095
}
@@ -1137,6 +1143,74 @@ UI::EventReturn DeveloperToolsScreen::OnLoadLanguageIni(UI::EventParams &e) {
1137
1143
return UI::EVENT_DONE;
1138
1144
}
1139
1145
1146
+ UI::EventReturn DeveloperToolsScreen::OnOpenTexturesIniFile (UI::EventParams &e) {
1147
+ std::string gameID = g_paramSFO.GetValueString (" DISC_ID" );
1148
+ std::string texturesDirectory = GetSysDirectory (DIRECTORY_TEXTURES) + gameID + " /" ;
1149
+ bool enabled_ = !gameID.empty ();
1150
+ if (enabled_) {
1151
+ if (!File::Exists (texturesDirectory)) {
1152
+ File::CreateFullPath (texturesDirectory);
1153
+ }
1154
+ if (!File::Exists (texturesDirectory + " textures.ini" )) {
1155
+ FILE *f = File::OpenCFile (texturesDirectory + " textures.ini" , " wb" );
1156
+ if (f) {
1157
+ fwrite (" \xEF\xBB\xBF " , 0 , 3 , f);
1158
+ fclose (f);
1159
+ }
1160
+ }
1161
+ enabled_ = File::Exists (texturesDirectory + " textures.ini" );
1162
+ }
1163
+ if (enabled_) {
1164
+ std::string texturesIniFile;
1165
+ #if defined(_WIN32)
1166
+ texturesIniFile = texturesDirectory + " textures.ini" ;
1167
+ // Can't rely on a .txt file extension to auto-open in the right editor,
1168
+ // so let's find notepad
1169
+ wchar_t notepad_path[MAX_PATH + 1 ];
1170
+ GetSystemDirectory (notepad_path, MAX_PATH);
1171
+ wcscat (notepad_path, L" \\ notepad.exe" );
1172
+
1173
+ wchar_t ini_path[MAX_PATH + 1 ] = { 0 };
1174
+ wcsncpy (ini_path, ConvertUTF8ToWString (texturesIniFile).c_str (), MAX_PATH);
1175
+ // Flip any slashes...
1176
+ for (size_t i = 0 ; i < wcslen (ini_path); i++) {
1177
+ if (ini_path[i] == ' /' )
1178
+ ini_path[i] = ' \\ ' ;
1179
+ }
1180
+
1181
+ // One for the space, one for the null.
1182
+ wchar_t command_line[MAX_PATH * 2 + 1 + 1 ];
1183
+ wsprintf (command_line, L" %s %s" , notepad_path, ini_path);
1184
+
1185
+ STARTUPINFO si;
1186
+ memset (&si, 0 , sizeof (si));
1187
+ si.cb = sizeof (si);
1188
+ si.wShowWindow = SW_SHOW;
1189
+ PROCESS_INFORMATION pi ;
1190
+ memset (&pi , 0 , sizeof (pi ));
1191
+ UINT retval = CreateProcess (0 , command_line, 0 , 0 , 0 , 0 , 0 , 0 , &si, &pi );
1192
+ if (!retval) {
1193
+ ERROR_LOG (COMMON, " Failed creating notepad process" );
1194
+ }
1195
+ CloseHandle (pi .hThread );
1196
+ CloseHandle (pi .hProcess );
1197
+ #elif !defined(MOBILE_DEVICE)
1198
+ #if defined(__APPLE__)
1199
+ texturesIniFile = " open " ;
1200
+ #else
1201
+ texturesIniFile = " xdg-open " ;
1202
+ #endif
1203
+ texturesIniFile.append (texturesDirectory + " textures.ini" ;);
1204
+ NOTICE_LOG (BOOT, " Launching %s" , texturesIniFile.c_str ());
1205
+ int retval = system (texturesIniFile.c_str ());
1206
+ if (retval != 0 ) {
1207
+ ERROR_LOG (COMMON, " Failed to launch textures.ini file" );
1208
+ }
1209
+ #endif
1210
+ }
1211
+ return UI::EVENT_DONE;
1212
+ }
1213
+
1140
1214
UI::EventReturn DeveloperToolsScreen::OnLogConfig (UI::EventParams &e) {
1141
1215
screenManager ()->push (new LogConfigScreen ());
1142
1216
return UI::EVENT_DONE;
0 commit comments