translations: remove NUMBER in enums
This commit is contained in:
parent
ab1b3d400f
commit
4f25a25802
|
@ -2,7 +2,7 @@
|
||||||
#include "translations.h"
|
#include "translations.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
||||||
template <typename Key, typename Value, int N>
|
template <typename Key, typename Value>
|
||||||
struct InitializedArray
|
struct InitializedArray
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -71,18 +71,15 @@ namespace {
|
||||||
// Use anonymous namespace instead of static to be able to forward declare translated_strings
|
// Use anonymous namespace instead of static to be able to forward declare translated_strings
|
||||||
extern const InitializedArray<
|
extern const InitializedArray<
|
||||||
lang,
|
lang,
|
||||||
languageInfo,
|
languageInfo
|
||||||
(int)lang::NUMBER
|
|
||||||
> languages;
|
> languages;
|
||||||
|
|
||||||
extern const InitializedArray<
|
extern const InitializedArray<
|
||||||
Msg,
|
Msg,
|
||||||
InitializedArray<
|
InitializedArray<
|
||||||
lang,
|
lang,
|
||||||
const char*,
|
const char*
|
||||||
(int)lang::NUMBER
|
>
|
||||||
>,
|
|
||||||
(int)Msg::NUMBER
|
|
||||||
> translated_strings;
|
> translated_strings;
|
||||||
|
|
||||||
lang current_language = lang::English;
|
lang current_language = lang::English;
|
||||||
|
@ -97,7 +94,7 @@ const languageInfo* translations::get_languages(size_t* languages_number) {
|
||||||
|
|
||||||
void translations::set_current_language(const char* short_name)
|
void translations::set_current_language(const char* short_name)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < (int)lang::NUMBER; i++) {
|
for(int i = 0; i < languages.size(); i++) {
|
||||||
if(!strcmp(short_name, languages[i].short_name)) {
|
if(!strcmp(short_name, languages[i].short_name)) {
|
||||||
current_language = (lang) i;
|
current_language = (lang) i;
|
||||||
return;
|
return;
|
||||||
|
@ -120,14 +117,14 @@ void translations::get_glyph_range(ImVector<ImWchar>* ranges)
|
||||||
{
|
{
|
||||||
ImFontGlyphRangesBuilder builder;
|
ImFontGlyphRangesBuilder builder;
|
||||||
|
|
||||||
for(int i = 0; i < (int)Msg::NUMBER; i++) {
|
for(int i = 0; i < translated_strings.size(); i++) {
|
||||||
const char* translation = get_translation((Msg)i);
|
const char* translation = get_translation((Msg)i);
|
||||||
if(translation)
|
if(translation)
|
||||||
{
|
{
|
||||||
builder.AddText(translation);
|
builder.AddText(translation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.AddRanges(ImGui::GetIO().Fonts->GetGlyphRangesDefault());
|
builder.AddRanges(ImGui::GetIO().Fonts->GetGlyphRangesDefault());
|
||||||
builder.BuildRanges(ranges);
|
builder.BuildRanges(ranges);
|
||||||
}
|
}
|
||||||
|
@ -135,8 +132,7 @@ void translations::get_glyph_range(ImVector<ImWchar>* ranges)
|
||||||
namespace {
|
namespace {
|
||||||
const InitializedArray<
|
const InitializedArray<
|
||||||
lang,
|
lang,
|
||||||
languageInfo,
|
languageInfo
|
||||||
(int)lang::NUMBER
|
|
||||||
> languages =
|
> languages =
|
||||||
{
|
{
|
||||||
{ lang::Arabic, {"ar", "Arabic" } },
|
{ lang::Arabic, {"ar", "Arabic" } },
|
||||||
|
@ -169,10 +165,8 @@ const InitializedArray<
|
||||||
Msg,
|
Msg,
|
||||||
InitializedArray<
|
InitializedArray<
|
||||||
lang,
|
lang,
|
||||||
const char*,
|
const char*
|
||||||
(int)lang::NUMBER
|
>
|
||||||
>,
|
|
||||||
(int)Msg::NUMBER
|
|
||||||
> translated_strings =
|
> translated_strings =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
|
|
@ -253,8 +253,6 @@ enum class Msg
|
||||||
Menu1_UseMaxResolution_640x480,
|
Menu1_UseMaxResolution_640x480,
|
||||||
Menu1_UseMaxResolution_800x600,
|
Menu1_UseMaxResolution_800x600,
|
||||||
Menu1_UseMaxResolution_1024x768,
|
Menu1_UseMaxResolution_1024x768,
|
||||||
|
|
||||||
NUMBER,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct languageInfo {
|
struct languageInfo {
|
||||||
|
|
Loading…
Reference in New Issue