Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions docs/options-window.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The window has five tabs:
| Graphics | Quality: Enhanced graphics, anti-aliasing, anisotropic filtering, render level. Effects: the effect toggles. Shadows: the shadow toggles |
| Audio | Sound and music volume, whisper sound |
| Gameplay | Auto attack, slide help |
| Interface | Language, font, UI theme, FPS counter, debug info |
| Interface | Language, translate item names, font, UI theme, FPS counter, debug info |

Each setting is a row with its name on the left and its control on the
right, aligned in two columns. A tab's settings scroll when they don't fit,
Expand Down Expand Up @@ -113,7 +113,10 @@ window writes to these sections:
own, through a temporary file, when a slider is let go; see "Tuning it
yourself" in [`enhanced-look.md`](enhanced-look.md).
- `[UI]` - `Locale`, `Font`, `RmlTheme` and `UIScalePercent` from the Display and
Interface tabs. `EnableAnimationTaskPool` (`0`/`1`, set by hand only, like the
Interface tabs. `TranslateItemNames` (default `1`): the "Translate item names"
checkbox under the language, applied at once; unticked, item names stay
English while the rest of the UI is in the chosen language.
`EnableAnimationTaskPool` (`0`/`1`, set by hand only, like the
`--enable-taskpool` command-line flag) animates characters on worker
threads.
- `[Audio]` - volumes.
Expand Down
5 changes: 4 additions & 1 deletion docs/translation-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,10 @@ Item names are not in the `.resx` files. They are part of the item data
`src/bin/Data/Items/*.json` holds the names by language code, using the same
codes as the UI texts. The game shows the name for the active locale and
falls back to English, like the UI texts; switching the locale at runtime
updates item names too.
updates item names too. Players who know the items by their English names can
untick **Translate item names** under the language in the options window
(Interface tab): item names then stay English, also in the item editor, while
every other text follows the language.

### In the JSON files

Expand Down
3 changes: 3 additions & 0 deletions src/Localization/Game.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,9 @@
<data name="Language" xml:space="preserve">
<value>Sprache</value>
</data>
<data name="Translate Item Names" xml:space="preserve">
<value>Gegenstandsnamen übersetzen</value>
</data>
<data name="Windowed mode" xml:space="preserve">
<value>Fenstermodus</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions src/Localization/Game.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,9 @@
<data name="Language" xml:space="preserve">
<value>Language</value>
</data>
<data name="Translate Item Names" xml:space="preserve">
<value>Translate item names</value>
</data>
<data name="Windowed mode" xml:space="preserve">
<value>Windowed mode</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions src/Localization/Game.es.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,9 @@
<data name="Language" xml:space="preserve">
<value>Idioma</value>
</data>
<data name="Translate Item Names" xml:space="preserve">
<value>Traducir nombres de objetos</value>
</data>
<data name="Windowed mode" xml:space="preserve">
<value>Modo ventana</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions src/Localization/Game.id.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,9 @@
<data name="Language" xml:space="preserve">
<value>Bahasa</value>
</data>
<data name="Translate Item Names" xml:space="preserve">
<value>Terjemahkan nama barang</value>
</data>
<data name="Windowed mode" xml:space="preserve">
<value>Mode jendela</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions src/Localization/Game.ja.resx
Original file line number Diff line number Diff line change
Expand Up @@ -11112,4 +11112,7 @@
<data name="QuestRequirementBuff" xml:space="preserve">
<value>Bonus: %ls</value>
</data>
<data name="Translate Item Names" xml:space="preserve">
<value>アイテム名を翻訳する</value>
</data>
</root>
3 changes: 3 additions & 0 deletions src/Localization/Game.pl.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,9 @@
<data name="Language" xml:space="preserve">
<value>Język</value>
</data>
<data name="Translate Item Names" xml:space="preserve">
<value>Tłumacz nazwy przedmiotów</value>
</data>
<data name="Windowed mode" xml:space="preserve">
<value>Tryb okienkowy</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions src/Localization/Game.pt.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,9 @@
<data name="Language" xml:space="preserve">
<value>Idioma</value>
</data>
<data name="Translate Item Names" xml:space="preserve">
<value>Traduzir nomes dos itens</value>
</data>
<data name="Windowed mode" xml:space="preserve">
<value>Modo janela</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions src/Localization/Game.ru.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,9 @@
<data name="Language" xml:space="preserve">
<value>Язык</value>
</data>
<data name="Translate Item Names" xml:space="preserve">
<value>Переводить названия предметов</value>
</data>
<data name="Windowed mode" xml:space="preserve">
<value>Оконный режим</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions src/Localization/Game.tl.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,9 @@
<data name="Language" xml:space="preserve">
<value>Wika</value>
</data>
<data name="Translate Item Names" xml:space="preserve">
<value>Isalin ang mga pangalan ng item</value>
</data>
<data name="Windowed mode" xml:space="preserve">
<value>Windowed mode</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions src/Localization/Game.uk.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,9 @@
<data name="Language" xml:space="preserve">
<value>Мова</value>
</data>
<data name="Translate Item Names" xml:space="preserve">
<value>Перекладати назви предметів</value>
</data>
<data name="Windowed mode" xml:space="preserve">
<value>Віконний режим</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions src/Localization/Game.zh-TW.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,9 @@
<data name="Language" xml:space="preserve">
<value>語言</value>
</data>
<data name="Translate Item Names" xml:space="preserve">
<value>翻譯物品名稱</value>
</data>
<data name="Windowed mode" xml:space="preserve">
<value>視窗模式</value>
</data>
Expand Down
15 changes: 8 additions & 7 deletions src/MuEditor/UI/EffectBrowser/EffectPreviewView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,24 +346,25 @@ void CEffectPreviewView::RenderItemList()
}

// The names come from the items as the game has them now; the list is made
// again when the item tools change the items or their models, or the language
// changes. The item models are all opened on the loading screen and stay, so
// the list does not change with the map; the models of the chosen level are
// checked when drawn.
// again when the item tools change the items or their models, or the item
// names change (another UI language, translated item names turned on or off).
// The item models are all opened on the loading screen and stay, so the list
// does not change with the map; the models of the chosen level are checked
// when drawn.
void CEffectPreviewView::RefreshItems()
{
const int version = g_ItemDatabase.GetVersion();
const int modelVersion = g_ItemModelDatabase.GetVersion();
const char* locale = I18N::GetCurrentLocale();
if (m_itemsVersion == version && m_itemModelsVersion == modelVersion && m_itemsLocale == locale)
const int namesVersion = g_ItemDatabase.GetNameVersion();
if (m_itemsVersion == version && m_itemModelsVersion == modelVersion && m_itemNamesVersion == namesVersion)
return;
// Whether an item can be drawn is known once its changed model is opened
// again, before the next frame: until then the list is built again each
// frame.
const bool modelsOpened = !g_ItemDataHandler.HasModelsToReopen();
m_itemsVersion = modelsOpened ? version : -1;
m_itemModelsVersion = modelVersion;
m_itemsLocale = locale;
m_itemNamesVersion = namesVersion;
m_items.Build(
MAX_ITEM, [](int itemType) { return Core::Text::ToUtf8(ItemAttribute[itemType].Name); }, IsItemDrawable);
m_itemMatchesValid = false;
Expand Down
3 changes: 1 addition & 2 deletions src/MuEditor/UI/EffectBrowser/EffectPreviewView.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ class CEffectPreviewView
MuEditor::Effects::EffectPreviewItems m_items;
int m_itemsVersion = -1;
int m_itemModelsVersion = -1;
// The language the item names are in (a pointer into I18N's locales).
const char* m_itemsLocale = nullptr;
int m_itemNamesVersion = -1;
char m_itemSearch[64] = {};
std::vector<int> m_itemMatches;
bool m_itemMatchesValid = false;
Expand Down
2 changes: 1 addition & 1 deletion src/MuEditor/UI/ItemTools/ItemBrowserList.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace MuEditor::Items
{
// The rows of the item browser: number, name in the UI language and model
// The rows of the item browser: number, name as the game shows it and model
// file of each listed item, the selected one highlighted.
class CItemBrowserList
{
Expand Down
4 changes: 2 additions & 2 deletions src/MuEditor/UI/ItemTools/ItemNamesakes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ const std::string& ItemNamesakes::GetQualifier(int itemType)

void ItemNamesakes::Update()
{
if (m_version == g_ItemDatabase.GetVersion() && m_locale == g_ItemDatabase.GetDisplayLocale())
if (m_version == g_ItemDatabase.GetVersion() && m_nameVersion == g_ItemDatabase.GetNameVersion())
{
return;
}
m_version = g_ItemDatabase.GetVersion();
m_locale = g_ItemDatabase.GetDisplayLocale();
m_nameVersion = g_ItemDatabase.GetNameVersion();
const auto slots = g_ItemDatabase.GetAllSlots();
m_qualifiers.assign(slots.size(), std::string());

Expand Down
6 changes: 3 additions & 3 deletions src/MuEditor/UI/ItemTools/ItemNamesakes.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace MuEditor::Items
{
// Items whose name (in the UI language) another item has too, e.g. the lucky
// Items whose name (as the game shows it) another item has too, e.g. the lucky
// sets and the tiers of the seed spheres: a short text that tells them apart
// in the item lists. It names the tags an item has that not all its
// namesakes have ("luckyItem"); namesakes that no tag tells apart count up
Expand All @@ -24,12 +24,12 @@ class ItemNamesakes
private:
ItemNamesakes() = default;

// Again when the items or the UI language changed.
// Again when the items or their names changed.
void Update();

std::vector<std::string> m_qualifiers;
int m_version = -1;
std::string m_locale;
int m_nameVersion = -1;
};

// Draws the qualifier after the item's name on the same line, greyed out;
Expand Down
4 changes: 2 additions & 2 deletions src/MuEditor/UI/ItemTools/ItemToolWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ bool RenderSelectedItem(int itemType)
I18N::Editor::NoItemAtThisNumber);
return false;
}
// In the UI language, as the item browser shows it and its namesakes are
// found.
// In the item name language, as the item browser shows it and its
// namesakes are found.
ImGui::Text("%s (%d,%d)", Core::Text::ToUtf8(item->name.c_str()).c_str(), Data::Items::GetItemGroup(itemType),
Data::Items::GetItemNumber(itemType));
RenderNamesakeQualifier(itemType);
Expand Down
2 changes: 1 addition & 1 deletion src/MuEditor/UI/ItemTools/ItemToolWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void End();
// editor's bar; a click does not take the focus from the item tool.
void RenderUndoRedo();

// "Kris (0,0)" in the UI language, with what tells it apart from items of the
// "Kris (0,0)" in the item name language, with what tells it apart from items of the
// same name (ItemNamesakes), or "Select an item"; false when there is no item
// to edit.
bool RenderSelectedItem(int itemType);
Expand Down
6 changes: 3 additions & 3 deletions src/MuEditor/UI/ItemTools/MuItemCategoriesUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,14 @@ void CMuItemCategoriesUI::UpdateTagLabels()

void CMuItemCategoriesUI::UpdateRows()
{
const std::string& locale = g_ItemDatabase.GetDisplayLocale();
if (m_rowsVersion == g_ItemDatabase.GetVersion() && m_rowsTag == m_tag && m_rowsLocale == locale)
if (m_rowsVersion == g_ItemDatabase.GetVersion() && m_rowsNameVersion == g_ItemDatabase.GetNameVersion() &&
m_rowsTag == m_tag)
{
return;
}
m_rowsVersion = g_ItemDatabase.GetVersion();
m_rowsNameVersion = g_ItemDatabase.GetNameVersion();
m_rowsTag = m_tag;
m_rowsLocale = locale;
m_rows.clear();
for (const int itemType : g_ItemDatabase.GetItemTypesWithTag(m_tag))
{
Expand Down
2 changes: 1 addition & 1 deletion src/MuEditor/UI/ItemTools/MuItemCategoriesUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class CMuItemCategoriesUI
int m_labelsVersion = -1;
std::vector<TagItemRow> m_rows;
Data::Items::ItemTag m_rowsTag{};
std::string m_rowsLocale;
int m_rowsVersion = -1;
int m_rowsNameVersion = -1;
int m_shownSerial = -1;
};

Expand Down
6 changes: 6 additions & 0 deletions src/bin/Data/Interface/RmlUi/option_window.rml
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,12 @@
</div>
</div>
</div>
<div class="option-row option-checkbox-row option-sub-row" data-event-click="option_toggle_translate_item_names">
<span class="option-row-label">{{translate_item_names_label}}</span>
<div class="checkbox-box" data-class-checked="translate_item_names">
<div class="checkbox-tick"></div>
</div>
</div>
<div class="option-row option-select-row">
<span class="option-row-label">{{font_row_label}}</span>
<div class="option-dropdown">
Expand Down
4 changes: 4 additions & 0 deletions src/bin/Data/Interface/RmlUi/themes/modern/option_window.rml
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,10 @@
</div>
</div>
</div>
<div class="opt-row opt-toggle-row opt-sub-row" data-event-click="option_toggle_translate_item_names">
<span class="opt-label">{{translate_item_names_label}}</span>
<div class="opt-control"><div class="opt-toggle" data-class-checked="translate_item_names"><div class="opt-toggle-knob"></div></div></div>
</div>
<div class="opt-row">
<span class="opt-label">{{font_row_label}}</span>
<div class="opt-control">
Expand Down
1 change: 1 addition & 0 deletions src/bin/config.ini.template
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ServerIP=localhost
ServerPort=44406
[UI]
Locale=en
TranslateItemNames=1
Font=
RmlTheme=legacy
UIScalePercent=100
Expand Down
2 changes: 2 additions & 0 deletions src/source/App/Platform/Windows/Winmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <utility>
#include <vector>
#include "Core/Platform/WinIni.h" // private-profile (.ini) API
#include "Data/DataHandler/ItemData/ItemDataHandler.h"
#include "Data/GameConfig/GameConfig.h"
#include "UI/Core/UIManager.h"
#include "Render/Textures/ZzzOpenglUtil.h"
Expand Down Expand Up @@ -2300,6 +2301,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int nC
std::string uiLocale(uiLocaleW.begin(), uiLocaleW.end());
I18N::SetLocale(uiLocale.c_str());
}
g_ItemDataHandler.SetTranslateItemNames(GameConfig::GetInstance().GetTranslateItemNames());

#ifdef _EDITOR
// Initialize MU Editor with the live SDL GPU window.
Expand Down
11 changes: 4 additions & 7 deletions src/source/Data/DataHandler/ItemData/ItemDataExportAsCSV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
#include "Core/Utilities/StringUtils.h"
#include <string>

// External references
extern ITEM_ATTRIBUTE* ItemAttribute;

// X-Macro helpers for CSV generation
#define CSV_HEADER_SIMPLE(name, type, arraySize, width, i18nName) "," #name
#define CSV_HEADER_ARRAY(nameWithIndex, baseName, index, type, width, i18nName) "," #nameWithIndex
Expand All @@ -29,7 +26,7 @@ extern ITEM_ATTRIBUTE* ItemAttribute;
#define CSV_PRINT_SIMPLE(name, type, arraySize, width, i18nName) PRINT_FIELD_##type(item, name);
#define CSV_PRINT_ARRAY(nameWithIndex, baseName, index, type, width, i18nName) fprintf(csvFp, ",%d", item.baseName[index]);

bool ItemDataExportAsCSV::ExportToCsv(wchar_t* fileName)
bool ItemDataExportAsCSV::ExportToCsv(wchar_t* fileName, const ITEM_ATTRIBUTE* attributes)
{
FILE* csvFp = _wfopen(fileName, L"w");
if (!csvFp)
Expand All @@ -46,10 +43,10 @@ bool ItemDataExportAsCSV::ExportToCsv(wchar_t* fileName)
for (int i = 0; i < MAX_ITEM; i++)
{
// Only export items with names
if (ItemAttribute[i].Name[0] != 0)
if (attributes[i].Name[0] != 0)
{
// Convert wide char name to UTF-8
std::string utf8Name = StringUtils::WideToNarrow(ItemAttribute[i].Name);
std::string utf8Name = StringUtils::WideToNarrow(attributes[i].Name);

// Escape quotes in name
std::string escapedName;
Expand All @@ -69,7 +66,7 @@ bool ItemDataExportAsCSV::ExportToCsv(wchar_t* fileName)
fprintf(csvFp, "%d,\"%s\"", i, escapedName.c_str());

// Print all fields using X-macros
ITEM_ATTRIBUTE& item = ItemAttribute[i];
const ITEM_ATTRIBUTE& item = attributes[i];
ITEM_FIELDS_SIMPLE(CSV_PRINT_SIMPLE)
ITEM_FIELDS_ARRAYS(CSV_PRINT_ARRAY)

Expand Down
5 changes: 4 additions & 1 deletion src/source/Data/DataHandler/ItemData/ItemDataExportAsCSV.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

#ifdef _EDITOR

#include "Data/GameData/ItemData/ItemStructs.h"

// Item Data Export/Import Operations
class ItemDataExportAsCSV
{
public:
static bool ExportToCsv(wchar_t* fileName);
// Writes the MAX_ITEM records of attributes that have a name.
static bool ExportToCsv(wchar_t* fileName, const ITEM_ATTRIBUTE* attributes);
// Future: static bool ImportFromCsv(wchar_t* fileName);
};

Expand Down
Loading
Loading