EasyRPG / Player

RPG Maker 2000/2003 and EasyRPG games interpreter
https://easyrpg.org/player/
GNU General Public License v3.0
1.01k stars 191 forks source link

Get rid of USE_SDL and USE_LIBRETRO checks #2352

Open Ghabry opened 4 years ago

Ghabry commented 4 years ago

Currently our code is "cluttered" (well, few lines) with different code paths for SDL and Libretro. By removing them from the main files it would become easy in CMake to build both an executable and the libretro library in the same step with only a small compile time penalty. Currently this would need an complete recompile twice, which takes too long.

baseui.cpp
26:#elif USE_LIBRETRO
43:#elif defined(USE_LIBRETRO)

input_buttons_desktop.cpp
18:#if !(defined(OPENDINGUX) || defined(GEKKO) || defined(USE_LIBRETRO))

output.cpp
199:#if !defined(USE_LIBRETRO)

filefinder.cpp
53:#ifdef USE_LIBRETRO
544:#elif defined(USE_LIBRETRO)

system.h
29:#if !(defined(USE_SDL) || defined(_3DS) || defined(PSP2) || defined(__SWITCH__) || defined(USE_LIBRETRO))
44:#if defined(USE_LIBRETRO)

player.cpp
217:#ifndef USE_LIBRETRO

decoder_wildmidi.cpp
32:#ifdef USE_LIBRETRO
118:#if defined(USE_LIBRETRO)
baseui.cpp
22:#if USE_SDL==2
24:#elif USE_SDL==1
39:#if USE_SDL==2
41:#elif USE_SDL==1

main.cpp
22:#ifdef USE_SDL

filefinder.cpp
35:#if defined(USE_SDL) && defined(__ANDROID__)

main_data.cpp
39:#if defined(USE_SDL) && defined(__ANDROID__)

system.h
23: * This option may have defined USE_SDL and others.
29:#if !(defined(USE_SDL) || defined(_3DS) || defined(PSP2) || defined(__SWITCH__) || defined(USE_LIBRETRO))
101:#ifdef USE_SDL

decoder_wildmidi.cpp
36:#if defined(USE_SDL) && defined(__ANDROID__)
47:#if defined(USE_SDL) && defined(__ANDROID__)
carstene1ns commented 2 years ago

This only works when we get rid of the checks in system.h and move everything in the build system. This header is used everywhere. Most other uses are needed currently, only input_buttons_desktop.cpp can be removed.

I would like to tackle this after removing autotools build and providing cmake only.

Ghabry commented 2 years ago

Now that we have a seperate main startup sequence for everything this could be approached again.

The main could instantiate a DisplayUi and a PlatformHandler (imo this should be splitted, think of Windows vs. Linux who both use SDL2 but completely different paths).

And then in PlatformHandler all the functions can be implemented:

std::vector<std::string> GetRtpPaths();
std::vector<std::string> GetWildMidiPaths();
std::vector<std::string> GetFluidSynthSoundfonts();
Game_Clock& GetClock();
bool SupportJoystick();
bool SupportMouse();
bool SupportTouch();
bool SupportKeyboard()
// Todo: Input Buttons? They are DisplayUi specific though