Merge branch '652-allow-system-placeholders-to-be-a-combination-of-text-and-image-make-text-and-image-customizable' into 575-theme-add-a-modern-clean-switch-like-theme-as-an-official-theme-in-es-de-to-choose-from

# Conflicts:
#	es-app/src/views/gamelist/DetailedGameListView.cpp
#	es-app/src/views/gamelist/GridGameListView.cpp
#	es-app/src/views/gamelist/VideoGameListView.cpp
This commit is contained in:
Sophia Hadash 2021-10-11 23:39:31 +02:00
commit 642c8304d9
373 changed files with 54861 additions and 747 deletions

View file

@ -134,7 +134,7 @@ SpacesInCStyleCastParentheses: false
SpacesInParentheses: false SpacesInParentheses: false
SpacesInSquareBrackets: false SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false SpaceBeforeSquareBrackets: false
Standard: c++14 Standard: c++17
StatementMacros: StatementMacros:
- Q_UNUSED - Q_UNUSED
- QT_REQUIRE_VERSION - QT_REQUIRE_VERSION

View file

@ -11,8 +11,8 @@
### Detailed list of changes ### Detailed list of changes
* Added alternative emulators support where additional emulators can be defined in es_systems.xml and be selected system-wide or per game via the user interface * Added alternative emulators support where additional emulators can be defined in es_systems.xml and be selected system-wide or per game via the user interface
* Populated the bundled es_systems.xml files with alternative emulator entries for must RetroArch cores * Populated the bundled es_systems.xml files with alternative emulator entries for most RetroArch cores
* Added a virtual keyboard partly based on code from batocera-emulationstation * Added a virtual keyboard, partly based on code from batocera-emulationstation
* Added the ability to make complementary game system customizations without having to replace the entire bundled es_systems.xml file * Added the ability to make complementary game system customizations without having to replace the entire bundled es_systems.xml file
* Added support for an optional \<systemsortname\> tag for es_systems.xml that can be used to override the default \<fullname\> systems sorting * Added support for an optional \<systemsortname\> tag for es_systems.xml that can be used to override the default \<fullname\> systems sorting
* Improved the gamelist filter screen to not allow filtering of values where there is no actual data to filter, e.g. Favorites for a system with no favorite games * Improved the gamelist filter screen to not allow filtering of values where there is no actual data to filter, e.g. Favorites for a system with no favorite games
@ -20,7 +20,11 @@
* Added the ability to filter on blank/unknown values for Genre, Player, Developer, Publisher and Alternative emulator. * Added the ability to filter on blank/unknown values for Genre, Player, Developer, Publisher and Alternative emulator.
* Added a filter for "Alternative emulator" and sorted the filters in the same order as the metadata editor fields * Added a filter for "Alternative emulator" and sorted the filters in the same order as the metadata editor fields
* Added a menu option to change the application exit key combination * Added a menu option to change the application exit key combination
* Lowered the minimum supported screen resolution from 640x480 to 224x224 to support arcade cabinet displays such as those running at 384x224 and 224x384
* Expanded the themeable options for "helpsystem" to support custom button graphics, dimmed text and icon colors, upper/lower/camel case and custom spacing * Expanded the themeable options for "helpsystem" to support custom button graphics, dimmed text and icon colors, upper/lower/camel case and custom spacing
* Made the scrolling speed of ScrollableContainer more consistent across various screen resolutions and display aspect ratios
* Made the game name and description stop scrolling when running the media viewer, the screensaver or when running in the background while a game is launched
* Added notification popups when plugging in or removing controllers
* Added support for using the left and right trigger buttons in the help prompts * Added support for using the left and right trigger buttons in the help prompts
* Removed the "Choose" entry from the help prompts in the gamelist view * Removed the "Choose" entry from the help prompts in the gamelist view
* Changed the "Toggle screensaver" help entry in the system view to simply "Screensaver" * Changed the "Toggle screensaver" help entry in the system view to simply "Screensaver"
@ -31,14 +35,21 @@
* Added a blinking cursor to TextEditComponent * Added a blinking cursor to TextEditComponent
* Changed the filter description "Text filter (game name)" to "Game name" * Changed the filter description "Text filter (game name)" to "Game name"
* Added support for multi-select total count and exclusive multi-select to OptionListComponent * Added support for multi-select total count and exclusive multi-select to OptionListComponent
* Added support for key repeat to OptionListComponent, making it possible to cycle through the options by holding the left or right button
* Added key repeat for the "Jump to" and "Sort games by" selectors on the game options menu
* Added key repeat when editing the "Release date" entry in the metadata editor (DateTimeEditComponent)
* Achieved a massive speed improvement for OptionListComponent by not resizing each added MenuComponent row (most notable in the filter GUI) * Achieved a massive speed improvement for OptionListComponent by not resizing each added MenuComponent row (most notable in the filter GUI)
* Made multiple optimizations to the GUI components by removing lots of unnecessary function calls for sizing, placement, opacity changes etc.
* Simplified the logic for info popups and prepared the code for the future "multiple popups" feature
* Added support for a new type of "flat style" button to ButtonComponent * Added support for a new type of "flat style" button to ButtonComponent
* Added support for correctly navigating arbitrarily sized ComponentGrid entries, i.e. those spanning multiple cells * Added support for correctly navigating arbitrarily sized ComponentGrid entries, i.e. those spanning multiple cells
* Bundled the bold font version of Fontfabric Akrobat * Bundled the bold font version of Fontfabric Akrobat
* Added RapidJSON as a Git subtree
* Added the GLM (OpenGL Mathematics) library as a Git subtree * Added the GLM (OpenGL Mathematics) library as a Git subtree
* Replaced all built-in matrix and vector data types and functions with GLM library equivalents * Replaced all built-in matrix and vector data types and functions with GLM library equivalents
* Replaced some additional math functions and moved the remaining built-in functions to a math utility namespace * Replaced some additional math functions and moved the remaining built-in functions to a math utility namespace
* Added a function to generate MD5 hashes * Added a function to generate MD5 hashes
* Made an optimization for SVG graphics to avoid a lot of unnecessary re-rasterizations
* Moved the "complex" mode functionality from GuiComplexTextEditPopup into GuiTextEditPopup and removed the source files for the former * Moved the "complex" mode functionality from GuiComplexTextEditPopup into GuiTextEditPopup and removed the source files for the former
* Replaced the String::Utils::trim function with better code and removed some inline text trimming throughout the application * Replaced the String::Utils::trim function with better code and removed some inline text trimming throughout the application
* Increased the warning level for Clang/LLVM and GCC by adding -Wall, -Wpedantic and some additional flags * Increased the warning level for Clang/LLVM and GCC by adding -Wall, -Wpedantic and some additional flags
@ -49,16 +60,22 @@
### Bug fixes ### Bug fixes
* When multi-scraping in interactive mode with "Auto-accept single game matches" enabled, the game name could not be refined if there were no games found * Setting a really small font size in a theme would crash the application
* When multi-scraping in interactive mode, the game counter was not decreased when skipping games, making it impossible to skip the final games in the queue * When scraping in interactive mode with "Auto-accept single game matches" enabled, the game name could not be refined if there were no games found
* When multi-scraping in interactive mode, "No games found" results could be accepted using the "A" button * When scraping in interactive mode, the game counter was not decreased when skipping games, making it impossible to skip the final games in the queue
* When scraping in interactive mode, "No games found" results could be accepted using the "A" button
* When scraping in interactive mode, any refining done using the "Y" button shortcut would not be shown when doing another refine using the "Refine search" button * When scraping in interactive mode, any refining done using the "Y" button shortcut would not be shown when doing another refine using the "Refine search" button
* Under some circumstances ScrollableContainer (used for the game descriptions) would contain a partially rendered bottom line
* If the TextListComponent height was not evenly dividable by the font height + line spacing, a partial bottom row would get rendered
* The line spacing for TextListComponent was incorrectly calculated for some resolutions such as 2560x1440
* Removing games from custom collections did not remove their filter index entries * Removing games from custom collections did not remove their filter index entries
* Input consisting of only whitespace characters would get accepted by TextEditComponent which led to various strange behaviors * Input consisting of only whitespace characters would get accepted by TextEditComponent which led to various strange behaviors
* Leading and trailing whitespace characters would not get trimmed from the collection name when creating a new custom collection * Leading and trailing whitespace characters would not get trimmed from the collection name when creating a new custom collection
* Leading and trailing whitespace characters would get included in scraper search refines and TheGamesDB searches * Leading and trailing whitespace characters would get included in scraper search refines and TheGamesDB searches
* Game name (text) filters were matching the system names for collection systems if the "Show system names in collections" setting was enabled * Game name (text) filters were matching the system names for collection systems if the "Show system names in collections" setting was enabled
* Brackets such as () and [] were filtered from game names in collection systems if the "Show system names in collections" setting was enabled * Brackets such as () and [] were filtered from game names in collection systems if the "Show system names in collections" setting was enabled
* Help prompts were missing for the "Rating" and "Release date" fields in the metadata editor
* There was some strange behavior in DateTimeEditComponent when changing the date all the way down to 1970-01-01
* When navigating menus, the separator lines and menu components did not align properly and moved up and down slightly * When navigating menus, the separator lines and menu components did not align properly and moved up and down slightly
* When scrolling in menus, pressing other buttons than "Up" or "Down" did not stop the scrolling which caused all sorts of weird behavior * When scrolling in menus, pressing other buttons than "Up" or "Down" did not stop the scrolling which caused all sorts of weird behavior
* With the menu scale-up effect enabled and entering a submenu before the parent menu was completely scaled up, the parent would get stuck at a semi-scaled size * With the menu scale-up effect enabled and entering a submenu before the parent menu was completely scaled up, the parent would get stuck at a semi-scaled size

View file

@ -1,28 +0,0 @@
# Find the RapidJSON parsing library.
#
# Sets the usual variables expected for find_package scripts:
#
# RAPIDJSON_INCLUDE_DIR - header location
# RAPIDJSON_FOUND - true if RAPIDJSON was found.
include(FindPkgMacros)
if (NOT WIN32)
find_package(PkgConfig)
pkg_check_modules(RAPIDJSON REQUIRED RapidJSON>=1.0.0)
endif (NOT WIN32)
if (WIN32)
find_path(RAPIDJSON_INCLUDE_DIR rapidjson/rapidjson.h)
# Support the REQUIRED and QUIET arguments, and set RAPIDJSON_FOUND if found.
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args(RAPIDJSON DEFAULT_MSG RAPIDJSON_INCLUDE_DIR)
if (NOT RAPIDJSON_INCLUDE_DIR)
message(FATAL_ERROR "RapidJSON include files not found!")
endif()
endif (WIN32)

View file

@ -90,7 +90,6 @@ if(NOT WIN32)
find_package(FreeImage REQUIRED) find_package(FreeImage REQUIRED)
find_package(Freetype REQUIRED) find_package(Freetype REQUIRED)
find_package(Pugixml REQUIRED) find_package(Pugixml REQUIRED)
find_package(RapidJSON REQUIRED)
find_package(SDL2 REQUIRED) find_package(SDL2 REQUIRED)
if(VLC_PLAYER) if(VLC_PLAYER)
find_package(VLC REQUIRED) find_package(VLC REQUIRED)
@ -243,11 +242,11 @@ set(COMMON_INCLUDE_DIRS ${CURL_INCLUDE_DIR}
${FreeImage_INCLUDE_DIRS} ${FreeImage_INCLUDE_DIRS}
${FREETYPE_INCLUDE_DIRS} ${FREETYPE_INCLUDE_DIRS}
${PUGIXML_INCLUDE_DIRS} ${PUGIXML_INCLUDE_DIRS}
${RAPIDJSON_INCLUDE_DIRS}
${SDL2_INCLUDE_DIR} ${SDL2_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/external/CImg ${CMAKE_CURRENT_SOURCE_DIR}/external/CImg
${CMAKE_CURRENT_SOURCE_DIR}/external/glm ${CMAKE_CURRENT_SOURCE_DIR}/external/glm
${CMAKE_CURRENT_SOURCE_DIR}/external/nanosvg/src ${CMAKE_CURRENT_SOURCE_DIR}/external/nanosvg/src
${CMAKE_CURRENT_SOURCE_DIR}/external/rapidjson/include
${CMAKE_CURRENT_SOURCE_DIR}/es-core/src) ${CMAKE_CURRENT_SOURCE_DIR}/es-core/src)
if(VLC_PLAYER) if(VLC_PLAYER)
set(COMMON_INCLUDE_DIRS ${COMMON_INCLUDE_DIRS} ${VLC_INCLUDE_DIR}) set(COMMON_INCLUDE_DIRS ${COMMON_INCLUDE_DIRS} ${VLC_INCLUDE_DIR})

View file

@ -27,7 +27,7 @@ There are some dependencies that need to be fulfilled in order to build ES-DE. T
All of the required packages can be installed with apt-get: All of the required packages can be installed with apt-get:
``` ```
sudo apt-get install build-essential clang-format git cmake libsdl2-dev libavcodec-dev libavfilter-dev libavformat-dev libavutil-dev libfreeimage-dev libfreetype6-dev libcurl4-openssl-dev libpugixml-dev rapidjson-dev libasound2-dev libgl1-mesa-dev sudo apt-get install build-essential clang-format git cmake libsdl2-dev libavcodec-dev libavfilter-dev libavformat-dev libavutil-dev libfreeimage-dev libfreetype6-dev libcurl4-openssl-dev libpugixml-dev libasound2-dev libgl1-mesa-dev
``` ```
If building with the optional VLC video player, the following packages are also needed: If building with the optional VLC video player, the following packages are also needed:
@ -39,7 +39,7 @@ sudo apt-get install vlc libvlc-dev
Use dnf to install all the required packages: Use dnf to install all the required packages:
``` ```
sudo dnf install gcc-c++ clang-tools-extra cmake SDL2-devel ffmpeg-devel freeimage-devel freetype-devel curl-devel pugixml-devel rapidjson-devel alsa-lib-devel mesa-libGL-devel sudo dnf install gcc-c++ clang-tools-extra cmake SDL2-devel ffmpeg-devel freeimage-devel freetype-devel curl-devel pugixml-devel alsa-lib-devel mesa-libGL-devel
``` ```
If building with the VLC video player, add the RPM Fusion repository. If building with the VLC video player, add the RPM Fusion repository.
@ -56,7 +56,7 @@ sudo dnf install vlc vlc-devel
Use pacman to install all the required packages: Use pacman to install all the required packages:
``` ```
sudo pacman -S gcc clang make cmake pkgconf sdl2 ffmpeg freeimage freetype2 pugixml rapidjson sudo pacman -S gcc clang make cmake pkgconf sdl2 ffmpeg freeimage freetype2 pugixml
``` ```
If building with the optional VLC video player, the following package is also needed: If building with the optional VLC video player, the following package is also needed:
@ -70,7 +70,7 @@ Note: The Raspberry Pi 4 is the minimum recommended model to use with ES-DE. As
All of the required packages can be installed with apt-get: All of the required packages can be installed with apt-get:
``` ```
sudo apt-get install clang-format cmake libsdl2-dev libavcodec-dev libavfilter-dev libavformat-dev libavutil-dev libfreeimage-dev libcurl4-gnutls-dev libpugixml-dev rapidjson-dev sudo apt-get install clang-format cmake libsdl2-dev libavcodec-dev libavfilter-dev libavformat-dev libavutil-dev libfreeimage-dev libcurl4-gnutls-dev libpugixml-dev
``` ```
If building with the optional VLC video player, the following packages are also needed: If building with the optional VLC video player, the following packages are also needed:
@ -87,7 +87,7 @@ sudo apt-get install libcec-dev libp8-platform-dev
Use pkg to install the dependencies: Use pkg to install the dependencies:
``` ```
pkg install git pkgconf cmake sdl2 ffmpeg freeimage pugixml rapidjson pkg install git pkgconf cmake sdl2 ffmpeg freeimage pugixml
``` ```
If building with the optional VLC video player, the following package is also needed: If building with the optional VLC video player, the following package is also needed:
@ -101,7 +101,7 @@ Clang/LLVM and cURL should already be included in the base OS installation.
Use pkgin to install the dependencies: Use pkgin to install the dependencies:
``` ```
pkgin install clang git cmake pkgconf SDL2 ffmpeg4 freeimage pugixml rapidjson pkgin install clang git cmake pkgconf SDL2 ffmpeg4 freeimage pugixml
``` ```
If building with the optional VLC video player, the following package is also needed: If building with the optional VLC video player, the following package is also needed:
@ -125,16 +125,6 @@ pkg_add vlc
In the same manner as for FreeBSD, Clang/LLVM and cURL should already be installed by default. In the same manner as for FreeBSD, Clang/LLVM and cURL should already be installed by default.
RapidJSON is not part of the OpenBSD ports/package collection as of v6.8, so you need to compile it yourself. At the time of writing, the latest release v1.1.0 does not compile on OpenBSD, so you need to use the latest available code from the master branch:
```
git clone https://github.com/Tencent/rapidjson.git
cd rapidjson
cmake .
make
make install
```
Pugixml does exist in the package collection but somehow this version is not properly detected by CMake, so you need to compile this manually as well: Pugixml does exist in the package collection but somehow this version is not properly detected by CMake, so you need to compile this manually as well:
``` ```
@ -440,7 +430,7 @@ Be aware that Homebrew can be really slow, especially when it compiles packages
Install the required tools and dependencies: Install the required tools and dependencies:
``` ```
brew install clang-format cmake pkg-config nasm fdk-aac libvpx sdl2 freeimage freetype pugixml rapidjson brew install clang-format cmake pkg-config nasm fdk-aac libvpx sdl2 freeimage freetype pugixml
``` ```
If building with the optional VLC video player, then run this as well: If building with the optional VLC video player, then run this as well:
@ -870,18 +860,6 @@ cmake -G "MinGW Makefiles" -DBUILD_SHARED_LIBS=ON .
make make
``` ```
[RapidJSON](http://rapidjson.org)
For RapidJSON you don't need to compile anything, you just need the include files.
At the time of writing, the latest release v1.1.0 generates some compiler warnings on Windows, but this can be avoided by using the latest available code from the master branch:
```
git clone git://github.com/Tencent/rapidjson.git
```
**Clone the ES-DE repository:** **Clone the ES-DE repository:**
This works the same as on Unix or macOS, just run the following: This works the same as on Unix or macOS, just run the following:
@ -903,7 +881,7 @@ As there is no standardized include directory structure in Windows, you need to
Make a directory in your build environment tree, for instance under `C:\Programming\include` Make a directory in your build environment tree, for instance under `C:\Programming\include`
Copy the include files for cURL, FFmpeg, FreeImage, FreeType, GLEW, pugixml, RapidJSON, SDL2 and optionally VLC to this directory. Copy the include files for cURL, FFmpeg, FreeImage, FreeType, GLEW, pugixml, SDL2 and optionally VLC to this directory.
You may need to create the SDL2 directory manually and copy the header files there. You may need to create the SDL2 directory manually and copy the header files there.
@ -924,7 +902,6 @@ libavformat/
libavutil/ libavutil/
pugiconfig.hpp pugiconfig.hpp
pugixml.hpp pugixml.hpp
rapidjson/
SDL2/ SDL2/
vlc/ (only if building with the VLC video player) vlc/ (only if building with the VLC video player)
``` ```

View file

@ -1,83 +1,90 @@
# EmulationStation Desktop Edition (ES-DE) v1.2 (development version) - Themes # EmulationStation Desktop Edition (ES-DE) v1.2 (development version) - Themes
**Note:** If creating theme sets specifically for ES-DE, please add `-DE` to the theme name, as in `rbsimple-DE`. Because the ES-DE theme support has already deviated somehow from the RetroPie EmulationStation fork and will continue to deviate further in the future, the theme set will likely not be backwards compatible. It would be confusing and annoying for a user that downloads and attempts to use an ES-DE theme set in another EmulationStation fork only to get crashes, error messages or corrupted graphics. At least the -DE extension is a visual indicator that it's an ES-DE specific theme set. **Note:** This document is only relevant for the current ES-DE development version, if you would like to see the documentation for the latest stable release, refer to [THEMES.md](THEMES.md) instead.
Also note that this document is only relevant for the current ES-DE development version, if you would like to see the documentation for the latest stable release, refer to [THEMES.md](THEMES.md) instead. If creating theme sets specifically for ES-DE, please add `-DE` to the theme name, as in `rbsimple-DE`. Because the ES-DE theme support has already deviated somehow from the RetroPie EmulationStation fork and will continue to deviate further in the future, the theme set will likely not be backwards compatible. It would be confusing and annoying for a user that downloads and attempts to use an ES-DE theme set in another EmulationStation fork only to get crashes, error messages or corrupted graphics. At least the -DE extension is a visual indicator that it's an ES-DE specific theme set.
ES-DE allows each system to have its own "theme." A theme is a collection **views** that define some **elements**, each with their own **properties**. Table of contents:
The first place ES-DE will check for a theme is in the system's `<path>` folder, for a theme.xml file: [[_TOC_]]
* `[SYSTEM_PATH]/theme.xml`
If that file doesn't exist, ES-DE will try to find the theme in the current **theme set**. Theme sets are just a collection of individual system themes arranged in the "themes" folder under some name. A theme set can provide a default theme that will be used if there is no matching system theme. Here's an example: ## Introduction
ES-DE allows the grouping of themes for multiple game systems into a **theme set**. Each theme is a collection of **views** that define some **elements**, each with their own **properties**.
Every game system has its own subdirectory within the theme set directory structure, and these are defined in the systems configuration file `es_systems.xml` either via the optional `<theme>` tag, or otherwise via the mandatory `<name>` tag. When ES-DE populates a system on startup it will look for a file named `theme.xml` in each such directory.
By placing a theme.xml file directly in the root of the theme set directory, that file will be processed as a default if there is no game-specific theme.xml file available.
In the example below, we have a theme set named `mythemeset-DE` which includes the `snes` and `nes` systems. Assuming you have some games installed for these systems, the files `mythemeset-DE/nes/theme.xml` and `mythemeset-DE/snes/theme.xml` will be processed on startup. If there are no games available for a system, its theme.xml file will be skipped.
The directory structure of our example theme set could look something like the following:
``` ```
... ...
themes/ themes/
my_theme_set/ mythemeset-DE/
snes/ core/
theme.xml font.ttf
my_cool_background.jpg bold_font.ttf
frame.png
nes/ nes/
theme.xml theme.xml
my_other_super_cool_background.jpg background.jpg
logo.svg
logo_video.svg
common_resources/
my_font.ttf
theme.xml (Default theme)
another_theme_set/
snes/ snes/
theme.xml theme.xml
some_resource.svg background.jpg
logo.svg
logo_video.svg
fonts.xml
theme.xml
``` ```
The theme set system makes it easy for users to try different themes and allows distributions to include multiple theme options. Users can change the currently active theme set in the "UI Settings" menu. The option is only visible if at least one theme set exists. The theme set approach makes it easy for users to install different themes and choose between them from the _UI Settings_ menu.
There are two places ES-DE can load theme sets from: There are two places that ES-DE can load theme sets from:
* `[HOME]/.emulationstation/themes/[CURRENT_THEME_SET]/[SYSTEM_THEME]/theme.xml` * `[HOME]/.emulationstation/themes/[THEME_SET]/`
* `[INSTALLATION PATH]/themes/[CURRENT_THEME_SET]/[SYSTEM_THEME]/theme.xml` * `[INSTALLATION PATH]/themes/[THEME_SET]/`
An example installation path would be: \ An example installation path would be: \
`/usr/share/emulationstation/themes/[CURRENT_THEME_SET]/[SYSTEM_THEME]/theme.xml` `/usr/share/emulationstation/themes/rbsimple-DE/`
`[SYSTEM_THEME]` is the `<theme>` tag for the system, as defined in `es_systems.cfg`. If the `<theme>` tag is not set, ES-DE will use the system's `<name>`. If a theme set with the same name exists in both locations, the one in the home directory will be loaded and the other one will be skipped.
If both files happen to exist, ES-DE will pick the first one (the one located in the home directory). ## Simple example
Again, the `[CURRENT_THEME_SET]` value is set in the "UI Settings" menu. If it has not been set yet or the previously selected theme set is missing, the first available theme set will be used as the default. Here is a very simple theme that changes the color of the game description text:
# Simple Example
Here is a very simple theme that changes the description text's color:
```xml ```xml
<theme> <theme>
<formatVersion>7</formatVersion> <formatVersion>7</formatVersion>
<view name="detailed"> <view name="detailed">
<text name="description"> <text name="description">
<color>00FF00</color> <color>00FF00</color>
</text> </text>
<image name="my_image" extra="true"> <image name="frame" extra="true">
<pos>0.5 0.5</pos> <pos>0.5 0.5</pos>
<origin>0.5 0.5</origin> <origin>0.5 0.5</origin>
<size>0.8 0.8</size> <size>0.8 0.8</size>
<path>./my_art/my_awesome_image.jpg</path> <path>./core/frame.png</path>
</image> </image>
</view> </view>
</theme> </theme>
``` ```
# How it works ## How it works
Everything must be inside a `<theme>` tag. All configuration must be contained within a `<theme>` tag pair.
**The `<formatVersion>` tag *must* be specified**. This is the version of the theming system the theme was designed for. The `<formatVersion>` tag **must** be specified. This is the version of the theming system the theme was designed for.
The current version is 7. The current version is 7.
A *view* can be thought of as a particular "screen" within EmulationStation. Views are defined like this: A _view_ can be thought of as a particular "screen" within ES-DE. Views are defined like this:
```xml ```xml
<view name="ViewNameHere"> <view name="ViewNameHere">
@ -85,63 +92,61 @@ A *view* can be thought of as a particular "screen" within EmulationStation. Vie
</view> </view>
``` ```
An *element* is a particular visual element, such as an image or a piece of text. You can modify an element that already exists for a particular view, as was done for the "description" example:
An *element* is a particular visual element, such as an image or a piece of text. You can either modify an element that already exists for a particular view (as is done in the "description" example), like this:
```xml ```xml
<elementTypeHere name="ExistingElementNameHere"> <elementTypeHere name="ExistingElementNameHere">
... define properties here ... ... define properties here ...
</elementTypeHere> </elementTypeHere>
``` ```
Or, you can create your own elements by adding `extra="true"` (as is done in the "my_image" example) like this: Or you can create your own elements by adding `extra="true"`, as was done for the "frame" example:
```xml ```xml
<elementTypeHere name="YourUniqueElementNameHere" extra="true"> <elementTypeHere name="YourUniqueElementNameHere" extra="true">
... define properties here ... ... define properties here ...
</elementTypeHere> </elementTypeHere>
``` ```
"Extra" elements will be drawn in the order they are defined (so define backgrounds first!). When they get drawn relative to the pre-existing elements depends on the view. Make sure "extra" element names do not clash with existing element names! An easy way to protect against this is to just start all your extra element names with some prefix like "e_". "Extra" elements will be drawn in the order they are defined (so make sure to define backgrounds first). In what order they get drawn relative to the pre-existing elements depends on the view. Make sure "extra" element names do not clash with existing element names. An easy way to protect against this is to start all your extra element names with a prefix such as "e_".
*Properties* control how a particular *element* looks - for example, its position, size, image path, etc. The type of the property determines what kinds of values you can use. You can read about the types below in the "Reference" section. Properties are defined like this: *Properties* control how a particular *element* looks - for example its position, size, image path etc. The type of the property determines what kinds of values you can use. You can read about the types below in the "Reference" section. Properties are defined like this:
```xml ```xml
<propertyNameHere>ValueHere</propertyNameHere> <propertyNameHere>ValueHere</propertyNameHere>
``` ```
# Advanced Features ## Advanced features
It is recommended that if you are writing a theme you launch EmulationStation with the `--debug` and `--windowed` switches. This way you can read error messages without having to check the log file. You can also reload the current gamelist view and system view with `Ctrl-R` if `--debug` is specified. If you are writing a theme it's recommended to launch ES-DE with the `--debug` flag from a terminal window. If on Unix you can also pass the `--windowed` and `--resolution` flags to avoid having the application window fill the entire screen. On macOS and Windows you only need to pass the `--resolution` flag to accomplish this. By doing so, you can read error messages directly in the terminal window without having to open the log file. You can also reload the current gamelist view and system view with `Ctrl-R` if the `--debug` flag has been set.
### The `<include>` tag ### The \<include\> tag
You can include theme files within theme files, similar to `#include` in C (though the internal mechanism is different, the effect is the same). Example: You can include theme files within theme files, for example:
`~/.emulationstation/all_themes.xml`: `~/.emulationstation/themes/mythemeset-DE/fonts.xml`:
```xml ```xml
<theme> <theme>
<formatVersion>7</formatVersion> <formatVersion>7</formatVersion>
<view name="detailed"> <view name="detailed">
<text name="description"> <text name="description">
<fontPath>./all_themes/myfont.ttf</fontPath> <fontPath>./core/font.ttf</fontPath>
<fontSize>0.035</fontSize>
<color>00FF00</color> <color>00FF00</color>
</text> </text>
</view> </view>
</theme> </theme>
``` ```
`~/.emulationstation/snes/theme.xml`: `~/.emulationstation/themes/mythemeset-DE/snes/theme.xml`:
```xml ```xml
<theme> <theme>
<formatVersion>7</formatVersion> <formatVersion>7</formatVersion>
<include>./../all_themes.xml</include> <include>./../fonts.xml</include>
<view name="detailed"> <view name="detailed">
<text name="description"> <text name="description">
<color>FF0000</color> <color>FF0000</color>
@ -150,84 +155,77 @@ You can include theme files within theme files, similar to `#include` in C (thou
</theme> </theme>
``` ```
Is equivalent to this `snes/theme.xml`: The above is equivalent to the following:
```xml ```xml
<theme> <theme>
<formatVersion>7</formatVersion> <formatVersion>7</formatVersion>
<view name="detailed"> <view name="detailed">
<text name="description"> <text name="description">
<fontPath>./all_themes/myfont.ttf</fontPath> <fontPath>./core/font.ttf</fontPath>
<fontSize>0.035</fontSize>
<color>FF0000</color> <color>FF0000</color>
</text> </text>
</view> </view>
</theme> </theme>
``` ```
Notice that properties that were not specified got merged (`<fontPath>`) and the `snes/theme.xml` could overwrite the included files' values (`<color>`). Also notice the included file still needed the `<formatVersion>` tag. Note that properties can get merged. In the above example the `<color>` tag from `fonts.xml` got overwritten by the equivalent tag in `snes/theme.xml`. This happens because that tag was effectively declared after the first `<color>` tag. Be aware that the included file also needs the `<formatVersion>` tag.
### Theming multiple views simultaneously ### Theming multiple views simultaneously
Sometimes you want to apply the same properties to the same elements across multiple views. The `name` attribute actually works as a list (delimited by any characters of `\t\r\n ,` - that is, whitespace and commas). So, for example, to easily apply the same header to the basic, grid, and system views: Sometimes you want to apply the same properties to the same elements across multiple views. The `name` attribute actually works as a list (delimited by any characters of `\t\r\n ,` - that is, whitespace and commas). So for example, to apply the same logo to the basic and detailed views you could write the following:
```xml ```xml
<theme> <theme>
<formatVersion>7</formatVersion> <formatVersion>7</formatVersion>
<view name="basic, grid, system"> <view name="basic, detailed">
<image name="logo"> <image name="logo">
<path>./snes_art/snes_header.png</path> <path>./snes/logo.svg</path>
</image> </image>
</view> </view>
<view name="detailed"> <view name="video">
<image name="logo"> <image name="logo">
<path>./snes_art/snes_header_detailed.png</path> <path>./snes/logo_video.svg</path>
</image> </image>
</view> </view>
</theme> </theme>
``` ```
This is equivalent to: The above is equivalent to:
```xml
```xml
<theme> <theme>
<formatVersion>7</formatVersion> <formatVersion>7</formatVersion>
<view name="basic"> <view name="basic">
<image name="logo"> <image name="logo">
<path>./snes_art/snes_header.png</path> <path>./snes/logo.svg</path>
</image> </image>
</view> </view>
<view name="detailed"> <view name="detailed">
<image name="logo"> <image name="logo">
<path>./snes_art/snes_header_detailed.png</path> <path>./snes/logo.svg</path>
</image> </image>
</view> </view>
<view name="grid"> <view name="video">
<image name="logo"> <image name="logo">
<path>./snes_art/snes_header.png</path> <path>./snes/logo_video.svg</path>
</image> </image>
</view> </view>
<view name="system">
<image name="logo">
<path>./snes_art/snes_header.png</path>
</image>
</view>
... and any other view that might try to look up "logo" ...
</theme> </theme>
``` ```
### Theming multiple elements simultaneously ### Theming multiple elements simultaneously
You can theme multiple elements *of the same type* simultaneously. The `name` attribute actually works as a list (delimited by any characters of `\t\r\n ,` - that is, whitespace and commas), just like it does for views, as long as the elements have the same type. This is useful if you want to, say, apply the same color to all the metadata labels: You can theme multiple elements *of the same type* simultaneously. The `name` attribute actually works as a list (delimited by any characters of `\t\r\n ,` - that is, whitespace and commas). This is useful if you want to, say, apply the same color to all the metadata labels:
```xml ```xml
<theme> <theme>
<formatVersion>7</formatVersion> <formatVersion>7</formatVersion>
<view name="detailed"> <view name="detailed">
<!-- Weird spaces/newline on purpose! --> <!-- Weird spaces/newline on purpose -->
<text name="md_lbl_rating, md_lbl_releasedate, md_lbl_developer, md_lbl_publisher, <text name="md_lbl_rating, md_lbl_releasedate, md_lbl_developer, md_lbl_publisher,
md_lbl_genre, md_lbl_players, md_lbl_lastplayed, md_lbl_playcount"> md_lbl_genre, md_lbl_players, md_lbl_lastplayed, md_lbl_playcount">
<color>48474D</color> <color>48474D</color>
@ -238,7 +236,6 @@ You can theme multiple elements *of the same type* simultaneously. The `name` a
Which is equivalent to: Which is equivalent to:
```xml ```xml
<theme> <theme>
<formatVersion>7</formatVersion> <formatVersion>7</formatVersion>
<view name="detailed"> <view name="detailed">
@ -270,20 +267,16 @@ Which is equivalent to:
</theme> </theme>
``` ```
Just remember, *this only works if the elements have the same type!* Just remember, _this only works if the elements have the same type._
### Element rendering order with z-index
You can now change the order in which elements are rendered by setting `zIndex` values. Default values correspond to the default rendering order while allowing elements to easily be shifted without having to set `zIndex` values for every element. Elements will be rendered in order from smallest z-index to largest.
#### Navigation sounds ### Navigation sounds
The navigation sounds are configured globally per theme set, so it needs to be defined as a feature and with the view set to the special 'all' category. Navigation sounds are configured globally per theme set, so it needs to be defined as a feature and with the view set to the special "all" category.
It's recommended to put these elements in a separate file and include it from the main theme file (e.g. `<include>./navigationsounds.xml</include>`). It's recommended to put these elements in a separate file and include it from the main theme file (e.g. `<include>./navigationsounds.xml</include>`).
There are seven different navigation sounds that can be configured. The names as well as the element structure should be self-explanatory based There are seven different navigation sounds that can be configured. The names as well as the element structure should be self-explanatory based
on the example below. on the example below.
Starting EmulationStation with the --debug flag will provide feedback on whether any navigation sound elements were read from the theme set. If no navigation sound is provided by the theme, ES-DE will use the bundled navigation sound file as a fallback. This is done per sound, so the theme could provide for example one or two custom sound files while using the bundled ES-DE sounds for the other samples. Starting ES-DE with the --debug flag will provide feedback on whether any navigation sound elements were read from the theme set. If no navigation sounds are provided by the theme, ES-DE will use the bundled navigation sounds as a fallback. This is done per sound file, so the theme could provide for example one or two custom sounds while using the bundled ES-DE sounds for the rest.
Example debug output: Example debug output:
``` ```
@ -297,7 +290,6 @@ Jul 12 11:28:58 Debug: Sound::getFromTheme(): Tag not found, using fallback sou
Example `navigationsounds.xml`, to be included from the main theme file: Example `navigationsounds.xml`, to be included from the main theme file:
```xml ```xml
<theme> <theme>
<formatVersion>7</formatVersion> <formatVersion>7</formatVersion>
<feature supported="navigationsounds"> <feature supported="navigationsounds">
@ -328,14 +320,18 @@ Example `navigationsounds.xml`, to be included from the main theme file:
</theme> </theme>
``` ```
#### Defaults ### Element rendering order using zIndex
##### system You can change the order in which elements are rendered by setting their `zIndex` values. All elements have a default value so you only need to define it for the ones you wish to explicitly change. Elements will be rendered in order from smallest to largest values.
Below are the default zIndex values per element type:
#### system
* Extra Elements `extra="true"` - 10 * Extra Elements `extra="true"` - 10
* `carousel name="systemcarousel"` - 40 * `carousel name="systemcarousel"` - 40
* `text name="systemInfo"` - 50 * `text name="systemInfo"` - 50
##### basic, detailed, grid, video #### basic, detailed, video, grid
* `image name="background"` - 0 * `image name="background"` - 0
* Extra Elements `extra="true"` - 10 * Extra Elements `extra="true"` - 10
* `textlist name="gamelist"` - 20 * `textlist name="gamelist"` - 20
@ -366,25 +362,27 @@ Example `navigationsounds.xml`, to be included from the main theme file:
* `text name="md_description"` * `text name="md_description"`
* `text name="md_name"` * `text name="md_name"`
* System Logo/Text - 50 * System Logo/Text - 50
* `text name="logoText"`
* `image name="logo"` * `image name="logo"`
* `text name="logoText"`
* `image name="logoPlaceholderImage"`
* `text name="logoPlaceholderText"`
* Gamelist information - 50 * Gamelist information - 50
* `text name="gamelistInfo"` * `text name="gamelistInfo"`
### Theme variables ### Theme variables
Theme variables can be used to simplify theme construction. There are 2 types of variables available. Theme variables can be used to simplify theme construction. There are 2 types of variables available.
* System Variables * System variables
* Theme Defined Variables * Theme defined variables
#### System Variables #### System variables
System variables are system specific and are derived from the values in es_systems.cfg. System variables are system specific and are derived from the values in es_systems.xml.
* `system.name` * `system.name`
* `system.fullName` * `system.fullName`
* `system.theme` * `system.theme`
#### Theme Defined Variables #### Theme defined variables
Variables can also be defined in the theme. Variables can also be defined in the theme.
``` ```
<variables> <variables>
@ -406,9 +404,32 @@ or to specify only a portion of the value of a theme property:
```` ````
# Reference ## Reference
### Views, their elements, and themeable properties
#### system
* `helpsystem name="help"` - ALL
- The help system style for this view.
* `carousel name="systemcarousel"` - ALL
- The system logo carousel
* `image name="logo"` - PATH | COLOR
- A logo image, to be displayed in the system logo carousel.
* `image name="logoPlaceholderImage"` - ALL
- A logo image, to be displayed system name in the system logo carousel when no logo is available. Set the position
to `0.5 0.5` to center the image.
* `text name="logoPlaceholderText"` - ALL
- Logo text, to be displayed system name in the system logo carousel when no logo is available. The logo text is
displayed on top of `logoPlaceholderImage`. Set the position to `0.5 0.5` to center the text.
* `text name="logoText"` - FONT_PATH | COLOR | FORCE_UPPERCASE | LINE_SPACING | TEXT
- **Deprecated:** A logo text, to be displayed system name in the system logo carousel when no logo is available.
Ignored when `logoPlaceholderImage` or `logoPlaceholderText` are set.
* `text name="systemInfo"` - ALL
- Displays details of the system currently selected in the carousel.
* You can use extra elements (elements with `extra="true"`) to add your own backgrounds, etc. They will be displayed
behind the carousel, and scroll relative to the carousel.
## Views, their elements, and themeable properties:
#### basic #### basic
* `helpsystem name="help"` - ALL * `helpsystem name="help"` - ALL
@ -422,7 +443,6 @@ or to specify only a portion of the value of a theme property:
* `textlist name="gamelist"` - ALL * `textlist name="gamelist"` - ALL
- The gamelist. `primaryColor` is for games, `secondaryColor` is for folders. Centered by default. - The gamelist. `primaryColor` is for games, `secondaryColor` is for folders. Centered by default.
---
#### detailed #### detailed
* `helpsystem name="help"` - ALL * `helpsystem name="help"` - ALL
@ -438,8 +458,8 @@ or to specify only a portion of the value of a theme property:
* `text name="gamelistInfo"` - ALL * `text name="gamelistInfo"` - ALL
- Displays the game count (all games as well as favorites), any applied filters, and a folder icon if a folder has been entered. If this text is left aligned, the folder icon will be placed to the right of the other information, and if it's right aligned, the folder icon will be placed to the left. Left aligned by default. - Displays the game count (all games as well as favorites), any applied filters, and a folder icon if a folder has been entered. If this text is left aligned, the folder icon will be placed to the right of the other information, and if it's right aligned, the folder icon will be placed to the left. Left aligned by default.
* Metadata - Metadata
* Labels - Labels
* `text name="md_lbl_rating"` - ALL * `text name="md_lbl_rating"` - ALL
* `text name="md_lbl_releasedate"` - ALL * `text name="md_lbl_releasedate"` - ALL
* `text name="md_lbl_developer"` - ALL * `text name="md_lbl_developer"` - ALL
@ -450,8 +470,7 @@ or to specify only a portion of the value of a theme property:
* `text name="md_lbl_playcount"` - ALL * `text name="md_lbl_playcount"` - ALL
* Values * Values
* All values will follow to the right of their labels if a position isn't specified. - _All values will follow to the right of their labels if a position isn't specified._
* `image name="md_image"` - POSITION | SIZE | Z_INDEX * `image name="md_image"` - POSITION | SIZE | Z_INDEX
- Path is the "image" metadata for the currently selected game. - Path is the "image" metadata for the currently selected game.
* `rating name="md_rating"` - ALL * `rating name="md_rating"` - ALL
@ -477,6 +496,7 @@ or to specify only a portion of the value of a theme property:
* `text name="md_name"` - ALL * `text name="md_name"` - ALL
- The "name" metadata (the game name). Unlike the others metadata fields, the name is positioned offscreen by default - The "name" metadata (the game name). Unlike the others metadata fields, the name is positioned offscreen by default
#### video #### video
* `helpsystem name="help"` - ALL * `helpsystem name="help"` - ALL
- The help system style for this view. - The help system style for this view.
@ -491,8 +511,8 @@ or to specify only a portion of the value of a theme property:
* `text name="gamelistInfo"` - ALL * `text name="gamelistInfo"` - ALL
- Displays the game count (all games as well as favorites), any applied filters, and a folder icon if a folder has been entered. If this text is left aligned, the folder icon will be placed to the right of the other information, and if it's right aligned, the folder icon will be placed to the left. Left aligned by default. - Displays the game count (all games as well as favorites), any applied filters, and a folder icon if a folder has been entered. If this text is left aligned, the folder icon will be placed to the right of the other information, and if it's right aligned, the folder icon will be placed to the left. Left aligned by default.
* Metadata - Metadata
* Labels - Labels
* `text name="md_lbl_rating"` - ALL * `text name="md_lbl_rating"` - ALL
* `text name="md_lbl_releasedate"` - ALL * `text name="md_lbl_releasedate"` - ALL
* `text name="md_lbl_developer"` - ALL * `text name="md_lbl_developer"` - ALL
@ -503,8 +523,7 @@ or to specify only a portion of the value of a theme property:
* `text name="md_lbl_playcount"` - ALL * `text name="md_lbl_playcount"` - ALL
* Values * Values
* All values will follow to the right of their labels if a position isn't specified. - _All values will follow to the right of their labels if a position isn't specified._
* `image name="md_image"` - POSITION | SIZE | Z_INDEX * `image name="md_image"` - POSITION | SIZE | Z_INDEX
- Path is the "image" metadata for the currently selected game. - Path is the "image" metadata for the currently selected game.
* `image name="md_marquee"` - POSITION | SIZE | Z_INDEX * `image name="md_marquee"` - POSITION | SIZE | Z_INDEX
@ -534,7 +553,6 @@ or to specify only a portion of the value of a theme property:
* `text name="md_name"` - ALL * `text name="md_name"` - ALL
- The "name" metadata (the game name). Unlike the others metadata fields, the name is positioned offscreen by default - The "name" metadata (the game name). Unlike the others metadata fields, the name is positioned offscreen by default
---
#### grid #### grid
* `helpsystem name="help"` - ALL * `helpsystem name="help"` - ALL
@ -554,8 +572,8 @@ or to specify only a portion of the value of a theme property:
* `text name="gamelistInfo"` - ALL * `text name="gamelistInfo"` - ALL
- Displays the game count (all games as well as favorites), any applied filters, and a folder icon if a folder has been entered. If this text is left aligned, the folder icon will be placed to the right of the other information, and if it's right aligned, the folder icon will be placed to the left. Left aligned by default. - Displays the game count (all games as well as favorites), any applied filters, and a folder icon if a folder has been entered. If this text is left aligned, the folder icon will be placed to the right of the other information, and if it's right aligned, the folder icon will be placed to the left. Left aligned by default.
* Metadata - Metadata
* Labels - Labels
* `text name="md_lbl_rating"` - ALL * `text name="md_lbl_rating"` - ALL
* `text name="md_lbl_releasedate"` - ALL * `text name="md_lbl_releasedate"` - ALL
* `text name="md_lbl_developer"` - ALL * `text name="md_lbl_developer"` - ALL
@ -566,8 +584,7 @@ or to specify only a portion of the value of a theme property:
* `text name="md_lbl_playcount"` - ALL * `text name="md_lbl_playcount"` - ALL
* Values * Values
* All values will follow to the right of their labels if a position isn't specified. - _All values will follow to the right of their labels if a position isn't specified._
* `rating name="md_rating"` - ALL * `rating name="md_rating"` - ALL
- The "rating" metadata. - The "rating" metadata.
* `datetime name="md_releasedate"` - ALL * `datetime name="md_releasedate"` - ALL
@ -591,23 +608,8 @@ or to specify only a portion of the value of a theme property:
* `text name="md_name"` - ALL * `text name="md_name"` - ALL
- The "name" metadata (the game name). Unlike the others metadata fields, the name is positioned offscreen by default - The "name" metadata (the game name). Unlike the others metadata fields, the name is positioned offscreen by default
---
#### system ### Types of properties
* `helpsystem name="help"` - ALL
- The help system style for this view.
* `carousel name="systemcarousel"` -ALL
- The system logo carousel
* `image name="logo"` - PATH | COLOR
- A logo image, to be displayed in the system logo carousel.
* `text name="logoText"` - FONT_PATH | COLOR | FORCE_UPPERCASE | LINE_SPACING | TEXT
- A logo text, to be displayed system name in the system logo carousel when no logo is available.
* `text name="systemInfo"` - ALL
- Displays details of the system currently selected in the carousel.
* You can use extra elements (elements with `extra="true"`) to add your own backgrounds, etc. They will be displayed behind the carousel, and scroll relative to the carousel.
## Types of properties:
* NORMALIZED_PAIR - two decimals, in the range [0..1], delimited by a space. For example, `0.25 0.5`. Most commonly used for position (x and y coordinates) and size (width and height). * NORMALIZED_PAIR - two decimals, in the range [0..1], delimited by a space. For example, `0.25 0.5`. Most commonly used for position (x and y coordinates) and size (width and height).
* NORMALIZED_RECT - four decimals, in the range [0..1], delimited by a space. For example, `0.25 0.5 0.10 0.30`. Most commonly used for padding to store top, left, bottom and right coordinates. * NORMALIZED_RECT - four decimals, in the range [0..1], delimited by a space. For example, `0.25 0.5 0.10 0.30`. Most commonly used for padding to store top, left, bottom and right coordinates.
@ -618,7 +620,7 @@ or to specify only a portion of the value of a theme property:
* STRING - a string of text. * STRING - a string of text.
## Types of elements and their properties: ### Types of elements and their properties
Common to almost all elements is a `pos` and `size` property of the NORMALIZED_PAIR type. They are normalized in terms of their "parent" object's size; 99% of the time, this is just the size of the screen. In this case, `<pos>0 0</pos>` would correspond to the top left corner, and `<pos>1 1</pos>` the bottom right corner (a positive Y value points further down). `pos` almost always refers to the top left corner of your element. You *can* use numbers outside of the [0..1] range if you want to place an element partially or completely off-screen. Common to almost all elements is a `pos` and `size` property of the NORMALIZED_PAIR type. They are normalized in terms of their "parent" object's size; 99% of the time, this is just the size of the screen. In this case, `<pos>0 0</pos>` would correspond to the top left corner, and `<pos>1 1</pos>` the bottom right corner (a positive Y value points further down). `pos` almost always refers to the top left corner of your element. You *can* use numbers outside of the [0..1] range if you want to place an element partially or completely off-screen.
@ -803,7 +805,7 @@ Can be created as an extra.
* `zIndex` - type: FLOAT. * `zIndex` - type: FLOAT.
- z-index value for component. Components will be rendered in order of z-index value from low to high. - z-index value for component. Components will be rendered in order of z-index value from low to high.
EmulationStation borrows the concept of "nine patches" from Android (or "9-Slices"). Currently the implementation is very simple and hard-coded to only use 48x48px images (16x16px for each "patch"). Check the `data/resources` directory for some examples (button.png, frame.png). ES-DE borrows the concept of "nine patches" from Android (or "9-Slices"). Currently the implementation is very simple and hard-coded to only use 48x48px images (16x16px for each "patch"). Check the `data/resources` directory for some examples (button.png, frame.png).
#### rating #### rating
@ -992,7 +994,9 @@ EmulationStation borrows the concept of "nine patches" from Android (or "9-Slice
The help system is a special element that displays a context-sensitive list of actions the user can take at any time. You should try and keep the position constant throughout every screen. Keep in mind the "default" settings (including position) are used whenever the user opens a menu. The help system is a special element that displays a context-sensitive list of actions the user can take at any time. You should try and keep the position constant throughout every screen. Keep in mind the "default" settings (including position) are used whenever the user opens a menu.
To see some examples of EmulationStation themes, the following resources are recommended: ## Example theme sets
To see some example EmulationStation themes, the following resources are recommended:
https://aloshi.com/emulationstation#themes https://aloshi.com/emulationstation#themes

View file

@ -40,7 +40,7 @@ There are two places ES-DE can load theme sets from:
An example installation path would be: \ An example installation path would be: \
`/usr/share/emulationstation/themes/[CURRENT_THEME_SET]/[SYSTEM_THEME]/theme.xml` `/usr/share/emulationstation/themes/[CURRENT_THEME_SET]/[SYSTEM_THEME]/theme.xml`
`[SYSTEM_THEME]` is the `<theme>` tag for the system, as defined in `es_systems.cfg`. If the `<theme>` tag is not set, ES-DE will use the system's `<name>`. `[SYSTEM_THEME]` is the `<theme>` tag for the system, as defined in `es_systems.xml`. If the `<theme>` tag is not set, ES-DE will use the system's `<name>`.
If both files happen to exist, ES-DE will pick the first one (the one located in the home directory). If both files happen to exist, ES-DE will pick the first one (the one located in the home directory).
@ -74,7 +74,7 @@ Everything must be inside a `<theme>` tag.
**The `<formatVersion>` tag *must* be specified**. This is the version of the theming system the theme was designed for. **The `<formatVersion>` tag *must* be specified**. This is the version of the theming system the theme was designed for.
The current version is 6. The current version is 6.
A *view* can be thought of as a particular "screen" within EmulationStation. Views are defined like this: A *view* can be thought of as a particular "screen" within ES-DE. Views are defined like this:
```xml ```xml
@ -112,7 +112,7 @@ Or, you can create your own elements by adding `extra="true"` (as is done in the
# Advanced Features # Advanced Features
It is recommended that if you are writing a theme you launch EmulationStation with the `--debug` and `--windowed` switches. This way you can read error messages without having to check the log file. You can also reload the current gamelist view and system view with `Ctrl-R` if `--debug` is specified. It is recommended that if you are writing a theme you launch ES-DE with the `--debug` and `--windowed` switches. This way you can read error messages without having to check the log file. You can also reload the current gamelist view and system view with `Ctrl-R` if `--debug` is specified.
### The `<include>` tag ### The `<include>` tag
@ -279,7 +279,7 @@ The navigation sounds are configured globally per theme set, so it needs to be d
It's recommended to put these elements in a separate file and include it from the main theme file (e.g. `<include>./navigationsounds.xml</include>`). It's recommended to put these elements in a separate file and include it from the main theme file (e.g. `<include>./navigationsounds.xml</include>`).
There are seven different navigation sounds that can be configured. The names as well as the element structure should be self-explanatory based There are seven different navigation sounds that can be configured. The names as well as the element structure should be self-explanatory based
on the example below. on the example below.
Starting EmulationStation with the --debug flag will provide feedback on whether any navigation sound elements were read from the theme set. If no navigation sound is provided by the theme, ES-DE will use the bundled navigation sound file as a fallback. This is done per sound, so the theme could provide for example one or two custom sound files while using the bundled ES-DE sounds for the other samples. Starting ES-DE with the --debug flag will provide feedback on whether any navigation sound elements were read from the theme set. If no navigation sound is provided by the theme, ES-DE will use the bundled navigation sound file as a fallback. This is done per sound, so the theme could provide for example one or two custom sound files while using the bundled ES-DE sounds for the other samples.
Example debug output: Example debug output:
``` ```
@ -375,7 +375,7 @@ Theme variables can be used to simplify theme construction. There are 2 types o
#### System Variables #### System Variables
System variables are system specific and are derived from the values in es_systems.cfg. System variables are system specific and are derived from the values in es_systems.xml.
* `system.name` * `system.name`
* `system.fullName` * `system.fullName`
* `system.theme` * `system.theme`
@ -793,7 +793,7 @@ Can be created as an extra.
* `zIndex` - type: FLOAT. * `zIndex` - type: FLOAT.
- z-index value for component. Components will be rendered in order of z-index value from low to high. - z-index value for component. Components will be rendered in order of z-index value from low to high.
EmulationStation borrows the concept of "nine patches" from Android (or "9-Slices"). Currently the implementation is very simple and hard-coded to only use 48x48px images (16x16px for each "patch"). Check the `data/resources` directory for some examples (button.png, frame.png). ES-DE borrows the concept of "nine patches" from Android (or "9-Slices"). Currently the implementation is very simple and hard-coded to only use 48x48px images (16x16px for each "patch"). Check the `data/resources` directory for some examples (button.png, frame.png).
#### rating #### rating

View file

@ -30,7 +30,6 @@ set(ES_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGamelistFilter.h ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGamelistFilter.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGamelistOptions.h ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGamelistOptions.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGameScraper.h ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGameScraper.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiInfoPopup.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiLaunchScreen.h ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiLaunchScreen.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMediaViewerOptions.h ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMediaViewerOptions.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMenu.h ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMenu.h
@ -81,7 +80,6 @@ set(ES_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGamelistFilter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGamelistFilter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGamelistOptions.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGamelistOptions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGameScraper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGameScraper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiInfoPopup.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiLaunchScreen.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiLaunchScreen.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMenu.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMenu.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMediaViewerOptions.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMediaViewerOptions.cpp

View file

@ -27,7 +27,7 @@
#include "Settings.h" #include "Settings.h"
#include "SystemData.h" #include "SystemData.h"
#include "ThemeData.h" #include "ThemeData.h"
#include "guis/GuiInfoPopup.h" #include "Window.h"
#include "utils/FileSystemUtil.h" #include "utils/FileSystemUtil.h"
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
#include "utils/TimeUtil.h" #include "utils/TimeUtil.h"
@ -385,14 +385,12 @@ void CollectionSystemsManager::updateCollectionSystem(FileData* file, Collection
parentRootFolder->sort(parentRootFolder->getSortTypeFromString( parentRootFolder->sort(parentRootFolder->getSortTypeFromString(
parentRootFolder->getSortTypeString()), parentRootFolder->getSortTypeString()),
mFavoritesSorting); mFavoritesSorting);
GuiInfoPopup* s = new GuiInfoPopup( mWindow->queueInfoPopup(
mWindow,
"DISABLED '" + "DISABLED '" +
Utils::String::toUpper( Utils::String::toUpper(
Utils::String::removeParenthesis(file->getName())) + Utils::String::removeParenthesis(file->getName())) +
"' IN '" + Utils::String::toUpper(sysData.system->getName()) + "'", "' IN '" + Utils::String::toUpper(sysData.system->getName()) + "'",
4000); 4000);
mWindow->setInfoPopup(s);
} }
else { else {
ViewController::get()->getGameListView(curSys).get()->remove(collectionEntry, ViewController::get()->getGameListView(curSys).get()->remove(collectionEntry,
@ -621,24 +619,18 @@ void CollectionSystemsManager::setEditMode(std::string collectionName, bool show
mEditingCollectionSystemData = sysData; mEditingCollectionSystemData = sysData;
if (showPopup) { if (showPopup) {
GuiInfoPopup* s = new GuiInfoPopup(mWindow, mWindow->queueInfoPopup("EDITING '" + Utils::String::toUpper(collectionName) +
"EDITING '" + Utils::String::toUpper(collectionName) + "' COLLECTION, ADD/REMOVE GAMES WITH 'Y'",
"' COLLECTION, ADD/REMOVE GAMES WITH 'Y'", 10000);
10000);
mWindow->setInfoPopup(s);
} }
} }
void CollectionSystemsManager::exitEditMode(bool showPopup) void CollectionSystemsManager::exitEditMode(bool showPopup)
{ {
if (showPopup) { if (showPopup) {
GuiInfoPopup* s = new GuiInfoPopup( mWindow->queueInfoPopup("FINISHED EDITING '" + Utils::String::toUpper(mEditingCollection) +
mWindow, "' COLLECTION",
"FINISHED EDITING '" + Utils::String::toUpper(mEditingCollection) + "' COLLECTION", 4000);
4000);
mWindow->setInfoPopup(s);
} }
mIsEditingCustom = false; mIsEditingCustom = false;
@ -669,7 +661,6 @@ bool CollectionSystemsManager::inCustomCollection(const std::string& collectionN
bool CollectionSystemsManager::toggleGameInCollection(FileData* file) bool CollectionSystemsManager::toggleGameInCollection(FileData* file)
{ {
if (file->getType() == GAME) { if (file->getType() == GAME) {
GuiInfoPopup* s;
bool adding = true; bool adding = true;
std::string name = file->getName(); std::string name = file->getName();
std::string sysName = mEditingCollection; std::string sysName = mEditingCollection;
@ -743,20 +734,17 @@ bool CollectionSystemsManager::toggleGameInCollection(FileData* file)
mAutoCollectionSystemsData["favorites"].system); mAutoCollectionSystemsData["favorites"].system);
} }
if (adding) { if (adding) {
s = new GuiInfoPopup( mWindow->queueInfoPopup(
mWindow,
"ADDED '" + Utils::String::toUpper(Utils::String::removeParenthesis(name)) + "ADDED '" + Utils::String::toUpper(Utils::String::removeParenthesis(name)) +
"' TO '" + Utils::String::toUpper(sysName) + "'", "' TO '" + Utils::String::toUpper(sysName) + "'",
4000); 4000);
} }
else { else {
s = new GuiInfoPopup( mWindow->queueInfoPopup(
mWindow,
"REMOVED '" + Utils::String::toUpper(Utils::String::removeParenthesis(name)) + "REMOVED '" + Utils::String::toUpper(Utils::String::removeParenthesis(name)) +
"' FROM '" + Utils::String::toUpper(sysName) + "'", "' FROM '" + Utils::String::toUpper(sysName) + "'",
4000); 4000);
} }
mWindow->setInfoPopup(s);
return true; return true;
} }
return false; return false;
@ -952,9 +940,8 @@ void CollectionSystemsManager::deleteCustomCollection(std::string collectionName
"configuration file '" "configuration file '"
<< configFile << "'."; << configFile << "'.";
GuiInfoPopup* s = new GuiInfoPopup( mWindow->queueInfoPopup(
mWindow, "DELETED COLLECTION '" + Utils::String::toUpper(collectionName) + "'", 5000); "DELETED COLLECTION '" + Utils::String::toUpper(collectionName) + "'", 5000);
mWindow->setInfoPopup(s);
} }
else { else {
LOG(LogError) << "Attempted to delete custom collection '" + collectionName + "' " + LOG(LogError) << "Attempted to delete custom collection '" + collectionName + "' " +

View file

@ -20,7 +20,6 @@
#include "Scripting.h" #include "Scripting.h"
#include "SystemData.h" #include "SystemData.h"
#include "Window.h" #include "Window.h"
#include "guis/GuiInfoPopup.h"
#include "utils/FileSystemUtil.h" #include "utils/FileSystemUtil.h"
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
#include "utils/TimeUtil.h" #include "utils/TimeUtil.h"
@ -856,9 +855,8 @@ void FileData::launchGame(Window* window)
LOG(LogError) << "Raw emulator launch command:"; LOG(LogError) << "Raw emulator launch command:";
LOG(LogError) << commandRaw; LOG(LogError) << commandRaw;
GuiInfoPopup* s = new GuiInfoPopup( window->queueInfoPopup("ERROR: MISSING EMULATOR CONFIGURATION FOR '" + emulatorEntry + "'",
window, "ERROR: MISSING EMULATOR CONFIGURATION FOR '" + emulatorEntry + "'", 6000); 6000);
window->setInfoPopup(s);
return; return;
} }
else if (binaryPath.empty()) { else if (binaryPath.empty()) {
@ -866,11 +864,8 @@ void FileData::launchGame(Window* window)
LOG(LogError) << "Raw emulator launch command:"; LOG(LogError) << "Raw emulator launch command:";
LOG(LogError) << commandRaw; LOG(LogError) << commandRaw;
GuiInfoPopup* s = new GuiInfoPopup(window, window->queueInfoPopup("ERROR: COULDN'T FIND EMULATOR, HAS IT BEEN PROPERLY INSTALLED?",
"ERROR: COULDN'T FIND EMULATOR, HAS IT " 6000);
"BEEN PROPERLY INSTALLED?",
6000);
window->setInfoPopup(s);
return; return;
} }
else { else {
@ -914,12 +909,10 @@ void FileData::launchGame(Window* window)
LOG(LogError) << "Raw emulator launch command:"; LOG(LogError) << "Raw emulator launch command:";
LOG(LogError) << commandRaw; LOG(LogError) << commandRaw;
GuiInfoPopup* s = new GuiInfoPopup( window->queueInfoPopup(
window,
"ERROR: COULDN'T FIND EMULATOR CORE FILE '" + "ERROR: COULDN'T FIND EMULATOR CORE FILE '" +
Utils::String::toUpper(Utils::FileSystem::getFileName(coreFile)) + "'", Utils::String::toUpper(Utils::FileSystem::getFileName(coreFile)) + "'",
6000); 6000);
window->setInfoPopup(s);
return; return;
} }
else { else {
@ -937,11 +930,7 @@ void FileData::launchGame(Window* window)
LOG(LogError) << "Raw emulator launch command:"; LOG(LogError) << "Raw emulator launch command:";
LOG(LogError) << commandRaw; LOG(LogError) << commandRaw;
GuiInfoPopup* s = new GuiInfoPopup(window, window->queueInfoPopup("ERROR: INVALID ENTRY IN SYSTEMS CONFIGURATION FILE", 6000);
"ERROR: INVALID ENTRY IN SYSTEMS "
"CONFIGURATION FILE",
6000);
window->setInfoPopup(s);
return; return;
} }
} }
@ -953,9 +942,7 @@ void FileData::launchGame(Window* window)
LOG(LogError) << "Raw emulator launch command:"; LOG(LogError) << "Raw emulator launch command:";
LOG(LogError) << commandRaw; LOG(LogError) << commandRaw;
GuiInfoPopup* s = new GuiInfoPopup( window->queueInfoPopup("ERROR: MISSING CORE CONFIGURATION FOR '" + coreEntry + "'", 6000);
window, "ERROR: MISSING CORE CONFIGURATION FOR '" + coreEntry + "'", 6000);
window->setInfoPopup(s);
return; return;
} }
@ -1024,11 +1011,7 @@ void FileData::launchGame(Window* window)
LOG(LogError) << "Raw emulator launch command:"; LOG(LogError) << "Raw emulator launch command:";
LOG(LogError) << commandRaw; LOG(LogError) << commandRaw;
GuiInfoPopup* s = new GuiInfoPopup(window, window->queueInfoPopup("ERROR: INVALID ENTRY IN SYSTEMS CONFIGURATION FILE", 6000);
"ERROR: INVALID ENTRY IN SYSTEMS "
"CONFIGURATION FILE",
6000);
window->setInfoPopup(s);
return; return;
} }
} }
@ -1041,12 +1024,10 @@ void FileData::launchGame(Window* window)
<< "Tried to find the core file using these paths as defined by es_find_rules.xml:"; << "Tried to find the core file using these paths as defined by es_find_rules.xml:";
LOG(LogError) << Utils::String::vectorToDelimitedString(emulatorCorePaths, ", "); LOG(LogError) << Utils::String::vectorToDelimitedString(emulatorCorePaths, ", ");
GuiInfoPopup* s = window->queueInfoPopup(
new GuiInfoPopup(window, "ERROR: COULDN'T FIND EMULATOR CORE FILE '" +
"ERROR: COULDN'T FIND EMULATOR CORE FILE '" + Utils::String::toUpper(coreName.substr(0, coreName.size()) + "'"),
Utils::String::toUpper(coreName.substr(0, coreName.size()) + "'"), 6000);
6000);
window->setInfoPopup(s);
return; return;
} }
@ -1087,12 +1068,10 @@ void FileData::launchGame(Window* window)
if (returnValue != 0) { if (returnValue != 0) {
LOG(LogWarning) << "...launch terminated with nonzero return value " << returnValue; LOG(LogWarning) << "...launch terminated with nonzero return value " << returnValue;
GuiInfoPopup* s = new GuiInfoPopup( window->queueInfoPopup("ERROR LAUNCHING GAME '" +
window, Utils::String::toUpper(metadata.get("name")) + "' (ERROR CODE " +
"ERROR LAUNCHING GAME '" + Utils::String::toUpper(metadata.get("name")) + Utils::String::toUpper(std::to_string(returnValue) + ")"),
"' (ERROR CODE " + Utils::String::toUpper(std::to_string(returnValue) + ")"), 6000);
6000);
window->setInfoPopup(s);
} }
else { else {
// Stop showing the game launch notification. // Stop showing the game launch notification.
@ -1120,8 +1099,10 @@ void FileData::launchGame(Window* window)
Scripting::fireEvent("game-end", romPath, getSourceFileData()->metadata.get("name")); Scripting::fireEvent("game-end", romPath, getSourceFileData()->metadata.get("name"));
// Re-enable the text scrolling that was disabled in ViewController on game launch. // Unless we're running in the background while the game is launched, re-enable the text
window->setAllowTextScrolling(true); // scrolling that was disabled in ViewController.
if (!ViewController::get()->runInBackground(mSystem))
window->setAllowTextScrolling(true);
// Update number of times the game has been launched. // Update number of times the game has been launched.
FileData* gameToUpdate = getSourceFileData(); FileData* gameToUpdate = getSourceFileData();

View file

@ -99,6 +99,10 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system)
mJumpToLetterList = mJumpToLetterList =
std::make_shared<LetterList>(mWindow, getHelpStyle(), "JUMP TO...", false); std::make_shared<LetterList>(mWindow, getHelpStyle(), "JUMP TO...", false);
// Enable key repeat so that the left or right button can be held to cycle through
// the letters.
mJumpToLetterList->setKeyRepeat(true, 650, 200);
// Populate the quick selector. // Populate the quick selector.
for (unsigned int i = 0; i < mFirstLetterIndex.size(); i++) { for (unsigned int i = 0; i < mFirstLetterIndex.size(); i++) {
mJumpToLetterList->add(mFirstLetterIndex[i], mFirstLetterIndex[i], 0); mJumpToLetterList->add(mFirstLetterIndex[i], mFirstLetterIndex[i], 0);
@ -128,10 +132,15 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system)
for (unsigned int i = 0; i < numSortTypes; i++) { for (unsigned int i = 0; i < numSortTypes; i++) {
const FileData::SortType& sort = FileSorts::SortTypes.at(i); const FileData::SortType& sort = FileSorts::SortTypes.at(i);
if (sort.description == sortType) if (sort.description == sortType)
mListSort->add(sort.description, &sort, 1); mListSort->add(sort.description, &sort, true);
else else
mListSort->add(sort.description, &sort, 0); mListSort->add(sort.description, &sort, false);
} }
// Enable key repeat so that the left or right button can be held to cycle through
// the sort options.
mListSort->setKeyRepeat(true, 650, 400);
// Don't show the sort type option if the gamelist type is recent/last played. // Don't show the sort type option if the gamelist type is recent/last played.
if (system->getName() != "recent") if (system->getName() != "recent")
mMenu.addWithLabel("SORT GAMES BY", mListSort); mMenu.addWithLabel("SORT GAMES BY", mListSort);

View file

@ -102,31 +102,15 @@ void GuiMenu::openUIOptions()
auto startup_system = std::make_shared<OptionListComponent<std::string>>( auto startup_system = std::make_shared<OptionListComponent<std::string>>(
mWindow, getHelpStyle(), "GAMELIST ON STARTUP", false); mWindow, getHelpStyle(), "GAMELIST ON STARTUP", false);
startup_system->add("NONE", "", Settings::getInstance()->getString("StartupSystem") == ""); startup_system->add("NONE", "", Settings::getInstance()->getString("StartupSystem") == "");
float dotsSize = Font::get(FONT_SIZE_MEDIUM)->sizeText("...").x; for (auto it = SystemData::sSystemVector.cbegin(); // Line break.
for (auto it = SystemData::sSystemVector.cbegin(); it != SystemData::sSystemVector.cend(); it != SystemData::sSystemVector.cend(); it++) {
it++) {
if ((*it)->getName() != "retropie") { if ((*it)->getName() != "retropie") {
// If required, abbreviate the system name so it doesn't overlap the setting name. // If required, abbreviate the system name so it doesn't overlap the setting name.
std::string abbreviatedString = float maxNameLength = mSize.x * 0.48f;
Font::get(FONT_SIZE_MEDIUM)->getTextMaxWidth((*it)->getFullName(), mSize.x * 0.47f); startup_system->add((*it)->getFullName(), (*it)->getName(),
float sizeDifference = Font::get(FONT_SIZE_MEDIUM)->sizeText((*it)->getFullName()).x -
Font::get(FONT_SIZE_MEDIUM)->sizeText(abbreviatedString).x;
if (sizeDifference > 0.0f) {
// It doesn't make sense to abbreviate if the number of pixels removed by
// the abbreviation is less or equal to the size of the three dots that
// would be appended to the string.
if (sizeDifference <= dotsSize) {
abbreviatedString = (*it)->getFullName();
}
else {
if (abbreviatedString.back() == ' ')
abbreviatedString.pop_back();
abbreviatedString += "...";
}
}
startup_system->add(abbreviatedString, (*it)->getName(),
Settings::getInstance()->getString("StartupSystem") == Settings::getInstance()->getString("StartupSystem") ==
(*it)->getName()); (*it)->getName(),
maxNameLength);
} }
} }
s->addWithLabel("GAMELIST ON STARTUP", startup_system); s->addWithLabel("GAMELIST ON STARTUP", startup_system);
@ -190,8 +174,11 @@ void GuiMenu::openUIOptions()
selectedSet = themeSets.cbegin(); selectedSet = themeSets.cbegin();
auto theme_set = std::make_shared<OptionListComponent<std::string>>(mWindow, getHelpStyle(), auto theme_set = std::make_shared<OptionListComponent<std::string>>(mWindow, getHelpStyle(),
"THEME SET", false); "THEME SET", false);
for (auto it = themeSets.cbegin(); it != themeSets.cend(); it++) for (auto it = themeSets.cbegin(); it != themeSets.cend(); it++) {
theme_set->add(it->first, it->first, it == selectedSet); // If required, abbreviate the theme set name so it doesn't overlap the setting name.
float maxNameLength = mSize.x * 0.62f;
theme_set->add(it->first, it->first, it == selectedSet, maxNameLength);
}
s->addWithLabel("THEME SET", theme_set); s->addWithLabel("THEME SET", theme_set);
s->addSaveFunc([this, theme_set, s] { s->addSaveFunc([this, theme_set, s] {
if (theme_set->getSelected() != Settings::getInstance()->getString("ThemeSet")) { if (theme_set->getSelected() != Settings::getInstance()->getString("ThemeSet")) {
@ -522,6 +509,18 @@ void GuiMenu::openUIOptions()
} }
}); });
// Enable menu scroll indicators.
auto scroll_indicators = std::make_shared<SwitchComponent>(mWindow);
scroll_indicators->setState(Settings::getInstance()->getBool("ScrollIndicators"));
s->addWithLabel("ENABLE MENU SCROLL INDICATORS", scroll_indicators);
s->addSaveFunc([scroll_indicators, s] {
if (scroll_indicators->getState() != Settings::getInstance()->getBool("ScrollIndicators")) {
Settings::getInstance()->setBool("ScrollIndicators", scroll_indicators->getState());
s->setNeedsSaving();
s->setInvalidateCachedBackground();
}
});
// Enable the 'Y' button for tagging games as favorites. // Enable the 'Y' button for tagging games as favorites.
auto favorites_add_button = std::make_shared<SwitchComponent>(mWindow); auto favorites_add_button = std::make_shared<SwitchComponent>(mWindow);
favorites_add_button->setState(Settings::getInstance()->getBool("FavoritesAddButton")); favorites_add_button->setState(Settings::getInstance()->getBool("FavoritesAddButton"));

View file

@ -31,6 +31,8 @@
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
#include "views/ViewController.h" #include "views/ViewController.h"
#define TITLE_HEIGHT (mTitle->getFont()->getLetterHeight() + Renderer::getScreenHeight() * 0.060f)
GuiMetaDataEd::GuiMetaDataEd(Window* window, GuiMetaDataEd::GuiMetaDataEd(Window* window,
MetaDataList* md, MetaDataList* md,
const std::vector<MetaDataDecl>& mdd, const std::vector<MetaDataDecl>& mdd,
@ -39,25 +41,24 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
std::function<void()> saveCallback, std::function<void()> saveCallback,
std::function<void()> clearGameFunc, std::function<void()> clearGameFunc,
std::function<void()> deleteGameFunc) std::function<void()> deleteGameFunc)
: GuiComponent(window) : GuiComponent{window}
, mBackground(window, ":/graphics/frame.svg") , mBackground{window, ":/graphics/frame.svg"}
, mGrid(window, glm::ivec2{1, 3}) , mGrid{window, glm::ivec2{3, 6}}
, mScraperParams(scraperParams) , mScraperParams{scraperParams}
, mMetaDataDecl(mdd) , mMetaDataDecl{mdd}
, mMetaData(md) , mMetaData{md}
, mSavedCallback(saveCallback) , mSavedCallback{saveCallback}
, mClearGameFunc(clearGameFunc) , mClearGameFunc{clearGameFunc}
, mDeleteGameFunc(deleteGameFunc) , mDeleteGameFunc{deleteGameFunc}
, mMediaFilesUpdated(false) , mMediaFilesUpdated{false}
, mInvalidEmulatorEntry(false) , mInvalidEmulatorEntry{false}
{ {
addChild(&mBackground); addChild(&mBackground);
addChild(&mGrid); addChild(&mGrid);
mHeaderGrid = std::make_shared<ComponentGrid>(mWindow, glm::ivec2{1, 5});
mTitle = std::make_shared<TextComponent>(mWindow, "EDIT METADATA", Font::get(FONT_SIZE_LARGE), mTitle = std::make_shared<TextComponent>(mWindow, "EDIT METADATA", Font::get(FONT_SIZE_LARGE),
0x555555FF, ALIGN_CENTER); 0x555555FF, ALIGN_CENTER);
mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true, glm::ivec2{3, 2});
// Extract possible subfolders from the path. // Extract possible subfolders from the path.
std::string folderPath = std::string folderPath =
@ -81,13 +82,25 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
(scraperParams.game->getType() == FOLDER ? " " + ViewController::FOLDER_CHAR : ""), (scraperParams.game->getType() == FOLDER ? " " + ViewController::FOLDER_CHAR : ""),
Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER, glm::vec3{}, glm::vec2{}, 0x00000000, Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER, glm::vec3{}, glm::vec2{}, 0x00000000,
0.05f); 0.05f);
mHeaderGrid->setEntry(mTitle, glm::ivec2{0, 1}, false, true);
mHeaderGrid->setEntry(mSubtitle, glm::ivec2{0, 3}, false, true);
mGrid.setEntry(mHeaderGrid, glm::ivec2{0, 0}, false, true); mGrid.setEntry(mSubtitle, glm::ivec2{0, 2}, false, true, glm::ivec2{3, 1});
mList = std::make_shared<ComponentList>(mWindow); mList = std::make_shared<ComponentList>(mWindow);
mGrid.setEntry(mList, glm::ivec2{0, 1}, true, true); mGrid.setEntry(mList, glm::ivec2{0, 4}, true, true, glm::ivec2{3, 1});
// Set up scroll indicators.
mScrollUp = std::make_shared<ImageComponent>(mWindow);
mScrollDown = std::make_shared<ImageComponent>(mWindow);
mScrollIndicator = std::make_shared<ScrollIndicatorComponent>(mList, mScrollUp, mScrollDown);
mScrollUp->setResize(0.0f, mTitle->getFont()->getLetterHeight() / 2.0f);
mScrollUp->setOrigin(0.0f, -0.35f);
mScrollDown->setResize(0.0f, mTitle->getFont()->getLetterHeight() / 2.0f);
mScrollDown->setOrigin(0.0f, 0.35f);
mGrid.setEntry(mScrollUp, glm::ivec2{2, 0}, false, false, glm::ivec2{1, 1});
mGrid.setEntry(mScrollDown, glm::ivec2{2, 1}, false, false, glm::ivec2{1, 1});
// Populate list. // Populate list.
for (auto iter = mdd.cbegin(); iter != mdd.cend(); iter++) { for (auto iter = mdd.cbegin(); iter != mdd.cend(); iter++) {
@ -143,10 +156,6 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
ed->setSize(0.0f, height); ed->setSize(0.0f, height);
row.addElement(ed, false, true); row.addElement(ed, false, true);
auto ratingSpacer = std::make_shared<GuiComponent>(mWindow);
ratingSpacer->setSize(Renderer::getScreenWidth() * 0.001f, 0.0f);
row.addElement(ratingSpacer, false);
// Pass input to the actual RatingComponent instead of the spacer. // Pass input to the actual RatingComponent instead of the spacer.
row.input_handler = std::bind(&GuiComponent::input, ed.get(), std::placeholders::_1, row.input_handler = std::bind(&GuiComponent::input, ed.get(), std::placeholders::_1,
std::placeholders::_2); std::placeholders::_2);
@ -162,10 +171,6 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
ed->setChangedColor(TEXTCOLOR_USERMARKED); ed->setChangedColor(TEXTCOLOR_USERMARKED);
row.addElement(ed, false); row.addElement(ed, false);
auto dateSpacer = std::make_shared<GuiComponent>(mWindow);
dateSpacer->setSize(Renderer::getScreenWidth() * 0.0035f, 0.0f);
row.addElement(dateSpacer, false);
// Pass input to the actual DateTimeEditComponent instead of the spacer. // Pass input to the actual DateTimeEditComponent instead of the spacer.
row.input_handler = std::bind(&GuiComponent::input, ed.get(), std::placeholders::_1, row.input_handler = std::bind(&GuiComponent::input, ed.get(), std::placeholders::_1,
std::placeholders::_2); std::placeholders::_2);
@ -253,9 +258,8 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
label = entry.second; label = entry.second;
std::shared_ptr<TextComponent> labelText = std::shared_ptr<TextComponent> labelText =
std::make_shared<TextComponent>(mWindow, label, std::make_shared<TextComponent>(
Font::get(FONT_SIZE_MEDIUM), mWindow, label, Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
0x777777FF, ALIGN_CENTER);
if (scraperParams.system->getAlternativeEmulator() == "" && if (scraperParams.system->getAlternativeEmulator() == "" &&
scraperParams.system->getSystemEnvData() scraperParams.system->getSystemEnvData()
@ -300,7 +304,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
// ratio value is the 16:9 reference. // ratio value is the 16:9 reference.
float aspectValue = 1.778f / Renderer::getScreenAspectRatio(); float aspectValue = 1.778f / Renderer::getScreenAspectRatio();
float maxWidthModifier = glm::clamp(0.70f * aspectValue, 0.50f, 0.92f); float maxWidthModifier = glm::clamp(0.64f * aspectValue, 0.42f, 0.92f);
float maxWidth = float maxWidth =
static_cast<float>(Renderer::getScreenWidth()) * maxWidthModifier; static_cast<float>(Renderer::getScreenWidth()) * maxWidthModifier;
@ -472,58 +476,38 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
} }
mButtons = makeButtonGrid(mWindow, buttons); mButtons = makeButtonGrid(mWindow, buttons);
mGrid.setEntry(mButtons, glm::ivec2{0, 2}, true, false); mGrid.setEntry(mButtons, glm::ivec2{0, 5}, true, false, glm::ivec2{3, 1});
// Resize + center. // Resize + center.
float width = float width =
static_cast<float>(std::min(static_cast<int>(Renderer::getScreenHeight() * 1.05f), static_cast<float>(std::min(static_cast<int>(Renderer::getScreenHeight() * 1.05f),
static_cast<int>(Renderer::getScreenWidth() * 0.90f))); static_cast<int>(Renderer::getScreenWidth() * 0.90f)));
setSize(width, Renderer::getScreenHeight() * 0.83f);
setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f, // Set height explicitly to ten rows for the component list.
(Renderer::getScreenHeight() - mSize.y) / 2.0f); float height = mList->getRowHeight(0) * 10.0f + mTitle->getSize().y + mSubtitle->getSize().y +
mButtons->getSize().y;
setSize(width, height);
} }
void GuiMetaDataEd::onSizeChanged() void GuiMetaDataEd::onSizeChanged()
{ {
mGrid.setSize(mSize);
const float titleHeight = mTitle->getFont()->getLetterHeight();
const float subtitleHeight = mSubtitle->getFont()->getLetterHeight();
const float titleSubtitleSpacing = mSize.y * 0.03f; const float titleSubtitleSpacing = mSize.y * 0.03f;
mGrid.setRowHeightPerc( mGrid.setRowHeightPerc(0, TITLE_HEIGHT / mSize.y / 2.0f);
0, (titleHeight + titleSubtitleSpacing + subtitleHeight + TITLE_VERT_PADDING) / mSize.y); mGrid.setRowHeightPerc(1, TITLE_HEIGHT / mSize.y / 2.0f);
mGrid.setRowHeightPerc(2, mButtons->getSize().y / mSize.y); mGrid.setRowHeightPerc(2, titleSubtitleSpacing / mSize.y);
mGrid.setRowHeightPerc(3, (titleSubtitleSpacing * 1.2f) / mSize.y);
mGrid.setRowHeightPerc(4, ((mList->getRowHeight(0) * 10.0f) + 2.0f) / mSize.y);
// Snap list size to the row height to prevent a fraction of a row from being displayed. mGrid.setColWidthPerc(0, 0.07f);
float listHeight = 0.0f; mGrid.setColWidthPerc(2, 0.07f);
float listSize = mList->getSize().y;
int i = 0;
while (i < mList->size()) {
// Add the separator height to the row height so that it also gets properly rendered.
float rowHeight = mList->getRowHeight(i) + Renderer::getScreenHeightModifier();
if (listHeight + rowHeight < listSize)
listHeight += rowHeight;
else
break;
i++;
}
// Adjust the size of the list and window. mGrid.setSize(mSize);
float heightAdjustment = listSize - listHeight; mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f});
mList->setSize(mList->getSize().x, listHeight);
glm::vec2 newWindowSize{mSize};
newWindowSize.y -= heightAdjustment;
mBackground.fitTo(newWindowSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f});
// Move the buttons up as well to make the layout align correctly after the resize. setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f,
glm::vec3 newButtonPos{mButtons->getPosition()}; (Renderer::getScreenHeight() - mSize.y) / 2.0f);
newButtonPos.y -= heightAdjustment;
mButtons->setPosition(newButtonPos);
mHeaderGrid->setRowHeightPerc(1, titleHeight / mHeaderGrid->getSize().y);
mHeaderGrid->setRowHeightPerc(2, titleSubtitleSpacing / mHeaderGrid->getSize().y);
mHeaderGrid->setRowHeightPerc(3, subtitleHeight / mHeaderGrid->getSize().y);
} }
void GuiMetaDataEd::save() void GuiMetaDataEd::save()
@ -560,9 +544,9 @@ void GuiMetaDataEd::save()
// If hidden games are not shown and the hide flag was set for the entry, then write the // If hidden games are not shown and the hide flag was set for the entry, then write the
// metadata immediately regardless of the SaveGamelistsMode setting. Otherwise the file // metadata immediately regardless of the SaveGamelistsMode setting. Otherwise the file
// will never be written as the game will be filtered from the gamelist. This solution is not // will never be written as the game will be filtered from the gamelist. This solution is
// really good as the gamelist will be written twice, but it's a very special and hopefully // not really good as the gamelist will be written twice, but it's a very special and
// rare situation. // hopefully rare situation.
if (hideGameWhileHidden) if (hideGameWhileHidden)
updateGamelist(mScraperParams.system); updateGamelist(mScraperParams.system);

View file

@ -15,6 +15,7 @@
#include "MetaData.h" #include "MetaData.h"
#include "components/ComponentGrid.h" #include "components/ComponentGrid.h"
#include "components/NinePatchComponent.h" #include "components/NinePatchComponent.h"
#include "components/ScrollIndicatorComponent.h"
#include "guis/GuiSettings.h" #include "guis/GuiSettings.h"
#include "scrapers/Scraper.h" #include "scrapers/Scraper.h"
@ -49,6 +50,9 @@ private:
ComponentGrid mGrid; ComponentGrid mGrid;
std::shared_ptr<TextComponent> mTitle; std::shared_ptr<TextComponent> mTitle;
std::shared_ptr<ImageComponent> mScrollUp;
std::shared_ptr<ImageComponent> mScrollDown;
std::shared_ptr<ScrollIndicatorComponent> mScrollIndicator;
std::shared_ptr<TextComponent> mSubtitle; std::shared_ptr<TextComponent> mSubtitle;
std::shared_ptr<ComponentGrid> mHeaderGrid; std::shared_ptr<ComponentGrid> mHeaderGrid;
std::shared_ptr<ComponentList> mList; std::shared_ptr<ComponentList> mList;

View file

@ -71,9 +71,9 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int
// Adjust the game description text scrolling parameters depending on the search type. // Adjust the game description text scrolling parameters depending on the search type.
if (mSearchType == NEVER_AUTO_ACCEPT) if (mSearchType == NEVER_AUTO_ACCEPT)
mDescContainer->setScrollParameters(3000, 3000, 85); mDescContainer->setScrollParameters(3000.0f, 3000.0f, 0.8f);
else else
mDescContainer->setScrollParameters(6000, 3000, 85); mDescContainer->setScrollParameters(6000.0f, 3000.0f, 0.8f);
mResultDesc = std::make_shared<TextComponent>(mWindow, "Result desc", mResultDesc = std::make_shared<TextComponent>(mWindow, "Result desc",
Font::get(FONT_SIZE_SMALL), 0x777777FF); Font::get(FONT_SIZE_SMALL), 0x777777FF);

View file

@ -232,7 +232,7 @@ bool parseArgs(int argc, char* argv[])
} }
int width = atoi(argv[i + 1]); int width = atoi(argv[i + 1]);
int height = atoi(argv[i + 2]); int height = atoi(argv[i + 2]);
if (width < 640 || height < 480 || width > 7680 || height > 4320 || if (width < 224 || height < 224 || width > 7680 || height > 4320 ||
height < width / 4 || width < height / 2) { height < width / 4 || width < height / 2) {
std::cerr << "Error: Unsupported resolution " << width << "x" << height std::cerr << "Error: Unsupported resolution " << width << "x" << height
<< " supplied.\n"; << " supplied.\n";

View file

@ -23,11 +23,12 @@
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
#include "utils/TimeUtil.h" #include "utils/TimeUtil.h"
#include "rapidjson/document.h"
#include "rapidjson/error/en.h"
#include <exception> #include <exception>
#include <map> #include <map>
#include <pugixml.hpp> #include <pugixml.hpp>
#include <rapidjson/document.h>
#include <rapidjson/error/en.h>
using namespace PlatformIds; using namespace PlatformIds;
using namespace rapidjson; using namespace rapidjson;

View file

@ -21,11 +21,12 @@
#include "Log.h" #include "Log.h"
#include "utils/FileSystemUtil.h" #include "utils/FileSystemUtil.h"
#include "rapidjson/document.h"
#include "rapidjson/error/en.h"
#include <chrono> #include <chrono>
#include <fstream> #include <fstream>
#include <memory> #include <memory>
#include <rapidjson/document.h>
#include <rapidjson/error/en.h>
#include <thread> #include <thread>
using namespace rapidjson; using namespace rapidjson;

View file

@ -68,6 +68,10 @@ void SystemView::populate()
e.name = (*it)->getName(); e.name = (*it)->getName();
e.object = *it; e.object = *it;
// Component offset.
glm::vec3 offsetLogo = {0.0f, 0.0f, 0.0f};
glm::vec3 offsetLogoPlaceholderText = {0.0f, 0.0f, 0.0f};
// Make logo. // Make logo.
const ThemeData::ThemeElement* logoElem = theme->getElement("system", "logo", "image"); const ThemeData::ThemeElement* logoElem = theme->getElement("system", "logo", "image");
if (logoElem) { if (logoElem) {
@ -84,25 +88,83 @@ void SystemView::populate()
e.data.logo = std::shared_ptr<GuiComponent>(logo); e.data.logo = std::shared_ptr<GuiComponent>(logo);
} }
} }
if (!e.data.logo) {
// No logo in theme; use text.
TextComponent* text =
new TextComponent(mWindow, (*it)->getName(), Font::get(FONT_SIZE_LARGE),
0x000000FF, ALIGN_CENTER);
text->setSize(mCarousel.logoSize * mCarousel.logoScale);
text->applyTheme((*it)->getTheme(), "system", "logoText",
ThemeFlags::FONT_PATH | ThemeFlags::FONT_SIZE | ThemeFlags::COLOR |
ThemeFlags::FORCE_UPPERCASE | ThemeFlags::LINE_SPACING |
ThemeFlags::TEXT);
e.data.logo = std::shared_ptr<GuiComponent>(text);
if (mCarousel.type == VERTICAL || mCarousel.type == VERTICAL_WHEEL) { if (!e.data.logo) {
text->setHorizontalAlignment(mCarousel.logoAlignment); // No logo in theme; use placeholder.
text->setVerticalAlignment(ALIGN_CENTER);
glm::vec2 resolution = glm::vec2{static_cast<float>(Renderer::getScreenWidth()),
static_cast<float>(Renderer::getScreenHeight())};
glm::vec3 center = {resolution.x / 2.0f, resolution.y / 2.0f, 1.0f};
glm::vec2 scale{getParent() ? getParent()->getSize() : resolution};
// Placeholder Image.
const ThemeData::ThemeElement* logoElem =
theme->getElement("system", "logoPlaceholderImage", "image");
if (logoElem) {
auto path = logoElem->get<std::string>("path");
std::string defaultPath =
logoElem->has("default") ? logoElem->get<std::string>("default") : "";
if ((!path.empty() && ResourceManager::getInstance()->fileExists(path)) ||
(!defaultPath.empty() &&
ResourceManager::getInstance()->fileExists(defaultPath))) {
ImageComponent* logo = new ImageComponent(mWindow, false, false);
logo->applyTheme(theme, "system", "logoPlaceholderImage", ThemeFlags::ALL);
if (!logoElem->has("size"))
logo->setMaxSize(mCarousel.logoSize * mCarousel.logoScale);
offsetLogo = logo->getPosition() - center;
logo->setRotateByTargetSize(true);
e.data.logo = std::shared_ptr<GuiComponent>(logo);
}
}
// Placeholder Text.
const ThemeData::ThemeElement* logoPlaceholderText =
theme->getElement("system", "logoPlaceholderText", "text");
if (logoPlaceholderText) {
// Element 'logoPlaceholderText' found in theme: place text
auto* text =
new TextComponent(mWindow, (*it)->getName(), Font::get(FONT_SIZE_LARGE),
0x000000FF, ALIGN_CENTER);
text->setSize(mCarousel.logoSize * mCarousel.logoScale);
if (mCarousel.type == VERTICAL || mCarousel.type == VERTICAL_WHEEL) {
text->setHorizontalAlignment(mCarousel.logoAlignment);
text->setVerticalAlignment(ALIGN_CENTER);
}
else {
text->setHorizontalAlignment(ALIGN_CENTER);
text->setVerticalAlignment(mCarousel.logoAlignment);
}
text->applyTheme((*it)->getTheme(), "system", "logoPlaceholderText",
ThemeFlags::ALL);
if (!e.data.logo) {
e.data.logo = std::shared_ptr<GuiComponent>(text);
offsetLogo = text->getPosition() - center;
}
else {
e.data.logoPlaceholderText = std::shared_ptr<GuiComponent>(text);
offsetLogoPlaceholderText = text->getPosition() - center;
}
} }
else { else {
text->setHorizontalAlignment(ALIGN_CENTER); // Fallback to legacy centered placeholder text.
text->setVerticalAlignment(mCarousel.logoAlignment); TextComponent* text =
new TextComponent(mWindow, (*it)->getName(), Font::get(FONT_SIZE_LARGE),
0x000000FF, ALIGN_CENTER);
text->setSize(mCarousel.logoSize * mCarousel.logoScale);
text->applyTheme((*it)->getTheme(), "system", "logoText",
ThemeFlags::FONT_PATH | ThemeFlags::FONT_SIZE |
ThemeFlags::COLOR | ThemeFlags::FORCE_UPPERCASE |
ThemeFlags::LINE_SPACING | ThemeFlags::TEXT);
e.data.logo = std::shared_ptr<GuiComponent>(text);
if (mCarousel.type == VERTICAL || mCarousel.type == VERTICAL_WHEEL) {
text->setHorizontalAlignment(mCarousel.logoAlignment);
text->setVerticalAlignment(ALIGN_CENTER);
}
else {
text->setHorizontalAlignment(ALIGN_CENTER);
text->setVerticalAlignment(mCarousel.logoAlignment);
}
} }
} }
@ -124,7 +186,11 @@ void SystemView::populate()
} }
glm::vec2 denormalized{mCarousel.logoSize * e.data.logo->getOrigin()}; glm::vec2 denormalized{mCarousel.logoSize * e.data.logo->getOrigin()};
e.data.logo->setPosition(denormalized.x, denormalized.y, 0.0f); glm::vec3 v = {denormalized.x, denormalized.y, 0.0f};
e.data.logo->setPosition(v + offsetLogo);
if (e.data.logoPlaceholderText)
e.data.logoPlaceholderText->setPosition(
v + offsetLogoPlaceholderText); // e.data.logo->getPosition() +
// Make background extras. // Make background extras.
e.data.backgroundExtras = ThemeData::makeExtras((*it)->getTheme(), "system", mWindow); e.data.backgroundExtras = ThemeData::makeExtras((*it)->getTheme(), "system", mWindow);
@ -590,6 +656,17 @@ void SystemView::renderCarousel(const glm::mat4& trans)
comp->setScale(scale); comp->setScale(scale);
comp->setOpacity(static_cast<unsigned char>(opacity)); comp->setOpacity(static_cast<unsigned char>(opacity));
comp->render(logoTrans); comp->render(logoTrans);
if (mEntries.at(index).data.logoPlaceholderText) {
const std::shared_ptr<GuiComponent>& comp = mEntries.at(index).data.logoPlaceholderText;
if (mCarousel.type == VERTICAL_WHEEL || mCarousel.type == HORIZONTAL_WHEEL) {
comp->setRotationDegrees(mCarousel.logoRotation * distance);
comp->setRotationOrigin(mCarousel.logoRotationOrigin);
}
comp->setScale(scale);
comp->setOpacity(static_cast<unsigned char>(opacity));
comp->render(logoTrans);
}
} }
Renderer::popClipRect(); Renderer::popClipRect();
} }

View file

@ -29,6 +29,7 @@ enum CarouselType : unsigned int {
struct SystemViewData { struct SystemViewData {
std::shared_ptr<GuiComponent> logo; std::shared_ptr<GuiComponent> logo;
std::shared_ptr<GuiComponent> logoPlaceholderText;
std::vector<GuiComponent*> backgroundExtras; std::vector<GuiComponent*> backgroundExtras;
}; };

View file

@ -24,7 +24,6 @@
#include "animations/Animation.h" #include "animations/Animation.h"
#include "animations/LambdaAnimation.h" #include "animations/LambdaAnimation.h"
#include "animations/MoveCameraAnimation.h" #include "animations/MoveCameraAnimation.h"
#include "guis/GuiInfoPopup.h"
#include "guis/GuiMenu.h" #include "guis/GuiMenu.h"
#include "guis/GuiTextEditKeyboardPopup.h" #include "guis/GuiTextEditKeyboardPopup.h"
#include "guis/GuiTextEditPopup.h" #include "guis/GuiTextEditPopup.h"
@ -700,10 +699,8 @@ void ViewController::launch(FileData* game)
if (durationString == "disabled") { if (durationString == "disabled") {
// If the game launch screen has been set as disabled, show a simple info popup // If the game launch screen has been set as disabled, show a simple info popup
// notification instead. // notification instead.
GuiInfoPopup* s = new GuiInfoPopup( mWindow->queueInfoPopup(
mWindow, "LAUNCHING GAME '" + Utils::String::toUpper(game->metadata.get("name") + "'"), "LAUNCHING GAME '" + Utils::String::toUpper(game->metadata.get("name") + "'"), 10000);
10000);
mWindow->setInfoPopup(s);
duration = 1700; duration = 1700;
} }
else if (durationString == "brief") { else if (durationString == "brief") {
@ -849,9 +846,12 @@ bool ViewController::input(InputConfig* config, Input input)
// background while a game is launched. If we're in this state and then register some // background while a game is launched. If we're in this state and then register some
// input, it means that the user is back in ES-DE. Therefore unset the game launch flag // input, it means that the user is back in ES-DE. Therefore unset the game launch flag
// and update all the GUI components. This will re-enable the video player and let the // and update all the GUI components. This will re-enable the video player and let the
// screensaver start on schedule again. // screensaver start on schedule again. Also re-enable scrolling for TextListComponent
if (mWindow->getGameLaunchedState()) // and ScrollableContainer.
if (mWindow->getGameLaunchedState()) {
mWindow->setAllowTextScrolling(true);
mWindow->unsetLaunchedGame(); mWindow->unsetLaunchedGame();
}
// Open the main menu. // Open the main menu.
if (!(UIModeController::getInstance()->isUIModeKid() && if (!(UIModeController::getInstance()->isUIModeKid() &&

View file

@ -13,7 +13,7 @@
#include "Settings.h" #include "Settings.h"
#include "Sound.h" #include "Sound.h"
#include "SystemData.h" #include "SystemData.h"
#include "guis/GuiInfoPopup.h" #include "Window.h"
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
#include "views/UIModeController.h" #include "views/UIModeController.h"
#include "views/ViewController.h" #include "views/ViewController.h"
@ -27,7 +27,7 @@ ISimpleGameListView::ISimpleGameListView(Window* window, FileData* root)
, mBackground(window) , mBackground(window)
, mRandomGame(nullptr) , mRandomGame(nullptr)
{ {
mHeaderText.setText("Logo Text"); mHeaderText.setText("Logo Text", false);
mHeaderText.setSize(mSize.x, 0.0f); mHeaderText.setSize(mSize.x, 0.0f);
mHeaderText.setPosition(0.0f, 0.0f); mHeaderText.setPosition(0.0f, 0.0f);
mHeaderText.setHorizontalAlignment(ALIGN_CENTER); mHeaderText.setHorizontalAlignment(ALIGN_CENTER);
@ -273,18 +273,13 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
mRoot->getSystem()->isGameSystem() && getCursor()->getType() != PLACEHOLDER && mRoot->getSystem()->isGameSystem() && getCursor()->getType() != PLACEHOLDER &&
getCursor()->getParent()->getPath() == "collections") { getCursor()->getParent()->getPath() == "collections") {
NavigationSounds::getInstance()->playThemeNavigationSound(FAVORITESOUND); NavigationSounds::getInstance()->playThemeNavigationSound(FAVORITESOUND);
GuiInfoPopup* s; mWindow->queueInfoPopup("CAN'T ADD CUSTOM COLLECTIONS TO CUSTOM COLLECTIONS", 4000);
s = new GuiInfoPopup(mWindow, "CAN'T ADD CUSTOM COLLECTIONS TO CUSTOM COLLECTIONS",
4000);
mWindow->setInfoPopup(s);
} }
// Notify the user if attempting to add a placeholder to a custom collection. // Notify the user if attempting to add a placeholder to a custom collection.
if (CollectionSystemsManager::get()->isEditing() && if (CollectionSystemsManager::get()->isEditing() &&
mRoot->getSystem()->isGameSystem() && getCursor()->getType() == PLACEHOLDER) { mRoot->getSystem()->isGameSystem() && getCursor()->getType() == PLACEHOLDER) {
NavigationSounds::getInstance()->playThemeNavigationSound(FAVORITESOUND); NavigationSounds::getInstance()->playThemeNavigationSound(FAVORITESOUND);
GuiInfoPopup* s; mWindow->queueInfoPopup("CAN'T ADD PLACEHOLDERS TO CUSTOM COLLECTIONS", 4000);
s = new GuiInfoPopup(mWindow, "CAN'T ADD PLACEHOLDERS TO CUSTOM COLLECTIONS", 4000);
mWindow->setInfoPopup(s);
} }
else if (mRoot->getSystem()->isGameSystem() && getCursor()->getType() != PLACEHOLDER && else if (mRoot->getSystem()->isGameSystem() && getCursor()->getType() != PLACEHOLDER &&
getCursor()->getParent()->getPath() != "collections") { getCursor()->getParent()->getPath() != "collections") {
@ -394,17 +389,14 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
// so it makes more sense to handle it here than to add the function to // so it makes more sense to handle it here than to add the function to
// CollectionSystemsManager. // CollectionSystemsManager.
if (entryToUpdate->getType() == FOLDER) { if (entryToUpdate->getType() == FOLDER) {
GuiInfoPopup* s;
if (isEditing) { if (isEditing) {
s = new GuiInfoPopup(mWindow, "CAN'T ADD FOLDERS TO CUSTOM COLLECTIONS", mWindow->queueInfoPopup("CAN'T ADD FOLDERS TO CUSTOM COLLECTIONS", 4000);
4000);
} }
else { else {
MetaDataList* md = &entryToUpdate->getSourceFileData()->metadata; MetaDataList* md = &entryToUpdate->getSourceFileData()->metadata;
if (md->get("favorite") == "false") { if (md->get("favorite") == "false") {
md->set("favorite", "true"); md->set("favorite", "true");
s = new GuiInfoPopup( mWindow->queueInfoPopup(
mWindow,
"MARKED FOLDER '" + "MARKED FOLDER '" +
Utils::String::toUpper(Utils::String::removeParenthesis( Utils::String::toUpper(Utils::String::removeParenthesis(
entryToUpdate->getName())) + entryToUpdate->getName())) +
@ -413,8 +405,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
} }
else { else {
md->set("favorite", "false"); md->set("favorite", "false");
s = new GuiInfoPopup( mWindow->queueInfoPopup(
mWindow,
"REMOVED FAVORITE MARKING FOR FOLDER '" + "REMOVED FAVORITE MARKING FOR FOLDER '" +
Utils::String::toUpper(Utils::String::removeParenthesis( Utils::String::toUpper(Utils::String::removeParenthesis(
entryToUpdate->getName())) + entryToUpdate->getName())) +
@ -423,7 +414,6 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
} }
} }
mWindow->setInfoPopup(s);
entryToUpdate->getSourceFileData()->getSystem()->onMetaDataSavePoint(); entryToUpdate->getSourceFileData()->getSystem()->onMetaDataSavePoint();
getCursor()->getParent()->sort( getCursor()->getParent()->sort(
@ -445,11 +435,9 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
return true; return true;
} }
else if (isEditing && entryToUpdate->metadata.get("nogamecount") == "true") { else if (isEditing && entryToUpdate->metadata.get("nogamecount") == "true") {
GuiInfoPopup* s = new GuiInfoPopup(mWindow, mWindow->queueInfoPopup("CAN'T ADD ENTRIES THAT ARE NOT COUNTED "
"CAN'T ADD ENTRIES THAT ARE NOT COUNTED " "AS GAMES TO CUSTOM COLLECTIONS",
"AS GAMES TO CUSTOM COLLECTIONS", 4000);
4000);
mWindow->setInfoPopup(s);
} }
else if (CollectionSystemsManager::get()->toggleGameInCollection(entryToUpdate)) { else if (CollectionSystemsManager::get()->toggleGameInCollection(entryToUpdate)) {
// As the toggling of the game destroyed this object, we need to get the view // As the toggling of the game destroyed this object, we need to get the view

View file

@ -52,6 +52,7 @@ set(CORE_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/src/components/OptionListComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/OptionListComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/src/components/RatingComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/RatingComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/src/components/ScrollableContainer.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ScrollableContainer.h
${CMAKE_CURRENT_SOURCE_DIR}/src/components/ScrollIndicatorComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/src/components/SliderComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/SliderComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/src/components/SwitchComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/SwitchComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/src/components/TextComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/TextComponent.h
@ -63,6 +64,7 @@ set(CORE_HEADERS
# GUIs # GUIs
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiDetectDevice.h ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiDetectDevice.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiInfoPopup.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiInputConfig.h ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiInputConfig.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMsgBox.h ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMsgBox.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiTextEditKeyboardPopup.h ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiTextEditKeyboardPopup.h
@ -135,6 +137,7 @@ set(CORE_SOURCES
# GUIs # GUIs
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiDetectDevice.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiDetectDevice.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiInfoPopup.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiInputConfig.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiInputConfig.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMsgBox.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMsgBox.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiTextEditKeyboardPopup.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiTextEditKeyboardPopup.cpp

View file

@ -114,7 +114,7 @@ CECInput::CECInput()
callbacks.keyPress = &onKeyPress; callbacks.keyPress = &onKeyPress;
callbacks.logMessage = &onLogMessage; callbacks.logMessage = &onLogMessage;
sprintf(config.strDeviceName, "RetroPie ES"); sprintf(config.strDeviceName, "ES-DE");
config.clientVersion = CEC::LIBCEC_VERSION_CURRENT; config.clientVersion = CEC::LIBCEC_VERSION_CURRENT;
config.bActivateSource = 0; config.bActivateSource = 0;
config.callbacks = &callbacks; config.callbacks = &callbacks;

View file

@ -95,18 +95,27 @@ void GuiComponent::renderChildren(const glm::mat4& transform) const
void GuiComponent::setPosition(float x, float y, float z) void GuiComponent::setPosition(float x, float y, float z)
{ {
if (mPosition.x == x && mPosition.y == y && mPosition.z == z)
return;
mPosition = glm::vec3{x, y, z}; mPosition = glm::vec3{x, y, z};
onPositionChanged(); onPositionChanged();
} }
void GuiComponent::setOrigin(float x, float y) void GuiComponent::setOrigin(float x, float y)
{ {
if (mOrigin.x == x && mOrigin.y == y)
return;
mOrigin = glm::vec2{x, y}; mOrigin = glm::vec2{x, y};
onOriginChanged(); onOriginChanged();
} }
void GuiComponent::setSize(float w, float h) void GuiComponent::setSize(float w, float h)
{ {
if (mSize.x == w && mSize.y == h)
return;
mSize = glm::vec2{w, h}; mSize = glm::vec2{w, h};
onSizeChanged(); onSizeChanged();
} }
@ -166,6 +175,9 @@ int GuiComponent::getChildIndex() const
void GuiComponent::setOpacity(unsigned char opacity) void GuiComponent::setOpacity(unsigned char opacity)
{ {
if (mOpacity == opacity)
return;
mOpacity = opacity; mOpacity = opacity;
for (auto it = mChildren.cbegin(); it != mChildren.cend(); it++) for (auto it = mChildren.cbegin(); it != mChildren.cend(); it++)
(*it)->setOpacity(opacity); (*it)->setOpacity(opacity);

View file

@ -161,6 +161,7 @@ public:
virtual void setOpacity(unsigned char opacity); virtual void setOpacity(unsigned char opacity);
virtual unsigned int getColor() const { return mColor; } virtual unsigned int getColor() const { return mColor; }
virtual unsigned int getColorShift() const { return mColorShift; } virtual unsigned int getColorShift() const { return mColorShift; }
virtual float getLineSpacing() { return 0.0f; }
virtual void setColor(unsigned int color) virtual void setColor(unsigned int color)
{ {
mColor = color; mColor = color;
@ -191,7 +192,7 @@ public:
virtual void setHiddenValue(const std::string& value) {} virtual void setHiddenValue(const std::string& value) {}
// Used to set the parameters for ScrollableContainer. // Used to set the parameters for ScrollableContainer.
virtual void setScrollParameters(float, float, int) {} virtual void setScrollParameters(float, float, float) {}
virtual void onFocusGained() {} virtual void onFocusGained() {}
virtual void onFocusLost() {} virtual void onFocusLost() {}

View file

@ -112,7 +112,7 @@ void InputManager::init()
numJoysticks--; numJoysticks--;
for (int i = 0; i < numJoysticks; i++) for (int i = 0; i < numJoysticks; i++)
addControllerByDeviceIndex(i); addControllerByDeviceIndex(nullptr, i);
SDL_USER_CECBUTTONDOWN = SDL_RegisterEvents(2); SDL_USER_CECBUTTONDOWN = SDL_RegisterEvents(2);
SDL_USER_CECBUTTONUP = SDL_USER_CECBUTTONDOWN + 1; SDL_USER_CECBUTTONUP = SDL_USER_CECBUTTONDOWN + 1;
@ -482,11 +482,11 @@ bool InputManager::parseEvent(const SDL_Event& event, Window* window)
break; break;
} }
case SDL_CONTROLLERDEVICEADDED: { case SDL_CONTROLLERDEVICEADDED: {
addControllerByDeviceIndex(event.cdevice.which); addControllerByDeviceIndex(window, event.cdevice.which);
return true; return true;
} }
case SDL_CONTROLLERDEVICEREMOVED: { case SDL_CONTROLLERDEVICEREMOVED: {
removeControllerByJoystickID(event.cdevice.which); removeControllerByJoystickID(window, event.cdevice.which);
return false; return false;
} }
} }
@ -621,7 +621,7 @@ void InputManager::loadDefaultControllerConfig(SDL_JoystickID deviceIndex)
// clang-format on // clang-format on
} }
void InputManager::addControllerByDeviceIndex(int deviceIndex) void InputManager::addControllerByDeviceIndex(Window* window, int deviceIndex)
{ {
// Open joystick and add it to our list. // Open joystick and add it to our list.
SDL_GameController* controller = SDL_GameControllerOpen(deviceIndex); SDL_GameController* controller = SDL_GameControllerOpen(deviceIndex);
@ -652,6 +652,14 @@ void InputManager::addControllerByDeviceIndex(int deviceIndex)
<< ", instance ID: " << joyID << ", device index: " << deviceIndex << ")"; << ", instance ID: " << joyID << ", device index: " << deviceIndex << ")";
} }
if (window != nullptr) {
window->queueInfoPopup(
"ADDED INPUT DEVICE '" +
Utils::String::toUpper(std::string(SDL_GameControllerName(mControllers[joyID]))) +
"'",
4000);
}
int numAxes = SDL_JoystickNumAxes(joy); int numAxes = SDL_JoystickNumAxes(joy);
int numButtons = SDL_JoystickNumButtons(joy); int numButtons = SDL_JoystickNumButtons(joy);
@ -662,7 +670,7 @@ void InputManager::addControllerByDeviceIndex(int deviceIndex)
mPrevButtonValues[std::make_pair(joyID, button)] = -1; mPrevButtonValues[std::make_pair(joyID, button)] = -1;
} }
void InputManager::removeControllerByJoystickID(SDL_JoystickID joyID) void InputManager::removeControllerByJoystickID(Window* window, SDL_JoystickID joyID)
{ {
assert(joyID != -1); assert(joyID != -1);
@ -673,6 +681,14 @@ void InputManager::removeControllerByJoystickID(SDL_JoystickID joyID)
LOG(LogInfo) << "Removed controller \"" << SDL_GameControllerName(mControllers[joyID]) LOG(LogInfo) << "Removed controller \"" << SDL_GameControllerName(mControllers[joyID])
<< "\" (GUID: " << guid << ", instance ID: " << joyID << ")"; << "\" (GUID: " << guid << ", instance ID: " << joyID << ")";
if (window != nullptr) {
window->queueInfoPopup(
"REMOVED INPUT DEVICE '" +
Utils::String::toUpper(std::string(SDL_GameControllerName(mControllers[joyID]))) +
"'",
4000);
}
// Delete mPrevAxisValues for the device. // Delete mPrevAxisValues for the device.
int axisEntries = static_cast<int>(mPrevAxisValues.size()); int axisEntries = static_cast<int>(mPrevAxisValues.size());
for (int i = 0; i < axisEntries; i++) { for (int i = 0; i < axisEntries; i++) {

View file

@ -61,8 +61,8 @@ private:
void loadDefaultKBConfig(); void loadDefaultKBConfig();
void loadDefaultControllerConfig(SDL_JoystickID deviceIndex); void loadDefaultControllerConfig(SDL_JoystickID deviceIndex);
void addControllerByDeviceIndex(int deviceIndex); void addControllerByDeviceIndex(Window* window, int deviceIndex);
void removeControllerByJoystickID(SDL_JoystickID joyID); void removeControllerByJoystickID(Window* window, SDL_JoystickID joyID);
static InputManager* sInstance; static InputManager* sInstance;
static const int DEADZONE_TRIGGERS = 18000; static const int DEADZONE_TRIGGERS = 18000;

View file

@ -181,6 +181,7 @@ void Settings::setDefaults()
mBoolMap["SpecialCharsASCII"] = {false, false}; mBoolMap["SpecialCharsASCII"] = {false, false};
mBoolMap["ListScrollOverlay"] = {false, false}; mBoolMap["ListScrollOverlay"] = {false, false};
mBoolMap["VirtualKeyboard"] = {true, true}; mBoolMap["VirtualKeyboard"] = {true, true};
mBoolMap["ScrollIndicators"] = {false, false};
mBoolMap["FavoritesAddButton"] = {true, true}; mBoolMap["FavoritesAddButton"] = {true, true};
mBoolMap["RandomAddButton"] = {false, false}; mBoolMap["RandomAddButton"] = {false, false};
mBoolMap["GamelistFilters"] = {true, true}; mBoolMap["GamelistFilters"] = {true, true};

View file

@ -698,8 +698,22 @@ std::string ThemeData::getThemeFromCurrentSet(const std::string& system)
std::map<std::string, ThemeSet>::const_iterator set = std::map<std::string, ThemeSet>::const_iterator set =
themeSets.find(Settings::getInstance()->getString("ThemeSet")); themeSets.find(Settings::getInstance()->getString("ThemeSet"));
if (set == themeSets.cend()) { if (set == themeSets.cend()) {
// Currently configured theme set is missing, so just pick the first available set. // Currently configured theme set is missing, attempt to load the default theme set
set = themeSets.cbegin(); // rbsimple-DE instead, and if that's also missing then pick the first available set.
bool defaultSetFound = true;
set = themeSets.find("rbsimple-DE");
if (set == themeSets.cend()) {
set = themeSets.cbegin();
defaultSetFound = false;
}
LOG(LogWarning) << "Configured theme set \""
<< Settings::getInstance()->getString("ThemeSet")
<< "\" does not exist, loading" << (defaultSetFound ? " default " : " ")
<< "theme set \"" << set->first << "\" instead";
Settings::getInstance()->setString("ThemeSet", set->first); Settings::getInstance()->setString("ThemeSet", set->first);
} }

View file

@ -11,6 +11,7 @@
#include "components/HelpComponent.h" #include "components/HelpComponent.h"
#include "components/ImageComponent.h" #include "components/ImageComponent.h"
#include "guis/GuiInfoPopup.h"
#if defined(BUILD_VLC_PLAYER) #if defined(BUILD_VLC_PLAYER)
#include "components/VideoVlcComponent.h" #include "components/VideoVlcComponent.h"
#endif #endif
@ -338,6 +339,24 @@ void Window::update(int deltaTime)
mTimeSinceLastInput += deltaTime; mTimeSinceLastInput += deltaTime;
// If there is a popup notification queued, then display it.
if (mInfoPopupQueue.size() > 0) {
bool popupIsRunning = false;
// If uncommenting the following, new popups will not be displayed until the one
// currently shown has reached its display duration. This will be used later when
// support for multiple GuiInfoPopup notifications is implemented.
// if (mInfoPopup != nullptr && mInfoPopup->isRunning())
// popupIsRunning = true;
if (!popupIsRunning) {
delete mInfoPopup;
mInfoPopup = new GuiInfoPopup(this, mInfoPopupQueue.front().first,
mInfoPopupQueue.front().second);
mInfoPopupQueue.pop();
}
}
if (peekGui()) if (peekGui())
peekGui()->update(deltaTime); peekGui()->update(deltaTime);
@ -544,13 +563,13 @@ void Window::render()
startScreensaver(); startScreensaver();
} }
if (mInfoPopup)
mInfoPopup->render(trans);
// Always call the screensaver render function regardless of whether the screensaver is active // Always call the screensaver render function regardless of whether the screensaver is active
// or not because it may perform a fade on transition. // or not because it may perform a fade on transition.
renderScreensaver(); renderScreensaver();
if (!mRenderScreensaver && mInfoPopup)
mInfoPopup->render(trans);
if (mTimeSinceLastInput >= screensaverTimer && screensaverTimer != 0) { if (mTimeSinceLastInput >= screensaverTimer && screensaverTimer != 0) {
if (!isProcessing() && mAllowSleep && (!mScreensaver)) { if (!isProcessing() && mAllowSleep && (!mScreensaver)) {
// Go to sleep. // Go to sleep.
@ -689,16 +708,13 @@ void Window::reloadHelpPrompts()
} }
} }
void Window::setInfoPopup(InfoPopup* infoPopup)
{
delete mInfoPopup;
mInfoPopup = infoPopup;
}
void Window::stopInfoPopup() void Window::stopInfoPopup()
{ {
if (mInfoPopup) if (mInfoPopup)
mInfoPopup->stop(); mInfoPopup->stop();
if (mInfoPopupQueue.size() > 0)
std::queue<std::pair<std::string, int>>().swap(mInfoPopupQueue);
} }
void Window::startScreensaver() void Window::startScreensaver()
@ -708,7 +724,7 @@ void Window::startScreensaver()
for (auto it = mGuiStack.cbegin(); it != mGuiStack.cend(); it++) for (auto it = mGuiStack.cbegin(); it != mGuiStack.cend(); it++)
(*it)->onScreensaverActivate(); (*it)->onScreensaverActivate();
stopInfoPopup(); setAllowTextScrolling(false);
mScreensaver->startScreensaver(true); mScreensaver->startScreensaver(true);
mRenderScreensaver = true; mRenderScreensaver = true;
} }
@ -719,6 +735,7 @@ bool Window::stopScreensaver()
if (mScreensaver && mRenderScreensaver) { if (mScreensaver && mRenderScreensaver) {
mScreensaver->stopScreensaver(); mScreensaver->stopScreensaver();
mRenderScreensaver = false; mRenderScreensaver = false;
setAllowTextScrolling(true);
// Tell the GUI components the screensaver has stopped. // Tell the GUI components the screensaver has stopped.
for (auto it = mGuiStack.cbegin(); it != mGuiStack.cend(); it++) { for (auto it = mGuiStack.cbegin(); it != mGuiStack.cend(); it++) {
@ -743,15 +760,19 @@ void Window::renderScreensaver()
void Window::startMediaViewer(FileData* game) void Window::startMediaViewer(FileData* game)
{ {
if (mMediaViewer) { if (mMediaViewer) {
if (mMediaViewer->startMediaViewer(game)) if (mMediaViewer->startMediaViewer(game)) {
setAllowTextScrolling(false);
mRenderMediaViewer = true; mRenderMediaViewer = true;
}
} }
} }
void Window::stopMediaViewer() void Window::stopMediaViewer()
{ {
if (mMediaViewer) if (mMediaViewer) {
mMediaViewer->stopMediaViewer(); mMediaViewer->stopMediaViewer();
setAllowTextScrolling(true);
}
mRenderMediaViewer = false; mRenderMediaViewer = false;
} }

View file

@ -18,10 +18,12 @@
#include <memory> #include <memory>
#include <mutex> #include <mutex>
#include <queue>
class FileData; class FileData;
class Font; class Font;
class GuiComponent; class GuiComponent;
class GuiInfoPopup;
class HelpComponent; class HelpComponent;
class ImageComponent; class ImageComponent;
class InputConfig; class InputConfig;
@ -73,14 +75,6 @@ public:
virtual void render(const glm::mat4& parentTrans) = 0; virtual void render(const glm::mat4& parentTrans) = 0;
}; };
class InfoPopup
{
public:
virtual void render(const glm::mat4& parentTrans) = 0;
virtual void stop() = 0;
virtual ~InfoPopup() {}
};
Window(); Window();
~Window(); ~Window();
@ -113,7 +107,11 @@ public:
void setHelpPrompts(const std::vector<HelpPrompt>& prompts, const HelpStyle& style); void setHelpPrompts(const std::vector<HelpPrompt>& prompts, const HelpStyle& style);
void reloadHelpPrompts(); void reloadHelpPrompts();
void setInfoPopup(InfoPopup* infoPopup); // GuiInfoPopup notifications.
void queueInfoPopup(const std::string& message, const int& duration)
{
mInfoPopupQueue.emplace(std::make_pair(message, duration));
}
void stopInfoPopup(); void stopInfoPopup();
void startScreensaver(); void startScreensaver();
@ -165,7 +163,9 @@ private:
Screensaver* mScreensaver; Screensaver* mScreensaver;
MediaViewer* mMediaViewer; MediaViewer* mMediaViewer;
GuiLaunchScreen* mLaunchScreen; GuiLaunchScreen* mLaunchScreen;
InfoPopup* mInfoPopup; GuiInfoPopup* mInfoPopup;
std::queue<std::pair<std::string, int>> mInfoPopupQueue;
std::string mListScrollText; std::string mListScrollText;
std::shared_ptr<Font> mListScrollFont; std::shared_ptr<Font> mListScrollFont;

View file

@ -138,7 +138,7 @@ void ComponentGrid::updateCellComponent(const GridEntry& cell)
for (int y = cell.pos.y; y < cell.pos.y + cell.dim.y; y++) for (int y = cell.pos.y; y < cell.pos.y + cell.dim.y; y++)
size.y += getRowHeight(y); size.y += getRowHeight(y);
if (cell.resize) if (cell.resize && size != glm::vec2{} && cell.component->getSize() != size)
cell.component->setSize(size); cell.component->setSize(size);
// Find top left corner. // Find top left corner.

View file

@ -11,17 +11,19 @@
#define TOTAL_HORIZONTAL_PADDING_PX 20.0f #define TOTAL_HORIZONTAL_PADDING_PX 20.0f
ComponentList::ComponentList(Window* window) ComponentList::ComponentList(Window* window)
: IList<ComponentListRow, void*>(window, LIST_SCROLL_STYLE_SLOW, LIST_NEVER_LOOP) : IList<ComponentListRow, void*>{window, LIST_SCROLL_STYLE_SLOW, LIST_NEVER_LOOP}
, mFocused{false}
, mSetupCompleted{false}
, mBottomCameraOffset{false}
, mSelectorBarOffset{0.0f}
, mCameraOffset{0.0f}
, mScrollIndicatorStatus{SCROLL_NONE}
{ {
// Adjust the padding relative to the aspect ratio and screen resolution to make it look // Adjust the padding relative to the aspect ratio and screen resolution to make it look
// coherent regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference. // coherent regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference.
float aspectValue = 1.778f / Renderer::getScreenAspectRatio(); float aspectValue{1.778f / Renderer::getScreenAspectRatio()};
mHorizontalPadding = mHorizontalPadding =
TOTAL_HORIZONTAL_PADDING_PX * aspectValue * Renderer::getScreenWidthModifier(); TOTAL_HORIZONTAL_PADDING_PX * aspectValue * Renderer::getScreenWidthModifier();
mSelectorBarOffset = 0.0f;
mCameraOffset = 0.0f;
mFocused = false;
} }
void ComponentList::addRow(const ComponentListRow& row, bool setCursorHere) void ComponentList::addRow(const ComponentListRow& row, bool setCursorHere)
@ -113,6 +115,35 @@ bool ComponentList::input(InputConfig* config, Input input)
void ComponentList::update(int deltaTime) void ComponentList::update(int deltaTime)
{ {
const float totalHeight = getTotalRowHeight();
// Scroll indicator logic, used by ScrollIndicatorComponent.
bool scrollIndicatorChanged = false;
if (totalHeight > mSize.y) {
if (mCameraOffset == 0) {
if (mScrollIndicatorStatus != SCROLL_DOWN) {
mScrollIndicatorStatus = SCROLL_DOWN;
scrollIndicatorChanged = true;
}
}
else if (mBottomCameraOffset) {
if (mScrollIndicatorStatus != SCROLL_UP) {
mScrollIndicatorStatus = SCROLL_UP;
scrollIndicatorChanged = true;
}
}
else if (mCameraOffset > 0) {
if (mScrollIndicatorStatus != SCROLL_UP_DOWN) {
mScrollIndicatorStatus = SCROLL_UP_DOWN;
scrollIndicatorChanged = true;
}
}
}
if (scrollIndicatorChanged == true && mScrollIndicatorChangedCallback != nullptr)
mScrollIndicatorChangedCallback(mScrollIndicatorStatus);
listUpdate(deltaTime); listUpdate(deltaTime);
if (size()) { if (size()) {
@ -125,6 +156,8 @@ void ComponentList::update(int deltaTime)
void ComponentList::onCursorChanged(const CursorState& state) void ComponentList::onCursorChanged(const CursorState& state)
{ {
mSetupCompleted = true;
// Update the selector bar position. // Update the selector bar position.
// In the future this might be animated. // In the future this might be animated.
mSelectorBarOffset = 0; mSelectorBarOffset = 0;
@ -149,6 +182,8 @@ void ComponentList::onCursorChanged(const CursorState& state)
void ComponentList::updateCameraOffset() void ComponentList::updateCameraOffset()
{ {
float oldCameraOffset = mCameraOffset;
// Move the camera to scroll. // Move the camera to scroll.
const float totalHeight = getTotalRowHeight(); const float totalHeight = getTotalRowHeight();
if (totalHeight > mSize.y) { if (totalHeight > mSize.y) {
@ -160,11 +195,17 @@ void ComponentList::updateCameraOffset()
unsigned int i = 0; unsigned int i = 0;
while (mCameraOffset < target && i < mEntries.size()) { while (mCameraOffset < target && i < mEntries.size()) {
mCameraOffset += getRowHeight(mEntries.at(i).data); mCameraOffset += getRowHeight(mEntries.at(i).data);
if (mCameraOffset > totalHeight - mSize.y) if (mCameraOffset > totalHeight - mSize.y) {
if (mSetupCompleted && mCameraOffset != oldCameraOffset)
mBottomCameraOffset = true;
break; break;
}
i++; i++;
} }
if (mCameraOffset < oldCameraOffset)
mBottomCameraOffset = false;
if (mCameraOffset < 0.0f) if (mCameraOffset < 0.0f)
mCameraOffset = 0.0f; mCameraOffset = 0.0f;
} }

View file

@ -61,6 +61,13 @@ class ComponentList : public IList<ComponentListRow, void*>
public: public:
ComponentList(Window* window); ComponentList(Window* window);
enum ScrollIndicator {
SCROLL_NONE, // Replace with AllowShortEnumsOnASingleLine: false (clang-format >=11.0).
SCROLL_UP,
SCROLL_UP_DOWN,
SCROLL_DOWN
};
void addRow(const ComponentListRow& row, bool setCursorHere = false); void addRow(const ComponentListRow& row, bool setCursorHere = false);
void textInput(const std::string& text) override; void textInput(const std::string& text) override;
@ -87,12 +94,19 @@ public:
{ {
return mCursorChangedCallback; return mCursorChangedCallback;
} }
void setScrollIndicatorChangedCallback(
const std::function<void(ScrollIndicator state)>& callback)
{
mScrollIndicatorChangedCallback = callback;
}
protected: protected:
void onCursorChanged(const CursorState& state) override; void onCursorChanged(const CursorState& state) override;
private: private:
bool mFocused; bool mFocused;
bool mSetupCompleted;
bool mBottomCameraOffset;
void updateCameraOffset(); void updateCameraOffset();
void updateElementPosition(const ComponentListRow& row); void updateElementPosition(const ComponentListRow& row);
@ -105,6 +119,9 @@ private:
float mCameraOffset; float mCameraOffset;
std::function<void(CursorState state)> mCursorChangedCallback; std::function<void(CursorState state)> mCursorChangedCallback;
std::function<void(ScrollIndicator state)> mScrollIndicatorChangedCallback;
ScrollIndicator mScrollIndicatorStatus;
}; };
#endif // ES_CORE_COMPONENTS_COMPONENT_LIST_H #endif // ES_CORE_COMPONENTS_COMPONENT_LIST_H

View file

@ -6,6 +6,9 @@
// Date and time edit component. // Date and time edit component.
// //
#define KEY_REPEAT_START_DELAY 600
#define KEY_REPEAT_SPEED 150 // Lower is faster.
#include "components/DateTimeEditComponent.h" #include "components/DateTimeEditComponent.h"
#include "Settings.h" #include "Settings.h"
@ -13,35 +16,43 @@
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
DateTimeEditComponent::DateTimeEditComponent(Window* window, bool alignRight, DisplayMode dispMode) DateTimeEditComponent::DateTimeEditComponent(Window* window, bool alignRight, DisplayMode dispMode)
: GuiComponent(window) : GuiComponent{window}
, mEditing(false) , mEditing{false}
, mEditIndex(0) , mEditIndex{0}
, mDisplayMode(dispMode) , mDisplayMode{dispMode}
, mRelativeUpdateAccumulator(0) , mKeyRepeatDir{0}
, mColor(0x777777FF) , mKeyRepeatTimer{0}
, mFont(Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT)) , mRelativeUpdateAccumulator{0}
, mAlignRight(alignRight) , mColor{0x777777FF}
, mUppercase(false) , mFont{Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT)}
, mAutoSize(true) , mAlignRight{alignRight}
, mUppercase{false}
, mAutoSize{true}
{ {
updateTextCache(); updateTextCache();
} }
void DateTimeEditComponent::setDisplayMode(DisplayMode mode) void DateTimeEditComponent::onSizeChanged()
{ {
mDisplayMode = mode; mAutoSize = false;
updateTextCache();
}
void DateTimeEditComponent::setValue(const std::string& val)
{
mTime = val;
mOriginalValue = val;
updateTextCache(); updateTextCache();
} }
bool DateTimeEditComponent::input(InputConfig* config, Input input) bool DateTimeEditComponent::input(InputConfig* config, Input input)
{ {
if (input.value == 0) if (config->isMappedTo("a", input) && input.value) {
return false;
if (config->isMappedTo("a", input)) {
if (mDisplayMode != DISP_RELATIVE_TO_NOW) // Don't allow editing for relative times. if (mDisplayMode != DISP_RELATIVE_TO_NOW) // Don't allow editing for relative times.
mEditing = !mEditing; mEditing = !mEditing;
mKeyRepeatDir = 0;
// Change the color of the text to reflect the changes. // Change the color of the text to reflect the changes.
if (mTime == mOriginalValue) if (mTime == mOriginalValue)
setColor(mColorOriginalValue); setColor(mColorOriginalValue);
@ -54,86 +65,77 @@ bool DateTimeEditComponent::input(InputConfig* config, Input input)
// Initialize to now if unset. // Initialize to now if unset.
if (mTime.getTime() == Utils::Time::DEFAULT_TIMEVALUE) { if (mTime.getTime() == Utils::Time::DEFAULT_TIMEVALUE) {
mTime = Utils::Time::now(); mTime = Utils::Time::stringToTime("19990101T0101");
updateTextCache(); updateTextCache();
} }
} }
updateHelpPrompts();
return true; return true;
} }
if (mEditing) { if (mEditing) {
if (config->isMappedLike("lefttrigger", input) || if ((config->isMappedLike("lefttrigger", input) ||
config->isMappedLike("righttrigger", input)) { config->isMappedLike("righttrigger", input))) {
mKeyRepeatDir = 0;
return true; return true;
} }
if (config->isMappedTo("b", input)) { if (config->isMappedTo("y", input) && input.value) {
mEditing = false; mEditing = false;
mTime = mTimeBeforeEdit; mTime = mTimeBeforeEdit;
mKeyRepeatDir = 0;
updateTextCache(); updateTextCache();
return false;
}
if (config->isMappedTo("b", input) && input.value) {
mEditing = false;
mTime = mTimeBeforeEdit;
mKeyRepeatDir = 0;
updateTextCache();
updateHelpPrompts();
return true; return true;
} }
int incDir = 0; if (config->isMappedLike("up", input) || config->isMappedLike("rightshoulder", input)) {
if (config->isMappedLike("up", input) || config->isMappedLike("rightshoulder", input)) if (input.value) {
incDir = 1; mKeyRepeatDir = 1;
else if (config->isMappedLike("down", input) || config->isMappedLike("leftshoulder", input)) mKeyRepeatTimer = -(KEY_REPEAT_START_DELAY - KEY_REPEAT_SPEED);
incDir = -1; changeDate();
return true;
if (incDir != 0) {
tm new_tm = mTime;
// ISO 8601 date format.
if (mEditIndex == 0) {
new_tm.tm_year += incDir;
if (new_tm.tm_year < 0)
new_tm.tm_year = 0;
} }
else if (mEditIndex == 1) { else {
new_tm.tm_mon += incDir; mKeyRepeatDir = 0;
if (new_tm.tm_mon > 11)
new_tm.tm_mon = 0;
else if (new_tm.tm_mon < 0)
new_tm.tm_mon = 11;
} }
else if (mEditIndex == 2) { }
const int days_in_month = else if (config->isMappedLike("down", input) ||
Utils::Time::daysInMonth(new_tm.tm_year + 1900, new_tm.tm_mon + 1); config->isMappedLike("leftshoulder", input)) {
new_tm.tm_mday += incDir; if (input.value) {
mKeyRepeatDir = -1;
if (new_tm.tm_mday > days_in_month) mKeyRepeatTimer = -(KEY_REPEAT_START_DELAY - KEY_REPEAT_SPEED);
new_tm.tm_mday = 1; changeDate();
else if (new_tm.tm_mday < 1) return true;
new_tm.tm_mday = days_in_month; }
else {
mKeyRepeatDir = 0;
} }
// Validate day.
const int days_in_month =
Utils::Time::daysInMonth(new_tm.tm_year + 1900, new_tm.tm_mon + 1);
if (new_tm.tm_mday > days_in_month)
new_tm.tm_mday = days_in_month;
mTime = new_tm;
updateTextCache();
return true;
} }
if (config->isMappedLike("right", input)) { if (mTime != 0 && config->isMappedLike("right", input) && input.value) {
mEditIndex++; mEditIndex++;
if (mEditIndex >= static_cast<int>(mCursorBoxes.size())) if (mEditIndex >= static_cast<int>(mCursorBoxes.size()))
mEditIndex--; mEditIndex--;
mKeyRepeatDir = 0;
return true; return true;
} }
if (config->isMappedLike("left", input)) { if (mTime != 0 && config->isMappedLike("left", input) && input.value) {
mEditIndex--; mEditIndex--;
if (mEditIndex < 0) if (mEditIndex < 0)
mEditIndex++; mEditIndex++;
mKeyRepeatDir = 0;
return true; return true;
} }
} }
@ -143,6 +145,14 @@ bool DateTimeEditComponent::input(InputConfig* config, Input input)
void DateTimeEditComponent::update(int deltaTime) void DateTimeEditComponent::update(int deltaTime)
{ {
if (mKeyRepeatDir != 0) {
mKeyRepeatTimer += deltaTime;
while (mKeyRepeatTimer >= KEY_REPEAT_SPEED) {
mKeyRepeatTimer -= KEY_REPEAT_SPEED;
changeDate();
}
}
if (mDisplayMode == DISP_RELATIVE_TO_NOW) { if (mDisplayMode == DISP_RELATIVE_TO_NOW) {
mRelativeUpdateAccumulator += deltaTime; mRelativeUpdateAccumulator += deltaTime;
if (mRelativeUpdateAccumulator > 1000) { if (mRelativeUpdateAccumulator > 1000) {
@ -162,12 +172,8 @@ void DateTimeEditComponent::render(const glm::mat4& parentTrans)
std::shared_ptr<Font> font = getFont(); std::shared_ptr<Font> font = getFont();
float referenceSize; float referenceSize;
if (mAlignRight) { if (mAlignRight)
if (mTime != 0) referenceSize = std::round(mParent->getSize().x * 0.1045f);
referenceSize = font->sizeText("ABCDEFG").x;
else
referenceSize = font->sizeText("ABCDEIJ").x;
}
// Vertically center. // Vertically center.
glm::vec3 off{0.0f, (mSize.y - mTextCache->metrics.size.y) / 2.0f, 0.0f}; glm::vec3 off{0.0f, (mSize.y - mTextCache->metrics.size.y) / 2.0f, 0.0f};
@ -191,7 +197,7 @@ void DateTimeEditComponent::render(const glm::mat4& parentTrans)
mTextCache->setColor((mColor & 0xFFFFFF00) | getOpacity()); mTextCache->setColor((mColor & 0xFFFFFF00) | getOpacity());
font->renderTextCache(mTextCache.get()); font->renderTextCache(mTextCache.get());
if (mEditing) { if (mEditing && mTime != 0) {
if (mEditIndex >= 0 && static_cast<unsigned int>(mEditIndex) < mCursorBoxes.size()) if (mEditIndex >= 0 && static_cast<unsigned int>(mEditIndex) < mCursorBoxes.size())
Renderer::drawRect(mCursorBoxes[mEditIndex][0], mCursorBoxes[mEditIndex][1], Renderer::drawRect(mCursorBoxes[mEditIndex][0], mCursorBoxes[mEditIndex][1],
mCursorBoxes[mEditIndex][2], mCursorBoxes[mEditIndex][3], mCursorBoxes[mEditIndex][2], mCursorBoxes[mEditIndex][3],
@ -200,13 +206,54 @@ void DateTimeEditComponent::render(const glm::mat4& parentTrans)
} }
} }
void DateTimeEditComponent::setValue(const std::string& val) void DateTimeEditComponent::setDisplayMode(DisplayMode mode)
{ {
mTime = val; mDisplayMode = mode;
mOriginalValue = val;
updateTextCache(); updateTextCache();
} }
void DateTimeEditComponent::setColor(unsigned int color)
{
mColor = color;
if (mTextCache)
mTextCache->setColor(color);
}
void DateTimeEditComponent::setFont(std::shared_ptr<Font> font)
{
mFont = font;
updateTextCache();
}
void DateTimeEditComponent::setUppercase(bool uppercase)
{
mUppercase = uppercase;
updateTextCache();
}
std::vector<HelpPrompt> DateTimeEditComponent::getHelpPrompts()
{
std::vector<HelpPrompt> prompts;
if (!mEditing) {
prompts.push_back(HelpPrompt("a", "edit date"));
}
else {
prompts.push_back(HelpPrompt("b", "cancel"));
prompts.push_back(HelpPrompt("a", "apply"));
prompts.push_back(HelpPrompt("left/right", "Y-M-D"));
prompts.push_back(HelpPrompt("up/down", "modify"));
}
return prompts;
}
std::shared_ptr<Font> DateTimeEditComponent::getFont() const
{
if (mFont)
return mFont;
return Font::get(FONT_SIZE_MEDIUM);
}
std::string DateTimeEditComponent::getDisplayString(DisplayMode mode) const std::string DateTimeEditComponent::getDisplayString(DisplayMode mode) const
{ {
// ISO 8601 date format. // ISO 8601 date format.
@ -256,12 +303,44 @@ std::string DateTimeEditComponent::getDisplayString(DisplayMode mode) const
return Utils::Time::timeToString(mTime, fmt); return Utils::Time::timeToString(mTime, fmt);
} }
std::shared_ptr<Font> DateTimeEditComponent::getFont() const void DateTimeEditComponent::changeDate()
{ {
if (mFont) tm new_tm = mTime;
return mFont;
return Font::get(FONT_SIZE_MEDIUM); // ISO 8601 date format.
if (mEditIndex == 0) {
new_tm.tm_year += mKeyRepeatDir;
if (new_tm.tm_year < 0)
new_tm.tm_year = 0;
}
else if (mEditIndex == 1) {
new_tm.tm_mon += mKeyRepeatDir;
if (new_tm.tm_mon > 11)
new_tm.tm_mon = 0;
else if (new_tm.tm_mon < 0)
new_tm.tm_mon = 11;
}
else if (mEditIndex == 2) {
const int days_in_month =
Utils::Time::daysInMonth(new_tm.tm_year + 1900, new_tm.tm_mon + 1);
new_tm.tm_mday += mKeyRepeatDir;
if (new_tm.tm_mday > days_in_month)
new_tm.tm_mday = 1;
else if (new_tm.tm_mday < 1)
new_tm.tm_mday = days_in_month;
}
// Validate day.
const int days_in_month = Utils::Time::daysInMonth(new_tm.tm_year + 1900, new_tm.tm_mon + 1);
if (new_tm.tm_mday > days_in_month)
new_tm.tm_mday = days_in_month;
mTime = new_tm;
updateTextCache();
} }
void DateTimeEditComponent::updateTextCache() void DateTimeEditComponent::updateTextCache()
@ -320,64 +399,3 @@ void DateTimeEditComponent::updateTextCache()
// The logic for handling time for 'mode = DISP_DATE_TIME' is missing, but // The logic for handling time for 'mode = DISP_DATE_TIME' is missing, but
// nobody will use it anyway so it's not worthwhile implementing. // nobody will use it anyway so it's not worthwhile implementing.
} }
void DateTimeEditComponent::setColor(unsigned int color)
{
mColor = color;
if (mTextCache)
mTextCache->setColor(color);
}
void DateTimeEditComponent::setFont(std::shared_ptr<Font> font)
{
mFont = font;
updateTextCache();
}
void DateTimeEditComponent::onSizeChanged()
{
mAutoSize = false;
updateTextCache();
}
void DateTimeEditComponent::setUppercase(bool uppercase)
{
mUppercase = uppercase;
updateTextCache();
}
void DateTimeEditComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
const std::string& view,
const std::string& element,
unsigned int properties)
{
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "datetime");
if (!elem)
return;
// We set mAutoSize BEFORE calling GuiComponent::applyTheme because it calls
// setSize(), which will call updateTextCache(), which will reset mSize if
// mAutoSize == true, ignoring the theme's value.
if (properties & ThemeFlags::SIZE)
mAutoSize = !elem->has("size");
GuiComponent::applyTheme(theme, view, element, properties);
using namespace ThemeFlags;
if (properties & COLOR && elem->has("color"))
setColor(elem->get<unsigned int>("color"));
if (properties & FORCE_UPPERCASE && elem->has("forceUppercase"))
setUppercase(elem->get<bool>("forceUppercase"));
setFont(Font::getFromTheme(elem, properties, mFont));
}
std::vector<HelpPrompt> DateTimeEditComponent::getHelpPrompts()
{
std::vector<HelpPrompt> prompts;
prompts.push_back(HelpPrompt("a", "edit date"));
return prompts;
}

View file

@ -28,14 +28,15 @@ public:
bool alignRight = false, bool alignRight = false,
DisplayMode dispMode = DISP_DATE); DisplayMode dispMode = DISP_DATE);
void onSizeChanged() override;
void setValue(const std::string& val) override; void setValue(const std::string& val) override;
std::string getValue() const override { return mTime; } std::string getValue() const override { return mTime; }
unsigned int getColor() const override { return mColor; }
bool input(InputConfig* config, Input input) override; bool input(InputConfig* config, Input input) override;
void update(int deltaTime) override; void update(int deltaTime) override;
unsigned int getColor() const override { return mColor; }
void render(const glm::mat4& parentTrans) override; void render(const glm::mat4& parentTrans) override;
void onSizeChanged() override;
// Set how the point in time will be displayed: // Set how the point in time will be displayed:
// * DISP_DATE - only display the date. // * DISP_DATE - only display the date.
@ -57,19 +58,14 @@ public:
// Force text to be uppercase when in DISP_RELATIVE_TO_NOW mode. // Force text to be uppercase when in DISP_RELATIVE_TO_NOW mode.
void setUppercase(bool uppercase); void setUppercase(bool uppercase);
virtual void applyTheme(const std::shared_ptr<ThemeData>& theme,
const std::string& view,
const std::string& element,
unsigned int properties) override;
virtual std::vector<HelpPrompt> getHelpPrompts() override; virtual std::vector<HelpPrompt> getHelpPrompts() override;
private: private:
std::shared_ptr<Font> getFont() const override; std::shared_ptr<Font> getFont() const override;
std::string getDisplayString(DisplayMode mode) const; std::string getDisplayString(DisplayMode mode) const;
DisplayMode getCurrentDisplayMode() const { return mDisplayMode; } DisplayMode getCurrentDisplayMode() const { return mDisplayMode; }
void changeDate();
void updateTextCache(); void updateTextCache();
Utils::Time::DateTime mTime; Utils::Time::DateTime mTime;
@ -79,6 +75,8 @@ private:
int mEditIndex; int mEditIndex;
DisplayMode mDisplayMode; DisplayMode mDisplayMode;
int mKeyRepeatDir;
int mKeyRepeatTimer;
int mRelativeUpdateAccumulator; int mRelativeUpdateAccumulator;
std::unique_ptr<TextCache> mTextCache; std::unique_ptr<TextCache> mTextCache;

View file

@ -14,14 +14,14 @@
#define BUTTON_GRID_VERT_PADDING 32.0f #define BUTTON_GRID_VERT_PADDING 32.0f
#define BUTTON_GRID_HORIZ_PADDING 10.0f #define BUTTON_GRID_HORIZ_PADDING 10.0f
#define TITLE_HEIGHT (mTitle->getFont()->getLetterHeight() + TITLE_VERT_PADDING) #define TITLE_HEIGHT (mTitle->getFont()->getLetterHeight() + Renderer::getScreenHeight() * 0.0637f)
MenuComponent::MenuComponent(Window* window, MenuComponent::MenuComponent(Window* window,
std::string title, std::string title,
const std::shared_ptr<Font>& titleFont) const std::shared_ptr<Font>& titleFont)
: GuiComponent(window) : GuiComponent(window)
, mBackground(window) , mBackground(window)
, mGrid(window, glm::ivec2{1, 3}) , mGrid(window, glm::ivec2{3, 4})
, mNeedsSaving(false) , mNeedsSaving(false)
{ {
addChild(&mBackground); addChild(&mBackground);
@ -34,11 +34,25 @@ MenuComponent::MenuComponent(Window* window,
mTitle->setHorizontalAlignment(ALIGN_CENTER); mTitle->setHorizontalAlignment(ALIGN_CENTER);
mTitle->setColor(0x555555FF); mTitle->setColor(0x555555FF);
setTitle(title, titleFont); setTitle(title, titleFont);
mGrid.setEntry(mTitle, glm::ivec2{}, false); mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true, glm::ivec2{3, 2});
// Set up list which will never change (externally, anyway). // Set up list which will never change (externally, anyway).
mList = std::make_shared<ComponentList>(mWindow); mList = std::make_shared<ComponentList>(mWindow);
mGrid.setEntry(mList, glm::ivec2{0, 1}, true); mGrid.setEntry(mList, glm::ivec2{0, 2}, true, true, glm::ivec2{3, 1});
// Set up scroll indicators.
mScrollUp = std::make_shared<ImageComponent>(mWindow);
mScrollDown = std::make_shared<ImageComponent>(mWindow);
mScrollIndicator = std::make_shared<ScrollIndicatorComponent>(mList, mScrollUp, mScrollDown);
mScrollUp->setResize(0.0f, mTitle->getFont()->getLetterHeight() / 2.0f);
mScrollUp->setOrigin(0.0f, -0.35f);
mScrollDown->setResize(0.0f, mTitle->getFont()->getLetterHeight() / 2.0f);
mScrollDown->setOrigin(0.0f, 0.35f);
mGrid.setEntry(mScrollUp, glm::ivec2{2, 0}, false, false, glm::ivec2{1, 1});
mGrid.setEntry(mScrollDown, glm::ivec2{2, 1}, false, false, glm::ivec2{1, 1});
updateGrid(); updateGrid();
updateSize(); updateSize();
@ -109,8 +123,12 @@ void MenuComponent::onSizeChanged()
mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f}); mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f});
// Update grid row/column sizes. // Update grid row/column sizes.
mGrid.setRowHeightPerc(0, TITLE_HEIGHT / mSize.y); mGrid.setRowHeightPerc(0, TITLE_HEIGHT / mSize.y / 2.0f);
mGrid.setRowHeightPerc(2, getButtonGridHeight() / mSize.y); mGrid.setRowHeightPerc(1, TITLE_HEIGHT / mSize.y / 2.0f);
mGrid.setRowHeightPerc(3, getButtonGridHeight() / mSize.y);
mGrid.setColWidthPerc(0, 0.07f);
mGrid.setColWidthPerc(2, 0.07f);
mGrid.setSize(mSize); mGrid.setSize(mSize);
} }
@ -134,7 +152,7 @@ void MenuComponent::updateGrid()
if (mButtons.size()) { if (mButtons.size()) {
mButtonGrid = makeButtonGrid(mWindow, mButtons); mButtonGrid = makeButtonGrid(mWindow, mButtons);
mGrid.setEntry(mButtonGrid, glm::ivec2{0, 2}, true, false); mGrid.setEntry(mButtonGrid, glm::ivec2{0, 3}, true, false, glm::ivec2{3, 1});
} }
} }

View file

@ -12,13 +12,12 @@
#include "components/ComponentGrid.h" #include "components/ComponentGrid.h"
#include "components/ComponentList.h" #include "components/ComponentList.h"
#include "components/NinePatchComponent.h" #include "components/NinePatchComponent.h"
#include "components/ScrollIndicatorComponent.h"
#include "components/TextComponent.h" #include "components/TextComponent.h"
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
#include <cmath> #include <cmath>
#define TITLE_VERT_PADDING (Renderer::getScreenHeight() * 0.0637f)
class ButtonComponent; class ButtonComponent;
class ImageComponent; class ImageComponent;
@ -87,6 +86,9 @@ private:
ComponentGrid mGrid; ComponentGrid mGrid;
std::shared_ptr<TextComponent> mTitle; std::shared_ptr<TextComponent> mTitle;
std::shared_ptr<ImageComponent> mScrollUp;
std::shared_ptr<ImageComponent> mScrollDown;
std::shared_ptr<ScrollIndicatorComponent> mScrollIndicator;
std::shared_ptr<ComponentList> mList; std::shared_ptr<ComponentList> mList;
std::shared_ptr<ComponentGrid> mButtonGrid; std::shared_ptr<ComponentGrid> mButtonGrid;
std::vector<std::shared_ptr<ButtonComponent>> mButtons; std::vector<std::shared_ptr<ButtonComponent>> mButtons;

View file

@ -10,6 +10,9 @@
#ifndef ES_CORE_COMPONENTS_OPTION_LIST_COMPONENT_H #ifndef ES_CORE_COMPONENTS_OPTION_LIST_COMPONENT_H
#define ES_CORE_COMPONENTS_OPTION_LIST_COMPONENT_H #define ES_CORE_COMPONENTS_OPTION_LIST_COMPONENT_H
#define OPTIONLIST_REPEAT_START_DELAY 650
#define OPTIONLIST_REPEAT_SPEED 250 // Lower is faster.
#define CHECKED_PATH ":/graphics/checkbox_checked.svg" #define CHECKED_PATH ":/graphics/checkbox_checked.svg"
#define UNCHECKED_PATH ":/graphics/checkbox_unchecked.svg" #define UNCHECKED_PATH ":/graphics/checkbox_unchecked.svg"
@ -30,17 +33,22 @@ public:
bool multiSelect = false, bool multiSelect = false,
bool multiExclusiveSelect = false, bool multiExclusiveSelect = false,
bool multiShowTotal = false) bool multiShowTotal = false)
: GuiComponent(window) : GuiComponent{window}
, mHelpStyle(helpstyle) , mHelpStyle{helpstyle}
, mMultiSelect(multiSelect) , mMultiSelect{multiSelect}
, mMultiExclusiveSelect(multiExclusiveSelect) , mMultiExclusiveSelect{multiExclusiveSelect}
, mMultiShowTotal(multiShowTotal) , mMultiShowTotal{multiShowTotal}
, mName(name) , mKeyRepeat{false}
, mText(window) , mKeyRepeatDir{0}
, mLeftArrow(window) , mKeyRepeatTimer{0}
, mRightArrow(window) , mKeyRepeatStartDelay{OPTIONLIST_REPEAT_START_DELAY}
, mKeyRepeatSpeed{OPTIONLIST_REPEAT_SPEED}
, mName{name}
, mText{window}
, mLeftArrow{window}
, mRightArrow{window}
{ {
auto font = Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT); auto font{Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT)};
mText.setFont(font); mText.setFont(font);
mText.setColor(0x777777FF); mText.setColor(0x777777FF);
mText.setHorizontalAlignment(ALIGN_CENTER); mText.setHorizontalAlignment(ALIGN_CENTER);
@ -88,16 +96,21 @@ public:
bool input(InputConfig* config, Input input) override bool input(InputConfig* config, Input input) override
{ {
if (input.value != 0) { if (config->isMappedTo("a", input) && input.value) {
if (config->isMappedTo("a", input)) { // Ignore input if the component has been disabled.
// Ignore input if the component has been disabled. if (!mEnabled)
if (!mEnabled)
return true;
open();
return true; return true;
} mKeyRepeatDir = 0;
if (!mMultiSelect) { open();
if (config->isMappedLike("left", input)) { return true;
}
if (!mMultiSelect) {
if (config->isMappedLike("left", input)) {
if (input.value) {
if (mKeyRepeat) {
mKeyRepeatDir = -1;
mKeyRepeatTimer = -(mKeyRepeatStartDelay - mKeyRepeatSpeed);
}
// Ignore input if the component has been disabled. // Ignore input if the component has been disabled.
if (!mEnabled) if (!mEnabled)
return true; return true;
@ -112,7 +125,16 @@ public:
onSelectedChanged(); onSelectedChanged();
return true; return true;
} }
else if (config->isMappedLike("right", input)) { else {
mKeyRepeatDir = 0;
}
}
else if (config->isMappedLike("right", input)) {
if (input.value) {
if (mKeyRepeat) {
mKeyRepeatDir = 1;
mKeyRepeatTimer = -(mKeyRepeatStartDelay - mKeyRepeatSpeed);
}
// Ignore input if the component has been disabled. // Ignore input if the component has been disabled.
if (!mEnabled) if (!mEnabled)
return true; return true;
@ -124,6 +146,12 @@ public:
onSelectedChanged(); onSelectedChanged();
return true; return true;
} }
else {
mKeyRepeatDir = 0;
}
}
else if (input.value) {
mKeyRepeatDir = 0;
} }
} }
return GuiComponent::input(config, input); return GuiComponent::input(config, input);
@ -148,20 +176,22 @@ public:
return selected.at(0); return selected.at(0);
} }
void add(const std::string& name, const T& obj, bool selected) void add(const std::string& name, const T& obj, bool selected, float maxNameLength = 0.0f)
{ {
OptionListData e; OptionListData e;
e.name = name; e.name = name;
e.object = obj; e.object = obj;
e.selected = selected; e.selected = selected;
e.maxNameLength = maxNameLength;
mEntries.push_back(e); mEntries.push_back(e);
onSelectedChanged(); onSelectedChanged();
} }
bool selectEntry(unsigned int entry) bool selectEntry(unsigned int entry)
{ {
if (entry > mEntries.size()) { if (mEntries.empty() || entry > mEntries.size()) {
return false; return false;
} }
else { else {
@ -218,6 +248,45 @@ public:
void setOverrideMultiText(const std::string& text) { mOverrideMultiText = text; } void setOverrideMultiText(const std::string& text) { mOverrideMultiText = text; }
void setKeyRepeat(bool state,
int delay = OPTIONLIST_REPEAT_START_DELAY,
int speed = OPTIONLIST_REPEAT_SPEED)
{
mKeyRepeat = state;
mKeyRepeatStartDelay = delay;
mKeyRepeatSpeed = speed;
}
void update(int deltaTime) override
{
if (mKeyRepeat && mKeyRepeatDir != 0) {
mKeyRepeatTimer += deltaTime;
while (mKeyRepeatTimer >= mKeyRepeatSpeed) {
if (mKeyRepeatDir == -1) {
// Move selection to previous.
unsigned int i = getSelectedId();
int next = static_cast<int>(i) - 1;
if (next < 0)
next += static_cast<int>(mEntries.size());
mEntries.at(i).selected = false;
mEntries.at(next).selected = true;
onSelectedChanged();
}
else {
// Move selection to next.
unsigned int i = getSelectedId();
int next = (i + 1) % mEntries.size();
mEntries.at(i).selected = false;
mEntries.at(next).selected = true;
onSelectedChanged();
}
mKeyRepeatTimer -= mKeyRepeatSpeed;
}
}
GuiComponent::update(deltaTime);
}
HelpStyle getHelpStyle() override { return mHelpStyle; } HelpStyle getHelpStyle() override { return mHelpStyle; }
private: private:
@ -225,6 +294,7 @@ private:
std::string name; std::string name;
T object; T object;
bool selected; bool selected;
float maxNameLength;
}; };
HelpStyle mHelpStyle; HelpStyle mHelpStyle;
@ -261,7 +331,37 @@ private:
// Display the selected entry and left/right option arrows. // Display the selected entry and left/right option arrows.
for (auto it = mEntries.cbegin(); it != mEntries.cend(); it++) { for (auto it = mEntries.cbegin(); it != mEntries.cend(); it++) {
if (it->selected) { if (it->selected) {
mText.setText(Utils::String::toUpper(it->name)); if (it->maxNameLength > 0.0f &&
Font::get(FONT_SIZE_MEDIUM)->sizeText(Utils::String::toUpper(it->name)).x >
it->maxNameLength) {
// A maximum length parameter has been passed and the "name" size surpasses
// this value, so abbreviate the string inside the arrows.
auto font = Font::get(FONT_SIZE_MEDIUM);
// Calculate with an extra dot to give some leeway.
float dotsSize = font->sizeText("....").x;
std::string abbreviatedString = font->getTextMaxWidth(
Utils::String::toUpper(it->name), it->maxNameLength);
float sizeDifference = font->sizeText(Utils::String::toUpper(it->name)).x -
font->sizeText(abbreviatedString).x;
if (sizeDifference > 0.0f) {
// It doesn't make sense to abbreviate if the number of pixels removed
// by the abbreviation is less or equal to the size of the three dots
// that would be appended to the string.
if (sizeDifference <= dotsSize) {
abbreviatedString = it->name;
}
else {
if (abbreviatedString.back() == ' ')
abbreviatedString.pop_back();
abbreviatedString += "...";
}
}
mText.setText(Utils::String::toUpper(abbreviatedString));
}
else {
mText.setText(Utils::String::toUpper(it->name));
}
mText.setSize(0.0f, mText.getSize().y); mText.setSize(0.0f, mText.getSize().y);
setSize(mText.getSize().x + mLeftArrow.getSize().x + mRightArrow.getSize().x + setSize(mText.getSize().x + mLeftArrow.getSize().x + mRightArrow.getSize().x +
24.0f * Renderer::getScreenWidthModifier(), 24.0f * Renderer::getScreenWidthModifier(),
@ -272,6 +372,7 @@ private:
} }
} }
} }
onSizeChanged();
} }
std::vector<HelpPrompt> getHelpPrompts() override std::vector<HelpPrompt> getHelpPrompts() override
@ -287,9 +388,16 @@ private:
bool mMultiSelect; bool mMultiSelect;
bool mMultiExclusiveSelect; bool mMultiExclusiveSelect;
bool mMultiShowTotal; bool mMultiShowTotal;
std::string mOverrideMultiText; bool mKeyRepeat;
int mKeyRepeatDir;
int mKeyRepeatTimer;
int mKeyRepeatStartDelay;
int mKeyRepeatSpeed;
std::string mOverrideMultiText;
std::string mName; std::string mName;
TextComponent mText; TextComponent mText;
ImageComponent mLeftArrow; ImageComponent mLeftArrow;
ImageComponent mRightArrow; ImageComponent mRightArrow;

View file

@ -0,0 +1,151 @@
// SPDX-License-Identifier: MIT
//
// EmulationStation Desktop Edition
// ScrollIndicatorComponent.h
//
// Visually indicates whether a menu can be scrolled (up, up/down or down).
//
#ifndef ES_CORE_COMPONENTS_SCROLL_INDICATOR_COMPONENT_H
#define ES_CORE_COMPONENTS_SCROLL_INDICATOR_COMPONENT_H
#define FADE_IN_TIME 90.0f
#include "animations/LambdaAnimation.h"
#include "components/ComponentList.h"
class ScrollIndicatorComponent
{
public:
ScrollIndicatorComponent(std::shared_ptr<ComponentList> componentList,
std::shared_ptr<ImageComponent> scrollUp,
std::shared_ptr<ImageComponent> scrollDown)
: mPreviousScrollState(ComponentList::SCROLL_NONE)
{
assert(componentList != nullptr && scrollUp != nullptr && scrollDown != nullptr);
scrollUp->setImage(":/graphics/scroll_up.svg");
scrollDown->setImage(":/graphics/scroll_down.svg");
scrollUp->setOpacity(0);
scrollDown->setOpacity(0);
if (!Settings::getInstance()->getBool("ScrollIndicators")) {
// If the scroll indicators setting is disabled, then show a permanent down arrow
// symbol when the component list contains more entries than can fit on screen.
componentList.get()->setScrollIndicatorChangedCallback(
[scrollUp, scrollDown](ComponentList::ScrollIndicator state) {
if (state == ComponentList::SCROLL_UP ||
state == ComponentList::SCROLL_UP_DOWN ||
state == ComponentList::SCROLL_DOWN) {
scrollDown->setOpacity(255);
}
});
}
else {
// If the scroll indicator setting is enabled, then also show the up and up/down
// combination and switch between these as the list is scrolled.
componentList.get()->setScrollIndicatorChangedCallback(
[this, scrollUp, scrollDown](ComponentList::ScrollIndicator state) {
float fadeInTime{FADE_IN_TIME};
bool upFadeIn = false;
bool upFadeOut = false;
bool downFadeIn = false;
bool downFadeOut = false;
scrollUp->finishAnimation(0);
scrollDown->finishAnimation(0);
if (state == ComponentList::SCROLL_UP &&
mPreviousScrollState == ComponentList::SCROLL_NONE) {
scrollUp->setOpacity(255);
}
else if (state == ComponentList::SCROLL_UP &&
mPreviousScrollState == ComponentList::SCROLL_UP_DOWN) {
downFadeOut = true;
}
else if (state == ComponentList::SCROLL_UP &&
mPreviousScrollState == ComponentList::SCROLL_DOWN) {
upFadeIn = true;
fadeInTime *= 1.5f;
scrollDown->setOpacity(0);
}
else if (state == ComponentList::SCROLL_UP_DOWN &&
mPreviousScrollState == ComponentList::SCROLL_NONE) {
scrollUp->setOpacity(255);
scrollDown->setOpacity(255);
}
else if (state == ComponentList::SCROLL_UP_DOWN &&
mPreviousScrollState == ComponentList::SCROLL_DOWN) {
upFadeIn = true;
}
else if (state == ComponentList::SCROLL_UP_DOWN &&
mPreviousScrollState == ComponentList::SCROLL_UP) {
downFadeIn = true;
}
else if (state == ComponentList::SCROLL_DOWN &&
mPreviousScrollState == ComponentList::SCROLL_NONE) {
scrollDown->setOpacity(255);
}
else if (state == ComponentList::SCROLL_DOWN &&
mPreviousScrollState == ComponentList::SCROLL_UP_DOWN) {
upFadeOut = true;
}
else if (state == ComponentList::SCROLL_DOWN &&
mPreviousScrollState == ComponentList::SCROLL_UP) {
downFadeIn = true;
fadeInTime *= 1.5f;
scrollUp->setOpacity(0);
}
if (upFadeIn) {
auto upFadeInFunc = [scrollUp](float t) {
scrollUp->setOpacity(
static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
};
scrollUp->setAnimation(
new LambdaAnimation(upFadeInFunc, static_cast<int>(fadeInTime)), 0,
nullptr, false);
}
if (upFadeOut) {
auto upFadeOutFunc = [scrollUp](float t) {
scrollUp->setOpacity(
static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
};
scrollUp->setAnimation(
new LambdaAnimation(upFadeOutFunc, static_cast<int>(fadeInTime)), 0,
nullptr, true);
}
if (downFadeIn) {
auto downFadeInFunc = [scrollDown](float t) {
scrollDown->setOpacity(
static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
};
scrollDown->setAnimation(
new LambdaAnimation(downFadeInFunc, static_cast<int>(fadeInTime)), 0,
nullptr, false);
}
if (downFadeOut) {
auto downFadeOutFunc = [scrollDown](float t) {
scrollDown->setOpacity(
static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
};
scrollDown->setAnimation(
new LambdaAnimation(downFadeOutFunc, static_cast<int>(fadeInTime)), 0,
nullptr, true);
}
mPreviousScrollState = state;
});
}
}
private:
ComponentList::ScrollIndicator mPreviousScrollState;
};
#endif // ES_CORE_COMPONENTS_SCROLL_INDICATOR_COMPONENT_H

View file

@ -3,8 +3,8 @@
// EmulationStation Desktop Edition // EmulationStation Desktop Edition
// ScrollableContainer.cpp // ScrollableContainer.cpp
// //
// Area containing scrollable information, for example the game description // Component containing scrollable information, used for the game
// text container in the detailed, video and grid views. // description text in the scraper and gamelist views.
// //
#include "components/ScrollableContainer.h" #include "components/ScrollableContainer.h"
@ -15,26 +15,18 @@
#include "resources/Font.h" #include "resources/Font.h"
ScrollableContainer::ScrollableContainer(Window* window) ScrollableContainer::ScrollableContainer(Window* window)
: GuiComponent(window) : GuiComponent{window}
, mScrollPos({}) , mScrollPos{0.0f, 0.0f}
, mScrollDir({}) , mScrollDir{0.0f, 0.0f}
, mFontSize(0.0f) , mAutoScrollDelay{0}
, mAutoScrollDelay(0) , mAutoScrollSpeed{0}
, mAutoScrollSpeed(0) , mAutoScrollAccumulator{0}
, mAutoScrollAccumulator(0) , mAutoScrollResetAccumulator{0}
, mAutoScrollResetAccumulator(0) , mAdjustedAutoScrollSpeed{0}
, mUpdatedSize{false}
{ {
// Set the modifier to get equivalent scrolling speed regardless of screen resolution. // Set the modifier to get equivalent scrolling speed regardless of screen resolution.
mResolutionModifier = Renderer::getScreenHeightModifier(); mResolutionModifier = Renderer::getScreenHeightModifier();
mSmallFontSize = static_cast<float>(Font::get(FONT_SIZE_SMALL)->getSize());
// For narrower aspect ratios than 16:9 there is a need to set an additional compensation
// to get somehow consistent scrolling speeds.
float aspectCompensation = static_cast<float>(Renderer::getScreenHeight()) /
static_cast<float>(Renderer::getScreenWidth()) -
0.5625f;
if (aspectCompensation > 0)
mResolutionModifier += aspectCompensation * 4.0f;
mAutoScrollResetDelayConstant = AUTO_SCROLL_RESET_DELAY; mAutoScrollResetDelayConstant = AUTO_SCROLL_RESET_DELAY;
mAutoScrollDelayConstant = AUTO_SCROLL_DELAY; mAutoScrollDelayConstant = AUTO_SCROLL_DELAY;
@ -46,9 +38,6 @@ void ScrollableContainer::setAutoScroll(bool autoScroll)
if (autoScroll) { if (autoScroll) {
mScrollDir = glm::vec2{0.0f, 1.0f}; mScrollDir = glm::vec2{0.0f, 1.0f};
mAutoScrollDelay = static_cast<int>(mAutoScrollDelayConstant); mAutoScrollDelay = static_cast<int>(mAutoScrollDelayConstant);
mAutoScrollSpeed = mAutoScrollSpeedConstant;
mAutoScrollSpeed =
static_cast<int>(static_cast<float>(mAutoScrollSpeedConstant) / mResolutionModifier);
reset(); reset();
} }
else { else {
@ -61,11 +50,11 @@ void ScrollableContainer::setAutoScroll(bool autoScroll)
void ScrollableContainer::setScrollParameters(float autoScrollDelayConstant, void ScrollableContainer::setScrollParameters(float autoScrollDelayConstant,
float autoScrollResetDelayConstant, float autoScrollResetDelayConstant,
int autoScrollSpeedConstant) float autoScrollSpeedConstant)
{ {
mAutoScrollResetDelayConstant = autoScrollResetDelayConstant; mAutoScrollResetDelayConstant = glm::clamp(autoScrollResetDelayConstant, 1000.0f, 10000.0f);
mAutoScrollDelayConstant = autoScrollDelayConstant; mAutoScrollDelayConstant = glm::clamp(autoScrollDelayConstant, 1000.0f, 10000.0f);
mAutoScrollSpeedConstant = autoScrollSpeedConstant; mAutoScrollSpeedConstant = AUTO_SCROLL_SPEED / glm::clamp(autoScrollSpeedConstant, 0.1f, 10.0f);
} }
void ScrollableContainer::reset() void ScrollableContainer::reset()
@ -86,27 +75,48 @@ void ScrollableContainer::update(int deltaTime)
return; return;
} }
const glm::vec2 contentSize{getContentSize()}; const glm::vec2 contentSize{mChildren.front()->getSize()};
int adjustedAutoScrollSpeed = mAutoScrollSpeed; float rowModifier{1.0f};
// Adjust the scrolling speed based on the width of the container. float lineSpacing{mChildren.front()->getLineSpacing()};
float widthModifier = contentSize.x / static_cast<float>(Renderer::getScreenWidth()); float combinedHeight{mChildren.front()->getFont()->getHeight(lineSpacing)};
adjustedAutoScrollSpeed = static_cast<int>(adjustedAutoScrollSpeed * widthModifier);
// Also adjust the scrolling speed based on the size of the font. // Resize container to font height boundary to avoid rendering a fraction of the last line.
float fontSizeModifier = mSmallFontSize / mFontSize; if (!mUpdatedSize && contentSize.y > mSize.y) {
adjustedAutoScrollSpeed = float numLines{mSize.y / combinedHeight};
static_cast<int>(adjustedAutoScrollSpeed * fontSizeModifier * fontSizeModifier); mSize.y = floorf(numLines) * combinedHeight;
mUpdatedSize = true;
}
else if (mUpdatedSize) {
// If there are less than 8 lines of text, accelerate the scrolling further.
float lines{mSize.y / combinedHeight};
if (lines < 8.0f)
rowModifier = lines / 8.0f;
}
if (adjustedAutoScrollSpeed < 0) if (!mAdjustedAutoScrollSpeed) {
adjustedAutoScrollSpeed = 1; float fontSize{static_cast<float>(mChildren.front()->getFont()->getSize())};
float width{contentSize.x / (fontSize * 1.3f)};
if (adjustedAutoScrollSpeed != 0) { // Keep speed adjustments within reason.
float speedModifier{glm::clamp(width, 10.0f, 40.0f)};
speedModifier *= mAutoScrollSpeedConstant;
speedModifier /= mResolutionModifier;
mAdjustedAutoScrollSpeed = static_cast<int>(speedModifier);
}
if (mAdjustedAutoScrollSpeed < 0)
mAdjustedAutoScrollSpeed = 1;
if (mAdjustedAutoScrollSpeed != 0) {
mAutoScrollAccumulator += deltaTime; mAutoScrollAccumulator += deltaTime;
while (mAutoScrollAccumulator >= adjustedAutoScrollSpeed) { while (mAutoScrollAccumulator >=
static_cast<int>(rowModifier * static_cast<float>(mAdjustedAutoScrollSpeed))) {
if (contentSize.y > mSize.y) if (contentSize.y > mSize.y)
mScrollPos += mScrollDir; mScrollPos += mScrollDir;
mAutoScrollAccumulator -= adjustedAutoScrollSpeed; mAutoScrollAccumulator -=
static_cast<int>(rowModifier * static_cast<float>(mAdjustedAutoScrollSpeed));
} }
} }
@ -171,20 +181,3 @@ void ScrollableContainer::render(const glm::mat4& parentTrans)
GuiComponent::renderChildren(trans); GuiComponent::renderChildren(trans);
Renderer::popClipRect(); Renderer::popClipRect();
} }
glm::vec2 ScrollableContainer::getContentSize()
{
glm::vec2 max{};
for (unsigned int i = 0; i < mChildren.size(); i++) {
glm::vec2 pos{mChildren.at(i)->getPosition().x, mChildren.at(i)->getPosition().y};
glm::vec2 bottomRight{mChildren.at(i)->getSize() + pos};
if (bottomRight.x > max.x)
max.x = bottomRight.x;
if (bottomRight.y > max.y)
max.y = bottomRight.y;
if (!mFontSize)
mFontSize = static_cast<float>(mChildren.at(i)->getFont()->getSize());
}
return max;
}

View file

@ -3,8 +3,8 @@
// EmulationStation Desktop Edition // EmulationStation Desktop Edition
// ScrollableContainer.h // ScrollableContainer.h
// //
// Area containing scrollable information, for example the game description // Component containing scrollable information, used for the game
// text container in the detailed, video and grid views. // description text in the scraper and gamelist views.
// //
#ifndef ES_CORE_COMPONENTS_SCROLLABLE_CONTAINER_H #ifndef ES_CORE_COMPONENTS_SCROLLABLE_CONTAINER_H
@ -15,7 +15,7 @@
// Time in ms before resetting to the top after we reach the bottom. // Time in ms before resetting to the top after we reach the bottom.
#define AUTO_SCROLL_RESET_DELAY 7000.0f #define AUTO_SCROLL_RESET_DELAY 7000.0f
// Relative scrolling speed (lower is faster). // Relative scrolling speed (lower is faster).
#define AUTO_SCROLL_SPEED 90 #define AUTO_SCROLL_SPEED 4.0f
#include "GuiComponent.h" #include "GuiComponent.h"
@ -30,31 +30,29 @@ public:
void setAutoScroll(bool autoScroll); void setAutoScroll(bool autoScroll);
void setScrollParameters(float autoScrollDelayConstant, void setScrollParameters(float autoScrollDelayConstant,
float autoScrollResetDelayConstant, float autoScrollResetDelayConstant,
int autoScrollSpeedConstant) override; float autoScrollSpeedConstant) override;
void reset(); void reset();
void update(int deltaTime) override; void update(int deltaTime) override;
void render(const glm::mat4& parentTrans) override; void render(const glm::mat4& parentTrans) override;
private: private:
glm::vec2 getContentSize();
glm::vec2 mScrollPos; glm::vec2 mScrollPos;
glm::vec2 mScrollDir; glm::vec2 mScrollDir;
float mFontSize;
float mSmallFontSize;
float mAutoScrollResetDelayConstant; float mAutoScrollResetDelayConstant;
float mAutoScrollDelayConstant; float mAutoScrollDelayConstant;
int mAutoScrollSpeedConstant; float mAutoScrollSpeedConstant;
float mResolutionModifier; float mResolutionModifier;
int mAutoScrollDelay; int mAutoScrollDelay;
int mAutoScrollSpeed; int mAutoScrollSpeed;
int mAutoScrollAccumulator; int mAutoScrollAccumulator;
int mAutoScrollResetAccumulator; int mAutoScrollResetAccumulator;
int mAdjustedAutoScrollSpeed;
bool mAtEnd; bool mAtEnd;
bool mUpdatedSize;
}; };
#endif // ES_CORE_COMPONENTS_SCROLLABLE_CONTAINER_H #endif // ES_CORE_COMPONENTS_SCROLLABLE_CONTAINER_H

View file

@ -53,7 +53,7 @@ TextComponent::TextComponent(Window* window,
setFont(font); setFont(font);
setColor(color); setColor(color);
setBackgroundColor(bgcolor); setBackgroundColor(bgcolor);
setText(text); setText(text, false);
setPosition(pos); setPosition(pos);
setSize(size); setSize(size);
} }
@ -66,6 +66,9 @@ void TextComponent::onSizeChanged()
void TextComponent::setFont(const std::shared_ptr<Font>& font) void TextComponent::setFont(const std::shared_ptr<Font>& font)
{ {
if (mFont == font)
return;
mFont = font; mFont = font;
onTextChanged(); onTextChanged();
} }
@ -103,10 +106,15 @@ void TextComponent::setOpacity(unsigned char opacity)
GuiComponent::setOpacity(opacity); GuiComponent::setOpacity(opacity);
} }
void TextComponent::setText(const std::string& text) void TextComponent::setText(const std::string& text, bool update)
{ {
if (mText == text)
return;
mText = text; mText = text;
onTextChanged();
if (update)
onTextChanged();
} }
void TextComponent::setUppercase(bool uppercase) void TextComponent::setUppercase(bool uppercase)
@ -262,8 +270,6 @@ void TextComponent::setHorizontalAlignment(Alignment align)
onTextChanged(); onTextChanged();
} }
void TextComponent::setVerticalAlignment(Alignment align) { mVerticalAlignment = align; }
void TextComponent::setLineSpacing(float spacing) void TextComponent::setLineSpacing(float spacing)
{ {
mLineSpacing = spacing; mLineSpacing = spacing;

View file

@ -38,12 +38,13 @@ public:
void setFont(const std::shared_ptr<Font>& font); void setFont(const std::shared_ptr<Font>& font);
void setUppercase(bool uppercase); void setUppercase(bool uppercase);
void onSizeChanged() override; void onSizeChanged() override;
void setText(const std::string& text); void setText(const std::string& text, bool update = true);
void setHiddenText(const std::string& text) { mHiddenText = text; } void setHiddenText(const std::string& text) { mHiddenText = text; }
void setColor(unsigned int color) override; void setColor(unsigned int color) override;
void setHorizontalAlignment(Alignment align); void setHorizontalAlignment(Alignment align);
void setVerticalAlignment(Alignment align); void setVerticalAlignment(Alignment align) { mVerticalAlignment = align; }
void setLineSpacing(float spacing); void setLineSpacing(float spacing);
float getLineSpacing() override { return mLineSpacing; }
void setNoTopMargin(bool margin); void setNoTopMargin(bool margin);
void setBackgroundColor(unsigned int color); void setBackgroundColor(unsigned int color);
void setRenderBackground(bool render) { mRenderBackground = render; } void setRenderBackground(bool render) { mRenderBackground = render; }

View file

@ -170,11 +170,19 @@ template <typename T> void TextListComponent<T>::render(const glm::mat4& parentT
int startEntry{0}; int startEntry{0};
float y{0.0f}; float y{0.0f};
const float entrySize{std::max(font->getHeight(1.0), static_cast<float>(font->getSize())) * const float entrySize{std::max(floorf(font->getHeight(1.0f)),
mLineSpacing}; floorf(static_cast<float>(font->getSize())) * mLineSpacing)};
const float lineSpacingHeight{floorf(font->getHeight(mLineSpacing) - font->getHeight(1.0f))};
// This extra vertical margin is technically incorrect, but it adds a little extra leeway
// to avoid removing the last row on some older theme sets. There was a sizing bug in the
// RetroPie fork of EmulationStation and some theme authors set sizes that are just slightly
// too small for the last row to show up when the sizing calculation is done correctly.
const float extraMargin{(Renderer::getScreenHeightModifier() >= 1.0f ? 3.0f : 0.0f)};
// Number of entries that can fit on the screen simultaneously. // Number of entries that can fit on the screen simultaneously.
int screenCount = static_cast<int>(mSize.y / entrySize + 0.5f); int screenCount{
static_cast<int>(floorf((mSize.y + lineSpacingHeight / 2.0f + extraMargin) / entrySize))};
if (size() >= screenCount) { if (size() >= screenCount) {
startEntry = mCursor - screenCount / 2; startEntry = mCursor - screenCount / 2;

View file

@ -15,14 +15,15 @@
class ComponentGrid; class ComponentGrid;
class NinePatchComponent; class NinePatchComponent;
class GuiInfoPopup : public GuiComponent, public Window::InfoPopup class GuiInfoPopup : public GuiComponent
{ {
public: public:
GuiInfoPopup(Window* window, std::string message, int duration); GuiInfoPopup(Window* window, std::string message, int duration);
~GuiInfoPopup(); ~GuiInfoPopup();
void render(const glm::mat4& parentTrans) override; void render(const glm::mat4& parentTrans);
void stop() override { mRunning = false; } void stop() { mRunning = false; }
bool isRunning() { return mRunning; }
private: private:
bool updateState(); bool updateState();

View file

@ -133,9 +133,6 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
mText = std::make_shared<TextEditComponent>(mWindow); mText = std::make_shared<TextEditComponent>(mWindow);
mText->setValue(initValue); mText->setValue(initValue);
if (!multiLine)
mText->setCursor(initValue.size());
// Header. // Header.
mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true); mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true);
@ -289,6 +286,9 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
setPosition((static_cast<float>(Renderer::getScreenWidth()) - mSize.x) / 2.0f, setPosition((static_cast<float>(Renderer::getScreenWidth()) - mSize.x) / 2.0f,
(static_cast<float>(Renderer::getScreenHeight()) - mSize.y) / 2.0f); (static_cast<float>(Renderer::getScreenHeight()) - mSize.y) / 2.0f);
} }
if (!multiLine)
mText->setCursor(initValue.size());
} }
void GuiTextEditKeyboardPopup::onSizeChanged() void GuiTextEditKeyboardPopup::onSizeChanged()

View file

@ -102,7 +102,7 @@ GuiTextEditPopup::GuiTextEditPopup(Window* window,
if (multiLine) if (multiLine)
textHeight *= 6.0f; textHeight *= 6.0f;
mText->setSize(0, textHeight); mText->setSize(0.0f, textHeight);
// Adapt width to the geometry of the display. The 1.778 aspect ratio is the 16:9 reference. // Adapt width to the geometry of the display. The 1.778 aspect ratio is the 16:9 reference.
float aspectValue = 1.778f / Renderer::getScreenAspectRatio(); float aspectValue = 1.778f / Renderer::getScreenAspectRatio();

View file

@ -79,7 +79,14 @@ Font::Font(int size, const std::string& path)
: mSize(size) : mSize(size)
, mPath(path) , mPath(path)
{ {
assert(mSize > 0); if (mSize < 9) {
mSize = 9;
LOG(LogWarning) << "Requested font size too small, changing to minimum supported size";
}
else if (mSize > Renderer::getScreenHeight()) {
mSize = Renderer::getScreenHeight();
LOG(LogWarning) << "Requested font size too large, changing to maximum supported size";
}
mMaxGlyphHeight = 0; mMaxGlyphHeight = 0;
@ -274,8 +281,6 @@ FT_Face Font::getFaceForChar(unsigned int id)
return mFaceCache.cbegin()->second->face; return mFaceCache.cbegin()->second->face;
} }
void Font::clearFaceCache() { mFaceCache.clear(); }
Font::Glyph* Font::getGlyph(unsigned int id) Font::Glyph* Font::getGlyph(unsigned int id)
{ {
// Is it already loaded? // Is it already loaded?
@ -339,7 +344,6 @@ Font::Glyph* Font::getGlyph(unsigned int id)
return &glyph; return &glyph;
} }
// Completely recreate the texture data for all textures based on mGlyphs information.
void Font::rebuildTextures() void Font::rebuildTextures()
{ {
// Recreate OpenGL textures. // Recreate OpenGL textures.
@ -441,7 +445,6 @@ float Font::getLetterHeight()
return glyph->texSize.y * glyph->texture->textureSize.y; return glyph->texSize.y * glyph->texture->textureSize.y;
} }
// Breaks up a normal string with newlines to make it fit xLen.
std::string Font::wrapText(std::string text, float xLen) std::string Font::wrapText(std::string text, float xLen)
{ {
std::string out; std::string out;
@ -666,8 +669,6 @@ TextCache* Font::buildTextCache(const std::string& text,
x += glyph->advance.x; x += glyph->advance.x;
} }
// TextCache::CacheMetrics metrics = { sizeText(text, lineSpacing) };
TextCache* cache = new TextCache(); TextCache* cache = new TextCache();
cache->vertexLists.resize(vertMap.size()); cache->vertexLists.resize(vertMap.size());
cache->metrics = {sizeText(text, lineSpacing)}; cache->metrics = {sizeText(text, lineSpacing)};

View file

@ -141,6 +141,7 @@ private:
virtual ~FontFace(); virtual ~FontFace();
}; };
// Completely recreate the texture data for all textures based on mGlyphs information.
void rebuildTextures(); void rebuildTextures();
void unloadTextures(); void unloadTextures();
@ -152,7 +153,7 @@ private:
std::map<unsigned int, std::unique_ptr<FontFace>> mFaceCache; std::map<unsigned int, std::unique_ptr<FontFace>> mFaceCache;
FT_Face getFaceForChar(unsigned int id); FT_Face getFaceForChar(unsigned int id);
void clearFaceCache(); void clearFaceCache() { mFaceCache.clear(); }
struct Glyph { struct Glyph {
FontTexture* texture; FontTexture* texture;
@ -170,7 +171,7 @@ private:
int mMaxGlyphHeight; int mMaxGlyphHeight;
const int mSize; int mSize;
const std::string mPath; const std::string mPath;
float getNewlineStartOffset(const std::string& text, float getNewlineStartOffset(const std::string& text,

View file

@ -16,8 +16,9 @@
#include "renderers/Renderer.h" #include "renderers/Renderer.h"
#include "resources/ResourceManager.h" #include "resources/ResourceManager.h"
#include <nanosvg.h> #include "nanosvg.h"
#include <nanosvgrast.h> #include "nanosvgrast.h"
#include <string.h> #include <string.h>
#define DPI 96 #define DPI 96

View file

@ -12,7 +12,8 @@
// Disable the CImg display capabilities. // Disable the CImg display capabilities.
#define cimg_display 0 #define cimg_display 0
#include <CImg.h> #include "CImg.h"
#include <vector> #include <vector>
namespace Utils namespace Utils

View file

@ -8,7 +8,7 @@
// remove files etc. // remove files etc.
// //
#if !defined(__APPLE__) #if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__)
#define _FILE_OFFSET_BITS 64 #define _FILE_OFFSET_BITS 64
#endif #endif

View file

@ -10,9 +10,10 @@
#ifndef ES_CORE_UTILS_MATH_UTIL_H #ifndef ES_CORE_UTILS_MATH_UTIL_H
#define ES_CORE_UTILS_MATH_UTIL_H #define ES_CORE_UTILS_MATH_UTIL_H
#include <glm/ext/matrix_clip_space.hpp> #include "glm/ext/matrix_clip_space.hpp"
#include <glm/ext/matrix_transform.hpp> #include "glm/ext/matrix_transform.hpp"
#include <glm/trigonometric.hpp> #include "glm/trigonometric.hpp"
#include <string> #include <string>
namespace Utils namespace Utils

22
external/rapidjson/.gitattributes vendored Normal file
View file

@ -0,0 +1,22 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.cpp text
*.h text
*.txt text
*.md text
*.cmake text
*.svg text
*.dot text
*.yml text
*.in text
*.sh text
*.autopkg text
Dockerfile text
# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
*.json binary

29
external/rapidjson/.gitignore vendored Normal file
View file

@ -0,0 +1,29 @@
/bin/*
!/bin/data
!/bin/encodings
!/bin/jsonchecker
!/bin/types
!/bin/unittestschema
/build
/doc/html
/doc/doxygen_*.db
*.a
# Temporary files created during CMake build
CMakeCache.txt
CMakeFiles
cmake_install.cmake
CTestTestfile.cmake
Makefile
RapidJSON*.cmake
RapidJSON.pc
Testing
/googletest
install_manifest.txt
Doxyfile
Doxyfile.zh-cn
DartConfiguration.tcl
*.nupkg
# Files created by OS
*.DS_Store

3
external/rapidjson/.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "thirdparty/gtest"]
path = thirdparty/gtest
url = https://github.com/google/googletest.git

166
external/rapidjson/.travis.yml vendored Normal file
View file

@ -0,0 +1,166 @@
sudo: required
dist: xenial
language: cpp
cache:
- ccache
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- cmake
- valgrind
- clang-8
env:
global:
- USE_CCACHE=1
- CCACHE_SLOPPINESS=pch_defines,time_macros
- CCACHE_COMPRESS=1
- CCACHE_MAXSIZE=100M
- ARCH_FLAGS_x86='-m32' # #266: don't use SSE on 32-bit
- ARCH_FLAGS_x86_64='-msse4.2' # use SSE4.2 on 64-bit
- ARCH_FLAGS_aarch64='-march=armv8-a'
- GITHUB_REPO='Tencent/rapidjson'
- secure: "HrsaCb+N66EG1HR+LWH1u51SjaJyRwJEDzqJGYMB7LJ/bfqb9mWKF1fLvZGk46W5t7TVaXRDD5KHFx9DPWvKn4gRUVkwTHEy262ah5ORh8M6n/6VVVajeV/AYt2C0sswdkDBDO4Xq+xy5gdw3G8s1A4Inbm73pUh+6vx+7ltBbk="
matrix:
include:
# gcc
- env: CONF=release ARCH=x86 CXX11=ON CXX17=OFF MEMBERSMAP=OFF
compiler: gcc
arch: amd64
- env: CONF=release ARCH=x86_64 CXX11=ON CXX17=OFF MEMBERSMAP=OFF
compiler: gcc
arch: amd64
- env: CONF=release ARCH=x86_64 CXX11=ON CXX17=OFF MEMBERSMAP=ON
compiler: gcc
arch: amd64
- env: CONF=debug ARCH=x86 CXX11=OFF CXX17=OFF MEMBERSMAP=OFF
compiler: gcc
arch: amd64
- env: CONF=debug ARCH=x86_64 CXX11=OFF CXX17=OFF MEMBERSMAP=OFF
compiler: gcc
arch: amd64
- env: CONF=debug ARCH=x86 CXX11=OFF CXX17=ON MEMBERSMAP=ON CXX_FLAGS='-D_GLIBCXX_DEBUG'
compiler: gcc
arch: amd64
- env: CONF=debug ARCH=x86_64 CXX11=OFF CXX17=ON MEMBERSMAP=ON CXX_FLAGS='-D_GLIBCXX_DEBUG'
compiler: gcc
arch: amd64
- env: CONF=release ARCH=aarch64 CXX11=ON CXX17=OFF MEMBERSMAP=OFF
compiler: gcc
arch: arm64
- env: CONF=release ARCH=aarch64 CXX11=OFF CXX17=OFF MEMBERSMAP=OFF
compiler: gcc
arch: arm64
- env: CONF=release ARCH=aarch64 CXX11=OFF CXX17=ON MEMBERSMAP=ON
compiler: gcc
arch: arm64
# clang
- env: CONF=release ARCH=x86 CXX11=ON CXX17=OFF MEMBERSMAP=ON CCACHE_CPP2=yes
compiler: clang
arch: amd64
- env: CONF=release ARCH=x86_64 CXX11=ON CXX17=OFF MEMBERSMAP=ON CCACHE_CPP2=yes
compiler: clang
arch: amd64
- env: CONF=release ARCH=x86_64 CXX11=ON CXX17=OFF MEMBERSMAP=OFF CCACHE_CPP2=yes
compiler: clang
arch: amd64
- env: CONF=debug ARCH=x86 CXX11=OFF CXX17=OFF MEMBERSMAP=ON CCACHE_CPP2=yes
compiler: clang
arch: amd64
- env: CONF=debug ARCH=x86_64 CXX11=OFF CXX17=OFF MEMBERSMAP=ON CCACHE_CPP2=yes
compiler: clang
arch: amd64
- env: CONF=debug ARCH=x86 CXX11=OFF CXX17=ON MEMBERSMAP=OFF CCACHE_CPP2=yes
compiler: clang
arch: amd64
- env: CONF=debug ARCH=x86_64 CXX11=OFF CXX17=ON MEMBERSMAP=OFF CCACHE_CPP2=yes
compiler: clang
arch: amd64
- env: CONF=debug ARCH=aarch64 CXX11=ON CXX17=OFF MEMBERSMAP=ON CCACHE_CPP2=yes
compiler: clang
arch: arm64
- env: CONF=debug ARCH=aarch64 CXX11=OFF CXX17=OFF MEMBERSMAP=ON CCACHE_CPP2=yes
compiler: clang
arch: arm64
- env: CONF=debug ARCH=aarch64 CXX11=OFF CXX17=ON MEMBERSMAP=OFF CCACHE_CPP2=yes
compiler: clang
arch: arm64
# coverage report
- env: CONF=debug ARCH=x86 GCOV_FLAGS='--coverage' CXX_FLAGS='-O0' CXX11=OFF CXX17=OFF
compiler: gcc
arch: amd64
cache:
- ccache
- pip
after_success:
- pip install --user cpp-coveralls
- coveralls -r .. --gcov-options '\-lp' -e thirdparty -e example -e test -e build/CMakeFiles -e include/rapidjson/msinttypes -e include/rapidjson/internal/meta.h -e include/rapidjson/error/en.h
- env: CONF=debug ARCH=x86_64 GCOV_FLAGS='--coverage' CXX_FLAGS='-O0' CXX11=ON CXX17=OFF MEMBERSMAP=ON
compiler: gcc
arch: amd64
cache:
- ccache
- pip
after_success:
- pip install --user cpp-coveralls
- coveralls -r .. --gcov-options '\-lp' -e thirdparty -e example -e test -e build/CMakeFiles -e include/rapidjson/msinttypes -e include/rapidjson/internal/meta.h -e include/rapidjson/error/en.h
- env: CONF=debug ARCH=aarch64 GCOV_FLAGS='--coverage' CXX_FLAGS='-O0' CXX11=OFF CXX17=ON
compiler: gcc
arch: arm64
cache:
- ccache
- pip
after_success:
- pip install --user cpp-coveralls
- coveralls -r .. --gcov-options '\-lp' -e thirdparty -e example -e test -e build/CMakeFiles -e include/rapidjson/msinttypes -e include/rapidjson/internal/meta.h -e include/rapidjson/error/en.h
- script: # Documentation task
- cd build
- cmake .. -DRAPIDJSON_HAS_STDSTRING=ON -DCMAKE_VERBOSE_MAKEFILE=ON
- make travis_doc
cache: false
addons:
apt:
packages:
- doxygen
before_install:
- if [ "x86_64" = "$(arch)" ]; then sudo apt-get install -y g++-multilib libc6-dbg:i386 --allow-unauthenticated; fi
before_script:
# travis provides clang-7 for amd64 and clang-3.8 for arm64
# here use clang-8 to all architectures as clang-7 is not available for arm64
- if [ -f /usr/bin/clang++-8 ]; then
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-8 1000;
sudo update-alternatives --config clang++;
export PATH=/usr/bin:$PATH;
fi
- if [ "$CXX" = "clang++" ]; then export CCACHE_CPP2=yes; fi
- ccache -s
# hack to avoid Valgrind bug (https://bugs.kde.org/show_bug.cgi?id=326469),
# exposed by merging PR#163 (using -march=native)
# TODO: Since this bug is already fixed. Remove this when valgrind can be upgraded.
- sed -i "s/-march=native//" CMakeLists.txt
- mkdir build
script:
- if [ "$CXX" = "clang++" ]; then export CXXFLAGS="-stdlib=libc++ ${CXXFLAGS}"; fi
- >
eval "ARCH_FLAGS=\${ARCH_FLAGS_${ARCH}}" ;
(cd build && cmake
-DRAPIDJSON_HAS_STDSTRING=ON
-DRAPIDJSON_USE_MEMBERSMAP=$MEMBERSMAP
-DRAPIDJSON_BUILD_CXX11=$CXX11
-DRAPIDJSON_BUILD_CXX17=$CXX17
-DCMAKE_VERBOSE_MAKEFILE=ON
-DCMAKE_BUILD_TYPE=$CONF
-DCMAKE_CXX_FLAGS="$ARCH_FLAGS $GCOV_FLAGS $CXX_FLAGS"
-DCMAKE_EXE_LINKER_FLAGS=$GCOV_FLAGS
..)
- cd build
- make tests -j 2
- make examples -j 2
- ctest -j 2 -V `[ "$CONF" = "release" ] || echo "-E perftest"`

158
external/rapidjson/CHANGELOG.md vendored Normal file
View file

@ -0,0 +1,158 @@
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
## 1.1.0 - 2016-08-25
### Added
* Add GenericDocument ctor overload to specify JSON type (#369)
* Add FAQ (#372, #373, #374, #376)
* Add forward declaration header `fwd.h`
* Add @PlatformIO Library Registry manifest file (#400)
* Implement assignment operator for BigInteger (#404)
* Add comments support (#443)
* Adding coapp definition (#460)
* documenttest.cpp: EXPECT_THROW when checking empty allocator (470)
* GenericDocument: add implicit conversion to ParseResult (#480)
* Use <wchar.h> with C++ linkage on Windows ARM (#485)
* Detect little endian for Microsoft ARM targets
* Check Nan/Inf when writing a double (#510)
* Add JSON Schema Implementation (#522)
* Add iostream wrapper (#530)
* Add Jsonx example for converting JSON into JSONx (a XML format) (#531)
* Add optional unresolvedTokenIndex parameter to Pointer::Get() (#532)
* Add encoding validation option for Writer/PrettyWriter (#534)
* Add Writer::SetMaxDecimalPlaces() (#536)
* Support {0, } and {0, m} in Regex (#539)
* Add Value::Get/SetFloat(), Value::IsLossLessFloat/Double() (#540)
* Add stream position check to reader unit tests (#541)
* Add Templated accessors and range-based for (#542)
* Add (Pretty)Writer::RawValue() (#543)
* Add Document::Parse(std::string), Document::Parse(const char*, size_t length) and related APIs. (#553)
* Add move constructor for GenericSchemaDocument (#554)
* Add VS2010 and VS2015 to AppVeyor CI (#555)
* Add parse-by-parts example (#556, #562)
* Support parse number as string (#564, #589)
* Add kFormatSingleLineArray for PrettyWriter (#577)
* Added optional support for trailing commas (#584)
* Added filterkey and filterkeydom examples (#615)
* Added npm docs (#639)
* Allow options for writing and parsing NaN/Infinity (#641)
* Add std::string overload to PrettyWriter::Key() when RAPIDJSON_HAS_STDSTRING is defined (#698)
### Fixed
* Fix gcc/clang/vc warnings (#350, #394, #397, #444, #447, #473, #515, #582, #589, #595, #667)
* Fix documentation (#482, #511, #550, #557, #614, #635, #660)
* Fix emscripten alignment issue (#535)
* Fix missing allocator to uses of AddMember in document (#365)
* CMake will no longer complain that the minimum CMake version is not specified (#501)
* Make it usable with old VC8 (VS2005) (#383)
* Prohibit C++11 move from Document to Value (#391)
* Try to fix incorrect 64-bit alignment (#419)
* Check return of fwrite to avoid warn_unused_result build failures (#421)
* Fix UB in GenericDocument::ParseStream (#426)
* Keep Document value unchanged on parse error (#439)
* Add missing return statement (#450)
* Fix Document::Parse(const Ch*) for transcoding (#478)
* encodings.h: fix typo in preprocessor condition (#495)
* Custom Microsoft headers are necessary only for Visual Studio 2012 and lower (#559)
* Fix memory leak for invalid regex (26e69ffde95ba4773ab06db6457b78f308716f4b)
* Fix a bug in schema minimum/maximum keywords for 64-bit integer (e7149d665941068ccf8c565e77495521331cf390)
* Fix a crash bug in regex (#605)
* Fix schema "required" keyword cannot handle duplicated keys (#609)
* Fix cmake CMP0054 warning (#612)
* Added missing include guards in istreamwrapper.h and ostreamwrapper.h (#634)
* Fix undefined behaviour (#646)
* Fix buffer overrun using PutN (#673)
* Fix rapidjson::value::Get<std::string>() may returns wrong data (#681)
* Add Flush() for all value types (#689)
* Handle malloc() fail in PoolAllocator (#691)
* Fix builds on x32 platform. #703
### Changed
* Clarify problematic JSON license (#392)
* Move Travis to container based infrastructure (#504, #558)
* Make whitespace array more compact (#513)
* Optimize Writer::WriteString() with SIMD (#544)
* x86-64 48-bit pointer optimization for GenericValue (#546)
* Define RAPIDJSON_HAS_CXX11_RVALUE_REFS directly in clang (#617)
* Make GenericSchemaDocument constructor explicit (#674)
* Optimize FindMember when use std::string (#690)
## [1.0.2] - 2015-05-14
### Added
* Add Value::XXXMember(...) overloads for std::string (#335)
### Fixed
* Include rapidjson.h for all internal/error headers.
* Parsing some numbers incorrectly in full-precision mode (`kFullPrecisionParseFlag`) (#342)
* Fix some numbers parsed incorrectly (#336)
* Fix alignment of 64bit platforms (#328)
* Fix MemoryPoolAllocator::Clear() to clear user-buffer (0691502573f1afd3341073dd24b12c3db20fbde4)
### Changed
* CMakeLists for include as a thirdparty in projects (#334, #337)
* Change Document::ParseStream() to use stack allocator for Reader (ffbe38614732af8e0b3abdc8b50071f386a4a685)
## [1.0.1] - 2015-04-25
### Added
* Changelog following [Keep a CHANGELOG](https://github.com/olivierlacan/keep-a-changelog) suggestions.
### Fixed
* Parsing of some numbers (e.g. "1e-00011111111111") causing assertion (#314).
* Visual C++ 32-bit compilation error in `diyfp.h` (#317).
## [1.0.0] - 2015-04-22
### Added
* 100% [Coverall](https://coveralls.io/r/Tencent/rapidjson?branch=master) coverage.
* Version macros (#311)
### Fixed
* A bug in trimming long number sequence (4824f12efbf01af72b8cb6fc96fae7b097b73015).
* Double quote in unicode escape (#288).
* Negative zero roundtrip (double only) (#289).
* Standardize behavior of `memcpy()` and `malloc()` (0c5c1538dcfc7f160e5a4aa208ddf092c787be5a, #305, 0e8bbe5e3ef375e7f052f556878be0bd79e9062d).
### Removed
* Remove an invalid `Document::ParseInsitu()` API (e7f1c6dd08b522cfcf9aed58a333bd9a0c0ccbeb).
## 1.0-beta - 2015-04-8
### Added
* RFC 7159 (#101)
* Optional Iterative Parser (#76)
* Deep-copy values (#20)
* Error code and message (#27)
* ASCII Encoding (#70)
* `kParseStopWhenDoneFlag` (#83)
* `kParseFullPrecisionFlag` (881c91d696f06b7f302af6d04ec14dd08db66ceb)
* Add `Key()` to handler concept (#134)
* C++11 compatibility and support (#128)
* Optimized number-to-string and vice versa conversions (#137, #80)
* Short-String Optimization (#131)
* Local stream optimization by traits (#32)
* Travis & Appveyor Continuous Integration, with Valgrind verification (#24, #242)
* Redo all documentation (English, Simplified Chinese)
### Changed
* Copyright ownership transferred to THL A29 Limited (a Tencent company).
* Migrating from Premake to CMAKE (#192)
* Resolve all warning reports
### Removed
* Remove other JSON libraries for performance comparison (#180)
## 0.11 - 2012-11-16
## 0.1 - 2011-11-18
[Unreleased]: https://github.com/Tencent/rapidjson/compare/v1.1.0...HEAD
[1.1.0]: https://github.com/Tencent/rapidjson/compare/v1.0.2...v1.1.0
[1.0.2]: https://github.com/Tencent/rapidjson/compare/v1.0.1...v1.0.2
[1.0.1]: https://github.com/Tencent/rapidjson/compare/v1.0.0...v1.0.1
[1.0.0]: https://github.com/Tencent/rapidjson/compare/v1.0-beta...v1.0.0

248
external/rapidjson/CMakeLists.txt vendored Normal file
View file

@ -0,0 +1,248 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
if(POLICY CMP0025)
# detect Apple's Clang
cmake_policy(SET CMP0025 NEW)
endif()
if(POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()
SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules)
set(LIB_MAJOR_VERSION "1")
set(LIB_MINOR_VERSION "1")
set(LIB_PATCH_VERSION "0")
set(LIB_VERSION_STRING "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_PATCH_VERSION}")
if (CMAKE_VERSION VERSION_LESS 3.0)
PROJECT(RapidJSON CXX)
else()
cmake_policy(SET CMP0048 NEW)
PROJECT(RapidJSON VERSION "${LIB_VERSION_STRING}" LANGUAGES CXX)
endif()
# compile in release with debug info mode by default
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif()
# Build all binaries in a separate directory
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
option(RAPIDJSON_BUILD_DOC "Build rapidjson documentation." ON)
option(RAPIDJSON_BUILD_EXAMPLES "Build rapidjson examples." ON)
option(RAPIDJSON_BUILD_TESTS "Build rapidjson perftests and unittests." ON)
option(RAPIDJSON_BUILD_THIRDPARTY_GTEST
"Use gtest installation in `thirdparty/gtest` by default if available" OFF)
option(RAPIDJSON_BUILD_CXX11 "Build rapidjson with C++11" ON)
option(RAPIDJSON_BUILD_CXX17 "Build rapidjson with C++17" OFF)
if(RAPIDJSON_BUILD_CXX11)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
endif()
option(RAPIDJSON_BUILD_ASAN "Build rapidjson with address sanitizer (gcc/clang)" OFF)
option(RAPIDJSON_BUILD_UBSAN "Build rapidjson with undefined behavior sanitizer (gcc/clang)" OFF)
option(RAPIDJSON_ENABLE_INSTRUMENTATION_OPT "Build rapidjson with -march or -mcpu options" ON)
option(RAPIDJSON_HAS_STDSTRING "" OFF)
if(RAPIDJSON_HAS_STDSTRING)
add_definitions(-DRAPIDJSON_HAS_STDSTRING)
endif()
option(RAPIDJSON_USE_MEMBERSMAP "" OFF)
if(RAPIDJSON_USE_MEMBERSMAP)
add_definitions(-DRAPIDJSON_USE_MEMBERSMAP=1)
endif()
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -fcolor-diagnostics")
endif()
endif(CCACHE_FOUND)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(RAPIDJSON_ENABLE_INSTRUMENTATION_OPT AND NOT CMAKE_CROSSCOMPILING)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "powerpc" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=native")
else()
#FIXME: x86 is -march=native, but doesn't mean every arch is this option. To keep original project's compatibility, I leave this except POWER.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
endif()
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
set(EXTRA_CXX_FLAGS -Weffc++ -Wswitch-default -Wfloat-equal -Wconversion -Wsign-conversion)
if (RAPIDJSON_BUILD_CXX11 AND CMAKE_VERSION VERSION_LESS 3.1)
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7.0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
elseif (RAPIDJSON_BUILD_CXX17 AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
endif()
if (RAPIDJSON_BUILD_ASAN)
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8.0")
message(FATAL_ERROR "GCC < 4.8 doesn't support the address sanitizer")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
endif()
endif()
if (RAPIDJSON_BUILD_UBSAN)
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9.0")
message(FATAL_ERROR "GCC < 4.9 doesn't support the undefined behavior sanitizer")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
endif()
endif()
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(NOT CMAKE_CROSSCOMPILING)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "powerpc" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=native")
else()
#FIXME: x86 is -march=native, but doesn't mean every arch is this option. To keep original project's compatibility, I leave this except POWER.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
endif()
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -Wno-missing-field-initializers")
set(EXTRA_CXX_FLAGS -Weffc++ -Wswitch-default -Wfloat-equal -Wconversion -Wimplicit-fallthrough)
if (RAPIDJSON_BUILD_CXX11 AND CMAKE_VERSION VERSION_LESS 3.1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif (RAPIDJSON_BUILD_CXX17 AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
endif()
if (RAPIDJSON_BUILD_ASAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
endif()
if (RAPIDJSON_BUILD_UBSAN)
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined-trap -fsanitize-undefined-trap-on-error")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
endif()
endif()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
# CMake >= 3.10 should handle the above CMAKE_CXX_STANDARD fine, otherwise use /std:c++XX with MSVC >= 19.10
if (RAPIDJSON_BUILD_CXX11 AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.10")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++11")
elseif (RAPIDJSON_BUILD_CXX17 AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.14")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17")
endif()
# Always compile with /WX
if(CMAKE_CXX_FLAGS MATCHES "/WX-")
string(REGEX REPLACE "/WX-" "/WX" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
endif()
elseif (CMAKE_CXX_COMPILER_ID MATCHES "XL")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -qarch=auto")
endif()
#add extra search paths for libraries and includes
SET(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "The directory the headers are installed in")
SET(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE STRING "Directory where lib will install")
SET(DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}" CACHE PATH "Path to the documentation")
IF(UNIX OR CYGWIN)
SET(_CMAKE_INSTALL_DIR "${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME}")
ELSEIF(WIN32)
SET(_CMAKE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/cmake")
ENDIF()
SET(CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" CACHE PATH "The directory cmake files are installed in")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
if(RAPIDJSON_BUILD_DOC)
add_subdirectory(doc)
endif()
add_custom_target(travis_doc)
add_custom_command(TARGET travis_doc
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/travis-doxygen.sh)
if(RAPIDJSON_BUILD_EXAMPLES)
add_subdirectory(example)
endif()
if(RAPIDJSON_BUILD_TESTS)
if(MSVC11)
# required for VS2012 due to missing support for variadic templates
add_definitions(-D_VARIADIC_MAX=10)
endif(MSVC11)
add_subdirectory(test)
include(CTest)
endif()
# pkg-config
IF (UNIX OR CYGWIN)
CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
@ONLY)
INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
DESTINATION "${LIB_INSTALL_DIR}/pkgconfig"
COMPONENT pkgconfig)
ENDIF()
install(FILES readme.md
DESTINATION "${DOC_INSTALL_DIR}"
COMPONENT doc)
install(DIRECTORY include/rapidjson
DESTINATION "${INCLUDE_INSTALL_DIR}"
COMPONENT dev)
install(DIRECTORY example/
DESTINATION "${DOC_INSTALL_DIR}/examples"
COMPONENT examples
# Following patterns are for excluding the intermediate/object files
# from an install of in-source CMake build.
PATTERN "CMakeFiles" EXCLUDE
PATTERN "Makefile" EXCLUDE
PATTERN "cmake_install.cmake" EXCLUDE)
# Provide config and version files to be used by other applications
# ===============================
################################################################################
# Export package for use from the build tree
EXPORT( PACKAGE ${PROJECT_NAME} )
# Create the RapidJSONConfig.cmake file for other cmake projects.
# ... for the build tree
SET( CONFIG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
SET( CONFIG_DIR ${CMAKE_CURRENT_BINARY_DIR})
SET( ${PROJECT_NAME}_INCLUDE_DIR "\${${PROJECT_NAME}_SOURCE_DIR}/include" )
CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake @ONLY )
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}ConfigVersion.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake @ONLY)
# ... for the install tree
SET( CMAKECONFIG_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME} )
FILE( RELATIVE_PATH REL_INCLUDE_DIR
"${CMAKECONFIG_INSTALL_DIR}"
"${CMAKE_INSTALL_PREFIX}/include" )
SET( ${PROJECT_NAME}_INCLUDE_DIR "\${${PROJECT_NAME}_CMAKE_DIR}/${REL_INCLUDE_DIR}" )
SET( CONFIG_SOURCE_DIR )
SET( CONFIG_DIR )
CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}Config.cmake @ONLY )
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}Config.cmake"
DESTINATION ${CMAKECONFIG_INSTALL_DIR} )
# Install files
INSTALL(FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION "${CMAKE_INSTALL_DIR}"
COMPONENT dev)

View file

@ -0,0 +1,30 @@
SET(GTEST_SEARCH_PATH
"${GTEST_SOURCE_DIR}"
"${CMAKE_CURRENT_LIST_DIR}/../thirdparty/gtest/googletest")
IF(UNIX)
IF(RAPIDJSON_BUILD_THIRDPARTY_GTEST)
LIST(APPEND GTEST_SEARCH_PATH "/usr/src/gtest")
ELSE()
LIST(INSERT GTEST_SEARCH_PATH 1 "/usr/src/gtest")
ENDIF()
ENDIF()
FIND_PATH(GTEST_SOURCE_DIR
NAMES CMakeLists.txt src/gtest_main.cc
PATHS ${GTEST_SEARCH_PATH})
# Debian installs gtest include directory in /usr/include, thus need to look
# for include directory separately from source directory.
FIND_PATH(GTEST_INCLUDE_DIR
NAMES gtest/gtest.h
PATH_SUFFIXES include
HINTS ${GTEST_SOURCE_DIR}
PATHS ${GTEST_SEARCH_PATH})
INCLUDE(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GTestSrc DEFAULT_MSG
GTEST_SOURCE_DIR
GTEST_INCLUDE_DIR)

7
external/rapidjson/RapidJSON.pc.in vendored Normal file
View file

@ -0,0 +1,7 @@
includedir=@INCLUDE_INSTALL_DIR@
Name: @PROJECT_NAME@
Description: A fast JSON parser/generator for C++ with both SAX/DOM style API
Version: @LIB_VERSION_STRING@
URL: https://github.com/Tencent/rapidjson
Cflags: -I${includedir}

View file

@ -0,0 +1,25 @@
################################################################################
# CMake minimum version required
cmake_minimum_required(VERSION 3.0)
################################################################################
# RapidJSON source dir
set( RapidJSON_SOURCE_DIR "@CONFIG_SOURCE_DIR@")
################################################################################
# RapidJSON build dir
set( RapidJSON_DIR "@CONFIG_DIR@")
################################################################################
# Compute paths
get_filename_component(RapidJSON_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set( RapidJSON_INCLUDE_DIR "@RapidJSON_INCLUDE_DIR@" )
set( RapidJSON_INCLUDE_DIRS "@RapidJSON_INCLUDE_DIR@" )
message(STATUS "RapidJSON found. Headers: ${RapidJSON_INCLUDE_DIRS}")
if(NOT TARGET rapidjson)
add_library(rapidjson INTERFACE IMPORTED)
set_property(TARGET rapidjson PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${RapidJSON_INCLUDE_DIRS})
endif()

View file

@ -0,0 +1,10 @@
SET(PACKAGE_VERSION "@LIB_VERSION_STRING@")
IF (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
SET(PACKAGE_VERSION_EXACT "true")
ENDIF (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
IF (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
SET(PACKAGE_VERSION_COMPATIBLE "true")
ELSE (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
SET(PACKAGE_VERSION_UNSUITABLE "true")
ENDIF (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)

102
external/rapidjson/appveyor.yml vendored Normal file
View file

@ -0,0 +1,102 @@
version: 1.1.0.{build}
configuration:
- Debug
- Release
environment:
matrix:
# - VS_VERSION: 9 2008
# VS_PLATFORM: win32
# - VS_VERSION: 9 2008
# VS_PLATFORM: x64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
VS_VERSION: 10 2010
VS_PLATFORM: win32
CXX11: OFF
CXX17: OFF
MEMBERSMAP: OFF
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
VS_VERSION: 10 2010
VS_PLATFORM: x64
CXX11: OFF
CXX17: OFF
MEMBERSMAP: ON
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
VS_VERSION: 11 2012
VS_PLATFORM: win32
CXX11: OFF
CXX17: OFF
MEMBERSMAP: ON
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
VS_VERSION: 11 2012
VS_PLATFORM: x64
CXX11: OFF
CXX17: OFF
MEMBERSMAP: OFF
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
VS_VERSION: 12 2013
VS_PLATFORM: win32
CXX11: OFF
CXX17: OFF
MEMBERSMAP: OFF
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
VS_VERSION: 12 2013
VS_PLATFORM: x64
CXX11: OFF
CXX17: OFF
MEMBERSMAP: ON
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
VS_VERSION: 14 2015
VS_PLATFORM: win32
CXX11: OFF
CXX17: OFF
MEMBERSMAP: ON
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
VS_VERSION: 14 2015
VS_PLATFORM: x64
CXX11: OFF
CXX17: OFF
MEMBERSMAP: OFF
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
VS_VERSION: 15 2017
VS_PLATFORM: win32
CXX11: OFF
CXX17: OFF
MEMBERSMAP: OFF
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
VS_VERSION: 15 2017
VS_PLATFORM: x64
CXX11: OFF
CXX17: OFF
MEMBERSMAP: ON
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
VS_VERSION: 15 2017
VS_PLATFORM: x64
CXX11: ON
CXX17: OFF
MEMBERSMAP: OFF
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
VS_VERSION: 15 2017
VS_PLATFORM: x64
CXX11: OFF
CXX17: ON
MEMBERSMAP: OFF
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
VS_VERSION: 16 2019
VS_PLATFORM: x64
CXX11: OFF
CXX17: ON
MEMBERSMAP: ON
before_build:
- git submodule update --init --recursive
- cmake -H. -BBuild/VS -G "Visual Studio %VS_VERSION%" -DCMAKE_GENERATOR_PLATFORM=%VS_PLATFORM% -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_SHARED_LIBS=true -DRAPIDJSON_BUILD_CXX11=%CXX11% -DRAPIDJSON_BUILD_CXX17=%CXX17% -DRAPIDJSON_USE_MEMBERSMAP=%MEMBERSMAP% -Wno-dev
build:
project: Build\VS\RapidJSON.sln
parallel: true
verbosity: minimal
test_script:
- cd Build\VS && if %CONFIGURATION%==Debug (ctest --verbose -E perftest --build-config %CONFIGURATION%) else (ctest --verbose --build-config %CONFIGURATION%)

1
external/rapidjson/bin/data/abcde.txt vendored Normal file
View file

@ -0,0 +1 @@
abcde

Binary file not shown.

BIN
external/rapidjson/bin/data/menu.json vendored Normal file

Binary file not shown.

View file

@ -0,0 +1 @@
sample.json is obtained from http://code.google.com/p/json-test-suite/downloads/detail?name=sample.zip

BIN
external/rapidjson/bin/data/sample.json vendored Normal file

Binary file not shown.

BIN
external/rapidjson/bin/data/webapp.json vendored Normal file

Binary file not shown.

BIN
external/rapidjson/bin/data/widget.json vendored Normal file

Binary file not shown.

150
external/rapidjson/bin/draft-04/schema vendored Normal file
View file

@ -0,0 +1,150 @@
{
"id": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Core schema meta-schema",
"definitions": {
"schemaArray": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#" }
},
"positiveInteger": {
"type": "integer",
"minimum": 0
},
"positiveIntegerDefault0": {
"allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ]
},
"simpleTypes": {
"enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ]
},
"stringArray": {
"type": "array",
"items": { "type": "string" },
"minItems": 1,
"uniqueItems": true
}
},
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uri"
},
"$schema": {
"type": "string",
"format": "uri"
},
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"default": {},
"multipleOf": {
"type": "number",
"minimum": 0,
"exclusiveMinimum": true
},
"maximum": {
"type": "number"
},
"exclusiveMaximum": {
"type": "boolean",
"default": false
},
"minimum": {
"type": "number"
},
"exclusiveMinimum": {
"type": "boolean",
"default": false
},
"maxLength": { "$ref": "#/definitions/positiveInteger" },
"minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
"pattern": {
"type": "string",
"format": "regex"
},
"additionalItems": {
"anyOf": [
{ "type": "boolean" },
{ "$ref": "#" }
],
"default": {}
},
"items": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/definitions/schemaArray" }
],
"default": {}
},
"maxItems": { "$ref": "#/definitions/positiveInteger" },
"minItems": { "$ref": "#/definitions/positiveIntegerDefault0" },
"uniqueItems": {
"type": "boolean",
"default": false
},
"maxProperties": { "$ref": "#/definitions/positiveInteger" },
"minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" },
"required": { "$ref": "#/definitions/stringArray" },
"additionalProperties": {
"anyOf": [
{ "type": "boolean" },
{ "$ref": "#" }
],
"default": {}
},
"definitions": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"properties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"patternProperties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"dependencies": {
"type": "object",
"additionalProperties": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/definitions/stringArray" }
]
}
},
"enum": {
"type": "array",
"minItems": 1,
"uniqueItems": true
},
"type": {
"anyOf": [
{ "$ref": "#/definitions/simpleTypes" },
{
"type": "array",
"items": { "$ref": "#/definitions/simpleTypes" },
"minItems": 1,
"uniqueItems": true
}
]
},
"allOf": { "$ref": "#/definitions/schemaArray" },
"anyOf": { "$ref": "#/definitions/schemaArray" },
"oneOf": { "$ref": "#/definitions/schemaArray" },
"not": { "$ref": "#" }
},
"dependencies": {
"exclusiveMaximum": [ "maximum" ],
"exclusiveMinimum": [ "minimum" ]
},
"default": {}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show more