Game list: check game location before updating settings file, code: misc. tweaks

This commit is contained in:
themitosan 2023-12-27 09:09:50 -03:00
parent b4aa5a9384
commit 024a044f92
13 changed files with 51 additions and 49 deletions

View file

@ -11,6 +11,7 @@ html, body {
color: #fff;
overflow: hidden;
user-select: none;
touch-action: none;
font-family: monospace;
scroll-behavior: smooth;
background-color: #0f1e3e;

View file

@ -31,19 +31,23 @@ temp_GAMELIST = {
gamepadMode: data.gamepadMode,
patchLocation: data.patchLocation,
importedModules: data.importedModules
};
// Check if title location exists
if (APP.fs.existsSync(data.path) === !0){
// Write file
try {
APP.fs.writeFileSync(data.path, JSON.stringify(gameSettings), 'utf8');
logMessage = APP.lang.getVariable('createdSettingsFile', [data.name]);
} catch (err) {
console.error(err);
logMessage = APP.lang.getVariable('errorCreateSettingsFile', [data.name, data.path, err]);
}
// Write file
try {
APP.fs.writeFileSync(data.path, JSON.stringify(gameSettings), 'utf8');
logMessage = APP.lang.getVariable('createdSettingsFile', [data.name]);
} catch (err) {
console.error(err);
logMessage = APP.lang.getVariable('errorCreateSettingsFile', [data.name, data.path, err]);
} else {
logMessage = APP.lang.getVariable('errorListUnableLocateGamePath', [data.name, data.path]);
APP.gameList.load();
}
// Log result
@ -59,7 +63,7 @@ temp_GAMELIST = {
logMessage = '',
tempData = APP.gameList.cGameSettings,
prevSettings = JSON.stringify(APP.gameList.cGameSettings),
fPath = APP.path.parse(this.list[this.selectedGame].exe).dir + '/launcherSettings.json';
fPath = `${APP.path.parse(this.list[this.selectedGame].exe).dir}/launcherSettings.json`;
/*
Update settings
@ -111,7 +115,8 @@ temp_GAMELIST = {
toggleGamePatch: function(){
// Get current game id
const cGame = this.selectedGame,
const
cGame = this.selectedGame,
listTop = document.getElementById('DIV_LIST_INTERNAL').scrollTop;
// Update GUI
@ -120,10 +125,8 @@ temp_GAMELIST = {
APP.design.update();
this.load();
// Select current game
// Select current game and update scroll
APP.design.selectGame(cGame);
// Update scroll
document.getElementById('DIV_LIST_INTERNAL').scrollTop = listTop;
},
@ -132,13 +135,13 @@ temp_GAMELIST = {
checkSdl2: function(){
// Check if gamepad mode is sdl2
if (document.getElementById("FPPS4_OPTIONS_SELECT_GAMEPAD_MODE").value === 'sdl2'){
if (document.getElementById('FPPS4_OPTIONS_SELECT_GAMEPAD_MODE').value === 'sdl2'){
// Get path for sdl2.dll and check if exists. If not, give an alert when its not found.
const
sdl2Path = APP.tools.fixPath(nw.__dirname) + "/Emu/SDL2.dll",
sdl2Path = `${APP.tools.fixPath(nw.__dirname)}/Emu/SDL2.dll`,
dllExists = APP.fs.existsSync(sdl2Path);
if (!dllExists) {
if (!dllExists){
window.alert(APP.lang.getVariable("Sdl2NotFound"));
}
@ -162,10 +165,8 @@ temp_GAMELIST = {
// Check if exists PARAM.SFO
if (APP.fs.existsSync(pLocation + '/sce_sys/param.sfo') === !0){
// Read PARAM.SFO
// Read PARAM.SFO and check if TITLE_ID matches current game
const getParamSfo = APP.paramSfo.parse(pLocation + '/sce_sys/param.sfo');
// Check if TITLE_ID matches current game
if (getParamSfo.TITLE_ID === cGame && getParamSfo.CATEGORY !== 'ac'){
// Set variables
@ -206,16 +207,10 @@ temp_GAMELIST = {
// Check if path exists
if (APP.fs.existsSync(APP.settings.data.gamePath) === !0){
// Reset selected game
this.selectedGame = '';
// Reset search box
document.getElementById('INPUT_gameListSearch').value = '';
// Reset game list
// Reset selected game, reset search box, reset game list and read game list path
APP.gameList.list = {};
// Get game list
this.selectedGame = '';
document.getElementById('INPUT_gameListSearch').value = '';
const gList = APP.fs.readdirSync(APP.settings.data.gamePath);
if (gList.length > 0){

View file

@ -111,8 +111,8 @@ temp_LANGUAGE = {
"dumpStatus_HB": "Homebrew",
"updateEmuWorkflow404": "ERROR - (Updater) Unable to locate selected CI workflow from fpPS4 GitHub!",
"updater_noWorkflowListAvailable": "No workflow list available",
"Sdl2NotFound": "SDL2.dll is not found in the Emu folder, please install it to use SDL2."
"Sdl2NotFound": "SDL2.dll is not found in the Emu folder, please install it to use SDL2.",
"errorListUnableLocateGamePath": "ERROR - Unable to locate \"%VARIABLE_0%\" settings path! In order to prevent issues, game list will be reloaded.\nPath: %VARIABLE_1%"
},
"title": {

View file

@ -19,10 +19,8 @@ temp_EMU_UPDATE = {
// If url was provided
if (url !== void 0 && navigator.onLine === !0 && typeof callback === 'function'){
// Get error message
// Get error message and fetch data
const errMsg = APP.lang.getVariable('updateEmuFetchActionsError');
// Fetch data
fetch(url).then(function(resp){
// Check if fetch status is ok
@ -54,17 +52,15 @@ temp_EMU_UPDATE = {
const processWorkflows = function(data){
// Variables
var htmlTemp = '<option disabled>' + APP.lang.getVariable('updater_noWorkflowListAvailable') + '</option>';
var htmlTemp = `<option disabled>${APP.lang.getVariable('updater_noWorkflowListAvailable')}</option>`;
// Check if data is provided
if (data !== void 0){
// Reset html temp
// Reset html temp and process workflow list
htmlTemp = '';
// Process workflow list
data.workflows.forEach(function(cData){
htmlTemp = htmlTemp + '<option value="' + cData.name + '">' + cData.name + '</option>';
htmlTemp = `${htmlTemp}<option value="${cData.name}">${cData.name}</option>`;
});
}

View file

@ -63,7 +63,8 @@
"dumpStatus_HB": "Homebrew",
"updateEmuWorkflow404": "ERREUR - (Mise à jour) N'a pas pu localiser une sélection CI dans la liste des flux de travail de GitHub !",
"updater_noWorkflowListAvailable": "Impossible d'obtenir la liste CI !",
"Sdl2NotFound": "Impossible de trouver SDL2.dll dans le dossier Emu, vérifiez s'il est là pour activer \"SDL\"."
"Sdl2NotFound": "Impossible de trouver SDL2.dll dans le dossier Emu, vérifiez s'il est là pour activer \"SDL\".",
"errorListUnableLocateGamePath": ""
},
"input_text": {

View file

@ -63,7 +63,8 @@
"dumpStatus_HB": "Homebrew",
"updateEmuWorkflow404": "ERRORE - Impossibile trovare l'elemento di configurazione principale nell'elenco dei workflows di fpPS4 su GitHub!",
"updater_noWorkflowListAvailable": "Impossibile ottenere l'elenco CI!",
"Sdl2NotFound": ""
"Sdl2NotFound": "",
"errorListUnableLocateGamePath": ""
},
"input_text": {

View file

@ -63,7 +63,8 @@
"dumpStatus_HB": "自作ソフト(Homebrew)",
"updateEmuWorkflow404": "",
"updater_noWorkflowListAvailable": "",
"Sdl2NotFound": ""
"Sdl2NotFound": "",
"errorListUnableLocateGamePath": ""
},
"input_text": {

View file

@ -63,7 +63,8 @@
"dumpStatus_HB": "Homebrew",
"updateEmuWorkflow404": "ERROR - (Updater) De geselecteerde CI workflow kon niet gevonden worden in de fpPS4 GitHub!",
"updater_noWorkflowListAvailable": "geen workflow lijst beschikbaar",
"Sdl2NotFound": "SDL2.dll is niet gevonden in de Emu map, installeer het om SDL2 te gebruiken."
"Sdl2NotFound": "SDL2.dll is niet gevonden in de Emu map, installeer het om SDL2 te gebruiken.",
"errorListUnableLocateGamePath": ""
},
"input_text": {

View file

@ -63,7 +63,8 @@
"dumpStatus_HB": "Homebrew",
"updateEmuWorkflow404": "ERRO - (Updater) Não foi possivel localizar a CI selecionada na lista de workflows do GitHub!",
"updater_noWorkflowListAvailable": "Não foi possivel obter lista de CI!",
"Sdl2NotFound": "Não foi possível encontrar SDL2.dll na pasta Emu, verifique se o mesmo se encontra lá para habilitar \"SDL\"."
"Sdl2NotFound": "Não foi possível encontrar SDL2.dll na pasta Emu, verifique se o mesmo se encontra lá para habilitar \"SDL\".",
"errorListUnableLocateGamePath": "ERRO - Não foi possível localizar a pasta de configurações para \"%VARIABLE_0%\"! Para prevenir erros, a lista de Apps / Games foi atualizada.\nCaminho: %VARIABLE_1%"
},
"input_text": {

View file

@ -63,7 +63,8 @@
"dumpStatus_HB": "",
"updateEmuWorkflow404": "ОШИБКА - (Обновления) Невозможно найти выбранный рабочий процесс на GitHub fpPS4!",
"updater_noWorkflowListAvailable": "Нет доступного списка рабочих процессов",
"Sdl2NotFound": "SDL2.dll не найден в папке Emu, пожалуйста установите его чтобы использовать SDL2."
"Sdl2NotFound": "SDL2.dll не найден в папке Emu, пожалуйста установите его чтобы использовать SDL2.",
"errorListUnableLocateGamePath": ""
},
"input_text": {

View file

@ -63,7 +63,8 @@
"dumpStatus_HB": "",
"updateEmuWorkflow404": "ПОМИЛКА - (Оновлення) Неможливо знайти обраний робочий процес на GitHub fpPS4!",
"updater_noWorkflowListAvailable": "Немає доступного списку робочих процесів",
"Sdl2NotFound": "SDL2.dll не знайдено в папці Emu, будь ласка встановіть його щоб використовувати SDL2."
"Sdl2NotFound": "SDL2.dll не знайдено в папці Emu, будь ласка встановіть його щоб використовувати SDL2.",
"errorListUnableLocateGamePath": ""
},
"input_text": {

View file

@ -63,7 +63,8 @@
"dumpStatus_HB": "自制",
"updateEmuWorkflow404": "ERROR - 无法在 fpPS4 GitHub 上找到当前选择的 CI Workflow",
"updater_noWorkflowListAvailable": "Workflow 列表无法读取",
"Sdl2NotFound": "模拟器文件夹中未发现 SDL2.dll , 请安装并使用 SDL2"
"Sdl2NotFound": "模拟器文件夹中未发现 SDL2.dll , 请安装并使用 SDL2",
"errorListUnableLocateGamePath": ""
},
"input_text": {

View file

@ -1,3 +1,5 @@
@echo off
color a
title Running fpPS4 Temmie's Launcher - Please wait...
echo Running fpPS4 Temmie's Launcher - Please wait...
start /b Nwjs\nw .