mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-01-31 05:40:44 +00:00
implemented language selection on the IWAD picker.
This commit is contained in:
parent
eb9e9133c9
commit
c7778b9332
9 changed files with 134 additions and 55 deletions
|
@ -11,4 +11,4 @@ struct SingleFontData
|
|||
};
|
||||
|
||||
std::vector<SingleFontData> LoadWidgetFontData(const std::string& name);
|
||||
std::vector<uint8_t> LoadWidgetImageData(const std::string& name);
|
||||
std::vector<uint8_t> LoadWidgetData(const std::string& name);
|
||||
|
|
|
@ -19,6 +19,7 @@ public:
|
|||
|
||||
void Activate();
|
||||
|
||||
std::function<void(int)> OnChanged;
|
||||
std::function<void()> OnActivated;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -249,7 +249,7 @@ BitmapCanvas::BitmapCanvas(DisplayWindow* window) : window(window)
|
|||
uiscale = window->GetDpiScale();
|
||||
uint32_t white = 0xffffffff;
|
||||
whiteTexture = createTexture(1, 1, &white);
|
||||
font = std::make_unique<CanvasFontGroup>("NotoSans", 15.0 * uiscale);
|
||||
font = std::make_unique<CanvasFontGroup>("NotoSans", 13.0 * uiscale);
|
||||
}
|
||||
|
||||
BitmapCanvas::~BitmapCanvas()
|
||||
|
|
|
@ -62,7 +62,7 @@ std::shared_ptr<Image> Image::LoadResource(const std::string& resourcename, doub
|
|||
|
||||
if (extension == "png")
|
||||
{
|
||||
auto filedata = LoadWidgetImageData(resourcename);
|
||||
auto filedata = LoadWidgetData(resourcename);
|
||||
|
||||
std::vector<unsigned char> pixels;
|
||||
unsigned long width = 0, height = 0;
|
||||
|
@ -74,7 +74,7 @@ std::shared_ptr<Image> Image::LoadResource(const std::string& resourcename, doub
|
|||
}
|
||||
else if (extension == "svg")
|
||||
{
|
||||
auto filedata = LoadWidgetImageData(resourcename);
|
||||
auto filedata = LoadWidgetData(resourcename);
|
||||
filedata.push_back(0);
|
||||
|
||||
NSVGimage* svgimage = nsvgParse((char*)filedata.data(), "px", (float)(96.0 * dpiscale));
|
||||
|
|
|
@ -27,6 +27,7 @@ void ListView::SetSelectedItem(int index)
|
|||
if (selectedItem != index && index >= 0 && index < items.size())
|
||||
{
|
||||
selectedItem = index;
|
||||
if (OnChanged) OnChanged(selectedItem);
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ std::vector<SingleFontData> LoadWidgetFontData(const std::string& name)
|
|||
return returnv;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> LoadWidgetImageData(const std::string& name)
|
||||
std::vector<uint8_t> LoadWidgetData(const std::string& name)
|
||||
{
|
||||
return LoadFile(name.c_str());
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "version.h"
|
||||
#include "i_interface.h"
|
||||
#include "gstrings.h"
|
||||
#include <zwidget/core/resourcedata.h>
|
||||
#include <zwidget/core/image.h>
|
||||
#include <zwidget/window/window.h>
|
||||
#include <zwidget/widgets/textedit/textedit.h>
|
||||
|
@ -17,13 +18,14 @@
|
|||
EXTERN_CVAR(Int, vid_preferbackend);
|
||||
#endif
|
||||
|
||||
EXTERN_CVAR(String, language)
|
||||
EXTERN_CVAR(Bool, queryiwad);
|
||||
|
||||
int LauncherWindow::ExecModal(WadStuff* wads, int numwads, int defaultiwad, int* autoloadflags)
|
||||
{
|
||||
Size screenSize = GetScreenSize();
|
||||
double windowWidth = 615.0;
|
||||
double windowHeight = 668.0;
|
||||
double windowHeight = 700.0;
|
||||
|
||||
auto launcher = std::make_unique<LauncherWindow>(wads, numwads, defaultiwad, autoloadflags);
|
||||
launcher->SetFrameGeometry((screenSize.width - windowWidth) * 0.5, (screenSize.height - windowHeight) * 0.5, windowWidth, windowHeight);
|
||||
|
@ -34,36 +36,9 @@ int LauncherWindow::ExecModal(WadStuff* wads, int numwads, int defaultiwad, int*
|
|||
return launcher->ExecResult;
|
||||
}
|
||||
|
||||
LauncherWindow::LauncherWindow(WadStuff* wads, int numwads, int defaultiwad, int* autoloadflags) : Widget(nullptr, WidgetType::Window), AutoloadFlags(autoloadflags)
|
||||
void LauncherWindow::UpdateLanguage()
|
||||
{
|
||||
SetWindowBackground(Colorf::fromRgba8(51, 51, 51));
|
||||
SetWindowBorderColor(Colorf::fromRgba8(51, 51, 51));
|
||||
SetWindowCaptionColor(Colorf::fromRgba8(33, 33, 33));
|
||||
SetWindowCaptionTextColor(Colorf::fromRgba8(226, 223, 219));
|
||||
SetWindowTitle(GAMENAME);
|
||||
|
||||
Logo = new ImageBox(this);
|
||||
WelcomeLabel = new TextLabel(this);
|
||||
VersionLabel = new TextLabel(this);
|
||||
SelectLabel = new TextLabel(this);
|
||||
GeneralLabel = new TextLabel(this);
|
||||
ExtrasLabel = new TextLabel(this);
|
||||
ParametersLabel = new TextLabel(this);
|
||||
FullscreenCheckbox = new CheckboxLabel(this);
|
||||
DisableAutoloadCheckbox = new CheckboxLabel(this);
|
||||
DontAskAgainCheckbox = new CheckboxLabel(this);
|
||||
LightsCheckbox = new CheckboxLabel(this);
|
||||
BrightmapsCheckbox = new CheckboxLabel(this);
|
||||
WidescreenCheckbox = new CheckboxLabel(this);
|
||||
PlayButton = new PushButton(this);
|
||||
ExitButton = new PushButton(this);
|
||||
GamesList = new ListView(this);
|
||||
ParametersEdit = new LineEdit(this);
|
||||
|
||||
PlayButton->OnClick = [=]() { OnPlayButtonClicked(); };
|
||||
ExitButton->OnClick = [=]() { OnExitButtonClicked(); };
|
||||
GamesList->OnActivated = [=]() { OnGamesListActivated(); };
|
||||
|
||||
LangLabel->SetText(GStrings("OPTMNU_LANGUAGE"));
|
||||
SelectLabel->SetText(GStrings("PICKER_SELECT"));
|
||||
PlayButton->SetText(GStrings("PICKER_PLAY"));
|
||||
ExitButton->SetText(GStrings("PICKER_EXIT"));
|
||||
|
@ -79,11 +54,7 @@ LauncherWindow::LauncherWindow(WadStuff* wads, int numwads, int defaultiwad, int
|
|||
ParametersLabel->SetText(GStrings("PICKER_ADDPARM"));
|
||||
|
||||
#ifdef RENDER_BACKENDS
|
||||
BackendLabel = new TextLabel(this);
|
||||
VulkanCheckbox = new CheckboxLabel(this);
|
||||
OpenGLCheckbox = new CheckboxLabel(this);
|
||||
GLESCheckbox = new CheckboxLabel(this);
|
||||
BackendLabel->SetText(GStrings("VIDMNU_PREFERBACKEND"));
|
||||
BackendLabel->SetText(GStrings("PICKER_PREFERBACKEND"));
|
||||
VulkanCheckbox->SetText(GStrings("OPTVAL_VULKAN"));
|
||||
OpenGLCheckbox->SetText(GStrings("OPTVAL_OPENGL"));
|
||||
GLESCheckbox->SetText(GStrings("OPTVAL_OPENGLES"));
|
||||
|
@ -95,6 +66,48 @@ LauncherWindow::LauncherWindow(WadStuff* wads, int numwads, int defaultiwad, int
|
|||
versionText.Substitute("%s", GetVersionString());
|
||||
WelcomeLabel->SetText(welcomeText.GetChars());
|
||||
VersionLabel->SetText(versionText.GetChars());
|
||||
}
|
||||
|
||||
LauncherWindow::LauncherWindow(WadStuff* wads, int numwads, int defaultiwad, int* autoloadflags) : Widget(nullptr, WidgetType::Window), AutoloadFlags(autoloadflags)
|
||||
{
|
||||
SetWindowBackground(Colorf::fromRgba8(51, 51, 51));
|
||||
SetWindowBorderColor(Colorf::fromRgba8(51, 51, 51));
|
||||
SetWindowCaptionColor(Colorf::fromRgba8(33, 33, 33));
|
||||
SetWindowCaptionTextColor(Colorf::fromRgba8(226, 223, 219));
|
||||
SetWindowTitle(GAMENAME);
|
||||
|
||||
Logo = new ImageBox(this);
|
||||
WelcomeLabel = new TextLabel(this);
|
||||
VersionLabel = new TextLabel(this);
|
||||
LangLabel = new TextLabel(this);
|
||||
SelectLabel = new TextLabel(this);
|
||||
GeneralLabel = new TextLabel(this);
|
||||
ExtrasLabel = new TextLabel(this);
|
||||
ParametersLabel = new TextLabel(this);
|
||||
FullscreenCheckbox = new CheckboxLabel(this);
|
||||
DisableAutoloadCheckbox = new CheckboxLabel(this);
|
||||
DontAskAgainCheckbox = new CheckboxLabel(this);
|
||||
LightsCheckbox = new CheckboxLabel(this);
|
||||
BrightmapsCheckbox = new CheckboxLabel(this);
|
||||
WidescreenCheckbox = new CheckboxLabel(this);
|
||||
PlayButton = new PushButton(this);
|
||||
ExitButton = new PushButton(this);
|
||||
LangList = new ListView(this);
|
||||
GamesList = new ListView(this);
|
||||
ParametersEdit = new LineEdit(this);
|
||||
|
||||
#ifdef RENDER_BACKENDS
|
||||
BackendLabel = new TextLabel(this);
|
||||
VulkanCheckbox = new CheckboxLabel(this);
|
||||
OpenGLCheckbox = new CheckboxLabel(this);
|
||||
GLESCheckbox = new CheckboxLabel(this);
|
||||
#endif
|
||||
|
||||
PlayButton->OnClick = [=]() { OnPlayButtonClicked(); };
|
||||
ExitButton->OnClick = [=]() { OnExitButtonClicked(); };
|
||||
GamesList->OnActivated = [=]() { OnGamesListActivated(); };
|
||||
|
||||
UpdateLanguage();
|
||||
|
||||
FullscreenCheckbox->SetChecked(vid_fullscreen);
|
||||
DontAskAgainCheckbox->SetChecked(!queryiwad);
|
||||
|
@ -126,6 +139,45 @@ LauncherWindow::LauncherWindow(WadStuff* wads, int numwads, int defaultiwad, int
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
auto data = LoadWidgetData("menudef.txt");
|
||||
FScanner sc;
|
||||
sc.OpenMem("menudef.txt", data);
|
||||
while (sc.GetString())
|
||||
{
|
||||
if (sc.Compare("OptionString"))
|
||||
{
|
||||
sc.MustGetString();
|
||||
if (sc.Compare("LanguageOptions"))
|
||||
{
|
||||
sc.MustGetStringName("{");
|
||||
while (!sc.CheckString("}"))
|
||||
{
|
||||
sc.MustGetString();
|
||||
FString iso = sc.String;
|
||||
sc.MustGetStringName(",");
|
||||
sc.MustGetString();
|
||||
if(iso.CompareNoCase("auto"))
|
||||
languages.push_back(std::make_pair(iso, FString(sc.String)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
hideLanguage = true;
|
||||
}
|
||||
int i = 0;
|
||||
for (auto& l : languages)
|
||||
{
|
||||
LangList->AddItem(l.second.GetChars());
|
||||
if (!l.first.CompareNoCase(::language))
|
||||
LangList->SetSelectedItem(i);
|
||||
i++;
|
||||
}
|
||||
for (int i = 0; i < numwads; i++)
|
||||
{
|
||||
const char* filepart = strrchr(wads[i].Path.GetChars(), '/');
|
||||
|
@ -150,6 +202,14 @@ LauncherWindow::LauncherWindow(WadStuff* wads, int numwads, int defaultiwad, int
|
|||
Logo->SetImage(Image::LoadResource("widgets/banner.png"));
|
||||
|
||||
GamesList->SetFocus();
|
||||
|
||||
LangList->OnChanged = [this](int i)
|
||||
{
|
||||
::language = languages[i].first.GetChars();
|
||||
GStrings.UpdateLanguage(::language); // CVAR callbacks are not active yet.
|
||||
UpdateLanguage();
|
||||
Update();
|
||||
};
|
||||
}
|
||||
|
||||
void LauncherWindow::OnClose()
|
||||
|
@ -215,10 +275,19 @@ void LauncherWindow::OnGeometryChanged()
|
|||
|
||||
y += 10.0;
|
||||
|
||||
if (!hideLanguage)
|
||||
{
|
||||
LangLabel->SetFrameGeometry(20.0, y, GetWidth() - 40.0, SelectLabel->GetPreferredHeight());
|
||||
y += LangLabel->GetPreferredHeight();
|
||||
LangList->SetFrameGeometry(20.0, y, GetWidth() - 40.0, 61);
|
||||
y += 64.0;
|
||||
}
|
||||
|
||||
|
||||
SelectLabel->SetFrameGeometry(20.0, y, GetWidth() - 40.0, SelectLabel->GetPreferredHeight());
|
||||
y += SelectLabel->GetPreferredHeight();
|
||||
|
||||
double listViewTop = y + 10.0;
|
||||
double listViewTop = y;
|
||||
|
||||
y = GetHeight() - 15.0 - PlayButton->GetPreferredHeight();
|
||||
PlayButton->SetFrameGeometry(20.0, y, 120.0, PlayButton->GetPreferredHeight());
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <zwidget/core/widget.h>
|
||||
#include "tarray.h"
|
||||
#include "zstring.h"
|
||||
|
||||
|
||||
#define RENDER_BACKENDS
|
||||
|
@ -27,10 +29,12 @@ private:
|
|||
|
||||
void OnClose() override;
|
||||
void OnGeometryChanged() override;
|
||||
void UpdateLanguage();
|
||||
|
||||
ImageBox* Logo = nullptr;
|
||||
TextLabel* WelcomeLabel = nullptr;
|
||||
TextLabel* VersionLabel = nullptr;
|
||||
TextLabel* LangLabel = nullptr;
|
||||
TextLabel* SelectLabel = nullptr;
|
||||
TextLabel* GeneralLabel = nullptr;
|
||||
TextLabel* ExtrasLabel = nullptr;
|
||||
|
@ -50,8 +54,11 @@ private:
|
|||
PushButton* PlayButton = nullptr;
|
||||
PushButton* ExitButton = nullptr;
|
||||
ListView* GamesList = nullptr;
|
||||
ListView* LangList = nullptr;
|
||||
LineEdit* ParametersEdit = nullptr;
|
||||
|
||||
int* AutoloadFlags = nullptr;
|
||||
int ExecResult = -1;
|
||||
bool hideLanguage = false;
|
||||
TArray<std::pair<FString, FString>> languages;
|
||||
};
|
||||
|
|
|
@ -859,17 +859,18 @@ Sprite Options,OPTMNU_SPRITE,,,,Sprity,Sprite-indstillinger,Spriteoptionen,,Agor
|
|||
Coronas,GLPREFMNU_CORONAS,,,,Záře,Coronas,,,Lum-ampoloj,Focos de luz,,,,,,光冠,,Corona's,Koronaer,Korony,,,,Короны,,Koronor,Koronalar,Корони,
|
||||
Appearance,DSPLYMNU_APPEARANCE,,,,Vzhled,Udseende,Spieldarstellung,,Aspekto,Apariencia,,,,,,アピアランス,,Uiterlijk,Utseende,Wygląd,Aparência,,,Внешность,,Utseende,Görünüş,Зовнішній вигляд,
|
||||
Advanced Display Options,DSPLYMNU_ADVANCED,,,,Grafika (pokročilé),Avancerede visningsindstillinger,Erweiterte Anzeigeoptionen,,Altnivelaj ekran-agordoj,Opciones avanzadas de visualización,,,,,,高度なディスプレイオプション,,Geavanceerde Weergave Opties,Avanserte visningsalternativer,Zaawansowane Opcje Wyświetlania,Opções de vídeo avançadas,,,Расширенные настройки экрана,,Avancerade visningsalternativ,Gelişmiş Görüntüleme Seçenekleri,Додаткові параметри відображення,
|
||||
Select which game file to run.,PICKER_SELECT,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
Play Game,PICKER_PLAY,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
Exit,PICKER_EXIT,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
General,PICKER_GENERAL,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
Extra Graphics,PICKER_EXTRA,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
Fullscreen,PICKER_FULLSCREEN,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
Disable autoload,PICKER_NOAUTOLOAD,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
Don't ask me again,PICKER_DONTASK,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
Lights,PICKER_LIGHTS,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
Brightmaps,PICKER_BRIGHTMAPS,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
Widescreen,PICKER_WIDESCREEN,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
Additional Parameters:,PICKER_ADDPARM,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
Welcome to %s!,PICKER_WELCOME,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
Version %s,PICKER_VERSION,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||
Select which game file to run.,PICKER_SELECT,,,,,,Bitte wähle ein Spiel aus.,,,,,,,,,,,,,,,,,Выбор файла игры для запуска.,,,,,
|
||||
Play Game,PICKER_PLAY,,,,,,Spielen,,,,,,,,,,,,,,,,,Играть,,,,,
|
||||
Exit,PICKER_EXIT,,,,,,Verlassen,,,,,,,,,,,,,,,,,Выход,,,,,
|
||||
General,PICKER_GENERAL,,,,,,Allgemein,,,,,,,,,,,,,,,,,Общее,,,,,
|
||||
Extra Graphics,PICKER_EXTRA,,,,,,Extragrafiken,,,,,,,,,,,,,,,,,Доп. графика,,,,,
|
||||
Fullscreen,PICKER_FULLSCREEN,,,,,,Vollbild,,,,,,,,,,,,,,,,,Полный экран,,,,,
|
||||
Disable autoload,PICKER_NOAUTOLOAD,,,,,,Autoload deaktivieren,,,,,,,,,,,,,,,,,Отключить автозагрузку,,,,,
|
||||
Don't ask me again,PICKER_DONTASK,,,,,,Nicht nochmal fragen,,,,,,,,,,,,,,,,,Не спрашивать снова,,,,,
|
||||
Lights,PICKER_LIGHTS,,,,,,Lichter,,,,,,,,,,,,,,,,,Освещение,,,,,
|
||||
Brightmaps,PICKER_BRIGHTMAPS,,,,,,,,,,,,,,,,,,,,,,,Карты освещения,,,,,
|
||||
Widescreen,PICKER_WIDESCREEN,,,,,,Breitbildunterstützung,,,,,,,,,,,,,,,,,Широкий экран,,,,,
|
||||
Additional Parameters:,PICKER_ADDPARM,,,,,,Zusätzliche Parameter,,,,,,,,,,,,,,,,,Доп. параметры:,,,,,
|
||||
Welcome to %s!,PICKER_WELCOME,,,,,,Willkommen bei %s!,,,,,,,,,,,,,,,,,Добро пожаловать в %s!,,,,,
|
||||
Version %s,PICKER_VERSION,,,,,,,,,,,,,,,,,,,,,,,Версия %s,,,,,
|
||||
Rendering API,PICKER_PREFERBACKEND,,,,API vykreslování,,Render API,,Preferita bildigado de API,API de renderizado,,Renderöinti API,API de rendu,Renderelő API,API di rendering,優先レンダリングAPI,기본적인 API 랜더링,,,API renderowania,API de renderização,,API Video Preferat,API для рендеринга,АПИ приказивања,API för rendering,,API для візуалізації,
|
Loading…
Reference in a new issue