From a5a8e75c2265e6eba397ad65a094e47432c5585d Mon Sep 17 00:00:00 2001 From: cpasjuste Date: Tue, 12 Sep 2023 10:22:43 +0200 Subject: [PATCH 01/63] windows: fix building --- libcross2d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcross2d b/libcross2d index c7db1d84..83030422 160000 --- a/libcross2d +++ b/libcross2d @@ -1 +1 @@ -Subproject commit c7db1d84dd195b7cca6b211d1d103b4d406d6a80 +Subproject commit 83030422d58ad7e40e1ddfdf5b610e0c5af0daaa From e849314813f9fd13f87543e631a06cdf3d636802 Mon Sep 17 00:00:00 2001 From: cpasjuste Date: Tue, 12 Sep 2023 10:44:02 +0200 Subject: [PATCH 02/63] cmake: bump cmake_minimum_required to 3.5 --- CMakeLists.txt | 2 +- libcross2d | 2 +- pfbneo/CMakeLists.txt | 2 +- pgen/CMakeLists.txt | 2 +- pnes/CMakeLists.txt | 2 +- psnes/CMakeLists.txt | 2 +- sscrap | 2 +- ui/CMakeLists.txt | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c51b1f56..6e6d9ac6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.5) #set(CMAKE_VERBOSE_MAKEFILE ON) # add libcross2d library. If you want to port pfba to another platform, diff --git a/libcross2d b/libcross2d index 83030422..efa4c82f 160000 --- a/libcross2d +++ b/libcross2d @@ -1 +1 @@ -Subproject commit 83030422d58ad7e40e1ddfdf5b610e0c5af0daaa +Subproject commit efa4c82f46e8f0042fde94bbcc084861d000b179 diff --git a/pfbneo/CMakeLists.txt b/pfbneo/CMakeLists.txt index bbaae7d9..2a2df1d0 100644 --- a/pfbneo/CMakeLists.txt +++ b/pfbneo/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.5) #set(CMAKE_VERBOSE_MAKEFILE ON) project(pfbneo) diff --git a/pgen/CMakeLists.txt b/pgen/CMakeLists.txt index 62b63149..5a0e82d3 100644 --- a/pgen/CMakeLists.txt +++ b/pgen/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.5) #set(CMAKE_VERBOSE_MAKEFILE ON) project(pgen) diff --git a/pnes/CMakeLists.txt b/pnes/CMakeLists.txt index 331a6a83..a9ad43ac 100644 --- a/pnes/CMakeLists.txt +++ b/pnes/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.5) #set(CMAKE_VERBOSE_MAKEFILE ON) project(pnes) diff --git a/psnes/CMakeLists.txt b/psnes/CMakeLists.txt index 10c71aae..0238b842 100644 --- a/psnes/CMakeLists.txt +++ b/psnes/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.5) #set(CMAKE_VERBOSE_MAKEFILE ON) project(psnes) diff --git a/sscrap b/sscrap index a5635cab..d903e652 160000 --- a/sscrap +++ b/sscrap @@ -1 +1 @@ -Subproject commit a5635cab67bf1934422c0667928019efa8427536 +Subproject commit d903e65252cfae021e8799e4e7ea4505a7037c6e diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt index f8253058..5e6a4805 100644 --- a/ui/CMakeLists.txt +++ b/ui/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.5) #set(CMAKE_VERBOSE_MAKEFILE ON) project(cross2dui) From 95f1bd8f8898bddb8ef00fde55eae74c83e69a86 Mon Sep 17 00:00:00 2001 From: cpasjuste Date: Wed, 13 Sep 2023 11:10:04 +0200 Subject: [PATCH 03/63] windows/linux: fix fullscreen on/off option --- libcross2d | 2 +- pfbneo/sources/config.cpp | 30 +- pfbneo/sources/config.h | 2 +- pfbneo/sources/main.cpp | 229 ++++---- pgen/sources/main.cpp | 203 +++---- pgen/sources/pgen_config.cpp | 56 +- pgen/sources/pgen_config.h | 36 +- pnes/sources/main.cpp | 13 +- pnes/sources/pnes_config.cpp | 2 +- pnes/sources/pnes_config.h | 2 +- psnes/sources/config.cpp | 2 +- psnes/sources/config.h | 2 +- psnes/sources/main.cpp | 13 +- ui/c2dui_config.cpp | 1029 +++++++++++++++++----------------- ui/c2dui_config.h | 4 +- ui/c2dui_option.h | 346 ++++++------ ui/c2dui_ui_main.cpp | 392 ++++++------- ui/c2dui_ui_main.h | 5 +- ui/c2dui_ui_menu.cpp | 842 ++++++++++++++-------------- 19 files changed, 1612 insertions(+), 1598 deletions(-) diff --git a/libcross2d b/libcross2d index efa4c82f..cd5f961c 160000 --- a/libcross2d +++ b/libcross2d @@ -1 +1 @@ -Subproject commit efa4c82f46e8f0042fde94bbcc084861d000b179 +Subproject commit cd5f961cde7c2a86987a47d54f91bc7ea51c83ff diff --git a/pfbneo/sources/config.cpp b/pfbneo/sources/config.cpp index cd86de1d..631283b7 100644 --- a/pfbneo/sources/config.cpp +++ b/pfbneo/sources/config.cpp @@ -9,25 +9,25 @@ using namespace c2d; using namespace c2dui; -PFBAConfig::PFBAConfig(UiMain *ui, int version) : Config(ui, version) { +PFBAConfig::PFBAConfig(c2d::Io *io, int version) : Config(io, version) { printf("PFBAConfig(%s, v%i)\n", getConfigPath().c_str(), version); #ifndef __PFBN_LIGHT__ // add fba default roms paths - roms_paths.emplace_back(ui->getIo()->getDataPath() + "channelf/"); - roms_paths.emplace_back(ui->getIo()->getDataPath() + "coleco/"); - roms_paths.emplace_back(ui->getIo()->getDataPath() + "fds/"); - roms_paths.emplace_back(ui->getIo()->getDataPath() + "gamegear/"); - roms_paths.emplace_back(ui->getIo()->getDataPath() + "megadrive/"); - roms_paths.emplace_back(ui->getIo()->getDataPath() + "msx/"); - roms_paths.emplace_back(ui->getIo()->getDataPath() + "nes/"); - roms_paths.emplace_back(ui->getIo()->getDataPath() + "ngp/"); - roms_paths.emplace_back(ui->getIo()->getDataPath() + "pce/"); - roms_paths.emplace_back(ui->getIo()->getDataPath() + "sg1000/"); - roms_paths.emplace_back(ui->getIo()->getDataPath() + "sgx/"); - roms_paths.emplace_back(ui->getIo()->getDataPath() + "sms/"); - roms_paths.emplace_back(ui->getIo()->getDataPath() + "spectrum/"); - roms_paths.emplace_back(ui->getIo()->getDataPath() + "tg16/"); + roms_paths.emplace_back(io->getDataPath() + "channelf/"); + roms_paths.emplace_back(io->getDataPath() + "coleco/"); + roms_paths.emplace_back(io->getDataPath() + "fds/"); + roms_paths.emplace_back(io->getDataPath() + "gamegear/"); + roms_paths.emplace_back(io->getDataPath() + "megadrive/"); + roms_paths.emplace_back(io->getDataPath() + "msx/"); + roms_paths.emplace_back(io->getDataPath() + "nes/"); + roms_paths.emplace_back(io->getDataPath() + "ngp/"); + roms_paths.emplace_back(io->getDataPath() + "pce/"); + roms_paths.emplace_back(io->getDataPath() + "sg1000/"); + roms_paths.emplace_back(io->getDataPath() + "sgx/"); + roms_paths.emplace_back(io->getDataPath() + "sms/"); + roms_paths.emplace_back(io->getDataPath() + "spectrum/"); + roms_paths.emplace_back(io->getDataPath() + "tg16/"); #endif //////////////////////////////////////////////////////////// diff --git a/pfbneo/sources/config.h b/pfbneo/sources/config.h index 0996f61b..afc585e4 100644 --- a/pfbneo/sources/config.h +++ b/pfbneo/sources/config.h @@ -11,7 +11,7 @@ class PFBAConfig : public c2dui::Config { public: - PFBAConfig(UiMain *ui, int version); + PFBAConfig(c2d::Io *io, int version); }; diff --git a/pfbneo/sources/main.cpp b/pfbneo/sources/main.cpp index 0fb3012b..89ae8c3f 100644 --- a/pfbneo/sources/main.cpp +++ b/pfbneo/sources/main.cpp @@ -1,112 +1,117 @@ -/* - * FinalBurn Alpha - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "burner.h" - -#include "c2dui.h" -#include "uiEmu.h" -#include "uiMenu.h" -#include "config.h" -#include "uiStateMenu.h" -#include "pfba_io.h" -#include "romlist.h" - -using namespace c2d; -using namespace c2dui; - -#ifdef __PSP2__ - -#include - -#elif __PS4__ -extern "C" int sceSystemServiceLoadExec(const char *path, const char *args[]); -#endif - -UiMain *ui; -PFBAGuiMenu *uiMenu; -PFBAUiEmu *uiEmu; -PFBAUIStateMenu *uiState; -PFBAConfig *cfg; -PFBARomList *romList; -UIRomList *uiRomList; -Skin *skin; - -void BurnPathsInit(C2DIo *io); - -int main(int argc, char **argv) { -#ifdef __PSP2__ - // set max cpu speed - scePowerSetArmClockFrequency(444); - scePowerSetBusClockFrequency(222); - scePowerSetGpuClockFrequency(222); - scePowerSetGpuXbarClockFrequency(166); -#endif - - // need custom io for some devices - auto io = new PFBAIo(); - // fbneo init - BurnPathsInit(io); - BurnLibInit(); - - // create main ui - ui = new UiMain(io); - - // load custom configuration - int version = (__PFBA_VERSION_MAJOR__ * 100) + __PFBA_VERSION_MINOR__; - cfg = new PFBAConfig(ui, version); - ui->setConfig(cfg); - - // load skin configuration - skin = new Skin(ui); - ui->setSkin(skin); - - // ui - std::string fba_version = "fbneo: "; - fba_version += szAppBurnVer; - romList = new PFBARomList(ui, fba_version, {".zip"}); - romList->build(); - uiRomList = new UIRomList(ui, romList, ui->getSize()); - uiMenu = new PFBAGuiMenu(ui); - uiEmu = new PFBAUiEmu(ui); - uiState = new PFBAUIStateMenu(ui); - ui->init(uiRomList, uiMenu, uiEmu, uiState); - - while (!ui->done) { - ui->flip(); - } - - // quit - BurnLibExit(); - - delete (skin); - delete (cfg); - delete (ui); - -#ifdef __PSP2__ - scePowerSetArmClockFrequency(266); - scePowerSetBusClockFrequency(166); - scePowerSetGpuClockFrequency(166); - scePowerSetGpuXbarClockFrequency(111); -#elif __PS4__ - sceSystemServiceLoadExec((char *) "exit", nullptr); - while (true) {} -#endif - - return 0; -} +/* + * FinalBurn Alpha + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "burner.h" + +#include "c2dui.h" +#include "uiEmu.h" +#include "uiMenu.h" +#include "config.h" +#include "uiStateMenu.h" +#include "pfba_io.h" +#include "romlist.h" + +using namespace c2d; +using namespace c2dui; + +#ifdef __PSP2__ + +#include + +#elif __PS4__ +extern "C" int sceSystemServiceLoadExec(const char *path, const char *args[]); +#endif + +UiMain *ui; +PFBAGuiMenu *uiMenu; +PFBAUiEmu *uiEmu; +PFBAUIStateMenu *uiState; +PFBAConfig *cfg; +PFBARomList *romList; +UIRomList *uiRomList; +Skin *skin; + +void BurnPathsInit(C2DIo *io); + +int main(int argc, char **argv) { +#ifdef __PSP2__ + // set max cpu speed + scePowerSetArmClockFrequency(444); + scePowerSetBusClockFrequency(222); + scePowerSetGpuClockFrequency(222); + scePowerSetGpuXbarClockFrequency(166); +#endif + + // need custom io for some devices + auto io = new PFBAIo(); + // fbneo init + BurnPathsInit(io); + BurnLibInit(); + + // load custom configuration + int version = (__PFBA_VERSION_MAJOR__ * 100) + __PFBA_VERSION_MINOR__; + cfg = new PFBAConfig(io, version); + + // create main ui + Option *fs = cfg->get(Option::Id::GUI_FULLSCREEN); + if (fs && !fs->getValueBool()) { + ui = new UiMain(io, {1280, 720}); + } else { + ui = new UiMain(io); + } + ui->setConfig(cfg); + + // load skin configuration + skin = new Skin(ui); + ui->setSkin(skin); + + // ui + std::string fba_version = "fbneo: "; + fba_version += szAppBurnVer; + romList = new PFBARomList(ui, fba_version, {".zip"}); + romList->build(); + uiRomList = new UIRomList(ui, romList, ui->getSize()); + uiMenu = new PFBAGuiMenu(ui); + uiEmu = new PFBAUiEmu(ui); + uiState = new PFBAUIStateMenu(ui); + ui->init(uiRomList, uiMenu, uiEmu, uiState); + + while (!ui->done) { + ui->flip(); + } + + // quit + BurnLibExit(); + + delete (skin); + delete (cfg); + delete (ui); + +#ifdef __PSP2__ + scePowerSetArmClockFrequency(266); + scePowerSetBusClockFrequency(166); + scePowerSetGpuClockFrequency(166); + scePowerSetGpuXbarClockFrequency(111); +#elif __PS4__ + sceSystemServiceLoadExec((char *) "exit", nullptr); + while (true) {} +#endif + + return 0; +} diff --git a/pgen/sources/main.cpp b/pgen/sources/main.cpp index e9b21102..cf4d45aa 100644 --- a/pgen/sources/main.cpp +++ b/pgen/sources/main.cpp @@ -1,99 +1,104 @@ -// -// Created by cpasjuste on 22/11/16. -// - -#include "c2dui.h" -#include "pgen_ui_emu.h" -#include "pgen_io.h" -#include "pgen_config.h" -#include "pgen_romlist.h" -#include "pgen_ui_statemenu.h" -#include "osd.h" - -using namespace c2d; -using namespace c2dui; - -#ifdef __PSP2__ -#include -#include -#define mkdir(x, y) sceIoMkdir(x, 0777) -#elif __PS4__ -extern "C" int sceSystemServiceLoadExec(const char *path, const char *args[]); -#endif - -UiMenu *uiMenu; -PGENUiEmu *uiEmu; -PGENConfig *cfg; -PGENRomList *romList; -PGENUIStateMenu *uiState; - -UiMain *ui; -Skin *skin; -UIRomList *uiRomList; - -int main(int argc, char **argv) { -#ifdef __PSP2__ - // set max cpu speed - scePowerSetArmClockFrequency(444); - scePowerSetBusClockFrequency(222); - scePowerSetGpuClockFrequency(222); - scePowerSetGpuXbarClockFrequency(166); -#endif - - // need custom io for some devices - auto *io = new PGENIo(); - // create paths - io->create(io->getDataPath()); - io->create(io->getDataPath() + "bios"); - io->create(io->getDataPath() + "rams"); - io->create(io->getDataPath() + "configs"); - io->create(io->getDataPath() + "saves"); - io->create(io->getDataPath() + "megadrive"); - io->create(io->getDataPath() + "sms"); - io->create(io->getDataPath() + "gamegear"); - io->create(io->getDataPath() + "megacd"); - - // create main ui - ui = new UiMain(io); - - // load custom configuration - int pgen_version = (__PGEN_VERSION_MAJOR__ * 100) + __PGEN_VERSION_MINOR__; - cfg = new PGENConfig(ui, pgen_version); - ui->setConfig(cfg); - - // load skin configuration - skin = new Skin(ui); - ui->setSkin(skin); - - // ui - std::string genesis_version = VERSION; - romList = new PGENRomList(ui, genesis_version, - {".zip", ".md", ".smd", ".gen", ".bin", - ".mdx", ".sms", ".gg", ".sg", ".68k"}); - romList->build(); - uiRomList = new UIRomList(ui, romList, ui->getSize()); - uiMenu = new UiMenu(ui); - uiEmu = new PGENUiEmu(ui); - uiState = new PGENUIStateMenu(ui); - ui->init(uiRomList, uiMenu, uiEmu, uiState); - - while (!ui->done) { - ui->flip(); - } - - delete (skin); - delete (cfg); - delete (ui); - -#ifdef __PSP2__ - scePowerSetArmClockFrequency(266); - scePowerSetBusClockFrequency(166); - scePowerSetGpuClockFrequency(166); - scePowerSetGpuXbarClockFrequency(111); -#elif __PS4__ - sceSystemServiceLoadExec((char *) "exit", nullptr); - while (true) {} -#endif - - return 0; -} +// +// Created by cpasjuste on 22/11/16. +// + +#include "c2dui.h" +#include "pgen_ui_emu.h" +#include "pgen_io.h" +#include "pgen_config.h" +#include "pgen_romlist.h" +#include "pgen_ui_statemenu.h" +#include "osd.h" + +using namespace c2d; +using namespace c2dui; + +#ifdef __PSP2__ +#include +#include +#define mkdir(x, y) sceIoMkdir(x, 0777) +#elif __PS4__ +extern "C" int sceSystemServiceLoadExec(const char *path, const char *args[]); +#endif + +UiMenu *uiMenu; +PGENUiEmu *uiEmu; +PGENConfig *cfg; +PGENRomList *romList; +PGENUIStateMenu *uiState; + +UiMain *ui; +Skin *skin; +UIRomList *uiRomList; + +int main(int argc, char **argv) { +#ifdef __PSP2__ + // set max cpu speed + scePowerSetArmClockFrequency(444); + scePowerSetBusClockFrequency(222); + scePowerSetGpuClockFrequency(222); + scePowerSetGpuXbarClockFrequency(166); +#endif + + // need custom io for some devices + auto *io = new PGENIo(); + // create paths + io->create(io->getDataPath()); + io->create(io->getDataPath() + "bios"); + io->create(io->getDataPath() + "rams"); + io->create(io->getDataPath() + "configs"); + io->create(io->getDataPath() + "saves"); + io->create(io->getDataPath() + "megadrive"); + io->create(io->getDataPath() + "sms"); + io->create(io->getDataPath() + "gamegear"); + io->create(io->getDataPath() + "megacd"); + + // load custom configuration + int pgen_version = (__PGEN_VERSION_MAJOR__ * 100) + __PGEN_VERSION_MINOR__; + cfg = new PGENConfig(io, pgen_version); + + // create main ui + Option *fs = cfg->get(Option::Id::GUI_FULLSCREEN); + if (fs && !fs->getValueBool()) { + ui = new UiMain(io, {1280, 720}); + } else { + ui = new UiMain(io); + } + ui->setConfig(cfg); + + // load skin configuration + skin = new Skin(ui); + ui->setSkin(skin); + + // ui + std::string genesis_version = VERSION; + romList = new PGENRomList(ui, genesis_version, + {".zip", ".md", ".smd", ".gen", ".bin", + ".mdx", ".sms", ".gg", ".sg", ".68k"}); + romList->build(); + uiRomList = new UIRomList(ui, romList, ui->getSize()); + uiMenu = new UiMenu(ui); + uiEmu = new PGENUiEmu(ui); + uiState = new PGENUIStateMenu(ui); + ui->init(uiRomList, uiMenu, uiEmu, uiState); + + while (!ui->done) { + ui->flip(); + } + + delete (skin); + delete (cfg); + delete (ui); + +#ifdef __PSP2__ + scePowerSetArmClockFrequency(266); + scePowerSetBusClockFrequency(166); + scePowerSetGpuClockFrequency(166); + scePowerSetGpuXbarClockFrequency(111); +#elif __PS4__ + sceSystemServiceLoadExec((char *) "exit", nullptr); + while (true) {} +#endif + + return 0; +} diff --git a/pgen/sources/pgen_config.cpp b/pgen/sources/pgen_config.cpp index a6c294de..d76dbd8e 100644 --- a/pgen/sources/pgen_config.cpp +++ b/pgen/sources/pgen_config.cpp @@ -1,28 +1,28 @@ -// -// Created by cpasjuste on 29/05/18. -// - -#include "c2dui.h" -#include "pgen_config.h" - -using namespace c2d; -using namespace c2dui; - -PGENConfig::PGENConfig(UiMain *ui, int version, const std::string &defaultRomsPath) - : Config(ui, version, defaultRomsPath) { - // add default roms paths - roms_paths.emplace_back(ui->getIo()->getDataPath() + "sms/"); - roms_paths.emplace_back(ui->getIo()->getDataPath() + "gamegear/"); - roms_paths.emplace_back(ui->getIo()->getDataPath() + "megacd/"); -#if 0 - roms_paths.emplace_back(ui->getIo()->getDataPath() + "sg1000/"); -#endif - // no need for auto-scaling mode on pgen - get(Option::Id::ROM_SCALING_MODE)->set( - {"SCALING_MODE", {"ASPECT", "INTEGER"}, 0, - Option::Id::ROM_SCALING_MODE, Option::Flags::STRING}); - - // "c2dui_romlist" will also reload config, but we need new roms paths - reset(); - load(); -} +// +// Created by cpasjuste on 29/05/18. +// + +#include "c2dui.h" +#include "pgen_config.h" + +using namespace c2d; +using namespace c2dui; + +PGENConfig::PGENConfig(c2d::Io *io, int version, const std::string &defaultRomsPath) + : Config(io, version, defaultRomsPath) { + // add default roms paths + roms_paths.emplace_back(io->getDataPath() + "sms/"); + roms_paths.emplace_back(io->getDataPath() + "gamegear/"); + roms_paths.emplace_back(io->getDataPath() + "megacd/"); +#if 0 + roms_paths.emplace_back(io->getDataPath() + "sg1000/"); +#endif + // no need for auto-scaling mode on pgen + get(Option::Id::ROM_SCALING_MODE)->set( + {"SCALING_MODE", {"ASPECT", "INTEGER"}, 0, + Option::Id::ROM_SCALING_MODE, Option::Flags::STRING}); + + // "c2dui_romlist" will also reload config, but we need new roms paths + reset(); + load(); +} diff --git a/pgen/sources/pgen_config.h b/pgen/sources/pgen_config.h index b025b93d..320afa03 100644 --- a/pgen/sources/pgen_config.h +++ b/pgen/sources/pgen_config.h @@ -1,18 +1,18 @@ -// -// Created by cpasjuste on 29/05/18. -// - -#ifndef PGEN_CONFIG_H -#define PGEN_CONFIG_H - -#include "c2dui_config.h" - -class PGENConfig : public c2dui::Config { - -public: - - PGENConfig(UiMain *iu, int version, const std::string &defaultRomsPath = "megadrive/"); - -}; - -#endif //PGEN_CONFIG_H +// +// Created by cpasjuste on 29/05/18. +// + +#ifndef PGEN_CONFIG_H +#define PGEN_CONFIG_H + +#include "c2dui_config.h" + +class PGENConfig : public c2dui::Config { + +public: + + PGENConfig(c2d::Io *io, int version, const std::string &defaultRomsPath = "megadrive/"); + +}; + +#endif //PGEN_CONFIG_H diff --git a/pnes/sources/main.cpp b/pnes/sources/main.cpp index 9f041eac..3f21c5e6 100644 --- a/pnes/sources/main.cpp +++ b/pnes/sources/main.cpp @@ -61,12 +61,17 @@ int main(int argc, char **argv) { io->create(io->getDataPath() + "configs"); io->create(io->getDataPath() + "saves"); - // create main ui - ui = new UiMain(io); - // load custom configuration int pnes_version = (__PNES_VERSION_MAJOR__ * 100) + __PNES_VERSION_MINOR__; - cfg = new PNESConfig(ui, pnes_version); + cfg = new PNESConfig(io, pnes_version); + + // create main ui + Option *fs = cfg->get(Option::Id::GUI_FULLSCREEN); + if (fs && !fs->getValueBool()) { + ui = new UiMain(io, {1280, 720}); + } else { + ui = new UiMain(io); + } ui->setConfig(cfg); // load skin configuration diff --git a/pnes/sources/pnes_config.cpp b/pnes/sources/pnes_config.cpp index 1e7e3009..1351ee1c 100644 --- a/pnes/sources/pnes_config.cpp +++ b/pnes/sources/pnes_config.cpp @@ -8,7 +8,7 @@ using namespace c2d; using namespace c2dui; -PNESConfig::PNESConfig(UiMain *ui, int version) : Config(ui, version) { +PNESConfig::PNESConfig(c2d::Io *io, int version) : Config(io, version) { // no need for auto-scaling mode on pnes get(Option::Id::ROM_SCALING_MODE)->set( {"SCALING_MODE", {"ASPECT", "INTEGER"}, 0, diff --git a/pnes/sources/pnes_config.h b/pnes/sources/pnes_config.h index 9b3bdb63..0fcab385 100644 --- a/pnes/sources/pnes_config.h +++ b/pnes/sources/pnes_config.h @@ -11,7 +11,7 @@ class PNESConfig : public c2dui::Config { public: - PNESConfig(UiMain *ui, int version); + PNESConfig(c2d::Io *io, int version); }; diff --git a/psnes/sources/config.cpp b/psnes/sources/config.cpp index 74d12aed..f6a4538b 100644 --- a/psnes/sources/config.cpp +++ b/psnes/sources/config.cpp @@ -8,7 +8,7 @@ using namespace c2d; using namespace c2dui; -PSNESConfig::PSNESConfig(UiMain *ui, int version) : Config(ui, version) { +PSNESConfig::PSNESConfig(c2d::Io *io, int version) : Config(io, version) { printf("PSNESConfig(%s, v%i)\n", getConfigPath().c_str(), version); add(Option::Id::ROM_SHOW_FPS, "AUDIO_SYNC", {"OFF", "ON"}, 0, diff --git a/psnes/sources/config.h b/psnes/sources/config.h index 1235d2e5..8ecfa6c2 100644 --- a/psnes/sources/config.h +++ b/psnes/sources/config.h @@ -10,7 +10,7 @@ class PSNESConfig : public c2dui::Config { public: - PSNESConfig(UiMain *ui, int version); + PSNESConfig(c2d::Io *io, int version); }; diff --git a/psnes/sources/main.cpp b/psnes/sources/main.cpp index f66c4747..f47295e1 100644 --- a/psnes/sources/main.cpp +++ b/psnes/sources/main.cpp @@ -42,12 +42,17 @@ int main(int argc, char **argv) { io->create(io->getDataPath() + "configs"); io->create(io->getDataPath() + "saves"); - // create main ui - ui = new UiMain(io); - // load custom configuration int version = (__PSNES_VERSION_MAJOR__ * 100) + __PSNES_VERSION_MINOR__; - cfg = new PSNESConfig(ui, version); + cfg = new PSNESConfig(io, version); + + // create main ui + Option *fs = cfg->get(Option::Id::GUI_FULLSCREEN); + if (fs && !fs->getValueBool()) { + ui = new UiMain(io, {1280, 720}); + } else { + ui = new UiMain(io); + } ui->setConfig(cfg); // skin diff --git a/ui/c2dui_config.cpp b/ui/c2dui_config.cpp index 9b9e3314..68006144 100644 --- a/ui/c2dui_config.cpp +++ b/ui/c2dui_config.cpp @@ -1,517 +1,512 @@ -// -// Created by cpasjuste on 05/12/16. -// - -#include "c2dui.h" - -Config::Config(UiMain *ui, int ver, const std::string &defaultRomsPath) { - m_ui = ui; - dataPath = m_ui->getIo()->getDataPath(); - configPath = dataPath + "config.cfg"; - version = ver; - - printf("Config(%s, v%i)\n", configPath.c_str(), ver); - - /// custom screens size - int joyDeadZoneIndex = 3; - std::string device = C2DDevice::getName(); - if (device == "pocket2") { - joyDeadZoneIndex = 11; - } - - /// add default roms paths - roms_paths.clear(); - roms_paths.emplace_back(m_ui->getIo()->getDataPath() + defaultRomsPath); - - /// default options available for all cores - ///////////////////////////////////////////////// - /// main/gui config - ///////////////////////////////////////////////// - append("MAIN", {"MAIN"}, 0, Option::Id::MENU_MAIN, Option::Flags::MENU); - append("SHOW_FAVORITES", {"OFF", "ON"}, 0, Option::Id::GUI_SHOW_FAVORITES, - Option::Flags::BOOLEAN); - append("SHOW_AVAILABLE", {"OFF", "ON"}, 0, Option::Id::GUI_SHOW_AVAILABLE, - Option::Flags::BOOLEAN); - get()->at(get()->size() - 1).setInfo( - "YOU NEED TO RESTART THE APPLICATION AFTER CHANGING THIS OPTION"); - append("SHOW_CLONES", {"OFF", "ON"}, 0, - Option::Id::GUI_FILTER_CLONES, Option::Flags::BOOLEAN | Option::Flags::HIDDEN); - append("SHOW_ZIP_NAMES", {"OFF", "ON"}, 1, Option::Id::GUI_SHOW_ZIP_NAMES, - Option::Flags::BOOLEAN); - append("SHOW_ICONS", {"OFF", "ON"}, 0, Option::Id::GUI_SHOW_ICONS, - Option::Flags::BOOLEAN | Option::Flags::HIDDEN); - get()->at(get()->size() - 1).setInfo( - "YOU NEED TO RESTART THE APPLICATION AFTER CHANGING THIS OPTION"); -#if 0 // TODO - append("SCREEN_WIDTH", (int) C2DDevice::getResolution().x, Option::Id::GUI_SCREEN_WIDTH, - Option::Flags::INTEGER | Option::Flags::HIDDEN); - append("SCREEN_HEIGHT", (int) C2DDevice::getResolution().y, Option::Id::GUI_SCREEN_HEIGHT, - Option::Flags::INTEGER | Option::Flags::HIDDEN); -#endif -#ifdef __FULLSCREEN__ - append("FULLSCREEN", {"OFF", "ON"}, 0, Option::Id::GUI_FULLSCREEN, Option::Flags::BOOLEAN); - get()->at(get()->size() - 1).setInfo("YOU NEED TO RESTART THE APPLICATION AFTER CHANGING THIS OPTION"); -#endif - - // build skin list - std::vector skins; - // add default skins from romfs - skins.emplace_back("default"); - // add skins from romfs dir - auto files = m_ui->getIo()->getDirList(m_ui->getIo()->getRomFsPath() + "skins/", true); - for (auto &file: files) { - if (file.type != c2d::Io::Type::Directory || file.name[0] == '.') { - continue; - } - // only append skin if it doesn't exist yet - if (std::find(skins.begin(), skins.end(), file.name) == skins.end()) { - skins.emplace_back(file.name); - printf("skin found: %s\n", file.path.c_str()); - } - } - // add skins from data dir - files = m_ui->getIo()->getDirList(dataPath + "skins/", true); - for (auto &file: files) { - if (file.type != c2d::Io::Type::Directory || file.name[0] == '.') { - continue; - } - // only append skin name if it - if (std::find(skins.begin(), skins.end(), file.name) == skins.end()) { - skins.emplace_back(file.name); - printf("skin found: %s\n", file.path.c_str()); - } - } - // set "default" skin index - if (!get(Option::Id::GUI_SKIN)) { - int index = 0; - for (size_t i = 0; i < skins.size(); i++) { - if (skins.at(i) == "default") { - index = (int) i; - } - } - append("SKIN", skins, index, Option::Id::GUI_SKIN, Option::Flags::STRING); - } - get()->at(get()->size() - 1).setInfo( - "YOU NEED TO RESTART THE APPLICATION AFTER CHANGING THIS OPTION"); - - int aspect_index = ui->getSize().x / ui->getSize().y > 1.33 ? 0 : 1; - append("SKIN_ASPECT", {"16/9", "4/3"}, - aspect_index, Option::Id::GUI_SKIN_ASPECT, Option::Flags::STRING); - get()->at(get()->size() - 1).setInfo( - "YOU NEED TO RESTART THE APPLICATION AFTER CHANGING THIS OPTION"); - - append("FONT_SCALING", {"0", "1", "2", "3", "4", "5"}, - 0, Option::Id::GUI_FONT_SCALING, Option::Flags::STRING); - get()->at(get()->size() - 1).setInfo( - "YOU NEED TO RESTART THE APPLICATION AFTER CHANGING THIS OPTION"); - - append("VIDEO_SNAP_DELAY", {"3", "5", "7", "10"}, 1, - Option::Id::GUI_VIDEO_SNAP_DELAY, Option::Flags::STRING); - - ///////////////////////////////////////////////// - /// default rom config - ///////////////////////////////////////////////// - append("EMULATION", {"EMULATION"}, 0, Option::Id::MENU_ROM_OPTIONS, Option::Flags::MENU); - if (m_ui->getSize().y > 1080) { - append("SCALING", {"NONE", "2X", "3X", "4X", "5", "6", "7", "8", "9", "FIT", "FULL"}, - 6, Option::Id::ROM_SCALING, Option::Flags::STRING); - } else if (m_ui->getSize().y > 720) { - append("SCALING", {"NONE", "2X", "3X", "4X", "FIT", "FULL"}, - 4, Option::Id::ROM_SCALING, Option::Flags::STRING); - } else if (m_ui->getSize().y > 544) { - append("SCALING", {"NONE", "2X", "3X", "FIT", "FULL"}, - 3, Option::Id::ROM_SCALING, Option::Flags::STRING); - } else if (m_ui->getSize().y > 240) { - append("SCALING", {"NONE", "2X", "FIT", "FULL"}, - 2, Option::Id::ROM_SCALING, Option::Flags::STRING); - } else { - append("SCALING", {"NONE", "FIT", "FULL"}, - 1, Option::Id::ROM_SCALING, Option::Flags::STRING); - } - append("SCALING_MODE", {"AUTO", "ASPECT", "INTEGER"}, 1, - Option::Id::ROM_SCALING_MODE, Option::Flags::STRING); - append("FILTER", {"POINT", "LINEAR"}, 0, Option::Id::ROM_FILTER, Option::Flags::STRING); -#ifdef __VITA__ - append("WAIT_RENDERING", {"OFF", "ON"}, 1, Option::Id::ROM_WAIT_RENDERING, Option::Flags::BOOLEAN); -#endif - append("SHOW_FPS", {"OFF", "ON"}, 0, Option::Id::ROM_SHOW_FPS, Option::Flags::BOOLEAN); - - /// joysticks config - append("JOYPAD", {"JOYPAD"}, 0, Option::Id::MENU_JOYPAD, Option::Flags::MENU); - append("JOY_UP", KEY_JOY_UP_DEFAULT, Option::Id::JOY_UP, Option::Flags::INPUT); - append("JOY_DOWN", KEY_JOY_DOWN_DEFAULT, Option::Id::JOY_DOWN, Option::Flags::INPUT); - append("JOY_LEFT", KEY_JOY_LEFT_DEFAULT, Option::Id::JOY_LEFT, Option::Flags::INPUT); - append("JOY_RIGHT", KEY_JOY_RIGHT_DEFAULT, Option::Id::JOY_RIGHT, Option::Flags::INPUT); - append("JOY_A", KEY_JOY_A_DEFAULT, Option::Id::JOY_A, Option::Flags::INPUT); - append("JOY_B", KEY_JOY_B_DEFAULT, Option::Id::JOY_B, Option::Flags::INPUT); - append("JOY_X", KEY_JOY_X_DEFAULT, Option::Id::JOY_X, Option::Flags::INPUT); - append("JOY_Y", KEY_JOY_Y_DEFAULT, Option::Id::JOY_Y, Option::Flags::INPUT); - append("JOY_LT", KEY_JOY_LT_DEFAULT, Option::Id::JOY_LT, Option::Flags::INPUT); - append("JOY_RT", KEY_JOY_RT_DEFAULT, Option::Id::JOY_RT, Option::Flags::INPUT); - append("JOY_LB", KEY_JOY_LB_DEFAULT, Option::Id::JOY_LB, Option::Flags::INPUT); - append("JOY_RB", KEY_JOY_RB_DEFAULT, Option::Id::JOY_RB, Option::Flags::INPUT); - append("JOY_SELECT", KEY_JOY_SELECT_DEFAULT, Option::Id::JOY_SELECT, Option::Flags::INPUT); - append("JOY_START", KEY_JOY_START_DEFAULT, Option::Id::JOY_START, Option::Flags::INPUT); - append("JOY_MENU1", KEY_JOY_MENU1_DEFAULT, Option::Id::JOY_MENU1, Option::Flags::INPUT); - append("JOY_MENU2", KEY_JOY_MENU2_DEFAULT, Option::Id::JOY_MENU2, Option::Flags::INPUT); - // TODO: add gui option for axis in option menu - append("JOY_AXIS_LX", KEY_JOY_AXIS_LX, Option::Id::JOY_AXIS_LX, - Option::Flags::INPUT | Option::Flags::HIDDEN); - append("JOY_AXIS_LY", KEY_JOY_AXIS_LY, Option::Id::JOY_AXIS_LY, - Option::Flags::INPUT | Option::Flags::HIDDEN); - append("JOY_AXIS_RX", KEY_JOY_AXIS_RX, Option::Id::JOY_AXIS_RX, - Option::Flags::INPUT | Option::Flags::HIDDEN); - append("JOY_AXIS_RY", KEY_JOY_AXIS_RY, Option::Id::JOY_AXIS_RY, - Option::Flags::INPUT | Option::Flags::HIDDEN); - append("JOY_DEADZONE", - {"2000", "4000", "6000", "8000", "10000", "12000", "14000", "16000", - "18000", "20000", "22000", "24000", "26000", "28000", "30000"}, joyDeadZoneIndex, - Option::Id::JOY_DEADZONE, Option::Flags::STRING); -#ifndef NO_KEYBOARD - // keyboard - append("KEYBOARD", {"KEYBOARD"}, 0, Option::Id::MENU_KEYBOARD, Option::Flags::MENU); - append("KEY_UP", KEY_KB_UP_DEFAULT, Option::Id::KEY_UP, Option::Flags::INPUT); - append("KEY_DOWN", KEY_KB_DOWN_DEFAULT, Option::Id::KEY_DOWN, Option::Flags::INPUT); - append("KEY_LEFT", KEY_KB_LEFT_DEFAULT, Option::Id::KEY_LEFT, Option::Flags::INPUT); - append("KEY_RIGHT", KEY_KB_RIGHT_DEFAULT, Option::Id::KEY_RIGHT, Option::Flags::INPUT); - append("KEY_A", KEY_KB_A_DEFAULT, Option::Id::KEY_A, Option::Flags::INPUT); - append("KEY_B", KEY_KB_B_DEFAULT, Option::Id::KEY_B, Option::Flags::INPUT); - append("KEY_X", KEY_KB_X_DEFAULT, Option::Id::KEY_X, Option::Flags::INPUT); - append("KEY_Y", KEY_KB_Y_DEFAULT, Option::Id::KEY_Y, Option::Flags::INPUT); - append("KEY_LT", KEY_KB_LT_DEFAULT, Option::Id::KEY_LT, Option::Flags::INPUT); - append("KEY_RT", KEY_KB_RT_DEFAULT, Option::Id::KEY_RT, Option::Flags::INPUT); - append("KEY_LB", KEY_KB_LB_DEFAULT, Option::Id::KEY_LB, Option::Flags::INPUT); - append("KEY_RB", KEY_KB_RB_DEFAULT, Option::Id::KEY_RB, Option::Flags::INPUT); - append("KEY_SELECT", KEY_KB_SELECT_DEFAULT, Option::Id::KEY_SELECT, Option::Flags::INPUT); - append("KEY_START", KEY_KB_START_DEFAULT, Option::Id::KEY_START, Option::Flags::INPUT); - append("KEY_MENU1", KEY_KB_MENU1_DEFAULT, Option::Id::KEY_MENU1, Option::Flags::INPUT); - append("KEY_MENU2", KEY_KB_MENU2_DEFAULT, Option::Id::KEY_MENU2, Option::Flags::INPUT); -#endif -} - -void Config::load(const ss_api::Game &game) { - config_t cfg; - config_init(&cfg); - - bool isRomCfg = game.id > 0; - std::vector