Skip to content

Commit

Permalink
Added PSPEMU Daedalus roms listing and custom roms path support.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinnegatamante committed Jun 30, 2020
1 parent 244218d commit 19289b8
Show file tree
Hide file tree
Showing 8 changed files with 183 additions and 58 deletions.
4 changes: 3 additions & 1 deletion Data/DaedalusX64/Languages/English.ini
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,6 @@ STR_ALERT_GAME_SETTINGS_LOAD=Game settings loaded successfully!
STR_ALERT_STATE_SAVE=Savestate saved successfully!
STR_ALERT_STATE_LOAD=Savestate loaded successfully!
STR_BIG_TEXT=Scale UI Texts
STR_ROM_LAUNCH=Launching ?ROMNAME?
STR_ROM_LAUNCH=Launching ?ROMNAME?
STR_CUSTOM_PATH=Custom Roms Path
STR_DLG_CUSTOM_PATH=Insert a custom Roms path to use
4 changes: 3 additions & 1 deletion Data/DaedalusX64/Languages/Italiano.ini
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,6 @@ STR_ALERT_GAME_SETTINGS_LOAD=Settaggi di gioco caricati con successo!
STR_ALERT_STATE_SAVE=Salvastato salvato con successo!
STR_ALERT_STATE_LOAD=Salvastato caricato con successo!
STR_BIG_TEXT=Scala testi della GUI
STR_ROM_LAUNCH=Avviando ?ROMNAME?
STR_ROM_LAUNCH=Avviando ?ROMNAME?
STR_CUSTOM_PATH=Path aggiuntiva delle Rom
STR_DLG_CUSTOM_PATH=Inserire una path aggiuntiva per le Rom da usare
27 changes: 16 additions & 11 deletions Source/SysVita/UI/MainMenuScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#define PREVIEW_WIDTH 387.0f
#define MIN(x,y) ((x) > (y) ? (y) : (x))

#define ROMS_FOLDERS_NUM 2
#define ROMS_FOLDERS_NUM 5

char selectedRom[256];

Expand Down Expand Up @@ -71,9 +71,19 @@ static int preview_width, preview_height, preview_x, preview_y;
CRefPtr<CNativeTexture> mpPreviewTexture;
GLuint preview_icon = 0;


int oldSortOrder = -1;

void resetRomList()
{
RomSelection *p = list;
while (p) {
RomSelection *old = p;
p = p->next;
free(old);
}
list = nullptr;
}

void swap(RomSelection *a, RomSelection *b)
{
char nametmp[128], pathtmp[256];
Expand Down Expand Up @@ -283,7 +293,10 @@ char *DrawRomSelector() {

const char *rom_folders[ROMS_FOLDERS_NUM] = {
DAEDALUS_VITA_PATH_EXT("ux0:" , "Roms/"),
DAEDALUS_VITA_PATH_EXT("uma0:", "Roms/")
DAEDALUS_VITA_PATH_EXT("uma0:", "Roms/"),
DAEDALUS_PSP_PATH_EXT("ux0:" , "Roms/"),
DAEDALUS_PSP_PATH_EXT("uma0:", "Roms/"),
gCustomRomPath
};

for (int i = 0; i < ROMS_FOLDERS_NUM; i++) {
Expand Down Expand Up @@ -404,14 +417,6 @@ char *DrawRomSelector() {
vglStopRendering();

if (selected) {
// NOTE: Uncomment this to make rom list to be re-built every time
/*p = list;
while (p) {
RomSelection *old = p;
p = p->next;
free(old);
}
list = nullptr;*/
CheatCodes_Read( hovered->settings.GameName.c_str(), "Daedalus.cht", hovered->id.CountryID );
return selectedRom;
}
Expand Down
15 changes: 11 additions & 4 deletions Source/SysVita/UI/Menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ enum {
};

// Translation strings
#define LANG_STRINGS_NUM 140
#define LANG_STRINGS_NUM 142

#define FOREACH_STR(FUNC) \
FUNC(STR_DOWNLOADER_COMPAT_LIST) \
Expand Down Expand Up @@ -195,7 +195,9 @@ enum {
FUNC(STR_ALERT_STATE_SAVE) \
FUNC(STR_ALERT_STATE_LOAD) \
FUNC(STR_BIG_TEXT) \
FUNC(STR_ROM_LAUNCH)
FUNC(STR_ROM_LAUNCH) \
FUNC(STR_CUSTOM_PATH) \
FUNC(STR_DLG_CUSTOM_PATH)

#define GET_VALUE(x) x,
#define GET_STRING(x) #x,
Expand All @@ -211,7 +213,8 @@ extern bool show_menubar;

// Dialog types
enum {
DIALOG_MESSAGE
DIALOG_MESSAGE,
DIALOG_KEYBOARD
};

// Alert types
Expand Down Expand Up @@ -258,9 +261,11 @@ extern int gSortOrder;
extern int gUiTheme;
extern int gAntiAliasing;
extern bool gBigText;
extern char gCustomRomPath[256];

extern bool pendingDialog;
extern bool pendingAlert;
extern bool custom_path_str_dirty;

char *DrawRomSelector();
void DrawInGameMenu();
Expand All @@ -277,6 +282,8 @@ void setUiTheme(int theme);
void setTranslation(int idx);
void setTexCacheMode(int mode);
void stripGameName(char *name);
void showDialog(char *text, void (*yes_func)(), void (*no_func)());
void showDialog(char *text, void (*yes_func)(), void (*no_func)(), int type);
void getDialogTextResult(char *text);
void showAlert(char *text, int type);
void reloadFont();
void resetRomList();
95 changes: 74 additions & 21 deletions Source/SysVita/UI/MenuBarScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@

#define MAX_SAVESLOT 9

void reset_ext_sampling_func () {
// Message Dialog sets back mode to SCE_CTRL_MODE_DIGITAL apparently
sceCtrlSetSamplingModeExt(SCE_CTRL_MODE_ANALOG_WIDE);
}

bool oldBigText = false;
int gLanguageIndex = SCE_SYSTEM_PARAM_LANG_ENGLISH_US;
int gUiTheme = DARK_THEME;
Expand All @@ -47,6 +42,9 @@ bool gTexturesDumper = false;
bool gUseHighResTextures = false;
bool gUseRearpad = false;

static char custom_path_str[512];
bool custom_path_str_dirty = true;

static bool cached_saveslots[MAX_SAVESLOT + 1];
static bool has_cached_saveslots = false;

Expand Down Expand Up @@ -82,6 +80,18 @@ float gamma_val = 1.0f;
char dbg_lines[MAX_DEBUG_LINES][256];
int cur_dbg_line = 0;

void saveCustomRomPath()
{
sceIoMkdir(DAEDALUS_VITA_PATH("Configs/"), 0777);

FILE *f = fopen(DAEDALUS_VITA_PATH("Configs/path.ini"), "w+");
if (f)
{
fprintf(f, gCustomRomPath);
fclose(f);
}
}

void saveConfig(const char *game)
{
char tmp[128];
Expand Down Expand Up @@ -140,6 +150,18 @@ void save_and_restart_func() {
sceAppMgrLoadExec("app0:eboot.bin", NULL, NULL);
}

void reset_ext_sampling_func () {
// Message Dialog sets back mode to SCE_CTRL_MODE_DIGITAL apparently
sceCtrlSetSamplingModeExt(SCE_CTRL_MODE_ANALOG_WIDE);
}

void change_custom_rom_path () {
getDialogTextResult(gCustomRomPath);
saveCustomRomPath();
resetRomList();
custom_path_str_dirty = true;
}

void SetupVFlux() {
colors = (float*)malloc(sizeof(float)*4*4);
vertices = (float*)malloc(sizeof(float)*3*4);
Expand Down Expand Up @@ -300,15 +322,15 @@ void DrawCommonMenuBar() {
SetDescription(lang_strings[STR_DESC_BILINEAR]);
if (ImGui::BeginMenu(lang_strings[STR_ANTI_ALIASING])){
if (ImGui::MenuItem(lang_strings[STR_DISABLED], nullptr, gAntiAliasing == ANTIALIASING_DISABLED)){
if (gAntiAliasing != ANTIALIASING_DISABLED) showDialog(lang_strings[STR_REBOOT_REQ], save_and_restart_func, reset_ext_sampling_func);
if (gAntiAliasing != ANTIALIASING_DISABLED) showDialog(lang_strings[STR_REBOOT_REQ], save_and_restart_func, reset_ext_sampling_func, DIALOG_MESSAGE);
gAntiAliasing = ANTIALIASING_DISABLED;
}
if (ImGui::MenuItem("MSAA 2x", nullptr, gAntiAliasing == ANTIALIASING_MSAA_2X)){
if (gAntiAliasing != ANTIALIASING_MSAA_2X) showDialog(lang_strings[STR_REBOOT_REQ], save_and_restart_func, reset_ext_sampling_func);
if (gAntiAliasing != ANTIALIASING_MSAA_2X) showDialog(lang_strings[STR_REBOOT_REQ], save_and_restart_func, reset_ext_sampling_func, DIALOG_MESSAGE);
gAntiAliasing = ANTIALIASING_MSAA_2X;
}
if (ImGui::MenuItem("MSAA 4x", nullptr, gAntiAliasing == ANTIALIASING_MSAA_4X)){
if (gAntiAliasing != ANTIALIASING_MSAA_4X) showDialog(lang_strings[STR_REBOOT_REQ], save_and_restart_func, reset_ext_sampling_func);
if (gAntiAliasing != ANTIALIASING_MSAA_4X) showDialog(lang_strings[STR_REBOOT_REQ], save_and_restart_func, reset_ext_sampling_func, DIALOG_MESSAGE);
gAntiAliasing = ANTIALIASING_MSAA_4X;
}
ImGui::EndMenu();
Expand Down Expand Up @@ -593,18 +615,41 @@ void DrawPendingAlert() {

void DrawPendingDialog() {
if (pendingDialog) {
while (sceMsgDialogGetStatus() != SCE_COMMON_DIALOG_STATUS_FINISHED) {
vglStopRenderingInit();
vglUpdateCommonDialog();
vglStopRenderingTerm();
vglStartRendering();
}
SceMsgDialogResult res;
memset(&res, 0, sizeof(SceMsgDialogResult));
sceMsgDialogGetResult(&res);
if (res.buttonId == SCE_MSG_DIALOG_BUTTON_ID_NO) cur_dialog.no_func();
else if (res.buttonId == SCE_MSG_DIALOG_BUTTON_ID_YES) cur_dialog.yes_func();
sceMsgDialogTerm();
switch(cur_dialog.type) {
case DIALOG_MESSAGE:
{
while (sceMsgDialogGetStatus() != SCE_COMMON_DIALOG_STATUS_FINISHED) {
vglStopRenderingInit();
vglUpdateCommonDialog();
vglStopRenderingTerm();
vglStartRendering();
}
SceMsgDialogResult res;
memset(&res, 0, sizeof(SceMsgDialogResult));
sceMsgDialogGetResult(&res);
if (res.buttonId == SCE_MSG_DIALOG_BUTTON_ID_NO) cur_dialog.no_func();
else if (res.buttonId == SCE_MSG_DIALOG_BUTTON_ID_YES) cur_dialog.yes_func();
sceMsgDialogTerm();
}
case DIALOG_KEYBOARD:
{
while (sceImeDialogGetStatus() != SCE_COMMON_DIALOG_STATUS_FINISHED) {
vglStopRenderingInit();
vglUpdateCommonDialog();
vglStopRenderingTerm();
vglStartRendering();
}
SceImeDialogResult res;
memset(&res, 0, sizeof(SceImeDialogResult));
sceImeDialogGetResult(&res);
if (res.button == SCE_IME_DIALOG_BUTTON_ENTER) cur_dialog.yes_func();
else cur_dialog.no_func();
sceImeDialogTerm();
}
default:
break;
}

pendingDialog = false;
}
}
Expand All @@ -618,10 +663,18 @@ void DrawMenuBar() {
oldBigText = gBigText;
}

if (custom_path_str_dirty) {
sprintf(custom_path_str, "%s: %s", lang_strings[STR_CUSTOM_PATH], strlen(gCustomRomPath) > 1 ? gCustomRomPath : lang_strings[STR_UNUSED]);
custom_path_str_dirty = false;
}

ImGui_ImplVitaGL_NewFrame();

if (ImGui::BeginMainMenuBar()){
if (ImGui::BeginMenu(lang_strings[STR_MENU_OPTIONS])){
if (ImGui::BeginMenu(lang_strings[STR_MENU_OPTIONS])) {
if (ImGui::MenuItem(custom_path_str)) {
showDialog(lang_strings[STR_DLG_CUSTOM_PATH], change_custom_rom_path, reset_ext_sampling_func, DIALOG_KEYBOARD);
}
if (ImGui::BeginMenu(lang_strings[STR_MENU_SORT_ROMS])){
if (ImGui::MenuItem(lang_strings[STR_SORT_A_TO_Z], nullptr, gSortOrder == SORT_A_TO_Z)){
gSortOrder = SORT_A_TO_Z;
Expand Down
4 changes: 3 additions & 1 deletion Source/SysVita/UI/TranslationStrings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,7 @@ char lang_strings[][256] = {
"Savestate saved successfully!", // STR_ALERT_STATE_SAVE
"Savestate loaded successfully!", // STR_ALERT_STATE_LOAD
"Scale UI Texts", // STR_BIG_TEXT
"Launching ?ROMNAME?" // STR_ROM_LAUNCH
"Launching ?ROMNAME?", // STR_ROM_LAUNCH
"Custom Roms Path", // STR_CUSTOM_PATH
"Insert a custom Roms path to use" // STR_DLG_CUSTOM_PATH
};
Loading

0 comments on commit 19289b8

Please sign in to comment.