Add updated theme

This commit is contained in:
Marcus Minhorst 2025-08-26 23:01:44 -04:00
commit cee2f9eb19
2 changed files with 43 additions and 6 deletions

View file

@ -1,6 +1,7 @@
#include <zwidget/core/resourcedata.h>
#include <zwidget/core/theme.h>
#include "c_cvars.h"
#include "filesystem.h"
#include "printf.h"
#include "zstring.h"
@ -10,6 +11,12 @@
#include <windows.h>
#endif
CUSTOM_CVARD(Int, ui_theme, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "launcher theme. 0: auto, 1: dark, 2: light")
{
if (self < 0) self = 0;
if (self > 2) self = 2;
}
FResourceFile* WidgetResources;
bool IsZWidgetAvailable()
@ -23,7 +30,35 @@ void InitWidgetResources(const char* filename)
if (!WidgetResources)
I_FatalError("Unable to open %s", filename);
WidgetTheme::SetTheme(std::make_unique<DarkWidgetTheme>());
bool use_dark = ui_theme != 2;
if (ui_theme == 0)
{
// TODO: detect system theme
}
if (use_dark) // light
{
// TODO: make a nice theme
WidgetTheme::SetTheme(std::make_unique<DarkWidgetTheme>());
}
else
{
WidgetTheme::SetTheme(std::unique_ptr<WidgetTheme>(new WidgetTheme{{
Colorf::fromRgb(0xeee8d5), // background
Colorf::fromRgb(0x000000), // text
Colorf::fromRgb(0xfdf6e3), // headers / inputs
Colorf::fromRgb(0x000000), // headers / inputs text
Colorf::fromRgb(0xd7d2bf), // interactive elements
Colorf::fromRgb(0x000000), // interactive elements text
Colorf::fromRgb(0xa4c2e9), // hover / highlight
Colorf::fromRgb(0x000000), // hover / highlight text
Colorf::fromRgb(0x7ca2e9), // click
Colorf::fromRgb(0x000000), // click text
Colorf::fromRgb(0x586e75), // around elements
Colorf::fromRgb(0xbdb8a7) // between elements
}}));
}
}
void CloseWidgetResources()

View file

@ -223,9 +223,10 @@ HostSubPage::HostSubPage(NetworkPage* main, const FStartupSelectionInfo& info) :
PortHintLabel = new TextLabel(this);
TeamHintLabel = new TextLabel(this);
MaxPlayerHintLabel->SetStyleColor("color", Colorf::fromRgba8(160, 160, 160));
PortHintLabel->SetStyleColor("color", Colorf::fromRgba8(160, 160, 160));
TeamHintLabel->SetStyleColor("color", Colorf::fromRgba8(160, 160, 160));
// TODO: Themeable de-emphasis
// MaxPlayerHintLabel->SetStyleColor("color", Colorf::fromRgba8(160, 160, 160));
// PortHintLabel->SetStyleColor("color", Colorf::fromRgba8(160, 160, 160));
// TeamHintLabel->SetStyleColor("color", Colorf::fromRgba8(160, 160, 160));
}
void HostSubPage::SetValues(FStartupSelectionInfo& info) const
@ -397,8 +398,9 @@ JoinSubPage::JoinSubPage(NetworkPage* main, const FStartupSelectionInfo& info) :
AddressPortHintLabel = new TextLabel(this);
TeamHintLabel = new TextLabel(this);
AddressPortHintLabel->SetStyleColor("color", Colorf::fromRgba8(160, 160, 160));
TeamHintLabel->SetStyleColor("color", Colorf::fromRgba8(160, 160, 160));
// TODO: Themeable de-emphasis
// AddressPortHintLabel->SetStyleColor("color", Colorf::fromRgba8(160, 160, 160));
// TeamHintLabel->SetStyleColor("color", Colorf::fromRgba8(160, 160, 160));
}
void JoinSubPage::SetValues(FStartupSelectionInfo& info) const