Skip to content

Commit

Permalink
Fix field list for PS version/directory
Browse files Browse the repository at this point in the history
  • Loading branch information
myst6re committed Aug 28, 2023
1 parent fd62708 commit a7df040
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 41 deletions.
44 changes: 23 additions & 21 deletions src/Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ int Data::currentModelID = -1;
QStringList *Data::currentHrcNames = nullptr;
QList<QStringList> *Data::currentAnimNames = nullptr;
QStringList Data::field_names;
QStringList Data::field_names_pc;
QStringList Data::movie_names_cd1;
QStringList Data::movie_names_cd2;
QStringList Data::movie_names_cd3;
Expand Down Expand Up @@ -559,6 +560,8 @@ bool Data::load()
ok = false;
}

Data::openMaplist();

return ok;
}

Expand Down Expand Up @@ -734,36 +737,35 @@ const char *Data::_mapList[788] = {
};

// Standard mapList
void Data::openMaplist(bool PC)
void Data::openMaplist()
{
field_names.clear();
for (int i=0; i<788; ++i) {
field_names.append(QString::fromUtf8(_mapList[i]));
}

if (PC) {
toPCMaplist(field_names);
}
toPCMaplist(field_names);
}

void Data::toPCMaplist(QStringList &field_names)
void Data::toPCMaplist(const QStringList &field_names)
{
field_names[88] = "qa";
field_names[89] = "qb";
field_names[90] = "qc";
field_names[91] = "qd";
field_names[92] = "qe";
field_names[153] = "min71";
field_names[164] = "sbwy4_1";
field_names[165] = "sbwy4_2";
field_names[166] = "sbwy4_3";
field_names[167] = "sbwy4_4";
field_names[168] = "sbwy4_5";
field_names[169] = "sbwy4_6";
field_names[174] = "min51_1";
field_names[175] = "min51_2";
field_names[586] = "tower5";
field_names[735] = "sbwy4_22";
field_names_pc = field_names;
field_names_pc[88] = "qa";
field_names_pc[89] = "qb";
field_names_pc[90] = "qc";
field_names_pc[91] = "qd";
field_names_pc[92] = "qe";
field_names_pc[153] = "min71";
field_names_pc[164] = "sbwy4_1";
field_names_pc[165] = "sbwy4_2";
field_names_pc[166] = "sbwy4_3";
field_names_pc[167] = "sbwy4_4";
field_names_pc[168] = "sbwy4_5";
field_names_pc[169] = "sbwy4_6";
field_names_pc[174] = "min51_1";
field_names_pc[175] = "min51_2";
field_names_pc[586] = "tower5";
field_names_pc[735] = "sbwy4_22";
}

const char *Data::musicList[100] =
Expand Down
14 changes: 7 additions & 7 deletions src/Data.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ class Data
static int loadKernel2Bin();
static int loadWindowBin();
static bool load();
static void openMaplist(bool PC = false);
static void toPCMaplist(QStringList &field_names);
static void openMaplist();
static void toPCMaplist(const QStringList &field_names);
static QColor color(Color color);
inline static const QStringList &maplist() {
return field_names;
inline static const QStringList &maplist(bool PC) {
return PC ? field_names_pc : field_names;
}
inline static QString mapName(int i) {
return field_names.value(i);
inline static QString mapName(int i, bool PC) {
return (PC ? field_names_pc : field_names).value(i);
}
static QStringList char_names;
static QStringList key_names;
Expand Down Expand Up @@ -98,7 +98,7 @@ class Data
static QString ff7Path(const QMap<FF7Version, QString> &pathList);
static QMap<Data::FF7Version, QString> ff7PathList(QString (*searchFF7Path)(FF7Version));
static void fill(const QByteArray &data, int pos, int dataSize, QStringList &names);
static QStringList field_names;
static QStringList field_names, field_names_pc;
static QString ff7DataPath_cache;
static QString ff7AppPath_cache;
static QString ff7RereleasePath_cache;
Expand Down
10 changes: 3 additions & 7 deletions src/core/field/FieldArchive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ FieldArchiveIO::ErrorCode FieldArchive::open()
return FieldArchiveIO::FieldNotFound;
}

if (Data::maplist().isEmpty()) {
Data::openMaplist(_io->isPC());
}

int fieldID = 0;
for (Field *f : qAsConst(fileList)) {
if (f != nullptr) {
Expand Down Expand Up @@ -266,7 +262,7 @@ int FieldArchive::appendField(Field *field)
qsizetype mapId = _mapList.mapNames().indexOf(field->name());
if (mapId < 0) {
if (_mapList.mapNames().isEmpty()) {
mapId = Data::maplist().indexOf(field->name());
mapId = Data::maplist(field->isPC()).indexOf(field->name());
}
if (mapId < 0) {
mapId = 1200 + (fileList.isEmpty() ? 0 : fileList.lastKey() + 1);
Expand Down Expand Up @@ -1943,6 +1939,6 @@ QString FieldArchive::mapName(int mapID) const
if (mapID < _mapList.mapNames().size()) {
return _mapList.mapNames().at(mapID);
}

return Data::mapName(mapID);
return Data::mapName(mapID, isPC());
}
4 changes: 2 additions & 2 deletions src/core/field/Opcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4984,8 +4984,8 @@ QString Opcode::_field(quint16 mapID, const Section1File *scriptsAndTexts)
&& scriptsAndTexts->field()->io() != nullptr
&& scriptsAndTexts->field()->io()->fieldArchive() != nullptr) {
mapNames = &(scriptsAndTexts->field()->io()->fieldArchive()->mapList().mapNames());
} else if (mapID < Data::maplist().size()) {
mapNames = &Data::maplist();
} else if (mapID < Data::maplist(scriptsAndTexts->field()->isPC()).size()) {
mapNames = &Data::maplist(scriptsAndTexts->field()->isPC());
}

if (mapNames != nullptr && mapID < mapNames->size()) {
Expand Down
8 changes: 4 additions & 4 deletions src/widgets/ScriptEditorWidgets/Delegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ QWidget *SpinBoxDelegate::createEditor(QWidget *parent,
int type = index.data(Qt::UserRole + 2).toInt();
int value = index.data(Qt::EditRole).toInt();
if (type == ScriptEditorGenericList::field_id
&& !Data::maplist().isEmpty()) {
&& !Data::maplist(_scriptsAndTexts->field()->isPC()).isEmpty()) {
QComboBox *comboBox = new QComboBox(parent);
comboBox->setEditable(true);
comboBox->setInsertPolicy(QComboBox::NoInsert);
Expand All @@ -98,7 +98,7 @@ QWidget *SpinBoxDelegate::createEditor(QWidget *parent,
if (!_scriptsAndTexts->field()->io()->fieldArchive()->mapList().mapNames().empty()) {
mapList = &_scriptsAndTexts->field()->io()->fieldArchive()->mapList().mapNames();
} else {
mapList = &Data::maplist();
mapList = &Data::maplist(_scriptsAndTexts->field()->isPC());
}
int mapId = 0;
for (const QString &mapName: *mapList) {
Expand Down Expand Up @@ -293,7 +293,7 @@ void SpinBoxDelegate::setEditorData(QWidget *editor,
QComboBox *comboBox = static_cast<QComboBox*>(editor);
comboBox->setCurrentIndex(comboBox->findData(value));
} else if ((type == ScriptEditorGenericList::field_id
&& !Data::maplist().isEmpty())
&& !Data::maplist(_scriptsAndTexts->field()->isPC()).isEmpty())
|| (type == ScriptEditorGenericList::group_id
&& _scriptsAndTexts->grpScriptCount() > 0)
|| type == ScriptEditorGenericList::personnage_id
Expand Down Expand Up @@ -331,7 +331,7 @@ void SpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
QComboBox *comboBox = static_cast<QComboBox*>(editor);
value = comboBox->itemData(comboBox->currentIndex()).toInt();
} else if ((type == ScriptEditorGenericList::field_id
&& !Data::maplist().isEmpty())
&& !Data::maplist(_scriptsAndTexts->field()->isPC()).isEmpty())
|| (type == ScriptEditorGenericList::group_id
&& _scriptsAndTexts->grpScriptCount() > 0)
|| type == ScriptEditorGenericList::personnage_id
Expand Down
24 changes: 24 additions & 0 deletions translations/Makou_Reactor_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,26 @@ Voulez-vous vraiment continuer ?</translation>
<source>Depth fine tune auto</source>
<translation>Profondeur plus précis auto</translation>
</message>
<message>
<source>Export tile image</source>
<translation>Exporter image tuile</translation>
</message>
<message>
<source>PNG image (*.png);;BMP image (*.bmp)</source>
<translation>Image PNG (*.png);;Image BMP (*.bmp)</translation>
</message>
<message>
<source>Import tile image</source>
<translation>Importer image tuile</translation>
</message>
<message>
<source>Invalid size</source>
<translation>Taille invalide</translation>
</message>
<message>
<source>Please import an image with size %1x%1</source>
<translation>Merci d&apos;importer une image ayant pour taille %1x%1</translation>
</message>
</context>
<context>
<name>CLI</name>
Expand Down Expand Up @@ -4084,6 +4104,10 @@ Certains scripts peuvent y faire référence !</translation>
<source>16-bit colors:</source>
<translation>Couleurs 16 bits :</translation>
</message>
<message>
<source>HTML code:</source>
<translation>Notation HTML:</translation>
</message>
</context>
<context>
<name>PsfDialog</name>
Expand Down
24 changes: 24 additions & 0 deletions translations/Makou_Reactor_ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,26 @@ Are you sure you want to continue?</source>
<source>Depth fine tune auto</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Export tile image</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>PNG image (*.png);;BMP image (*.bmp)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Import tile image</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invalid size</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Please import an image with size %1x%1</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CLI</name>
Expand Down Expand Up @@ -3583,6 +3603,10 @@ Some scripts can refer to it!</source>
<source>16-bit colors:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>HTML code:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PsfDialog</name>
Expand Down

0 comments on commit a7df040

Please sign in to comment.