summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2021-04-11 13:56:24 +0200
committerfrosch <github@elsenhans.name>2021-04-22 22:16:56 +0200
commita9740cef82b6969be1087bb0cfa2fcfdc3058845 (patch)
treef4ffefadf2b3dd84b19384bb595ba636e488b390
parentd1dd997f077fca5e1f969a1b610914f9310f9561 (diff)
downloadopenttd-a9740cef82b6969be1087bb0cfa2fcfdc3058845.tar.xz
Add: show completion progress of languages in the language dropdown for non-release builds.
-rw-r--r--src/lang/english.txt1
-rw-r--r--src/settings_gui.cpp5
-rw-r--r--src/strgen/strgen.cpp10
3 files changed, 12 insertions, 4 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 125273ed9..8eb7616bc 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -993,6 +993,7 @@ STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_12_MONTHS :Every 12 months
STR_GAME_OPTIONS_LANGUAGE :{BLACK}Language
STR_GAME_OPTIONS_LANGUAGE_TOOLTIP :{BLACK}Select the interface language to use
+STR_GAME_OPTIONS_LANGUAGE_PERCENTAGE :{RAW_STRING} ({NUM}% completed)
STR_GAME_OPTIONS_FULLSCREEN :{BLACK}Fullscreen
STR_GAME_OPTIONS_FULLSCREEN_TOOLTIP :{BLACK}Check this box to play OpenTTD fullscreen mode
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 0705c3fcc..1e3bdb7d7 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -36,6 +36,7 @@
#include "querystring_gui.h"
#include "fontcache.h"
#include "zoom_func.h"
+#include "rev.h"
#include "video/video_driver.hpp"
#include "music/music_driver.hpp"
@@ -217,7 +218,8 @@ struct GameOptionsWindow : Window {
case WID_GO_LANG_DROPDOWN: { // Setup interface language dropdown
for (uint i = 0; i < _languages.size(); i++) {
- auto item = new DropDownListParamStringItem(STR_JUST_RAW_STRING, i, false);
+ bool hide_percentage = IsReleasedVersion() || _languages[i].missing < _settings_client.gui.missing_strings_threshold;
+ auto item = new DropDownListParamStringItem(hide_percentage ? STR_JUST_RAW_STRING : STR_GAME_OPTIONS_LANGUAGE_PERCENTAGE, i, false);
if (&_languages[i] == _current_language) {
*selected_index = i;
item->SetParamStr(0, _languages[i].own_name);
@@ -229,6 +231,7 @@ struct GameOptionsWindow : Window {
* entries in the dropdown list. */
item->SetParamStr(0, _languages[i].name);
}
+ item->SetParam(1, (LANGUAGE_TOTAL_STRINGS - _languages[i].missing) * 100 / LANGUAGE_TOTAL_STRINGS);
list.emplace_back(item);
}
std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp
index 9377e6362..68002cc3f 100644
--- a/src/strgen/strgen.cpp
+++ b/src/strgen/strgen.cpp
@@ -273,13 +273,14 @@ struct HeaderFileWriter : HeaderWriter, FileWriter {
const char *real_filename;
/** The previous string ID that was printed. */
int prev;
+ uint total_strings;
/**
* Open a file to write to.
* @param filename The file to open.
*/
HeaderFileWriter(const char *filename) : FileWriter("tmp.xxx"),
- real_filename(stredup(filename)), prev(0)
+ real_filename(stredup(filename)), prev(0), total_strings(0)
{
fprintf(this->fh, "/* This file is automatically generated. Do not modify */\n\n");
fprintf(this->fh, "#ifndef TABLE_STRINGS_H\n");
@@ -297,6 +298,7 @@ struct HeaderFileWriter : HeaderWriter, FileWriter {
if (prev + 1 != stringid) fprintf(this->fh, "\n");
fprintf(this->fh, "static const StringID %s = 0x%X;\n", name, stringid);
prev = stringid;
+ total_strings++;
}
void Finalise(const StringData &data)
@@ -311,8 +313,10 @@ struct HeaderFileWriter : HeaderWriter, FileWriter {
"\n"
"static const uint LANGUAGE_PACK_VERSION = 0x%X;\n"
"static const uint LANGUAGE_MAX_PLURAL = %u;\n"
- "static const uint LANGUAGE_MAX_PLURAL_FORMS = %d;\n\n",
- (uint)data.Version(), (uint)lengthof(_plural_forms), max_plural_forms
+ "static const uint LANGUAGE_MAX_PLURAL_FORMS = %d;\n"
+ "static const uint LANGUAGE_TOTAL_STRINGS = %u;\n"
+ "\n",
+ (uint)data.Version(), (uint)lengthof(_plural_forms), max_plural_forms, total_strings
);
fprintf(this->fh, "#endif /* TABLE_STRINGS_H */\n");