2020-09-13 18:32:22 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-05-25 19:34:42 +00:00
|
|
|
//
|
2024-04-08 17:26:08 +00:00
|
|
|
// ES-DE is a frontend for browsing and launching games from your multi-platform collection.
|
2020-05-25 19:34:42 +00:00
|
|
|
//
|
2021-07-08 16:47:29 +00:00
|
|
|
// The column limit is 100 characters.
|
|
|
|
// All ES-DE C++ source code is formatted using clang-format.
|
2020-05-26 16:34:33 +00:00
|
|
|
//
|
2020-06-21 12:25:28 +00:00
|
|
|
// main.cpp
|
2020-05-25 19:34:42 +00:00
|
|
|
//
|
2023-11-27 19:19:35 +00:00
|
|
|
// Main program loop. Interprets command-line arguments, checks for the home folder
|
|
|
|
// and es_settings.xml configuration file, sets up the application environment and
|
|
|
|
// starts listening to SDL events.
|
2020-05-25 19:34:42 +00:00
|
|
|
//
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2023-02-18 11:42:19 +00:00
|
|
|
#include "ApplicationUpdater.h"
|
2023-12-16 11:30:13 +00:00
|
|
|
#include "ApplicationVersion.h"
|
2020-12-20 23:23:22 +00:00
|
|
|
#include "AudioManager.h"
|
2020-12-23 17:06:30 +00:00
|
|
|
#include "CollectionSystemsManager.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
#include "InputManager.h"
|
|
|
|
#include "Log.h"
|
2018-02-09 17:23:58 +00:00
|
|
|
#include "MameNames.h"
|
2021-05-16 11:12:31 +00:00
|
|
|
#include "MediaViewer.h"
|
2023-06-21 21:02:19 +00:00
|
|
|
#include "PDFViewer.h"
|
2022-01-17 17:43:29 +00:00
|
|
|
#include "Screensaver.h"
|
2022-05-18 21:56:51 +00:00
|
|
|
#include "Scripting.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
#include "Settings.h"
|
2021-03-19 17:37:56 +00:00
|
|
|
#include "Sound.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
#include "SystemData.h"
|
2021-07-07 18:03:42 +00:00
|
|
|
#include "guis/GuiDetectDevice.h"
|
|
|
|
#include "guis/GuiLaunchScreen.h"
|
|
|
|
#include "utils/FileSystemUtil.h"
|
feat/update 3.1.0 (#7)
* Added initial text shaping support
* Fixed some font issues
* (Windows) Added initial text shaping support
* (macOS) Added initial text shaping support
* Disabled building of HarfBuzz-subset on Windows and macOS
* (Android) Added initial text shaping support
* Added the nl_NL locale to locale/languages
* Changed the font VRAM usage calculation to actually only include texture data
* Moved the HarfBuzz segment building to a separate function
Also implemented segment caching and fixed an issue where missing glyphs were not handled correctly
* Moved the text shaping to a separate function
* Fixed a text shaping issue when there was a font change for the last character of a string
* Added support for the pl_PL locale
* Changed two font calculation functions to use shaped text
Also consolidated the HarfBuzz segment creation and shaping into a single function
* Added a hack to make shaped text wrap somehow correctly
* Changed the text shaping function to return the segment vector
* Text shaping segments are no longer created by space characters
* RTL text segments are now flagged as such
* Fixed an issue where text was not correctly centered after line breaks
* Reverted some font changes that were not needed after all
* Changed to having HarfBuzz set the horizontal glyph advance
* Fixed another failure mode for the wrapText shaped text hack
* Added a precaution to prevent crashes in case of broken fonts being used
* Made accurate text layout work correctly using HarfBuzz
* Removed the offensive wrapText hacks and added some optimizations
Also changed the three dots to an actual ellipsis Unicode character when abbreviating text
* Reverted a change in TextComponent as it caused unforeseen issues
* Changed Font::shapeText() to pass the segments vector by reference
* Removed a temporary member variable in Font and replaced it with proper argument passing
* Fixed a regression where text shaping stopped working
* Added sharing of glyph atlas entries between shaped glyph entries that need the same texture
* Added support for the ar_EG locale
* Some font-related code and comments cleanup
* Fixed a source file header typo
* Documentation update
* Removed a lot of unnecessary text processing
* Added the ICU library as a dependency
* (Android) Added the ICU library as a dependency
* (macOS) Added the ICU library as a dependency
* (Windows) Added the ICU library as a dependency
* (Windows) Fixed an MSVC compiler warning
* Replaced all built-in Unicode case conversion logic and lookup tables with facilities from the ICU library
* Documentation update
* Updated the pl_PL translations
* Added a menu title font size adjustment for the pl_PL translations
* Removed support for NetBSD and OpenBSD
* Changed a code comment that referred to BSD Unix
* Documentation update
* Silenced some Clang compiler warnings
* Added experimental support for building on Haiku
* (Haiku) Added a ScreenScraper platform identifier
* (Haiku) Added support for the Sony PlayStation Portable (psp) game system
* (Haiku) Added support for the ScummVM Game Engine (scummvm) game system
* Documentation update
* Updated the pl_PL translations
* Changed ScreenSaver to use TextComponent instead of using Font facilities directly
* Changed Window to use TextComponent instead of using Font facilities directly
* Changed ButtonComponent to use TextComponent instead of using Font facilities directly
* Changed SliderComponent to use TextComponent instead of using Font facilities directly
* Reverted ButtonComponent and SliderComponent to render the debug overlays themselves
* Changed DateTimeEditComponent to use TextComponent instead of using Font facilities directly
* Minor code cleanup
* Changed TextEditComponent to use TextComponent instead of using Font facilities directly
* Changed Font::buildTextCache() and Font::renderTextCache() to protected functions
* Changed a compiler silencing option to only apply to Clang
* (Haiku) Updated CMake configuration to make ES-DE build on Haiku Nightly (but no longer on R1/beta4)
* Documentation update
* (Haiku) Added find rule configuration for RetroArch
Also added a single core for testing purposes
* Removed direct use of Font::wrapText() from OptionListComponent, TextEditComponent and TextListComponent
* Removed direct use of Font::wrapText() from TextComponent
* Fixed an issue where ComponentList could generate elements with negative widths
* Added an assertion to GuiComponent::setSize() to check for negative mSize values
* DateTimeEditComponent no longer renders the debug overlay unless there is a string to display
* (FreeBSD) Added support for building with DEINIT_ON_LAUNCH
* (FreeBSD) Added the man page to the CPack configuration
* (FreeBSD) Added support for rebooting and powering off from inside ES-DE
* (FreeBSD) Added fallback method to locate binary
* Added layout and line wrapping support for shaped text and for mixing of LTR and RTL scripts
* Fixed a special line wrapping scenario where a trailing space should be removed
* (Windows) Fixed some MSVC compiler warnings
* Fixed some Clang compiler warnings
* Fixed an issue where theme names in the theme downloader could get abbreviated
* Added support for the ca_AD locale
* Documentation update
* (Android) Fonts and locales are now copied earlier than the other assets as HarfBuzz and libintl need them earlier in the startup process
* Documentation update
* Added support for the de_DE locale
* (Android) Added a new default find rule entry for Flycast as its application ID has been changed
* Documentation update
* Fixed an issue where text shaping could be permanently disabled after editing text
* Fixed a potential issue where globally disabling text shaping could cause space detection to fail
* Added a check for whether a text element has a width defined when the container property is set
* (Android) Changed ePSXe to use %ROM% instead of %ROMSAF%
* (Haiku) Added support for the PDF viewer
* Updated the el_GR.po, es_ES.po, fr_FR.po, it_IT.po, ja_JP.po, ru_RU.po and zh_CN.po locale files
* Documentation update
* (Haiku) Added correct installation directories to the CMake configuration
* (Haiku) Changed to correct installation directories
* (Haiku) Added support for the correct system resource directories
* (Haiku) Made sure es-pdf-convert is found under all circumstances
* Updated the fr_FR translations
* Updated the es_ES translations
* Updated the it_IT translations
* Added a menu title font size adjustment for the it_IT translations
* Updated the ja_JP translations
* Updated the zh_CN translations
* Fixed an issue where scraping using TheGamesDB would crash the application
* Added an extra check in OptionListComponent to avoid potential crashes
* Removed support for the ca_AD locale
* Added a code comment clarification in FileSystemUtil
* Updated the pl_PL translations
* Some minor code modernization in MameNames
* Fixed an issue where returning from a game would sometimes make the helpsystem use the dimmed theme properties
* (Haiku) Added a resource file
* Added a menu title font size adjustment for the de_DE translations
* (Haiku) Added support for some game systems
* (Haiku) Added a HaikuPorts recipe
* (Haiku) Fixed an URI issue in the HaikuPorts recipe
* Documentation update
* (Haiku) Added configuration for a number of game systems
* Updated the it_IT translations
* Documentation update
* (Haiku) Updated the srcGitRev value in the HaikuPorts recipe
* (Haiku) Added configuration for a number of game systems
* Documentation update
* (Haiku) Updated the srcGitRev value in the HaikuPorts recipe
* (Haiku) Added configuration for a number of game systems
* Documentation update
* (Haiku) Added configuration for a number of game systems
* Documentation update
* (Haiku) Updated the srcGitRev value in the HaikuPorts recipe
* Added basic configuration support and menu entries for theme localization
* Changed a theme loading debug message
* (linear-es-de) Fixed an issue where the system logo for saturnjp was incorrectly showing the western variant
* (modern-es-de) Fixed an issue where the system logo for saturnjp was incorrectly showing the western variant
* Updated the it_IT translations
* Added support for using language variables in the theme configuration
* Added localization support to DateTimeComponent
* Added translations for the automatic collection names when used as theme system variables
* Added localization support for the theme game counter
* Added theme contextual hinting to the custom collection summary text in CollectionSystemsManager
Also added translation support for a string that was previously missed
* Added localization support to the label entries in capabilities.xml
* Fixed a regression where horizontal text containers would sometimes not work correctly
* Fixed an issue where text elements defined as gamecount using the systemdata property could not scroll horizontally
* Added support for including theme files from within the colorScheme and fontSize tag pairs
* Added translations for the automatic collection names (short name versions) when used as theme system variables
* Fixed an incorrect code comment in CollectionSystemsManager
* Added translations for the name and fullname systemdata properties for the text element
* Added translation support for the metadata property for the text element
* Updated all locale (.po) files with the theme engine localization additions
* (linear-es-de) Added translations for en_US, en_GB and sv_SE
* Documentation update
* Updated the fr_FR translations
* (linear-es-de) Added translations for fr_FR
* Updated the ja_JP translations
* Updated the zh_CN translations
* (modern-es-de) Added translations for en_US, en_GB, fr_FR and sv_SE
* Updated the es_ES translations
* Updated the ro_RO translations
* (linear-es-de) Added translations for es_ES
* (linear-es-de) Added translations for ro_RO
* (slate-es-de) Added translations for en_US, en_GB and sv_SE
* (linear-es-de) Updated the es_ES translations
* (modern-es-de) Updated the fr_FR translations
* (linear-es-de) Some minor translation changes
* (modern-es-de) Added translations for ro_RO
* (slate-es-de) Added translations for ro_RO
* Updated the it_IT translations
* Updated the pt_BR translations
* (linear-es-de) Added translations for it_IT
* (modern-es-de) Decreased the helpsystem entry spacing
* (modern-es-de) Added translations for es_ES and it_IT
* (slate-es-de) Added translations for es_ES, fr_FR and it_IT
* (linear-es-de) Added translations for pt_BR
* (modern-es-de) Added translations for pt_BR
* (slate-es-de) Added translations for pt_BR
* (Haiku) Added support for the c64, plus4 and vic20 systems
* Documentation update
* (Haiku) Updated the srcGitRev value in the HaikuPorts recipe
* Updated SDL to 2.30.6 on Android, Windows, macOS and the Linux AppImage builds
* Added an ICU filter configuration file
* (macOS) Reduced the ICU library size via a data filter file
* (Windows) Reduced the ICU library size via a data filter file
* Updated the ru_RU translations
* (linear-es-de) Added translations for ru_RU
* (modern-es-de) Added translations for ru_RU
* (slate-es-de) Added translations for ru_RU
* Added a menu title font size adjustment for the ru_RU translations
* Removed an unnecessary element resize in ScrollableContainer
* Fixed a line breaking issue
* Added theme engine translations for 'unknown' metadata values for developer, publisher, genre and players
* Added theme engine translations for 'never' and 'unknown' date values
* (linear-es-de) Added translations for ja_JP and zh_CN
* (modern-es-de) Added translations for ja_JP and zh_CN
* (slate-es-de) Added translations for ja_JP and zh_CN
* Updated all locales with new theme engine translations
* Fixed an issue where the text element defaultValue property no longer worked correctly
* (modern-es-de) Added some capitalized default metadata values
* Documentation update
* pdated the el_GR translations
* (linear-es-de) Updated the system metadata
* (linear-es-de) Added sv_SE translations for all system hardware types
* Updated the de_DE translations
* Updated the pl_PL translations
* Bundled the July 2024 release of the Mozilla TLS/SSL certificates
* Updated the MAME index files to include ROMs up to MAME version 0.269
* (linear-es-de) Added translations for pl_PL
* Added the VirtualXT RetroArch core as an alternative emulator for the dos and pc systems
* Added the Stella 2023 RetroArch core as an alternative emulator for the atari2600 system
* Removed support for the ar_EG, de_DE, el_GR and nl_NL locales and moved their .po files to an archive directory
* Documentation update
* (modern-es-de) Added translations for pl_PL
* (slate-es-de) Added translations for pl_PL
* Updated SDL to 2.30.7 on Android, Windows, macOS and the Linux AppImage builds
* Updated the fr_FR translations
* Added support for the new Lime3DS binary names on Linux, macOS and Windows
* Added some missing find rules for Lime3DS
* (Windows) Added 'Shortcut' as an alternative emulator for the switch system
Also added the .lnk file extension
* Added jgenesis as an alternative emulator for the famicom, gamegear, gb, gbc, genesis, mastersystem, megacd, megacdjp, megadrive, megadrivejp, nes, segacd, sfc, snes and snesna systems on Linux and Windows
* Documentation update
* Added izapple2 standalone as an alternative emulator for the apple2 system on Linux and Windows
* (Android) Added support for the Microsoft Windows (windows) game system using the Winlator emulator
* (Android) Added Winlator PRoot Cmod standalone as an alternative emulator for the windows system
* Documentation update
* (Android) Added support for the PC Arcade Systems (pcarcade) and Taito Type X (type-x) game systems
* Bumped the version to 3.1.0
* (modern-es-de) Eliminated an annoying debug message
* (linear-es-de) Added some missing metadata files
* (linear-es-de) Added some missing sv_SE translations
* Updated the Winlator emulator names
* Documentation update
* Documentation update for the 3.1.0 release
* Updated latest_release.json for the 3.1.0 release
* Fixed a typo in the changelog
* Documentation update
* (Haiku) Updated the srcGitRev value in the HaikuPorts recipe
* Bumped the version to 3.1.1-alpha
* Video player resources are now completely freed up after finishing view transitions
* Changed a rounding in ScrollableContainer to slightly decrease the risk of glyphs getting cut off at the bottom of the container
* Added the Nanum Square Neo Korean font
* Added support for the ko_KR locale
* Fixed an issue where newly entered ScreenScraper username and password values were positioned incorrectly vertically in the account settings menu
* Documentation update
* Changed the position of the ko_KR language
* Changed the ja_JP position in the languages file
* Fixed an issue where attempting to view media for a game that had no downloaded media paused the playback of all static theme videos
* Documentation update
* Added support for the de_DE locale
* Updated the fr_FR translations
* Documentation update
* Updated the de_DE translations
---------
Co-authored-by: Leon Styhre <leon@leonstyhre.com>
2024-09-18 00:23:26 +00:00
|
|
|
#include "utils/LocalizationUtil.h"
|
2022-01-10 17:56:04 +00:00
|
|
|
#include "utils/PlatformUtil.h"
|
2021-07-07 18:03:42 +00:00
|
|
|
#include "utils/StringUtil.h"
|
|
|
|
#include "views/ViewController.h"
|
2020-06-26 16:03:55 +00:00
|
|
|
|
|
|
|
#include <SDL2/SDL_events.h>
|
|
|
|
#include <SDL2/SDL_main.h>
|
|
|
|
#include <SDL2/SDL_timer.h>
|
2020-08-23 14:15:06 +00:00
|
|
|
|
2023-12-12 22:21:27 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
#include "utils/PlatformUtilAndroid.h"
|
|
|
|
#endif
|
|
|
|
|
2022-01-12 20:38:37 +00:00
|
|
|
#if defined(__EMSCRIPTEN__)
|
|
|
|
#include <emscripten.h>
|
|
|
|
#endif
|
|
|
|
|
2020-08-23 14:15:06 +00:00
|
|
|
#if defined(_WIN64)
|
|
|
|
#include <cstring>
|
|
|
|
#include <windows.h>
|
2020-06-26 16:03:55 +00:00
|
|
|
#endif
|
|
|
|
|
2020-06-23 18:07:00 +00:00
|
|
|
#include <FreeImage.h>
|
2021-06-30 15:27:20 +00:00
|
|
|
#include <fstream>
|
2017-11-01 22:21:10 +00:00
|
|
|
#include <iostream>
|
2018-01-29 22:50:10 +00:00
|
|
|
#include <time.h>
|
2014-11-25 02:49:11 +00:00
|
|
|
|
2022-01-12 20:38:37 +00:00
|
|
|
namespace
|
|
|
|
{
|
2022-01-16 11:09:55 +00:00
|
|
|
SDL_Event event {};
|
2022-03-14 18:51:48 +00:00
|
|
|
Renderer* renderer {nullptr};
|
2022-01-16 11:09:55 +00:00
|
|
|
Window* window {nullptr};
|
|
|
|
int lastTime {0};
|
2022-01-12 20:38:37 +00:00
|
|
|
|
2024-02-06 21:38:15 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
int inputBlockTime {0};
|
|
|
|
bool blockInput {false};
|
|
|
|
#endif
|
|
|
|
|
2023-02-18 11:42:19 +00:00
|
|
|
#if defined(APPLICATION_UPDATER)
|
|
|
|
bool noUpdateCheck {false};
|
|
|
|
#endif
|
2022-01-16 11:09:55 +00:00
|
|
|
bool forceInputConfig {false};
|
2022-05-18 16:32:13 +00:00
|
|
|
bool createSystemDirectories {false};
|
2022-01-16 11:09:55 +00:00
|
|
|
bool settingsNeedSaving {false};
|
2022-06-12 08:34:17 +00:00
|
|
|
bool portableMode {false};
|
2020-08-03 09:39:04 +00:00
|
|
|
|
2022-01-12 20:38:37 +00:00
|
|
|
enum loadSystemsReturnCode {
|
2022-06-05 10:36:55 +00:00
|
|
|
LOADING_OK,
|
2022-01-12 20:38:37 +00:00
|
|
|
INVALID_FILE,
|
|
|
|
NO_ROMS
|
|
|
|
};
|
2020-08-15 08:12:19 +00:00
|
|
|
|
2020-08-23 15:04:30 +00:00
|
|
|
#if defined(_WIN64)
|
2022-01-12 20:38:37 +00:00
|
|
|
enum win64ConsoleType {
|
2022-06-05 10:36:55 +00:00
|
|
|
NO_CONSOLE,
|
2022-01-12 20:38:37 +00:00
|
|
|
PARENT_CONSOLE,
|
|
|
|
ALLOCATED_CONSOLE
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
} // namespace
|
2020-07-03 18:23:51 +00:00
|
|
|
|
2022-01-12 20:38:37 +00:00
|
|
|
#if defined(_WIN64)
|
2023-08-11 18:22:48 +00:00
|
|
|
// As we link using the WINDOWS subsystem there is no console allocated on application startup.
|
|
|
|
// As such we'll attempt to attach to a parent console, and if this fails it probably means we've
|
|
|
|
// not been started from the command line. In this case there is no need to redirect anything.
|
|
|
|
// Note that some console types such as the "Git Bash" shell simply don't work properly. Windows
|
|
|
|
// thinks it's attaching to a console but is unable to redirect the standard input and output.
|
|
|
|
// Output also can't be redirected or piped by the user for any console type, and PowerShell
|
|
|
|
// behaves quite strange. Still it works well enough to be somewhat usable.
|
|
|
|
void outputToConsole()
|
2020-07-03 18:23:51 +00:00
|
|
|
{
|
2023-01-08 15:30:39 +00:00
|
|
|
HANDLE outputHandle {nullptr};
|
|
|
|
HWND consoleWindow {nullptr};
|
2020-07-03 18:23:51 +00:00
|
|
|
|
|
|
|
// Try to attach to a parent console process.
|
|
|
|
if (AttachConsole(ATTACH_PARENT_PROCESS))
|
2021-07-07 18:03:42 +00:00
|
|
|
outputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
2020-07-03 18:23:51 +00:00
|
|
|
|
|
|
|
// If there is a parent console process, then attempt to retrieve its handle.
|
2023-08-11 18:22:48 +00:00
|
|
|
if (outputHandle != INVALID_HANDLE_VALUE && outputHandle != nullptr)
|
2020-07-03 18:23:51 +00:00
|
|
|
consoleWindow = GetConsoleWindow();
|
|
|
|
|
2023-08-11 18:22:48 +00:00
|
|
|
// If we couldn't retrieve the handle, then we're probably not running from a console.
|
|
|
|
if (!consoleWindow)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Redirect stdin, stdout and stderr to the console window.
|
|
|
|
FILE* fp {nullptr};
|
|
|
|
freopen_s(&fp, "CONIN$", "r", stdin);
|
|
|
|
freopen_s(&fp, "CONOUT$", "w", stdout);
|
|
|
|
setvbuf(stdout, 0, _IONBF, 0);
|
|
|
|
freopen_s(&fp, "CONOUT$", "w", stderr);
|
|
|
|
setvbuf(stderr, 0, _IONBF, 0);
|
|
|
|
|
|
|
|
// Point the standard streams to the console.
|
|
|
|
std::ios::sync_with_stdio(true);
|
|
|
|
|
|
|
|
// Clear the error state for each standard stream.
|
|
|
|
std::wcout.clear();
|
|
|
|
std::cout.clear();
|
|
|
|
std::wcerr.clear();
|
|
|
|
std::cerr.clear();
|
|
|
|
std::wcin.clear();
|
|
|
|
std::cin.clear();
|
2020-07-03 18:23:51 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-08-11 18:22:48 +00:00
|
|
|
bool parseArguments(const std::vector<std::string>& arguments)
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
2023-08-11 18:22:48 +00:00
|
|
|
Utils::FileSystem::setExePath(arguments[0]);
|
|
|
|
const std::string portableFilePath {Utils::FileSystem::getExePath() + "/portable.txt"};
|
2021-06-30 15:27:20 +00:00
|
|
|
|
|
|
|
// This is primarily intended for portable ES-DE installations on Windows (for example
|
|
|
|
// placed on a USB memory stick) but it may be usable for other operating systems too.
|
|
|
|
if (Utils::FileSystem::exists(portableFilePath)) {
|
|
|
|
std::cout << "Found portable.txt in the ES-DE executable directory\n";
|
|
|
|
std::ifstream portableFile;
|
|
|
|
std::string homePath;
|
2021-07-07 18:03:42 +00:00
|
|
|
#if defined(_WIN64)
|
2021-06-30 15:27:20 +00:00
|
|
|
portableFile.open(Utils::String::stringToWideString(portableFilePath).c_str());
|
2021-07-07 18:03:42 +00:00
|
|
|
#else
|
2021-06-30 15:27:20 +00:00
|
|
|
portableFile.open(portableFilePath.c_str());
|
2021-07-07 18:03:42 +00:00
|
|
|
#endif
|
2021-06-30 15:27:20 +00:00
|
|
|
if (!portableFile.fail()) {
|
|
|
|
std::string relativePath;
|
|
|
|
getline(portableFile, relativePath);
|
|
|
|
// If the file is empty, use the ES-DE executable directory as home.
|
|
|
|
if (relativePath == "")
|
|
|
|
homePath = Utils::FileSystem::getExePath();
|
|
|
|
else
|
|
|
|
homePath = Utils::FileSystem::getExePath() + "/" + relativePath;
|
|
|
|
|
2021-07-07 18:03:42 +00:00
|
|
|
#if defined(_WIN64)
|
2021-06-30 15:27:20 +00:00
|
|
|
homePath = Utils::String::replace(homePath, "/", "\\");
|
2021-07-07 18:03:42 +00:00
|
|
|
#endif
|
2022-06-11 16:59:40 +00:00
|
|
|
bool homeExists {false};
|
2021-06-30 15:27:20 +00:00
|
|
|
|
2022-06-11 16:59:40 +00:00
|
|
|
if (Utils::FileSystem::exists(homePath))
|
|
|
|
homeExists = true;
|
|
|
|
#if defined(_WIN64)
|
|
|
|
else if (homePath.size() == 2 && Utils::FileSystem::driveExists(homePath))
|
|
|
|
homeExists = true;
|
|
|
|
#endif
|
|
|
|
if (!homeExists) {
|
2021-06-30 15:27:20 +00:00
|
|
|
std::cerr << "Error: Defined home path \"" << homePath << "\" does not exist\n";
|
|
|
|
}
|
|
|
|
else if (Utils::FileSystem::isRegularFile(homePath)) {
|
|
|
|
std::cerr << "Error: Defined home path \"" << homePath << "\" is a file\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
std::cout << "Setting home path to \"" << homePath << "\"\n";
|
|
|
|
Utils::FileSystem::setHomePath(homePath);
|
2022-06-12 08:34:17 +00:00
|
|
|
portableMode = true;
|
2021-06-30 15:27:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
portableFile.close();
|
|
|
|
}
|
|
|
|
|
2023-08-11 18:22:48 +00:00
|
|
|
// We need to process --home before any call to Settings::getInstance(), because
|
|
|
|
// settings are loaded from the home path.
|
|
|
|
for (size_t i {1}; i < arguments.size(); ++i) {
|
|
|
|
if (arguments[i] == "--home") {
|
|
|
|
if (i >= arguments.size() - 1) {
|
2021-06-24 21:29:03 +00:00
|
|
|
std::cerr << "Error: No home path supplied with \'--home'\n";
|
2020-06-21 12:25:28 +00:00
|
|
|
return false;
|
|
|
|
}
|
2021-07-07 18:03:42 +00:00
|
|
|
#if defined(_WIN64)
|
2023-08-11 18:22:48 +00:00
|
|
|
if (!Utils::FileSystem::exists(arguments[i + 1]) &&
|
|
|
|
(!Utils::FileSystem::driveExists(arguments[i + 1]))) {
|
2021-07-07 18:03:42 +00:00
|
|
|
#else
|
2023-08-11 18:22:48 +00:00
|
|
|
if (!Utils::FileSystem::exists(arguments[i + 1])) {
|
2021-07-07 18:03:42 +00:00
|
|
|
#endif
|
2023-08-11 18:22:48 +00:00
|
|
|
std::cerr << "Error: Home path \'" << arguments[i + 1] << "\' does not exist\n";
|
2020-05-25 19:34:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
if (Utils::FileSystem::isRegularFile(arguments[i + 1])) {
|
|
|
|
std::cerr << "Error: Home path \'" << arguments[i + 1]
|
2021-07-07 18:03:42 +00:00
|
|
|
<< "\' is a file and not a directory\n";
|
2020-05-25 19:34:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
Utils::FileSystem::setHomePath(arguments[i + 1]);
|
2022-06-12 08:34:17 +00:00
|
|
|
portableMode = false;
|
2020-06-21 12:25:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-08-25 15:23:02 +00:00
|
|
|
|
2023-08-11 18:22:48 +00:00
|
|
|
for (size_t i {1}; i < arguments.size(); ++i) {
|
2020-05-25 19:34:42 +00:00
|
|
|
// Skip past --home flag as we already processed it.
|
2023-08-11 18:22:48 +00:00
|
|
|
if (arguments[i] == "--home") {
|
2021-11-17 16:35:34 +00:00
|
|
|
++i; // Skip the argument value.
|
2020-05-25 19:34:42 +00:00
|
|
|
continue;
|
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
if (arguments[i] == "--display") {
|
|
|
|
if (i >= arguments.size() - 1 || stoi(arguments[i + 1]) < 1 ||
|
|
|
|
stoi(arguments[i + 1]) > 4) {
|
2023-01-09 16:55:54 +00:00
|
|
|
std::cerr << "Error: Invalid display index supplied\n";
|
2021-01-24 22:44:50 +00:00
|
|
|
return false;
|
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
const int displayIndex {stoi(arguments[i + 1])};
|
|
|
|
Settings::getInstance()->setInt("DisplayIndex", displayIndex);
|
2021-01-25 17:10:11 +00:00
|
|
|
settingsNeedSaving = true;
|
2021-11-17 16:35:34 +00:00
|
|
|
++i;
|
2021-01-24 22:44:50 +00:00
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
else if (arguments[i] == "--resolution") {
|
|
|
|
if (i >= arguments.size() - 2) {
|
2023-01-09 16:55:54 +00:00
|
|
|
std::cerr << "Error: Invalid resolution values supplied\n";
|
2020-06-21 12:25:28 +00:00
|
|
|
return false;
|
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
const std::string widthArg {arguments[i + 1]};
|
|
|
|
const std::string heightArg {arguments[i + 2]};
|
2021-03-21 20:54:30 +00:00
|
|
|
if (widthArg.find_first_not_of("0123456789") != std::string::npos ||
|
2021-07-07 18:03:42 +00:00
|
|
|
heightArg.find_first_not_of("0123456789") != std::string::npos) {
|
2023-01-09 16:55:54 +00:00
|
|
|
std::cerr << "Error: Invalid resolution values supplied\n";
|
2021-03-21 20:54:30 +00:00
|
|
|
return false;
|
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
const int width {stoi(arguments[i + 1])};
|
|
|
|
const int height {stoi(arguments[i + 2])};
|
2021-10-18 16:14:49 +00:00
|
|
|
if (width < 224 || height < 224 || width > 7680 || height > 7680 ||
|
2023-12-19 17:41:35 +00:00
|
|
|
height < width / 4 || width < height / 3) {
|
2021-07-07 18:03:42 +00:00
|
|
|
std::cerr << "Error: Unsupported resolution " << width << "x" << height
|
2023-01-09 16:55:54 +00:00
|
|
|
<< " supplied\n";
|
2021-03-12 20:12:54 +00:00
|
|
|
return false;
|
|
|
|
}
|
2020-06-21 12:25:28 +00:00
|
|
|
Settings::getInstance()->setInt("ScreenWidth", width);
|
|
|
|
Settings::getInstance()->setInt("ScreenHeight", height);
|
2021-01-25 17:10:11 +00:00
|
|
|
i += 2;
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
else if (arguments[i] == "--screenoffset") {
|
|
|
|
if (i >= arguments.size() - 2) {
|
2023-01-09 16:55:54 +00:00
|
|
|
std::cerr << "Error: Invalid screenoffset values supplied\n";
|
2020-06-21 12:25:28 +00:00
|
|
|
return false;
|
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
const int x {stoi(arguments[i + 1])};
|
|
|
|
const int y {stoi(arguments[i + 2])};
|
2020-06-21 12:25:28 +00:00
|
|
|
Settings::getInstance()->setInt("ScreenOffsetX", x);
|
|
|
|
Settings::getInstance()->setInt("ScreenOffsetY", y);
|
2021-01-25 17:10:11 +00:00
|
|
|
i += 2;
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
else if (arguments[i] == "--screenrotate") {
|
|
|
|
if (i >= arguments.size() - 1) {
|
2023-01-09 16:55:54 +00:00
|
|
|
std::cerr << "Error: No screenrotate value supplied\n";
|
2022-03-11 23:40:03 +00:00
|
|
|
return false;
|
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
const std::string rotateValue {arguments[i + 1]};
|
2023-02-06 22:38:35 +00:00
|
|
|
if (rotateValue != "0" && rotateValue != "90" && rotateValue != "180" &&
|
|
|
|
rotateValue != "270") {
|
2023-01-09 16:55:54 +00:00
|
|
|
std::cerr << "Error: Invalid screenrotate value supplied\n";
|
2020-06-21 12:25:28 +00:00
|
|
|
return false;
|
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
Settings::getInstance()->setInt("ScreenRotate", stoi(arguments[i + 1]));
|
2023-02-06 22:38:35 +00:00
|
|
|
settingsNeedSaving = true;
|
2021-11-17 16:35:34 +00:00
|
|
|
++i;
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
else if (arguments[i] == "--fullscreen-padding") {
|
|
|
|
if (i >= arguments.size() - 1) {
|
2023-02-12 21:14:09 +00:00
|
|
|
std::cerr << "Error: No fullscreen-padding value supplied\n";
|
|
|
|
return false;
|
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
std::string fullscreenPaddingValue {arguments[i + 1]};
|
2023-02-12 21:14:09 +00:00
|
|
|
if (fullscreenPaddingValue != "on" && fullscreenPaddingValue != "off" &&
|
|
|
|
fullscreenPaddingValue != "1" && fullscreenPaddingValue != "0") {
|
|
|
|
std::cerr << "Error: Invalid fullscreen-padding value supplied\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
const bool fullscreenPadding {
|
|
|
|
(fullscreenPaddingValue == "on" || fullscreenPaddingValue == "1") ? true : false};
|
|
|
|
Settings::getInstance()->setBool("FullscreenPadding", fullscreenPadding);
|
|
|
|
++i;
|
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
else if (arguments[i] == "--vsync") {
|
|
|
|
if (i >= arguments.size() - 1) {
|
2023-01-09 16:55:54 +00:00
|
|
|
std::cerr << "Error: No VSync value supplied\n";
|
2021-02-28 14:20:34 +00:00
|
|
|
return false;
|
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
std::string vSyncValue {arguments[i + 1]};
|
2021-02-28 14:20:34 +00:00
|
|
|
if (vSyncValue != "on" && vSyncValue != "off" && vSyncValue != "1" &&
|
2021-07-07 18:03:42 +00:00
|
|
|
vSyncValue != "0") {
|
2023-01-09 16:55:54 +00:00
|
|
|
std::cerr << "Error: Invalid VSync value supplied\n";
|
2021-02-28 14:20:34 +00:00
|
|
|
return false;
|
|
|
|
}
|
2023-02-12 21:14:09 +00:00
|
|
|
const bool vSync {(vSyncValue == "on" || vSyncValue == "1") ? true : false};
|
2021-02-28 14:20:34 +00:00
|
|
|
Settings::getInstance()->setBool("VSync", vSync);
|
2021-11-17 16:35:34 +00:00
|
|
|
++i;
|
2021-01-24 21:17:36 +00:00
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
else if (arguments[i] == "--max-vram") {
|
|
|
|
if (i >= arguments.size() - 1) {
|
2023-01-09 16:55:54 +00:00
|
|
|
std::cerr << "Error: Invalid VRAM value supplied\n";
|
2020-06-21 12:25:28 +00:00
|
|
|
return false;
|
2020-05-25 19:34:42 +00:00
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
const int maxVRAM {stoi(arguments[i + 1])};
|
2020-06-21 12:25:28 +00:00
|
|
|
Settings::getInstance()->setInt("MaxVRAM", maxVRAM);
|
2021-01-25 17:10:11 +00:00
|
|
|
settingsNeedSaving = true;
|
2021-11-17 16:35:34 +00:00
|
|
|
++i;
|
2021-01-24 21:17:36 +00:00
|
|
|
}
|
2023-01-09 16:55:54 +00:00
|
|
|
#if !defined(USE_OPENGLES)
|
2023-08-11 18:22:48 +00:00
|
|
|
else if (arguments[i] == "--anti-aliasing") {
|
2023-01-09 16:55:54 +00:00
|
|
|
bool invalidValue {false};
|
|
|
|
int antiAlias {0};
|
2023-08-11 18:22:48 +00:00
|
|
|
if (i >= arguments.size() - 1) {
|
2023-01-09 16:55:54 +00:00
|
|
|
invalidValue = true;
|
|
|
|
}
|
|
|
|
else {
|
2023-08-11 18:22:48 +00:00
|
|
|
antiAlias = stoi(arguments[i + 1]);
|
2023-01-09 16:55:54 +00:00
|
|
|
if (antiAlias != 0 && antiAlias != 2 && antiAlias != 4)
|
|
|
|
invalidValue = true;
|
|
|
|
}
|
|
|
|
if (invalidValue) {
|
|
|
|
std::cerr << "Error: Invalid anti-aliasing value supplied\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
Settings::getInstance()->setInt("AntiAliasing", antiAlias);
|
|
|
|
settingsNeedSaving = true;
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
#endif
|
2023-08-11 18:22:48 +00:00
|
|
|
else if (arguments[i] == "--no-splash") {
|
2021-01-24 21:17:36 +00:00
|
|
|
Settings::getInstance()->setBool("SplashScreen", false);
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
2023-02-18 11:42:19 +00:00
|
|
|
#if defined(APPLICATION_UPDATER)
|
2023-08-11 18:22:48 +00:00
|
|
|
else if (arguments[i] == "--no-update-check") {
|
2023-02-18 11:42:19 +00:00
|
|
|
noUpdateCheck = true;
|
|
|
|
}
|
|
|
|
#endif
|
2023-08-11 18:22:48 +00:00
|
|
|
else if (arguments[i] == "--gamelist-only") {
|
2020-06-21 12:25:28 +00:00
|
|
|
Settings::getInstance()->setBool("ParseGamelistOnly", true);
|
2022-06-29 15:17:31 +00:00
|
|
|
settingsNeedSaving = true;
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
else if (arguments[i] == "--ignore-gamelist") {
|
2020-06-21 12:25:28 +00:00
|
|
|
Settings::getInstance()->setBool("IgnoreGamelist", true);
|
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
else if (arguments[i] == "--show-hidden-files") {
|
2020-06-21 12:25:28 +00:00
|
|
|
Settings::getInstance()->setBool("ShowHiddenFiles", true);
|
2021-01-25 17:10:11 +00:00
|
|
|
settingsNeedSaving = true;
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
else if (arguments[i] == "--show-hidden-games") {
|
2020-07-26 20:19:29 +00:00
|
|
|
Settings::getInstance()->setBool("ShowHiddenGames", true);
|
2021-01-25 17:10:11 +00:00
|
|
|
settingsNeedSaving = true;
|
2020-07-26 20:19:29 +00:00
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
else if (arguments[i] == "--force-full") {
|
2020-07-27 10:11:30 +00:00
|
|
|
Settings::getInstance()->setString("UIMode", "full");
|
2020-12-17 22:45:29 +00:00
|
|
|
Settings::getInstance()->setBool("ForceFull", true);
|
2020-07-26 20:19:29 +00:00
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
else if (arguments[i] == "--force-kiosk") {
|
2020-06-21 12:25:28 +00:00
|
|
|
Settings::getInstance()->setBool("ForceKiosk", true);
|
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
else if (arguments[i] == "--force-kid") {
|
2020-06-21 12:25:28 +00:00
|
|
|
Settings::getInstance()->setBool("ForceKid", true);
|
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
else if (arguments[i] == "--force-input-config") {
|
2020-08-03 09:39:04 +00:00
|
|
|
forceInputConfig = true;
|
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
else if (arguments[i] == "--create-system-dirs") {
|
2022-05-18 16:32:13 +00:00
|
|
|
createSystemDirectories = true;
|
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
else if (arguments[i] == "--debug") {
|
2021-01-24 21:17:36 +00:00
|
|
|
Settings::getInstance()->setBool("Debug", true);
|
2023-10-02 17:59:13 +00:00
|
|
|
Settings::getInstance()->setBool("DebugFlag", true);
|
2021-01-24 21:17:36 +00:00
|
|
|
Log::setReportingLevel(LogDebug);
|
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
else if (arguments[i] == "--version" || arguments[i] == "-v") {
|
2024-02-25 10:32:44 +00:00
|
|
|
std::cout << "ES-DE " << PROGRAM_VERSION_STRING << " (r" << PROGRAM_RELEASE_NUMBER
|
2023-12-16 12:17:13 +00:00
|
|
|
<< ")\n";
|
2020-05-25 19:34:42 +00:00
|
|
|
return false;
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
2023-08-11 18:22:48 +00:00
|
|
|
else if (arguments[i] == "--help" || arguments[i] == "-h") {
|
2020-06-21 12:25:28 +00:00
|
|
|
std::cout <<
|
2021-07-07 18:03:42 +00:00
|
|
|
// clang-format off
|
2023-12-16 11:30:13 +00:00
|
|
|
"Usage: es-de [options]\n"
|
2024-03-24 11:40:00 +00:00
|
|
|
"ES-DE Frontend\n\n"
|
2020-05-25 19:34:42 +00:00
|
|
|
"Options:\n"
|
2023-02-12 21:14:09 +00:00
|
|
|
" --display [1 to 4] Display/monitor to use\n"
|
|
|
|
" --resolution [width] [height] Application resolution\n"
|
|
|
|
" --screenoffset [horiz.] [vert.] Offset screen contents within application window\n"
|
|
|
|
" --screenrotate [0, 90, 180 or 270] Rotate screen contents within application window\n"
|
|
|
|
" --fullscreen-padding [1/on or 0/off] Padding if --resolution is lower than display resolution\n"
|
|
|
|
" --vsync [1/on or 0/off] Turn VSync on or off (default is on)\n"
|
|
|
|
" --max-vram [size] Max VRAM to use (in mebibytes) before swapping\n"
|
2023-01-09 16:55:54 +00:00
|
|
|
#if !defined(USE_OPENGLES)
|
2023-02-12 21:14:09 +00:00
|
|
|
" --anti-aliasing [0, 2 or 4] Set MSAA anti-aliasing to disabled, 2x or 4x\n"
|
2023-01-09 16:55:54 +00:00
|
|
|
#endif
|
2023-02-12 21:14:09 +00:00
|
|
|
" --no-splash Don't show the splash screen during startup\n"
|
2023-02-18 11:42:19 +00:00
|
|
|
#if defined(APPLICATION_UPDATER)
|
|
|
|
" --no-update-check Don't check for application updates during startup\n"
|
|
|
|
#endif
|
2023-08-14 21:22:50 +00:00
|
|
|
" --gamelist-only Skip automatic game search, only read from gamelist.xml\n"
|
2023-02-12 21:14:09 +00:00
|
|
|
" --ignore-gamelist Ignore the gamelist.xml files\n"
|
|
|
|
" --show-hidden-files Show hidden files and folders\n"
|
|
|
|
" --show-hidden-games Show hidden games\n"
|
|
|
|
" --force-full Force the UI mode to Full\n"
|
|
|
|
" --force-kiosk Force the UI mode to Kiosk\n"
|
|
|
|
" --force-kid Force the UI mode to Kid\n"
|
|
|
|
" --force-input-config Force configuration of input devices\n"
|
|
|
|
" --create-system-dirs Create game system directories\n"
|
|
|
|
" --home [path] Directory to use as home path\n"
|
2023-10-02 17:59:13 +00:00
|
|
|
" --debug Enable debug mode\n"
|
2023-02-12 21:14:09 +00:00
|
|
|
" --version, -v Display version information\n"
|
|
|
|
" --help, -h Summon a sentient, angry tuba\n";
|
2021-07-07 18:03:42 +00:00
|
|
|
// clang-format on
|
2023-08-11 18:22:48 +00:00
|
|
|
return false;
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
|
|
|
else {
|
2023-08-11 18:22:48 +00:00
|
|
|
const std::string argUnknown {arguments[i]};
|
|
|
|
std::cout << "Unknown option '" << argUnknown << "'.\n";
|
2023-12-16 11:30:13 +00:00
|
|
|
std::cout << "Try 'es-de --help' for more information.\n";
|
2023-08-11 18:22:48 +00:00
|
|
|
return false;
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-29 15:17:31 +00:00
|
|
|
if (Settings::getInstance()->getBool("IgnoreGamelist")) {
|
|
|
|
Settings::getInstance()->setBool("ParseGamelistOnly", false);
|
|
|
|
settingsNeedSaving = true;
|
|
|
|
}
|
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
return true;
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
2023-12-15 17:33:02 +00:00
|
|
|
bool checkApplicationDataDirectory()
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
2023-12-15 17:33:02 +00:00
|
|
|
// Check that the application data directory exists, otherwise create it.
|
2023-12-19 16:35:58 +00:00
|
|
|
const std::string applicationData {Utils::FileSystem::getAppDataDirectory()};
|
|
|
|
if (!Utils::FileSystem::exists(applicationData)) {
|
2023-12-15 17:33:02 +00:00
|
|
|
#if defined(__ANDROID__)
|
2023-11-27 19:19:35 +00:00
|
|
|
__android_log_print(ANDROID_LOG_VERBOSE, ANDROID_APPLICATION_ID,
|
2023-12-15 17:33:02 +00:00
|
|
|
"First startup, creating application data directory \"%s\"",
|
2023-12-19 16:35:58 +00:00
|
|
|
applicationData.c_str());
|
2021-07-07 18:03:42 +00:00
|
|
|
#else
|
2023-12-19 16:35:58 +00:00
|
|
|
std::cout << "First startup, creating application data directory \"" << applicationData
|
|
|
|
<< "\"\n";
|
2021-07-07 18:03:42 +00:00
|
|
|
#endif
|
2023-12-19 16:35:58 +00:00
|
|
|
Utils::FileSystem::createDirectory(applicationData);
|
|
|
|
if (!Utils::FileSystem::exists(applicationData)) {
|
2023-11-25 09:31:09 +00:00
|
|
|
#if defined(__ANDROID__)
|
2023-11-27 19:19:35 +00:00
|
|
|
__android_log_print(ANDROID_LOG_ERROR, ANDROID_APPLICATION_ID,
|
2023-11-25 09:31:09 +00:00
|
|
|
"Error: Couldn't create directory, permission problems?");
|
|
|
|
#else
|
2023-08-11 18:22:48 +00:00
|
|
|
std::cerr << "Error: Couldn't create directory, permission problems?\n";
|
2023-11-25 09:31:09 +00:00
|
|
|
#endif
|
2020-06-21 12:25:28 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
2021-03-10 17:21:49 +00:00
|
|
|
loadSystemsReturnCode loadSystemConfigFile()
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
2021-06-16 16:54:04 +00:00
|
|
|
if (SystemData::loadConfig())
|
|
|
|
return INVALID_FILE;
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2020-07-10 16:32:23 +00:00
|
|
|
if (SystemData::sSystemVector.size() == 0) {
|
2023-01-23 17:06:53 +00:00
|
|
|
LOG(LogInfo) << "No game files were found, make sure that the system directories are "
|
|
|
|
"setup correctly and that the file extensions are supported";
|
2020-08-15 08:12:19 +00:00
|
|
|
return NO_ROMS;
|
2020-06-21 12:25:28 +00:00
|
|
|
}
|
|
|
|
|
2021-06-16 16:54:04 +00:00
|
|
|
return LOADING_OK;
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void onExit()
|
|
|
|
{
|
2021-07-07 18:03:42 +00:00
|
|
|
// Called on exit, assuming we get far enough to have the log initialized.
|
2020-06-21 12:25:28 +00:00
|
|
|
Log::close();
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
2022-01-12 20:38:37 +00:00
|
|
|
void applicationLoop()
|
|
|
|
{
|
|
|
|
#if !defined(__EMSCRIPTEN__)
|
|
|
|
while (true) {
|
|
|
|
#endif
|
|
|
|
if (SDL_PollEvent(&event)) {
|
|
|
|
do {
|
2024-02-06 21:38:15 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
// Prevent that button presses get registered immediately when entering the
|
|
|
|
// foreground (which most commonly mean we're returning from a game).
|
2024-02-11 21:58:32 +00:00
|
|
|
// Also perform some other tasks on resume such as resetting timers.
|
2024-02-06 21:38:15 +00:00
|
|
|
if (event.type == SDL_APP_WILLENTERFOREGROUND) {
|
|
|
|
blockInput = true;
|
|
|
|
inputBlockTime = 0;
|
|
|
|
window->setBlockInput(true);
|
2024-02-10 10:03:33 +00:00
|
|
|
Utils::Platform::Android::onResume();
|
2024-02-10 09:49:02 +00:00
|
|
|
ViewController::getInstance()->resetViewVideosTimer();
|
2024-02-06 21:38:15 +00:00
|
|
|
}
|
|
|
|
#endif
|
2022-01-19 17:01:54 +00:00
|
|
|
InputManager::getInstance().parseEvent(event);
|
2022-01-12 20:38:37 +00:00
|
|
|
|
|
|
|
if (event.type == SDL_QUIT)
|
|
|
|
#if !defined(__EMSCRIPTEN__)
|
|
|
|
return;
|
|
|
|
#else
|
|
|
|
SDL_Quit();
|
|
|
|
#endif
|
|
|
|
} while (SDL_PollEvent(&event));
|
|
|
|
}
|
|
|
|
|
2023-07-29 15:49:32 +00:00
|
|
|
int curTime {static_cast<int>(SDL_GetTicks())};
|
|
|
|
int deltaTime {curTime - lastTime};
|
2022-01-12 20:38:37 +00:00
|
|
|
lastTime = curTime;
|
|
|
|
|
|
|
|
// Cap deltaTime if it ever goes negative.
|
|
|
|
if (deltaTime < 0)
|
|
|
|
deltaTime = 1000;
|
|
|
|
|
2024-02-06 21:38:15 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
if (blockInput) {
|
|
|
|
inputBlockTime += deltaTime;
|
|
|
|
if (inputBlockTime > 300) {
|
|
|
|
inputBlockTime = 0;
|
|
|
|
blockInput = false;
|
|
|
|
window->setBlockInput(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2022-01-12 20:38:37 +00:00
|
|
|
window->update(deltaTime);
|
|
|
|
window->render();
|
|
|
|
|
2022-03-14 18:51:48 +00:00
|
|
|
renderer->swapBuffers();
|
2022-01-12 20:38:37 +00:00
|
|
|
Log::flush();
|
|
|
|
#if !defined(__EMSCRIPTEN__)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
2023-01-08 15:30:39 +00:00
|
|
|
const auto applicationStartTime {std::chrono::system_clock::now()};
|
2016-12-20 20:25:35 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
std::locale::global(std::locale("C"));
|
2014-10-18 21:31:10 +00:00
|
|
|
|
2024-06-08 10:20:32 +00:00
|
|
|
SDL_SetHint(SDL_HINT_APP_NAME, "ES-DE");
|
|
|
|
|
2021-07-07 18:03:42 +00:00
|
|
|
#if defined(__APPLE__)
|
2021-03-11 16:42:08 +00:00
|
|
|
// This is a workaround to disable the incredibly annoying save state functionality in
|
|
|
|
// macOS which forces a restore of the previous window state. The problem is that this
|
|
|
|
// removes the splash screen on startup and it may have other adverse effects as well.
|
2023-01-22 20:03:08 +00:00
|
|
|
std::string saveStateDir {Utils::FileSystem::expandHomePath(
|
2023-12-16 11:30:13 +00:00
|
|
|
"~/Library/Saved Application State/org.es-de.Frontend.savedState")};
|
2021-03-11 16:42:08 +00:00
|
|
|
// Deletion of the state files should normally not be required as there shouldn't be any
|
|
|
|
// files to begin with. But maybe the files can still be created for unknown reasons
|
|
|
|
// as macOS really really loves to restore windows. Let's therefore include this deletion
|
|
|
|
// step as an extra precaution.
|
|
|
|
if (Utils::FileSystem::exists(saveStateDir)) {
|
2023-01-22 20:03:08 +00:00
|
|
|
for (std::string stateFile : Utils::FileSystem::getDirContent(saveStateDir))
|
2021-03-11 16:42:08 +00:00
|
|
|
Utils::FileSystem::removeFile(stateFile);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Utils::FileSystem::createDirectory(saveStateDir);
|
|
|
|
}
|
|
|
|
// Removing the write permission from the save state directory effectively disables
|
|
|
|
// the functionality.
|
2023-01-08 15:30:39 +00:00
|
|
|
std::string chmodCommand {"chmod 500 \"" + saveStateDir + "\""};
|
2021-03-11 16:42:08 +00:00
|
|
|
system(chmodCommand.c_str());
|
2021-07-07 18:03:42 +00:00
|
|
|
#endif
|
2021-03-11 16:42:08 +00:00
|
|
|
|
2021-07-07 18:03:42 +00:00
|
|
|
#if defined(_WIN64)
|
2023-08-11 18:22:48 +00:00
|
|
|
// If we've been started from a console then redirect the standard streams there.
|
|
|
|
outputToConsole();
|
2021-07-07 18:03:42 +00:00
|
|
|
#endif
|
2020-07-03 18:23:51 +00:00
|
|
|
|
2023-12-23 19:26:33 +00:00
|
|
|
#if !defined(__ANDROID__)
|
2023-08-11 18:22:48 +00:00
|
|
|
{
|
|
|
|
std::vector<std::string> arguments;
|
|
|
|
for (int i {0}; i < argc; ++i)
|
|
|
|
arguments.emplace_back(argv[i]);
|
2021-07-07 18:03:42 +00:00
|
|
|
#if defined(_WIN64)
|
2023-08-11 18:22:48 +00:00
|
|
|
if (!parseArguments(arguments)) {
|
|
|
|
FreeConsole();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
if (!parseArguments(arguments)) {
|
|
|
|
return 0;
|
|
|
|
}
|
2021-07-07 18:03:42 +00:00
|
|
|
#endif
|
2023-08-11 18:22:48 +00:00
|
|
|
}
|
2023-12-23 19:26:33 +00:00
|
|
|
#endif
|
2014-11-25 02:49:11 +00:00
|
|
|
|
2023-12-30 18:38:16 +00:00
|
|
|
#if defined(__ANDROID__)
|
2024-03-10 23:33:21 +00:00
|
|
|
// This hint will prevent a popup from being displayed asking for access to the controller.
|
|
|
|
// Pressing OK in that dialog grants exclusive access to the controller which makes it
|
|
|
|
// unusable in any emulator that is launched.
|
|
|
|
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI, "0");
|
|
|
|
|
2024-02-25 23:25:40 +00:00
|
|
|
// If ES-DE is set as the home app/launcher we may be in a situation where we get started
|
|
|
|
// before the external storage has been mounted. If the application data directory or the
|
|
|
|
// ROMs directory have been located on this storage then the configurator will get executed.
|
2024-05-06 15:19:24 +00:00
|
|
|
// To prevent the likelyhood of this happening we wait up to 45 * 100 milliseconds, then
|
2024-02-25 23:25:40 +00:00
|
|
|
// we give up. This is not an airtight solution but it hopefully decreases the risk of
|
|
|
|
// this failure occuring. Under normal circumstances the storage would be mounted when
|
|
|
|
// the application is starting, so no delay would occur.
|
|
|
|
if (SDL_AndroidGetExternalStorageState() == 0) {
|
2024-05-06 15:19:24 +00:00
|
|
|
for (int i {0}; i < 45; ++i) {
|
2024-02-25 23:25:40 +00:00
|
|
|
__android_log_print(ANDROID_LOG_VERBOSE, ANDROID_APPLICATION_ID,
|
|
|
|
"Storage not mounted, waiting 100 ms until next attempt");
|
|
|
|
SDL_Delay(100);
|
|
|
|
if (SDL_AndroidGetExternalStorageState() != 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-08 17:27:27 +00:00
|
|
|
if (Utils::Platform::Android::checkConfigurationNeeded()) {
|
2024-01-04 20:38:46 +00:00
|
|
|
Utils::Platform::Android::startConfigurator();
|
2024-01-03 16:33:59 +00:00
|
|
|
|
2024-01-08 17:27:27 +00:00
|
|
|
while (AndroidVariables::sHold)
|
|
|
|
SDL_Delay(20);
|
2024-01-03 16:33:59 +00:00
|
|
|
|
2024-01-08 17:27:27 +00:00
|
|
|
if (Utils::Platform::Android::checkConfigurationNeeded())
|
|
|
|
exit(0);
|
|
|
|
}
|
2024-01-04 20:38:46 +00:00
|
|
|
|
2024-01-03 16:33:59 +00:00
|
|
|
Utils::Platform::Android::setDataDirectories();
|
2023-12-30 18:38:16 +00:00
|
|
|
Utils::Platform::Android::setROMDirectory();
|
|
|
|
#endif
|
|
|
|
|
2024-01-03 16:33:59 +00:00
|
|
|
if (!Settings::getInstance()->getBool("DebugFlag") &&
|
|
|
|
Settings::getInstance()->getBool("DebugMode")) {
|
|
|
|
Settings::getInstance()->setBool("Debug", true);
|
|
|
|
Log::setReportingLevel(LogDebug);
|
|
|
|
}
|
|
|
|
|
2021-07-07 18:03:42 +00:00
|
|
|
#if defined(FREEIMAGE_LIB)
|
2020-06-21 12:25:28 +00:00
|
|
|
// Call this ONLY when linking with FreeImage as a static library.
|
|
|
|
FreeImage_Initialise();
|
2021-07-07 18:03:42 +00:00
|
|
|
#endif
|
2017-10-17 20:05:12 +00:00
|
|
|
|
2023-12-15 17:33:02 +00:00
|
|
|
// If the application data directory doesn't exist and can't be created, then exit.
|
|
|
|
if (!checkApplicationDataDirectory())
|
2020-06-21 12:25:28 +00:00
|
|
|
return 1;
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2023-12-15 21:35:28 +00:00
|
|
|
{
|
|
|
|
if (!Settings::getInstance()->getBool("LegacyAppDataDirectory")) {
|
|
|
|
// Create the logs folder in the application data directory.
|
2023-12-19 16:35:58 +00:00
|
|
|
const std::string logsDir {Utils::FileSystem::getAppDataDirectory() + "/logs"};
|
|
|
|
if (!Utils::FileSystem::isDirectory(logsDir)) {
|
2023-12-15 21:35:28 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
__android_log_print(ANDROID_LOG_VERBOSE, ANDROID_APPLICATION_ID,
|
2023-12-19 16:35:58 +00:00
|
|
|
"Creating logs directory \"%s\"...", logsDir.c_str());
|
2023-12-15 21:35:28 +00:00
|
|
|
#else
|
2023-12-19 16:35:58 +00:00
|
|
|
std::cout << "Creating logs directory \"" << logsDir << "\"..." << std::endl;
|
2023-12-15 21:35:28 +00:00
|
|
|
#endif
|
2023-12-19 16:35:58 +00:00
|
|
|
Utils::FileSystem::createDirectory(logsDir);
|
|
|
|
if (!Utils::FileSystem::isDirectory(logsDir)) {
|
2023-12-15 21:35:28 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
__android_log_print(ANDROID_LOG_ERROR, ANDROID_APPLICATION_ID,
|
|
|
|
"Couldn't create directory, permission problems?");
|
|
|
|
#else
|
|
|
|
std::cerr << "Couldn't create directory, permission problems?" << std::endl;
|
|
|
|
#endif
|
|
|
|
}
|
2023-12-16 12:17:13 +00:00
|
|
|
else {
|
|
|
|
// Remove any old logs in the root of the directory.
|
2023-12-19 16:35:58 +00:00
|
|
|
Utils::FileSystem::removeFile(Utils::FileSystem::getAppDataDirectory() +
|
|
|
|
"/es_log.txt");
|
|
|
|
Utils::FileSystem::removeFile(Utils::FileSystem::getAppDataDirectory() +
|
|
|
|
"/es_log.txt.bak");
|
2023-12-16 12:17:13 +00:00
|
|
|
}
|
2023-12-15 21:35:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
// Start the logger.
|
|
|
|
Log::init();
|
|
|
|
Log::open();
|
2023-12-25 22:23:39 +00:00
|
|
|
{
|
2024-09-25 01:40:05 +00:00
|
|
|
|
|
|
|
#if defined(__RETRODECK__)
|
2024-02-20 20:37:11 +00:00
|
|
|
const std::string applicationName {"RetroDECK"};
|
2024-09-25 01:40:05 +00:00
|
|
|
#endif
|
2024-02-25 10:32:44 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
LOG(LogInfo) << applicationName << " " << PROGRAM_VERSION_STRING << "-"
|
|
|
|
<< ANDROID_VERSION_CODE << " (r" << PROGRAM_RELEASE_NUMBER << "), built "
|
|
|
|
<< PROGRAM_BUILT_STRING;
|
2024-05-20 17:49:28 +00:00
|
|
|
|
|
|
|
if (AndroidVariables::sIsHomeApp) {
|
|
|
|
LOG(LogInfo) << "Running as the Android home app";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
LOG(LogInfo) << "Running as a regular Android app";
|
|
|
|
}
|
|
|
|
|
2024-02-25 10:32:44 +00:00
|
|
|
#else
|
|
|
|
LOG(LogInfo) << applicationName << " " << PROGRAM_VERSION_STRING << " (r"
|
2023-12-25 22:23:39 +00:00
|
|
|
<< PROGRAM_RELEASE_NUMBER << "), built " << PROGRAM_BUILT_STRING;
|
2024-02-25 10:32:44 +00:00
|
|
|
#endif
|
2023-12-25 22:23:39 +00:00
|
|
|
if (portableMode) {
|
|
|
|
LOG(LogInfo) << "Running in portable mode";
|
|
|
|
Settings::getInstance()->setBool("PortableMode", true);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Settings::getInstance()->setBool("PortableMode", false);
|
|
|
|
}
|
2022-06-12 08:34:17 +00:00
|
|
|
}
|
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
// Always close the log on exit.
|
|
|
|
atexit(&onExit);
|
|
|
|
|
2022-05-18 16:32:13 +00:00
|
|
|
if (createSystemDirectories) {
|
|
|
|
if (!SystemData::createSystemDirectories() && !Settings::getInstance()->getBool("Debug"))
|
|
|
|
std::cout << "System directories successfully created" << std::endl;
|
2023-12-16 11:30:13 +00:00
|
|
|
LOG(LogInfo) << "ES-DE cleanly shutting down";
|
2022-05-18 16:32:13 +00:00
|
|
|
#if defined(_WIN64)
|
|
|
|
FreeConsole();
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-05-18 21:56:51 +00:00
|
|
|
Scripting::fireEvent("startup");
|
|
|
|
|
2022-01-12 20:38:37 +00:00
|
|
|
#if defined(__EMSCRIPTEN__)
|
|
|
|
// TODO: Remove when application window resizing has been implemented.
|
|
|
|
Settings::getInstance()->setBool("Debug", true);
|
|
|
|
Log::setReportingLevel(LogDebug);
|
2023-02-12 21:14:09 +00:00
|
|
|
Settings::getInstance()->setInt("ScreenWidth", 1280);
|
|
|
|
Settings::getInstance()->setInt("ScreenHeight", 720);
|
2022-01-12 20:38:37 +00:00
|
|
|
#endif
|
|
|
|
|
2023-12-15 23:00:10 +00:00
|
|
|
bool migratedSettings {false};
|
|
|
|
|
2023-12-15 21:35:28 +00:00
|
|
|
{
|
|
|
|
if (!Settings::getInstance()->getBool("LegacyAppDataDirectory")) {
|
|
|
|
// Create the settings folder in the application data directory.
|
2023-12-19 16:35:58 +00:00
|
|
|
const std::string settingsDir {Utils::FileSystem::getAppDataDirectory() + "/settings"};
|
|
|
|
if (!Utils::FileSystem::isDirectory(settingsDir)) {
|
2024-04-10 20:45:33 +00:00
|
|
|
#if defined(_WIN64)
|
|
|
|
LOG(LogInfo) << "Creating settings directory \""
|
|
|
|
<< Utils::String::replace(settingsDir, "/", "\\") << "\"...";
|
|
|
|
#else
|
2023-12-19 16:35:58 +00:00
|
|
|
LOG(LogInfo) << "Creating settings directory \"" << settingsDir << "\"...";
|
2024-04-10 20:45:33 +00:00
|
|
|
#endif
|
2023-12-19 16:35:58 +00:00
|
|
|
Utils::FileSystem::createDirectory(settingsDir);
|
|
|
|
if (!Utils::FileSystem::isDirectory(settingsDir)) {
|
2023-12-15 21:35:28 +00:00
|
|
|
LOG(LogError) << "Couldn't create directory, permission problems?";
|
|
|
|
}
|
|
|
|
}
|
2023-12-19 16:35:58 +00:00
|
|
|
std::string settingsPathOld;
|
|
|
|
std::string settingsPathNew;
|
|
|
|
settingsPathOld = Utils::FileSystem::getAppDataDirectory() + "/es_settings.xml";
|
|
|
|
settingsPathNew =
|
|
|
|
Utils::FileSystem::getAppDataDirectory() + "/settings/es_settings.xml";
|
|
|
|
if (!Utils::FileSystem::exists(settingsPathNew) &&
|
|
|
|
Utils::FileSystem::exists(settingsPathOld)) {
|
|
|
|
Utils::FileSystem::renameFile(settingsPathOld, settingsPathNew, false);
|
2023-12-15 23:00:10 +00:00
|
|
|
Settings::getInstance()->loadFile();
|
|
|
|
migratedSettings = true;
|
|
|
|
}
|
2023-12-19 16:35:58 +00:00
|
|
|
settingsPathOld = Utils::FileSystem::getAppDataDirectory() + "/es_input.xml";
|
|
|
|
settingsPathNew = Utils::FileSystem::getAppDataDirectory() + "/settings/es_input.xml";
|
|
|
|
if (!Utils::FileSystem::exists(settingsPathNew) &&
|
|
|
|
Utils::FileSystem::exists(settingsPathOld)) {
|
|
|
|
Utils::FileSystem::renameFile(settingsPathOld, settingsPathNew, false);
|
2023-12-15 23:00:10 +00:00
|
|
|
migratedSettings = true;
|
|
|
|
}
|
2023-12-15 21:35:28 +00:00
|
|
|
}
|
2021-01-25 17:10:11 +00:00
|
|
|
}
|
2020-07-11 08:10:07 +00:00
|
|
|
|
2023-12-15 21:35:28 +00:00
|
|
|
{
|
2023-12-15 23:00:10 +00:00
|
|
|
// Check if the es_settings.xml file exists, and if not, create it.
|
2023-12-19 16:35:58 +00:00
|
|
|
std::string settingsPath;
|
2023-12-15 21:35:28 +00:00
|
|
|
if (Settings::getInstance()->getBool("LegacyAppDataDirectory"))
|
2023-12-19 16:35:58 +00:00
|
|
|
settingsPath = Utils::FileSystem::getAppDataDirectory() + "/es_settings.xml";
|
2023-12-15 21:35:28 +00:00
|
|
|
else
|
2023-12-19 16:35:58 +00:00
|
|
|
settingsPath = Utils::FileSystem::getAppDataDirectory() + "/settings/es_settings.xml";
|
2023-12-15 21:35:28 +00:00
|
|
|
|
2023-12-19 16:35:58 +00:00
|
|
|
if (!Utils::FileSystem::exists(settingsPath)) {
|
2023-12-15 21:35:28 +00:00
|
|
|
LOG(LogInfo) << "Settings file es_settings.xml does not exist, creating it...";
|
|
|
|
Settings::getInstance()->saveFile();
|
|
|
|
}
|
|
|
|
else if (settingsNeedSaving) {
|
|
|
|
LOG(LogInfo) << "Saving settings that were modified by command line options...";
|
|
|
|
Settings::getInstance()->saveFile();
|
2021-06-22 15:47:01 +00:00
|
|
|
}
|
2023-12-15 21:35:28 +00:00
|
|
|
}
|
|
|
|
|
2024-02-02 18:58:15 +00:00
|
|
|
#if defined(__ANDROID__)
|
2024-05-20 18:26:57 +00:00
|
|
|
// Reset the touch overlay if at least the second screen of the configurator was reached.
|
|
|
|
if (AndroidVariables::sResetTouchOverlay) {
|
2024-02-02 18:58:15 +00:00
|
|
|
Settings::getInstance()->setBool("InputTouchOverlay", true);
|
|
|
|
Settings::getInstance()->saveFile();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-12-15 21:35:28 +00:00
|
|
|
{
|
|
|
|
// Check if the application release number has changed, which would normally mean that the
|
|
|
|
// user has upgraded to a new version.
|
|
|
|
int applicationRelease;
|
|
|
|
if ((applicationRelease = Settings::getInstance()->getInt("ApplicationRelease")) !=
|
|
|
|
PROGRAM_RELEASE_NUMBER) {
|
|
|
|
if (applicationRelease != 0) {
|
|
|
|
LOG(LogInfo) << "Application release number changed from previous startup, from \""
|
|
|
|
<< applicationRelease << "\" to \"" << PROGRAM_RELEASE_NUMBER << "\"";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
LOG(LogInfo) << "Application release number setting is blank, changing it to \""
|
|
|
|
<< PROGRAM_RELEASE_NUMBER << "\"";
|
|
|
|
}
|
|
|
|
Settings::getInstance()->setInt("ApplicationRelease", PROGRAM_RELEASE_NUMBER);
|
|
|
|
Settings::getInstance()->saveFile();
|
2021-06-24 21:29:03 +00:00
|
|
|
}
|
2021-06-22 15:47:01 +00:00
|
|
|
}
|
|
|
|
|
2023-12-15 21:35:28 +00:00
|
|
|
{
|
|
|
|
// Create the gamelists folder in the application data directory.
|
2023-12-19 16:35:58 +00:00
|
|
|
const std::string gamelistsDir {Utils::FileSystem::getAppDataDirectory() + "/gamelists"};
|
|
|
|
if (!Utils::FileSystem::exists(gamelistsDir)) {
|
2024-04-10 20:45:33 +00:00
|
|
|
#if defined(_WIN64)
|
|
|
|
LOG(LogInfo) << "Creating gamelists directory \""
|
|
|
|
<< Utils::String::replace(gamelistsDir, "/", "\\") << "\"...";
|
|
|
|
#else
|
2023-12-19 16:35:58 +00:00
|
|
|
LOG(LogInfo) << "Creating gamelists directory \"" << gamelistsDir << "\"...";
|
2024-04-10 20:45:33 +00:00
|
|
|
#endif
|
2023-12-19 16:35:58 +00:00
|
|
|
Utils::FileSystem::createDirectory(gamelistsDir);
|
|
|
|
if (!Utils::FileSystem::exists(gamelistsDir)) {
|
2023-12-15 21:35:28 +00:00
|
|
|
LOG(LogWarning) << "Couldn't create directory, permission problems?";
|
|
|
|
}
|
2023-01-09 20:16:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-10 20:45:33 +00:00
|
|
|
{
|
|
|
|
// Create the game media folder.
|
|
|
|
const std::string mediaDirectory {FileData::getMediaDirectory()};
|
|
|
|
if (!Utils::FileSystem::exists(mediaDirectory)) {
|
|
|
|
#if defined(_WIN64)
|
|
|
|
LOG(LogInfo) << "Creating game media directory \""
|
|
|
|
<< Utils::String::replace(mediaDirectory, "/", "\\") << "\"...";
|
|
|
|
#else
|
|
|
|
LOG(LogInfo) << "Creating game media directory \"" << mediaDirectory << "\"...";
|
|
|
|
#endif
|
|
|
|
Utils::FileSystem::createDirectory(mediaDirectory);
|
|
|
|
if (!Utils::FileSystem::exists(mediaDirectory)) {
|
|
|
|
LOG(LogWarning) << "Couldn't create directory, permission problems?";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-15 21:35:28 +00:00
|
|
|
{
|
2023-12-15 17:33:02 +00:00
|
|
|
#if defined(__ANDROID__)
|
2023-12-19 16:35:58 +00:00
|
|
|
const std::string themeDir {Utils::FileSystem::getAppDataDirectory() + "/themes"};
|
|
|
|
if (!Utils::FileSystem::exists(themeDir)) {
|
|
|
|
LOG(LogInfo) << "Creating themes directory \"" << themeDir << "\"...";
|
2023-12-15 21:35:28 +00:00
|
|
|
|
2023-12-19 16:35:58 +00:00
|
|
|
Utils::FileSystem::createDirectory(themeDir);
|
|
|
|
if (!Utils::FileSystem::exists(themeDir)) {
|
2023-12-15 21:35:28 +00:00
|
|
|
LOG(LogWarning) << "Couldn't create directory, permission problems?";
|
|
|
|
}
|
2023-12-15 17:33:02 +00:00
|
|
|
}
|
2024-01-31 20:03:28 +00:00
|
|
|
if (!Utils::FileSystem::exists(themeDir + "/.nomedia")) {
|
|
|
|
LOG(LogInfo) << "Creating \"no media\" file \"" << themeDir + "/.nomedia"
|
|
|
|
<< "\"...";
|
|
|
|
Utils::FileSystem::createEmptyFile(themeDir + "/.nomedia");
|
|
|
|
if (!Utils::FileSystem::exists(themeDir + "/.nomedia")) {
|
|
|
|
LOG(LogWarning) << "Couldn't create file, permission problems?";
|
|
|
|
}
|
|
|
|
}
|
2023-12-15 17:33:02 +00:00
|
|
|
#else
|
2023-12-15 21:35:28 +00:00
|
|
|
// Create the themes folder in the application data directory (or elsewhere if the
|
|
|
|
// UserThemeDirectory setting has been defined).
|
2023-12-19 16:35:58 +00:00
|
|
|
const std::string defaultUserThemeDir {Utils::FileSystem::getAppDataDirectory() +
|
|
|
|
"/themes"};
|
|
|
|
std::string userThemeDirSetting {Utils::FileSystem::expandHomePath(
|
2023-12-15 21:35:28 +00:00
|
|
|
Settings::getInstance()->getString("UserThemeDirectory"))};
|
2023-12-19 16:35:58 +00:00
|
|
|
std::string userThemeDirectory;
|
2023-12-15 21:35:28 +00:00
|
|
|
|
|
|
|
if (userThemeDirSetting.empty())
|
|
|
|
userThemeDirectory = defaultUserThemeDir;
|
|
|
|
else
|
|
|
|
userThemeDirectory = userThemeDirSetting;
|
|
|
|
|
2023-12-19 16:35:58 +00:00
|
|
|
if (!Utils::FileSystem::exists(userThemeDirectory)) {
|
2024-04-10 20:45:33 +00:00
|
|
|
#if defined(_WIN64)
|
|
|
|
LOG(LogInfo) << "Creating themes directory \""
|
|
|
|
<< Utils::String::replace(userThemeDirectory, "/", "\\") << "\"...";
|
|
|
|
#else
|
2023-12-19 16:35:58 +00:00
|
|
|
LOG(LogInfo) << "Creating themes directory \"" << userThemeDirectory << "\"...";
|
2024-04-10 20:45:33 +00:00
|
|
|
#endif
|
2023-12-19 16:35:58 +00:00
|
|
|
Utils::FileSystem::createDirectory(userThemeDirectory);
|
|
|
|
if (!Utils::FileSystem::exists(userThemeDirectory)) {
|
2023-12-15 21:35:28 +00:00
|
|
|
LOG(LogWarning) << "Couldn't create directory, permission problems?";
|
|
|
|
}
|
2021-06-24 21:29:03 +00:00
|
|
|
}
|
2023-12-15 17:33:02 +00:00
|
|
|
#endif
|
2023-12-15 21:35:28 +00:00
|
|
|
}
|
2021-06-24 21:29:03 +00:00
|
|
|
|
2024-01-31 20:03:28 +00:00
|
|
|
{
|
|
|
|
#if defined(__ANDROID__)
|
|
|
|
const std::string mediaDirectory {FileData::getMediaDirectory()};
|
|
|
|
if (Utils::FileSystem::exists(mediaDirectory))
|
|
|
|
if (!Utils::FileSystem::exists(mediaDirectory + ".nomedia")) {
|
|
|
|
LOG(LogInfo) << "Creating \"no media\" file \"" << mediaDirectory + ".nomedia"
|
|
|
|
<< "\"...";
|
|
|
|
Utils::FileSystem::createEmptyFile(mediaDirectory + ".nomedia");
|
|
|
|
if (!Utils::FileSystem::exists(mediaDirectory + ".nomedia")) {
|
|
|
|
LOG(LogWarning) << "Couldn't create file, permission problems?";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2023-12-15 21:35:28 +00:00
|
|
|
{
|
|
|
|
// Create the scripts folder in the application data directory. This is only required
|
|
|
|
// for custom event scripts so it's also created as a convenience.
|
2023-12-19 16:35:58 +00:00
|
|
|
const std::string scriptsDir {Utils::FileSystem::getAppDataDirectory() + "/scripts"};
|
|
|
|
if (!Utils::FileSystem::exists(scriptsDir)) {
|
2024-04-10 20:45:33 +00:00
|
|
|
#if defined(_WIN64)
|
|
|
|
LOG(LogInfo) << "Creating scripts directory \""
|
|
|
|
<< Utils::String::replace(scriptsDir, "/", "\\") << "\"...";
|
|
|
|
#else
|
2023-12-19 16:35:58 +00:00
|
|
|
LOG(LogInfo) << "Creating scripts directory \"" << scriptsDir << "\"...";
|
2024-04-10 20:45:33 +00:00
|
|
|
#endif
|
2023-12-19 16:35:58 +00:00
|
|
|
Utils::FileSystem::createDirectory(scriptsDir);
|
|
|
|
if (!Utils::FileSystem::exists(scriptsDir)) {
|
2023-12-15 21:35:28 +00:00
|
|
|
LOG(LogWarning) << "Couldn't create directory, permission problems?";
|
2023-12-16 20:18:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
// Create the screensavers and screensavers/custom_slideshow directories.
|
2023-12-19 16:35:58 +00:00
|
|
|
const std::string screensaversDir {Utils::FileSystem::getAppDataDirectory() +
|
|
|
|
"/screensavers"};
|
|
|
|
const std::string slideshowDir {Utils::FileSystem::getAppDataDirectory() +
|
|
|
|
"/screensavers/custom_slideshow"};
|
|
|
|
if (!Utils::FileSystem::exists(screensaversDir)) {
|
2024-04-10 20:45:33 +00:00
|
|
|
#if defined(_WIN64)
|
|
|
|
LOG(LogInfo) << "Creating screensavers directory \""
|
|
|
|
<< Utils::String::replace(screensaversDir, "/", "\\") << "\"...";
|
|
|
|
#else
|
2023-12-19 16:35:58 +00:00
|
|
|
LOG(LogInfo) << "Creating screensavers directory \"" << screensaversDir << "\"...";
|
2024-04-10 20:45:33 +00:00
|
|
|
#endif
|
2023-12-19 16:35:58 +00:00
|
|
|
Utils::FileSystem::createDirectory(screensaversDir);
|
|
|
|
if (!Utils::FileSystem::exists(screensaversDir)) {
|
2023-12-16 20:18:58 +00:00
|
|
|
LOG(LogWarning) << "Couldn't create directory, permission problems?";
|
|
|
|
}
|
|
|
|
}
|
2024-01-31 20:03:28 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
if (!Utils::FileSystem::exists(screensaversDir + "/.nomedia")) {
|
|
|
|
LOG(LogInfo) << "Creating \"no media\" file \"" << screensaversDir + "/.nomedia"
|
|
|
|
<< "\"...";
|
|
|
|
Utils::FileSystem::createEmptyFile(screensaversDir + "/.nomedia");
|
|
|
|
if (!Utils::FileSystem::exists(screensaversDir + "/.nomedia")) {
|
|
|
|
LOG(LogWarning) << "Couldn't create file, permission problems?";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2023-12-19 16:35:58 +00:00
|
|
|
if (!Utils::FileSystem::exists(slideshowDir)) {
|
2024-04-10 20:45:33 +00:00
|
|
|
#if defined(_WIN64)
|
|
|
|
LOG(LogInfo) << "Creating custom_slideshow directory \""
|
|
|
|
<< Utils::String::replace(slideshowDir, "/", "\\") << "\"...";
|
|
|
|
#else
|
2023-12-19 16:35:58 +00:00
|
|
|
LOG(LogInfo) << "Creating custom_slideshow directory \"" << slideshowDir << "\"...";
|
2024-04-10 20:45:33 +00:00
|
|
|
#endif
|
2023-12-19 16:35:58 +00:00
|
|
|
Utils::FileSystem::createDirectory(slideshowDir);
|
|
|
|
if (!Utils::FileSystem::exists(slideshowDir)) {
|
2023-12-16 20:18:58 +00:00
|
|
|
LOG(LogWarning) << "Couldn't create directory, permission problems?";
|
2023-12-15 21:35:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
if (!Settings::getInstance()->getBool("LegacyAppDataDirectory")) {
|
|
|
|
// Create the controllers folder in the application data directory.
|
2023-12-19 16:35:58 +00:00
|
|
|
const std::string controllersDir {Utils::FileSystem::getAppDataDirectory() +
|
|
|
|
"/controllers"};
|
|
|
|
if (!Utils::FileSystem::exists(controllersDir)) {
|
2024-04-10 20:45:33 +00:00
|
|
|
#if defined(_WIN64)
|
|
|
|
LOG(LogInfo) << "Creating controllers directory \""
|
|
|
|
<< Utils::String::replace(controllersDir, "/", "\\") << "\"...";
|
|
|
|
#else
|
2023-12-19 16:35:58 +00:00
|
|
|
LOG(LogInfo) << "Creating controllers directory \"" << controllersDir << "\"...";
|
2024-04-10 20:45:33 +00:00
|
|
|
#endif
|
2023-12-19 16:35:58 +00:00
|
|
|
Utils::FileSystem::createDirectory(controllersDir);
|
|
|
|
if (!Utils::FileSystem::exists(controllersDir)) {
|
2023-12-15 21:35:28 +00:00
|
|
|
LOG(LogWarning) << "Couldn't create directory, permission problems?";
|
|
|
|
}
|
|
|
|
}
|
2023-12-19 16:35:58 +00:00
|
|
|
std::string configPathOld {Utils::FileSystem::getAppDataDirectory() +
|
|
|
|
"/es_controller_mappings.cfg"};
|
|
|
|
std::string configPathNew {Utils::FileSystem::getAppDataDirectory() +
|
|
|
|
"/controllers/es_controller_mappings.cfg"};
|
|
|
|
if (!Utils::FileSystem::exists(configPathNew) &&
|
|
|
|
Utils::FileSystem::exists(configPathOld)) {
|
|
|
|
Utils::FileSystem::renameFile(configPathOld, configPathNew, false);
|
2023-12-15 23:00:10 +00:00
|
|
|
migratedSettings = true;
|
|
|
|
}
|
2021-06-24 21:29:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
feat/update 3.1.0 (#7)
* Added initial text shaping support
* Fixed some font issues
* (Windows) Added initial text shaping support
* (macOS) Added initial text shaping support
* Disabled building of HarfBuzz-subset on Windows and macOS
* (Android) Added initial text shaping support
* Added the nl_NL locale to locale/languages
* Changed the font VRAM usage calculation to actually only include texture data
* Moved the HarfBuzz segment building to a separate function
Also implemented segment caching and fixed an issue where missing glyphs were not handled correctly
* Moved the text shaping to a separate function
* Fixed a text shaping issue when there was a font change for the last character of a string
* Added support for the pl_PL locale
* Changed two font calculation functions to use shaped text
Also consolidated the HarfBuzz segment creation and shaping into a single function
* Added a hack to make shaped text wrap somehow correctly
* Changed the text shaping function to return the segment vector
* Text shaping segments are no longer created by space characters
* RTL text segments are now flagged as such
* Fixed an issue where text was not correctly centered after line breaks
* Reverted some font changes that were not needed after all
* Changed to having HarfBuzz set the horizontal glyph advance
* Fixed another failure mode for the wrapText shaped text hack
* Added a precaution to prevent crashes in case of broken fonts being used
* Made accurate text layout work correctly using HarfBuzz
* Removed the offensive wrapText hacks and added some optimizations
Also changed the three dots to an actual ellipsis Unicode character when abbreviating text
* Reverted a change in TextComponent as it caused unforeseen issues
* Changed Font::shapeText() to pass the segments vector by reference
* Removed a temporary member variable in Font and replaced it with proper argument passing
* Fixed a regression where text shaping stopped working
* Added sharing of glyph atlas entries between shaped glyph entries that need the same texture
* Added support for the ar_EG locale
* Some font-related code and comments cleanup
* Fixed a source file header typo
* Documentation update
* Removed a lot of unnecessary text processing
* Added the ICU library as a dependency
* (Android) Added the ICU library as a dependency
* (macOS) Added the ICU library as a dependency
* (Windows) Added the ICU library as a dependency
* (Windows) Fixed an MSVC compiler warning
* Replaced all built-in Unicode case conversion logic and lookup tables with facilities from the ICU library
* Documentation update
* Updated the pl_PL translations
* Added a menu title font size adjustment for the pl_PL translations
* Removed support for NetBSD and OpenBSD
* Changed a code comment that referred to BSD Unix
* Documentation update
* Silenced some Clang compiler warnings
* Added experimental support for building on Haiku
* (Haiku) Added a ScreenScraper platform identifier
* (Haiku) Added support for the Sony PlayStation Portable (psp) game system
* (Haiku) Added support for the ScummVM Game Engine (scummvm) game system
* Documentation update
* Updated the pl_PL translations
* Changed ScreenSaver to use TextComponent instead of using Font facilities directly
* Changed Window to use TextComponent instead of using Font facilities directly
* Changed ButtonComponent to use TextComponent instead of using Font facilities directly
* Changed SliderComponent to use TextComponent instead of using Font facilities directly
* Reverted ButtonComponent and SliderComponent to render the debug overlays themselves
* Changed DateTimeEditComponent to use TextComponent instead of using Font facilities directly
* Minor code cleanup
* Changed TextEditComponent to use TextComponent instead of using Font facilities directly
* Changed Font::buildTextCache() and Font::renderTextCache() to protected functions
* Changed a compiler silencing option to only apply to Clang
* (Haiku) Updated CMake configuration to make ES-DE build on Haiku Nightly (but no longer on R1/beta4)
* Documentation update
* (Haiku) Added find rule configuration for RetroArch
Also added a single core for testing purposes
* Removed direct use of Font::wrapText() from OptionListComponent, TextEditComponent and TextListComponent
* Removed direct use of Font::wrapText() from TextComponent
* Fixed an issue where ComponentList could generate elements with negative widths
* Added an assertion to GuiComponent::setSize() to check for negative mSize values
* DateTimeEditComponent no longer renders the debug overlay unless there is a string to display
* (FreeBSD) Added support for building with DEINIT_ON_LAUNCH
* (FreeBSD) Added the man page to the CPack configuration
* (FreeBSD) Added support for rebooting and powering off from inside ES-DE
* (FreeBSD) Added fallback method to locate binary
* Added layout and line wrapping support for shaped text and for mixing of LTR and RTL scripts
* Fixed a special line wrapping scenario where a trailing space should be removed
* (Windows) Fixed some MSVC compiler warnings
* Fixed some Clang compiler warnings
* Fixed an issue where theme names in the theme downloader could get abbreviated
* Added support for the ca_AD locale
* Documentation update
* (Android) Fonts and locales are now copied earlier than the other assets as HarfBuzz and libintl need them earlier in the startup process
* Documentation update
* Added support for the de_DE locale
* (Android) Added a new default find rule entry for Flycast as its application ID has been changed
* Documentation update
* Fixed an issue where text shaping could be permanently disabled after editing text
* Fixed a potential issue where globally disabling text shaping could cause space detection to fail
* Added a check for whether a text element has a width defined when the container property is set
* (Android) Changed ePSXe to use %ROM% instead of %ROMSAF%
* (Haiku) Added support for the PDF viewer
* Updated the el_GR.po, es_ES.po, fr_FR.po, it_IT.po, ja_JP.po, ru_RU.po and zh_CN.po locale files
* Documentation update
* (Haiku) Added correct installation directories to the CMake configuration
* (Haiku) Changed to correct installation directories
* (Haiku) Added support for the correct system resource directories
* (Haiku) Made sure es-pdf-convert is found under all circumstances
* Updated the fr_FR translations
* Updated the es_ES translations
* Updated the it_IT translations
* Added a menu title font size adjustment for the it_IT translations
* Updated the ja_JP translations
* Updated the zh_CN translations
* Fixed an issue where scraping using TheGamesDB would crash the application
* Added an extra check in OptionListComponent to avoid potential crashes
* Removed support for the ca_AD locale
* Added a code comment clarification in FileSystemUtil
* Updated the pl_PL translations
* Some minor code modernization in MameNames
* Fixed an issue where returning from a game would sometimes make the helpsystem use the dimmed theme properties
* (Haiku) Added a resource file
* Added a menu title font size adjustment for the de_DE translations
* (Haiku) Added support for some game systems
* (Haiku) Added a HaikuPorts recipe
* (Haiku) Fixed an URI issue in the HaikuPorts recipe
* Documentation update
* (Haiku) Added configuration for a number of game systems
* Updated the it_IT translations
* Documentation update
* (Haiku) Updated the srcGitRev value in the HaikuPorts recipe
* (Haiku) Added configuration for a number of game systems
* Documentation update
* (Haiku) Updated the srcGitRev value in the HaikuPorts recipe
* (Haiku) Added configuration for a number of game systems
* Documentation update
* (Haiku) Added configuration for a number of game systems
* Documentation update
* (Haiku) Updated the srcGitRev value in the HaikuPorts recipe
* Added basic configuration support and menu entries for theme localization
* Changed a theme loading debug message
* (linear-es-de) Fixed an issue where the system logo for saturnjp was incorrectly showing the western variant
* (modern-es-de) Fixed an issue where the system logo for saturnjp was incorrectly showing the western variant
* Updated the it_IT translations
* Added support for using language variables in the theme configuration
* Added localization support to DateTimeComponent
* Added translations for the automatic collection names when used as theme system variables
* Added localization support for the theme game counter
* Added theme contextual hinting to the custom collection summary text in CollectionSystemsManager
Also added translation support for a string that was previously missed
* Added localization support to the label entries in capabilities.xml
* Fixed a regression where horizontal text containers would sometimes not work correctly
* Fixed an issue where text elements defined as gamecount using the systemdata property could not scroll horizontally
* Added support for including theme files from within the colorScheme and fontSize tag pairs
* Added translations for the automatic collection names (short name versions) when used as theme system variables
* Fixed an incorrect code comment in CollectionSystemsManager
* Added translations for the name and fullname systemdata properties for the text element
* Added translation support for the metadata property for the text element
* Updated all locale (.po) files with the theme engine localization additions
* (linear-es-de) Added translations for en_US, en_GB and sv_SE
* Documentation update
* Updated the fr_FR translations
* (linear-es-de) Added translations for fr_FR
* Updated the ja_JP translations
* Updated the zh_CN translations
* (modern-es-de) Added translations for en_US, en_GB, fr_FR and sv_SE
* Updated the es_ES translations
* Updated the ro_RO translations
* (linear-es-de) Added translations for es_ES
* (linear-es-de) Added translations for ro_RO
* (slate-es-de) Added translations for en_US, en_GB and sv_SE
* (linear-es-de) Updated the es_ES translations
* (modern-es-de) Updated the fr_FR translations
* (linear-es-de) Some minor translation changes
* (modern-es-de) Added translations for ro_RO
* (slate-es-de) Added translations for ro_RO
* Updated the it_IT translations
* Updated the pt_BR translations
* (linear-es-de) Added translations for it_IT
* (modern-es-de) Decreased the helpsystem entry spacing
* (modern-es-de) Added translations for es_ES and it_IT
* (slate-es-de) Added translations for es_ES, fr_FR and it_IT
* (linear-es-de) Added translations for pt_BR
* (modern-es-de) Added translations for pt_BR
* (slate-es-de) Added translations for pt_BR
* (Haiku) Added support for the c64, plus4 and vic20 systems
* Documentation update
* (Haiku) Updated the srcGitRev value in the HaikuPorts recipe
* Updated SDL to 2.30.6 on Android, Windows, macOS and the Linux AppImage builds
* Added an ICU filter configuration file
* (macOS) Reduced the ICU library size via a data filter file
* (Windows) Reduced the ICU library size via a data filter file
* Updated the ru_RU translations
* (linear-es-de) Added translations for ru_RU
* (modern-es-de) Added translations for ru_RU
* (slate-es-de) Added translations for ru_RU
* Added a menu title font size adjustment for the ru_RU translations
* Removed an unnecessary element resize in ScrollableContainer
* Fixed a line breaking issue
* Added theme engine translations for 'unknown' metadata values for developer, publisher, genre and players
* Added theme engine translations for 'never' and 'unknown' date values
* (linear-es-de) Added translations for ja_JP and zh_CN
* (modern-es-de) Added translations for ja_JP and zh_CN
* (slate-es-de) Added translations for ja_JP and zh_CN
* Updated all locales with new theme engine translations
* Fixed an issue where the text element defaultValue property no longer worked correctly
* (modern-es-de) Added some capitalized default metadata values
* Documentation update
* pdated the el_GR translations
* (linear-es-de) Updated the system metadata
* (linear-es-de) Added sv_SE translations for all system hardware types
* Updated the de_DE translations
* Updated the pl_PL translations
* Bundled the July 2024 release of the Mozilla TLS/SSL certificates
* Updated the MAME index files to include ROMs up to MAME version 0.269
* (linear-es-de) Added translations for pl_PL
* Added the VirtualXT RetroArch core as an alternative emulator for the dos and pc systems
* Added the Stella 2023 RetroArch core as an alternative emulator for the atari2600 system
* Removed support for the ar_EG, de_DE, el_GR and nl_NL locales and moved their .po files to an archive directory
* Documentation update
* (modern-es-de) Added translations for pl_PL
* (slate-es-de) Added translations for pl_PL
* Updated SDL to 2.30.7 on Android, Windows, macOS and the Linux AppImage builds
* Updated the fr_FR translations
* Added support for the new Lime3DS binary names on Linux, macOS and Windows
* Added some missing find rules for Lime3DS
* (Windows) Added 'Shortcut' as an alternative emulator for the switch system
Also added the .lnk file extension
* Added jgenesis as an alternative emulator for the famicom, gamegear, gb, gbc, genesis, mastersystem, megacd, megacdjp, megadrive, megadrivejp, nes, segacd, sfc, snes and snesna systems on Linux and Windows
* Documentation update
* Added izapple2 standalone as an alternative emulator for the apple2 system on Linux and Windows
* (Android) Added support for the Microsoft Windows (windows) game system using the Winlator emulator
* (Android) Added Winlator PRoot Cmod standalone as an alternative emulator for the windows system
* Documentation update
* (Android) Added support for the PC Arcade Systems (pcarcade) and Taito Type X (type-x) game systems
* Bumped the version to 3.1.0
* (modern-es-de) Eliminated an annoying debug message
* (linear-es-de) Added some missing metadata files
* (linear-es-de) Added some missing sv_SE translations
* Updated the Winlator emulator names
* Documentation update
* Documentation update for the 3.1.0 release
* Updated latest_release.json for the 3.1.0 release
* Fixed a typo in the changelog
* Documentation update
* (Haiku) Updated the srcGitRev value in the HaikuPorts recipe
* Bumped the version to 3.1.1-alpha
* Video player resources are now completely freed up after finishing view transitions
* Changed a rounding in ScrollableContainer to slightly decrease the risk of glyphs getting cut off at the bottom of the container
* Added the Nanum Square Neo Korean font
* Added support for the ko_KR locale
* Fixed an issue where newly entered ScreenScraper username and password values were positioned incorrectly vertically in the account settings menu
* Documentation update
* Changed the position of the ko_KR language
* Changed the ja_JP position in the languages file
* Fixed an issue where attempting to view media for a game that had no downloaded media paused the playback of all static theme videos
* Documentation update
* Added support for the de_DE locale
* Updated the fr_FR translations
* Documentation update
* Updated the de_DE translations
---------
Co-authored-by: Leon Styhre <leon@leonstyhre.com>
2024-09-18 00:23:26 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
// We need to copy the font and locale files before starting the renderer as HarfBuzz
|
|
|
|
// and libintl need them before that point.
|
|
|
|
std::string buildIdentifier {PROGRAM_VERSION_STRING};
|
|
|
|
buildIdentifier.append(" (r")
|
|
|
|
.append(std::to_string(PROGRAM_RELEASE_NUMBER))
|
|
|
|
.append("), built ")
|
|
|
|
.append(PROGRAM_BUILT_STRING);
|
|
|
|
const bool needResourceCopy {Utils::Platform::Android::checkNeedResourceCopy(buildIdentifier)};
|
|
|
|
if (needResourceCopy) {
|
|
|
|
LOG(LogInfo) << "Application has been updated or it's a new installation, copying "
|
|
|
|
"bundled fonts and locales to internal storage...";
|
|
|
|
Utils::Platform::Android::setupFontFiles();
|
|
|
|
Utils::Platform::Android::setupLocalizationFiles();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
Utils::Localization::setLocale();
|
|
|
|
|
2022-03-14 18:51:48 +00:00
|
|
|
renderer = Renderer::getInstance();
|
2022-01-12 20:38:37 +00:00
|
|
|
window = Window::getInstance();
|
2023-02-18 11:42:19 +00:00
|
|
|
|
2023-05-07 20:56:24 +00:00
|
|
|
ViewController::getInstance()->setMenuColors();
|
2022-01-04 20:21:26 +00:00
|
|
|
CollectionSystemsManager::getInstance();
|
2022-01-17 17:43:29 +00:00
|
|
|
Screensaver screensaver;
|
2022-01-04 20:21:26 +00:00
|
|
|
MediaViewer mediaViewer;
|
2023-06-21 21:02:19 +00:00
|
|
|
PDFViewer pdfViewer;
|
2022-01-04 20:21:26 +00:00
|
|
|
GuiLaunchScreen guiLaunchScreen;
|
|
|
|
|
|
|
|
if (!window->init()) {
|
2020-10-19 15:28:20 +00:00
|
|
|
LOG(LogError) << "Window failed to initialize";
|
2020-06-21 12:25:28 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2023-11-25 09:31:09 +00:00
|
|
|
#if defined(__ANDROID__)
|
2024-01-14 20:55:09 +00:00
|
|
|
InputOverlay::getInstance().init();
|
2024-01-13 15:14:46 +00:00
|
|
|
|
2023-11-25 09:31:09 +00:00
|
|
|
LOG(LogDebug) << "Android API level: " << SDL_GetAndroidSDKVersion();
|
2023-12-23 19:53:30 +00:00
|
|
|
Utils::Platform::Android::printDeviceInfo();
|
2023-12-23 09:53:46 +00:00
|
|
|
int storageState {SDL_AndroidGetExternalStorageState()};
|
|
|
|
if (storageState == 0) {
|
|
|
|
LOG(LogError) << "Android external storage state: " << SDL_GetError();
|
|
|
|
}
|
|
|
|
else if (storageState == 1) {
|
|
|
|
LOG(LogWarning) << "Android external storage state: mounted read-only";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
LOG(LogDebug) << "Android external storage state: mounted read/write";
|
|
|
|
}
|
|
|
|
LOG(LogDebug) << "Android internal directory: " << AndroidVariables::sInternalDataDirectory;
|
|
|
|
LOG(LogDebug) << "Android external directory: " << AndroidVariables::sExternalDataDirectory;
|
2024-01-06 11:55:29 +00:00
|
|
|
|
feat/update 3.1.0 (#7)
* Added initial text shaping support
* Fixed some font issues
* (Windows) Added initial text shaping support
* (macOS) Added initial text shaping support
* Disabled building of HarfBuzz-subset on Windows and macOS
* (Android) Added initial text shaping support
* Added the nl_NL locale to locale/languages
* Changed the font VRAM usage calculation to actually only include texture data
* Moved the HarfBuzz segment building to a separate function
Also implemented segment caching and fixed an issue where missing glyphs were not handled correctly
* Moved the text shaping to a separate function
* Fixed a text shaping issue when there was a font change for the last character of a string
* Added support for the pl_PL locale
* Changed two font calculation functions to use shaped text
Also consolidated the HarfBuzz segment creation and shaping into a single function
* Added a hack to make shaped text wrap somehow correctly
* Changed the text shaping function to return the segment vector
* Text shaping segments are no longer created by space characters
* RTL text segments are now flagged as such
* Fixed an issue where text was not correctly centered after line breaks
* Reverted some font changes that were not needed after all
* Changed to having HarfBuzz set the horizontal glyph advance
* Fixed another failure mode for the wrapText shaped text hack
* Added a precaution to prevent crashes in case of broken fonts being used
* Made accurate text layout work correctly using HarfBuzz
* Removed the offensive wrapText hacks and added some optimizations
Also changed the three dots to an actual ellipsis Unicode character when abbreviating text
* Reverted a change in TextComponent as it caused unforeseen issues
* Changed Font::shapeText() to pass the segments vector by reference
* Removed a temporary member variable in Font and replaced it with proper argument passing
* Fixed a regression where text shaping stopped working
* Added sharing of glyph atlas entries between shaped glyph entries that need the same texture
* Added support for the ar_EG locale
* Some font-related code and comments cleanup
* Fixed a source file header typo
* Documentation update
* Removed a lot of unnecessary text processing
* Added the ICU library as a dependency
* (Android) Added the ICU library as a dependency
* (macOS) Added the ICU library as a dependency
* (Windows) Added the ICU library as a dependency
* (Windows) Fixed an MSVC compiler warning
* Replaced all built-in Unicode case conversion logic and lookup tables with facilities from the ICU library
* Documentation update
* Updated the pl_PL translations
* Added a menu title font size adjustment for the pl_PL translations
* Removed support for NetBSD and OpenBSD
* Changed a code comment that referred to BSD Unix
* Documentation update
* Silenced some Clang compiler warnings
* Added experimental support for building on Haiku
* (Haiku) Added a ScreenScraper platform identifier
* (Haiku) Added support for the Sony PlayStation Portable (psp) game system
* (Haiku) Added support for the ScummVM Game Engine (scummvm) game system
* Documentation update
* Updated the pl_PL translations
* Changed ScreenSaver to use TextComponent instead of using Font facilities directly
* Changed Window to use TextComponent instead of using Font facilities directly
* Changed ButtonComponent to use TextComponent instead of using Font facilities directly
* Changed SliderComponent to use TextComponent instead of using Font facilities directly
* Reverted ButtonComponent and SliderComponent to render the debug overlays themselves
* Changed DateTimeEditComponent to use TextComponent instead of using Font facilities directly
* Minor code cleanup
* Changed TextEditComponent to use TextComponent instead of using Font facilities directly
* Changed Font::buildTextCache() and Font::renderTextCache() to protected functions
* Changed a compiler silencing option to only apply to Clang
* (Haiku) Updated CMake configuration to make ES-DE build on Haiku Nightly (but no longer on R1/beta4)
* Documentation update
* (Haiku) Added find rule configuration for RetroArch
Also added a single core for testing purposes
* Removed direct use of Font::wrapText() from OptionListComponent, TextEditComponent and TextListComponent
* Removed direct use of Font::wrapText() from TextComponent
* Fixed an issue where ComponentList could generate elements with negative widths
* Added an assertion to GuiComponent::setSize() to check for negative mSize values
* DateTimeEditComponent no longer renders the debug overlay unless there is a string to display
* (FreeBSD) Added support for building with DEINIT_ON_LAUNCH
* (FreeBSD) Added the man page to the CPack configuration
* (FreeBSD) Added support for rebooting and powering off from inside ES-DE
* (FreeBSD) Added fallback method to locate binary
* Added layout and line wrapping support for shaped text and for mixing of LTR and RTL scripts
* Fixed a special line wrapping scenario where a trailing space should be removed
* (Windows) Fixed some MSVC compiler warnings
* Fixed some Clang compiler warnings
* Fixed an issue where theme names in the theme downloader could get abbreviated
* Added support for the ca_AD locale
* Documentation update
* (Android) Fonts and locales are now copied earlier than the other assets as HarfBuzz and libintl need them earlier in the startup process
* Documentation update
* Added support for the de_DE locale
* (Android) Added a new default find rule entry for Flycast as its application ID has been changed
* Documentation update
* Fixed an issue where text shaping could be permanently disabled after editing text
* Fixed a potential issue where globally disabling text shaping could cause space detection to fail
* Added a check for whether a text element has a width defined when the container property is set
* (Android) Changed ePSXe to use %ROM% instead of %ROMSAF%
* (Haiku) Added support for the PDF viewer
* Updated the el_GR.po, es_ES.po, fr_FR.po, it_IT.po, ja_JP.po, ru_RU.po and zh_CN.po locale files
* Documentation update
* (Haiku) Added correct installation directories to the CMake configuration
* (Haiku) Changed to correct installation directories
* (Haiku) Added support for the correct system resource directories
* (Haiku) Made sure es-pdf-convert is found under all circumstances
* Updated the fr_FR translations
* Updated the es_ES translations
* Updated the it_IT translations
* Added a menu title font size adjustment for the it_IT translations
* Updated the ja_JP translations
* Updated the zh_CN translations
* Fixed an issue where scraping using TheGamesDB would crash the application
* Added an extra check in OptionListComponent to avoid potential crashes
* Removed support for the ca_AD locale
* Added a code comment clarification in FileSystemUtil
* Updated the pl_PL translations
* Some minor code modernization in MameNames
* Fixed an issue where returning from a game would sometimes make the helpsystem use the dimmed theme properties
* (Haiku) Added a resource file
* Added a menu title font size adjustment for the de_DE translations
* (Haiku) Added support for some game systems
* (Haiku) Added a HaikuPorts recipe
* (Haiku) Fixed an URI issue in the HaikuPorts recipe
* Documentation update
* (Haiku) Added configuration for a number of game systems
* Updated the it_IT translations
* Documentation update
* (Haiku) Updated the srcGitRev value in the HaikuPorts recipe
* (Haiku) Added configuration for a number of game systems
* Documentation update
* (Haiku) Updated the srcGitRev value in the HaikuPorts recipe
* (Haiku) Added configuration for a number of game systems
* Documentation update
* (Haiku) Added configuration for a number of game systems
* Documentation update
* (Haiku) Updated the srcGitRev value in the HaikuPorts recipe
* Added basic configuration support and menu entries for theme localization
* Changed a theme loading debug message
* (linear-es-de) Fixed an issue where the system logo for saturnjp was incorrectly showing the western variant
* (modern-es-de) Fixed an issue where the system logo for saturnjp was incorrectly showing the western variant
* Updated the it_IT translations
* Added support for using language variables in the theme configuration
* Added localization support to DateTimeComponent
* Added translations for the automatic collection names when used as theme system variables
* Added localization support for the theme game counter
* Added theme contextual hinting to the custom collection summary text in CollectionSystemsManager
Also added translation support for a string that was previously missed
* Added localization support to the label entries in capabilities.xml
* Fixed a regression where horizontal text containers would sometimes not work correctly
* Fixed an issue where text elements defined as gamecount using the systemdata property could not scroll horizontally
* Added support for including theme files from within the colorScheme and fontSize tag pairs
* Added translations for the automatic collection names (short name versions) when used as theme system variables
* Fixed an incorrect code comment in CollectionSystemsManager
* Added translations for the name and fullname systemdata properties for the text element
* Added translation support for the metadata property for the text element
* Updated all locale (.po) files with the theme engine localization additions
* (linear-es-de) Added translations for en_US, en_GB and sv_SE
* Documentation update
* Updated the fr_FR translations
* (linear-es-de) Added translations for fr_FR
* Updated the ja_JP translations
* Updated the zh_CN translations
* (modern-es-de) Added translations for en_US, en_GB, fr_FR and sv_SE
* Updated the es_ES translations
* Updated the ro_RO translations
* (linear-es-de) Added translations for es_ES
* (linear-es-de) Added translations for ro_RO
* (slate-es-de) Added translations for en_US, en_GB and sv_SE
* (linear-es-de) Updated the es_ES translations
* (modern-es-de) Updated the fr_FR translations
* (linear-es-de) Some minor translation changes
* (modern-es-de) Added translations for ro_RO
* (slate-es-de) Added translations for ro_RO
* Updated the it_IT translations
* Updated the pt_BR translations
* (linear-es-de) Added translations for it_IT
* (modern-es-de) Decreased the helpsystem entry spacing
* (modern-es-de) Added translations for es_ES and it_IT
* (slate-es-de) Added translations for es_ES, fr_FR and it_IT
* (linear-es-de) Added translations for pt_BR
* (modern-es-de) Added translations for pt_BR
* (slate-es-de) Added translations for pt_BR
* (Haiku) Added support for the c64, plus4 and vic20 systems
* Documentation update
* (Haiku) Updated the srcGitRev value in the HaikuPorts recipe
* Updated SDL to 2.30.6 on Android, Windows, macOS and the Linux AppImage builds
* Added an ICU filter configuration file
* (macOS) Reduced the ICU library size via a data filter file
* (Windows) Reduced the ICU library size via a data filter file
* Updated the ru_RU translations
* (linear-es-de) Added translations for ru_RU
* (modern-es-de) Added translations for ru_RU
* (slate-es-de) Added translations for ru_RU
* Added a menu title font size adjustment for the ru_RU translations
* Removed an unnecessary element resize in ScrollableContainer
* Fixed a line breaking issue
* Added theme engine translations for 'unknown' metadata values for developer, publisher, genre and players
* Added theme engine translations for 'never' and 'unknown' date values
* (linear-es-de) Added translations for ja_JP and zh_CN
* (modern-es-de) Added translations for ja_JP and zh_CN
* (slate-es-de) Added translations for ja_JP and zh_CN
* Updated all locales with new theme engine translations
* Fixed an issue where the text element defaultValue property no longer worked correctly
* (modern-es-de) Added some capitalized default metadata values
* Documentation update
* pdated the el_GR translations
* (linear-es-de) Updated the system metadata
* (linear-es-de) Added sv_SE translations for all system hardware types
* Updated the de_DE translations
* Updated the pl_PL translations
* Bundled the July 2024 release of the Mozilla TLS/SSL certificates
* Updated the MAME index files to include ROMs up to MAME version 0.269
* (linear-es-de) Added translations for pl_PL
* Added the VirtualXT RetroArch core as an alternative emulator for the dos and pc systems
* Added the Stella 2023 RetroArch core as an alternative emulator for the atari2600 system
* Removed support for the ar_EG, de_DE, el_GR and nl_NL locales and moved their .po files to an archive directory
* Documentation update
* (modern-es-de) Added translations for pl_PL
* (slate-es-de) Added translations for pl_PL
* Updated SDL to 2.30.7 on Android, Windows, macOS and the Linux AppImage builds
* Updated the fr_FR translations
* Added support for the new Lime3DS binary names on Linux, macOS and Windows
* Added some missing find rules for Lime3DS
* (Windows) Added 'Shortcut' as an alternative emulator for the switch system
Also added the .lnk file extension
* Added jgenesis as an alternative emulator for the famicom, gamegear, gb, gbc, genesis, mastersystem, megacd, megacdjp, megadrive, megadrivejp, nes, segacd, sfc, snes and snesna systems on Linux and Windows
* Documentation update
* Added izapple2 standalone as an alternative emulator for the apple2 system on Linux and Windows
* (Android) Added support for the Microsoft Windows (windows) game system using the Winlator emulator
* (Android) Added Winlator PRoot Cmod standalone as an alternative emulator for the windows system
* Documentation update
* (Android) Added support for the PC Arcade Systems (pcarcade) and Taito Type X (type-x) game systems
* Bumped the version to 3.1.0
* (modern-es-de) Eliminated an annoying debug message
* (linear-es-de) Added some missing metadata files
* (linear-es-de) Added some missing sv_SE translations
* Updated the Winlator emulator names
* Documentation update
* Documentation update for the 3.1.0 release
* Updated latest_release.json for the 3.1.0 release
* Fixed a typo in the changelog
* Documentation update
* (Haiku) Updated the srcGitRev value in the HaikuPorts recipe
* Bumped the version to 3.1.1-alpha
* Video player resources are now completely freed up after finishing view transitions
* Changed a rounding in ScrollableContainer to slightly decrease the risk of glyphs getting cut off at the bottom of the container
* Added the Nanum Square Neo Korean font
* Added support for the ko_KR locale
* Fixed an issue where newly entered ScreenScraper username and password values were positioned incorrectly vertically in the account settings menu
* Documentation update
* Changed the position of the ko_KR language
* Changed the ja_JP position in the languages file
* Fixed an issue where attempting to view media for a game that had no downloaded media paused the playback of all static theme videos
* Documentation update
* Added support for the de_DE locale
* Updated the fr_FR translations
* Documentation update
* Updated the de_DE translations
---------
Co-authored-by: Leon Styhre <leon@leonstyhre.com>
2024-09-18 00:23:26 +00:00
|
|
|
if (needResourceCopy) {
|
|
|
|
LOG(LogInfo) << "Application has been updated or it's a new installation, copying "
|
|
|
|
"bundled resources and theme to internal storage...";
|
|
|
|
if (Settings::getInstance()->getBool("SplashScreen"))
|
|
|
|
window->renderSplashScreen(Window::SplashScreenState::RESOURCE_COPY, 0.0f);
|
|
|
|
if (Utils::Platform::Android::setupResources(buildIdentifier)) {
|
|
|
|
LOG(LogError) << "Copying of resources and themes failed";
|
|
|
|
return -1;
|
2023-12-02 11:47:17 +00:00
|
|
|
}
|
|
|
|
}
|
2024-01-06 11:55:29 +00:00
|
|
|
|
|
|
|
if (Utils::Platform::Android::getCreateSystemDirectories()) {
|
|
|
|
if (Settings::getInstance()->getBool("SplashScreen"))
|
|
|
|
window->renderSplashScreen(Window::SplashScreenState::DIR_CREATION, 0.0f);
|
2024-01-04 20:38:46 +00:00
|
|
|
SystemData::createSystemDirectories();
|
2024-01-06 11:55:29 +00:00
|
|
|
}
|
2023-11-25 09:31:09 +00:00
|
|
|
#endif
|
|
|
|
|
2023-02-18 13:06:29 +00:00
|
|
|
#if defined(APPLICATION_UPDATER)
|
2023-02-26 11:50:30 +00:00
|
|
|
if (!noUpdateCheck)
|
|
|
|
ApplicationUpdater::getInstance().checkForUpdates();
|
2023-02-18 13:06:29 +00:00
|
|
|
#endif
|
|
|
|
|
2022-01-04 20:49:22 +00:00
|
|
|
window->pushGui(ViewController::getInstance());
|
2023-01-27 16:34:38 +00:00
|
|
|
|
|
|
|
if (Settings::getInstance()->getBool("SplashScreen"))
|
|
|
|
window->renderSplashScreen(Window::SplashScreenState::SCANNING, 0.0f);
|
2022-01-04 20:21:26 +00:00
|
|
|
|
2023-01-29 21:38:16 +00:00
|
|
|
while (SDL_PollEvent(&event)) {};
|
2021-01-19 19:14:37 +00:00
|
|
|
|
2021-12-09 19:23:09 +00:00
|
|
|
#if defined(_WIN64)
|
|
|
|
// Hide taskbar if the setting for this is enabled.
|
2023-01-08 15:30:39 +00:00
|
|
|
bool taskbarStateChanged {false};
|
|
|
|
unsigned int taskbarState {0};
|
2021-12-09 19:23:09 +00:00
|
|
|
|
|
|
|
if (Settings::getInstance()->getBool("HideTaskbar")) {
|
|
|
|
taskbarStateChanged = true;
|
2022-01-10 17:43:17 +00:00
|
|
|
taskbarState = Utils::Platform::getTaskbarState();
|
|
|
|
Utils::Platform::hideTaskbar();
|
2021-12-09 19:23:09 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-03-17 19:08:33 +00:00
|
|
|
AudioManager::getInstance();
|
2023-06-25 12:33:06 +00:00
|
|
|
|
|
|
|
SDL_version version;
|
|
|
|
SDL_GetVersion(&version);
|
|
|
|
|
|
|
|
LOG(LogInfo) << "SDL version: " << std::to_string(version.major) << "."
|
|
|
|
<< std::to_string(version.minor) << "." << std::to_string(version.patch);
|
|
|
|
|
2024-02-01 22:25:43 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
if (Settings::getInstance()->getBool("VirtualKeyboard"))
|
|
|
|
SDL_SetHint(SDL_HINT_ENABLE_SCREEN_KEYBOARD, "0");
|
|
|
|
else
|
|
|
|
SDL_SetHint(SDL_HINT_ENABLE_SCREEN_KEYBOARD, "1");
|
|
|
|
#else
|
2023-06-25 12:33:06 +00:00
|
|
|
if (version.major > 2 || (version.major == 2 && version.minor >= 28)) {
|
|
|
|
// This will prevent the popup virtual keyboard of any handheld device from being
|
|
|
|
// automatically displayed on top of the ES-DE virtual keyboard.
|
|
|
|
#define SDL_HINT_ENABLE_SCREEN_KEYBOARD "SDL_ENABLE_SCREEN_KEYBOARD"
|
|
|
|
SDL_SetHint(SDL_HINT_ENABLE_SCREEN_KEYBOARD, "0");
|
|
|
|
}
|
2024-01-31 21:54:04 +00:00
|
|
|
#endif
|
2023-06-25 12:33:06 +00:00
|
|
|
|
2021-11-17 20:32:40 +00:00
|
|
|
MameNames::getInstance();
|
2023-08-14 20:40:32 +00:00
|
|
|
ThemeData::populateThemes();
|
2023-01-08 15:30:39 +00:00
|
|
|
loadSystemsReturnCode loadSystemsStatus {loadSystemConfigFile()};
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2023-02-07 17:14:16 +00:00
|
|
|
if (!SystemData::sStartupExitSignal) {
|
|
|
|
if (loadSystemsStatus) {
|
|
|
|
// If there was an issue parsing the es_systems.xml file, display an error message.
|
|
|
|
// If there were no game files found, give the option to the user to quit or to
|
|
|
|
// configure a different ROM directory as well as to generate the game systems
|
|
|
|
// directory structure.
|
|
|
|
if (loadSystemsStatus == INVALID_FILE) {
|
|
|
|
ViewController::getInstance()->invalidSystemsFileDialog();
|
|
|
|
}
|
|
|
|
else if (loadSystemsStatus == NO_ROMS) {
|
|
|
|
ViewController::getInstance()->noGamesDialog();
|
|
|
|
}
|
2020-08-15 08:12:19 +00:00
|
|
|
}
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2023-02-07 17:14:16 +00:00
|
|
|
// Don't generate controller events while we're loading.
|
|
|
|
SDL_GameControllerEventState(SDL_DISABLE);
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2023-02-07 17:14:16 +00:00
|
|
|
// Preload system view and all gamelist views.
|
|
|
|
ViewController::getInstance()->preload();
|
2022-08-19 15:02:25 +00:00
|
|
|
}
|
2022-08-14 18:24:26 +00:00
|
|
|
|
2023-02-07 17:14:16 +00:00
|
|
|
if (!SystemData::sStartupExitSignal) {
|
2023-02-26 11:50:30 +00:00
|
|
|
if (loadSystemsStatus == loadSystemsReturnCode::LOADING_OK)
|
2023-02-09 23:34:24 +00:00
|
|
|
ThemeData::themeLoadedLogOutput();
|
2023-02-21 17:52:48 +00:00
|
|
|
|
|
|
|
if (!loadSystemsStatus)
|
|
|
|
ViewController::getInstance()->goToStart(true);
|
|
|
|
|
|
|
|
// Check if any of the enabled systems have an invalid alternative emulator entry,
|
|
|
|
// which means that a label is present in the gamelist.xml file which is not matching
|
|
|
|
// any command tag in es_systems.xml.
|
|
|
|
for (auto system : SystemData::sSystemVector) {
|
|
|
|
if (system->getAlternativeEmulator().substr(0, 9) == "<INVALID>") {
|
|
|
|
ViewController::getInstance()->invalidAlternativeEmulatorDialog();
|
|
|
|
break;
|
2023-02-07 17:14:16 +00:00
|
|
|
}
|
2020-08-03 09:39:04 +00:00
|
|
|
}
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2024-02-11 21:58:32 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
if (!Utils::FileSystem::exists(FileData::getROMDirectory() + ".nomedia")) {
|
|
|
|
LOG(LogInfo) << "Creating \"no media\" file \""
|
|
|
|
<< FileData::getROMDirectory() + ".nomedia"
|
|
|
|
<< "\"...";
|
|
|
|
Utils::FileSystem::createEmptyFile(FileData::getROMDirectory() + ".nomedia");
|
|
|
|
if (!Utils::FileSystem::exists(FileData::getROMDirectory() + ".nomedia")) {
|
|
|
|
LOG(LogWarning) << "Couldn't create file, permission problems?";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-02-07 17:14:16 +00:00
|
|
|
// Generate controller events since we're done loading.
|
|
|
|
SDL_GameControllerEventState(SDL_ENABLE);
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2023-02-07 17:14:16 +00:00
|
|
|
lastTime = SDL_GetTicks();
|
2020-10-18 10:45:19 +00:00
|
|
|
|
2023-02-26 11:57:16 +00:00
|
|
|
#if defined(APPLICATION_UPDATER)
|
|
|
|
if (ApplicationUpdater::getInstance().getResults())
|
|
|
|
ViewController::getInstance()->updateAvailableDialog();
|
2024-04-08 17:26:08 +00:00
|
|
|
else
|
|
|
|
HttpReq::cleanupCurlMulti();
|
2023-02-26 11:57:16 +00:00
|
|
|
#endif
|
|
|
|
|
2023-07-31 15:42:38 +00:00
|
|
|
#if defined(_WIN64)
|
|
|
|
if (Settings::getInstance()->getBool("PortableMode")) {
|
|
|
|
// If it's the portable Windows release then create a release file, and check if there
|
|
|
|
// are any release files from different versions than the one currently running.
|
|
|
|
// If this is the case an unsafe upgrade has taken place, probably by simply unpacking
|
|
|
|
// the new release on top of the old one.
|
|
|
|
bool releaseFileExists {true};
|
2023-08-02 18:36:29 +00:00
|
|
|
const std::filesystem::path releaseFile {Utils::FileSystem::getExePath() + "/r" +
|
|
|
|
std::to_string(PROGRAM_RELEASE_NUMBER) +
|
|
|
|
".rel"};
|
|
|
|
if (!Utils::FileSystem::exists(releaseFile.string()))
|
|
|
|
releaseFileExists = Utils::FileSystem::createEmptyFile(releaseFile);
|
2023-07-31 15:42:38 +00:00
|
|
|
if (releaseFileExists) {
|
|
|
|
for (auto& file : Utils::FileSystem::getMatchingFiles(
|
|
|
|
Utils::FileSystem::getExePath() + "/*.rel")) {
|
2023-08-02 18:36:29 +00:00
|
|
|
if (Utils::FileSystem::getFileName(file) != releaseFile.filename()) {
|
2023-07-31 15:42:38 +00:00
|
|
|
LOG(LogWarning) << "It seems as if an unsafe upgrade has been made";
|
|
|
|
ViewController::getInstance()->unsafeUpgradeDialog();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-12-15 23:00:10 +00:00
|
|
|
if (Settings::getInstance()->getBool("LegacyAppDataDirectory"))
|
|
|
|
ViewController::getInstance()->legacyAppDataDialog();
|
|
|
|
|
|
|
|
if (migratedSettings) {
|
|
|
|
LOG(LogInfo) << "Migrated settings from a legacy application data directory structure";
|
|
|
|
ViewController::getInstance()->migratedAppDataFilesDialog();
|
|
|
|
}
|
|
|
|
|
2023-02-07 17:14:16 +00:00
|
|
|
LOG(LogInfo) << "Application startup time: "
|
|
|
|
<< std::chrono::duration_cast<std::chrono::milliseconds>(
|
|
|
|
std::chrono::system_clock::now() - applicationStartTime)
|
|
|
|
.count()
|
|
|
|
<< " ms";
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2023-02-21 17:52:48 +00:00
|
|
|
// Open the input configuration GUI if the force flag was passed from the command line.
|
|
|
|
if (forceInputConfig) {
|
|
|
|
ViewController::getInstance()->cancelViewTransitions();
|
|
|
|
window->pushGui(new GuiDetectDevice(false, true, nullptr));
|
|
|
|
}
|
|
|
|
|
2023-02-07 17:14:16 +00:00
|
|
|
// Main application loop.
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2023-02-07 17:14:16 +00:00
|
|
|
if (!SystemData::sStartupExitSignal) {
|
2022-01-12 20:38:37 +00:00
|
|
|
#if defined(__EMSCRIPTEN__)
|
2023-02-07 17:14:16 +00:00
|
|
|
emscripten_set_main_loop(&applicationLoop, 0, 1);
|
2022-01-12 20:38:37 +00:00
|
|
|
#else
|
2023-02-07 17:14:16 +00:00
|
|
|
applicationLoop();
|
2022-01-12 20:38:37 +00:00
|
|
|
#endif
|
2023-02-07 17:14:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
LOG(LogInfo) << "Exit signal received, aborting application startup";
|
|
|
|
}
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2022-01-04 20:49:22 +00:00
|
|
|
while (window->peekGui() != ViewController::getInstance())
|
2022-01-04 20:21:26 +00:00
|
|
|
delete window->peekGui();
|
|
|
|
window->deinit();
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2023-11-10 19:42:14 +00:00
|
|
|
TextureResource::setExit();
|
2023-07-20 19:59:28 +00:00
|
|
|
CollectionSystemsManager::getInstance()->deinit(true);
|
2020-06-21 12:25:28 +00:00
|
|
|
SystemData::deleteSystems();
|
2021-11-15 21:43:06 +00:00
|
|
|
NavigationSounds::getInstance().deinit();
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2021-07-07 18:03:42 +00:00
|
|
|
#if defined(FREEIMAGE_LIB)
|
2020-06-21 12:25:28 +00:00
|
|
|
// Call this ONLY when linking with FreeImage as a static library.
|
|
|
|
FreeImage_DeInitialise();
|
2021-07-07 18:03:42 +00:00
|
|
|
#endif
|
2017-10-17 20:05:12 +00:00
|
|
|
|
2021-07-07 18:03:42 +00:00
|
|
|
#if defined(_WIN64)
|
2020-07-18 11:21:44 +00:00
|
|
|
// If the taskbar state was changed (taskbar was hidden), then revert it.
|
|
|
|
if (taskbarStateChanged)
|
2022-01-10 17:43:17 +00:00
|
|
|
Utils::Platform::revertTaskbarState(taskbarState);
|
2021-07-07 18:03:42 +00:00
|
|
|
#endif
|
2020-07-18 11:21:44 +00:00
|
|
|
|
2022-01-10 17:43:17 +00:00
|
|
|
Utils::Platform::processQuitMode();
|
2019-08-14 23:50:23 +00:00
|
|
|
|
2023-12-16 11:30:13 +00:00
|
|
|
LOG(LogInfo) << "ES-DE cleanly shutting down";
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2021-07-07 18:03:42 +00:00
|
|
|
#if defined(_WIN64)
|
2020-12-31 12:50:55 +00:00
|
|
|
FreeConsole();
|
2021-07-07 18:03:42 +00:00
|
|
|
#endif
|
2020-07-03 18:23:51 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
return 0;
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|