many sparse changes
This commit is contained in:
1 parent
2c26c6f795
commit
7aa4ea4425
23 files changed
+1317
-290
No files matched your search
@@ -77,6 +77,10 @@ GraphicSet *loadGraphicSet(const QString &name, bool transparency = true);
|
||||
|
||||
enum class FontType { Normal, Small, Tiny, Caption, Button, Count };
|
||||
|
||||
// ScreenTools.pas's LoadFonts(): fills UniFont[] from a Fonts.txt script
|
||||
// ("#SECTION" lines followed by "Name, <pixel height>[B][I]" lines).
|
||||
void loadFonts(const QString &scriptFileName);
|
||||
|
||||
// Fonts, the main background texture and the system sprite sheets are
|
||||
// populated by the application's asset-loading step (ScreenTools.pas's
|
||||
// UnitInit/LoadAssets in the original, not ported here); null/default until
|
||||
|
||||
@@ -42,10 +42,8 @@ public:
|
||||
Texture();
|
||||
|
||||
int age() const { return m_age; }
|
||||
// Updates the palette colors from Cevo::Colors; does not (re)load the
|
||||
// per-age background image, that stays an application-level concern
|
||||
// (Directories::getGraphicsDir() + image()->loadFromFile() is not
|
||||
// ported here). Call image().loadFromFile() explicitly afterwards.
|
||||
// Loads the age's background image ("Texture<age+1>.jpg" from
|
||||
// Cevo::graphicsDir) and updates the palette colors from Cevo::Colors.
|
||||
void setAge(int value);
|
||||
|
||||
int width() const { return m_image.width(); }
|
||||
|
||||
@@ -29,9 +29,11 @@
|
||||
#include "Cevo/CevoScreenTools.h"
|
||||
#include "Cevo/CevoGraphicSet.h"
|
||||
#include "Cevo/CevoTexture.h"
|
||||
#include "Dpi/DpiCommon.h"
|
||||
#include "Dpi/DpiPixelPointer.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QFile>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
@@ -59,6 +61,48 @@ void drawBufferEnsureSize(int width, int height)
|
||||
drawBuffer.canvas().end();
|
||||
}
|
||||
|
||||
void loadFonts(const QString &scriptFileName)
|
||||
{
|
||||
QFile file(scriptFileName);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
return;
|
||||
FontType section = FontType::Normal;
|
||||
while (!file.atEnd()) {
|
||||
const QString line = QString::fromUtf8(file.readLine()).trimmed();
|
||||
if (line.isEmpty())
|
||||
continue;
|
||||
if (line.at(0) == QLatin1Char('#')) {
|
||||
if (line == QLatin1String("#SMALL"))
|
||||
section = FontType::Small;
|
||||
else if (line == QLatin1String("#TINY"))
|
||||
section = FontType::Tiny;
|
||||
else if (line == QLatin1String("#CAPTION"))
|
||||
section = FontType::Caption;
|
||||
else if (line == QLatin1String("#BUTTON"))
|
||||
section = FontType::Button;
|
||||
else
|
||||
section = FontType::Normal;
|
||||
continue;
|
||||
}
|
||||
const int comma = line.indexOf(QLatin1Char(','));
|
||||
if (comma <= 0)
|
||||
continue;
|
||||
Dpi::Font &font = UniFont[static_cast<std::size_t>(section)];
|
||||
font.setName(line.left(comma).trimmed());
|
||||
int size = 0;
|
||||
for (int i = comma + 1; i < line.length(); ++i) {
|
||||
const QChar c = line.at(i);
|
||||
if (c >= QLatin1Char('0') && c <= QLatin1Char('9'))
|
||||
size = size * 10 + c.digitValue();
|
||||
else if (c == QLatin1Char('B') || c == QLatin1Char('b'))
|
||||
font.setBold(true);
|
||||
else if (c == QLatin1Char('I') || c == QLatin1Char('i'))
|
||||
font.setItalic(true);
|
||||
}
|
||||
font.setHeight(Dpi::scaleToNative(size)); // the script gives pixel heights
|
||||
}
|
||||
}
|
||||
|
||||
QColor colorFromDelphi(int value)
|
||||
{
|
||||
return QColor(value & 0xFF, (value >> 8) & 0xFF, (value >> 16) & 0xFF);
|
||||
|
||||
@@ -38,6 +38,9 @@ void Texture::setAge(int value)
|
||||
if (m_age == value)
|
||||
return;
|
||||
m_age = value;
|
||||
if (!graphicsDir.isEmpty())
|
||||
m_image.loadFromFile(graphicsDir + QStringLiteral("/Texture") + QString::number(m_age + 1) +
|
||||
QStringLiteral(".jpg"));
|
||||
if (!Colors)
|
||||
return;
|
||||
QImage &palette = Colors->image();
|
||||
|
||||
Reference in new issue
Block a user