Skip to content

Commit f49a5ac

Browse files
committed
Improve language support, especially for non-Global regions
Up until now Novus assumed you wanted to read everything in English, but this quickly falls apart once you load non-Global clients. I also cleaned up non-latin character display in Armoury. Other places seemed fine. You can now select the language from the install configuration.
1 parent 2554c01 commit f49a5ac

17 files changed

Lines changed: 76 additions & 25 deletions

File tree

apps/armoury/include/gearview.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct ModelInfo {
1515
};
1616

1717
struct GearInfo {
18-
std::string name;
18+
QString name;
1919
Slot slot;
2020
ModelInfo modelInfo;
2121
uint16_t icon;

apps/armoury/src/fullmodelviewer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ void FullModelViewer::reloadGear()
216216
} else {
217217
// smallclothes body
218218
GearInfo info = {};
219-
info.name = "SmallClothes Body";
219+
info.name = i18n("SmallClothes Body");
220220
info.slot = Slot::Body;
221221

222222
gearView->addGear(info);
@@ -227,7 +227,7 @@ void FullModelViewer::reloadGear()
227227
} else {
228228
// smallclothes legs
229229
GearInfo info = {};
230-
info.name = "SmallClothes Legs";
230+
info.name = i18n("SmallClothes Legs");
231231
info.slot = Slot::Legs;
232232

233233
gearView->addGear(info);
@@ -236,7 +236,7 @@ void FullModelViewer::reloadGear()
236236
// smallclothes hands
237237
{
238238
GearInfo info = {};
239-
info.name = "SmallClothes Hands";
239+
info.name = i18n("SmallClothes Hands");
240240
info.slot = Slot::Hands;
241241

242242
gearView->addGear(info);
@@ -245,7 +245,7 @@ void FullModelViewer::reloadGear()
245245
// smallclothes hands
246246
{
247247
GearInfo info = {};
248-
info.name = "SmallClothes Feet";
248+
info.name = i18n("SmallClothes Feet");
249249
info.slot = Slot::Feet;
250250

251251
gearView->addGear(info);

apps/armoury/src/gearlistmodel.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include "gearlistmodel.h"
55

6+
#include "settings.h"
7+
68
#include <KLocalizedString>
79
#include <QtConcurrent>
810
#include <magic_enum.hpp>
@@ -14,7 +16,7 @@ GearListModel::GearListModel(physis_SqPackResource *data, QObject *parent)
1416
// smallclothes body
1517
{
1618
GearInfo info = {};
17-
info.name = "SmallClothes Body";
19+
info.name = i18n("SmallClothes Body");
1820
info.slot = Slot::Body;
1921

2022
gears.push_back(info);
@@ -23,14 +25,14 @@ GearListModel::GearListModel(physis_SqPackResource *data, QObject *parent)
2325
// smallclothes legs
2426
{
2527
GearInfo info = {};
26-
info.name = "SmallClothes Legs";
28+
info.name = i18n("SmallClothes Legs");
2729
info.slot = Slot::Legs;
2830

2931
gears.push_back(info);
3032
}
3133

3234
m_exh = physis_exh_parse(data->platform, physis_sqpack_read(data, "exd/item.exh"));
33-
m_sheet = physis_sqpack_read_excel_sheet(data, "Item", &m_exh, Language::English);
35+
m_sheet = physis_sqpack_read_excel_sheet(data, "Item", &m_exh, getLanguage());
3436

3537
for (unsigned int i = 0; i < m_sheet.page_count; i++) {
3638
for (unsigned int j = m_exh.pages[i].start_id; j < m_exh.pages[i].start_id + m_sheet.pages[i].entry_count; j++) {
@@ -48,7 +50,7 @@ GearListModel::GearListModel(physis_SqPackResource *data, QObject *parent)
4850
}
4951

5052
GearInfo info = {};
51-
info.name = row.columns[9].string._0;
53+
info.name = QString::fromStdString(row.columns[9].string._0);
5254
info.icon = row.columns[10].u_int16._0;
5355
info.slot = slot;
5456
info.modelInfo.primaryID = parts[0];
@@ -160,7 +162,7 @@ QVariant GearListModel::data(const QModelIndex &index, int role) const
160162
}
161163
} else if (item->type == TreeType::Item) {
162164
if (role == Qt::DisplayRole) {
163-
return QLatin1String(item->gear->name.data());
165+
return item->gear->name;
164166
} else if (role == Qt::DecorationRole) {
165167
// TODO: cache these images in memory
166168
const QString iconName = QString::number(item->gear->icon);

apps/armoury/src/gearview.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void GearView::exportModel(const QString &fileName)
104104

105105
void GearView::addGear(GearInfo &gear)
106106
{
107-
qDebug() << "Adding gear" << gear.name.c_str();
107+
qDebug() << "Adding gear" << gear.name;
108108

109109
queuedGearAdditions.emplace_back(gear);
110110

@@ -121,7 +121,7 @@ void GearView::addGear(GearInfo &gear)
121121

122122
void GearView::removeGear(GearInfo &gear)
123123
{
124-
qDebug() << "Removing gear" << gear.name.c_str();
124+
qDebug() << "Removing gear" << gear.name;
125125

126126
queuedGearRemovals.emplace_back(gear);
127127
gearDirty = true;

apps/armoury/src/singlegearview.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ SingleGearView::SingleGearView(physis_SqPackResource *data, FileCache &cache, QW
105105
QString path = QStringLiteral("%1/%2/%3/%4")
106106
.arg(sourceDirectory)
107107
.arg(QString::fromStdString(magic_enum::enum_name(currentGear->slot).data()))
108-
.arg(QString::fromStdString(currentGear->name))
108+
.arg(currentGear->name)
109109
.arg(QStringLiteral("3D"));
110110

111111
if (!QDir().exists(path))
@@ -144,7 +144,7 @@ SingleGearView::SingleGearView(physis_SqPackResource *data, FileCache &cache, QW
144144
QString path = QStringLiteral("%1/%2/%3/%4")
145145
.arg(sourceDirectory)
146146
.arg(QString::fromStdString(magic_enum::enum_name(currentGear->slot).data()))
147-
.arg(QString::fromStdString(currentGear->name))
147+
.arg(currentGear->name)
148148
.arg(QStringLiteral("3D"));
149149

150150
if (!QDir().exists(path))
@@ -175,7 +175,7 @@ SingleGearView::SingleGearView(physis_SqPackResource *data, FileCache &cache, QW
175175
QString path = QStringLiteral("%1/%2/%3/%4")
176176
.arg(sourceDirectory)
177177
.arg(QString::fromStdString(magic_enum::enum_name(currentGear->slot).data()))
178-
.arg(QString::fromStdString(currentGear->name))
178+
.arg(currentGear->name)
179179
.arg(QStringLiteral("3D"));
180180

181181
if (!QDir().exists(path))

apps/mapeditor/src/mainwindow.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "mapview.h"
2020
#include "scenepart.h"
2121
#include "scenestate.h"
22+
#include "settings.h"
2223

2324
#include <KConfig>
2425
#include <KConfigGroup>
@@ -197,7 +198,7 @@ void MainWindow::openMap(const QString &basePath, int contentFinderCondition)
197198
qInfo() << "This map contains a duty! CF:" << contentFinderCondition;
198199

199200
auto cfcExh = physis_exh_parse(m_data.platform, physis_sqpack_read(&m_data, "exd/ContentFinderCondition.exh"));
200-
auto cfcSheet = physis_sqpack_read_excel_sheet(&m_data, "ContentFinderCondition", &cfcExh, Language::English);
201+
auto cfcSheet = physis_sqpack_read_excel_sheet(&m_data, "ContentFinderCondition", &cfcExh, getLanguage());
201202

202203
auto cfcRow = physis_excel_get_row(&cfcSheet, contentFinderCondition);
203204
auto instanceContentId = cfcRow.columns[3].u_int16._0;

apps/mapeditor/src/maplistwidget.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include "maplistwidget.h"
55

6+
#include "settings.h"
7+
68
#include <KLocalizedString>
79
#include <QDialogButtonBox>
810
#include <QLineEdit>
@@ -39,7 +41,7 @@ MapListWidget::MapListWidget(physis_SqPackResource *data, QWidget *parent)
3941
auto nameExh = physis_exh_parse(data->platform, physis_sqpack_read(data, "exd/PlaceName.exh"));
4042
auto territoryExh = physis_exh_parse(data->platform, physis_sqpack_read(data, "exd/TerritoryType.exh"));
4143

42-
auto nameSheet = physis_sqpack_read_excel_sheet(data, "PlaceName", &nameExh, Language::English);
44+
auto nameSheet = physis_sqpack_read_excel_sheet(data, "PlaceName", &nameExh, getLanguage());
4345
auto territorySheet = physis_sqpack_read_excel_sheet(data, "TerritoryType", &territoryExh, Language::None);
4446

4547
// TODO: figure out why row_count in EXH is wrong?!

apps/sdklauncher/include/settingswindow.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#pragma once
55

6+
#include "enumedit.h"
67
#include "settings.h"
78

89
#include <QLineEdit>
@@ -28,6 +29,7 @@ class SettingsWindow : public QWidget
2829
QListWidget *m_installWidget;
2930
QLineEdit *m_labelEdit;
3031
QLineEdit *m_pathEdit;
32+
EnumEdit<Language> *m_languageEdit;
3133
QList<GameInstall> m_installs;
3234
QPushButton *m_addButton;
3335
QPushButton *m_removeButton;

apps/sdklauncher/src/settingswindow.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ SettingsWindow::SettingsWindow(QWidget *parent)
5353
});
5454
configureWidgetLayout->addRow(i18n("Game Path:"), m_pathEdit);
5555

56+
m_languageEdit = new EnumEdit<Language>();
57+
connect(m_languageEdit, &EnumEdit<Language>::editingFinished, this, [this] {
58+
auto &install = currentInstall();
59+
install.language = m_languageEdit->value();
60+
});
61+
configureWidgetLayout->addRow(i18n("Language:"), m_languageEdit);
62+
5663
// TODO: port to QDialogButtonBox
5764
auto bottomButtonLayout = new QHBoxLayout();
5865
layout->addLayout(bottomButtonLayout);
@@ -107,13 +114,15 @@ void SettingsWindow::refreshConfigureWidget(const QUuid uuid)
107114
if (install.uuid == uuid) {
108115
m_labelEdit->setText(install.label);
109116
m_pathEdit->setText(install.path);
117+
m_languageEdit->setValue(install.language);
110118

111119
valid = true;
112120
}
113121
}
114122

115123
m_labelEdit->setEnabled(valid);
116124
m_pathEdit->setEnabled(valid);
125+
m_languageEdit->setEnabled(valid);
117126
m_removeButton->setEnabled(m_installs.size() > 1);
118127
}
119128

common/include/enumedit.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class EnumEdit : public EditWidget
2626
for (auto [type, name] : magic_enum::enum_entries<E>()) {
2727
comboBox->addItem(QString::fromLatin1(name.data()));
2828
}
29+
30+
connect(comboBox, &QComboBox::currentIndexChanged, this, &EnumEdit::editingFinished);
2931
}
3032
~EnumEdit() override = default;
3133

@@ -40,6 +42,11 @@ class EnumEdit : public EditWidget
4042
comboBox->setCurrentIndex(-1);
4143
}
4244

45+
E value() const
46+
{
47+
return static_cast<E>(comboBox->currentIndex());
48+
}
49+
4350
private:
4451
QComboBox *comboBox = nullptr;
4552
};

0 commit comments

Comments
 (0)