Add palette editor bit depth to config

This commit is contained in:
GriffinR 2023-02-22 11:21:30 -05:00
parent 420e92e912
commit 4fbe8bf5ef
5 changed files with 30 additions and 5 deletions

View file

@ -7,6 +7,9 @@ and this project somewhat adheres to [Semantic Versioning](https://semver.org/sp
The **"Breaking Changes"** listed below are changes that have been made in the decompilation projects (e.g. pokeemerald), which porymap requires in order to work properly. It also includes changes to the scripting API that may change the behavior of existing porymap scripts. If porymap is used with a project or API script that is not up-to-date with the breaking changes, then porymap will likely break or behave improperly.
## [Unreleased]
### Changed
- The Palette Editor now remembers the Bit Depth setting.
### Fixed
- Fix text boxes in the Palette Editor calculating color incorrectly.

View file

@ -5051,7 +5051,7 @@
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="label_Palette">
<property name="text">
<string>Palette</string>
</property>
@ -5096,9 +5096,6 @@
<property name="text">
<string>24</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>

View file

@ -81,6 +81,7 @@ public:
void setTheme(QString theme);
void setTextEditorOpenFolder(const QString &command);
void setTextEditorGotoLine(const QString &command);
void setPaletteEditorBitDepth(int bitDepth);
QString getRecentProject();
bool getReopenOnLaunch();
MapSortOrder getMapSortOrder();
@ -100,6 +101,7 @@ public:
QString getTheme();
QString getTextEditorOpenFolder();
QString getTextEditorGotoLine();
int getPaletteEditorBitDepth();
protected:
virtual QString getConfigFilepath() override;
virtual void parseConfigKeyValue(QString key, QString value) override;
@ -135,6 +137,7 @@ private:
QString theme;
QString textEditorOpenFolder;
QString textEditorGotoLine;
int paletteEditorBitDepth;
};
extern PorymapConfig porymapConfig;

View file

@ -246,6 +246,11 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) {
this->textEditorOpenFolder = value;
} else if (key == "text_editor_goto_line") {
this->textEditorGotoLine = value;
} else if (key == "palette_editor_bit_depth") {
this->paletteEditorBitDepth = getConfigInteger(key, value, 15, 24, 24);
if (this->paletteEditorBitDepth != 15 && this->paletteEditorBitDepth != 24){
this->paletteEditorBitDepth = 24;
}
} else {
logWarn(QString("Invalid config key found in config file %1: '%2'").arg(this->getConfigFilepath()).arg(key));
}
@ -278,6 +283,7 @@ QMap<QString, QString> PorymapConfig::getKeyValueMap() {
map.insert("theme", this->theme);
map.insert("text_editor_open_directory", this->textEditorOpenFolder);
map.insert("text_editor_goto_line", this->textEditorGotoLine);
map.insert("palette_editor_bit_depth", QString("%1").arg(this->paletteEditorBitDepth));
return map;
}
@ -400,6 +406,11 @@ void PorymapConfig::setTextEditorGotoLine(const QString &command) {
this->save();
}
void PorymapConfig::setPaletteEditorBitDepth(int bitDepth) {
this->paletteEditorBitDepth = bitDepth;
this->save();
}
QString PorymapConfig::getRecentProject() {
return this->recentProject;
}
@ -498,6 +509,10 @@ QString PorymapConfig::getTextEditorGotoLine() {
return this->textEditorGotoLine;
}
int PorymapConfig::getPaletteEditorBitDepth() {
return this->paletteEditorBitDepth;
}
const QMap<BaseGameVersion, QString> baseGameVersionMap = {
{BaseGameVersion::pokeruby, "pokeruby"},
{BaseGameVersion::pokefirered, "pokefirered"},

View file

@ -87,7 +87,13 @@ PaletteEditor::PaletteEditor(Project *project, Tileset *primaryTileset, Tileset
connect(this->pickButtons[i], &QToolButton::clicked, [this, i](){ this->pickColor(i); });
}
setBitDepth(24);
int bitDepth = porymapConfig.getPaletteEditorBitDepth();
if (bitDepth == 15) {
this->ui->bit_depth_15->setChecked(true);
} else {
this->ui->bit_depth_24->setChecked(true);
}
setBitDepth(bitDepth);
// Connect bit depth buttons
connect(this->ui->bit_depth_15, &QRadioButton::toggled, [this](bool checked){ if (checked) this->setBitDepth(15); });
@ -227,6 +233,7 @@ void PaletteEditor::setBitDepth(int bits) {
break;
}
this->bitDepth = bits;
porymapConfig.setPaletteEditorBitDepth(bits);
refreshColorUis();
setSignalsEnabled(true);
}