various fixes
This commit is contained in:
1 parent
ef2e1b4680
commit
d1074096aa
2 files changed
+21
-4
No files matched your search
@@ -47,6 +47,10 @@ class GraphicSetItem;
|
|||||||
// (e.g. ButtonA's $0000FF placeholder color) with this helper rather than
|
// (e.g. ButtonA's $0000FF placeholder color) with this helper rather than
|
||||||
// constructing QColor from the raw hex value directly.
|
// constructing QColor from the raw hex value directly.
|
||||||
QColor colorFromDelphi(int value);
|
QColor colorFromDelphi(int value);
|
||||||
|
// Inverse of colorFromDelphi(): packs a QColor back into a Delphi/VCL
|
||||||
|
// $00BBGGRR int (needed whenever a QColor-valued field, e.g. a tribe's
|
||||||
|
// Color, must be passed to a raw-Delphi-int API like imageOpBCC()).
|
||||||
|
int colorToDelphi(const QColor &color);
|
||||||
|
|
||||||
// Global display gamma correction setting, in percent (100 = no
|
// Global display gamma correction setting, in percent (100 = no
|
||||||
// correction) - ScreenTools.pas's `Gamma`. Call applyGammaToBitmap()
|
// correction) - ScreenTools.pas's `Gamma`. Call applyGammaToBitmap()
|
||||||
|
|||||||
@@ -51,6 +51,11 @@ QColor colorFromDelphi(int value)
|
|||||||
return QColor(value & 0xFF, (value >> 8) & 0xFF, (value >> 16) & 0xFF);
|
return QColor(value & 0xFF, (value >> 8) & 0xFF, (value >> 16) & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int colorToDelphi(const QColor &color)
|
||||||
|
{
|
||||||
|
return color.red() | (color.green() << 8) | (color.blue() << 16);
|
||||||
|
}
|
||||||
|
|
||||||
int gamma = 100;
|
int gamma = 100;
|
||||||
GraphicSets grExt;
|
GraphicSets grExt;
|
||||||
QString graphicsDir;
|
QString graphicsDir;
|
||||||
@@ -124,14 +129,22 @@ GraphicSet *loadGraphicSet(const QString &name, bool transparency)
|
|||||||
return result;
|
return result;
|
||||||
result = &grExt.addNew(name);
|
result = &grExt.addNew(name);
|
||||||
|
|
||||||
const QString fileName = graphicsDir + QLatin1Char('/') + name;
|
const QString baseFileName = graphicsDir + QLatin1Char('/') + name;
|
||||||
|
// The original's LoadGraphicFile auto-appends ".png" when the name has
|
||||||
|
// no extension, but that is a by-value parameter so it does NOT affect
|
||||||
|
// the (possibly extension-less) base name used below for the .grs
|
||||||
|
// sidecar path - replicate both quirks exactly.
|
||||||
|
QString imageFileName = baseFileName;
|
||||||
|
if (QFileInfo(imageFileName).suffix().isEmpty())
|
||||||
|
imageFileName += QLatin1String(".png");
|
||||||
// Do not apply gamma during file load as it would affect transparency colors too.
|
// Do not apply gamma during file load as it would affect transparency colors too.
|
||||||
result->data.loadFromFile(fileName);
|
result->data.loadFromFile(imageFileName);
|
||||||
if (result->data.width() == 0 || result->data.height() == 0)
|
if (result->data.width() == 0 || result->data.height() == 0)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const QString grsFileName = QFileInfo(fileName).path() + QLatin1Char('/') +
|
const QFileInfo baseInfo(baseFileName);
|
||||||
QFileInfo(fileName).completeBaseName() + QLatin1String(GraphicSetFileExt);
|
const QString grsFileName = baseInfo.path() + QLatin1Char('/') +
|
||||||
|
baseInfo.completeBaseName() + QLatin1String(GraphicSetFileExt);
|
||||||
if (QFileInfo::exists(grsFileName))
|
if (QFileInfo::exists(grsFileName))
|
||||||
result->loadFromFile(grsFileName);
|
result->loadFromFile(grsFileName);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user