diff --git a/CHANGELOG.md b/CHANGELOG.md index 3af834783..af4d4a9f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,37 +13,53 @@ * 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 most RetroArch cores * Added a virtual keyboard, partly based on code from batocera-emulationstation +* Added badges that indicate favorite/completed/broken games as well as games suitable for children and those with a selected alternative emulator +* Added game-specific controller images that are selectable via the metadata editor and displayed as a controller badge * 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 \ tag for es_systems.xml that can be used to override the default \ systems sorting +* Added menu scroll indicators showing if there are additional entries available below or above what's currently shown on screen +* Improved the layout of the scraper GUIs (single-game scraper and multi-scraper) +* Added horizontal scrolling of long game names to the scraper GUIs * 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 * Grayed out all fields in the gamelist filter screen where there is no data to filter, previously some fields were removed entirely and some could still be used * 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 filters for "Alternative emulator" and "Controller badges" 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 an option to preload the gamelists on startup which leads to smoother navigation when first entering each gamelist * 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 * Made the scrolling speed of ScrollableContainer more consistent across various screen resolutions and display aspect ratios +* Decreased the amount of text that ScrollableContainer renders above and below the starting position as content is scrolled * 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 +* Made large optimizations to the SVG rendering which reduces application startup time dramatically when many systems are populated +* Changed to loading the default theme set rbsimple-DE instead of the first available theme if the currently configured theme is missing * 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 +* Replaced a number of help prompt hacks with proper solutions * Changed the "Toggle screensaver" help entry in the system view to simply "Screensaver" +* Changed the font size for the custom collection deletion screen to the same size as for all other menus * Added support for upscaling bitmap images using linear filtering * Changed the marquee image upscale filtering from nearest neighbor to linear for the launch screen and the gamelist views * Moved the Media Viewer and Screensaver settings higher in the UI Settings menu * Moved the game media directory setting to the top of the Other Settings menu, following the new Alternative Emulators entry * Added a blinking cursor to TextEditComponent * Changed the filter description "Text filter (game name)" to "Game name" +* Removed a margin hack from TextComponent and if abbreviated strings end with a space character, that space is now removed * Added support for multi-select total count and exclusive multi-select to OptionListComponent +* Added support for a maximum name length to OptionListComponent (non-multiselect only) with an abbreviation of the name if it exceeds this value * 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) +* Added support for setting the Kidgame metadata flag for folders (which will only affect the badges) * 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 correctly navigating arbitrarily sized ComponentGrid entries, i.e. those spanning multiple cells * Bundled the bold font version of Fontfabric Akrobat +* Moved the resources/help directory to resources/graphics/help +* Removed the unused graphics files resources/graphics/fav_add.svg and resources/graphics/fav_remove.svg * Added RapidJSON 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 @@ -65,23 +81,34 @@ * 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 +* Fixed multiple minor rendering issues where graphics would be slightly cut off or incorrectly resized * 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 +* Fixed multiple issues with scaling of images which lead to various inconsistencies and sometimes cut-off graphics * 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 * 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 * 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 +* Fixed multiple issues where ComponentGrid would display incorrect help prompts * 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 +* Under some circumstances and at some screen resolutions, the last menu separator line would not get rendered (still an issue at extreme resolutions like 320x240) * 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 +* The custom collection deletion screen had incorrect row heights when running at lower resolutions such as 1280x720 +* If there was an abbreviated full system name for the "Gamelist on startup" option, that abbreviation would also get displayed when opening the selector window +* Really long theme set names would not get abbreviated in the UI settings menu, leading to a garbled "Theme set" setting row * Disabling a collection while its gamelist was displayed would lead to a slide transition from a black screen if a gamelist on startup had been set * When marking a game to not be counted in the metadata editor and the game was part of a custom collection, no collection disabling notification was displayed +* SliderComponent had very inconsistent widths at different screen aspect ratios +* SliderComponent did not properly align the knob and bar vertically +* Resizing in SwitchComponent did not reposition the image properly leading to a non-centered image * Horizontal sizing of the TextComponent input field was not consistent across different screen resolutions +* The sizing of the metadata editor was strange, which was clearly visible when activating the Ctrl+G debug mode * The "sortname" window header was incorrectly spelled when editing this type of entry in the metadata editor * When the last row of a menu had its text color changed, this color was completely desaturated when navigating to a button below the list diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 45d8f5725..15f31d09b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,7 +30,6 @@ This plan is under constant review so expect it to change from time to time. Sti * Support for pre-defined alternative emulators and cores (configured in es_systems.xml) * Badges highlighting things like favorite games, completed games etc. (will require theme support) -* Improved full-screen support, removing the temporary full-screen hacks * Virtual (on-screen) keyboard * Support for the Raspberry Pi 4 (Raspberry Pi OS) * Add GLM library dependency for matrix and vector operations, decommission the built-in functions @@ -39,25 +38,27 @@ This plan is under constant review so expect it to change from time to time. Sti #### v1.3 -* Localization/multi-language support * New theme engine with generalized views (only System and Gamelist) and theme variants support * Add multiple new gamelist components (wheels, wall/grid etc.) * Move existing theme logic to legacy support, only to be used for backwards compatibility +* Improve full-screen support and make game launching more seamless, remove the temporary full-screen hacks * Checksum support for the scraper for exact searches and for determining when to overwrite files -* Improved text and font functions, e.g. faster and cleaner line wrapping and more exact sizing +* Improve text and font functions, e.g. faster and cleaner line wrapping and more exact sizing #### v1.4 +* Bulk metadata editor +* Localization/multi-language support * Authoring tools to clean up orphaned gamelist entries, media files etc. +* Add scraping of game manuals and maps and create a viewer for these (with PDF, GIF, JPG and PNG support) * Scrollbar component for the gamelist view which can be used by the themes * Web proxy support for the scraper * Add "time played" counter per game, similar to how it works in Steam -* Preload all built-in resources and never clear them from the cache -* Improved multi-threading +* Improve multi-threading #### v1.5 -* Bulk metadata editor +* Reorganize the menus, possibly adding basic/advanced modes * Simple file browsing component * Improve the performance of the GLSL shader code * Animated menu elements like switches, tick boxes, smooth scrolling etc. diff --git a/INSTALL-DEV.md b/INSTALL-DEV.md index cd33d350f..cead7d5fd 100644 --- a/INSTALL-DEV.md +++ b/INSTALL-DEV.md @@ -1870,6 +1870,7 @@ There are two basic categories of metadata, `game` and `folders` and the metdata * `nomultiscrape` - bool, indicates whether the game should be excluded from the multi-scraper * `hidemetadata` - bool, indicates whether to hide most of the metadata fields when displaying the game in the gamelist view * `playcount` - integer, the number of times this game has been played +* `controller` - string, used to display controller badges * `altemulator` - string, overrides the emulator/launch command on a per game basis * `lastplayed` - statistic, datetime, the last date and time this game was played @@ -1891,6 +1892,7 @@ For folders, most of the fields are identical although some are removed. In the * `broken` * `nomultiscrape` * `hidemetadata` +* `controller` * `lastplayed` - statistic, for folders this is inherited by the latest game file launched inside the folder. **Additional gamelist.xml information:** diff --git a/THEMES-DEV.md b/THEMES-DEV.md index bdeba480b..b94cd4bc8 100644 --- a/THEMES-DEV.md +++ b/THEMES-DEV.md @@ -368,6 +368,8 @@ Below are the default zIndex values per element type: * `text name="logoPlaceholderText"` * Gamelist information - 50 * `text name="gamelistInfo"` +* Badges - 50 + * `badges name="md_badges"` ### Theme variables @@ -485,6 +487,8 @@ or to specify only a portion of the value of a theme property: - The "genre" metadata. * `text name="md_players"` - ALL - The "players" metadata (number of players the game supports). + * `badges name="md_badges"` - ALL + - The "badges" metadata. Displayed as a group of badges that indicate metadata such as favorites and completed games. * `datetime name="md_lastplayed"` - ALL - The "lastplayed" metadata. Displayed as a string representing the time relative to "now" (e.g. "3 hours ago"). * `text name="md_playcount"` - ALL @@ -540,6 +544,8 @@ or to specify only a portion of the value of a theme property: - The "genre" metadata. * `text name="md_players"` - ALL - The "players" metadata (number of players the game supports). + * `badges name="md_badges"` - ALL + - The "badges" metadata. Displayed as a group of badges that indicate metadata such as favorites and completed games. * `datetime name="md_lastplayed"` - ALL - The "lastplayed" metadata. Displayed as a string representing the time relative to "now" (e.g. "3 hours ago"). * `text name="md_playcount"` - ALL @@ -593,6 +599,8 @@ or to specify only a portion of the value of a theme property: - The "genre" metadata. * `text name="md_players"` - ALL - The "players" metadata (number of players the game supports). + * `badges name="md_badges"` - ALL + - The "badges" metadata. Displayed as a group of badges that indicate metadata such as favorites and completed games. * `datetime name="md_lastplayed"` - ALL - The "lastplayed" metadata. Displayed as a string representing the time relative to "now" (e.g. "3 hours ago"). * `text name="md_playcount"` - ALL @@ -636,7 +644,7 @@ Can be created as an extra. * `rotation` - type: FLOAT. - angle in degrees that the image should be rotated. Positive values will rotate clockwise, negative values will rotate counterclockwise. * `rotationOrigin` - type: NORMALIZED_PAIR. - - Point around which the image will be rotated. Defaults to `0.5 0.5`. + - Point around which the image will be rotated. Default is `0.5 0.5`. * `path` - type: PATH. - Path to the image file. Most common extensions are supported (including .jpg, .png, and unanimated .gif). * `default` - type: PATH. @@ -710,7 +718,7 @@ Can be created as an extra. * `rotation` - type: FLOAT. - angle in degrees that the text should be rotated. Positive values will rotate clockwise, negative values will rotate counterclockwise. * `rotationOrigin` - type: NORMALIZED_PAIR. - - Point around which the text will be rotated. Defaults to `0.5 0.5`. + - Point around which the text will be rotated. Default is `0.5 0.5`. * `delay` - type: FLOAT. Default is false. - Delay in seconds before video will start playing. * `default` - type: PATH. @@ -739,7 +747,7 @@ Can be created as an extra. * `rotation` - type: FLOAT. - angle in degrees that the text should be rotated. Positive values will rotate clockwise, negative values will rotate counterclockwise. * `rotationOrigin` - type: NORMALIZED_PAIR. - - Point around which the text will be rotated. Defaults to `0.5 0.5`. + - Point around which the text will be rotated. Default is `0.5 0.5`. * `text` - type: STRING. * `color` - type: COLOR. * `backgroundColor` - type: COLOR; @@ -811,7 +819,7 @@ ES-DE borrows the concept of "nine patches" from Android (or "9-Slices"). Curren * `rotation` - type: FLOAT. - angle in degrees that the rating should be rotated. Positive values will rotate clockwise, negative values will rotate counterclockwise. * `rotationOrigin` - type: NORMALIZED_PAIR. - - Point around which the rating will be rotated. Defaults to `0.5 0.5`. + - Point around which the rating will be rotated. Default is `0.5 0.5`. * `filledPath` - type: PATH. - Path to the "filled star" image. Image must be square (width equals height). * `unfilledPath` - type: PATH. @@ -835,7 +843,7 @@ ES-DE borrows the concept of "nine patches" from Android (or "9-Slices"). Curren * `rotation` - type: FLOAT. - angle in degrees that the text should be rotated. Positive values will rotate clockwise, negative values will rotate counterclockwise. * `rotationOrigin` - type: NORMALIZED_PAIR. - - Point around which the text will be rotated. Defaults to `0.5 0.5`. + - Point around which the text will be rotated. Default is `0.5 0.5`. * `color` - type: COLOR. * `backgroundColor` - type: COLOR; * `fontPath` - type: PATH. @@ -911,6 +919,51 @@ ES-DE borrows the concept of "nine patches" from Android (or "9-Slices"). Curren `button_back_XBOX360`, `button_start_XBOX360`. +#### badges + +It's strongly recommended to use the same image dimensions for all badges as varying aspect ratios will lead to alignment issues. For the controller images it's recommended to keep to the square canvas size used by the default bundled graphics as otherwise sizing and placement will be inconsistent (unless all controller graphic files are customized of course). + +* `pos` - type: NORMALIZED_PAIR. +* `size` - type: NORMALIZED_PAIR. + - Possible combinations: + - `w h` - Dimensions of the badges container. The badges will be scaled to fit within these dimensions. Minimum value per axis is `0.03`, maximum value is `1.0`. Default is `0.15 0.20`. +* `origin` - type: NORMALIZED_PAIR. + - Where on the component `pos` refers to. For example, an origin of `0.5 0.5` and a `pos` of `0.5 0.5` would place the component exactly in the middle of the screen. If the "POSITION" and "SIZE" attributes are themeable, "ORIGIN" is implied. Default is `0 0`. +* `rotation` - type: FLOAT. + - angle in degrees that the image should be rotated. Positive values will rotate clockwise, negative values will rotate counterclockwise. Default is `0`. +* `rotationOrigin` - type: NORMALIZED_PAIR. + - Point around which the image will be rotated. Default is `0.5 0.5`. +* `direction` - type: STRING. + - Valid values are "row" or "column". Controls the primary layout direction (line axis) for the badges. Lines will fill up in the specified direction. Default is `row`. +* `lines` - type: FLOAT. + - The number of lines available. Default is `2`. +* `itemsPerLine` - type: FLOAT. + - Number of badges that fit on a line. When more badges are available a new line will be started. Default is `4`. +* `itemMargin` - type: NORMALIZED_PAIR. + - The margins between badges. Possible combinations: + - `x y` - horizontal and vertical margins. Minimum value per axis is `0`, maximum value is `0.2`. Default is `0.01 0.01`. If one of the axis is set to `-1` the margin of the other axis (in pixels) will be used, which makes it possible to get identical spacing between all items regardless of screen aspect ratio. +* `slots` - type: STRING. + - The badge types that should be displayed. Should be specified as a list of strings delimited by any characters of `\t\r\n ,` - that is, whitespace and commas. The order will be followed when placing badges on the screen. Available badges are: + - `favorite`: Will be shown when the game is marked as favorite. + - `completed`: Will be shown when the game is marked as completed. + - `kidgame`: Will be shown when the game is marked as a kids game. + - `broken`: Will be shown when the game is marked as broken. + - `controller`: Will be shown and overlaid by the corresponding controller icon if a controller type has been selected for the game using the metadata editor. + - `altemulator`: Will be shown when an alternative emulator is setup for the game. +* `controllerPos` - type: NORMALIZED_PAIR. + - The position of the controller icon relative to the parent `controller` badge. Minimum value per axis is `-1.0`, maximum value is `2.0`. Default is `0.5 0.5` which centers the controller icon on the badge. +* `controllerSize` - type: FLOAT. + - The size of the controller icon relative to the parent `controller` badge. Minimum value is `0.1`, maximum value is `2.0`. Setting the value to `1.0` sizes the controller icon to the same width as the parent badge. The image aspect ratio is always maintained. +* `customBadgeIcon` - type: PATH. + - A badge icon override. Specify the badge type in the attribute `badge`. The available badges are the ones listed above. +* `customControllerIcon` - type: PATH. + - A controller icon override. Specify the controller type in the attribute `controller`. These are the available types: + - `gamepad_generic`, `gamepad_xbox`, `gamepad_playstation`, `gamepad_nintendo_nes`, `gamepad_nintendo_snes`, `gamepad_nintendo_64`, `joystick_generic`, `joystick_arcade_2_buttons`, `joystick_arcade_3_buttons`, `joystick_arcade_4_buttons`, `joystick_arcade_6_buttons`, `trackball_generic`, `lightgun_generic`, `lightgun_nintendo`, `keyboard_generic`, `mouse_generic`, `mouse_amiga`, `keyboard_mouse_generic`, `steering_wheel_generic`, `wii_remote_nintendo`, `wii_remote_nunchuck_nintendo`, `joycon_left_or_right_nintendo`, `joycon_pair_nintendo`, `unknown`. +* `visible` - type: BOOLEAN. + - If true, component will be rendered, otherwise rendering will be skipped. Can be used to hide elements from a particular view. +* `zIndex` - type: FLOAT. + - z-index value for component. Components will be rendered in order of z-index value from low to high. Default is `50`. + #### carousel * `type` - type: STRING. @@ -933,7 +986,7 @@ ES-DE borrows the concept of "nine patches" from Android (or "9-Slices"). Curren - Default is 7.5 - This property only applies when `type` is "horizontal_wheel" or "vertical_wheel". * `logoRotationOrigin` - type: NORMALIZED_PAIR. - - Point around which the logos will be rotated. Defaults to `-5 0.5`. + - Point around which the logos will be rotated. Default is `-5 0.5`. - This property only applies when `type` is "horizontal_wheel" or "vertical_wheel". * `logoAlignment` - type: STRING. - Sets the alignment of the logos relative to the carousel. diff --git a/USERGUIDE-DEV.md b/USERGUIDE-DEV.md index 25ffbd132..d56306a2a 100644 --- a/USERGUIDE-DEV.md +++ b/USERGUIDE-DEV.md @@ -47,6 +47,8 @@ The following operating systems have been tested (all for the x86 architecture u **Note:** If using a Mac with an ARM CPU (e.g. M1) you need to install the x86 version of RetroArch and any other emulators, or you won't be able to launch any games. This will be fixed whenever a native macOS ARM build of ES-DE is released. +As for display resolutions, the minimum pixel value is 224 and the maximum is 7680. This means that you can run ES-DE at for instance 320x224 all the way up to 7680x4320 (8K UHD). Vertical screen orientation is also supported, as well as ultra-wide resolutions like 3840x1440. Note that there could be some minor visual glitches when running in vertical orientation (this will be fixed in future ES-DE releases) and for the best experience you will probably need to use a customized theme set when running at extreme or unusual resolutions. + The installation procedure is just covered briefly here and may differ a bit for your specific operating system, so in case of problems refer to your system documentation. **Installing a Linux .deb package** @@ -213,6 +215,8 @@ In addition to the styles just described, there is a **Grid** view style as well If the theme supports it, there's a gamelist information field displayed in the gamelist view, showing the number of games for the system (total and favorites) as well as a folder icon if a folder has been entered. When applying any filters to the gamelist, the game counter is replaced with the amount of games filtered, as in 'filtered / total games', e.g. '19 / 77'. If there are game entries in the filter result that are marked not to be counted as games, the number of such files will be indicated as 'filtered + filtered non-games / total games', for example '23 + 4 / 77' indicating 23 normal games, 4 non-games out of a total of 77. Due to this approach it's theoretically possible that the combined filtered game amount exceeds the number of counted games in the collection, for instance '69 + 11 / 77'. This is not considered a bug and is so by design. This gamelist information field functionality is specific to EmulationStation Desktop Edition so older themes will not support this. +Another feature which requires theme support is **Badges**, which is a set of icons displaying the status for various metadata fields. The currently supported badge types are _favorite, completed, kidgame, broken, controller_ and _alternative emulator_. If any of the first four metadata fields have been set for a game, their corresponding badges will be displayed. If a game-specific controller has been selected via the metadata editor, the corresponding controller badge will be shown. And if an alternative emulator has been selected for the specific game, that badge will be displayed. Setting an alternative emulator system-wide will not display this badge as it's only intended to indicate game-specific overrides. + ![alt text](images/es-de_gamelist_view.png "ES-DE Gamelist View") _The **Gamelist view** is where you browse the games for a specific system._ @@ -970,6 +974,10 @@ With this option enabled, there will be an overlay displayed when scrolling the This enables a virtual (on-screen) keyboard that can be used at various places throughout the application to input text and numbers using a controller. The Shift and Alt keys can be toggled individually or combined together to access many special characters. The general use of the virtual keyboard should hopefully be self-explanatory. +**Enable menu scroll indicators** + +With this option enabled, "up and down" scroll indicators will be displayed in the upper right corner of menus (including the metadata editor) if there are more entries available than can be shown on the screen at the same time. These indicators will change dynamically as the list is scrolled. If the setting is disabled, a simplified static indicator will be displayed instead. + **Enable toggle favorites button** This setting enables the _Y_ button for quickly toggling a game as favorite. Although this may be convenient at times, it's also quite easy to accidentally remove a favorite tagging of a game when using the application more casually. As such it could sometimes make sense to disable this functionality. It's of course still possible to mark a game as favorite using the metadata editor when this setting is disabled. The option does not affect the use of the _Y_ button to add or remove games when editing custom collections. @@ -1244,6 +1252,10 @@ Enabling this option offloads video decoding to the GPU. Whether this actually i With this option enabled, videos with lower frame rates than 60 FPS, such as 24 and 30 will get upscaled to 60 FPS. This results in slightly smoother playback for some videos. There is a small performance hit from this option, so on weaker machines it may be necessary to disable it for fluent video playback. This setting has no effect when using the VLC video player. If the VLC video player is not included in the ES-DE build, the "(FFmpeg)" text is omitted from the setting name. +**Preload gamelists on startup** + +When this option is enabled, all gamelists will be loaded on application startup. This will increase the startup time slightly and lead to a higher initial memory utilization, but navigation will be smoother the first time a gamelist is entered. The improvement is especially noticeable when the _slide_ transition style has been selected. + **Enable alternative emulators per game** If enabled, you will be able to select alternative emulators per game using the metadata editor. It's only recommended to disable this option for testing purposes. @@ -1364,9 +1376,11 @@ The following filters can be applied: **Broken** +**Controller badge** + **Alternative emulator** -With the exception of the game name text filter, all available filter values are assembled from metadata from the actual gamelist, so if there is no data to filter for the specific field, the text _Nothing to filter_ will be displayed. This for example happens for the _Completed_ filter if there are no games marked as having been completed in the current gamelist. +With the exception of the game name text filter, all available filter values are assembled from metadata from the actual gamelist, so if there is no data to filter for the specific field, the text _Nothing to filter_ will be displayed. This for example happens for the _Completed_ filter if there are no games marked as having been completed in the current gamelist. The same happens if a metadata setting is identical for all games, such as all games being flagged as favorites. Be aware that although folders can have most of the metadata values set, the filters are only applied to files (this is also true for the game name text filter). So if you for example set a filter to only display your favorite games, any folder that contains a favorite game will be displayed, and other folders which are themselves marked as favorites but that do not contain any favorite games will be hidden. @@ -1440,9 +1454,9 @@ A flag to indicate whether this is a favorite game. This flag can also be set di A flag to indicate whether you have completed the game. -**Kidgame** _(files only)_ +**Kidgame** -A flag to mark whether the game is suitable for children. This will be applied as a filter when starting ES-DE in _Kid_ mode. +A flag to mark whether the game is suitable for children. This will be applied as a filter when starting ES-DE in _Kid_ mode. Although it's possible to also set this flag for folders, this will **not** affect the actual files inside those folders. It will instead only be used to display the Kidgame badge for the folders themselves. **Hidden** @@ -1462,12 +1476,16 @@ Whether to exclude the file from the multi-scraper. This is quite useful in orde **Hide metadata fields** -This option will hide most metadata fields in the gamelist view. The intention is to be able to hide the fields for situations such as general folders (Multi-disc, Cartridges etc.) and for setup programs and similar (e.g. SETUP.EXE or INSTALL.BAT for DOS games). It could also be used on the game files for multi-disc games where perhaps only the .m3u playlist should have any metadata values. The only fields shown with this option enabled are the game name and description. Using the description it's possible to write some comments regarding the file or folder, should you want to. It's also possible to display game images and videos with this setting enabled. +This option will hide most metadata fields as well as any badges. The intention is to be able to hide the fields for situations such as general folders (Multi-disc, Cartridges etc.) and for setup programs and similar (e.g. SETUP.EXE or INSTALL.BAT for DOS games). It could also be used on the game files for multi-disc games where perhaps only the .m3u playlist should have any metadata values. The only fields shown with this option enabled are the game name and description. Using the description it's possible to write some comments regarding the file or folder, should you want to. It's also possible to display game images and videos with this setting enabled. **Times played** _(files only)_ A statistics counter that tracks how many times you have played the game. You normally don't need to touch this, but if you want to, the possibility is there. +**Controller badge** + +This entry provides a selection of controller icons that are built into ES-DE (although the theme set can override the actual graphics files). The selected icon will be displayed as a badge if the current theme set support badges. This functionality is only cosmetic and will not affect the actual emulators. + **Alternative emulator** _(files only)_ If the option _Enable alternative emulators per game_ has been enabled, there will be an entry shown where you can select between alternative emulators for the specific game. There is a similar _Alternative emulators_ entry under the _Other settings_ menu, but that will apply the selection to the entire game system. If you select an alternative for a specific game using the metadata editor, that will take precedence and override any system-wide emulator selection (the currently selected system-wide emulator will be clearly marked on the selection screen). The alternative emulators need to be defined in the es_systems.xml file, and if there are no alternatives available for the current system, this row in the metadata editor will be grayed out. If you select an alternative emulator and later remove its corresponding entry from the es_systems.xml file, an error notice will be shown on this row. In this case you have the option to remove the invalid entry. But even if there is an invalid entry, games will still launch using the default emulator while logging a warning message to the es_log.txt file. Apart from this, the emulator selection should hopefully be self-explanatory. diff --git a/es-app/src/FileFilterIndex.cpp b/es-app/src/FileFilterIndex.cpp index 20063dea8..ec4384c18 100644 --- a/es-app/src/FileFilterIndex.cpp +++ b/es-app/src/FileFilterIndex.cpp @@ -33,6 +33,7 @@ FileFilterIndex::FileFilterIndex() , mFilterByKidGame(false) , mFilterByHidden(false) , mFilterByBroken(false) + , mFilterByController(false) , mFilterByAltemulator(false) { clearAllFilters(); @@ -50,6 +51,7 @@ FileFilterIndex::FileFilterIndex() {KIDGAME_FILTER, &mKidGameIndexAllKeys, &mFilterByKidGame, &mKidGameIndexFilteredKeys, "kidgame", false, "", "KIDGAME"}, {HIDDEN_FILTER, &mHiddenIndexAllKeys, &mFilterByHidden, &mHiddenIndexFilteredKeys, "hidden", false, "", "HIDDEN"}, {BROKEN_FILTER, &mBrokenIndexAllKeys, &mFilterByBroken, &mBrokenIndexFilteredKeys, "broken", false, "", "BROKEN"}, + {CONTROLLER_FILTER, &mControllerIndexAllKeys, &mFilterByController, &mControllerIndexFilteredKeys, "controller", false, "", "CONTROLLER BADGE"}, {ALTEMULATOR_FILTER, &mAltemulatorIndexAllKeys, &mFilterByAltemulator, &mAltemulatorIndexFilteredKeys, "altemulator", false, "", "ALTERNATIVE EMULATOR"} }; // clang-format on @@ -82,6 +84,7 @@ void FileFilterIndex::importIndex(FileFilterIndex* indexToImport) {&mKidGameIndexAllKeys, &(indexToImport->mKidGameIndexAllKeys)}, {&mHiddenIndexAllKeys, &(indexToImport->mHiddenIndexAllKeys)}, {&mBrokenIndexAllKeys, &(indexToImport->mBrokenIndexAllKeys)}, + {&mControllerIndexAllKeys, &(indexToImport->mControllerIndexAllKeys)}, {&mAltemulatorIndexAllKeys, &(indexToImport->mAltemulatorIndexAllKeys)}, }; @@ -119,6 +122,7 @@ void FileFilterIndex::resetIndex() clearIndex(mKidGameIndexAllKeys); clearIndex(mHiddenIndexAllKeys); clearIndex(mBrokenIndexAllKeys); + clearIndex(mControllerIndexAllKeys); clearIndex(mAltemulatorIndexAllKeys); } @@ -215,6 +219,12 @@ std::string FileFilterIndex::getIndexableKey(FileData* game, key = Utils::String::toUpper(game->metadata.get("broken")); break; } + case CONTROLLER_FILTER: { + if (getSecondary) + break; + key = Utils::String::toUpper(game->metadata.get("controller")); + break; + } case ALTEMULATOR_FILTER: { if (getSecondary) break; @@ -231,8 +241,8 @@ std::string FileFilterIndex::getIndexableKey(FileData* game, type == PUBLISHER_FILTER) && Utils::String::toUpper(key) == UNKNOWN_LABEL) key = ViewController::CROSSEDCIRCLE_CHAR + " UNKNOWN"; - else if (type == ALTEMULATOR_FILTER && key.empty()) - key = ViewController::CROSSEDCIRCLE_CHAR + " NONE DEFINED"; + else if ((type == CONTROLLER_FILTER || type == ALTEMULATOR_FILTER) && key.empty()) + key = ViewController::CROSSEDCIRCLE_CHAR + " NONE SELECTED"; else if (key.empty() || (type == RATINGS_FILTER && key == "0 STARS")) key = UNKNOWN_LABEL; @@ -251,6 +261,7 @@ void FileFilterIndex::addToIndex(FileData* game) manageKidGameEntryInIndex(game); manageHiddenEntryInIndex(game); manageBrokenEntryInIndex(game); + manageControllerEntryInIndex(game); manageAltemulatorEntryInIndex(game); } @@ -266,6 +277,7 @@ void FileFilterIndex::removeFromIndex(FileData* game) manageKidGameEntryInIndex(game, true); manageHiddenEntryInIndex(game, true); manageBrokenEntryInIndex(game, true); + manageControllerEntryInIndex(game, true); manageAltemulatorEntryInIndex(game, true); } @@ -365,6 +377,9 @@ void FileFilterIndex::debugPrintIndexes() for (auto x : mBrokenIndexAllKeys) { LOG(LogInfo) << "Broken Index: " << x.first << ": " << x.second; } + for (auto x : mControllerIndexAllKeys) { + LOG(LogInfo) << "Controller Index: " << x.first << ": " << x.second; + } for (auto x : mAltemulatorIndexAllKeys) { LOG(LogInfo) << "Altemulator Index: " << x.first << ": " << x.second; } @@ -444,28 +459,29 @@ bool FileFilterIndex::isFiltered() if (UIModeController::getInstance()->isUIModeKid()) { return (mFilterByText || mFilterByRatings || mFilterByDeveloper || mFilterByPublisher || mFilterByGenre || mFilterByPlayers || mFilterByFavorites || mFilterByCompleted || - mFilterByHidden || mFilterByBroken || mFilterByAltemulator); + mFilterByHidden || mFilterByBroken || mFilterByController || mFilterByAltemulator); } else { return (mFilterByText || mFilterByRatings || mFilterByDeveloper || mFilterByPublisher || mFilterByGenre || mFilterByPlayers || mFilterByFavorites || mFilterByCompleted || - mFilterByKidGame || mFilterByHidden || mFilterByBroken || mFilterByAltemulator); + mFilterByKidGame || mFilterByHidden || mFilterByBroken || mFilterByController || + mFilterByAltemulator); } } bool FileFilterIndex::isKeyBeingFilteredBy(std::string key, FilterIndexType type) { - const FilterIndexType filterTypes[11] = {RATINGS_FILTER, DEVELOPER_FILTER, PUBLISHER_FILTER, - GENRE_FILTER, PLAYER_FILTER, FAVORITES_FILTER, - COMPLETED_FILTER, KIDGAME_FILTER, HIDDEN_FILTER, - BROKEN_FILTER, ALTEMULATOR_FILTER}; - std::vector filterKeysList[11] = { + const FilterIndexType filterTypes[12] = { + RATINGS_FILTER, DEVELOPER_FILTER, PUBLISHER_FILTER, GENRE_FILTER, + PLAYER_FILTER, FAVORITES_FILTER, COMPLETED_FILTER, KIDGAME_FILTER, + HIDDEN_FILTER, BROKEN_FILTER, CONTROLLER_FILTER, ALTEMULATOR_FILTER}; + std::vector filterKeysList[12] = { mRatingsIndexFilteredKeys, mDeveloperIndexFilteredKeys, mPublisherIndexFilteredKeys, mGenreIndexFilteredKeys, mPlayersIndexFilteredKeys, mFavoritesIndexFilteredKeys, mCompletedIndexFilteredKeys, mKidGameIndexFilteredKeys, mHiddenIndexFilteredKeys, - mBrokenIndexFilteredKeys, mAltemulatorIndexFilteredKeys}; + mBrokenIndexFilteredKeys, mControllerIndexFilteredKeys, mAltemulatorIndexFilteredKeys}; - for (int i = 0; i < 11; i++) { + for (int i = 0; i < 12; i++) { if (filterTypes[i] == type) { for (std::vector::const_iterator it = filterKeysList[i].cbegin(); it != filterKeysList[i].cend(); it++) { @@ -611,6 +627,12 @@ void FileFilterIndex::manageBrokenEntryInIndex(FileData* game, bool remove) manageIndexEntry(&mBrokenIndexAllKeys, key, remove); } +void FileFilterIndex::manageControllerEntryInIndex(FileData* game, bool remove) +{ + std::string key = getIndexableKey(game, CONTROLLER_FILTER, false); + manageIndexEntry(&mControllerIndexAllKeys, key, remove); +} + void FileFilterIndex::manageAltemulatorEntryInIndex(FileData* game, bool remove) { std::string key = getIndexableKey(game, ALTEMULATOR_FILTER, false); diff --git a/es-app/src/FileFilterIndex.h b/es-app/src/FileFilterIndex.h index d4d744a7f..975c58432 100644 --- a/es-app/src/FileFilterIndex.h +++ b/es-app/src/FileFilterIndex.h @@ -31,6 +31,7 @@ enum FilterIndexType { KIDGAME_FILTER, HIDDEN_FILTER, BROKEN_FILTER, + CONTROLLER_FILTER, ALTEMULATOR_FILTER }; @@ -82,6 +83,7 @@ private: void manageKidGameEntryInIndex(FileData* game, bool remove = false); void manageHiddenEntryInIndex(FileData* game, bool remove = false); void manageBrokenEntryInIndex(FileData* game, bool remove = false); + void manageControllerEntryInIndex(FileData* game, bool remove = false); void manageAltemulatorEntryInIndex(FileData* game, bool remove = false); void manageIndexEntry(std::map* index, std::string key, bool remove); @@ -102,6 +104,7 @@ private: bool mFilterByKidGame; bool mFilterByHidden; bool mFilterByBroken; + bool mFilterByController; bool mFilterByAltemulator; std::map mRatingsIndexAllKeys; @@ -114,6 +117,7 @@ private: std::map mKidGameIndexAllKeys; std::map mHiddenIndexAllKeys; std::map mBrokenIndexAllKeys; + std::map mControllerIndexAllKeys; std::map mAltemulatorIndexAllKeys; std::vector mRatingsIndexFilteredKeys; @@ -126,6 +130,7 @@ private: std::vector mKidGameIndexFilteredKeys; std::vector mHiddenIndexFilteredKeys; std::vector mBrokenIndexFilteredKeys; + std::vector mControllerIndexFilteredKeys; std::vector mAltemulatorIndexFilteredKeys; }; diff --git a/es-app/src/MetaData.cpp b/es-app/src/MetaData.cpp index 18b3557bb..1dc7a10e1 100644 --- a/es-app/src/MetaData.cpp +++ b/es-app/src/MetaData.cpp @@ -37,26 +37,29 @@ MetaDataDecl gameDecls[] = { {"nomultiscrape", MD_BOOL, "false", false, "exclude from multi-scraper", "enter no multi-scrape off/on", false}, {"hidemetadata", MD_BOOL, "false", false, "hide metadata fields", "enter hide metadata off/on", false}, {"playcount", MD_INT, "0", false, "times played", "enter number of times played", false}, +{"controller", MD_CONTROLLER, "", false, "controller badge", "select controller badge", false}, {"altemulator", MD_ALT_EMULATOR, "", false, "alternative emulator", "select alternative emulator", false}, {"lastplayed", MD_TIME, "0", true, "last played", "enter last played date", false} }; MetaDataDecl folderDecls[] = { -{"name", MD_STRING, "", false, "name", "enter name", true}, -{"desc", MD_MULTILINE_STRING, "", false, "description", "enter description", true}, -{"rating", MD_RATING, "0", false, "rating", "enter rating", true}, -{"releasedate", MD_DATE, "19700101T010000", false, "release date", "enter release date", true}, -{"developer", MD_STRING, "unknown", false, "developer", "enter developer", true}, -{"publisher", MD_STRING, "unknown", false, "publisher", "enter publisher", true}, -{"genre", MD_STRING, "unknown", false, "genre", "enter genre", true}, -{"players", MD_STRING, "unknown", false, "players", "enter number of players", true}, -{"favorite", MD_BOOL, "false", false, "favorite", "enter favorite off/on", false}, -{"completed", MD_BOOL, "false", false, "completed", "enter completed off/on", false}, -{"hidden", MD_BOOL, "false", false, "hidden", "enter hidden off/on", false}, -{"broken", MD_BOOL, "false", false, "broken/not working", "enter broken off/on", false}, -{"nomultiscrape", MD_BOOL, "false", false, "exclude from multi-scraper", "enter no multi-scrape off/on", false}, -{"hidemetadata", MD_BOOL, "false", false, "hide metadata fields", "enter hide metadata off/on", false}, -{"lastplayed", MD_TIME, "0", true, "last played", "enter last played date", false} +{"name", MD_STRING, "", false, "name", "enter name", true}, +{"desc", MD_MULTILINE_STRING, "", false, "description", "enter description", true}, +{"rating", MD_RATING, "0", false, "rating", "enter rating", true}, +{"releasedate", MD_DATE, "19700101T010000", false, "release date", "enter release date", true}, +{"developer", MD_STRING, "unknown", false, "developer", "enter developer", true}, +{"publisher", MD_STRING, "unknown", false, "publisher", "enter publisher", true}, +{"genre", MD_STRING, "unknown", false, "genre", "enter genre", true}, +{"players", MD_STRING, "unknown", false, "players", "enter number of players", true}, +{"favorite", MD_BOOL, "false", false, "favorite", "enter favorite off/on", false}, +{"completed", MD_BOOL, "false", false, "completed", "enter completed off/on", false}, +{"kidgame", MD_BOOL, "false", false, "kidgame (only affects badges)", "enter kidgame off/on", false}, +{"hidden", MD_BOOL, "false", false, "hidden", "enter hidden off/on", false}, +{"broken", MD_BOOL, "false", false, "broken/not working", "enter broken off/on", false}, +{"nomultiscrape", MD_BOOL, "false", false, "exclude from multi-scraper", "enter no multi-scrape off/on", false}, +{"hidemetadata", MD_BOOL, "false", false, "hide metadata fields", "enter hide metadata off/on", false}, +{"controller", MD_CONTROLLER, "", false, "controller badge", "select controller badge", false}, +{"lastplayed", MD_TIME, "0", true, "last played", "enter last played date", false} }; // clang-format on diff --git a/es-app/src/MetaData.h b/es-app/src/MetaData.h index 8f0ac5964..e7867e9e4 100644 --- a/es-app/src/MetaData.h +++ b/es-app/src/MetaData.h @@ -32,6 +32,7 @@ enum MetaDataType { // Specialized types. MD_MULTILINE_STRING, + MD_CONTROLLER, MD_ALT_EMULATOR, MD_PATH, MD_RATING, diff --git a/es-app/src/guis/GuiAlternativeEmulators.cpp b/es-app/src/guis/GuiAlternativeEmulators.cpp index 50420a17b..e19de6ef9 100644 --- a/es-app/src/guis/GuiAlternativeEmulators.cpp +++ b/es-app/src/guis/GuiAlternativeEmulators.cpp @@ -39,13 +39,6 @@ GuiAlternativeEmulators::GuiAlternativeEmulators(Window* window) ComponentListRow row; - // This transparent bracket is only added to generate a left margin. - auto bracket = std::make_shared(mWindow); - bracket->setImage(":/graphics/arrow.svg"); - bracket->setOpacity(0); - bracket->setSize(bracket->getSize() / 3.0f); - row.addElement(bracket, false); - std::string name = (*it)->getName(); std::shared_ptr systemText = std::make_shared(mWindow, name, Font::get(FONT_SIZE_MEDIUM), 0x777777FF); @@ -94,7 +87,9 @@ GuiAlternativeEmulators::GuiAlternativeEmulators(Window* window) labelText->setColor(TEXTCOLOR_SCRAPERMARKED); mCommandRows[name] = labelText; - labelText->setSize(labelSizeX, labelText->getSize().y); + labelText->setSize(mMenu.getSize().x - systemSizeX - + 20.0f * Renderer::getScreenHeightModifier(), + systemText->getSize().y); row.addElement(labelText, false); row.makeAcceptInputHandler([this, it, labelText] { @@ -157,6 +152,7 @@ void GuiAlternativeEmulators::selectorWindow(SystemData* system) std::shared_ptr labelText = std::make_shared( mWindow, label, Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_LEFT); + labelText->setSelectable(true); if (system->getSystemEnvData()->mLaunchCommands.front().second == label) labelText->setValue(labelText->getValue().append(" [DEFAULT]")); @@ -193,13 +189,6 @@ void GuiAlternativeEmulators::selectorWindow(SystemData* system) delete s; }); - // This transparent bracket is only added to generate the correct help prompts. - auto bracket = std::make_shared(mWindow); - bracket->setImage(":/graphics/arrow.svg"); - bracket->setOpacity(0); - bracket->setSize(bracket->getSize() / 3.0f); - row.addElement(bracket, false); - // Select the row that corresponds to the selected label. if (selectedLabel == label) s->addRow(row, true); diff --git a/es-app/src/guis/GuiCollectionSystemsOptions.cpp b/es-app/src/guis/GuiCollectionSystemsOptions.cpp index 2d1e31059..fd18b1cb5 100644 --- a/es-app/src/guis/GuiCollectionSystemsOptions.cpp +++ b/es-app/src/guis/GuiCollectionSystemsOptions.cpp @@ -177,12 +177,8 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st row.makeAcceptInputHandler(createCollectionCall); auto themeFolder = std::make_shared( mWindow, Utils::String::toUpper(name), Font::get(FONT_SIZE_SMALL), 0x777777FF); + themeFolder->setSelectable(true); row.addElement(themeFolder, true); - // This transparent bracket is only added to generate the correct help prompts. - auto bracket = std::make_shared(mWindow); - bracket->setImage(":/graphics/arrow.svg"); - bracket->setOpacity(0); - row.addElement(bracket, false); ss->addRow(row); } mWindow->pushGui(ss); @@ -287,15 +283,17 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st }; row.makeAcceptInputHandler(deleteCollectionCall); auto customCollection = std::make_shared( - mWindow, Utils::String::toUpper(name), Font::get(FONT_SIZE_SMALL), 0x777777FF); + mWindow, Utils::String::toUpper(name), Font::get(FONT_SIZE_MEDIUM), 0x777777FF); + customCollection->setSelectable(true); row.addElement(customCollection, true); - // This transparent bracket is only added generate the correct help prompts. - auto bracket = std::make_shared(mWindow); - bracket->setImage(":/graphics/arrow.svg"); - bracket->setOpacity(0); - row.addElement(bracket, false); ss->addRow(row); } + // Make the menu slightly wider to fit the scroll indicators. + glm::vec2 menuSize{ss->getMenuSize()}; + glm::vec3 menuPos{ss->getMenuPosition()}; + ss->setMenuSize(glm::vec2{menuSize.x * 1.08f, menuSize.y}); + menuPos.x = static_cast((Renderer::getScreenWidth()) - ss->getMenuSize().x) / 2.0f; + ss->setMenuPosition(menuPos); mWindow->pushGui(ss); }); addRow(row); diff --git a/es-app/src/guis/GuiGameScraper.cpp b/es-app/src/guis/GuiGameScraper.cpp index 9ddc85caa..bcda1e93f 100644 --- a/es-app/src/guis/GuiGameScraper.cpp +++ b/es-app/src/guis/GuiGameScraper.cpp @@ -23,15 +23,13 @@ GuiGameScraper::GuiGameScraper(Window* window, std::function doneFunc) : GuiComponent(window) , mClose(false) - , mGrid(window, glm::ivec2{1, 7}) + , mGrid(window, glm::ivec2{2, 6}) , mBox(window, ":/graphics/frame.svg") , mSearchParams(params) { addChild(&mBox); addChild(&mGrid); - // Row 0 is a spacer. - std::string scrapeName; if (Settings::getInstance()->getBool("ScraperSearchMetadataName")) { @@ -51,21 +49,37 @@ GuiGameScraper::GuiGameScraper(Window* window, mWindow, scrapeName + ((mSearchParams.game->getType() == FOLDER) ? " " + ViewController::FOLDER_CHAR : ""), - Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_CENTER); - mGrid.setEntry(mGameName, glm::ivec2{0, 1}, false, true); - - // Row 2 is a spacer. + Font::get(FONT_SIZE_LARGE), 0x777777FF, ALIGN_CENTER); + mGameName->setColor(0x555555FF); + mGrid.setEntry(mGameName, glm::ivec2{0, 0}, false, true, glm::ivec2{2, 2}); mSystemName = std::make_shared( mWindow, Utils::String::toUpper(mSearchParams.system->getFullName()), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER); - mGrid.setEntry(mSystemName, glm::ivec2{0, 3}, false, true); + mGrid.setEntry(mSystemName, glm::ivec2{0, 2}, false, true, glm::ivec2{2, 1}); - // Row 4 is a spacer. + // Row 3 is a spacer. // GuiScraperSearch. mSearch = std::make_shared(window, GuiScraperSearch::NEVER_AUTO_ACCEPT, 1); - mGrid.setEntry(mSearch, glm::ivec2{0, 5}, true); + mGrid.setEntry(mSearch, glm::ivec2{0, 4}, true, true, glm::ivec2{2, 1}); + + mResultList = mSearch->getResultList(); + + // Set up scroll indicators. + mScrollUp = std::make_shared(mWindow); + mScrollDown = std::make_shared(mWindow); + mScrollIndicator = + std::make_shared(mResultList, mScrollUp, mScrollDown); + + mScrollUp->setResize(0.0f, mGameName->getFont()->getLetterHeight() / 2.0f); + mScrollUp->setOrigin(0.0f, -0.35f); + + mScrollDown->setResize(0.0f, mGameName->getFont()->getLetterHeight() / 2.0f); + mScrollDown->setOrigin(0.0f, 0.35f); + + mGrid.setEntry(mScrollUp, glm::ivec2{1, 0}, false, false, glm::ivec2{1, 1}); + mGrid.setEntry(mScrollDown, glm::ivec2{1, 1}, false, false, glm::ivec2{1, 1}); // Buttons std::vector> buttons; @@ -74,6 +88,9 @@ GuiGameScraper::GuiGameScraper(Window* window, std::make_shared(mWindow, "REFINE SEARCH", "refine search", [&] { // Refine the search, unless the result has already been accepted. if (!mSearch->getAcceptedResult()) { + // Copy any search refine that may have been previously entered by opening + // the input screen using the "Y" button shortcut. + mSearchParams.nameOverride = mSearch->getNameOverride(); mSearch->openInputScreen(mSearchParams); mGrid.resetCursor(); } @@ -92,20 +109,34 @@ GuiGameScraper::GuiGameScraper(Window* window, })); mButtonGrid = makeButtonGrid(mWindow, buttons); - mGrid.setEntry(mButtonGrid, glm::ivec2{0, 6}, true, false); + mGrid.setEntry(mButtonGrid, glm::ivec2{0, 5}, true, false, glm::ivec2{2, 1}); mSearch->setAcceptCallback([this, doneFunc](const ScraperSearchResult& result) { doneFunc(result); close(); }); mSearch->setCancelCallback([&] { delete this; }); + mSearch->setRefineCallback([&] { + mScrollUp->setOpacity(0); + mScrollDown->setOpacity(0); + mResultList->resetScrollIndicatorStatus(); + }); // Limit the width of the GUI on ultrawide monitors. The 1.778 aspect ratio value is // the 16:9 reference. float aspectValue = 1.778f / Renderer::getScreenAspectRatio(); float width = glm::clamp(0.95f * aspectValue, 0.70f, 0.95f) * Renderer::getScreenWidth(); - setSize(width, Renderer::getScreenHeight() * 0.747f); + float height = (mGameName->getFont()->getLetterHeight() + + static_cast(Renderer::getScreenHeight()) * 0.0637f) + + mSystemName->getFont()->getLetterHeight() + + static_cast(Renderer::getScreenHeight()) * 0.04f + + mButtonGrid->getSize().y + Font::get(FONT_SIZE_MEDIUM)->getHeight() * 8.0f; + + // TODO: Temporary hack, see below. + height -= 7.0f * Renderer::getScreenHeightModifier(); + + setSize(width, height); setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f, (Renderer::getScreenHeight() - mSize.y) / 2.0f); @@ -115,15 +146,31 @@ GuiGameScraper::GuiGameScraper(Window* window, void GuiGameScraper::onSizeChanged() { + mGrid.setRowHeightPerc( + 0, (mGameName->getFont()->getLetterHeight() + Renderer::getScreenHeight() * 0.0637f) / + mSize.y / 2.0f); + mGrid.setRowHeightPerc( + 1, (mGameName->getFont()->getLetterHeight() + Renderer::getScreenHeight() * 0.0637f) / + mSize.y / 2.0f); + mGrid.setRowHeightPerc(2, mSystemName->getFont()->getLetterHeight() / mSize.y, false); + mGrid.setRowHeightPerc(3, 0.04f, false); + mGrid.setRowHeightPerc(4, ((Font::get(FONT_SIZE_MEDIUM)->getHeight() * 8.0f)) / mSize.y, false); + + // TODO: Replace this temporary hack with a proper solution. There is some kind of rounding + // issue somewhere that causes a small alignment error. This code partly compensates for this + // at higher resolutions than 1920x1080. + if (Renderer::getScreenHeightModifier() > 1.0f) + mSize.y -= 3.0f * Renderer::getScreenHeightModifier(); + + mGrid.setColWidthPerc(1, 0.04f); + + mGrid.setSize(mSize); mBox.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f}); - mGrid.setRowHeightPerc(0, 0.04f, false); - mGrid.setRowHeightPerc(1, mGameName->getFont()->getLetterHeight() / mSize.y, false); - mGrid.setRowHeightPerc(2, 0.04f, false); - mGrid.setRowHeightPerc(3, mSystemName->getFont()->getLetterHeight() / mSize.y, false); - mGrid.setRowHeightPerc(4, 0.04f, false); - mGrid.setRowHeightPerc(6, mButtonGrid->getSize().y / mSize.y, false); - mGrid.setSize(mSize); + // Add some extra margins to the game name. + const float newSizeX = mSize.x * 0.96f; + mGameName->setSize(newSizeX, mGameName->getSize().y); + mGameName->setPosition((mSize.x - newSizeX) / 2.0f, 0.0f); } bool GuiGameScraper::input(InputConfig* config, Input input) diff --git a/es-app/src/guis/GuiGameScraper.h b/es-app/src/guis/GuiGameScraper.h index b910c1351..040f1e072 100644 --- a/es-app/src/guis/GuiGameScraper.h +++ b/es-app/src/guis/GuiGameScraper.h @@ -13,6 +13,7 @@ #include "GuiComponent.h" #include "components/NinePatchComponent.h" +#include "components/ScrollIndicatorComponent.h" #include "guis/GuiScraperSearch.h" class GuiGameScraper : public GuiComponent @@ -38,9 +39,13 @@ private: NinePatchComponent mBox; std::shared_ptr mGameName; + std::shared_ptr mScrollUp; + std::shared_ptr mScrollDown; + std::shared_ptr mScrollIndicator; std::shared_ptr mSystemName; std::shared_ptr mSearch; std::shared_ptr mButtonGrid; + std::shared_ptr mResultList; ScraperSearchParams mSearchParams; diff --git a/es-app/src/guis/GuiGamelistFilter.cpp b/es-app/src/guis/GuiGamelistFilter.cpp index 6feda35e7..7721e38bf 100644 --- a/es-app/src/guis/GuiGamelistFilter.cpp +++ b/es-app/src/guis/GuiGamelistFilter.cpp @@ -11,9 +11,11 @@ #include "guis/GuiGamelistFilter.h" #include "SystemData.h" +#include "components/BadgeComponent.h" #include "components/OptionListComponent.h" #include "guis/GuiTextEditKeyboardPopup.h" #include "guis/GuiTextEditPopup.h" +#include "utils/StringUtil.h" #include "views/UIModeController.h" #include "views/ViewController.h" @@ -185,8 +187,21 @@ void GuiGamelistFilter::addFiltersToMenu() optionList->setOverrideMultiText("NOTHING TO FILTER"); } - for (auto it : *allKeys) - optionList->add(it.first, it.first, mFilterIndex->isKeyBeingFilteredBy(it.first, type)); + if (type == CONTROLLER_FILTER) { + for (auto it : *allKeys) { + std::string displayName = + BadgeComponent::getDisplayName(Utils::String::toLower(it.first)); + if (displayName == "unknown") + displayName = it.first; + optionList->add(displayName, it.first, + mFilterIndex->isKeyBeingFilteredBy(it.first, type)); + } + } + else { + for (auto it : *allKeys) + optionList->add(it.first, it.first, + mFilterIndex->isKeyBeingFilteredBy(it.first, type)); + } if (allKeys->size() == 0) optionList->add("", "", false); diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index 74f707d68..ebcfee71a 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -61,7 +61,7 @@ GuiMenu::GuiMenu(Window* window) if (isFullUI) addEntry("OTHER SETTINGS", 0x777777FF, true, [this] { openOtherOptions(); }); - // TEMPORARY - disabled for now, will be used in the future. + // TEMPORARY: Disabled for now, will be used in the future. // if (isFullUI) // addEntry("UTILITIES", 0x777777FF, true, [this] { // openUtilitiesMenu(); }); @@ -593,6 +593,7 @@ void GuiMenu::openUIOptions() } }); + s->setSize(mSize); mWindow->pushGui(s); } @@ -600,8 +601,8 @@ void GuiMenu::openSoundOptions() { auto s = new GuiSettings(mWindow, "SOUND SETTINGS"); -// TEMPORARY - Hide the volume slider on macOS and BSD Unix until the volume control logic -// has been implemented for these operating systems. +// TODO: Hide the volume slider on macOS and BSD Unix until the volume control logic has been +// implemented for these operating systems. #if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) // System volume. auto system_volume = std::make_shared(mWindow, 0.f, 100.f, 1.f, "%"); @@ -700,6 +701,7 @@ void GuiMenu::openSoundOptions() }); } + s->setSize(mSize); mWindow->pushGui(s); } @@ -756,6 +758,7 @@ void GuiMenu::openInputDeviceOptions() configure_input_row.makeAcceptInputHandler(std::bind(&GuiMenu::openConfigInput, this, s)); s->addRow(configure_input_row); + s->setSize(mSize); mWindow->pushGui(s); } @@ -1043,6 +1046,17 @@ void GuiMenu::openOtherOptions() } }); + // Whether to preload the gamelists on application startup. + auto preloadGamelists = std::make_shared(mWindow); + preloadGamelists->setState(Settings::getInstance()->getBool("PreloadGamelists")); + s->addWithLabel("PRELOAD GAMELISTS ON STARTUP", preloadGamelists); + s->addSaveFunc([preloadGamelists, s] { + if (preloadGamelists->getState() != Settings::getInstance()->getBool("PreloadGamelists")) { + Settings::getInstance()->setBool("PreloadGamelists", preloadGamelists->getState()); + s->setNeedsSaving(); + } + }); + // Whether to enable alternative emulators per game (the option to disable this is intended // primarily for testing purposes). auto alternativeEmulatorPerGame = std::make_shared(mWindow); @@ -1180,12 +1194,14 @@ void GuiMenu::openOtherOptions() run_in_background->setCallback(launchWorkaroundToggleFunc); #endif + s->setSize(mSize); mWindow->pushGui(s); } void GuiMenu::openUtilitiesMenu() { auto s = new GuiSettings(mWindow, "UTILITIES"); + s->setSize(mSize); mWindow->pushGui(s); } @@ -1207,11 +1223,6 @@ void GuiMenu::openQuitMenu() Window* window = mWindow; HelpStyle style = getHelpStyle(); - // This transparent bracket is only neeeded to generate the correct help prompts. - auto bracket = std::make_shared(mWindow); - bracket->setImage(":/graphics/arrow.svg"); - bracket->setOpacity(0); - ComponentListRow row; row.makeAcceptInputHandler([window, this] { @@ -1224,10 +1235,10 @@ void GuiMenu::openQuitMenu() }, "NO", nullptr)); }); - row.addElement(std::make_shared(window, "QUIT EMULATIONSTATION", - Font::get(FONT_SIZE_MEDIUM), 0x777777FF), - true); - row.addElement(bracket, false); + auto quitText = std::make_shared(window, "QUIT EMULATIONSTATION", + Font::get(FONT_SIZE_MEDIUM), 0x777777FF); + quitText->setSelectable(true); + row.addElement(quitText, true); s->addRow(row); row.elements.clear(); @@ -1243,10 +1254,10 @@ void GuiMenu::openQuitMenu() }, "NO", nullptr)); }); - row.addElement(std::make_shared(window, "REBOOT SYSTEM", - Font::get(FONT_SIZE_MEDIUM), 0x777777FF), - true); - row.addElement(bracket, false); + auto rebootText = std::make_shared(window, "REBOOT SYSTEM", + Font::get(FONT_SIZE_MEDIUM), 0x777777FF); + rebootText->setSelectable(true); + row.addElement(rebootText, true); s->addRow(row); row.elements.clear(); @@ -1262,12 +1273,13 @@ void GuiMenu::openQuitMenu() }, "NO", nullptr)); }); - row.addElement(std::make_shared(window, "POWER OFF SYSTEM", - Font::get(FONT_SIZE_MEDIUM), 0x777777FF), - true); - row.addElement(bracket, false); + auto powerOffText = std::make_shared( + window, "POWER OFF SYSTEM", Font::get(FONT_SIZE_MEDIUM), 0x777777FF); + powerOffText->setSelectable(true); + row.addElement(powerOffText, true); s->addRow(row); + s->setSize(mSize); mWindow->pushGui(s); } } diff --git a/es-app/src/guis/GuiMetaDataEd.cpp b/es-app/src/guis/GuiMetaDataEd.cpp index ced319e6c..02d713c42 100644 --- a/es-app/src/guis/GuiMetaDataEd.cpp +++ b/es-app/src/guis/GuiMetaDataEd.cpp @@ -43,7 +43,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, std::function deleteGameFunc) : GuiComponent{window} , mBackground{window, ":/graphics/frame.svg"} - , mGrid{window, glm::ivec2{3, 6}} + , mGrid{window, glm::ivec2{2, 6}} , mScraperParams{scraperParams} , mMetaDataDecl{mdd} , mMetaData{md} @@ -53,12 +53,18 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, , mMediaFilesUpdated{false} , mInvalidEmulatorEntry{false} { + mControllerBadges = BadgeComponent::getGameControllers(); + + // Remove the last "unknown" controller entry. + if (mControllerBadges.size() > 1) + mControllerBadges.pop_back(); + addChild(&mBackground); addChild(&mGrid); mTitle = std::make_shared(mWindow, "EDIT METADATA", Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); - mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true, glm::ivec2{3, 2}); + mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true, glm::ivec2{2, 2}); // Extract possible subfolders from the path. std::string folderPath = @@ -80,13 +86,12 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, folderPath + Utils::FileSystem::getFileName(scraperParams.game->getPath()) + " [" + Utils::String::toUpper(scraperParams.system->getName()) + "]" + (scraperParams.game->getType() == FOLDER ? " " + ViewController::FOLDER_CHAR : ""), - Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER, glm::vec3{}, glm::vec2{}, 0x00000000, - 0.05f); + Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER); - mGrid.setEntry(mSubtitle, glm::ivec2{0, 2}, false, true, glm::ivec2{3, 1}); + mGrid.setEntry(mSubtitle, glm::ivec2{0, 2}, false, true, glm::ivec2{2, 1}); mList = std::make_shared(mWindow); - mGrid.setEntry(mList, glm::ivec2{0, 4}, true, true, glm::ivec2{3, 1}); + mGrid.setEntry(mList, glm::ivec2{0, 4}, true, true, glm::ivec2{2, 1}); // Set up scroll indicators. mScrollUp = std::make_shared(mWindow); @@ -99,8 +104,8 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, 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}); + mGrid.setEntry(mScrollUp, glm::ivec2{1, 0}, false, false, glm::ivec2{1, 1}); + mGrid.setEntry(mScrollDown, glm::ivec2{1, 1}, false, false, glm::ivec2{1, 1}); // Populate list. for (auto iter = mdd.cbegin(); iter != mdd.cend(); iter++) { @@ -138,8 +143,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, ed = std::make_shared(window); // Make the switches slightly smaller. glm::vec2 switchSize{ed->getSize() * 0.9f}; - ed->setResize(switchSize.x, switchSize.y); - ed->setOrigin(-0.05f, -0.09f); + ed->setResize(ceilf(switchSize.x), switchSize.y); ed->setChangedColor(ICONCOLOR_USERMARKED); row.addElement(ed, false, true); @@ -176,6 +180,88 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, std::placeholders::_2); break; } + case MD_CONTROLLER: { + ed = std::make_shared(window, "", + Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT), + 0x777777FF, ALIGN_RIGHT); + row.addElement(ed, true); + + auto spacer = std::make_shared(mWindow); + spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0.0f); + row.addElement(spacer, false); + + auto bracket = std::make_shared(mWindow); + bracket->setImage(":/graphics/arrow.svg"); + bracket->setResize(glm::vec2{0.0f, lbl->getFont()->getLetterHeight()}); + row.addElement(bracket, false); + + const std::string title = iter->displayPrompt; + + // OK callback (apply new value to ed). + auto updateVal = [ed, originalValue](const std::string& newVal) { + ed->setValue(newVal); + if (newVal == BadgeComponent::getDisplayName(originalValue)) + ed->setColor(DEFAULT_TEXTCOLOR); + else + ed->setColor(TEXTCOLOR_USERMARKED); + }; + + row.makeAcceptInputHandler([this, title, ed, updateVal] { + GuiSettings* s = new GuiSettings(mWindow, title); + + for (auto controller : mControllerBadges) { + std::string selectedLabel = ed->getValue(); + std::string label; + ComponentListRow row; + + std::shared_ptr labelText = std::make_shared( + mWindow, label, Font::get(FONT_SIZE_MEDIUM), 0x777777FF); + labelText->setSelectable(true); + labelText->setValue(controller.displayName); + + label = controller.displayName; + + row.addElement(labelText, true); + + row.makeAcceptInputHandler([s, updateVal, controller] { + updateVal(controller.displayName); + delete s; + }); + + // Select the row that corresponds to the selected label. + if (selectedLabel == label) + s->addRow(row, true); + else + s->addRow(row, false); + } + + // If a value is set, then display "Clear entry" as the last entry. + if (ed->getValue() != "") { + ComponentListRow row; + std::shared_ptr clearText = std::make_shared( + mWindow, ViewController::CROSSEDCIRCLE_CHAR + " CLEAR ENTRY", + Font::get(FONT_SIZE_MEDIUM), 0x777777FF); + clearText->setSelectable(true); + row.addElement(clearText, true); + row.makeAcceptInputHandler([s, ed] { + ed->setValue(""); + delete s; + }); + s->addRow(row, false); + } + + float aspectValue = 1.778f / Renderer::getScreenAspectRatio(); + float maxWidthModifier = glm::clamp(0.64f * aspectValue, 0.42f, 0.92f); + float maxWidth = + static_cast(Renderer::getScreenWidth()) * maxWidthModifier; + + s->setMenuSize(glm::vec2{maxWidth, s->getMenuSize().y}); + s->setMenuPosition( + glm::vec3{(s->getSize().x - maxWidth) / 2.0f, mPosition.y, mPosition.z}); + mWindow->pushGui(s); + }); + break; + } case MD_ALT_EMULATOR: { mInvalidEmulatorEntry = false; @@ -248,6 +334,11 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, "", ViewController::CROSSEDCIRCLE_CHAR + " CLEAR ENTRY")); for (auto entry : launchCommands) { + if (mInvalidEmulatorEntry && singleEntry && + entry.second != + ViewController::EXCLAMATION_CHAR + " " + originalValue) + continue; + std::string selectedLabel = ed->getValue(); std::string label; ComponentListRow row; @@ -260,6 +351,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, std::shared_ptr labelText = std::make_shared( mWindow, label, Font::get(FONT_SIZE_MEDIUM), 0x777777FF); + labelText->setSelectable(true); if (scraperParams.system->getAlternativeEmulator() == "" && scraperParams.system->getSystemEnvData() @@ -284,14 +376,6 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, delete s; }); - // This transparent bracket is only added to generate the correct help - // prompts. - auto bracket = std::make_shared(mWindow); - bracket->setImage(":/graphics/arrow.svg"); - bracket->setOpacity(0); - bracket->setSize(bracket->getSize() / 3.0f); - row.addElement(bracket, false); - // Select the row that corresponds to the selected label. if (selectedLabel == label) s->addRow(row, true); @@ -299,23 +383,14 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, s->addRow(row, false); } - // Adjust the width depending on the aspect ratio of the screen, to make the - // screen look somewhat coherent regardless of screen type. The 1.778 aspect - // ratio value is the 16:9 reference. float aspectValue = 1.778f / Renderer::getScreenAspectRatio(); - float maxWidthModifier = glm::clamp(0.64f * aspectValue, 0.42f, 0.92f); float maxWidth = static_cast(Renderer::getScreenWidth()) * maxWidthModifier; s->setMenuSize(glm::vec2{maxWidth, s->getMenuSize().y}); - - auto menuSize = s->getMenuSize(); - auto menuPos = s->getMenuPosition(); - - s->setMenuPosition(glm::vec3{(s->getSize().x - menuSize.x) / 2.0f, - (s->getSize().y - menuSize.y) / 3.0f, - menuPos.z}); + s->setMenuPosition(glm::vec3{(s->getSize().x - maxWidth) / 2.0f, + mPosition.y, mPosition.z}); mWindow->pushGui(s); }); } @@ -398,10 +473,19 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, assert(ed); mList->addRow(row); - if (iter->type == MD_ALT_EMULATOR && mInvalidEmulatorEntry == true) + if (iter->type == MD_ALT_EMULATOR && mInvalidEmulatorEntry == true) { ed->setValue(ViewController::EXCLAMATION_CHAR + " " + originalValue); - else + } + else if (iter->type == MD_CONTROLLER && mMetaData->get(iter->key) != "") { + std::string displayName = BadgeComponent::getDisplayName(mMetaData->get(iter->key)); + if (displayName != "unknown") + ed->setValue(displayName); + else + ed->setValue(ViewController::EXCLAMATION_CHAR + " " + mMetaData->get(iter->key)); + } + else { ed->setValue(mMetaData->get(iter->key)); + } mEditors.push_back(ed); } @@ -476,7 +560,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, } mButtons = makeButtonGrid(mWindow, buttons); - mGrid.setEntry(mButtons, glm::ivec2{0, 5}, true, false, glm::ivec2{3, 1}); + mGrid.setEntry(mButtons, glm::ivec2{0, 5}, true, false, glm::ivec2{2, 1}); // Resize + center. float width = @@ -500,14 +584,18 @@ void GuiMetaDataEd::onSizeChanged() mGrid.setRowHeightPerc(3, (titleSubtitleSpacing * 1.2f) / mSize.y); mGrid.setRowHeightPerc(4, ((mList->getRowHeight(0) * 10.0f) + 2.0f) / mSize.y); - mGrid.setColWidthPerc(0, 0.07f); - mGrid.setColWidthPerc(2, 0.07f); + mGrid.setColWidthPerc(1, 0.055f); mGrid.setSize(mSize); mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f}); setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f, (Renderer::getScreenHeight() - mSize.y) / 2.0f); + + // Add some extra margins to the file/folder name. + const float newSizeX = mSize.x * 0.96f; + mSubtitle->setSize(newSizeX, mSubtitle->getSize().y); + mSubtitle->setPosition((mSize.x - newSizeX) / 2.0f, mSubtitle->getPosition().y); } void GuiMetaDataEd::save() @@ -528,6 +616,13 @@ void GuiMetaDataEd::save() if (mMetaDataDecl.at(i).key == "altemulator" && mInvalidEmulatorEntry == true) continue; + if (mMetaDataDecl.at(i).key == "controller" && mEditors.at(i)->getValue() != "") { + std::string shortName = BadgeComponent::getShortName(mEditors.at(i)->getValue()); + if (shortName != "unknown") + mMetaData->set(mMetaDataDecl.at(i).key, shortName); + continue; + } + if (!showHiddenGames && mMetaDataDecl.at(i).key == "hidden" && mEditors.at(i)->getValue() != mMetaData->get("hidden")) hideGameWhileHidden = true; @@ -672,6 +767,12 @@ void GuiMetaDataEd::close() if (key == "altemulator" && mInvalidEmulatorEntry == true) continue; + if (mMetaDataDecl.at(i).key == "controller" && mEditors.at(i)->getValue() != "") { + std::string shortName = BadgeComponent::getShortName(mEditors.at(i)->getValue()); + if (shortName == "unknown" || mMetaDataValue == shortName) + continue; + } + if (mMetaDataValue != mEditorsValue) { metadataUpdated = true; break; diff --git a/es-app/src/guis/GuiMetaDataEd.h b/es-app/src/guis/GuiMetaDataEd.h index ec1793145..ec4ca13af 100644 --- a/es-app/src/guis/GuiMetaDataEd.h +++ b/es-app/src/guis/GuiMetaDataEd.h @@ -13,6 +13,7 @@ #include "GuiComponent.h" #include "MetaData.h" +#include "components/BadgeComponent.h" #include "components/ComponentGrid.h" #include "components/NinePatchComponent.h" #include "components/ScrollIndicatorComponent.h" @@ -60,6 +61,7 @@ private: ScraperSearchParams mScraperParams; + std::vector mControllerBadges; std::vector> mEditors; std::vector mMetaDataDecl; diff --git a/es-app/src/guis/GuiScraperMulti.cpp b/es-app/src/guis/GuiScraperMulti.cpp index 067352199..50b8aab67 100644 --- a/es-app/src/guis/GuiScraperMulti.cpp +++ b/es-app/src/guis/GuiScraperMulti.cpp @@ -28,7 +28,7 @@ GuiScraperMulti::GuiScraperMulti(Window* window, bool approveResults) : GuiComponent(window) , mBackground(window, ":/graphics/frame.svg") - , mGrid(window, glm::ivec2{1, 5}) + , mGrid(window, glm::ivec2{2, 6}) , mSearchQueue(searches) , mApproveResults(approveResults) { @@ -47,15 +47,15 @@ GuiScraperMulti::GuiScraperMulti(Window* window, // Set up grid. mTitle = std::make_shared(mWindow, "SCRAPING IN PROGRESS", Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); - mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true); + mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true, glm::ivec2{2, 2}); mSystem = std::make_shared(mWindow, "SYSTEM", Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_CENTER); - mGrid.setEntry(mSystem, glm::ivec2{0, 1}, false, true); + mGrid.setEntry(mSystem, glm::ivec2{0, 2}, false, true, glm::ivec2{2, 1}); mSubtitle = std::make_shared( mWindow, "subtitle text", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER); - mGrid.setEntry(mSubtitle, glm::ivec2{0, 2}, false, true); + mGrid.setEntry(mSubtitle, glm::ivec2{0, 3}, false, true, glm::ivec2{2, 1}); if (mApproveResults && !Settings::getInstance()->getBool("ScraperSemiautomatic")) mSearchComp = std::make_shared( @@ -70,10 +70,34 @@ GuiScraperMulti::GuiScraperMulti(Window* window, std::bind(&GuiScraperMulti::acceptResult, this, std::placeholders::_1)); mSearchComp->setSkipCallback(std::bind(&GuiScraperMulti::skip, this)); mSearchComp->setCancelCallback(std::bind(&GuiScraperMulti::finish, this)); - mGrid.setEntry(mSearchComp, glm::ivec2{0, 3}, - mSearchComp->getSearchType() != GuiScraperSearch::ALWAYS_ACCEPT_FIRST_RESULT, - true); + mSearchComp->setRefineCallback([&] { + mScrollUp->setOpacity(0); + mScrollDown->setOpacity(0); + mResultList->resetScrollIndicatorStatus(); + }); + mGrid.setEntry(mSearchComp, glm::ivec2{0, 4}, + mSearchComp->getSearchType() != GuiScraperSearch::ALWAYS_ACCEPT_FIRST_RESULT, + true, glm::ivec2{2, 1}); + + mResultList = mSearchComp->getResultList(); + + // Set up scroll indicators. + mScrollUp = std::make_shared(mWindow); + mScrollDown = std::make_shared(mWindow); + mScrollIndicator = + std::make_shared(mResultList, 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{1, 0}, false, false, glm::ivec2{1, 1}); + mGrid.setEntry(mScrollDown, glm::ivec2{1, 1}, false, false, glm::ivec2{1, 1}); + + // Buttons. std::vector> buttons; if (mApproveResults) { @@ -125,14 +149,23 @@ GuiScraperMulti::GuiScraperMulti(Window* window, std::bind(&GuiScraperMulti::finish, this))); mButtonGrid = makeButtonGrid(mWindow, buttons); - mGrid.setEntry(mButtonGrid, glm::ivec2{0, 4}, true, false); + mGrid.setEntry(mButtonGrid, glm::ivec2{0, 5}, true, false, glm::ivec2{2, 1}); // Limit the width of the GUI on ultrawide monitors. The 1.778 aspect ratio value is // the 16:9 reference. float aspectValue = 1.778f / Renderer::getScreenAspectRatio(); float width = glm::clamp(0.95f * aspectValue, 0.70f, 0.95f) * Renderer::getScreenWidth(); - setSize(width, Renderer::getScreenHeight() * 0.849f); + float height = (mTitle->getFont()->getLetterHeight() + + static_cast(Renderer::getScreenHeight()) * 0.0637f) + + mSystem->getFont()->getLetterHeight() + + mSubtitle->getFont()->getHeight() * 1.75f + mButtonGrid->getSize().y + + Font::get(FONT_SIZE_MEDIUM)->getHeight() * 7.0f; + + // TODO: Temporary hack, see below. + height -= 7.0f * Renderer::getScreenHeightModifier(); + + setSize(width, height); setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f, (Renderer::getScreenHeight() - mSize.y) / 2.0f); @@ -153,13 +186,26 @@ GuiScraperMulti::~GuiScraperMulti() void GuiScraperMulti::onSizeChanged() { - mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f}); + mGrid.setRowHeightPerc( + 0, (mTitle->getFont()->getLetterHeight() + Renderer::getScreenHeight() * 0.0637f) / + mSize.y / 2.0f); + mGrid.setRowHeightPerc( + 1, (mTitle->getFont()->getLetterHeight() + Renderer::getScreenHeight() * 0.0637f) / + mSize.y / 2.0f); + mGrid.setRowHeightPerc(2, (mSystem->getFont()->getLetterHeight()) / mSize.y, false); + mGrid.setRowHeightPerc(3, mSubtitle->getFont()->getHeight() * 1.75f / mSize.y, false); + mGrid.setRowHeightPerc(4, ((Font::get(FONT_SIZE_MEDIUM)->getHeight() * 7.0f)) / mSize.y, false); + + // TODO: Replace this temporary hack with a proper solution. There is some kind of rounding + // issue somewhere that causes a small alignment error. This code partly compensates for this + // at higher resolutions than 1920x1080. + if (Renderer::getScreenHeightModifier() > 1.0f) + mSize.y -= 3.0f * Renderer::getScreenHeightModifier(); + + mGrid.setColWidthPerc(1, 0.04f); - mGrid.setRowHeightPerc(0, mTitle->getFont()->getLetterHeight() * 1.9725f / mSize.y, false); - mGrid.setRowHeightPerc(1, (mSystem->getFont()->getLetterHeight() + 2.0f) / mSize.y, false); - mGrid.setRowHeightPerc(2, mSubtitle->getFont()->getHeight() * 1.75f / mSize.y, false); - mGrid.setRowHeightPerc(4, mButtonGrid->getSize().y / mSize.y, false); mGrid.setSize(mSize); + mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f}); } void GuiScraperMulti::doNextSearch() @@ -189,6 +235,10 @@ void GuiScraperMulti::doNextSearch() scrapeName = Utils::FileSystem::getFileName(mSearchQueue.front().game->getPath()); } + mScrollUp->setOpacity(0); + mScrollDown->setOpacity(0); + mResultList->resetScrollIndicatorStatus(); + // Extract possible subfolders from the path. std::string folderPath = Utils::String::replace(Utils::FileSystem::getParent(mSearchQueue.front().game->getPath()), @@ -264,9 +314,6 @@ void GuiScraperMulti::finish() std::vector GuiScraperMulti::getHelpPrompts() { std::vector prompts = mGrid.getHelpPrompts(); - // Remove the 'Choose' entry if in fully automatic mode. - if (!mApproveResults) - prompts.pop_back(); return prompts; } diff --git a/es-app/src/guis/GuiScraperMulti.h b/es-app/src/guis/GuiScraperMulti.h index 63c755f6b..d71525086 100644 --- a/es-app/src/guis/GuiScraperMulti.h +++ b/es-app/src/guis/GuiScraperMulti.h @@ -16,6 +16,7 @@ #include "MetaData.h" #include "components/ComponentGrid.h" #include "components/NinePatchComponent.h" +#include "components/ScrollIndicatorComponent.h" #include "scrapers/Scraper.h" class GuiScraperSearch; @@ -45,10 +46,14 @@ private: ComponentGrid mGrid; std::shared_ptr mTitle; + std::shared_ptr mScrollUp; + std::shared_ptr mScrollDown; + std::shared_ptr mScrollIndicator; std::shared_ptr mSystem; std::shared_ptr mSubtitle; std::shared_ptr mSearchComp; std::shared_ptr mButtonGrid; + std::shared_ptr mResultList; std::queue mSearchQueue; std::vector mMetaDataDecl; diff --git a/es-app/src/guis/GuiScraperSearch.cpp b/es-app/src/guis/GuiScraperSearch.cpp index 340eb81e2..bf7aba7b9 100644 --- a/es-app/src/guis/GuiScraperSearch.cpp +++ b/es-app/src/guis/GuiScraperSearch.cpp @@ -39,7 +39,7 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int scrapeCount) : GuiComponent(window) - , mGrid(window, glm::ivec2{4, 3}) + , mGrid(window, glm::ivec2{5, 3}) , mSearchType(type) , mScrapeCount(scrapeCount) , mRefinedSearch(false) @@ -88,14 +88,11 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int mMD_ReleaseDate = std::make_shared(mWindow); mMD_ReleaseDate->setColor(mdColor); mMD_ReleaseDate->setUppercase(true); - mMD_Developer = std::make_shared(mWindow, "", font, mdColor, ALIGN_LEFT, - glm::vec3{}, glm::vec2{}, 0x00000000, 0.02f); - mMD_Publisher = std::make_shared(mWindow, "", font, mdColor, ALIGN_LEFT, - glm::vec3{}, glm::vec2{}, 0x00000000, 0.02f); - mMD_Genre = std::make_shared(mWindow, "", font, mdColor, ALIGN_LEFT, glm::vec3{}, - glm::vec2{}, 0x00000000, 0.02f); - mMD_Players = std::make_shared(mWindow, "", font, mdColor, ALIGN_LEFT, - glm::vec3{}, glm::vec2{}, 0x00000000, 0.02f); + mMD_Developer = std::make_shared(mWindow, "", font, mdColor, ALIGN_LEFT); + mMD_Publisher = std::make_shared(mWindow, "", font, mdColor, ALIGN_LEFT); + mMD_Genre = + std::make_shared(mWindow, "", font, mdColor, ALIGN_LEFT, glm::vec3{}); + mMD_Players = std::make_shared(mWindow, "", font, mdColor, ALIGN_LEFT); mMD_Filler = std::make_shared(mWindow, "", font, mdColor); if (Settings::getInstance()->getString("Scraper") != "thegamesdb") @@ -193,45 +190,47 @@ void GuiScraperSearch::onSizeChanged() mGrid.setColWidthPerc(1, 0.25f); if (mSearchType == ALWAYS_ACCEPT_FIRST_RESULT) - mGrid.setColWidthPerc(2, 0.25f); + mGrid.setColWidthPerc(2, 0.33f); else - mGrid.setColWidthPerc(2, 0.28f); + mGrid.setColWidthPerc(2, 0.30f); // Row heights. if (mSearchType == ALWAYS_ACCEPT_FIRST_RESULT) // Show name. mGrid.setRowHeightPerc(0, (mResultName->getFont()->getHeight() * 1.6f) / mGrid.getSize().y); // Result name. else - mGrid.setRowHeightPerc(0, 0.0825f); // Hide name but do padding. + mGrid.setRowHeightPerc(0, 0.0725f); // Hide name but do padding. if (mSearchType == ALWAYS_ACCEPT_FIRST_RESULT) mGrid.setRowHeightPerc(2, 0.2f); else mGrid.setRowHeightPerc(1, 0.505f); - const float boxartCellScale = 0.9f; + const float thumbnailCellScale = 0.93f; // Limit thumbnail size using setMaxHeight - we do this instead of letting mGrid // call setSize because it maintains the aspect ratio. // We also pad a little so it doesn't rub up against the metadata labels. - mResultThumbnail->setMaxSize(mGrid.getColWidth(1) * boxartCellScale, mGrid.getRowHeight(1)); + mResultThumbnail->setMaxSize(mGrid.getColWidth(1) * thumbnailCellScale, mGrid.getRowHeight(1)); // Metadata. resizeMetadata(); + // Small vertical spacer between the metadata fields and the result list. + mGrid.setColWidthPerc(3, 0.004f); + if (mSearchType != ALWAYS_ACCEPT_FIRST_RESULT) - mDescContainer->setSize(mGrid.getColWidth(1) * boxartCellScale + mGrid.getColWidth(2), + mDescContainer->setSize(mGrid.getColWidth(1) * thumbnailCellScale + mGrid.getColWidth(2), mResultDesc->getFont()->getHeight() * 3.0f); else - mDescContainer->setSize(mGrid.getColWidth(3) * boxartCellScale, - mResultDesc->getFont()->getHeight() * 6.0f); + mDescContainer->setSize(mGrid.getColWidth(4) * thumbnailCellScale, + mResultDesc->getFont()->getHeight() * 8.0f); // Make description text wrap at edge of container. mResultDesc->setSize(mDescContainer->getSize().x, 0.0f); // Set the width of mResultName to the cell width so that text abbreviation will work correctly. - glm::vec2 resultNameSize{mResultName->getSize()}; - mResultName->setSize(mGrid.getColWidth(3), resultNameSize.y); + mResultName->setSize(mGrid.getColWidth(1) + mGrid.getColWidth(2), mResultName->getSize().y); mGrid.onSizeChanged(); mBusyAnim.setSize(mSize); @@ -289,30 +288,30 @@ void GuiScraperSearch::updateViewStyle() // Add them back depending on search type. if (mSearchType == ALWAYS_ACCEPT_FIRST_RESULT) { // Show name. - mGrid.setEntry(mResultName, glm::ivec2{1, 0}, false, false, glm::ivec2{2, 1}, + mGrid.setEntry(mResultName, glm::ivec2{1, 0}, false, false, glm::ivec2{3, 1}, GridFlags::BORDER_TOP); // Need a border on the bottom left. mGrid.setEntry(std::make_shared(mWindow), glm::ivec2{0, 2}, false, false, - glm::ivec2{3, 1}, GridFlags::BORDER_BOTTOM); + glm::ivec2{4, 1}, GridFlags::BORDER_BOTTOM); // Show description on the right. - mGrid.setEntry(mDescContainer, glm::ivec2{3, 0}, false, false, glm::ivec2{1, 3}, - GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM); + mGrid.setEntry(mDescContainer, glm::ivec2{4, 0}, false, false, glm::ivec2{1, 3}, + GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM | GridFlags::BORDER_LEFT); // Make description text wrap at edge of container. mResultDesc->setSize(mDescContainer->getSize().x, 0.0f); } else { // Fake row where name would be. mGrid.setEntry(std::make_shared(mWindow), glm::ivec2{1, 0}, false, true, - glm::ivec2{2, 1}, GridFlags::BORDER_TOP); + glm::ivec2{3, 1}, GridFlags::BORDER_TOP); // Show result list on the right. - mGrid.setEntry(mResultList, glm::ivec2{3, 0}, true, true, glm::ivec2{1, 3}, + mGrid.setEntry(mResultList, glm::ivec2{4, 0}, true, true, glm::ivec2{1, 3}, GridFlags::BORDER_LEFT | GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM); // Show description under image/info. - mGrid.setEntry(mDescContainer, glm::ivec2{1, 2}, false, false, glm::ivec2{2, 1}, + mGrid.setEntry(mDescContainer, glm::ivec2{1, 2}, false, false, glm::ivec2{3, 1}, GridFlags::BORDER_BOTTOM); // Make description text wrap at edge of container. mResultDesc->setSize(mDescContainer->getSize().x, 0); @@ -328,6 +327,7 @@ void GuiScraperSearch::search(const ScraperSearchParams& params) mScrapeResult = {}; mResultList->clear(); + mResultList->setLoopRows(false); mScraperResults.clear(); mMDRetrieveURLsHandle.reset(); mThumbnailReqMap.clear(); @@ -356,6 +356,7 @@ void GuiScraperSearch::onSearchDone(const std::vector& resu mResultList->clear(); mScraperResults = results; + mResultList->setLoopRows(true); auto font = Font::get(FONT_SIZE_MEDIUM); unsigned int color = 0x777777FF; @@ -390,7 +391,7 @@ void GuiScraperSearch::onSearchDone(const std::vector& resu row.addElement( std::make_shared( mWindow, Utils::String::toUpper(results.at(i).mdl.get("name")), font, color), - true); + false); row.makeAcceptInputHandler([this, i] { returnResult(mScraperResults.at(i)); }); mResultList->addRow(row); } @@ -563,8 +564,10 @@ bool GuiScraperSearch::input(InputConfig* config, Input input) else if (mSearchType == ACCEPT_SINGLE_MATCHES && !mFoundGame) allowRefine = true; - if (allowRefine) + if (allowRefine) { + mResultList->stopLooping(); openInputScreen(mLastSearch); + } } // If multi-scraping, skip game unless the result has already been accepted. @@ -590,6 +593,7 @@ void GuiScraperSearch::render(const glm::mat4& parentTrans) void GuiScraperSearch::returnResult(ScraperSearchResult result) { + mResultList->setLoopRows(false); mBlockAccept = true; mAcceptedResult = true; @@ -798,6 +802,8 @@ void GuiScraperSearch::openInputScreen(ScraperSearchParams& params) stop(); mRefinedSearch = true; params.nameOverride = name; + if (mRefineCallback != nullptr) + mRefineCallback(); search(params); }; diff --git a/es-app/src/guis/GuiScraperSearch.h b/es-app/src/guis/GuiScraperSearch.h index 449124ba0..082e8e3b0 100644 --- a/es-app/src/guis/GuiScraperSearch.h +++ b/es-app/src/guis/GuiScraperSearch.h @@ -71,6 +71,10 @@ public: { mCancelCallback = cancelCallback; } + void setRefineCallback(const std::function& refineCallback) + { + mRefineCallback = refineCallback; + } bool input(InputConfig* config, Input input) override; void update(int deltaTime) override; @@ -92,6 +96,8 @@ public: void onFocusGained() override { mGrid.onFocusGained(); } void onFocusLost() override { mGrid.onFocusLost(); } + std::shared_ptr& getResultList() { return mResultList; } + private: void updateViewStyle(); void updateThumbnail(); @@ -152,6 +158,7 @@ private: std::function mAcceptCallback; std::function mSkipCallback; std::function mCancelCallback; + std::function mRefineCallback; unsigned int mScrapeCount; bool mRefinedSearch; bool mBlockAccept; diff --git a/es-app/src/guis/GuiScreensaverOptions.cpp b/es-app/src/guis/GuiScreensaverOptions.cpp index 8c7dd71ca..cb5bffae2 100644 --- a/es-app/src/guis/GuiScreensaverOptions.cpp +++ b/es-app/src/guis/GuiScreensaverOptions.cpp @@ -17,6 +17,7 @@ GuiScreensaverOptions::GuiScreensaverOptions(Window* window, const std::string& title) : GuiSettings(window, title) + , mWindow(window) { // Screensaver timer. auto screensaver_timer = std::make_shared(mWindow, 0.0f, 30.0f, 1.0f, "m"); @@ -52,7 +53,8 @@ GuiScreensaverOptions::GuiScreensaverOptions(Window* window, const std::string& // If before it wasn't risky but now there's a risk of problems, show warning. mWindow->pushGui(new GuiMsgBox( mWindow, getHelpStyle(), - "THE 'VIDEO' SCREENSAVER SHOWS\nVIDEOS FROM YOUR GAMELISTS\n\n" + "THE 'VIDEO' SCREENSAVER SHOWS\n" + "VIDEOS FROM YOUR GAMELISTS\n\n" "IF YOU DO NOT HAVE ANY VIDEOS, THE\n" "SCREENSAVER WILL DEFAULT TO 'DIM'", "OK", [] { return; }, "", nullptr, "", nullptr)); @@ -94,6 +96,8 @@ GuiScreensaverOptions::GuiScreensaverOptions(Window* window, const std::string& row.makeAcceptInputHandler( std::bind(&GuiScreensaverOptions::openVideoScreensaverOptions, this)); addRow(row); + + setSize(getMenuSize()); } void GuiScreensaverOptions::openSlideshowScreensaverOptions() @@ -205,6 +209,7 @@ void GuiScreensaverOptions::openSlideshowScreensaverOptions() } }); + s->setSize(mSize); mWindow->pushGui(s); } @@ -286,5 +291,6 @@ void GuiScreensaverOptions::openVideoScreensaverOptions() }); #endif + s->setSize(mSize); mWindow->pushGui(s); } diff --git a/es-app/src/guis/GuiScreensaverOptions.h b/es-app/src/guis/GuiScreensaverOptions.h index 9423ab6fe..1fe1993e3 100644 --- a/es-app/src/guis/GuiScreensaverOptions.h +++ b/es-app/src/guis/GuiScreensaverOptions.h @@ -18,6 +18,8 @@ public: GuiScreensaverOptions(Window* window, const std::string& title); private: + Window* mWindow; + void openSlideshowScreensaverOptions(); void openVideoScreensaverOptions(); }; diff --git a/es-app/src/main.cpp b/es-app/src/main.cpp index be86c130f..c68c06bbb 100644 --- a/es-app/src/main.cpp +++ b/es-app/src/main.cpp @@ -232,7 +232,7 @@ bool parseArgs(int argc, char* argv[]) } int width = atoi(argv[i + 1]); int height = atoi(argv[i + 2]); - if (width < 224 || height < 224 || width > 7680 || height > 4320 || + if (width < 224 || height < 224 || width > 7680 || height > 7680 || height < width / 4 || width < height / 2) { std::cerr << "Error: Unsupported resolution " << width << "x" << height << " supplied.\n"; diff --git a/es-app/src/views/ViewController.cpp b/es-app/src/views/ViewController.cpp index 5daa8fdc9..366c30a81 100644 --- a/es-app/src/views/ViewController.cpp +++ b/es-app/src/views/ViewController.cpp @@ -961,7 +961,11 @@ void ViewController::preload() std::to_string(systemCount) + ")"); } (*it)->getIndex()->resetFilters(); - getGameListView(*it); + + if (Settings::getInstance()->getBool("PreloadGamelists")) + getGameListView(*it)->preloadGamelist(); + else + getGameListView(*it); } // Load navigation sounds, either from the theme if it supports it, or otherwise from diff --git a/es-app/src/views/gamelist/DetailedGameListView.cpp b/es-app/src/views/gamelist/DetailedGameListView.cpp index a02e31878..5a0846ff0 100644 --- a/es-app/src/views/gamelist/DetailedGameListView.cpp +++ b/es-app/src/views/gamelist/DetailedGameListView.cpp @@ -38,6 +38,7 @@ DetailedGameListView::DetailedGameListView(Window* window, FileData* root) , mLastPlayed(window) , mPlayCount(window) , mName(window) + , mBadges(window) , mDescContainer(window) , mDescription(window) , mGamelistInfo(window) @@ -101,6 +102,13 @@ DetailedGameListView::DetailedGameListView(Window* window, FileData* root) addChild(&mLblPlayCount); addChild(&mPlayCount); + // Badges. + addChild(&mBadges); + mBadges.setOrigin(0.5f, 0.5f); + mBadges.setPosition(mSize.x * 0.8f, mSize.y * 0.7f); + mBadges.setSize(mSize.x * 0.15f, mSize.y * 0.2f); + mBadges.setDefaultZIndex(50.0f); + mName.setPosition(mSize.x, mSize.y); mName.setDefaultZIndex(40.0f); mName.setColor(0xAAAAAAFF); @@ -141,6 +149,7 @@ void DetailedGameListView::onThemeChanged(const std::shared_ptr& them mImage.applyTheme(theme, getName(), "md_image", POSITION | ThemeFlags::SIZE | Z_INDEX | ROTATION | VISIBLE); mName.applyTheme(theme, getName(), "md_name", ALL); + mBadges.applyTheme(theme, getName(), "md_badges", ALL); initMDLabels(); std::vector labels = getMDLabels(); @@ -297,6 +306,7 @@ void DetailedGameListView::updateInfoPanel() mLastPlayed.setVisible(false); mLblPlayCount.setVisible(false); mPlayCount.setVisible(false); + mBadges.setVisible(false); } else { mLblRating.setVisible(true); @@ -315,6 +325,7 @@ void DetailedGameListView::updateInfoPanel() mLastPlayed.setVisible(true); mLblPlayCount.setVisible(true); mPlayCount.setVisible(true); + mBadges.setVisible(true); } bool fadingOut = false; @@ -397,6 +408,29 @@ void DetailedGameListView::updateInfoPanel() mPublisher.setValue(file->metadata.get("publisher")); mGenre.setValue(file->metadata.get("genre")); mPlayers.setValue(file->metadata.get("players")); + + // Populate the badge slots based on game metadata. + std::vector badgeSlots; + for (auto badge : mBadges.getBadgeTypes()) { + BadgeComponent::BadgeInfo badgeInfo; + badgeInfo.badgeType = badge; + if (badge == "controller") { + if (file->metadata.get("controller").compare("") != 0) { + badgeInfo.gameController = file->metadata.get("controller"); + badgeSlots.push_back(badgeInfo); + } + } + else if (badge == "altemulator") { + if (file->metadata.get(badge).compare("") != 0) + badgeSlots.push_back(badgeInfo); + } + else { + if (file->metadata.get(badge).compare("true") == 0) + badgeSlots.push_back(badgeInfo); + } + } + mBadges.setBadges(badgeSlots); + mName.setValue(file->metadata.get("name")); if (file->getType() == GAME) { @@ -422,6 +456,7 @@ void DetailedGameListView::updateInfoPanel() comps.push_back(&mImage); comps.push_back(&mDescription); comps.push_back(&mName); + comps.push_back(&mBadges); std::vector labels = getMDLabels(); comps.insert(comps.cend(), labels.cbegin(), labels.cend()); diff --git a/es-app/src/views/gamelist/DetailedGameListView.h b/es-app/src/views/gamelist/DetailedGameListView.h index f0b0202a9..08302d5a7 100644 --- a/es-app/src/views/gamelist/DetailedGameListView.h +++ b/es-app/src/views/gamelist/DetailedGameListView.h @@ -9,6 +9,7 @@ #ifndef ES_APP_VIEWS_GAME_LIST_DETAILED_GAME_LIST_VIEW_H #define ES_APP_VIEWS_GAME_LIST_DETAILED_GAME_LIST_VIEW_H +#include "components/BadgeComponent.h" #include "components/DateTimeComponent.h" #include "components/RatingComponent.h" #include "components/ScrollableContainer.h" @@ -24,6 +25,8 @@ public: virtual std::string getName() const override { return "detailed"; } virtual void launch(FileData* game) override; + virtual void preloadGamelist() override { updateInfoPanel(); } + protected: virtual void update(int deltaTime) override; @@ -55,6 +58,7 @@ private: DateTimeComponent mLastPlayed; TextComponent mPlayCount; TextComponent mName; + BadgeComponent mBadges; std::vector getMDLabels(); std::vector getMDValues(); diff --git a/es-app/src/views/gamelist/GridGameListView.cpp b/es-app/src/views/gamelist/GridGameListView.cpp index efb322d9a..284762deb 100644 --- a/es-app/src/views/gamelist/GridGameListView.cpp +++ b/es-app/src/views/gamelist/GridGameListView.cpp @@ -32,6 +32,7 @@ GridGameListView::GridGameListView(Window* window, FileData* root) , mLblPlayers(window) , mLblLastPlayed(window) , mLblPlayCount(window) + , mBadges(window) , mRating(window) , mReleaseDate(window) , mDeveloper(window) @@ -55,6 +56,7 @@ GridGameListView::GridGameListView(Window* window, FileData* root) populateList(root->getChildrenListToDisplay(), root); // Metadata labels + values. + addChild(&mBadges); mLblRating.setText("Rating: ", false); addChild(&mLblRating); addChild(&mRating); @@ -491,7 +493,7 @@ void GridGameListView::updateInfoPanel() if ((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) || (!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) { - // TEMPORARY - This does not seem to work, needs to be reviewed later. + // TODO: This does not seem to work, needs to be reviewed later. // auto func = [comp](float t) { auto func = [](float t) { // comp->setOpacity(static_cast(glm::mix(0.0f, 1.0f, t) * 255)); diff --git a/es-app/src/views/gamelist/GridGameListView.h b/es-app/src/views/gamelist/GridGameListView.h index 9a0bf0714..f84d52cf7 100644 --- a/es-app/src/views/gamelist/GridGameListView.h +++ b/es-app/src/views/gamelist/GridGameListView.h @@ -9,6 +9,7 @@ #ifndef ES_APP_VIEWS_GAME_LIST_GRID_GAME_LIST_VIEW_H #define ES_APP_VIEWS_GAME_LIST_GRID_GAME_LIST_VIEW_H +#include "components/BadgeComponent.h" #include "components/DateTimeComponent.h" #include "components/ImageGridComponent.h" #include "components/RatingComponent.h" @@ -88,6 +89,7 @@ private: TextComponent mLblLastPlayed; TextComponent mLblPlayCount; + BadgeComponent mBadges; RatingComponent mRating; DateTimeComponent mReleaseDate; TextComponent mDeveloper; diff --git a/es-app/src/views/gamelist/IGameListView.h b/es-app/src/views/gamelist/IGameListView.h index 853aa925e..212a062e9 100644 --- a/es-app/src/views/gamelist/IGameListView.h +++ b/es-app/src/views/gamelist/IGameListView.h @@ -32,6 +32,8 @@ public: void setTheme(const std::shared_ptr& theme); const std::shared_ptr& getTheme() const { return mTheme; } + virtual void preloadGamelist(){}; + virtual FileData* getCursor() = 0; virtual void setCursor(FileData*) = 0; virtual FileData* getNextEntry() = 0; diff --git a/es-app/src/views/gamelist/VideoGameListView.cpp b/es-app/src/views/gamelist/VideoGameListView.cpp index 33f50e600..ef76d29e0 100644 --- a/es-app/src/views/gamelist/VideoGameListView.cpp +++ b/es-app/src/views/gamelist/VideoGameListView.cpp @@ -45,6 +45,7 @@ VideoGameListView::VideoGameListView(Window* window, FileData* root) , mLastPlayed(window) , mPlayCount(window) , mName(window) + , mBadges(window) , mDescContainer(window) , mDescription(window) , mGamelistInfo(window) @@ -118,6 +119,13 @@ VideoGameListView::VideoGameListView(Window* window, FileData* root) addChild(&mLblPlayCount); addChild(&mPlayCount); + // Badges. + addChild(&mBadges); + mBadges.setOrigin(0.5f, 0.5f); + mBadges.setPosition(mSize.x * 0.8f, mSize.y * 0.7f); + mBadges.setSize(mSize.x * 0.15f, mSize.y * 0.2f); + mBadges.setDefaultZIndex(50.0f); + mName.setPosition(mSize.x, mSize.y); mName.setDefaultZIndex(40.0f); mName.setColor(0xAAAAAAFF); @@ -163,6 +171,7 @@ void VideoGameListView::onThemeChanged(const std::shared_ptr& theme) POSITION | ThemeFlags::SIZE | ThemeFlags::DELAY | Z_INDEX | ROTATION | VISIBLE); mName.applyTheme(theme, getName(), "md_name", ALL); + mBadges.applyTheme(theme, getName(), "md_badges", ALL); initMDLabels(); std::vector labels = getMDLabels(); @@ -319,6 +328,7 @@ void VideoGameListView::updateInfoPanel() mLastPlayed.setVisible(false); mLblPlayCount.setVisible(false); mPlayCount.setVisible(false); + mBadges.setVisible(false); } else { mLblRating.setVisible(true); @@ -337,6 +347,7 @@ void VideoGameListView::updateInfoPanel() mLastPlayed.setVisible(true); mLblPlayCount.setVisible(true); mPlayCount.setVisible(true); + mBadges.setVisible(true); } bool fadingOut = false; @@ -437,6 +448,29 @@ void VideoGameListView::updateInfoPanel() mPublisher.setValue(file->metadata.get("publisher")); mGenre.setValue(file->metadata.get("genre")); mPlayers.setValue(file->metadata.get("players")); + + // Populate the badge slots based on game metadata. + std::vector badgeSlots; + for (auto badge : mBadges.getBadgeTypes()) { + BadgeComponent::BadgeInfo badgeInfo; + badgeInfo.badgeType = badge; + if (badge == "controller") { + if (file->metadata.get("controller").compare("") != 0) { + badgeInfo.gameController = file->metadata.get("controller"); + badgeSlots.push_back(badgeInfo); + } + } + else if (badge == "altemulator") { + if (file->metadata.get(badge).compare("") != 0) + badgeSlots.push_back(badgeInfo); + } + else { + if (file->metadata.get(badge).compare("true") == 0) + badgeSlots.push_back(badgeInfo); + } + } + mBadges.setBadges(badgeSlots); + mName.setValue(file->metadata.get("name")); if (file->getType() == GAME) { @@ -462,6 +496,7 @@ void VideoGameListView::updateInfoPanel() comps.push_back(mVideo); comps.push_back(&mDescription); comps.push_back(&mName); + comps.push_back(&mBadges); std::vector labels = getMDLabels(); comps.insert(comps.cend(), labels.cbegin(), labels.cend()); diff --git a/es-app/src/views/gamelist/VideoGameListView.h b/es-app/src/views/gamelist/VideoGameListView.h index ff1129742..e0d6775de 100644 --- a/es-app/src/views/gamelist/VideoGameListView.h +++ b/es-app/src/views/gamelist/VideoGameListView.h @@ -9,6 +9,7 @@ #ifndef ES_APP_VIEWS_GAME_LIST_VIDEO_GAME_LIST_VIEW_H #define ES_APP_VIEWS_GAME_LIST_VIDEO_GAME_LIST_VIEW_H +#include "components/BadgeComponent.h" #include "components/DateTimeComponent.h" #include "components/RatingComponent.h" #include "components/ScrollableContainer.h" @@ -27,6 +28,8 @@ public: virtual std::string getName() const override { return "video"; } virtual void launch(FileData* game) override; + virtual void preloadGamelist() override { updateInfoPanel(); } + protected: virtual void update(int deltaTime) override; @@ -59,6 +62,7 @@ private: DateTimeComponent mLastPlayed; TextComponent mPlayCount; TextComponent mName; + BadgeComponent mBadges; std::vector getMDLabels(); std::vector getMDValues(); diff --git a/es-core/CMakeLists.txt b/es-core/CMakeLists.txt index 9cc65d92c..d579317c6 100644 --- a/es-core/CMakeLists.txt +++ b/es-core/CMakeLists.txt @@ -34,12 +34,14 @@ set(CORE_HEADERS # GUI components ${CMAKE_CURRENT_SOURCE_DIR}/src/components/AnimatedImageComponent.h + ${CMAKE_CURRENT_SOURCE_DIR}/src/components/BadgeComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/BusyComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ButtonComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ComponentGrid.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ComponentList.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/DateTimeComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/DateTimeEditComponent.h + ${CMAKE_CURRENT_SOURCE_DIR}/src/components/FlexboxComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GridTileComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/HelpComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/IList.h @@ -110,12 +112,14 @@ set(CORE_SOURCES # GUI components ${CMAKE_CURRENT_SOURCE_DIR}/src/components/AnimatedImageComponent.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/components/BadgeComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/BusyComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ButtonComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ComponentGrid.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ComponentList.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/DateTimeComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/DateTimeEditComponent.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/components/FlexboxComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GridTileComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/HelpComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ImageComponent.cpp diff --git a/es-core/src/Settings.cpp b/es-core/src/Settings.cpp index a69705ea9..34c3a8c8b 100644 --- a/es-core/src/Settings.cpp +++ b/es-core/src/Settings.cpp @@ -181,7 +181,7 @@ void Settings::setDefaults() mBoolMap["SpecialCharsASCII"] = {false, false}; mBoolMap["ListScrollOverlay"] = {false, false}; mBoolMap["VirtualKeyboard"] = {true, true}; - mBoolMap["ScrollIndicators"] = {false, false}; + mBoolMap["ScrollIndicators"] = {true, true}; mBoolMap["FavoritesAddButton"] = {true, true}; mBoolMap["RandomAddButton"] = {false, false}; mBoolMap["GamelistFilters"] = {true, true}; @@ -242,6 +242,7 @@ void Settings::setDefaults() mBoolMap["VideoHardwareDecoding"] = {false, false}; #endif mBoolMap["VideoUpscaleFrameRate"] = {false, false}; + mBoolMap["PreloadGamelists"] = {true, true}; mBoolMap["AlternativeEmulatorPerGame"] = {true, true}; mBoolMap["ShowHiddenFiles"] = {true, true}; mBoolMap["ShowHiddenGames"] = {true, true}; diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index 026897b3a..2a1c7f07f 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -146,6 +146,24 @@ std::map> The {"unfilledPath", PATH}, {"visible", BOOLEAN}, {"zIndex", FLOAT}}}, + {"badges", + {{"pos", NORMALIZED_PAIR}, + {"size", NORMALIZED_PAIR}, + {"origin", NORMALIZED_PAIR}, + {"rotation", FLOAT}, + {"rotationOrigin", NORMALIZED_PAIR}, + {"alignment", STRING}, + {"direction", STRING}, + {"lines", FLOAT}, + {"itemsPerLine", FLOAT}, + {"itemMargin", NORMALIZED_PAIR}, + {"slots", STRING}, + {"controllerPos", NORMALIZED_PAIR}, + {"controllerSize", FLOAT}, + {"customBadgeIcon", PATH}, + {"customControllerIcon", PATH}, + {"visible", BOOLEAN}, + {"zIndex", FLOAT}}}, {"sound", {{"path", PATH}}}, {"helpsystem", {{"pos", NORMALIZED_PAIR}, @@ -503,15 +521,30 @@ void ThemeData::parseElement(const pugi::xml_node& root, ""); } - // Special parsing instruction for customButtonIcon -> save node as it's button - // attribute to prevent nodes overwriting each other. + // Special parsing instruction for recurring options. + // Store as its attribute to prevent nodes overwriting each other. if (strcmp(node.name(), "customButtonIcon") == 0) { - const auto btn = node.attribute("button").as_string(""); - if (strcmp(btn, "") == 0) + const auto button = node.attribute("button").as_string(""); + if (strcmp(button, "") == 0) LOG(LogError) << " element requires the `button` property."; else - element.properties[btn] = path; + element.properties[button] = path; + } + else if (strcmp(node.name(), "customBadgeIcon") == 0) { + const auto badge = node.attribute("badge").as_string(""); + if (strcmp(badge, "") == 0) + LOG(LogError) << " element requires the `badge` property."; + else + element.properties[badge] = path; + } + else if (strcmp(node.name(), "customControllerIcon") == 0) { + const auto controller = node.attribute("controller").as_string(""); + if (strcmp(controller, "") == 0) + LOG(LogError) + << " element requires the `controller` property."; + else + element.properties[controller] = path; } else element.properties[node.name()] = path; diff --git a/es-core/src/Window.cpp b/es-core/src/Window.cpp index 0943e8f04..39c419136 100644 --- a/es-core/src/Window.cpp +++ b/es-core/src/Window.cpp @@ -24,7 +24,9 @@ #include #include +#if defined(USE_OPENGL_21) #define CLOCK_BACKGROUND_CREATION false +#endif Window::Window() : mScreensaver(nullptr) @@ -600,8 +602,8 @@ void Window::renderLoadingScreen(std::string text) static_cast(Renderer::getScreenHeight()), 0x000000FF, 0x000000FF); ImageComponent splash(this, true); - splash.setResize(Renderer::getScreenWidth() * 0.6f, 0.0f); splash.setImage(":/graphics/splash.svg"); + splash.setResize(Renderer::getScreenWidth() * 0.6f, 0.0f); splash.setPosition((Renderer::getScreenWidth() - splash.getSize().x) / 2.0f, (Renderer::getScreenHeight() - splash.getSize().y) / 2.0f * 0.6f); splash.render(trans); diff --git a/es-core/src/components/BadgeComponent.cpp b/es-core/src/components/BadgeComponent.cpp new file mode 100644 index 000000000..abe74f0d7 --- /dev/null +++ b/es-core/src/components/BadgeComponent.cpp @@ -0,0 +1,308 @@ +// SPDX-License-Identifier: MIT +// +// EmulationStation Desktop Edition +// BadgeComponent.cpp +// +// Game badges icons. +// Used by the gamelist views. +// + +#define SLOT_FAVORITE "favorite" +#define SLOT_COMPLETED "completed" +#define SLOT_KIDGAME "kidgame" +#define SLOT_BROKEN "broken" +#define SLOT_CONTROLLER "controller" +#define SLOT_ALTEMULATOR "altemulator" + +#include "components/BadgeComponent.h" + +#include "Log.h" +#include "ThemeData.h" +#include "utils/StringUtil.h" + +std::vector BadgeComponent::sGameControllers; + +// clang-format off + +// The "unknown" controller entry has to be placed last. +GameControllers sControllerDefinitions [] = { + // shortName displayName fileName + {"gamepad_generic", "Gamepad (Generic)", ":/graphics/controllers/gamepad_generic.svg"}, + {"gamepad_xbox", "Gamepad (Xbox)", ":/graphics/controllers/gamepad_xbox.svg"}, + {"gamepad_playstation", "Gamepad (PlayStation)", ":/graphics/controllers/gamepad_playstation.svg"}, + {"gamepad_nintendo_nes", "Gamepad (Nintendo NES)", ":/graphics/controllers/gamepad_nintendo_nes.svg"}, + {"gamepad_nintendo_snes", "Gamepad (Nintendo SNES)", ":/graphics/controllers/gamepad_nintendo_snes.svg"}, + {"gamepad_nintendo_64", "Gamepad (Nintendo 64)", ":/graphics/controllers/gamepad_nintendo_64.svg"}, + {"joystick_generic", "Joystick (Generic)", ":/graphics/controllers/joystick_generic.svg"}, + {"joystick_arcade_2_buttons", "Joystick (Arcade 2 Buttons)", ":/graphics/controllers/joystick_arcade_2_buttons.svg"}, + {"joystick_arcade_3_buttons", "Joystick (Arcade 3 Buttons)", ":/graphics/controllers/joystick_arcade_3_buttons.svg"}, + {"joystick_arcade_4_buttons", "Joystick (Arcade 4 Buttons)", ":/graphics/controllers/joystick_arcade_4_buttons.svg"}, + {"joystick_arcade_6_buttons", "Joystick (Arcade 6 Buttons)", ":/graphics/controllers/joystick_arcade_6_buttons.svg"}, + {"trackball_generic", "Trackball (Generic)", ":/graphics/controllers/trackball_generic.svg"}, + {"lightgun_generic", "Lightgun (Generic)", ":/graphics/controllers/lightgun_generic.svg"}, + {"lightgun_nintendo", "Lightgun (Nintendo)", ":/graphics/controllers/lightgun_nintendo.svg"}, + {"keyboard_generic", "Keyboard (Generic)", ":/graphics/controllers/keyboard_generic.svg"}, + {"mouse_generic", "Mouse (Generic)", ":/graphics/controllers/mouse_generic.svg"}, + {"mouse_amiga", "Mouse (Amiga)", ":/graphics/controllers/mouse_amiga.svg"}, + {"keyboard_mouse_generic", "Keyboard and Mouse (Generic)", ":/graphics/controllers/keyboard_mouse_generic.svg"}, + {"steering_wheel_generic", "Steering Wheel (Generic)", ":/graphics/controllers/steering_wheel_generic.svg"}, + {"wii_remote_nintendo", "Wii Remote (Nintendo)", ":/graphics/controllers/wii_remote_nintendo.svg"}, + {"wii_remote_nunchuck_nintendo", "Wii Remote and Nunchuck (Nintendo)", ":/graphics/controllers/wii_remote_nunchuck_nintendo.svg"}, + {"joycon_left_or_right_nintendo", "Joy-Con Left or Right (Nintendo)", ":/graphics/controllers/joycon_left_or_right_nintendo.svg"}, + {"joycon_pair_nintendo", "Joy-Con Pair (Nintendo)", ":/graphics/controllers/joycon_pair_nintendo.svg"}, + {"unknown", "Unknown Controller", ":/graphics/controllers/unknown.svg"} +}; + +// clang-format on + +BadgeComponent::BadgeComponent(Window* window) + : GuiComponent{window} + , mFlexboxItems{} + , mFlexboxComponent{window, mFlexboxItems} + , mBadgeTypes{{SLOT_FAVORITE, SLOT_COMPLETED, SLOT_KIDGAME, SLOT_BROKEN, SLOT_CONTROLLER, + SLOT_ALTEMULATOR}} +{ + mBadgeIcons[SLOT_FAVORITE] = ":/graphics/badge_favorite.svg"; + mBadgeIcons[SLOT_COMPLETED] = ":/graphics/badge_completed.svg"; + mBadgeIcons[SLOT_KIDGAME] = ":/graphics/badge_kidgame.svg"; + mBadgeIcons[SLOT_BROKEN] = ":/graphics/badge_broken.svg"; + mBadgeIcons[SLOT_CONTROLLER] = ":/graphics/badge_controller.svg"; + mBadgeIcons[SLOT_ALTEMULATOR] = ":/graphics/badge_altemulator.svg"; +} + +void BadgeComponent::populateGameControllers() +{ + sGameControllers.clear(); + for (auto controller : sControllerDefinitions) + sGameControllers.push_back(controller); +} + +void BadgeComponent::setBadges(const std::vector& badges) +{ + std::map prevVisibility; + std::map prevPlayers; + std::map prevController; + + // Save the visibility status to know whether any badges changed. + for (auto& item : mFlexboxItems) { + prevVisibility[item.label] = item.visible; + prevController[item.label] = item.overlayImage.getTexture()->getTextureFilePath(); + item.visible = false; + } + + for (auto& badge : badges) { + auto it = std::find_if( + mFlexboxItems.begin(), mFlexboxItems.end(), + [badge](FlexboxComponent::FlexboxItem item) { return item.label == badge.badgeType; }); + + if (it != mFlexboxItems.end()) { + it->visible = true; + if (badge.gameController != "" && + badge.gameController != it->overlayImage.getTexture()->getTextureFilePath()) { + + auto it2 = std::find_if(sGameControllers.begin(), sGameControllers.end(), + [badge](GameControllers gameController) { + return gameController.shortName == badge.gameController; + }); + + if (it2 != sGameControllers.cend()) { + it->overlayImage.setImage((*it2).fileName); + } + else if (badge.gameController != "") + it->overlayImage.setImage(sGameControllers.back().fileName); + } + } + } + + // Only recalculate the flexbox if any badges changed. + for (auto& item : mFlexboxItems) { + if (prevVisibility[item.label] != item.visible || + prevController[item.label] != item.label) { + mFlexboxComponent.onSizeChanged(); + break; + } + } +} + +const std::string BadgeComponent::getShortName(const std::string& displayName) +{ + auto it = std::find_if(sGameControllers.begin(), sGameControllers.end(), + [displayName](GameControllers gameController) { + return gameController.displayName == displayName; + }); + if (it != sGameControllers.end()) + return (*it).shortName; + else + return "unknown"; +} + +const std::string BadgeComponent::getDisplayName(const std::string& shortName) +{ + auto it = std::find_if(sGameControllers.begin(), sGameControllers.end(), + [shortName](GameControllers gameController) { + return gameController.shortName == shortName; + }); + if (it != sGameControllers.end()) + return (*it).displayName; + else + return "unknown"; +} + +void BadgeComponent::render(const glm::mat4& parentTrans) +{ + if (!isVisible()) + return; + + if (mOpacity == 255) { + mFlexboxComponent.render(parentTrans); + } + else { + mFlexboxComponent.setOpacity(mOpacity); + mFlexboxComponent.render(parentTrans); + mFlexboxComponent.setOpacity(255); + } +} + +void BadgeComponent::applyTheme(const std::shared_ptr& theme, + const std::string& view, + const std::string& element, + unsigned int properties) +{ + populateGameControllers(); + + using namespace ThemeFlags; + + const ThemeData::ThemeElement* elem{theme->getElement(view, element, "badges")}; + if (!elem) + return; + + if (elem->has("alignment")) { + const std::string alignment{elem->get("alignment")}; + if (alignment != "left" && alignment != "right") { + LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, set to \"" + << alignment << "\""; + } + else { + mFlexboxComponent.setAlignment(alignment); + } + } + + if (elem->has("direction")) { + const std::string direction{elem->get("direction")}; + if (direction != "row" && direction != "column") { + LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, set to \"" + << direction << "\""; + } + else { + mFlexboxComponent.setDirection(direction); + } + } + + if (elem->has("lines")) { + const float lines{elem->get("lines")}; + if (lines < 1.0f || lines > 10.0f) { + LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, set to \"" + << lines << "\""; + } + else { + mFlexboxComponent.setLines(static_cast(lines)); + } + } + + if (elem->has("itemsPerLine")) { + const float itemsPerLine{elem->get("itemsPerLine")}; + if (itemsPerLine < 1.0f || itemsPerLine > 10.0f) { + LOG(LogWarning) + << "BadgeComponent: Invalid theme configuration, set to \"" + << itemsPerLine << "\""; + } + else { + mFlexboxComponent.setItemsPerLine(static_cast(itemsPerLine)); + } + } + + if (elem->has("itemMargin")) { + glm::vec2 itemMargin = elem->get("itemMargin"); + if ((itemMargin.x != -1.0 && itemMargin.y != -1.0) && + (itemMargin.x < 0.0f || itemMargin.x > 0.2f || itemMargin.y < 0.0f || + itemMargin.y > 0.2f)) { + LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, set to \"" + << itemMargin.x << " " << itemMargin.y << "\""; + } + else { + mFlexboxComponent.setItemMargin(itemMargin); + } + } + + if (elem->has("controllerPos")) { + const glm::vec2 controllerPos = elem->get("controllerPos"); + if (controllerPos.x < -1.0f || controllerPos.x > 2.0f || controllerPos.y < -1.0f || + controllerPos.y > 2.0f) { + LOG(LogWarning) + << "BadgeComponent: Invalid theme configuration, set to \"" + << controllerPos.x << " " << controllerPos.y << "\""; + } + else { + mFlexboxComponent.setOverlayPosition(controllerPos); + } + } + + if (elem->has("controllerSize")) { + const float controllerSize = elem->get("controllerSize"); + if (controllerSize < 0.1f || controllerSize > 2.0f) { + LOG(LogWarning) + << "BadgeComponent: Invalid theme configuration, set to \"" + << controllerSize << "\""; + } + else { + mFlexboxComponent.setOverlaySize(controllerSize); + } + } + + if (elem->has("slots")) { + // Replace possible whitespace separators with commas. + std::string slotsTag = Utils::String::toLower(elem->get("slots")); + for (auto& character : slotsTag) { + if (std::isspace(character)) + character = ','; + } + slotsTag = Utils::String::replace(slotsTag, ",,", ","); + std::vector slots = Utils::String::delimitedStringToVector(slotsTag, ","); + + for (auto slot : slots) { + if (std::find(mBadgeTypes.cbegin(), mBadgeTypes.cend(), slot) != mBadgeTypes.end()) { + if (properties & PATH && elem->has(slot)) + mBadgeIcons[slot] = elem->get(slot); + + FlexboxComponent::FlexboxItem item; + item.label = slot; + + ImageComponent badgeImage{mWindow, false, false}; + badgeImage.setImage(mBadgeIcons[slot]); + item.baseImage = badgeImage; + item.overlayImage = ImageComponent{mWindow}; + + mFlexboxItems.push_back(item); + } + else { + LOG(LogError) << "Invalid badge slot \"" << slot << "\" defined"; + } + } + + for (auto& gameController : sGameControllers) { + if (properties & PATH && elem->has(gameController.shortName)) + gameController.fileName = elem->get(gameController.shortName); + } + + GuiComponent::applyTheme(theme, view, element, properties); + + mFlexboxComponent.setPosition(mPosition); + mFlexboxComponent.setSize(mSize); + mFlexboxComponent.setOrigin(mOrigin); + mFlexboxComponent.setRotation(mRotation); + mFlexboxComponent.setRotationOrigin(mRotationOrigin); + mFlexboxComponent.setVisible(mVisible); + mFlexboxComponent.setDefaultZIndex(mDefaultZIndex); + mFlexboxComponent.setZIndex(mZIndex); + } +} diff --git a/es-core/src/components/BadgeComponent.h b/es-core/src/components/BadgeComponent.h new file mode 100644 index 000000000..2f998b9da --- /dev/null +++ b/es-core/src/components/BadgeComponent.h @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: MIT +// +// EmulationStation Desktop Edition +// BadgeComponent.h +// +// Game badges icons. +// Used by the gamelist views. +// + +#ifndef ES_CORE_COMPONENTS_BADGE_COMPONENT_H +#define ES_CORE_COMPONENTS_BADGE_COMPONENT_H + +#include "FlexboxComponent.h" +#include "GuiComponent.h" + +struct GameControllers { + std::string shortName; + std::string displayName; + std::string fileName; +}; + +class BadgeComponent : public GuiComponent +{ +public: + BadgeComponent(Window* window); + + struct BadgeInfo { + std::string badgeType; + std::string gameController; + }; + + static void populateGameControllers(); + std::vector getBadgeTypes() { return mBadgeTypes; } + void setBadges(const std::vector& badges); + static const std::vector& getGameControllers() + { + if (sGameControllers.empty()) + populateGameControllers(); + return sGameControllers; + } + + static const std::string getShortName(const std::string& displayName); + static const std::string getDisplayName(const std::string& shortName); + + void render(const glm::mat4& parentTrans) override; + void onSizeChanged() override { mFlexboxComponent.onSizeChanged(); } + + virtual void applyTheme(const std::shared_ptr& theme, + const std::string& view, + const std::string& element, + unsigned int properties) override; + +private: + static std::vector sGameControllers; + + std::vector mFlexboxItems; + FlexboxComponent mFlexboxComponent; + + std::vector mBadgeTypes; + std::map mBadgeIcons; +}; + +#endif // ES_CORE_COMPONENTS_BADGE_COMPONENT_H diff --git a/es-core/src/components/ComponentGrid.cpp b/es-core/src/components/ComponentGrid.cpp index fd87cd10d..1fd3c4c7e 100644 --- a/es-core/src/components/ComponentGrid.cpp +++ b/es-core/src/components/ComponentGrid.cpp @@ -474,22 +474,42 @@ std::vector ComponentGrid::getHelpPrompts() if (e) prompts = e->component->getHelpPrompts(); - bool canScrollVert = mGridSize.y > 1; - bool canScrollHoriz = mGridSize.x > 1; - for (auto it = prompts.cbegin(); it != prompts.cend(); it++) { - if (it->first == "up/down/left/right") { - canScrollHoriz = false; - canScrollVert = false; - break; + bool canScrollVert = false; + + // If the currently selected cell does not fill the entire Y axis, then check if the cells + // above or below are actually focusable as otherwise they should not affect the help prompts. + if (mGridSize.y > 1 && e->dim.y < mGridSize.y) { + if (e->pos.y - e->dim.y >= 0) { + const GridEntry* cell = getCellAt(glm::ivec2{e->pos.x, e->pos.y - e->dim.y}); + if (cell != nullptr && cell->canFocus) + canScrollVert = true; } - else if (it->first == "up/down") { - canScrollVert = false; - } - else if (it->first == "left/right") { - canScrollHoriz = false; + if (e->pos.y + e->dim.y < mGridSize.y) { + const GridEntry* cell = getCellAt(glm::ivec2{e->pos.x, e->pos.y + e->dim.y}); + if (cell != nullptr && cell->canFocus) + canScrollVert = true; } } + // There is currently no situation in the application where unfocusable cells are located + // next to each other horizontally, so this code is good enough. If this changes in the + // future, code similar to the the vertical cell handling above needs to be added. + bool canScrollHoriz = (mGridSize.x > 1 && e->dim.x < mGridSize.x); + + // Check existing capabilities as indicated by the help prompts, and if the prompts should + // be combined into "up/down/left/right" then also remove the single-axis prompts. + if (!prompts.empty() && prompts.back() == HelpPrompt("up/down", "choose")) { + canScrollVert = true; + if (canScrollHoriz && canScrollVert) + prompts.pop_back(); + } + else if (!prompts.empty() && prompts.back() == HelpPrompt("left/right", "choose")) { + canScrollHoriz = true; + if (canScrollHoriz && canScrollVert) + prompts.pop_back(); + } + + // Any duplicates will be removed in Window::setHelpPrompts() if (canScrollHoriz && canScrollVert) prompts.push_back(HelpPrompt("up/down/left/right", "choose")); else if (canScrollHoriz) diff --git a/es-core/src/components/ComponentList.cpp b/es-core/src/components/ComponentList.cpp index c829399ee..cee1ab3bb 100644 --- a/es-core/src/components/ComponentList.cpp +++ b/es-core/src/components/ComponentList.cpp @@ -8,6 +8,8 @@ #include "components/ComponentList.h" +#include "resources/Font.h" + #define TOTAL_HORIZONTAL_PADDING_PX 20.0f ComponentList::ComponentList(Window* window) @@ -15,8 +17,14 @@ ComponentList::ComponentList(Window* window) , mFocused{false} , mSetupCompleted{false} , mBottomCameraOffset{false} + , mSingleRowScroll{false} , mSelectorBarOffset{0.0f} , mCameraOffset{0.0f} + , mLoopRows{false} + , mLoopScroll{false} + , mLoopOffset{0} + , mLoopOffset2{0} + , mLoopTime{0} , mScrollIndicatorStatus{SCROLL_NONE} { // Adjust the padding relative to the aspect ratio and screen resolution to make it look @@ -63,6 +71,8 @@ bool ComponentList::input(InputConfig* config, Input input) if (size() == 0) return false; + mSingleRowScroll = false; + if (input.value && (config->isMappedTo("a", input) || config->isMappedLike("lefttrigger", input) || config->isMappedLike("righttrigger", input))) { @@ -86,9 +96,11 @@ bool ComponentList::input(InputConfig* config, Input input) // Input handler didn't consume the input - try to scroll. if (config->isMappedLike("up", input)) { + mSingleRowScroll = true; return listInput(input.value != 0 ? -1 : 0); } else if (config->isMappedLike("down", input)) { + mSingleRowScroll = true; return listInput(input.value != 0 ? 1 : 0); } else if (config->isMappedLike("leftshoulder", input)) { @@ -115,6 +127,12 @@ bool ComponentList::input(InputConfig* config, Input input) void ComponentList::update(int deltaTime) { + if (!mFocused && mLoopRows) { + mLoopOffset = 0; + mLoopOffset2 = 0; + mLoopTime = 0; + } + const float totalHeight = getTotalRowHeight(); // Scroll indicator logic, used by ScrollIndicatorComponent. @@ -142,15 +160,44 @@ void ComponentList::update(int deltaTime) } if (scrollIndicatorChanged == true && mScrollIndicatorChangedCallback != nullptr) - mScrollIndicatorChangedCallback(mScrollIndicatorStatus); + mScrollIndicatorChangedCallback(mScrollIndicatorStatus, mSingleRowScroll); listUpdate(deltaTime); if (size()) { + float rowWidth{0.0f}; + // Update our currently selected row. for (auto it = mEntries.at(mCursor).data.elements.cbegin(); - it != mEntries.at(mCursor).data.elements.cend(); it++) + it != mEntries.at(mCursor).data.elements.cend(); it++) { it->component->update(deltaTime); + rowWidth += it->component->getSize().x; + } + + if (mLoopRows && rowWidth + mHorizontalPadding / 2.0f > mSize.x) { + // Loop the text. + const float speed{ + Font::get(FONT_SIZE_MEDIUM)->sizeText("ABCDEFGHIJKLMNOPQRSTUVWXYZ").x * 0.247f}; + const float delay{1500.0f}; + const float scrollLength{rowWidth}; + const float returnLength{speed * 1.5f}; + const float scrollTime{(scrollLength * 1000.0f) / speed}; + const float returnTime{(returnLength * 1000.0f) / speed}; + const int maxTime{static_cast(delay + scrollTime + returnTime)}; + + mLoopTime += deltaTime; + while (mLoopTime > maxTime) + mLoopTime -= maxTime; + + mLoopOffset = static_cast(Utils::Math::loop(delay, scrollTime + returnTime, + static_cast(mLoopTime), + scrollLength + returnLength)); + + if (mLoopOffset > (scrollLength - (mSize.x - returnLength))) + mLoopOffset2 = static_cast(mLoopOffset - (scrollLength + returnLength)); + else if (mLoopOffset2 < 0) + mLoopOffset2 = 0; + } } } @@ -158,6 +205,12 @@ void ComponentList::onCursorChanged(const CursorState& state) { mSetupCompleted = true; + if (mLoopRows) { + mLoopOffset = 0; + mLoopOffset2 = 0; + mLoopTime = 0; + } + // Update the selector bar position. // In the future this might be animated. mSelectorBarOffset = 0; @@ -196,14 +249,24 @@ void ComponentList::updateCameraOffset() while (mCameraOffset < target && i < mEntries.size()) { mCameraOffset += getRowHeight(mEntries.at(i).data); if (mCameraOffset > totalHeight - mSize.y) { - if (mSetupCompleted && mCameraOffset != oldCameraOffset) - mBottomCameraOffset = true; + if (mSetupCompleted) { + if (mScrollIndicatorStatus == ComponentList::SCROLL_NONE && + oldCameraOffset == 0.0f) + break; + if (mScrollIndicatorStatus != ComponentList::SCROLL_NONE && + oldCameraOffset == 0.0f) + mBottomCameraOffset = true; + else if (mCameraOffset != oldCameraOffset) + mBottomCameraOffset = true; + } break; } i++; } - if (mCameraOffset < oldCameraOffset) + if (mCameraOffset < oldCameraOffset && + (oldCameraOffset > mSelectorBarOffset || + mScrollIndicatorStatus != ComponentList::SCROLL_NONE)) mBottomCameraOffset = false; if (mCameraOffset < 0.0f) @@ -226,22 +289,47 @@ void ComponentList::render(const glm::mat4& parentTrans) dim.x = (trans[0].x * dim.x + trans[3].x) - trans[3].x; dim.y = (trans[1].y * dim.y + trans[3].y) - trans[3].y; - Renderer::pushClipRect( - glm::ivec2{static_cast(std::round(trans[3].x)), - static_cast(std::round(trans[3].y))}, - glm::ivec2{static_cast(std::round(dim.x)), static_cast(std::round(dim.y))}); + const int clipRectPosX{static_cast(std::round(trans[3].x))}; + const int clipRectPosY{static_cast(std::round(trans[3].y))}; + const int clipRectSizeX{static_cast(std::round(dim.x))}; + const int clipRectSizeY{static_cast(std::round(dim.y))}; + + Renderer::pushClipRect(glm::ivec2{clipRectPosX, clipRectPosY}, + glm::ivec2{clipRectSizeX, clipRectSizeY}); // Scroll the camera. trans = glm::translate(trans, glm::vec3{0.0f, -mCameraOffset, 0.0f}); + glm::mat4 loopTrans{trans}; + // Draw our entries. std::vector drawAfterCursor; bool drawAll; for (size_t i = 0; i < mEntries.size(); i++) { + + if (mLoopRows && mFocused && mLoopOffset > 0) { + loopTrans = + glm::translate(trans, glm::vec3{static_cast(-mLoopOffset), 0.0f, 0.0f}); + } + auto& entry = mEntries.at(i); drawAll = !mFocused || i != static_cast(mCursor); for (auto it = entry.data.elements.cbegin(); it != entry.data.elements.cend(); it++) { if (drawAll || it->invert_when_selected) { + auto renderLoopFunc = [&]() { + // Needed to avoid flickering when returning to the start position. + if (mLoopOffset == 0 && mLoopOffset2 == 0) + mLoopScroll = false; + it->component->render(loopTrans); + // Render row again if text is moved far enough for it to repeat. + if (mLoopOffset2 < 0 || mLoopScroll) { + mLoopScroll = true; + loopTrans = glm::translate( + trans, glm::vec3{static_cast(-mLoopOffset2), 0.0f, 0.0f}); + it->component->render(loopTrans); + } + }; + // For the row where the cursor is at, we want to remove any hue from the // font or image before inverting, as it would otherwise lead to an ugly // inverted color (e.g. red inverting to a green hue). @@ -260,15 +348,14 @@ void ComponentList::render(const glm::mat4& parentTrans) unsigned char byteBlue = origColor >> 8 & 0xFF; // If it's neutral, just proceed with normal rendering. if (byteRed == byteGreen && byteGreen == byteBlue) { - it->component->render(trans); + renderLoopFunc(); } else { if (isTextComponent) it->component->setColor(DEFAULT_INVERTED_TEXTCOLOR); else it->component->setColorShift(DEFAULT_INVERTED_IMAGECOLOR); - - it->component->render(trans); + renderLoopFunc(); // Revert to the original color after rendering. if (isTextComponent) it->component->setColor(origColor); diff --git a/es-core/src/components/ComponentList.h b/es-core/src/components/ComponentList.h index 9035cd881..8b9d9f76c 100644 --- a/es-core/src/components/ComponentList.h +++ b/es-core/src/components/ComponentList.h @@ -86,6 +86,22 @@ public: float getTotalRowHeight() const; float getRowHeight(int row) const { return getRowHeight(mEntries.at(row).data); } + // Horizontal looping for row content that doesn't fit on-screen. + void setLoopRows(bool state) { mLoopRows = state; } + void stopLooping() + { + mLoopOffset = 0; + mLoopOffset2 = 0; + mLoopTime = 0; + } + + void resetScrollIndicatorStatus() + { + mScrollIndicatorStatus = SCROLL_NONE; + if (mScrollIndicatorChangedCallback != nullptr) + mScrollIndicatorChangedCallback(mScrollIndicatorStatus, false); + } + void setCursorChangedCallback(const std::function& callback) { mCursorChangedCallback = callback; @@ -95,7 +111,7 @@ public: return mCursorChangedCallback; } void setScrollIndicatorChangedCallback( - const std::function& callback) + const std::function& callback) { mScrollIndicatorChangedCallback = callback; } @@ -107,6 +123,7 @@ private: bool mFocused; bool mSetupCompleted; bool mBottomCameraOffset; + bool mSingleRowScroll; void updateCameraOffset(); void updateElementPosition(const ComponentListRow& row); @@ -118,8 +135,15 @@ private: float mSelectorBarOffset; float mCameraOffset; + bool mLoopRows; + bool mLoopScroll; + int mLoopOffset; + int mLoopOffset2; + int mLoopTime; + std::function mCursorChangedCallback; - std::function mScrollIndicatorChangedCallback; + std::function + mScrollIndicatorChangedCallback; ScrollIndicator mScrollIndicatorStatus; }; diff --git a/es-core/src/components/FlexboxComponent.cpp b/es-core/src/components/FlexboxComponent.cpp new file mode 100644 index 000000000..3b9fe9a0d --- /dev/null +++ b/es-core/src/components/FlexboxComponent.cpp @@ -0,0 +1,258 @@ +// SPDX-License-Identifier: MIT +// +// EmulationStation Desktop Edition +// FlexboxComponent.cpp +// +// Flexbox layout component. +// + +#define DEFAULT_DIRECTION "row" +#define DEFAULT_ALIGNMENT "left" +#define DEFAULT_ITEMS_PER_LINE 4 +#define DEFAULT_LINES 2 +#define DEFAULT_ITEM_PLACEMENT "center" +#define DEFAULT_MARGIN_X std::roundf(0.01f * Renderer::getScreenWidth()) +#define DEFAULT_MARGIN_Y std::roundf(0.01f * Renderer::getScreenHeight()) + +#include "components/FlexboxComponent.h" + +#include "Settings.h" +#include "ThemeData.h" + +FlexboxComponent::FlexboxComponent(Window* window, std::vector& items) + : GuiComponent{window} + , mItems(items) + , mDirection{DEFAULT_DIRECTION} + , mAlignment{DEFAULT_ALIGNMENT} + , mLines{DEFAULT_LINES} + , mItemsPerLine{DEFAULT_ITEMS_PER_LINE} + , mItemPlacement{DEFAULT_ITEM_PLACEMENT} + , mItemMargin{glm::vec2{DEFAULT_MARGIN_X, DEFAULT_MARGIN_Y}} + , mOverlayPosition{0.5f, 0.5f} + , mOverlaySize{0.5f} + , mLayoutValid{false} +{ +} + +void FlexboxComponent::render(const glm::mat4& parentTrans) +{ + if (!isVisible()) + return; + + if (!mLayoutValid) + computeLayout(); + + glm::mat4 trans{parentTrans * getTransform()}; + Renderer::setMatrix(trans); + + if (Settings::getInstance()->getBool("DebugImage")) + Renderer::drawRect(0.0f, 0.0f, ceilf(mSize.x), ceilf(mSize.y), 0xFF000033, 0xFF000033); + + for (auto& item : mItems) { + if (!item.visible) + continue; + if (mOpacity == 255) { + item.baseImage.render(trans); + if (item.overlayImage.getTexture() != nullptr) + item.overlayImage.render(trans); + } + else { + item.baseImage.setOpacity(mOpacity); + item.baseImage.render(trans); + item.baseImage.setOpacity(255); + if (item.overlayImage.getTexture() != nullptr) { + item.overlayImage.setOpacity(mOpacity); + item.overlayImage.render(trans); + item.overlayImage.setOpacity(255); + } + } + } +} + +void FlexboxComponent::setItemMargin(glm::vec2 value) +{ + if (value.x == -1.0f) + mItemMargin.x = std::roundf(value.y * Renderer::getScreenHeight()); + else + mItemMargin.x = std::roundf(value.x * Renderer::getScreenWidth()); + + if (value.y == -1.0f) + mItemMargin.y = std::roundf(value.x * Renderer::getScreenWidth()); + else + mItemMargin.y = std::roundf(value.y * Renderer::getScreenHeight()); + + mLayoutValid = false; +} + +void FlexboxComponent::computeLayout() +{ + // If we're not clamping itemMargin to a reasonable value, all kinds of weird rendering + // issues could occur. + mItemMargin.x = glm::clamp(mItemMargin.x, 0.0f, mSize.x / 2.0f); + mItemMargin.y = glm::clamp(mItemMargin.y, 0.0f, mSize.y / 2.0f); + + // Also keep the size within reason. + mSize.x = glm::clamp(mSize.x, static_cast(Renderer::getScreenWidth()) * 0.03f, + static_cast(Renderer::getScreenWidth())); + mSize.y = glm::clamp(mSize.y, static_cast(Renderer::getScreenHeight()) * 0.03f, + static_cast(Renderer::getScreenHeight())); + + if (mItemsPerLine * mLines < mItems.size()) { + LOG(LogWarning) + << "FlexboxComponent: Invalid theme configuration, the number of badges" + " exceeds the product of times , setting to " + << mItems.size(); + mItemsPerLine = static_cast(mItems.size()); + } + + glm::vec2 grid{}; + + if (mDirection == "row") + grid = {mItemsPerLine, mLines}; + else + grid = {mLines, mItemsPerLine}; + + glm::vec2 maxItemSize{(mSize + mItemMargin - grid * mItemMargin) / grid}; + + float rowHeight{0.0f}; + bool firstItem{true}; + + // Calculate maximum item dimensions. + for (auto& item : mItems) { + if (!item.visible) + continue; + + glm::vec2 sizeDiff{item.baseImage.getSize() / maxItemSize}; + + // The first item dictates the maximum width for the rest. + if (firstItem) { + maxItemSize.x = (item.baseImage.getSize() / std::max(sizeDiff.x, sizeDiff.y)).x; + sizeDiff = item.baseImage.getSize() / maxItemSize; + item.baseImage.setSize((item.baseImage.getSize() / std::max(sizeDiff.x, sizeDiff.y))); + firstItem = false; + } + else { + item.baseImage.setSize((item.baseImage.getSize() / std::max(sizeDiff.x, sizeDiff.y))); + } + + if (item.baseImage.getSize().y > rowHeight) + rowHeight = item.baseImage.getSize().y; + } + + // Update the maximum item height. + maxItemSize.y = 0.0f; + for (auto& item : mItems) { + if (!item.visible) + continue; + if (item.baseImage.getSize().y > maxItemSize.y) + maxItemSize.y = item.baseImage.getSize().y; + } + + maxItemSize = glm::round(maxItemSize); + + bool alignRight{mAlignment == "right"}; + float alignRightComp{0.0f}; + + // If right-aligning, move the overall container contents during grid setup. + if (alignRight && mDirection == "row") + alignRightComp = + std::round(mSize.x - ((maxItemSize.x + mItemMargin.x) * grid.x) + mItemMargin.x); + + std::vector itemPositions; + + // Lay out the grid. + if (mDirection == "row") { + for (int y = 0; y < grid.y; y++) { + for (int x = 0; x < grid.x; x++) { + itemPositions.push_back( + glm::vec2{(x * (maxItemSize.x + mItemMargin.x) + alignRightComp), + y * (rowHeight + mItemMargin.y)}); + } + } + } + else if (mDirection == "column" && !alignRight) { + for (int x = 0; x < grid.x; x++) { + for (int y = 0; y < grid.y; y++) { + itemPositions.push_back(glm::vec2{(x * (maxItemSize.x + mItemMargin.x)), + y * (rowHeight + mItemMargin.y)}); + } + } + } + else { // Right-aligned. + for (int x = 0; x < grid.x; x++) { + for (int y = 0; y < grid.y; y++) { + itemPositions.push_back( + glm::vec2{(mSize.x - (x * (maxItemSize.x + mItemMargin.x)) - maxItemSize.x), + y * (rowHeight + mItemMargin.y)}); + } + } + } + + int pos{0}; + float lastY{0.0f}; + float itemsOnLastRow{0}; + + // Position items on the grid. + for (auto& item : mItems) { + if (!item.visible) + continue; + + if (mDirection == "row" && pos > 0) { + if (itemPositions[pos - 1].y < itemPositions[pos].y) { + lastY = itemPositions[pos].y; + itemsOnLastRow = 0; + } + } + + float verticalOffset{0.0f}; + + // For any items that do not fill the maximum height, position these either on + // top/start (implicit), center or bottom/end. + if (item.baseImage.getSize().y < maxItemSize.y) { + if (mItemPlacement == "center") { + verticalOffset = std::floor((maxItemSize.y - item.baseImage.getSize().y) / 2.0f); + } + else if (mItemPlacement == "end") { + verticalOffset = maxItemSize.y - item.baseImage.getSize().y; + } + } + + item.baseImage.setPosition(itemPositions[pos].x, itemPositions[pos].y + verticalOffset, + 0.0f); + + // Optional overlay image. + if (item.overlayImage.getTexture() != nullptr) { + item.overlayImage.setResize(item.baseImage.getSize().x * mOverlaySize, 0.0f); + item.overlayImage.setPosition( + item.baseImage.getPosition().x + (item.baseImage.getSize().x * mOverlayPosition.x) - + item.overlayImage.getSize().x / 2.0f, + item.baseImage.getPosition().y + (item.baseImage.getSize().y * mOverlayPosition.y) - + item.overlayImage.getSize().y / 2.0f); + } + + // This rasterizes the SVG images so they look nice and smooth. + item.baseImage.setResize(item.baseImage.getSize()); + + itemsOnLastRow++; + pos++; + } + + // Apply right-align to the items if we're using row mode. + if (alignRight && mDirection == "row") { + for (auto& item : mItems) { + if (!item.visible) + continue; + glm::vec3 currPos{item.baseImage.getPosition()}; + if (currPos.y == lastY) { + const float offset{(grid.x - itemsOnLastRow) * (maxItemSize.x + mItemMargin.x)}; + item.baseImage.setPosition(currPos.x + offset, currPos.y, currPos.z); + if (item.overlayImage.getTexture() != nullptr) { + currPos = item.overlayImage.getPosition(); + item.overlayImage.setPosition(currPos.x + offset, currPos.y, currPos.z); + } + } + } + } + + mLayoutValid = true; +} diff --git a/es-core/src/components/FlexboxComponent.h b/es-core/src/components/FlexboxComponent.h new file mode 100644 index 000000000..ce5a6c60f --- /dev/null +++ b/es-core/src/components/FlexboxComponent.h @@ -0,0 +1,101 @@ +// SPDX-License-Identifier: MIT +// +// EmulationStation Desktop Edition +// FlexboxComponent.h +// +// Flexbox layout component. +// + +#ifndef ES_CORE_COMPONENTS_FLEXBOX_COMPONENT_H +#define ES_CORE_COMPONENTS_FLEXBOX_COMPONENT_H + +#include "GuiComponent.h" +#include "Window.h" +#include "components/ImageComponent.h" + +class FlexboxComponent : public GuiComponent +{ +public: + struct FlexboxItem { + // Optional label, mostly a convenience for the calling class to track items. + std::string label; + // Main image that governs grid sizing and placement. + ImageComponent baseImage{nullptr}; + // Optional overlay image that can be sized and positioned relative to the base image. + ImageComponent overlayImage{nullptr}; + bool visible = false; + }; + + FlexboxComponent(Window* window, std::vector& items); + + // Getters/setters for the layout. + std::string getDirection() const { return mDirection; } + void setDirection(const std::string& direction) + { + assert(direction == "row" || direction == "column"); + mDirection = direction; + } + + std::string getAlignment() const { return mAlignment; } + void setAlignment(const std::string& value) + { + assert(value == "left" || value == "right"); + mAlignment = value; + mLayoutValid = false; + } + + unsigned int getLines() const { return mLines; } + void setLines(unsigned int value) + { + mLines = value; + mLayoutValid = false; + } + + unsigned int getItemsPerLine() const { return mItemsPerLine; } + void setItemsPerLine(unsigned int value) + { + mItemsPerLine = value; + mLayoutValid = false; + } + + std::string getItemPlacement() const { return mItemPlacement; } + void setItemPlacement(const std::string& value) + { + assert(value == "start" || value == "center" || value == "end" || value == "stretch"); + mItemPlacement = value; + mLayoutValid = false; + } + + glm::vec2 getItemMargin() const { return mItemMargin; } + void setItemMargin(glm::vec2 value); + + glm::vec2 getOverlayPosition() const { return mOverlayPosition; } + void setOverlayPosition(glm::vec2 position) { mOverlayPosition = position; } + + float getOverlaySize() const { return mOverlaySize; } + void setOverlaySize(float size) { mOverlaySize = size; } + + void onSizeChanged() override { mLayoutValid = false; } + void render(const glm::mat4& parentTrans) override; + +private: + // Calculate flexbox layout. + void computeLayout(); + + std::vector& mItems; + + // Layout options. + std::string mDirection; + std::string mAlignment; + unsigned int mLines; + unsigned int mItemsPerLine; + std::string mItemPlacement; + glm::vec2 mItemMargin; + + glm::vec2 mOverlayPosition; + float mOverlaySize; + + bool mLayoutValid; +}; + +#endif // ES_CORE_COMPONENTS_FLEXBOX_COMPONENT_H diff --git a/es-core/src/components/HelpComponent.cpp b/es-core/src/components/HelpComponent.cpp index 7b6c7197f..49b68e354 100644 --- a/es-core/src/components/HelpComponent.cpp +++ b/es-core/src/components/HelpComponent.cpp @@ -34,129 +34,129 @@ void HelpComponent::assignIcons() // These graphics files are common between all controller types. sIconPathMap["up/down"] = mStyle.mCustomButtons.dpad_updown.empty() ? - ":/help/dpad_updown.svg" : + ":/graphics/help/dpad_updown.svg" : mStyle.mCustomButtons.dpad_updown; sIconPathMap["left/right"] = mStyle.mCustomButtons.dpad_leftright.empty() ? - ":/help/dpad_leftright.svg" : + ":/graphics/help/dpad_leftright.svg" : mStyle.mCustomButtons.dpad_leftright; sIconPathMap["up/down/left/right"] = mStyle.mCustomButtons.dpad_all.empty() ? - ":/help/dpad_all.svg" : + ":/graphics/help/dpad_all.svg" : mStyle.mCustomButtons.dpad_all; sIconPathMap["thumbstickclick"] = mStyle.mCustomButtons.thumbstick_click.empty() ? - ":/help/thumbstick_click.svg" : + ":/graphics/help/thumbstick_click.svg" : mStyle.mCustomButtons.thumbstick_click; - sIconPathMap["l"] = mStyle.mCustomButtons.button_l.empty() ? ":/help/button_l.svg" : + sIconPathMap["l"] = mStyle.mCustomButtons.button_l.empty() ? ":/graphics/help/button_l.svg" : mStyle.mCustomButtons.button_l; - sIconPathMap["r"] = mStyle.mCustomButtons.button_r.empty() ? ":/help/button_r.svg" : + sIconPathMap["r"] = mStyle.mCustomButtons.button_r.empty() ? ":/graphics/help/button_r.svg" : mStyle.mCustomButtons.button_r; - sIconPathMap["lr"] = mStyle.mCustomButtons.button_lr.empty() ? ":/help/button_lr.svg" : + sIconPathMap["lr"] = mStyle.mCustomButtons.button_lr.empty() ? ":/graphics/help/button_lr.svg" : mStyle.mCustomButtons.button_lr; - sIconPathMap["lt"] = mStyle.mCustomButtons.button_lt.empty() ? ":/help/button_lt.svg" : + sIconPathMap["lt"] = mStyle.mCustomButtons.button_lt.empty() ? ":/graphics/help/button_lt.svg" : mStyle.mCustomButtons.button_lt; - sIconPathMap["rt"] = mStyle.mCustomButtons.button_rt.empty() ? ":/help/button_rt.svg" : + sIconPathMap["rt"] = mStyle.mCustomButtons.button_rt.empty() ? ":/graphics/help/button_rt.svg" : mStyle.mCustomButtons.button_rt; // These graphics files are custom per controller type. if (controllerType == "snes") { sIconPathMap["a"] = mStyle.mCustomButtons.button_a_SNES.empty() ? - ":/help/button_a_SNES.svg" : + ":/graphics/help/button_a_SNES.svg" : mStyle.mCustomButtons.button_a_SNES; sIconPathMap["b"] = mStyle.mCustomButtons.button_b_SNES.empty() ? - ":/help/button_b_SNES.svg" : + ":/graphics/help/button_b_SNES.svg" : mStyle.mCustomButtons.button_b_SNES; sIconPathMap["x"] = mStyle.mCustomButtons.button_x_SNES.empty() ? - ":/help/button_x_SNES.svg" : + ":/graphics/help/button_x_SNES.svg" : mStyle.mCustomButtons.button_x_SNES; sIconPathMap["y"] = mStyle.mCustomButtons.button_y_SNES.empty() ? - ":/help/button_y_SNES.svg" : + ":/graphics/help/button_y_SNES.svg" : mStyle.mCustomButtons.button_y_SNES; sIconPathMap["start"] = mStyle.mCustomButtons.button_start_SNES.empty() ? - ":/help/button_start_SNES.svg" : + ":/graphics/help/button_start_SNES.svg" : mStyle.mCustomButtons.button_start_SNES; sIconPathMap["back"] = mStyle.mCustomButtons.button_back_SNES.empty() ? - ":/help/button_back_SNES.svg" : + ":/graphics/help/button_back_SNES.svg" : mStyle.mCustomButtons.button_back_SNES; } else if (controllerType == "ps4") { sIconPathMap["a"] = mStyle.mCustomButtons.button_a_PS.empty() ? - ":/help/button_a_PS.svg" : + ":/graphics/help/button_a_PS.svg" : mStyle.mCustomButtons.button_a_PS; sIconPathMap["b"] = mStyle.mCustomButtons.button_b_PS.empty() ? - ":/help/button_b_PS.svg" : + ":/graphics/help/button_b_PS.svg" : mStyle.mCustomButtons.button_b_PS; sIconPathMap["x"] = mStyle.mCustomButtons.button_x_PS.empty() ? - ":/help/button_x_PS.svg" : + ":/graphics/help/button_x_PS.svg" : mStyle.mCustomButtons.button_x_PS; sIconPathMap["y"] = mStyle.mCustomButtons.button_y_PS.empty() ? - ":/help/button_y_PS.svg" : + ":/graphics/help/button_y_PS.svg" : mStyle.mCustomButtons.button_y_PS; sIconPathMap["start"] = mStyle.mCustomButtons.button_start_PS4.empty() ? - ":/help/button_start_PS4.svg" : + ":/graphics/help/button_start_PS4.svg" : mStyle.mCustomButtons.button_start_PS4; sIconPathMap["back"] = mStyle.mCustomButtons.button_back_PS4.empty() ? - ":/help/button_back_PS4.svg" : + ":/graphics/help/button_back_PS4.svg" : mStyle.mCustomButtons.button_back_PS4; } else if (controllerType == "ps5") { sIconPathMap["a"] = mStyle.mCustomButtons.button_a_PS.empty() ? - ":/help/button_a_PS.svg" : + ":/graphics/help/button_a_PS.svg" : mStyle.mCustomButtons.button_a_PS; sIconPathMap["b"] = mStyle.mCustomButtons.button_b_PS.empty() ? - ":/help/button_b_PS.svg" : + ":/graphics/help/button_b_PS.svg" : mStyle.mCustomButtons.button_b_PS; sIconPathMap["x"] = mStyle.mCustomButtons.button_x_PS.empty() ? - ":/help/button_x_PS.svg" : + ":/graphics/help/button_x_PS.svg" : mStyle.mCustomButtons.button_x_PS; sIconPathMap["y"] = mStyle.mCustomButtons.button_y_PS.empty() ? - ":/help/button_y_PS.svg" : + ":/graphics/help/button_y_PS.svg" : mStyle.mCustomButtons.button_y_PS; sIconPathMap["start"] = mStyle.mCustomButtons.button_start_PS5.empty() ? - ":/help/button_start_PS5.svg" : + ":/graphics/help/button_start_PS5.svg" : mStyle.mCustomButtons.button_start_PS5; sIconPathMap["back"] = mStyle.mCustomButtons.button_back_PS5.empty() ? - ":/help/button_back_PS5.svg" : + ":/graphics/help/button_back_PS5.svg" : mStyle.mCustomButtons.button_back_PS5; } else if (controllerType == "xbox360") { sIconPathMap["a"] = mStyle.mCustomButtons.button_a_XBOX.empty() ? - ":/help/button_a_XBOX.svg" : + ":/graphics/help/button_a_XBOX.svg" : mStyle.mCustomButtons.button_a_XBOX; sIconPathMap["b"] = mStyle.mCustomButtons.button_b_XBOX.empty() ? - ":/help/button_b_XBOX.svg" : + ":/graphics/help/button_b_XBOX.svg" : mStyle.mCustomButtons.button_b_XBOX; sIconPathMap["x"] = mStyle.mCustomButtons.button_x_XBOX.empty() ? - ":/help/button_x_XBOX.svg" : + ":/graphics/help/button_x_XBOX.svg" : mStyle.mCustomButtons.button_x_XBOX; sIconPathMap["y"] = mStyle.mCustomButtons.button_y_XBOX.empty() ? - ":/help/button_y_XBOX.svg" : + ":/graphics/help/button_y_XBOX.svg" : mStyle.mCustomButtons.button_y_XBOX; sIconPathMap["start"] = mStyle.mCustomButtons.button_start_XBOX360.empty() ? - ":/help/button_start_XBOX360.svg" : + ":/graphics/help/button_start_XBOX360.svg" : mStyle.mCustomButtons.button_start_XBOX360; sIconPathMap["back"] = mStyle.mCustomButtons.button_back_XBOX360.empty() ? - ":/help/button_back_XBOX360.svg" : + ":/graphics/help/button_back_XBOX360.svg" : mStyle.mCustomButtons.button_back_XBOX360; } else { // Xbox One and later. sIconPathMap["a"] = mStyle.mCustomButtons.button_a_XBOX.empty() ? - ":/help/button_a_XBOX.svg" : + ":/graphics/help/button_a_XBOX.svg" : mStyle.mCustomButtons.button_a_XBOX; sIconPathMap["b"] = mStyle.mCustomButtons.button_b_XBOX.empty() ? - ":/help/button_b_XBOX.svg" : + ":/graphics/help/button_b_XBOX.svg" : mStyle.mCustomButtons.button_b_XBOX; sIconPathMap["x"] = mStyle.mCustomButtons.button_x_XBOX.empty() ? - ":/help/button_x_XBOX.svg" : + ":/graphics/help/button_x_XBOX.svg" : mStyle.mCustomButtons.button_x_XBOX; sIconPathMap["y"] = mStyle.mCustomButtons.button_y_XBOX.empty() ? - ":/help/button_y_XBOX.svg" : + ":/graphics/help/button_y_XBOX.svg" : mStyle.mCustomButtons.button_y_XBOX; sIconPathMap["start"] = mStyle.mCustomButtons.button_start_XBOX.empty() ? - ":/help/button_start_XBOX.svg" : + ":/graphics/help/button_start_XBOX.svg" : mStyle.mCustomButtons.button_start_XBOX; sIconPathMap["back"] = mStyle.mCustomButtons.button_back_XBOX.empty() ? - ":/help/button_back_XBOX.svg" : + ":/graphics/help/button_back_XBOX.svg" : mStyle.mCustomButtons.button_back_XBOX; } diff --git a/es-core/src/components/ImageComponent.cpp b/es-core/src/components/ImageComponent.cpp index f6c2d2af2..92aa7c7d7 100644 --- a/es-core/src/components/ImageComponent.cpp +++ b/es-core/src/components/ImageComponent.cpp @@ -63,11 +63,8 @@ void ImageComponent::resize() else { // SVG rasterization is determined by height and rasterization is done in terms of pixels. // If rounding is off enough in the rasterization step (for images with extreme aspect - // ratios), it can cause cutoff when the aspect ratio breaks. - // So we always make sure the resultant height is an integer to make sure cutoff doesn't - // happen, and scale width from that (you'll see this scattered throughout the function). - // It's important to use floorf rather than round for this, as we never want to round up - // since that can lead to the cutoff just described. + // ratios), it can cause cutoff when the aspect ratio breaks. So we always make sure to + // round accordingly to avoid such issues. if (mTargetIsMax) { mSize = textureSize; @@ -77,13 +74,11 @@ void ImageComponent::resize() // This will be mTargetSize.x. We can't exceed it, nor be lower than it. mSize.x *= resizeScale.x; // We need to make sure we're not creating an image larger than max size. - mSize.y = std::min(floorf(mSize.y * resizeScale.x), mTargetSize.y); + mSize.y = floorf(std::min(mSize.y * resizeScale.x, mTargetSize.y)); } else { // This will be mTargetSize.y(). We can't exceed it. - mSize.y = floorf(mSize.y * resizeScale.y); - // For SVG rasterization, always calculate width from rounded height (see comment - // above). We need to make sure we're not creating an image larger than max size. + mSize.y *= resizeScale.y; mSize.x = std::min((mSize.y / textureSize.y) * textureSize.x, mTargetSize.x); } } @@ -106,9 +101,7 @@ void ImageComponent::resize() float cropPercent = (mSize.x - mTargetSize.x) / (mSize.x * 2.0f); crop(cropPercent, 0.0f, cropPercent, 0.0f); } - // For SVG rasterization, always calculate width from rounded height (see comment - // above). We need to make sure we're not creating an image smaller than min size. - mSize.y = std::max(floorf(mSize.y), mTargetSize.y); + mSize.y = std::max(mSize.y, mTargetSize.y); mSize.x = std::max((mSize.y / textureSize.y) * textureSize.x, mTargetSize.x); } else { @@ -117,23 +110,24 @@ void ImageComponent::resize() mSize = mTargetSize == glm::vec2{} ? textureSize : mTargetSize; // If only one component is set, we resize in a way that maintains aspect ratio. - // For SVG rasterization, we always calculate width from rounded height (see - // comment above). if (!mTargetSize.x && mTargetSize.y) { - mSize.y = floorf(mTargetSize.y); + mSize.y = mTargetSize.y; mSize.x = (mSize.y / textureSize.y) * textureSize.x; } else if (mTargetSize.x && !mTargetSize.y) { - mSize.y = floorf((mTargetSize.x / textureSize.x) * textureSize.y); + mSize.y = (mTargetSize.x / textureSize.x) * textureSize.y; mSize.x = (mSize.y / textureSize.y) * textureSize.x; } } } - mSize.x = floorf(mSize.x); - mSize.y = floorf(mSize.y); - // mSize.y() should already be rounded. - mTexture->rasterizeAt(static_cast(mSize.x), static_cast(mSize.y)); + // Make sure sub-pixel values are not rounded to zero. + if (mSize.x < 1.0f) + mSize.x = 1.0f; + if (mSize.y < 1.0f) + mSize.y = 1.0f; + + mTexture->rasterizeAt(mSize.x, mSize.y); onSizeChanged(); } @@ -339,7 +333,7 @@ void ImageComponent::setSaturation(float saturation) void ImageComponent::updateVertices() { - if (!mTexture || !mTexture->isInitialized()) + if (!mTexture) return; // We go through this mess to make sure everything is properly rounded. @@ -404,7 +398,7 @@ void ImageComponent::render(const glm::mat4& parentTrans) Renderer::drawRect(0.0f, 0.0f, mSize.x, mSize.y, 0xFF000033, 0xFF000033); } // An image with zero size would normally indicate a corrupt image file. - if (mTexture->isInitialized() && mTexture->getSize() != glm::ivec2{}) { + if (mTexture->getSize() != glm::ivec2{}) { // Actually draw the image. // The bind() function returns false if the texture is not currently loaded. A blank // texture is bound in this case but we want to handle a fade so it doesn't just diff --git a/es-core/src/components/ImageComponent.h b/es-core/src/components/ImageComponent.h index 159d65e3b..e91955204 100644 --- a/es-core/src/components/ImageComponent.h +++ b/es-core/src/components/ImageComponent.h @@ -107,7 +107,8 @@ private: bool mTargetIsMin; // Calculates the correct mSize from our resizing information (set by setResize/setMaxSize). - // Used internally whenever the resizing parameters or texture change. + // Used internally whenever the resizing parameters or texture change. This function also + // initiates the SVG rasterization. void resize(); Renderer::Vertex mVertices[4]; diff --git a/es-core/src/components/MenuComponent.cpp b/es-core/src/components/MenuComponent.cpp index 4f8a2dbf9..f1cfe029d 100644 --- a/es-core/src/components/MenuComponent.cpp +++ b/es-core/src/components/MenuComponent.cpp @@ -21,7 +21,7 @@ MenuComponent::MenuComponent(Window* window, const std::shared_ptr& titleFont) : GuiComponent(window) , mBackground(window) - , mGrid(window, glm::ivec2{3, 4}) + , mGrid(window, glm::ivec2{2, 4}) , mNeedsSaving(false) { addChild(&mBackground); @@ -34,11 +34,11 @@ MenuComponent::MenuComponent(Window* window, mTitle->setHorizontalAlignment(ALIGN_CENTER); mTitle->setColor(0x555555FF); setTitle(title, titleFont); - mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true, glm::ivec2{3, 2}); + mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true, glm::ivec2{2, 2}); // Set up list which will never change (externally, anyway). mList = std::make_shared(mWindow); - mGrid.setEntry(mList, glm::ivec2{0, 2}, true, true, glm::ivec2{3, 1}); + mGrid.setEntry(mList, glm::ivec2{0, 2}, true, true, glm::ivec2{2, 1}); // Set up scroll indicators. mScrollUp = std::make_shared(mWindow); @@ -51,8 +51,8 @@ MenuComponent::MenuComponent(Window* window, 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}); + mGrid.setEntry(mScrollUp, glm::ivec2{1, 0}, false, false, glm::ivec2{1, 1}); + mGrid.setEntry(mScrollDown, glm::ivec2{1, 1}, false, false, glm::ivec2{1, 1}); updateGrid(); updateSize(); @@ -103,7 +103,7 @@ void MenuComponent::updateSize() 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) + (1 * Renderer::getScreenHeightModifier()); + float rowHeight = mList->getRowHeight(i) + (1.0f * Renderer::getScreenHeightModifier()); if (height + rowHeight < maxHeight) height += rowHeight; else @@ -127,8 +127,7 @@ void MenuComponent::onSizeChanged() 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.setColWidthPerc(1, 0.055f); mGrid.setSize(mSize); } @@ -152,7 +151,7 @@ void MenuComponent::updateGrid() if (mButtons.size()) { mButtonGrid = makeButtonGrid(mWindow, mButtons); - mGrid.setEntry(mButtonGrid, glm::ivec2{0, 3}, true, false, glm::ivec2{3, 1}); + mGrid.setEntry(mButtonGrid, glm::ivec2{0, 3}, true, false, glm::ivec2{2, 1}); } } diff --git a/es-core/src/components/NinePatchComponent.cpp b/es-core/src/components/NinePatchComponent.cpp index d908499fd..e1b62b366 100644 --- a/es-core/src/components/NinePatchComponent.cpp +++ b/es-core/src/components/NinePatchComponent.cpp @@ -59,7 +59,7 @@ void NinePatchComponent::buildVertices() else scaleFactor = glm::clamp(Renderer::getScreenWidthModifier(), 0.4f, 3.0f); - mTexture = TextureResource::get(mPath, false, false, true, true, scaleFactor); + mTexture = TextureResource::get(mPath, false, false, false, true, true, scaleFactor); if (mTexture->getSize() == glm::ivec2{}) { mVertices = nullptr; diff --git a/es-core/src/components/OptionListComponent.h b/es-core/src/components/OptionListComponent.h index c25812743..181b8693a 100644 --- a/es-core/src/components/OptionListComponent.h +++ b/es-core/src/components/OptionListComponent.h @@ -76,8 +76,12 @@ public: // Handles positioning/resizing of text and arrows. void onSizeChanged() override { - mLeftArrow.setResize(0, mText.getFont()->getLetterHeight()); - mRightArrow.setResize(0, mText.getFont()->getLetterHeight()); + if (mText.getFont()->getLetterHeight() != mLeftArrow.getSize().y || + mLeftArrow.getTexture()->getPendingRasterization()) + mLeftArrow.setResize(0, mText.getFont()->getLetterHeight()); + if (mText.getFont()->getLetterHeight() != mRightArrow.getSize().y || + mRightArrow.getTexture()->getPendingRasterization()) + mRightArrow.setResize(0, mText.getFont()->getLetterHeight()); if (mSize.x < (mLeftArrow.getSize().x + mRightArrow.getSize().x)) { LOG(LogWarning) << "OptionListComponent too narrow"; diff --git a/es-core/src/components/RatingComponent.cpp b/es-core/src/components/RatingComponent.cpp index 6c2c22c6f..7dcdecf7b 100644 --- a/es-core/src/components/RatingComponent.cpp +++ b/es-core/src/components/RatingComponent.cpp @@ -102,11 +102,10 @@ void RatingComponent::onSizeChanged() mSize.x = mSize.y * NUM_RATING_STARS; if (mSize.y > 0.0f) { - size_t heightPx = static_cast(std::round(mSize.y)); if (mFilledTexture) - mFilledTexture->rasterizeAt(heightPx, heightPx); + mFilledTexture->rasterizeAt(mSize.y, mSize.y); if (mUnfilledTexture) - mUnfilledTexture->rasterizeAt(heightPx, heightPx); + mUnfilledTexture->rasterizeAt(mSize.y, mSize.y); } updateVertices(); diff --git a/es-core/src/components/ScrollIndicatorComponent.h b/es-core/src/components/ScrollIndicatorComponent.h index 4c0f5801c..58afa5b9b 100644 --- a/es-core/src/components/ScrollIndicatorComponent.h +++ b/es-core/src/components/ScrollIndicatorComponent.h @@ -34,7 +34,7 @@ public: // 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) { + [scrollUp, scrollDown](ComponentList::ScrollIndicator state, bool singleRowScroll) { if (state == ComponentList::SCROLL_UP || state == ComponentList::SCROLL_UP_DOWN || state == ComponentList::SCROLL_DOWN) { @@ -46,8 +46,9 @@ public: // 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}; + [this, scrollUp, scrollDown](ComponentList::ScrollIndicator state, + bool singleRowScroll) { + float fadeTime{FADE_IN_TIME}; bool upFadeIn = false; bool upFadeOut = false; @@ -68,7 +69,7 @@ public: else if (state == ComponentList::SCROLL_UP && mPreviousScrollState == ComponentList::SCROLL_DOWN) { upFadeIn = true; - fadeInTime *= 1.5f; + fadeTime *= 2.0f; scrollDown->setOpacity(0); } else if (state == ComponentList::SCROLL_UP_DOWN && @@ -95,17 +96,22 @@ public: else if (state == ComponentList::SCROLL_DOWN && mPreviousScrollState == ComponentList::SCROLL_UP) { downFadeIn = true; - fadeInTime *= 1.5f; + fadeTime *= 2.0f; scrollUp->setOpacity(0); } + // If jumping more than one row using the shoulder or trigger buttons, then + // don't fade the indicators. + if (!singleRowScroll) + fadeTime = 0.0f; + if (upFadeIn) { auto upFadeInFunc = [scrollUp](float t) { scrollUp->setOpacity( static_cast(glm::mix(0.0f, 1.0f, t) * 255)); }; scrollUp->setAnimation( - new LambdaAnimation(upFadeInFunc, static_cast(fadeInTime)), 0, + new LambdaAnimation(upFadeInFunc, static_cast(fadeTime)), 0, nullptr, false); } @@ -115,7 +121,7 @@ public: static_cast(glm::mix(0.0f, 1.0f, t) * 255)); }; scrollUp->setAnimation( - new LambdaAnimation(upFadeOutFunc, static_cast(fadeInTime)), 0, + new LambdaAnimation(upFadeOutFunc, static_cast(fadeTime)), 0, nullptr, true); } @@ -125,7 +131,7 @@ public: static_cast(glm::mix(0.0f, 1.0f, t) * 255)); }; scrollDown->setAnimation( - new LambdaAnimation(downFadeInFunc, static_cast(fadeInTime)), 0, + new LambdaAnimation(downFadeInFunc, static_cast(fadeTime)), 0, nullptr, false); } @@ -135,7 +141,7 @@ public: static_cast(glm::mix(0.0f, 1.0f, t) * 255)); }; scrollDown->setAnimation( - new LambdaAnimation(downFadeOutFunc, static_cast(fadeInTime)), 0, + new LambdaAnimation(downFadeOutFunc, static_cast(fadeTime)), 0, nullptr, true); } diff --git a/es-core/src/components/ScrollableContainer.cpp b/es-core/src/components/ScrollableContainer.cpp index 218b7cd3a..5568d0f63 100644 --- a/es-core/src/components/ScrollableContainer.cpp +++ b/es-core/src/components/ScrollableContainer.cpp @@ -18,6 +18,7 @@ ScrollableContainer::ScrollableContainer(Window* window) : GuiComponent{window} , mScrollPos{0.0f, 0.0f} , mScrollDir{0.0f, 0.0f} + , mClipSpacing{0.0f} , mAutoScrollDelay{0} , mAutoScrollSpeed{0} , mAutoScrollAccumulator{0} @@ -81,6 +82,13 @@ void ScrollableContainer::update(int deltaTime) float lineSpacing{mChildren.front()->getLineSpacing()}; float combinedHeight{mChildren.front()->getFont()->getHeight(lineSpacing)}; + // Calculate the spacing which will be used to clip the container. + if (lineSpacing > 1.2f && mClipSpacing == 0.0f) { + const float minimumSpacing = mChildren.front()->getFont()->getHeight(1.2f); + const float currentSpacing = mChildren.front()->getFont()->getHeight(lineSpacing); + mClipSpacing = std::round((currentSpacing - minimumSpacing) / 2.0f); + } + // Resize container to font height boundary to avoid rendering a fraction of the last line. if (!mUpdatedSize && contentSize.y > mSize.y) { float numLines{mSize.y / combinedHeight}; @@ -170,8 +178,13 @@ void ScrollableContainer::render(const glm::mat4& parentTrans) dimScaled.x = std::fabs(trans[3].x + mSize.x); dimScaled.y = std::fabs(trans[3].y + mSize.y); - glm::ivec2 clipDim{static_cast(dimScaled.x - trans[3].x), - static_cast(dimScaled.y - trans[3].y)}; + glm::ivec2 clipDim{static_cast(ceilf(dimScaled.x - trans[3].x)), + static_cast(ceilf(dimScaled.y - trans[3].y))}; + + // By effectively clipping the upper and lower boundaries of the container we mostly avoid + // scrolling outside the vertical starting and ending positions. + clipPos.y += static_cast(mClipSpacing); + clipDim.y -= static_cast(mClipSpacing); Renderer::pushClipRect(clipPos, clipDim); diff --git a/es-core/src/components/ScrollableContainer.h b/es-core/src/components/ScrollableContainer.h index 27b63f459..fb80b7eea 100644 --- a/es-core/src/components/ScrollableContainer.h +++ b/es-core/src/components/ScrollableContainer.h @@ -44,6 +44,7 @@ private: float mAutoScrollDelayConstant; float mAutoScrollSpeedConstant; float mResolutionModifier; + float mClipSpacing; int mAutoScrollDelay; int mAutoScrollSpeed; diff --git a/es-core/src/components/SliderComponent.cpp b/es-core/src/components/SliderComponent.cpp index bd0c40696..bcf0ca9d9 100644 --- a/es-core/src/components/SliderComponent.cpp +++ b/es-core/src/components/SliderComponent.cpp @@ -8,6 +8,7 @@ #include "components/SliderComponent.h" +#include "Window.h" #include "resources/Font.h" #define MOVE_REPEAT_DELAY 500 @@ -15,15 +16,16 @@ SliderComponent::SliderComponent( Window* window, float min, float max, float increment, const std::string& suffix) - : GuiComponent(window) - , mMin(min) - , mMax(max) - , mSingleIncrement(increment) - , mMoveRate(0) - , mKnob(window) - , mSuffix(suffix) + : GuiComponent{window} + , mMin{min} + , mMax{max} + , mSingleIncrement{increment} + , mMoveRate{0.0f} + , mBarHeight{0.0f} + , mKnob{window} + , mSuffix{suffix} { - assert((min - max) != 0); + assert((min - max) != 0.0f); // Some sane default value. mValue = (max + min) / 2.0f; @@ -31,7 +33,7 @@ SliderComponent::SliderComponent( mKnob.setOrigin(0.5f, 0.5f); mKnob.setImage(":/graphics/slider_knob.svg"); - setSize(Renderer::getScreenWidth() * 0.15f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()); + setSize(window->peekGui()->getSize().x * 0.26f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()); } bool SliderComponent::input(InputConfig* config, Input input) @@ -41,7 +43,7 @@ bool SliderComponent::input(InputConfig* config, Input input) if (input.value) setValue(mValue - mSingleIncrement); - mMoveRate = input.value ? -mSingleIncrement : 0; + mMoveRate = input.value ? -mSingleIncrement : 0.0f; mMoveAccumulator = -MOVE_REPEAT_DELAY; return true; } @@ -49,13 +51,13 @@ bool SliderComponent::input(InputConfig* config, Input input) if (input.value) setValue(mValue + mSingleIncrement); - mMoveRate = input.value ? mSingleIncrement : 0; + mMoveRate = input.value ? mSingleIncrement : 0.0f; mMoveAccumulator = -MOVE_REPEAT_DELAY; return true; } } else { - mMoveRate = 0; + mMoveRate = 0.0f; } return GuiComponent::input(config, input); @@ -79,19 +81,26 @@ void SliderComponent::render(const glm::mat4& parentTrans) glm::mat4 trans{parentTrans * getTransform()}; Renderer::setMatrix(trans); - // Render suffix. - if (mValueCache) - mFont->renderTextCache(mValueCache.get()); + if (Settings::getInstance()->getBool("DebugText")) { + Renderer::drawRect( + mSize.x - mTextCache->metrics.size.x, (mSize.y - mTextCache->metrics.size.y) / 2.0f, + mTextCache->metrics.size.x, mTextCache->metrics.size.y, 0x0000FF33, 0x0000FF33); + Renderer::drawRect(mSize.x - mTextCache->metrics.size.x, 0.0f, mTextCache->metrics.size.x, + mSize.y, 0x00000033, 0x00000033); + } float width{mSize.x - mKnob.getSize().x - - (mValueCache ? - mValueCache->metrics.size.x + (4.0f * Renderer::getScreenWidthModifier()) : + (mTextCache ? + mTextCache->metrics.size.x + (4.0f * Renderer::getScreenWidthModifier()) : 0.0f)}; - // Render line. - const float lineWidth{2.0f * Renderer::getScreenHeightModifier()}; - Renderer::drawRect(mKnob.getSize().x / 2.0f, mSize.y / 2.0f - lineWidth / 2.0f, width, - lineWidth, 0x777777FF, 0x777777FF); + // Render suffix. + if (mTextCache) + mFont->renderTextCache(mTextCache.get()); + + // Render bar. + Renderer::drawRect(mKnob.getSize().x / 2.0f, mSize.y / 2.0f - mBarHeight / 2.0f, width, + mBarHeight, 0x777777FF, 0x777777FF); // Render knob. mKnob.render(trans); @@ -138,19 +147,33 @@ void SliderComponent::onValueChanged() const std::string max = ss.str(); glm::vec2 textSize = mFont->sizeText(max); - mValueCache = std::shared_ptr(mFont->buildTextCache( + mTextCache = std::shared_ptr(mFont->buildTextCache( val, mSize.x - textSize.x, (mSize.y - textSize.y) / 2.0f, 0x777777FF)); - mValueCache->metrics.size.x = textSize.x; // Fudge the width. + mTextCache->metrics.size.x = textSize.x; // Fudge the width. } - // Update knob position/size. - mKnob.setResize(0, mSize.y * 0.7f); - float lineLength = - mSize.x - mKnob.getSize().x - - (mValueCache ? mValueCache->metrics.size.x + (4.0f * Renderer::getScreenWidthModifier()) : - 0.0f); + mKnob.setResize(0.0f, std::round(mSize.y * 0.7f)); - mKnob.setPosition(((mValue - mMin / 2.0f) / mMax) * lineLength + mKnob.getSize().x / 2.0f, + float barLength = + mSize.x - mKnob.getSize().x - + (mTextCache ? mTextCache->metrics.size.x + (4.0f * Renderer::getScreenWidthModifier()) : + 0.0f); + + int barHeight = static_cast(std::round(2.0f * Renderer::getScreenHeightModifier())); + + // For very low resolutions, make sure the bar height is not rounded to zero. + if (barHeight == 0) + barHeight = 1; + + // Resize the knob one pixel if necessary to keep the bar centered. + if (barHeight % 2 == 0 && static_cast(mKnob.getSize().y) % 2 != 0) + mKnob.setResize(mKnob.getSize().x - 1.0f, mKnob.getSize().y - 1.0f); + else if (barHeight == 1 && static_cast(mKnob.getSize().y) % 2 == 0) + mKnob.setResize(mKnob.getSize().x - 1.0f, mKnob.getSize().y - 1); + + mBarHeight = static_cast(barHeight); + + mKnob.setPosition(((mValue - mMin / 2.0f) / mMax) * barLength + mKnob.getSize().x / 2.0f, mSize.y / 2.0f); } diff --git a/es-core/src/components/SliderComponent.h b/es-core/src/components/SliderComponent.h index 1e6214bc8..2ca75cb9a 100644 --- a/es-core/src/components/SliderComponent.h +++ b/es-core/src/components/SliderComponent.h @@ -45,13 +45,14 @@ private: float mValue; float mSingleIncrement; float mMoveRate; + float mBarHeight; int mMoveAccumulator; ImageComponent mKnob; std::string mSuffix; std::shared_ptr mFont; - std::shared_ptr mValueCache; + std::shared_ptr mTextCache; }; #endif // ES_CORE_COMPONENTS_SLIDER_COMPONENT_H diff --git a/es-core/src/components/SwitchComponent.cpp b/es-core/src/components/SwitchComponent.cpp index 23f64dd24..e1249009a 100644 --- a/es-core/src/components/SwitchComponent.cpp +++ b/es-core/src/components/SwitchComponent.cpp @@ -71,6 +71,7 @@ void SwitchComponent::setValue(const std::string& statestring) void SwitchComponent::onStateChanged() { mImage.setImage(mState ? ":/graphics/on.svg" : ":/graphics/off.svg"); + mImage.setResize(mSize); // Change the color of the switch to reflect the changes. if (mState == mOriginalValue) diff --git a/es-core/src/components/SwitchComponent.h b/es-core/src/components/SwitchComponent.h index c21219144..47011b29d 100644 --- a/es-core/src/components/SwitchComponent.h +++ b/es-core/src/components/SwitchComponent.h @@ -22,8 +22,7 @@ public: void render(const glm::mat4& parentTrans) override; void onSizeChanged() override { mImage.setSize(mSize); } - void setResize(float width, float height) override { mImage.setResize(width, height); } - + void setResize(float width, float height) override { setSize(width, height); } bool getState() const { return mState; } void setState(bool state); std::string getValue() const override; diff --git a/es-core/src/components/TextComponent.cpp b/es-core/src/components/TextComponent.cpp index ad4dda89f..08aa17674 100644 --- a/es-core/src/components/TextComponent.cpp +++ b/es-core/src/components/TextComponent.cpp @@ -13,18 +13,18 @@ #include "utils/StringUtil.h" TextComponent::TextComponent(Window* window) - : GuiComponent(window) - , mFont(Font::get(FONT_SIZE_MEDIUM)) - , mColor(0x000000FF) - , mBgColor(0) - , mMargin(0.0f) - , mRenderBackground(false) - , mUppercase(false) - , mAutoCalcExtent(true, true) - , mHorizontalAlignment(ALIGN_LEFT) - , mVerticalAlignment(ALIGN_CENTER) - , mLineSpacing(1.5f) - , mNoTopMargin(false) + : GuiComponent{window} + , mFont{Font::get(FONT_SIZE_MEDIUM)} + , mColor{0x000000FF} + , mBgColor{0} + , mRenderBackground{false} + , mUppercase{false} + , mAutoCalcExtent{1, 1} + , mHorizontalAlignment{ALIGN_LEFT} + , mVerticalAlignment{ALIGN_CENTER} + , mLineSpacing{1.5f} + , mNoTopMargin{false} + , mSelectable{false} { } @@ -35,20 +35,19 @@ TextComponent::TextComponent(Window* window, Alignment align, glm::vec3 pos, glm::vec2 size, - unsigned int bgcolor, - float margin) - : GuiComponent(window) - , mFont(nullptr) - , mColor(0x000000FF) - , mBgColor(0) - , mMargin(margin) - , mRenderBackground(false) - , mUppercase(false) - , mAutoCalcExtent(true, true) - , mHorizontalAlignment(align) - , mVerticalAlignment(ALIGN_CENTER) - , mLineSpacing(1.5f) - , mNoTopMargin(false) + unsigned int bgcolor) + : GuiComponent{window} + , mFont{nullptr} + , mColor{0x000000FF} + , mBgColor{0} + , mRenderBackground{false} + , mUppercase{false} + , mAutoCalcExtent{1, 1} + , mHorizontalAlignment{align} + , mVerticalAlignment{ALIGN_CENTER} + , mLineSpacing{1.5f} + , mNoTopMargin{false} + , mSelectable{false} { setFont(font); setColor(color); @@ -236,12 +235,12 @@ void TextComponent::onTextChanged() // Abbreviate text. const std::string abbrev = "..."; glm::vec2 abbrevSize{f->sizeText(abbrev)}; - // mMargin adds a margin around the text if it's abbreviated. - float marginAdjustedSize = mSize.x - (mSize.x * mMargin); - while (text.size() && size.x + abbrevSize.x > marginAdjustedSize) { + while (text.size() && size.x + abbrevSize.x > mSize.x) { size_t newSize = Utils::String::prevCursor(text, text.size()); text.erase(newSize, text.size() - newSize); + if (!text.empty() && text.back() == ' ') + text.pop_back(); size = f->sizeText(text); } @@ -282,6 +281,14 @@ void TextComponent::setNoTopMargin(bool margin) onTextChanged(); } +std::vector TextComponent::getHelpPrompts() +{ + std::vector prompts; + if (mSelectable) + prompts.push_back(HelpPrompt("a", "select")); + return prompts; +} + void TextComponent::applyTheme(const std::shared_ptr& theme, const std::string& view, const std::string& element, diff --git a/es-core/src/components/TextComponent.h b/es-core/src/components/TextComponent.h index 57a5561c5..eb1694cdc 100644 --- a/es-core/src/components/TextComponent.h +++ b/es-core/src/components/TextComponent.h @@ -32,8 +32,7 @@ public: Alignment align = ALIGN_LEFT, glm::vec3 pos = {}, glm::vec2 size = {}, - unsigned int bgcolor = 0x00000000, - float margin = 0.0f); + unsigned int bgcolor = 0x00000000); void setFont(const std::shared_ptr& font); void setUppercase(bool uppercase); @@ -60,11 +59,15 @@ public: unsigned char getOpacity() const override { return mColor & 0x000000FF; } void setOpacity(unsigned char opacity) override; + void setSelectable(bool status) { mSelectable = status; } + virtual void applyTheme(const std::shared_ptr& theme, const std::string& view, const std::string& element, unsigned int properties) override; + virtual std::vector getHelpPrompts() override; + unsigned int getColor() const override { return mColor; } std::shared_ptr getFont() const override { return mFont; } Alignment getHorizontalAlignment() { return mHorizontalAlignment; } @@ -85,7 +88,6 @@ private: unsigned int mBgColor; unsigned char mColorOpacity; unsigned char mBgColorOpacity; - float mMargin; bool mRenderBackground; bool mUppercase; @@ -95,6 +97,7 @@ private: Alignment mVerticalAlignment; float mLineSpacing; bool mNoTopMargin; + bool mSelectable; }; #endif // ES_CORE_COMPONENTS_TEXT_COMPONENT_H diff --git a/es-core/src/components/TextListComponent.h b/es-core/src/components/TextListComponent.h index 35174aed0..c551ec9b8 100644 --- a/es-core/src/components/TextListComponent.h +++ b/es-core/src/components/TextListComponent.h @@ -24,7 +24,7 @@ struct TextListData { std::shared_ptr textCache; }; -// A graphical list. Supports multiple colors for rows and scrolling. +// A scrollable text list supporting multiple row colors. template class TextListComponent : public IList { protected: @@ -108,10 +108,10 @@ protected: virtual void onCursorChanged(const CursorState& state) override; private: - int mMarqueeOffset; - int mMarqueeOffset2; - int mMarqueeTime; - bool mMarqueeScroll; + int mLoopOffset; + int mLoopOffset2; + int mLoopTime; + bool mLoopScroll; Alignment mAlignment; float mHorizontalMargin; @@ -138,10 +138,10 @@ TextListComponent::TextListComponent(Window* window) : IList(window) , mSelectorImage(window) { - mMarqueeOffset = 0; - mMarqueeOffset2 = 0; - mMarqueeTime = 0; - mMarqueeScroll = false; + mLoopOffset = 0; + mLoopOffset2 = 0; + mLoopTime = 0; + mLoopScroll = false; mHorizontalMargin = 0.0f; mAlignment = ALIGN_CENTER; @@ -223,8 +223,10 @@ template void TextListComponent::render(const glm::mat4& parentT dim.y = (trans[1].y * dim.y + trans[3].y) - trans[3].y; Renderer::pushClipRect( - glm::ivec2{static_cast(trans[3].x + mHorizontalMargin), static_cast(trans[3].y)}, - glm::ivec2{static_cast(dim.x - mHorizontalMargin * 2.0f), static_cast(dim.y)}); + glm::ivec2{static_cast(std::round(trans[3].x + mHorizontalMargin)), + static_cast(std::round(trans[3].y))}, + glm::ivec2{static_cast(std::round(dim.x - mHorizontalMargin * 2.0f)), + static_cast(std::round(dim.y))}); for (int i = startEntry; i < listCutoff; i++) { typename IList::Entry& entry = mEntries.at(static_cast(i)); @@ -271,26 +273,26 @@ template void TextListComponent::render(const glm::mat4& parentT // Render text. glm::mat4 drawTrans{trans}; - // Currently selected item text might be scrolling. - if (mCursor == i && mMarqueeOffset > 0) + // Currently selected item text might be looping. + if (mCursor == i && mLoopOffset > 0) drawTrans = glm::translate( - drawTrans, offset - glm::vec3{static_cast(mMarqueeOffset), 0.0f, 0.0f}); + drawTrans, offset - glm::vec3{static_cast(mLoopOffset), 0.0f, 0.0f}); else drawTrans = glm::translate(drawTrans, offset); // Needed to avoid flickering when returning to the start position. - if (mMarqueeOffset == 0 && mMarqueeOffset2 == 0) - mMarqueeScroll = false; + if (mLoopOffset == 0 && mLoopOffset2 == 0) + mLoopScroll = false; Renderer::setMatrix(drawTrans); font->renderTextCache(entry.data.textCache.get()); - // Render currently selected row again if marquee is scrolled far enough for it to repeat. - if ((mCursor == i && mMarqueeOffset2 < 0) || (mCursor == i && mMarqueeScroll)) { - mMarqueeScroll = true; + // Render currently selected row again if text is moved far enough for it to repeat. + if ((mCursor == i && mLoopOffset2 < 0) || (mCursor == i && mLoopScroll)) { + mLoopScroll = true; drawTrans = trans; drawTrans = glm::translate( - drawTrans, offset - glm::vec3{static_cast(mMarqueeOffset2), 0.0f, 0.0f}); + drawTrans, offset - glm::vec3{static_cast(mLoopOffset2), 0.0f, 0.0f}); Renderer::setMatrix(drawTrans); font->renderTextCache(entry.data.textCache.get()); } @@ -353,11 +355,11 @@ template void TextListComponent::update(int deltaTime) stopScrolling(); if (!isScrolling() && size() > 0) { - // Always reset the marquee offsets. - mMarqueeOffset = 0; - mMarqueeOffset2 = 0; + // Always reset the loop offsets. + mLoopOffset = 0; + mLoopOffset2 = 0; - // If we're not scrolling and this object's text exceeds our size, then marquee it. + // If we're not scrolling and this object's text exceeds our size, then loop it. const float textLength = mFont ->sizeText(Utils::String::toUpper( mEntries.at(static_cast(mCursor)).name)) @@ -374,16 +376,16 @@ template void TextListComponent::update(int deltaTime) const float returnTime = (returnLength * 1000.0f) / speed; const int maxTime = static_cast(delay + scrollTime + returnTime); - mMarqueeTime += deltaTime; - while (mMarqueeTime > maxTime) - mMarqueeTime -= maxTime; + mLoopTime += deltaTime; + while (mLoopTime > maxTime) + mLoopTime -= maxTime; - mMarqueeOffset = static_cast(Utils::Math::loop(delay, scrollTime + returnTime, - static_cast(mMarqueeTime), - scrollLength + returnLength)); + mLoopOffset = static_cast(Utils::Math::loop(delay, scrollTime + returnTime, + static_cast(mLoopTime), + scrollLength + returnLength)); - if (mMarqueeOffset > (scrollLength - (limit - returnLength))) - mMarqueeOffset2 = static_cast(mMarqueeOffset - (scrollLength + returnLength)); + if (mLoopOffset > (scrollLength - (limit - returnLength))) + mLoopOffset2 = static_cast(mLoopOffset - (scrollLength + returnLength)); } } @@ -405,9 +407,9 @@ void TextListComponent::add(const std::string& name, const T& obj, unsigned i template void TextListComponent::onCursorChanged(const CursorState& state) { - mMarqueeOffset = 0; - mMarqueeOffset2 = 0; - mMarqueeTime = 0; + mLoopOffset = 0; + mLoopOffset2 = 0; + mLoopTime = 0; if (mCursorChangedCallback) mCursorChangedCallback(state); diff --git a/es-core/src/guis/GuiInputConfig.cpp b/es-core/src/guis/GuiInputConfig.cpp index 516d17c6e..f9bf3d10f 100644 --- a/es-core/src/guis/GuiInputConfig.cpp +++ b/es-core/src/guis/GuiInputConfig.cpp @@ -201,67 +201,67 @@ void GuiInputConfig::populateConfigList() std::string controllerType = Settings::getInstance()->getString("InputControllerType"); // clang-format off - sGuiInputConfigList[0] = {"Up", false, "D-PAD UP", ":/help/dpad_up.svg"}; - sGuiInputConfigList[1] = {"Down", false, "D-PAD DOWN", ":/help/dpad_down.svg"}; - sGuiInputConfigList[2] = {"Left", false, "D-PAD LEFT", ":/help/dpad_left.svg"}; - sGuiInputConfigList[3] = {"Right", false, "D-PAD RIGHT", ":/help/dpad_right.svg"}; + sGuiInputConfigList[0] = {"Up", false, "D-PAD UP", ":/graphics/help/dpad_up.svg"}; + sGuiInputConfigList[1] = {"Down", false, "D-PAD DOWN", ":/graphics/help/dpad_down.svg"}; + sGuiInputConfigList[2] = {"Left", false, "D-PAD LEFT", ":/graphics/help/dpad_left.svg"}; + sGuiInputConfigList[3] = {"Right", false, "D-PAD RIGHT", ":/graphics/help/dpad_right.svg"}; if (controllerType == "snes") { - sGuiInputConfigList[4] = {"Back", false, "SELECT", ":/help/button_back_SNES.svg"}; - sGuiInputConfigList[5] = {"Start", false, "START", ":/help/button_start_SNES.svg"}; - sGuiInputConfigList[6] = {"A", false, "B", ":/help/mbuttons_a_SNES.svg"}; - sGuiInputConfigList[7] = {"B", false, "A", ":/help/mbuttons_b_SNES.svg"}; - sGuiInputConfigList[8] = {"X", true, "Y", ":/help/mbuttons_x_SNES.svg"}; - sGuiInputConfigList[9] = {"Y", true, "X", ":/help/mbuttons_y_SNES.svg"}; + sGuiInputConfigList[4] = {"Back", false, "SELECT", ":/graphics/help/button_back_SNES.svg"}; + sGuiInputConfigList[5] = {"Start", false, "START", ":/graphics/help/button_start_SNES.svg"}; + sGuiInputConfigList[6] = {"A", false, "B", ":/graphics/help/mbuttons_a_SNES.svg"}; + sGuiInputConfigList[7] = {"B", false, "A", ":/graphics/help/mbuttons_b_SNES.svg"}; + sGuiInputConfigList[8] = {"X", true, "Y", ":/graphics/help/mbuttons_x_SNES.svg"}; + sGuiInputConfigList[9] = {"Y", true, "X", ":/graphics/help/mbuttons_y_SNES.svg"}; } else if (controllerType == "ps4") { - sGuiInputConfigList[4] = {"Back", false, "SHARE", ":/help/button_back_PS4.svg"}; - sGuiInputConfigList[5] = {"Start", false, "OPTIONS", ":/help/button_start_PS4.svg"}; - sGuiInputConfigList[6] = {"A", false, "CROSS", ":/help/mbuttons_a_PS.svg"}; - sGuiInputConfigList[7] = {"B", false, "CIRCLE", ":/help/mbuttons_b_PS.svg"}; - sGuiInputConfigList[8] = {"X", true, "SQUARE", ":/help/mbuttons_x_PS.svg"}; - sGuiInputConfigList[9] = {"Y", true, "TRIANGLE", ":/help/mbuttons_y_PS.svg"}; + sGuiInputConfigList[4] = {"Back", false, "SHARE", ":/graphics/help/button_back_PS4.svg"}; + sGuiInputConfigList[5] = {"Start", false, "OPTIONS", ":/graphics/help/button_start_PS4.svg"}; + sGuiInputConfigList[6] = {"A", false, "CROSS", ":/graphics/help/mbuttons_a_PS.svg"}; + sGuiInputConfigList[7] = {"B", false, "CIRCLE", ":/graphics/help/mbuttons_b_PS.svg"}; + sGuiInputConfigList[8] = {"X", true, "SQUARE", ":/graphics/help/mbuttons_x_PS.svg"}; + sGuiInputConfigList[9] = {"Y", true, "TRIANGLE", ":/graphics/help/mbuttons_y_PS.svg"}; } else if (controllerType == "ps5") { - sGuiInputConfigList[4] = {"Back", false, "CREATE", ":/help/button_back_PS5.svg"}; - sGuiInputConfigList[5] = {"Start", false, "OPTIONS", ":/help/button_start_PS5.svg"}; - sGuiInputConfigList[6] = {"A", false, "CROSS", ":/help/mbuttons_a_PS.svg"}; - sGuiInputConfigList[7] = {"B", false, "CIRCLE", ":/help/mbuttons_b_PS.svg"}; - sGuiInputConfigList[8] = {"X", true, "SQUARE", ":/help/mbuttons_x_PS.svg"}; - sGuiInputConfigList[9] = {"Y", true, "TRIANGLE", ":/help/mbuttons_y_PS.svg"}; + sGuiInputConfigList[4] = {"Back", false, "CREATE", ":/graphics/help/button_back_PS5.svg"}; + sGuiInputConfigList[5] = {"Start", false, "OPTIONS", ":/graphics/help/button_start_PS5.svg"}; + sGuiInputConfigList[6] = {"A", false, "CROSS", ":/graphics/help/mbuttons_a_PS.svg"}; + sGuiInputConfigList[7] = {"B", false, "CIRCLE", ":/graphics/help/mbuttons_b_PS.svg"}; + sGuiInputConfigList[8] = {"X", true, "SQUARE", ":/graphics/help/mbuttons_x_PS.svg"}; + sGuiInputConfigList[9] = {"Y", true, "TRIANGLE", ":/graphics/help/mbuttons_y_PS.svg"}; } else if (controllerType == "xbox360") { - sGuiInputConfigList[4] = {"Back", false, "BACK", ":/help/button_back_XBOX360.svg"}; - sGuiInputConfigList[5] = {"Start", false, "START", ":/help/button_start_XBOX360.svg"}; - sGuiInputConfigList[6] = {"A", false, "A", ":/help/mbuttons_a_XBOX.svg"}; - sGuiInputConfigList[7] = {"B", false, "B", ":/help/mbuttons_b_XBOX.svg"}; - sGuiInputConfigList[8] = {"X", true, "X", ":/help/mbuttons_x_XBOX.svg"}; - sGuiInputConfigList[9] = {"Y", true, "Y", ":/help/mbuttons_y_XBOX.svg"}; + sGuiInputConfigList[4] = {"Back", false, "BACK", ":/graphics/help/button_back_XBOX360.svg"}; + sGuiInputConfigList[5] = {"Start", false, "START", ":/graphics/help/button_start_XBOX360.svg"}; + sGuiInputConfigList[6] = {"A", false, "A", ":/graphics/help/mbuttons_a_XBOX.svg"}; + sGuiInputConfigList[7] = {"B", false, "B", ":/graphics/help/mbuttons_b_XBOX.svg"}; + sGuiInputConfigList[8] = {"X", true, "X", ":/graphics/help/mbuttons_x_XBOX.svg"}; + sGuiInputConfigList[9] = {"Y", true, "Y", ":/graphics/help/mbuttons_y_XBOX.svg"}; } else { // Xbox One and later. - sGuiInputConfigList[4] = {"Back", false, "VIEW", ":/help/button_back_XBOX.svg"}; - sGuiInputConfigList[5] = {"Start", false, "MENU", ":/help/button_start_XBOX.svg"}; - sGuiInputConfigList[6] = {"A", false, "A", ":/help/mbuttons_a_XBOX.svg"}; - sGuiInputConfigList[7] = {"B", false, "B", ":/help/mbuttons_b_XBOX.svg"}; - sGuiInputConfigList[8] = {"X", true, "X", ":/help/mbuttons_x_XBOX.svg"}; - sGuiInputConfigList[9] = {"Y", true, "Y", ":/help/mbuttons_y_XBOX.svg"}; + sGuiInputConfigList[4] = {"Back", false, "VIEW", ":/graphics/help/button_back_XBOX.svg"}; + sGuiInputConfigList[5] = {"Start", false, "MENU", ":/graphics/help/button_start_XBOX.svg"}; + sGuiInputConfigList[6] = {"A", false, "A", ":/graphics/help/mbuttons_a_XBOX.svg"}; + sGuiInputConfigList[7] = {"B", false, "B", ":/graphics/help/mbuttons_b_XBOX.svg"}; + sGuiInputConfigList[8] = {"X", true, "X", ":/graphics/help/mbuttons_x_XBOX.svg"}; + sGuiInputConfigList[9] = {"Y", true, "Y", ":/graphics/help/mbuttons_y_XBOX.svg"}; } - sGuiInputConfigList[10] = {"LeftShoulder", true, "LEFT SHOULDER", ":/help/button_l.svg"}; - sGuiInputConfigList[11] = {"RightShoulder", true, "RIGHT SHOULDER", ":/help/button_r.svg"}; - sGuiInputConfigList[12] = {"LeftTrigger", true, "LEFT TRIGGER", ":/help/button_lt.svg"}; - sGuiInputConfigList[13] = {"RightTrigger", true, "RIGHT TRIGGER", ":/help/button_rt.svg"}; - sGuiInputConfigList[14] = {"LeftThumbstickUp", true, "LEFT THUMBSTICK UP", ":/help/thumbstick_up.svg"}; - sGuiInputConfigList[15] = {"LeftThumbstickDown", true, "LEFT THUMBSTICK DOWN", ":/help/thumbstick_down.svg"}; - sGuiInputConfigList[16] = {"LeftThumbstickLeft", true, "LEFT THUMBSTICK LEFT", ":/help/thumbstick_left.svg"}; - sGuiInputConfigList[17] = {"LeftThumbstickRight", true, "LEFT THUMBSTICK RIGHT", ":/help/thumbstick_right.svg"}; - sGuiInputConfigList[18] = {"LeftThumbstickClick", true, "LEFT THUMBSTICK CLICK", ":/help/thumbstick_click.svg"}; - sGuiInputConfigList[19] = {"RightThumbstickUp", true, "RIGHT THUMBSTICK UP", ":/help/thumbstick_up.svg"}; - sGuiInputConfigList[20] = {"RightThumbstickDown", true, "RIGHT THUMBSTICK DOWN", ":/help/thumbstick_down.svg"}; - sGuiInputConfigList[21] = {"RightThumbstickLeft", true, "RIGHT THUMBSTICK LEFT", ":/help/thumbstick_left.svg"}; - sGuiInputConfigList[22] = {"RightThumbstickRight", true, "RIGHT THUMBSTICK RIGHT", ":/help/thumbstick_right.svg"}; - sGuiInputConfigList[23] = {"RightThumbstickClick", true, "RIGHT THUMBSTICK CLICK", ":/help/thumbstick_click.svg"}; + sGuiInputConfigList[10] = {"LeftShoulder", true, "LEFT SHOULDER", ":/graphics/help/button_l.svg"}; + sGuiInputConfigList[11] = {"RightShoulder", true, "RIGHT SHOULDER", ":/graphics/help/button_r.svg"}; + sGuiInputConfigList[12] = {"LeftTrigger", true, "LEFT TRIGGER", ":/graphics/help/button_lt.svg"}; + sGuiInputConfigList[13] = {"RightTrigger", true, "RIGHT TRIGGER", ":/graphics/help/button_rt.svg"}; + sGuiInputConfigList[14] = {"LeftThumbstickUp", true, "LEFT THUMBSTICK UP", ":/graphics/help/thumbstick_up.svg"}; + sGuiInputConfigList[15] = {"LeftThumbstickDown", true, "LEFT THUMBSTICK DOWN", ":/graphics/help/thumbstick_down.svg"}; + sGuiInputConfigList[16] = {"LeftThumbstickLeft", true, "LEFT THUMBSTICK LEFT", ":/graphics/help/thumbstick_left.svg"}; + sGuiInputConfigList[17] = {"LeftThumbstickRight", true, "LEFT THUMBSTICK RIGHT", ":/graphics/help/thumbstick_right.svg"}; + sGuiInputConfigList[18] = {"LeftThumbstickClick", true, "LEFT THUMBSTICK CLICK", ":/graphics/help/thumbstick_click.svg"}; + sGuiInputConfigList[19] = {"RightThumbstickUp", true, "RIGHT THUMBSTICK UP", ":/graphics/help/thumbstick_up.svg"}; + sGuiInputConfigList[20] = {"RightThumbstickDown", true, "RIGHT THUMBSTICK DOWN", ":/graphics/help/thumbstick_down.svg"}; + sGuiInputConfigList[21] = {"RightThumbstickLeft", true, "RIGHT THUMBSTICK LEFT", ":/graphics/help/thumbstick_left.svg"}; + sGuiInputConfigList[22] = {"RightThumbstickRight", true, "RIGHT THUMBSTICK RIGHT", ":/graphics/help/thumbstick_right.svg"}; + sGuiInputConfigList[23] = {"RightThumbstickClick", true, "RIGHT THUMBSTICK CLICK", ":/graphics/help/thumbstick_click.svg"}; // clang-format on } diff --git a/es-core/src/guis/GuiMsgBox.cpp b/es-core/src/guis/GuiMsgBox.cpp index 0e0a7fcb2..d92acbb9b 100644 --- a/es-core/src/guis/GuiMsgBox.cpp +++ b/es-core/src/guis/GuiMsgBox.cpp @@ -179,11 +179,6 @@ std::vector GuiMsgBox::getHelpPrompts() { std::vector prompts = mGrid.getHelpPrompts(); - // If there is only one button, then remove the "Choose" help symbol - // as there is no way to make a choice. - if (mButtons.size() == 1) - prompts.pop_back(); - if (!mDisableBackButton) prompts.push_back(HelpPrompt("b", "Back")); diff --git a/es-core/src/guis/GuiTextEditKeyboardPopup.cpp b/es-core/src/guis/GuiTextEditKeyboardPopup.cpp index a3ce28161..8a1c270f3 100644 --- a/es-core/src/guis/GuiTextEditKeyboardPopup.cpp +++ b/es-core/src/guis/GuiTextEditKeyboardPopup.cpp @@ -567,8 +567,8 @@ void GuiTextEditKeyboardPopup::shiftKeys() mShift = !mShift; if (mShift) { - mShiftButton->setFlatColorFocused(0xFF2222FF); - mShiftButton->setFlatColorUnfocused(0xFF2222FF); + mShiftButton->setFlatColorFocused(0xF26767FF); + mShiftButton->setFlatColorUnfocused(0xF26767FF); } else { mShiftButton->setFlatColorFocused(0x878787FF); @@ -600,8 +600,8 @@ void GuiTextEditKeyboardPopup::altKeys() mAlt = !mAlt; if (mAlt) { - mAltButton->setFlatColorFocused(0xFF2222FF); - mAltButton->setFlatColorUnfocused(0xFF2222FF); + mAltButton->setFlatColorFocused(0xF26767FF); + mAltButton->setFlatColorUnfocused(0xF26767FF); } else { mAltButton->setFlatColorFocused(0x878787FF); diff --git a/es-core/src/resources/TextureData.cpp b/es-core/src/resources/TextureData.cpp index 70375c5b3..e9c05e198 100644 --- a/es-core/src/resources/TextureData.cpp +++ b/es-core/src/resources/TextureData.cpp @@ -24,16 +24,18 @@ #define DPI 96 TextureData::TextureData(bool tile) - : mTile(tile) - , mTextureID(0) + : mTile{tile} + , mTextureID{0} , mDataRGBA({}) - , mWidth(0) - , mHeight(0) - , mSourceWidth(0.0f) - , mSourceHeight(0.0f) - , mScaleDuringLoad(1.0f) - , mScalable(false) - , mLinearMagnify(false) + , mWidth{0} + , mHeight{0} + , mSourceWidth{0.0f} + , mSourceHeight{0.0f} + , mScaleDuringLoad{1.0f} + , mScalable{false} + , mLinearMagnify{false} + , mForceRasterization{false} + , mPendingRasterization{false} { } @@ -54,27 +56,32 @@ void TextureData::initFromPath(const std::string& path) bool TextureData::initSVGFromMemory(const std::string& fileData) { // If already initialized then don't process it again. - std::unique_lock lock(mMutex); + std::unique_lock lock{mMutex}; if (!mDataRGBA.empty()) return true; - NSVGimage* svgImage = nsvgParse(const_cast(fileData.c_str()), "px", DPI); + NSVGimage* svgImage{nsvgParse(const_cast(fileData.c_str()), "px", DPI)}; if (!svgImage) { LOG(LogError) << "Couldn't parse SVG image"; return false; } - // We want to rasterize this texture at a specific resolution. If the source size - // variables are set then use them, otherwise get them from the parsed file. - if ((mSourceWidth == 0.0f) && (mSourceHeight == 0.0f)) { - mSourceWidth = svgImage->width; - mSourceHeight = svgImage->height; + bool rasterize{true}; + + // If there is no image size defined yet, then don't rasterize unless mForceRasterization has + // been set (this is only used by NinePatchComponent to avoid flickering menus). + if (mSourceWidth == 0.0f && mSourceHeight == 0.0f) { + if (!mForceRasterization) + rasterize = false; + // Set a small temporary size that maintains the image aspect ratio. + mSourceWidth = 64.0f; + mSourceHeight = 64.0f * (svgImage->height / svgImage->width); } - mWidth = static_cast(floorf(floorf(mSourceWidth) * mScaleDuringLoad)); - mHeight = static_cast(floorf(floorf(mSourceHeight) * mScaleDuringLoad)); + mWidth = static_cast(std::round(mSourceWidth * mScaleDuringLoad)); + mHeight = static_cast(std::round(mSourceHeight * mScaleDuringLoad)); if (mWidth == 0) { // Auto scale width to keep aspect ratio. @@ -87,24 +94,31 @@ bool TextureData::initSVGFromMemory(const std::string& fileData) std::round((static_cast(mWidth) / svgImage->width) * svgImage->height)); } - std::vector tempVector; - tempVector.reserve(mWidth * mHeight * 4); + if (rasterize) { + std::vector tempVector; + tempVector.reserve(mWidth * mHeight * 4); - NSVGrasterizer* rast = nsvgCreateRasterizer(); + NSVGrasterizer* rast = nsvgCreateRasterizer(); - nsvgRasterize(rast, svgImage, 0, 0, mHeight / svgImage->height, tempVector.data(), - static_cast(mWidth), static_cast(mHeight), - static_cast(mWidth) * 4); + nsvgRasterize(rast, svgImage, 0, 0, mHeight / svgImage->height, tempVector.data(), mWidth, + mHeight, mWidth * 4); + + nsvgDeleteRasterizer(rast); + + mDataRGBA.insert(mDataRGBA.begin(), tempVector.data(), + tempVector.data() + (mWidth * mHeight * 4)); + + ImageIO::flipPixelsVert(mDataRGBA.data(), mWidth, mHeight); + mPendingRasterization = false; + } + else { + // TODO: Fix this properly instead of using the single byte texture workaround. + mDataRGBA.push_back(0); + mPendingRasterization = true; + } - // This is important in order to avoid memory leaks. - nsvgDeleteRasterizer(rast); nsvgDelete(svgImage); - mDataRGBA.insert(mDataRGBA.begin(), tempVector.data(), - tempVector.data() + (mWidth * mHeight * 4)); - - ImageIO::flipPixelsVert(mDataRGBA.data(), mWidth, mHeight); - return true; } @@ -148,8 +162,8 @@ bool TextureData::initFromRGBA(const unsigned char* dataRGBA, size_t width, size mDataRGBA.reserve(width * height * 4); mDataRGBA.insert(mDataRGBA.begin(), dataRGBA, dataRGBA + (width * height * 4)); - mWidth = width; - mHeight = height; + mWidth = static_cast(width); + mHeight = static_cast(height); return true; } diff --git a/es-core/src/resources/TextureData.h b/es-core/src/resources/TextureData.h index c50cd19d3..1717bf101 100644 --- a/es-core/src/resources/TextureData.h +++ b/es-core/src/resources/TextureData.h @@ -61,8 +61,13 @@ public: void setScaleDuringLoad(float scale) { mScaleDuringLoad = scale; } // Whether to use linear filtering when magnifying the texture. void setLinearMagnify(bool setting) { mLinearMagnify = setting; } + // Whether to rasterize the image even if a size has not been set yet. + void setForceRasterization(bool setting) { mForceRasterization = setting; } - std::vector getRawRGBAData() { return mDataRGBA; } + // Has the image been loaded but not yet been rasterized as the size was not known? + bool getPendingRasterization() { return mPendingRasterization; } + + std::vector& getRawRGBAData() { return mDataRGBA; } std::string getTextureFilePath() { return mPath; } bool tiled() { return mTile; } @@ -72,14 +77,16 @@ private: std::string mPath; unsigned int mTextureID; std::vector mDataRGBA; - size_t mWidth; - size_t mHeight; + int mWidth; + int mHeight; float mSourceWidth; float mSourceHeight; float mScaleDuringLoad; bool mScalable; bool mLinearMagnify; bool mReloadable; + bool mForceRasterization; + bool mPendingRasterization; }; #endif // ES_CORE_RESOURCES_TEXTURE_DATA_H diff --git a/es-core/src/resources/TextureResource.cpp b/es-core/src/resources/TextureResource.cpp index 74e5d5bfe..8217a9f58 100644 --- a/es-core/src/resources/TextureResource.cpp +++ b/es-core/src/resources/TextureResource.cpp @@ -8,16 +8,20 @@ #include "resources/TextureResource.h" -#include "resources/TextureData.h" #include "utils/FileSystemUtil.h" +#include "utils/StringUtil.h" TextureDataManager TextureResource::sTextureDataManager; std::map> TextureResource::sTextureMap; std::set TextureResource::sAllTextures; -TextureResource::TextureResource( - const std::string& path, bool tile, bool dynamic, bool linearMagnify, float scaleDuringLoad) +TextureResource::TextureResource(const std::string& path, + bool tile, + bool dynamic, + bool linearMagnify, + bool forceRasterization, + float scaleDuringLoad) : mTextureData(nullptr) , mForceLoad(false) { @@ -32,6 +36,7 @@ TextureResource::TextureResource( if (scaleDuringLoad != 1.0f) data->setScaleDuringLoad(scaleDuringLoad); data->setLinearMagnify(linearMagnify); + data->setForceRasterization(forceRasterization); // Force the texture manager to load it using a blocking load. sTextureDataManager.load(data, true); } @@ -42,6 +47,7 @@ TextureResource::TextureResource( if (scaleDuringLoad != 1.0f) data->setScaleDuringLoad(scaleDuringLoad); data->setLinearMagnify(linearMagnify); + data->setForceRasterization(forceRasterization); // Load it so we can read the width/height. data->load(); } @@ -148,14 +154,15 @@ std::shared_ptr TextureResource::get(const std::string& path, bool forceLoad, bool dynamic, bool linearMagnify, + bool forceRasterization, float scaleDuringLoad) { std::shared_ptr& rm = ResourceManager::getInstance(); const std::string canonicalPath = Utils::FileSystem::getCanonicalPath(path); if (canonicalPath.empty()) { - std::shared_ptr tex( - new TextureResource("", tile, false, linearMagnify, scaleDuringLoad)); + std::shared_ptr tex(new TextureResource( + "", tile, false, linearMagnify, forceRasterization, scaleDuringLoad)); // Make sure we get properly deinitialized even though we do nothing on reinitialization. rm->addReloadable(tex); return tex; @@ -171,12 +178,13 @@ std::shared_ptr TextureResource::get(const std::string& path, // Need to create it. std::shared_ptr tex; - tex = std::shared_ptr( - new TextureResource(key.first, tile, dynamic, linearMagnify, scaleDuringLoad)); + tex = std::shared_ptr(new TextureResource( + key.first, tile, dynamic, linearMagnify, forceRasterization, scaleDuringLoad)); std::shared_ptr data = sTextureDataManager.get(tex.get()); // Is it an SVG? - if (key.first.substr(key.first.size() - 4, std::string::npos) != ".svg") { + if (Utils::String::toLower(key.first.substr(key.first.size() - 4, std::string::npos)) != + ".svg") { // Probably not. Add it to our map. We don't add SVGs because 2 SVGs might be // rasterized at different sizes. sTextureMap[key] = std::weak_ptr(tex); @@ -194,7 +202,7 @@ std::shared_ptr TextureResource::get(const std::string& path, return tex; } -void TextureResource::rasterizeAt(size_t width, size_t height) +void TextureResource::rasterizeAt(float width, float height) { if (mTextureData != nullptr) { glm::vec2 textureSize = mTextureData.get()->getSize(); @@ -209,7 +217,7 @@ void TextureResource::rasterizeAt(size_t width, size_t height) data = sTextureDataManager.get(this); mSourceSize = glm::vec2{static_cast(width), static_cast(height)}; data->setSourceSize(static_cast(width), static_cast(height)); - if (mForceLoad || (mTextureData != nullptr)) + if (mForceLoad || mTextureData != nullptr) data->load(); } diff --git a/es-core/src/resources/TextureResource.h b/es-core/src/resources/TextureResource.h index 223d60fcc..7ae64728b 100644 --- a/es-core/src/resources/TextureResource.h +++ b/es-core/src/resources/TextureResource.h @@ -10,6 +10,7 @@ #define ES_CORE_RESOURCES_TEXTURE_RESOURCE_H #include "resources/ResourceManager.h" +#include "resources/TextureData.h" #include "resources/TextureDataManager.h" #include "utils/MathUtil.h" @@ -30,6 +31,7 @@ public: bool forceLoad = false, bool dynamic = true, bool linearMagnify = false, + bool forceRasterization = false, float scaleDuringLoad = 1.0f); void initFromPixels(const unsigned char* dataRGBA, size_t width, size_t height); virtual void initFromMemory(const char* data, size_t length); @@ -38,18 +40,23 @@ public: // Returns the raw pixel values. std::vector getRawRGBAData(); + // Has the image been loaded but not yet been rasterized as the size was not known? + bool getPendingRasterization() + { + return (mTextureData != nullptr ? mTextureData->getPendingRasterization() : false); + } + std::string getTextureFilePath(); // For SVG graphics this function effectively rescales the image to the defined size. // It does unload and re-rasterize the texture though which may cause flickering in some // situations. An alternative is to set a scaling factor directly when loading the texture // using get(), by using the scaleDuringLoad parameter (which also works for raster graphics). - void rasterizeAt(size_t width, size_t height); + void rasterizeAt(float width, float height); glm::vec2 getSourceImageSize() const { return mSourceSize; } virtual ~TextureResource(); - bool isInitialized() const { return true; } bool isTiled() const; const glm::ivec2 getSize() const { return mSize; } @@ -65,6 +72,7 @@ protected: bool tile, bool dynamic, bool linearMagnify, + bool forceRasterization, float scaleDuringLoad); virtual void unload(std::shared_ptr& rm); virtual void reload(std::shared_ptr& rm); diff --git a/resources/graphics/badge_altemulator.svg b/resources/graphics/badge_altemulator.svg new file mode 100644 index 000000000..f8a9d5442 --- /dev/null +++ b/resources/graphics/badge_altemulator.svg @@ -0,0 +1,405 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/graphics/badge_broken.svg b/resources/graphics/badge_broken.svg new file mode 100644 index 000000000..9e631adf0 --- /dev/null +++ b/resources/graphics/badge_broken.svg @@ -0,0 +1,141 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/graphics/badge_completed.svg b/resources/graphics/badge_completed.svg new file mode 100644 index 000000000..941c24cc5 --- /dev/null +++ b/resources/graphics/badge_completed.svg @@ -0,0 +1,150 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/graphics/badge_controller.svg b/resources/graphics/badge_controller.svg new file mode 100644 index 000000000..53faecd2f --- /dev/null +++ b/resources/graphics/badge_controller.svg @@ -0,0 +1,147 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/graphics/badge_favorite.svg b/resources/graphics/badge_favorite.svg new file mode 100644 index 000000000..913880a4b --- /dev/null +++ b/resources/graphics/badge_favorite.svg @@ -0,0 +1,142 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/graphics/badge_kidgame.svg b/resources/graphics/badge_kidgame.svg new file mode 100644 index 000000000..04c066613 --- /dev/null +++ b/resources/graphics/badge_kidgame.svg @@ -0,0 +1,145 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/graphics/controllers/gamepad_generic.svg b/resources/graphics/controllers/gamepad_generic.svg new file mode 100644 index 000000000..b6b01c15a --- /dev/null +++ b/resources/graphics/controllers/gamepad_generic.svg @@ -0,0 +1,69 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/resources/graphics/controllers/gamepad_nintendo_64.svg b/resources/graphics/controllers/gamepad_nintendo_64.svg new file mode 100644 index 000000000..48c9bf4e8 --- /dev/null +++ b/resources/graphics/controllers/gamepad_nintendo_64.svg @@ -0,0 +1,294 @@ + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/graphics/controllers/gamepad_nintendo_nes.svg b/resources/graphics/controllers/gamepad_nintendo_nes.svg new file mode 100644 index 000000000..e546a52eb --- /dev/null +++ b/resources/graphics/controllers/gamepad_nintendo_nes.svg @@ -0,0 +1,334 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/graphics/controllers/gamepad_nintendo_snes.svg b/resources/graphics/controllers/gamepad_nintendo_snes.svg new file mode 100644 index 000000000..f4e823894 --- /dev/null +++ b/resources/graphics/controllers/gamepad_nintendo_snes.svg @@ -0,0 +1,260 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/graphics/controllers/gamepad_playstation.svg b/resources/graphics/controllers/gamepad_playstation.svg new file mode 100644 index 000000000..9ae7276e1 --- /dev/null +++ b/resources/graphics/controllers/gamepad_playstation.svg @@ -0,0 +1,295 @@ + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/graphics/controllers/gamepad_xbox.svg b/resources/graphics/controllers/gamepad_xbox.svg new file mode 100644 index 000000000..b6b01c15a --- /dev/null +++ b/resources/graphics/controllers/gamepad_xbox.svg @@ -0,0 +1,69 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/resources/graphics/controllers/joycon_left_or_right_nintendo.svg b/resources/graphics/controllers/joycon_left_or_right_nintendo.svg new file mode 100644 index 000000000..3a8554f7d --- /dev/null +++ b/resources/graphics/controllers/joycon_left_or_right_nintendo.svg @@ -0,0 +1,314 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/graphics/controllers/joycon_pair_nintendo.svg b/resources/graphics/controllers/joycon_pair_nintendo.svg new file mode 100644 index 000000000..649377f0a --- /dev/null +++ b/resources/graphics/controllers/joycon_pair_nintendo.svg @@ -0,0 +1,322 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/graphics/controllers/joystick_arcade_2_buttons.svg b/resources/graphics/controllers/joystick_arcade_2_buttons.svg new file mode 100644 index 000000000..b6b01c15a --- /dev/null +++ b/resources/graphics/controllers/joystick_arcade_2_buttons.svg @@ -0,0 +1,69 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/resources/graphics/controllers/joystick_arcade_3_buttons.svg b/resources/graphics/controllers/joystick_arcade_3_buttons.svg new file mode 100644 index 000000000..b6b01c15a --- /dev/null +++ b/resources/graphics/controllers/joystick_arcade_3_buttons.svg @@ -0,0 +1,69 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/resources/graphics/controllers/joystick_arcade_4_buttons.svg b/resources/graphics/controllers/joystick_arcade_4_buttons.svg new file mode 100644 index 000000000..b6b01c15a --- /dev/null +++ b/resources/graphics/controllers/joystick_arcade_4_buttons.svg @@ -0,0 +1,69 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/resources/graphics/controllers/joystick_arcade_6_buttons.svg b/resources/graphics/controllers/joystick_arcade_6_buttons.svg new file mode 100644 index 000000000..b6b01c15a --- /dev/null +++ b/resources/graphics/controllers/joystick_arcade_6_buttons.svg @@ -0,0 +1,69 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/resources/graphics/controllers/joystick_generic.svg b/resources/graphics/controllers/joystick_generic.svg new file mode 100644 index 000000000..ebabd7953 --- /dev/null +++ b/resources/graphics/controllers/joystick_generic.svg @@ -0,0 +1,334 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/graphics/controllers/keyboard_generic.svg b/resources/graphics/controllers/keyboard_generic.svg new file mode 100644 index 000000000..b6b01c15a --- /dev/null +++ b/resources/graphics/controllers/keyboard_generic.svg @@ -0,0 +1,69 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/resources/graphics/controllers/keyboard_mouse_generic.svg b/resources/graphics/controllers/keyboard_mouse_generic.svg new file mode 100644 index 000000000..b6b01c15a --- /dev/null +++ b/resources/graphics/controllers/keyboard_mouse_generic.svg @@ -0,0 +1,69 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/resources/graphics/controllers/lightgun_generic.svg b/resources/graphics/controllers/lightgun_generic.svg new file mode 100644 index 000000000..b6b01c15a --- /dev/null +++ b/resources/graphics/controllers/lightgun_generic.svg @@ -0,0 +1,69 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/resources/graphics/controllers/lightgun_nintendo.svg b/resources/graphics/controllers/lightgun_nintendo.svg new file mode 100644 index 000000000..b6b01c15a --- /dev/null +++ b/resources/graphics/controllers/lightgun_nintendo.svg @@ -0,0 +1,69 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/resources/graphics/controllers/mouse_amiga.svg b/resources/graphics/controllers/mouse_amiga.svg new file mode 100644 index 000000000..696cbd88d --- /dev/null +++ b/resources/graphics/controllers/mouse_amiga.svg @@ -0,0 +1,110 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/graphics/controllers/mouse_generic.svg b/resources/graphics/controllers/mouse_generic.svg new file mode 100644 index 000000000..b6b01c15a --- /dev/null +++ b/resources/graphics/controllers/mouse_generic.svg @@ -0,0 +1,69 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/resources/graphics/controllers/steering_wheel_generic.svg b/resources/graphics/controllers/steering_wheel_generic.svg new file mode 100644 index 000000000..b6b01c15a --- /dev/null +++ b/resources/graphics/controllers/steering_wheel_generic.svg @@ -0,0 +1,69 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/resources/graphics/controllers/trackball_generic.svg b/resources/graphics/controllers/trackball_generic.svg new file mode 100644 index 000000000..b6b01c15a --- /dev/null +++ b/resources/graphics/controllers/trackball_generic.svg @@ -0,0 +1,69 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/resources/graphics/controllers/unknown.svg b/resources/graphics/controllers/unknown.svg new file mode 100644 index 000000000..e7b99fea2 --- /dev/null +++ b/resources/graphics/controllers/unknown.svg @@ -0,0 +1,69 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/resources/graphics/controllers/wii_remote_nintendo.svg b/resources/graphics/controllers/wii_remote_nintendo.svg new file mode 100644 index 000000000..c8a5055c7 --- /dev/null +++ b/resources/graphics/controllers/wii_remote_nintendo.svg @@ -0,0 +1,334 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/graphics/controllers/wii_remote_nunchuck_nintendo.svg b/resources/graphics/controllers/wii_remote_nunchuck_nintendo.svg new file mode 100644 index 000000000..d9699c383 --- /dev/null +++ b/resources/graphics/controllers/wii_remote_nunchuck_nintendo.svg @@ -0,0 +1,368 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/graphics/fav_add.svg b/resources/graphics/fav_add.svg deleted file mode 100644 index 34402f462..000000000 --- a/resources/graphics/fav_add.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/resources/graphics/fav_remove.svg b/resources/graphics/fav_remove.svg deleted file mode 100644 index bb5f3f2a7..000000000 --- a/resources/graphics/fav_remove.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/resources/help/button_1.svg b/resources/graphics/help/button_1.svg similarity index 100% rename from resources/help/button_1.svg rename to resources/graphics/help/button_1.svg diff --git a/resources/help/button_2.svg b/resources/graphics/help/button_2.svg similarity index 100% rename from resources/help/button_2.svg rename to resources/graphics/help/button_2.svg diff --git a/resources/help/button_3.svg b/resources/graphics/help/button_3.svg similarity index 100% rename from resources/help/button_3.svg rename to resources/graphics/help/button_3.svg diff --git a/resources/help/button_4.svg b/resources/graphics/help/button_4.svg similarity index 100% rename from resources/help/button_4.svg rename to resources/graphics/help/button_4.svg diff --git a/resources/help/button_a_PS.svg b/resources/graphics/help/button_a_PS.svg similarity index 100% rename from resources/help/button_a_PS.svg rename to resources/graphics/help/button_a_PS.svg diff --git a/resources/help/button_a_SNES.svg b/resources/graphics/help/button_a_SNES.svg similarity index 100% rename from resources/help/button_a_SNES.svg rename to resources/graphics/help/button_a_SNES.svg diff --git a/resources/help/button_a_XBOX.svg b/resources/graphics/help/button_a_XBOX.svg similarity index 100% rename from resources/help/button_a_XBOX.svg rename to resources/graphics/help/button_a_XBOX.svg diff --git a/resources/help/button_b_PS.svg b/resources/graphics/help/button_b_PS.svg similarity index 100% rename from resources/help/button_b_PS.svg rename to resources/graphics/help/button_b_PS.svg diff --git a/resources/help/button_b_SNES.svg b/resources/graphics/help/button_b_SNES.svg similarity index 100% rename from resources/help/button_b_SNES.svg rename to resources/graphics/help/button_b_SNES.svg diff --git a/resources/help/button_b_XBOX.svg b/resources/graphics/help/button_b_XBOX.svg similarity index 100% rename from resources/help/button_b_XBOX.svg rename to resources/graphics/help/button_b_XBOX.svg diff --git a/resources/help/button_back_PS4.svg b/resources/graphics/help/button_back_PS4.svg similarity index 100% rename from resources/help/button_back_PS4.svg rename to resources/graphics/help/button_back_PS4.svg diff --git a/resources/help/button_back_PS5.svg b/resources/graphics/help/button_back_PS5.svg similarity index 100% rename from resources/help/button_back_PS5.svg rename to resources/graphics/help/button_back_PS5.svg diff --git a/resources/help/button_back_SNES.svg b/resources/graphics/help/button_back_SNES.svg similarity index 100% rename from resources/help/button_back_SNES.svg rename to resources/graphics/help/button_back_SNES.svg diff --git a/resources/help/button_back_XBOX.svg b/resources/graphics/help/button_back_XBOX.svg similarity index 100% rename from resources/help/button_back_XBOX.svg rename to resources/graphics/help/button_back_XBOX.svg diff --git a/resources/help/button_back_XBOX360.svg b/resources/graphics/help/button_back_XBOX360.svg similarity index 100% rename from resources/help/button_back_XBOX360.svg rename to resources/graphics/help/button_back_XBOX360.svg diff --git a/resources/help/button_hotkey.svg b/resources/graphics/help/button_hotkey.svg similarity index 100% rename from resources/help/button_hotkey.svg rename to resources/graphics/help/button_hotkey.svg diff --git a/resources/help/button_l.svg b/resources/graphics/help/button_l.svg similarity index 100% rename from resources/help/button_l.svg rename to resources/graphics/help/button_l.svg diff --git a/resources/help/button_lr.svg b/resources/graphics/help/button_lr.svg similarity index 100% rename from resources/help/button_lr.svg rename to resources/graphics/help/button_lr.svg diff --git a/resources/help/button_lt.svg b/resources/graphics/help/button_lt.svg similarity index 100% rename from resources/help/button_lt.svg rename to resources/graphics/help/button_lt.svg diff --git a/resources/help/button_r.svg b/resources/graphics/help/button_r.svg similarity index 100% rename from resources/help/button_r.svg rename to resources/graphics/help/button_r.svg diff --git a/resources/help/button_rt.svg b/resources/graphics/help/button_rt.svg similarity index 100% rename from resources/help/button_rt.svg rename to resources/graphics/help/button_rt.svg diff --git a/resources/help/button_start_PS4.svg b/resources/graphics/help/button_start_PS4.svg similarity index 100% rename from resources/help/button_start_PS4.svg rename to resources/graphics/help/button_start_PS4.svg diff --git a/resources/help/button_start_PS5.svg b/resources/graphics/help/button_start_PS5.svg similarity index 100% rename from resources/help/button_start_PS5.svg rename to resources/graphics/help/button_start_PS5.svg diff --git a/resources/help/button_start_SNES.svg b/resources/graphics/help/button_start_SNES.svg similarity index 100% rename from resources/help/button_start_SNES.svg rename to resources/graphics/help/button_start_SNES.svg diff --git a/resources/help/button_start_XBOX.svg b/resources/graphics/help/button_start_XBOX.svg similarity index 100% rename from resources/help/button_start_XBOX.svg rename to resources/graphics/help/button_start_XBOX.svg diff --git a/resources/help/button_start_XBOX360.svg b/resources/graphics/help/button_start_XBOX360.svg similarity index 100% rename from resources/help/button_start_XBOX360.svg rename to resources/graphics/help/button_start_XBOX360.svg diff --git a/resources/help/button_x_PS.svg b/resources/graphics/help/button_x_PS.svg similarity index 100% rename from resources/help/button_x_PS.svg rename to resources/graphics/help/button_x_PS.svg diff --git a/resources/help/button_x_SNES.svg b/resources/graphics/help/button_x_SNES.svg similarity index 100% rename from resources/help/button_x_SNES.svg rename to resources/graphics/help/button_x_SNES.svg diff --git a/resources/help/button_x_XBOX.svg b/resources/graphics/help/button_x_XBOX.svg similarity index 100% rename from resources/help/button_x_XBOX.svg rename to resources/graphics/help/button_x_XBOX.svg diff --git a/resources/help/button_y_PS.svg b/resources/graphics/help/button_y_PS.svg similarity index 100% rename from resources/help/button_y_PS.svg rename to resources/graphics/help/button_y_PS.svg diff --git a/resources/help/button_y_SNES.svg b/resources/graphics/help/button_y_SNES.svg similarity index 100% rename from resources/help/button_y_SNES.svg rename to resources/graphics/help/button_y_SNES.svg diff --git a/resources/help/button_y_XBOX.svg b/resources/graphics/help/button_y_XBOX.svg similarity index 100% rename from resources/help/button_y_XBOX.svg rename to resources/graphics/help/button_y_XBOX.svg diff --git a/resources/help/dpad_all.svg b/resources/graphics/help/dpad_all.svg similarity index 100% rename from resources/help/dpad_all.svg rename to resources/graphics/help/dpad_all.svg diff --git a/resources/help/dpad_down.svg b/resources/graphics/help/dpad_down.svg similarity index 100% rename from resources/help/dpad_down.svg rename to resources/graphics/help/dpad_down.svg diff --git a/resources/help/dpad_left.svg b/resources/graphics/help/dpad_left.svg similarity index 100% rename from resources/help/dpad_left.svg rename to resources/graphics/help/dpad_left.svg diff --git a/resources/help/dpad_leftright.svg b/resources/graphics/help/dpad_leftright.svg similarity index 100% rename from resources/help/dpad_leftright.svg rename to resources/graphics/help/dpad_leftright.svg diff --git a/resources/help/dpad_right.svg b/resources/graphics/help/dpad_right.svg similarity index 100% rename from resources/help/dpad_right.svg rename to resources/graphics/help/dpad_right.svg diff --git a/resources/help/dpad_up.svg b/resources/graphics/help/dpad_up.svg similarity index 100% rename from resources/help/dpad_up.svg rename to resources/graphics/help/dpad_up.svg diff --git a/resources/help/dpad_updown.svg b/resources/graphics/help/dpad_updown.svg similarity index 100% rename from resources/help/dpad_updown.svg rename to resources/graphics/help/dpad_updown.svg diff --git a/resources/help/mbuttons_a_PS.svg b/resources/graphics/help/mbuttons_a_PS.svg similarity index 100% rename from resources/help/mbuttons_a_PS.svg rename to resources/graphics/help/mbuttons_a_PS.svg diff --git a/resources/help/mbuttons_a_SNES.svg b/resources/graphics/help/mbuttons_a_SNES.svg similarity index 100% rename from resources/help/mbuttons_a_SNES.svg rename to resources/graphics/help/mbuttons_a_SNES.svg diff --git a/resources/help/mbuttons_a_XBOX.svg b/resources/graphics/help/mbuttons_a_XBOX.svg similarity index 100% rename from resources/help/mbuttons_a_XBOX.svg rename to resources/graphics/help/mbuttons_a_XBOX.svg diff --git a/resources/help/mbuttons_b_PS.svg b/resources/graphics/help/mbuttons_b_PS.svg similarity index 100% rename from resources/help/mbuttons_b_PS.svg rename to resources/graphics/help/mbuttons_b_PS.svg diff --git a/resources/help/mbuttons_b_SNES.svg b/resources/graphics/help/mbuttons_b_SNES.svg similarity index 100% rename from resources/help/mbuttons_b_SNES.svg rename to resources/graphics/help/mbuttons_b_SNES.svg diff --git a/resources/help/mbuttons_b_XBOX.svg b/resources/graphics/help/mbuttons_b_XBOX.svg similarity index 100% rename from resources/help/mbuttons_b_XBOX.svg rename to resources/graphics/help/mbuttons_b_XBOX.svg diff --git a/resources/help/mbuttons_x_PS.svg b/resources/graphics/help/mbuttons_x_PS.svg similarity index 100% rename from resources/help/mbuttons_x_PS.svg rename to resources/graphics/help/mbuttons_x_PS.svg diff --git a/resources/help/mbuttons_x_SNES.svg b/resources/graphics/help/mbuttons_x_SNES.svg similarity index 100% rename from resources/help/mbuttons_x_SNES.svg rename to resources/graphics/help/mbuttons_x_SNES.svg diff --git a/resources/help/mbuttons_x_XBOX.svg b/resources/graphics/help/mbuttons_x_XBOX.svg similarity index 100% rename from resources/help/mbuttons_x_XBOX.svg rename to resources/graphics/help/mbuttons_x_XBOX.svg diff --git a/resources/help/mbuttons_y_PS.svg b/resources/graphics/help/mbuttons_y_PS.svg similarity index 100% rename from resources/help/mbuttons_y_PS.svg rename to resources/graphics/help/mbuttons_y_PS.svg diff --git a/resources/help/mbuttons_y_SNES.svg b/resources/graphics/help/mbuttons_y_SNES.svg similarity index 100% rename from resources/help/mbuttons_y_SNES.svg rename to resources/graphics/help/mbuttons_y_SNES.svg diff --git a/resources/help/mbuttons_y_XBOX.svg b/resources/graphics/help/mbuttons_y_XBOX.svg similarity index 100% rename from resources/help/mbuttons_y_XBOX.svg rename to resources/graphics/help/mbuttons_y_XBOX.svg diff --git a/resources/help/thumbstick.svg b/resources/graphics/help/thumbstick.svg similarity index 100% rename from resources/help/thumbstick.svg rename to resources/graphics/help/thumbstick.svg diff --git a/resources/help/thumbstick_click.svg b/resources/graphics/help/thumbstick_click.svg similarity index 100% rename from resources/help/thumbstick_click.svg rename to resources/graphics/help/thumbstick_click.svg diff --git a/resources/help/thumbstick_down.svg b/resources/graphics/help/thumbstick_down.svg similarity index 100% rename from resources/help/thumbstick_down.svg rename to resources/graphics/help/thumbstick_down.svg diff --git a/resources/help/thumbstick_left.svg b/resources/graphics/help/thumbstick_left.svg similarity index 100% rename from resources/help/thumbstick_left.svg rename to resources/graphics/help/thumbstick_left.svg diff --git a/resources/help/thumbstick_right.svg b/resources/graphics/help/thumbstick_right.svg similarity index 100% rename from resources/help/thumbstick_right.svg rename to resources/graphics/help/thumbstick_right.svg diff --git a/resources/help/thumbstick_up.svg b/resources/graphics/help/thumbstick_up.svg similarity index 100% rename from resources/help/thumbstick_up.svg rename to resources/graphics/help/thumbstick_up.svg diff --git a/themes/rbsimple-DE/c64/images/controller.svg b/themes/rbsimple-DE/c64/images/controller.svg index f38851465..c30aa519d 100644 --- a/themes/rbsimple-DE/c64/images/controller.svg +++ b/themes/rbsimple-DE/c64/images/controller.svg @@ -19,14 +19,37 @@ inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)">image/svg+xml + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - + - - + id="g4878"> - - - - - - - - - - - - - - - - - + - \ No newline at end of file + style="opacity:1;fill:#0c0c0c;fill-opacity:1;stroke-width:0.4416638" /> \ No newline at end of file diff --git a/themes/rbsimple-DE/megadrive/images/logo.svg b/themes/rbsimple-DE/megadrive/images/logo.svg index 4bcf3bded..9371aa60a 100644 --- a/themes/rbsimple-DE/megadrive/images/logo.svg +++ b/themes/rbsimple-DE/megadrive/images/logo.svg @@ -3,8 +3,8 @@ + xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="567.500px" + height="90.32px" viewBox="0 0 567.500 90.32" enable-background="new 0 0 566.932 90.32" xml:space="preserve"> diff --git a/themes/rbsimple-DE/switch/images/logo.svg b/themes/rbsimple-DE/switch/images/logo.svg index 04414e24f..5ca4ddafb 100644 --- a/themes/rbsimple-DE/switch/images/logo.svg +++ b/themes/rbsimple-DE/switch/images/logo.svg @@ -7,10 +7,10 @@ xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="2922" - height="644" + width="800" + height="176.36418" version="1.1" - viewBox="0 0 2922 644" + viewBox="0 0 800 176.36418" id="svg2" sodipodi:docname="logo.svg" inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"> @@ -41,31 +41,35 @@ inkscape:window-height="2065" id="namedview4" showgrid="false" - inkscape:zoom="0.30969238" - inkscape:cx="338.77838" - inkscape:cy="458.73741" + inkscape:zoom="2.184783" + inkscape:cx="366.47128" + inkscape:cy="193.80534" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="1" - inkscape:current-layer="svg2" /> + inkscape:current-layer="svg2" + fit-margin-top="0" + fit-margin-left="0" + fit-margin-right="0" + fit-margin-bottom="0" /> + d="M 37.76031,0.58425297 C 20.19122,3.7246229 6.0555905,16.724283 1.5993975,33.813713 c -1.60715171,6.17119 -1.71673023,9.78626 -1.53409936,57.6586 0.10957852,43.965127 0.14610469,44.987577 0.87662817,48.383547 4.05440539,18.29447 17.05772269,31.33064 35.53996669,35.63952 2.410727,0.54774 5.478927,0.65728 25.239586,0.76683 20.454656,0.14606 22.573174,0.10955 23.121068,-0.43819 0.547893,-0.54774 0.584418,-7.5953 0.584418,-87.492077 0,-59.22878 -0.109579,-87.1269201 -0.365262,-87.63814003 -0.365262,-0.65729 -0.986206,-0.6938000088983 -22.390543,-0.65729 -17.386458,0.0365 -22.609702,0.14607 -24.91085,0.54774 z M 70.816496,88.222393 v 73.981197 l -14.866152,-0.18258 c -13.697316,-0.14606 -15.158362,-0.21909 -17.897826,-0.91289 -11.761427,-3.03082 -20.491183,-12.08677 -22.938436,-23.8814 -0.803576,-3.6881 -0.803576,-94.539647 -0.03653,-98.154717 2.191571,-10.26096 9.314175,-18.76917 18.920557,-22.60334 4.821456,-1.93534 7.049552,-2.15443 22.682754,-2.19095 l 14.13563,-0.0365 z" /> + d="m 40.901559,36.552403 c -2.301147,0.4382 -5.807661,2.19096 -7.670494,3.83417 -3.83525,3.32295 -5.734609,8.0335 -5.442401,13.58392 0.146105,2.88475 0.328736,3.65158 1.497574,5.9886 1.716728,3.54204 4.310086,6.13467 7.853125,7.88744 2.447255,1.20502 3.0682,1.35108 6.245977,1.46063 2.885568,0.10955 3.908301,0 5.844189,-0.65729 7.926179,-2.66565 12.711107,-10.37051 11.359638,-18.25794 -1.570626,-9.38459 -10.483011,-15.66532 -19.687608,-13.83953 z" /> + d="m 103.21521,0.25561297 c -0.14611,0.10955 -0.25568,39.69277003 -0.25568,87.96678003 0,79.641157 0.0365,87.711177 0.58441,87.930267 0.98621,0.36516 29.33052,0.2191 32.83703,-0.14606 14.82963,-1.67973 27.906,-10.69916 35.0286,-24.10049 0.91316,-1.71625 2.11852,-4.601 2.73947,-6.39028 2.30115,-6.86499 2.22809,-5.03919 2.22809,-57.512527 0,-41.88373 -0.073,-48.12795 -0.58441,-50.79361 C 172.17662,18.184913 157.67573,3.8341629 138.60907,0.54773297 136.05224,0.10954297 132.10741,2.9611016e-6 119.3963,2.9611016e-6 110.63002,2.9611016e-6 103.32479,0.10954297 103.21521,0.25561297 Z M 142.22516,79.787223 c 5.69808,1.49715 10.37343,5.84254 12.2728,11.39296 1.20536,3.4325 1.16883,8.47169 -0.0365,11.612047 -2.2281,5.76952 -6.61124,9.82278 -12.23627,11.31993 -9.13154,2.37353 -18.84751,-3.14037 -21.51391,-12.19631 -0.80358,-2.775207 -0.76705,-7.449237 0.1461,-10.297477 2.73946,-8.94639 12.23627,-14.20468 21.36781,-11.83115 z" /> + transform="matrix(0.62745924,0,0,0.62745924,-274.21022,-113.86845)"> 0.873 0.212 right + + 0.880 0.757 + 0.13 0.1635 + 0.5 0.5 + left + row + 2 + 3 + 0.5 0.572 + 0.81 + -1.0 0.005 + favorite, completed, kidgame, broken, controller, altemulator +