-
-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CEGUI 'modern' interface #3975
base: master
Are you sure you want to change the base?
CEGUI 'modern' interface #3975
Conversation
todo: autoload the skin changes from a separate source, instead of editing the default skin files
Plus other small fixes. Note: 'host game' window will still use the selected/non-modern skin, since it's created after CLocalGUI (which is wrapped by modern skin toggle)
This reverts commit dc34672. Revert "Implement CGUIGridLayout custom element" This reverts commit 4f47d47. Revert "Add map for item lookup" This reverts commit 5c47f44. Revert "Fix issues with CEGUI testing tab" This reverts commit 42cdfd4. Revert "Minor optimization in item lookup map usage" This reverts commit c80bb0c. Revert "Fix cell item assignment in CGUIGridLayout" This reverts commit 068a497. Revert "Add flex column & row support to CGUIGridLayout" This reverts commit 548e530.
Instead of hardcoding color values in the implementation code
Fantastic job. Let us know when you'd like to receive in depth code reviews. |
Whenever someone has time, this code won't change much now unless there are fixes required or additional features. It's in draft mode purely so it doesn't get merged, even if reviewed. |
CGUILabel* m_pInterfaceModernLabel; | ||
CGUICheckBox* m_pInterfaceModern; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CGUILabel* m_pInterfaceModernLabel; | |
CGUICheckBox* m_pInterfaceModern; | |
CGUILabel* m_pInterfaceModernLabel{}; | |
CGUICheckBox* m_pInterfaceModern{}; |
@@ -118,4 +118,5 @@ class CLocalGUI : public CSingleton<CLocalGUI> | |||
SString m_LastSkinName; | |||
SString m_LastLocaleName; | |||
uint m_LocaleChangeCounter; | |||
bool m_ModernSkinEnabled; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool m_ModernSkinEnabled; | |
bool m_ModernSkinEnabled{}; |
CGraphicsInterface* m_pGraphics; | ||
CXML* m_pXML; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CGraphicsInterface* m_pGraphics; | |
CXML* m_pXML; | |
CGraphicsInterface* m_pGraphics{}; | |
CXML* m_pXML{}; |
|
||
if (!bConvertSkin) | ||
{ | ||
BrowseToSolution("gui-skin", EXIT_GAME_FIRST, SString("Error converting skin '%s' to modern", szName)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Future note: we have to create this help page in the future when this gets merged.
{ | ||
if (!m_pXML) | ||
{ | ||
AddReportLog(1337, "ConvertToModernSkin: XML interface not initialized"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Future note: we have to pick a different number here
Summary
This PR 'extends' the CEGUI skinning implementation, essentially allowing two skins to be used at the same time; the user selected skin, and the 'modern' skin which MTA provides.
The main benefit of this is the ability to toggle between two skins for created CEGUI elements, without needing to rebuild the entire GUI, thereby allowing us to build a new main menu design without affecting in-game/server GUI.
The 'modern' skin used in this PR is simply an example to prove the 'multi-skin' functionality works as intended, and not actually meant to look good or change the overall design of the GUI at this stage
As such this should only be merged alongside other main menu revamp PRs submitted later on. I thought it'd be best to split things up and allow for individual parts of the revamp to get reviewed along the way, making it easier for everyone.
How it works
By generating a merged version of the user selected skin & the modern skin upon launch, plus whenever the user selects a new skin. Merged files include various XML configurations and the PNG imageset.
The modern template original version lives under
MTA/cgui/modern/templates
The merged skin gets created under
MTA/cgui/modern/autogenerated
The modern template has
Modern
appended to Falagard mapping definition names, which allows a different LookNFeel definition to be used whenCGUI::SetModernSkinEnabled
is used (see implementation and usage ofCGUI_Impl::ResolveModernName
). This also avoids clashes with the user selected skin.Imagesets in the modern skin are defined the same as in a normal skin, the position values will get translated automatically when the skins are merged. Again,
Modern
is appended to definition names.The modern skin is versioned, and hashes of the user selected skin are stored in the autogenerated skin directory, so the 'merged' skin is only built when necessary.
Example of merged imageset (user skin left, modern skin right)
Currently (for testing purposes), the generation/usage of modern skin relies on a CVAR
cgui_modern_interface
being true, which can be changed via F8 console (cgui_modern_interface=1
or0
) or viaSettings > Interface > Use modern interface
Testing
A main menu setting has been added (enabled by default) under
Interface > Use modern interface
.Enabling this setting will cause the majority of the main menu to use the 'modern' skin. Some windows will still be generated with the user-selected skin (which is just a dark/black theme), such as "host game" and connection status dialog. This is due to the fact we're enabling the usage of modern skin inside
CLocalGUI::CreateWindows
only, and some of MTA's GUI / main menu actually gets created outside of this method.As this is only for testing purpose, it serves as a way to quickly test the difference between user selected skin and the modern skin without connecting to a server. It goes without saying that server GUI should remain unchanged, and will not use the modern skin.
The current 'modern' skin is just a copy of GWEN Orange iirc, and I've made it into a dark theme instead.
Additional changes
As part of this work, I've also introduced a new method for placeholder color text.
MTA main menu uses labels over the top of inputs to act as a placeholder, hidden once the input gains focus; the color of this label is hardcoded in C++ implementation to black (the opposite of the
TextColours
definition used in all the default skins we provide:<Property name="TextColours" value="tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF" />
). This is bad, since you don't allow the skin to define its own placeholder text color.To resolve this, I've added new methods
CGUILabel_Impl::InvertTextColor()
andCGUILabel_Impl::SetPlaceholderColors()
, the latter is used in replace of instances where we've hardcoded placeholder text color.SetPlaceholderColors
will attempt to look for a"PlaceholderTextColours"
property in the skin's StaticText definition (LookNFeel) and set the color based on that. If this doesn't exist (which is the case for all our default skins) the text color gets inverted instead, resulting in the same behaviour/color as prior for default skins, when modern interface is enabled.excuse the usage of color and colour, MTA uses US variant and CEGUI uses GB