All new types, locals and globals should use CamelCase.
This commit is contained in:
parent
17c059b6f7
commit
78c8acc31e
|
@ -7,20 +7,20 @@
|
||||||
#include "winmain.h"
|
#include "winmain.h"
|
||||||
|
|
||||||
static const char* popupName = "Font Selection";
|
static const char* popupName = "Font Selection";
|
||||||
bool font_selection::ShowDialog = false;
|
bool font_selection::ShowDialogFlag = false;
|
||||||
char font_selection::DialogInputBuffer[512];
|
char font_selection::DialogInputBuffer[512];
|
||||||
|
|
||||||
void font_selection::show_dialog()
|
void font_selection::ShowDialog()
|
||||||
{
|
{
|
||||||
ShowDialog = true;
|
ShowDialogFlag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void font_selection::RenderDialog()
|
void font_selection::RenderDialog()
|
||||||
{
|
{
|
||||||
if (ShowDialog == true)
|
if (ShowDialogFlag == true)
|
||||||
{
|
{
|
||||||
strncpy(DialogInputBuffer, options::Options.FontFileName.c_str(), sizeof(DialogInputBuffer));
|
strncpy(DialogInputBuffer, options::Options.FontFileName.c_str(), sizeof(DialogInputBuffer));
|
||||||
ShowDialog = false;
|
ShowDialogFlag = false;
|
||||||
if (!ImGui::IsPopupOpen(popupName))
|
if (!ImGui::IsPopupOpen(popupName))
|
||||||
{
|
{
|
||||||
ImGui::OpenPopup(popupName);
|
ImGui::OpenPopup(popupName);
|
||||||
|
@ -33,7 +33,7 @@ void font_selection::RenderDialog()
|
||||||
ImGui::Text("Font file to use: ");
|
ImGui::Text("Font file to use: ");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::InputText("", DialogInputBuffer, IM_ARRAYSIZE(DialogInputBuffer));
|
ImGui::InputText("", DialogInputBuffer, IM_ARRAYSIZE(DialogInputBuffer));
|
||||||
|
|
||||||
if (ImGui::Button(pinball::get_rc_string(Msg::HIGHSCORES_Ok)))
|
if (ImGui::Button(pinball::get_rc_string(Msg::HIGHSCORES_Ok)))
|
||||||
{
|
{
|
||||||
options::Options.FontFileName = DialogInputBuffer;
|
options::Options.FontFileName = DialogInputBuffer;
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
class font_selection
|
class font_selection
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void show_dialog();
|
static void ShowDialog();
|
||||||
static void RenderDialog();
|
static void RenderDialog();
|
||||||
private:
|
private:
|
||||||
static bool ShowDialog;
|
static bool ShowDialogFlag;
|
||||||
static char DialogInputBuffer[512];
|
static char DialogInputBuffer[512];
|
||||||
};
|
};
|
||||||
|
|
|
@ -114,7 +114,7 @@ void options::InitPrimary()
|
||||||
Options.DebugOverlayCollisionMask = get_int("Debug Overlay Collision Mask", true);
|
Options.DebugOverlayCollisionMask = get_int("Debug Overlay Collision Mask", true);
|
||||||
Options.DebugOverlaySprites = get_int("Debug Overlay Sprites", true);
|
Options.DebugOverlaySprites = get_int("Debug Overlay Sprites", true);
|
||||||
Options.DebugOverlaySounds = get_int("Debug Overlay Sounds", true);
|
Options.DebugOverlaySounds = get_int("Debug Overlay Sounds", true);
|
||||||
translations::set_current_language(get_string("Language", translations::get_current_language()->short_name).c_str());
|
translations::SetCurrentLanguage(get_string("Language", translations::GetCurrentLanguage()->ShortName).c_str());
|
||||||
Options.FontFileName = get_string("FontFileName", "");
|
Options.FontFileName = get_string("FontFileName", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ void options::uninit()
|
||||||
set_int("Debug Overlay Collision Mask", Options.DebugOverlayCollisionMask);
|
set_int("Debug Overlay Collision Mask", Options.DebugOverlayCollisionMask);
|
||||||
set_int("Debug Overlay Sprites", Options.DebugOverlaySprites);
|
set_int("Debug Overlay Sprites", Options.DebugOverlaySprites);
|
||||||
set_int("Debug Overlay Sounds", Options.DebugOverlaySounds);
|
set_int("Debug Overlay Sounds", Options.DebugOverlaySounds);
|
||||||
set_string("Language", translations::get_current_language()->short_name);
|
set_string("Language", translations::GetCurrentLanguage()->ShortName);
|
||||||
set_string("FontFileName", Options.FontFileName.c_str());
|
set_string("FontFileName", Options.FontFileName.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
int LoadStringAlt(Msg uID, LPSTR lpBuffer, int cchBufferMax)
|
int LoadStringAlt(Msg uID, LPSTR lpBuffer, int cchBufferMax)
|
||||||
{
|
{
|
||||||
const char* text = translations::get_translation(uID);
|
const char* text = translations::GetTranslation(uID);
|
||||||
|
|
||||||
strncpy(lpBuffer, text, cchBufferMax);
|
strncpy(lpBuffer, text, cchBufferMax);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -258,7 +258,7 @@ enum class Msg : int
|
||||||
Max,
|
Max,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class lang : int
|
enum class Lang : int
|
||||||
{
|
{
|
||||||
Min = 0,
|
Min = 0,
|
||||||
Arabic = 0,
|
Arabic = 0,
|
||||||
|
@ -290,7 +290,7 @@ enum class lang : int
|
||||||
|
|
||||||
struct TextArray
|
struct TextArray
|
||||||
{
|
{
|
||||||
TextArray(const std::initializer_list<std::pair<Msg, std::initializer_list<std::pair<lang, LPCSTR>>>>& iList)
|
TextArray(const std::initializer_list<std::pair<Msg, std::initializer_list<std::pair<Lang, LPCSTR>>>>& iList)
|
||||||
{
|
{
|
||||||
for (const auto& msgPair : iList)
|
for (const auto& msgPair : iList)
|
||||||
{
|
{
|
||||||
|
@ -302,14 +302,14 @@ struct TextArray
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LPCSTR Get(Msg msgId, lang langId) const
|
LPCSTR Get(Msg msgId, Lang langId) const
|
||||||
{
|
{
|
||||||
assertm(TextArray::contains(msgId), "Message Id out of bounds");
|
assertm(TextArray::contains(msgId), "Message Id out of bounds");
|
||||||
assertm(TextArray::contains(langId), "Language Id out of bounds");
|
assertm(TextArray::contains(langId), "Language Id out of bounds");
|
||||||
return Store[static_cast<int>(msgId)][static_cast<int>(langId)];
|
return Store[static_cast<int>(msgId)][static_cast<int>(langId)];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool contains(Msg msgId, lang langId) const
|
bool contains(Msg msgId, Lang langId) const
|
||||||
{
|
{
|
||||||
return contains(msgId) && Get(msgId, langId) != nullptr;
|
return contains(msgId) && Get(msgId, langId) != nullptr;
|
||||||
}
|
}
|
||||||
|
@ -319,15 +319,15 @@ struct TextArray
|
||||||
return msgId >= Msg::Min && msgId < Msg::Max;
|
return msgId >= Msg::Min && msgId < Msg::Max;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool contains(lang langId)
|
static bool contains(Lang langId)
|
||||||
{
|
{
|
||||||
return langId >= lang::Min && langId < lang::Max;
|
return langId >= Lang::Min && langId < Lang::Max;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LPCSTR Store[static_cast<int>(Msg::Max )][static_cast<int>(lang::Max)]{ nullptr };
|
LPCSTR Store[static_cast<int>(Msg::Max )][static_cast<int>(Lang::Max)]{ nullptr };
|
||||||
|
|
||||||
void Set(Msg msgId, lang langId, LPCSTR value)
|
void Set(Msg msgId, Lang langId, LPCSTR value)
|
||||||
{
|
{
|
||||||
assertm(TextArray::contains(msgId), "Message Id out of bounds");
|
assertm(TextArray::contains(msgId), "Message Id out of bounds");
|
||||||
assertm(TextArray::contains(langId), "Language Id out of bounds");
|
assertm(TextArray::contains(langId), "Language Id out of bounds");
|
||||||
|
@ -335,24 +335,24 @@ private:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct languageInfo
|
struct LanguageInfo
|
||||||
{
|
{
|
||||||
const lang Language;
|
const Lang Language;
|
||||||
const char* short_name;
|
const char* ShortName;
|
||||||
const char* display_name;
|
const char* DisplayName;
|
||||||
};
|
};
|
||||||
|
|
||||||
class translations
|
class translations
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const languageInfo Languages[static_cast<int>(lang::Max)];
|
static const LanguageInfo Languages[static_cast<int>(Lang::Max)];
|
||||||
|
|
||||||
static const char* get_translation(Msg id);
|
static const char* GetTranslation(Msg id);
|
||||||
static void set_current_language(const char* short_name);
|
static void SetCurrentLanguage(const char* short_name);
|
||||||
static const languageInfo* get_current_language();
|
static const LanguageInfo* GetCurrentLanguage();
|
||||||
static void get_glyph_range(ImVector<ImWchar>* ranges);
|
static void GetGlyphRange(ImVector<ImWchar>* ranges);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const TextArray Translations;
|
static const TextArray Translations;
|
||||||
static lang current_language;
|
static Lang CurrentLanguage;
|
||||||
};
|
};
|
||||||
|
|
|
@ -120,7 +120,7 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
||||||
ImGuiSDL::Deinitialize();
|
ImGuiSDL::Deinitialize();
|
||||||
io.Fonts->Clear();
|
io.Fonts->Clear();
|
||||||
ImVector<ImWchar> ranges;
|
ImVector<ImWchar> ranges;
|
||||||
translations::get_glyph_range(&ranges);
|
translations::GetGlyphRange(&ranges);
|
||||||
ImFontConfig fontConfig;
|
ImFontConfig fontConfig;
|
||||||
fontConfig.OversampleV = 2;
|
fontConfig.OversampleV = 2;
|
||||||
fontConfig.OversampleH = 8;
|
fontConfig.OversampleH = 8;
|
||||||
|
@ -469,12 +469,12 @@ void winmain::RenderUi()
|
||||||
}
|
}
|
||||||
if (ImGui::BeginMenu("Language"))
|
if (ImGui::BeginMenu("Language"))
|
||||||
{
|
{
|
||||||
auto currentLanguage = translations::get_current_language();
|
auto currentLanguage = translations::GetCurrentLanguage();
|
||||||
for (auto &item : translations::Languages)
|
for (auto &item : translations::Languages)
|
||||||
{
|
{
|
||||||
if (ImGui::MenuItem(item.display_name, nullptr, currentLanguage->Language == item.Language))
|
if (ImGui::MenuItem(item.DisplayName, nullptr, currentLanguage->Language == item.Language))
|
||||||
{
|
{
|
||||||
translations::set_current_language(item.short_name);
|
translations::SetCurrentLanguage(item.ShortName);
|
||||||
winmain::Restart();
|
winmain::Restart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -523,7 +523,7 @@ void winmain::RenderUi()
|
||||||
{
|
{
|
||||||
if (ImGui::MenuItem("Change Font"))
|
if (ImGui::MenuItem("Change Font"))
|
||||||
{
|
{
|
||||||
font_selection::show_dialog();
|
font_selection::ShowDialog();
|
||||||
}
|
}
|
||||||
if (ImGui::MenuItem("Uniform Scaling", nullptr, Options.UniformScaling))
|
if (ImGui::MenuItem("Uniform Scaling", nullptr, Options.UniformScaling))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue