Fix color calc in palette editor hex edit

This commit is contained in:
GriffinR 2023-02-22 10:42:21 -05:00
parent 48d9d07689
commit 420e92e912
2 changed files with 9 additions and 11 deletions

View file

@ -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

View file

@ -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)));
}
}