diff --git a/CHANGELOG.md b/CHANGELOG.md index 005f9130..bb42bc23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,8 @@ 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] -Nothing, yet. +### Fixed +- Fix text boxes in the Palette Editor calculating color incorrectly. ## [5.1.1] - 2023-02-20 ### Added diff --git a/src/ui/paletteeditor.cpp b/src/ui/paletteeditor.cpp index a674b4e7..f56902a1 100644 --- a/src/ui/paletteeditor.cpp +++ b/src/ui/paletteeditor.cpp @@ -261,18 +261,15 @@ void PaletteEditor::setRgbFromSliders(int colorIndex) { void PaletteEditor::setRgbFromHexEdit(int colorIndex) { QString text = this->hexEdits[colorIndex]->text(); bool ok = false; + int rgb = text.toInt(&ok, 16); + if (!ok) rgb = 0xFFFFFFFF; if (this->bitDepth == 15) { - int rgb15 = text.toInt(&ok, 16); - int rc = gbaRed(rgb15); - int gc = gbaGreen(rgb15); - int bc = gbaBlue(rgb15); - QRgb rgb = qRgb(rc, gc, bc); - if (!ok) rgb = 0xFFFFFFFF; - setRgb(colorIndex, rgb); + int rc = gbaRed(rgb); + int gc = gbaGreen(rgb); + int bc = gbaBlue(rgb); + setRgb(colorIndex, qRgb(rgb8(rc), rgb8(gc), rgb8(bc))); } else { - QRgb rgb = text.toInt(&ok, 16); - if (!ok) rgb = 0xFFFFFFFF; - setRgb(colorIndex, rgb); + setRgb(colorIndex, qRgb(qRed(rgb), qGreen(rgb), qBlue(rgb))); } }