final ports and first fixes
This commit is contained in:
1 parent
77690cbd96
commit
6f3556009a
23 files changed
+2302
-41
No files matched your search
@@ -119,6 +119,11 @@ set(PROJECT_SOURCES
|
|||||||
game/NoTerm.cpp
|
game/NoTerm.cpp
|
||||||
game/NoTerm.h
|
game/NoTerm.h
|
||||||
game/NoTerm.ui
|
game/NoTerm.ui
|
||||||
|
game/Start.cpp
|
||||||
|
game/Start.h
|
||||||
|
game/Start.Paint.cpp
|
||||||
|
game/Start.ui
|
||||||
|
game/StartLayout.h
|
||||||
game/localplayer/KeyBindings.cpp
|
game/localplayer/KeyBindings.cpp
|
||||||
game/localplayer/KeyBindings.h
|
game/localplayer/KeyBindings.h
|
||||||
game/localplayer/ClientTools.cpp
|
game/localplayer/ClientTools.cpp
|
||||||
|
|||||||
@@ -61,7 +61,11 @@ set_target_properties(stdai PROPERTIES
|
|||||||
)
|
)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
# Installed as an AI module directory (<AIDIR>/StdAI/StdAI.ai.txt, StdAI.png and the library).
|
||||||
install(TARGETS stdai
|
install(TARGETS stdai
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_AIDIR}
|
LIBRARY DESTINATION ${CMAKE_INSTALL_AIDIR}/StdAI
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_AIDIR}
|
RUNTIME DESTINATION ${CMAKE_INSTALL_AIDIR}/StdAI
|
||||||
|
)
|
||||||
|
install(FILES StdAI.ai.txt StdAI.png
|
||||||
|
DESTINATION ${CMAKE_INSTALL_AIDIR}/StdAI
|
||||||
)
|
)
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#NAME Standard AI
|
||||||
|
#GAMEVERSION 1.2.0
|
||||||
|
#BEGINNER
|
||||||
|
#PATH stdai.so
|
||||||
|
#PATH_WIN32 stdai.dll
|
||||||
|
#PATH_WIN64 stdai.dll
|
||||||
|
#CREDITS Standard AI by Steffen Gerlach.
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 6.9 KiB |
@@ -47,6 +47,10 @@ namespace {
|
|||||||
// resolve the install-time default set up by CMakeLists.txt.
|
// resolve the install-time default set up by CMakeLists.txt.
|
||||||
QString getAiDir()
|
QString getAiDir()
|
||||||
{
|
{
|
||||||
|
// The CEVO_AI_DIR environment variable overrides the install location (for running a build-tree binary).
|
||||||
|
const QByteArray fromEnvironment = qgetenv("CEVO_AI_DIR");
|
||||||
|
if (!fromEnvironment.isEmpty())
|
||||||
|
return QString::fromLocal8Bit(fromEnvironment);
|
||||||
#ifdef CEVO_AI_DIR
|
#ifdef CEVO_AI_DIR
|
||||||
return QStringLiteral(CEVO_AI_DIR);
|
return QStringLiteral(CEVO_AI_DIR);
|
||||||
#else
|
#else
|
||||||
|
|||||||
+13
-4
@@ -31,6 +31,7 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "Messg.h"
|
#include "Messg.h"
|
||||||
#include "NoTerm.h"
|
#include "NoTerm.h"
|
||||||
|
#include "Start.h"
|
||||||
#include "localplayer/LocalPlayer.h"
|
#include "localplayer/LocalPlayer.h"
|
||||||
|
|
||||||
#include "Cevo/CevoScreenTools.h"
|
#include "Cevo/CevoScreenTools.h"
|
||||||
@@ -82,6 +83,12 @@ DirectDlg::DirectDlg(QWidget *parent) : DrawDlg(parent)
|
|||||||
GameServer::brainRandom->lookupName = QStringLiteral("RANDOMAI");
|
GameServer::brainRandom->lookupName = QStringLiteral("RANDOMAI");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DirectDlg::setStartDlg(StartDlg *dlg)
|
||||||
|
{
|
||||||
|
m_startDlg = dlg;
|
||||||
|
m_background = dlg ? dlg->background() : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void DirectDlg::showEvent(QShowEvent *event)
|
void DirectDlg::showEvent(QShowEvent *event)
|
||||||
{
|
{
|
||||||
DrawDlg::showEvent(event);
|
DrawDlg::showEvent(event);
|
||||||
@@ -240,10 +247,12 @@ void DirectDlg::dlgNotify(GameServer::NotifyId id, int index)
|
|||||||
case NotifyId::StartGoRefreshMaps:
|
case NotifyId::StartGoRefreshMaps:
|
||||||
if (m_quick) {
|
if (m_quick) {
|
||||||
close();
|
close();
|
||||||
} else {
|
} else if (m_startDlg) {
|
||||||
// TODO: StartDlg::updateFormerGames()/updateMaps() not ported.
|
if (id == NotifyId::StartGoRefresh)
|
||||||
if (m_startDlg)
|
m_startDlg->updateFormerGames();
|
||||||
m_startDlg->show();
|
else if (id == NotifyId::StartGoRefreshMaps)
|
||||||
|
m_startDlg->updateMaps(false);
|
||||||
|
m_startDlg->show();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NotifyId::ChangeClient:
|
case NotifyId::ChangeClient:
|
||||||
|
|||||||
+8
-10
@@ -35,18 +35,17 @@
|
|||||||
|
|
||||||
namespace Cevo {
|
namespace Cevo {
|
||||||
|
|
||||||
|
class StartDlg;
|
||||||
|
|
||||||
// Equivalent of Direct.pas's TDirectDlg: the small "busy/progress" splash
|
// Equivalent of Direct.pas's TDirectDlg: the small "busy/progress" splash
|
||||||
// dialog shown while the game engine starts up, loads a save/map file, or
|
// dialog shown while the game engine starts up, loads a save/map file, or
|
||||||
// hands control over between clients - and the application's actual entry
|
// hands control over between clients - and the application's actual entry
|
||||||
// point (OnGo parses the command line and kicks everything off). Like
|
// point (OnGo parses the command line and kicks everything off). Like
|
||||||
// Back.pas, the .lfm has no child controls, so no .ui file is used here.
|
// Back.pas, the .lfm has no child controls, so no .ui file is used here.
|
||||||
//
|
//
|
||||||
// Start.pas/LocalPlayer.pas/NoTerm.pas/NetworkServer.pas/NetworkClient.pas
|
// NetworkServer.pas/NetworkClient.pas are not ported (their client entry
|
||||||
// are not ported - every place the original reaches into StartDlg or
|
// points are a marked gap in the .cpp). The start screen plugs in through
|
||||||
// assigns a special brain's in-process Client function pointer is a
|
// setStartDlg(), the same decoupling used by Back.pas's setAnchor().
|
||||||
// disclosed, clearly-marked gap (see the .cpp). setStartDlg()/
|
|
||||||
// setBackground() let the eventual Start.pas port plug itself in, the same
|
|
||||||
// decoupling already used by Back.pas's setAnchor().
|
|
||||||
class DirectDlg : public DrawDlg {
|
class DirectDlg : public DrawDlg {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@@ -56,9 +55,8 @@ public:
|
|||||||
// DlgNotify) - pass this to GameServer::init().
|
// DlgNotify) - pass this to GameServer::init().
|
||||||
void dlgNotify(GameServer::NotifyId id, int index = 0);
|
void dlgNotify(GameServer::NotifyId id, int index = 0);
|
||||||
|
|
||||||
// Not-yet-ported Start.pas decoupling (see class comment).
|
// Start.pas decoupling: the start screen and, through it, the background window.
|
||||||
void setStartDlg(QWidget *dlg) { m_startDlg = dlg; }
|
void setStartDlg(StartDlg *dlg);
|
||||||
void setBackground(QWidget *background) { m_background = background; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void showEvent(QShowEvent *event) override;
|
void showEvent(QShowEvent *event) override;
|
||||||
@@ -70,7 +68,7 @@ private:
|
|||||||
void setInfo(const QString &text);
|
void setInfo(const QString &text);
|
||||||
void setState(int value);
|
void setState(int value);
|
||||||
|
|
||||||
QWidget *m_startDlg = nullptr;
|
StartDlg *m_startDlg = nullptr;
|
||||||
QWidget *m_background = nullptr;
|
QWidget *m_background = nullptr;
|
||||||
|
|
||||||
QString m_info;
|
QString m_info;
|
||||||
|
|||||||
@@ -55,10 +55,13 @@ namespace Cevo {
|
|||||||
namespace GameServer {
|
namespace GameServer {
|
||||||
|
|
||||||
|
|
||||||
// Equivalent of Directories.pas's GetAiDir() - see Brain.cpp's own copy of
|
// Equivalent of Directories.pas's GetAiDir().
|
||||||
// this (not shared via a header since Directories.pas itself isn't ported).
|
|
||||||
QString getAiDir()
|
QString getAiDir()
|
||||||
{
|
{
|
||||||
|
// The CEVO_AI_DIR environment variable overrides the install location (for running a build-tree binary).
|
||||||
|
const QByteArray fromEnvironment = qgetenv("CEVO_AI_DIR");
|
||||||
|
if (!fromEnvironment.isEmpty())
|
||||||
|
return QString::fromLocal8Bit(fromEnvironment);
|
||||||
#ifdef CEVO_AI_DIR
|
#ifdef CEVO_AI_DIR
|
||||||
return QStringLiteral(CEVO_AI_DIR);
|
return QStringLiteral(CEVO_AI_DIR);
|
||||||
#else
|
#else
|
||||||
|
|||||||
+1
-2
@@ -210,8 +210,7 @@ void init(const NotifyFunction ¬ifyFunction)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (brains.kindCount(BrainType::AI) == 0)
|
// No AI at all is reported to the user by DirectDlg::go() (Brains.Count = 3 there), not fatal here.
|
||||||
throw std::runtime_error(("No AI libraries found in directory " + getAiDir()).toStdString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,11 +35,15 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
|
#include <QRect>
|
||||||
|
#include <QSettings>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
namespace Cevo {
|
namespace Cevo {
|
||||||
|
|
||||||
bool fullScreen = false;
|
bool fullScreen = false;
|
||||||
|
float musicVolume = 0.5f;
|
||||||
|
QRect termBounds(0, 0, 800, 480);
|
||||||
bool musicEnabled = true;
|
bool musicEnabled = true;
|
||||||
bool generateNames = true;
|
bool generateNames = true;
|
||||||
|
|
||||||
@@ -160,6 +164,34 @@ QString formatPhrase(const QString &key, const QStringList &args)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void loadConfig()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
localeCode = settings.value(QStringLiteral("Locale")).toString();
|
||||||
|
fullScreen = settings.value(QStringLiteral("ScreenMode"), 1).toInt() > 0;
|
||||||
|
musicEnabled = settings.value(QStringLiteral("MusicEnabled"), true).toBool();
|
||||||
|
musicVolume = settings.value(QStringLiteral("MusicVolume"), 0.5).toFloat();
|
||||||
|
termBounds = QRect(settings.value(QStringLiteral("TermLeft"), 0).toInt(),
|
||||||
|
settings.value(QStringLiteral("TermTop"), 0).toInt(),
|
||||||
|
settings.value(QStringLiteral("TermWidth"), 800).toInt(),
|
||||||
|
settings.value(QStringLiteral("TermHeight"), 480).toInt());
|
||||||
|
gamma = settings.value(QStringLiteral("Gamma"), 100).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void saveConfig()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
settings.setValue(QStringLiteral("Locale"), localeCode);
|
||||||
|
settings.setValue(QStringLiteral("ScreenMode"), fullScreen ? 1 : 0);
|
||||||
|
settings.setValue(QStringLiteral("MusicEnabled"), musicEnabled);
|
||||||
|
settings.setValue(QStringLiteral("MusicVolume"), musicVolume);
|
||||||
|
settings.setValue(QStringLiteral("TermLeft"), termBounds.left());
|
||||||
|
settings.setValue(QStringLiteral("TermTop"), termBounds.top());
|
||||||
|
settings.setValue(QStringLiteral("TermWidth"), termBounds.width());
|
||||||
|
settings.setValue(QStringLiteral("TermHeight"), termBounds.height());
|
||||||
|
settings.setValue(QStringLiteral("Gamma"), gamma);
|
||||||
|
}
|
||||||
|
|
||||||
void loadAssets()
|
void loadAssets()
|
||||||
{
|
{
|
||||||
graphicsDir = getGraphicsDir();
|
graphicsDir = getGraphicsDir();
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "Cevo/CevoStringTables.h"
|
#include "Cevo/CevoStringTables.h"
|
||||||
|
|
||||||
|
#include <QRect>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
@@ -42,6 +43,10 @@ constexpr const char *CevoTitle = "C-evo";
|
|||||||
constexpr const char *CevoSubTitle = "New Horizons";
|
constexpr const char *CevoSubTitle = "New Horizons";
|
||||||
constexpr const char *CevoExt = ".cevo";
|
constexpr const char *CevoExt = ".cevo";
|
||||||
constexpr const char *CevoTribeExt = ".tribe.txt";
|
constexpr const char *CevoTribeExt = ".tribe.txt";
|
||||||
|
constexpr const char *CevoHomepageShort = "app.zdechov.net/c-evo";
|
||||||
|
constexpr const char *CevoHomepage = "https://app.zdechov.net/c-evo";
|
||||||
|
constexpr const char *CevoContactBug = "https://app.zdechov.net/c-evo/report/1";
|
||||||
|
constexpr const char *AITemplateFileName = "AI Template/AI development manual.html";
|
||||||
|
|
||||||
constexpr int CevoVersionMajor = 1;
|
constexpr int CevoVersionMajor = 1;
|
||||||
constexpr int CevoVersionMinor = 4;
|
constexpr int CevoVersionMinor = 4;
|
||||||
@@ -54,6 +59,17 @@ constexpr int CevoVersion = ((CevoVersionMajor & 0xFF) << 16) | ((CevoVersionMin
|
|||||||
// by Back.pas/Start.pas to decide fullscreen vs. windowed layout).
|
// by Back.pas/Start.pas to decide fullscreen vs. windowed layout).
|
||||||
extern bool fullScreen;
|
extern bool fullScreen;
|
||||||
|
|
||||||
|
// Global.pas/ScreenTools.pas user settings: music volume (0..1) and the
|
||||||
|
// main game window's last position/size.
|
||||||
|
extern float musicVolume;
|
||||||
|
extern QRect termBounds;
|
||||||
|
|
||||||
|
// The persisted user settings shared by the whole game (language, screen
|
||||||
|
// mode, music, main window bounds, gamma), stored with QSettings where the
|
||||||
|
// original used the registry. loadConfig() must run before loadAssets().
|
||||||
|
void loadConfig();
|
||||||
|
void saveConfig();
|
||||||
|
|
||||||
// Equivalent of a user-settings `MusicEnabled` flag (Start.pas/Direct.pas -
|
// Equivalent of a user-settings `MusicEnabled` flag (Start.pas/Direct.pas -
|
||||||
// neither ported in full - toggle background music playback on/off).
|
// neither ported in full - toggle background music playback on/off).
|
||||||
extern bool musicEnabled;
|
extern bool musicEnabled;
|
||||||
|
|||||||
@@ -0,0 +1,385 @@
|
|||||||
|
// This file is part of c-evo-evo.
|
||||||
|
//
|
||||||
|
// This software is governed by the CeCILL license under French law and
|
||||||
|
// abiding by the rules of distribution of free software. You can use,
|
||||||
|
// modify and/or redistribute the software under the terms of the CeCILL
|
||||||
|
// license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
|
// "http://www.cecill.info".
|
||||||
|
//
|
||||||
|
// As a counterpart to the access to the source code and rights to copy,
|
||||||
|
// modify and redistribute granted by the license, users are provided only
|
||||||
|
// with a limited warranty and the software's author, the holder of the
|
||||||
|
// economic rights, and the successive licensors have only limited
|
||||||
|
// liability.
|
||||||
|
//
|
||||||
|
// In this respect, the user's attention is drawn to the risks associated
|
||||||
|
// with loading, using, modifying and/or developing or reproducing the
|
||||||
|
// software by the user in light of its specific status of free software,
|
||||||
|
// that may mean that it is complicated to manipulate, and that also
|
||||||
|
// therefore means that it is reserved for developers and experienced
|
||||||
|
// professionals having in-depth computer knowledge. Users are therefore
|
||||||
|
// encouraged to load and test the software's suitability as regards their
|
||||||
|
// requirements in conditions enabling the security of their systems and/or
|
||||||
|
// data to be ensured and, more generally, to use and operate it in the
|
||||||
|
// same conditions as regards security.
|
||||||
|
//
|
||||||
|
// The fact that you are presently reading this means that you have had
|
||||||
|
// knowledge of the CeCILL license and that you accept its terms.
|
||||||
|
|
||||||
|
// Start.pas, the painting part: TStartDlg.OffscreenPaint and DrawAction.
|
||||||
|
|
||||||
|
#include "Start.h"
|
||||||
|
#include "ui_Start.h"
|
||||||
|
|
||||||
|
#include "Cevo/CevoButtonA.h"
|
||||||
|
#include "Cevo/CevoButtonB.h"
|
||||||
|
#include "Cevo/CevoButtonC.h"
|
||||||
|
#include "Cevo/CevoGraphicSet.h"
|
||||||
|
#include "Cevo/CevoListBoxEx.h"
|
||||||
|
#include "Cevo/CevoScreenTools.h"
|
||||||
|
#include "Cevo/CevoTexture.h"
|
||||||
|
#include "Cevo/Database.h"
|
||||||
|
#include "GameServer.h"
|
||||||
|
#include "Global.h"
|
||||||
|
#include "StartLayout.h"
|
||||||
|
#include "localplayer/Term.h"
|
||||||
|
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
namespace Cevo {
|
||||||
|
|
||||||
|
using namespace StartLayout;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
QString startControl(int index)
|
||||||
|
{
|
||||||
|
return phrases.lookup(QStringLiteral("STARTCONTROLS"), index);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isPlayableBrain(const Brain *brain)
|
||||||
|
{
|
||||||
|
return brain && (brain->kind == BrainType::Term || brain->kind == BrainType::Random ||
|
||||||
|
brain->kind == BrainType::AI);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rectangular copy between two canvases (Pascal's BitBltCanvas).
|
||||||
|
void copyBlock(Dpi::Canvas &dst, int x, int y, int w, int h, Dpi::Canvas &src, int xSrc, int ySrc)
|
||||||
|
{
|
||||||
|
dst.copyRect(QRect(x, y, w, h), src, QRect(xSrc, ySrc, w, h));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
void StartDlg::drawAction(int y, int iconIndex, const QString &headerItem, const QString &textItem)
|
||||||
|
{
|
||||||
|
Dpi::Canvas &canvas = offscreen.canvas();
|
||||||
|
canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Caption)]);
|
||||||
|
canvas.font().setUnderline(true);
|
||||||
|
risedTextOut(canvas, xAction, y - 3, phrases2.lookup(headerItem));
|
||||||
|
canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Normal)]);
|
||||||
|
biColorTextOut(canvas, Colors->image().pixelColor(clkAge0 - 1, cliDimmedText), Qt::black, xAction, y + 21,
|
||||||
|
phrases2.lookup(textItem));
|
||||||
|
|
||||||
|
drawBufferEnsureSize(50, 50);
|
||||||
|
drawBuffer.canvas().begin();
|
||||||
|
copyBlock(drawBuffer.canvas(), 0, 0, 50, 50, canvas, xActionIcon - 2, y - 2);
|
||||||
|
drawBuffer.canvas().end();
|
||||||
|
glowFrame(drawBuffer, 8, 8, 34, 34, QColor(0x20, 0x20, 0x20));
|
||||||
|
copyBlock(canvas, xActionIcon - 2, y - 2, 50, 50, drawBuffer.canvas(), 0, 0);
|
||||||
|
copyBlock(canvas, xActionIcon, y, 40, 40, bigImp->canvas(), (iconIndex % 7) * xSizeBig + 8,
|
||||||
|
(iconIndex / 7) * ySizeBig);
|
||||||
|
rframe(canvas, xActionIcon - 1, y - 1, xActionIcon + 40, y + 40, Qt::black, Qt::black);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StartDlg::offscreenPaint()
|
||||||
|
{
|
||||||
|
static const int tabNames[4] = { 0, 11, 3, 4 };
|
||||||
|
BufferedDrawDlg::offscreenPaint();
|
||||||
|
clearOffscreen(offscreen);
|
||||||
|
if (!MainTexture || !HGrSystem || !Templates || !bigImp || !Colors)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Dpi::Canvas &canvas = offscreen.canvas();
|
||||||
|
canvas.begin();
|
||||||
|
const QColor shade = MainTexture->colorBevelShade;
|
||||||
|
const QColor light = MainTexture->colorBevelLight;
|
||||||
|
const int clientWidth = width();
|
||||||
|
const int clientHeight = height();
|
||||||
|
const int tabIndex = static_cast<int>(m_tab);
|
||||||
|
canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Normal)]);
|
||||||
|
canvas.brush().setStyle(Qt::NoBrush);
|
||||||
|
|
||||||
|
paintBackground(canvas, 3, 3, TabOffset + 4 * TabSize - 4, TabHeight - 3, clientWidth, clientHeight);
|
||||||
|
paintBackground(canvas, 3, TabHeight + 3, clientWidth - 6, clientHeight - TabHeight - 6, clientWidth,
|
||||||
|
clientHeight);
|
||||||
|
canvas.brush().setStyle(Qt::SolidPattern);
|
||||||
|
canvas.brush().setColor(Qt::black);
|
||||||
|
canvas.fillRect(QRect(0, 1, clientWidth, 2));
|
||||||
|
canvas.fillRect(QRect(TabOffset + 4 * TabSize + 2, 0, clientWidth - (TabOffset + 4 * TabSize + 2), TabHeight));
|
||||||
|
canvas.brush().setStyle(Qt::NoBrush);
|
||||||
|
|
||||||
|
if (m_page == Page::StartRandom || m_page == Page::StartMap) {
|
||||||
|
frame(canvas, 328, yMain + 112 - 15, clientWidth + 10, ui->up2Btn->y() + 38, shade, light);
|
||||||
|
if (m_autoDiff > 0)
|
||||||
|
frame(canvas, -1, yMain + 112 - 15, x0Brain + dxBrain + 64, ui->up2Btn->y() + 38, shade, light);
|
||||||
|
} else if (m_page != Page::Main) {
|
||||||
|
frame(canvas, 328, ui->up1Btn->y() - 15, clientWidth + 10, ui->up2Btn->y() + 38, shade, light);
|
||||||
|
}
|
||||||
|
frame(canvas, 0, 0, clientWidth - 1, clientHeight - 1, Qt::black, Qt::black);
|
||||||
|
|
||||||
|
// draw tabs
|
||||||
|
const int lift0 = 2 * (m_tab != Tab::Main ? 1 : 0);
|
||||||
|
frame(canvas, 2, 2 + lift0, TabOffset + (0 + 1) * TabSize - 1, TabHeight, light, shade);
|
||||||
|
frame(canvas, 1, 1 + lift0, TabOffset + (0 + 1) * TabSize, TabHeight, light, shade);
|
||||||
|
canvas.setPixel(1, 1 + lift0, shade);
|
||||||
|
for (int tab2 = static_cast<int>(Tab::Map); tab2 <= static_cast<int>(Tab::PreviousGame); ++tab2) {
|
||||||
|
const int lift = 2 * (tabIndex != tab2 ? 1 : 0);
|
||||||
|
frame(canvas, TabOffset + tab2 * TabSize + 2, 2 + lift, TabOffset + (tab2 + 1) * TabSize - 1, TabHeight, light,
|
||||||
|
shade);
|
||||||
|
frame(canvas, TabOffset + tab2 * TabSize + 1, 1 + lift, TabOffset + (tab2 + 1) * TabSize, TabHeight, light,
|
||||||
|
shade);
|
||||||
|
canvas.setPixel(TabOffset + tab2 * TabSize + 1, 1 + lift, shade);
|
||||||
|
}
|
||||||
|
canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Normal)]);
|
||||||
|
for (int tab2 = static_cast<int>(Tab::Map); tab2 <= static_cast<int>(Tab::PreviousGame); ++tab2) {
|
||||||
|
const QString s = startControl(tabNames[tab2]);
|
||||||
|
risedTextOut(canvas, TabOffset + tab2 * TabSize + 1 + (TabSize - biColorTextWidth(canvas, s)) / 2,
|
||||||
|
10 + 2 * (tabIndex != tab2 ? 1 : 0), s);
|
||||||
|
}
|
||||||
|
frame(canvas, TabOffset + 4 * TabSize + 1, -1, clientWidth, TabHeight, Qt::black, Qt::black);
|
||||||
|
frame(canvas, 1, TabHeight + 1, clientWidth - 2, clientHeight - 2, light, shade);
|
||||||
|
frame(canvas, 2, TabHeight + 2, clientWidth - 3, clientHeight - 3, light, shade);
|
||||||
|
if (m_tab == Tab::Main) {
|
||||||
|
paintBackground(canvas, 3, TabHeight - 1, TabSize - 4 - 3 + TabOffset + 3, 4, clientWidth, clientHeight);
|
||||||
|
canvas.setPixel(2, TabHeight, light);
|
||||||
|
} else {
|
||||||
|
paintBackground(canvas, TabOffset + 3 + tabIndex * TabSize, TabHeight - 1, TabSize - 4, 4, clientWidth,
|
||||||
|
clientHeight);
|
||||||
|
canvas.setPixel(TabOffset + tabIndex * TabSize + 2, TabHeight, light);
|
||||||
|
}
|
||||||
|
canvas.setPixel(TabOffset + (tabIndex + 1) * TabSize - 1, TabHeight + 1, shade);
|
||||||
|
if (m_tab < Tab::PreviousGame)
|
||||||
|
frame(canvas, TabOffset + (tabIndex + 1) * TabSize + 1, 3, TabOffset + (tabIndex + 1) * TabSize + 2,
|
||||||
|
TabHeight, shade, shade); // tab shadow
|
||||||
|
|
||||||
|
// Paint menu logo
|
||||||
|
if (GraphicSetItem *menuLogo = Templates->searchByName(QStringLiteral("MenuLogo"))) {
|
||||||
|
const int logoY = 3 + 2 * (m_tab != Tab::Main ? 1 : 0);
|
||||||
|
drawBufferEnsureSize(menuLogo->width, menuLogo->height);
|
||||||
|
drawBuffer.canvas().begin();
|
||||||
|
copyBlock(drawBuffer.canvas(), 0, 0, menuLogo->width, menuLogo->height, canvas, 6, logoY);
|
||||||
|
drawBuffer.canvas().end();
|
||||||
|
imageOpBCC(drawBuffer, Templates->data, 0, 0, menuLogo->left, menuLogo->top, menuLogo->width,
|
||||||
|
menuLogo->height - 9, 0xBFBF20, 0x4040DF); // logo part 1
|
||||||
|
imageOpBCC(drawBuffer, Templates->data, 10, 27, menuLogo->left + 10, menuLogo->top + 27, menuLogo->width - 10,
|
||||||
|
9, 0xBFBF20, 0x4040DF); // logo part 2
|
||||||
|
copyBlock(canvas, 6, logoY, menuLogo->width, menuLogo->height, drawBuffer.canvas(), 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_page == Page::Main) {
|
||||||
|
if (m_selectedAction != MainAction::None) { // mark selected action
|
||||||
|
const int row = static_cast<int>(m_selectedAction);
|
||||||
|
const int w = clientWidth - 2 * ActionSideBorder;
|
||||||
|
int h = ActionPitch;
|
||||||
|
const int top = yAction + row * ActionPitch - 8;
|
||||||
|
if (top + h > clientHeight - ActionBottomBorder)
|
||||||
|
h = clientHeight - ActionBottomBorder - top;
|
||||||
|
drawBufferEnsureSize(w, h);
|
||||||
|
drawBuffer.canvas().begin();
|
||||||
|
copyBlock(drawBuffer.canvas(), 0, 0, w, h, canvas, ActionSideBorder, top);
|
||||||
|
drawBuffer.canvas().end();
|
||||||
|
makeBlue(drawBuffer, 0, 0, w, h);
|
||||||
|
copyBlock(canvas, ActionSideBorder, top, w, h, drawBuffer.canvas(), 0, 0);
|
||||||
|
}
|
||||||
|
int y = yAction;
|
||||||
|
for (int row = 0; row <= static_cast<int>(MainAction::None); ++row, y += ActionPitch) {
|
||||||
|
const auto action = static_cast<MainAction>(row);
|
||||||
|
if (std::find(m_actionsOffered.begin(), m_actionsOffered.end(), action) == m_actionsOffered.end())
|
||||||
|
continue;
|
||||||
|
switch (action) {
|
||||||
|
case MainAction::Config: drawAction(y, 25, QStringLiteral("ACTIONHEADER_CONFIG"), QStringLiteral("ACTION_CONFIG")); break;
|
||||||
|
case MainAction::Manual: drawAction(y, 19, QStringLiteral("ACTIONHEADER_MANUAL"), QStringLiteral("ACTION_MANUAL")); break;
|
||||||
|
case MainAction::Credits: drawAction(y, 22, QStringLiteral("ACTIONHEADER_CREDITS"), QStringLiteral("ACTION_CREDITS")); break;
|
||||||
|
case MainAction::AIDev: drawAction(y, 24, QStringLiteral("ACTIONHEADER_AIDEV"), QStringLiteral("ACTION_AIDEV")); break;
|
||||||
|
case MainAction::Web: {
|
||||||
|
canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Caption)]);
|
||||||
|
risedTextOut(canvas, xActionIcon + 99, y,
|
||||||
|
phraseToQtFormat(phrases2.lookup(QStringLiteral("ACTIONHEADER_WEB")))
|
||||||
|
.arg(QString::fromLatin1(CevoHomepageShort)));
|
||||||
|
canvas.font().assign(UniFont[static_cast<std::size_t>(FontType::Normal)]);
|
||||||
|
if (GraphicSetItem *arrows = Templates->searchByName(QStringLiteral("LinkArrows"))) {
|
||||||
|
drawBufferEnsureSize(arrows->width, arrows->height);
|
||||||
|
drawBuffer.canvas().begin();
|
||||||
|
copyBlock(drawBuffer.canvas(), 0, 0, arrows->width, arrows->height, canvas, xActionIcon, y + 2);
|
||||||
|
drawBuffer.canvas().end();
|
||||||
|
imageOpBCC(drawBuffer, Templates->data, 0, 0, arrows->left, arrows->top, arrows->width,
|
||||||
|
arrows->height, 0,
|
||||||
|
colorToDelphi(Colors->image().pixelColor(clkAge0 - 1, cliDimmedText)));
|
||||||
|
copyBlock(canvas, xActionIcon, y + 2, arrows->width, arrows->height, drawBuffer.canvas(), 0, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MainAction::None: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (m_page == Page::StartRandom || m_page == Page::StartMap) {
|
||||||
|
underlinedTitleValue(canvas, startControl(10), Term::turnToString(m_maxTurn), 344, y0Mini + 61, 170);
|
||||||
|
|
||||||
|
QString s = startControl(7);
|
||||||
|
loweredTextOut(canvas, -2, *MainTexture, x0Brain + 32 - canvas.textWidth(s) / 2, y0Brain + dyBrain + 69, s);
|
||||||
|
|
||||||
|
initOrnament();
|
||||||
|
GraphicSetItem *ornament = HGrSystem2 ? HGrSystem2->searchByName(QStringLiteral("Ornament")) : nullptr;
|
||||||
|
if (m_autoDiff < 0) {
|
||||||
|
if (ornament) {
|
||||||
|
for (int i = 12; i <= 19; ++i) {
|
||||||
|
if (i < 13 || i > 17)
|
||||||
|
sprite(canvas, 9 + i * 27, yLogo - 2, *ornament);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
paintLogo(canvas, 69 + 11 * 27, yLogo, light, shade);
|
||||||
|
|
||||||
|
for (int i = 0; i < nPlOffered; ++i) {
|
||||||
|
if (!((1 << i) & m_slotAvailable))
|
||||||
|
continue;
|
||||||
|
Brain *brain = GameServer::playersBrain[static_cast<std::size_t>(i)];
|
||||||
|
if (brain)
|
||||||
|
frameImage(canvas, brain->picture, xBrain[i], yBrain[i], 64, 64, 0, 0, true);
|
||||||
|
else
|
||||||
|
frameImage(canvas, m_emptyPicture, xBrain[i], yBrain[i], 64, 64, 0, 0, true);
|
||||||
|
if (isPlayableBrain(brain)) {
|
||||||
|
const PlayerSlot &slot = m_playerSlots[static_cast<std::size_t>(i)];
|
||||||
|
copyBlock(canvas, xBrain[i] - 18, yBrain[i] + 19, 12, 14, HGrSystem->data.canvas(),
|
||||||
|
134 + (Database::difficulty[static_cast<std::size_t>(i)] - 1) * 13, 28);
|
||||||
|
frame(canvas, xBrain[i] - 19, yBrain[i] + 18, xBrain[i] - 18 + 12, yBrain[i] + (19 + 14),
|
||||||
|
Qt::black, Qt::black);
|
||||||
|
rframe(canvas, slot.diffUpBtn->x() - 1, slot.diffUpBtn->y() - 1, slot.diffUpBtn->x() + 12,
|
||||||
|
slot.diffUpBtn->y() + 24, shade, light);
|
||||||
|
canvas.brush().setStyle(Qt::SolidPattern);
|
||||||
|
canvas.brush().setColor(Qt::black);
|
||||||
|
canvas.fillRect(QRect(xBrain[i] - 5, yBrain[i] + 25, 3, 2));
|
||||||
|
canvas.brush().setStyle(Qt::NoBrush);
|
||||||
|
if (slot.offerMultiple) {
|
||||||
|
rframe(canvas, slot.multiBtn->x() - 1, slot.multiBtn->y() - 1, slot.multiBtn->x() + 12,
|
||||||
|
slot.multiBtn->y() + 12, shade, light);
|
||||||
|
copyBlock(canvas, xBrain[i] - 31, yBrain[i], 13, 12, HGrSystem->data.canvas(), 88, 47);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (brain) {
|
||||||
|
const PlayerSlot &slot = m_playerSlots[static_cast<std::size_t>(i)];
|
||||||
|
const QString hint = phraseToQtFormat(startControl(9)).arg(brain->name());
|
||||||
|
slot.diffUpBtn->setToolTip(hint);
|
||||||
|
slot.diffDownBtn->setToolTip(hint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dLine(canvas, 24, 198, yMain + 140 + 19, light, shade);
|
||||||
|
risedTextOut(canvas, 24, yMain + 140, startControl(15));
|
||||||
|
if (m_page == Page::StartRandom)
|
||||||
|
s = QString::number(m_autoEnemies);
|
||||||
|
else if (m_mapStartPositions == 0)
|
||||||
|
s = QStringLiteral("0");
|
||||||
|
else
|
||||||
|
s = QString::number(m_mapStartPositions - 1);
|
||||||
|
risedTextOut(canvas, 198 - biColorTextWidth(canvas, s), yMain + 140, s);
|
||||||
|
|
||||||
|
dLine(canvas, 24, xDefault - 6, yMain + 164 + 19, light, shade);
|
||||||
|
risedTextOut(canvas, 24, yMain + 164, startControl(16));
|
||||||
|
if (m_autoDiff == 1) {
|
||||||
|
if (Brain *beginner = GameServer::brains.beginner())
|
||||||
|
frameImage(canvas, beginner->picture, xDefault, yDefault, 64, 64, 0, 0, false);
|
||||||
|
} else if (m_brainDefault) {
|
||||||
|
frameImage(canvas, m_brainDefault->picture, xDefault, yDefault, 64, 64, 0, 0, true);
|
||||||
|
}
|
||||||
|
dLine(canvas, 56, 272, y0Mini + 61 + 19, light, shade);
|
||||||
|
|
||||||
|
risedTextOut(canvas, 56, y0Mini + 61, startControl(14));
|
||||||
|
s = phrases.lookup(QStringLiteral("AUTODIFF"), m_autoDiff - 1);
|
||||||
|
risedTextOut(canvas, 272 - biColorTextWidth(canvas, s), y0Mini + 61, s);
|
||||||
|
if (ornament) {
|
||||||
|
for (int i = 0; i < 20; ++i) {
|
||||||
|
if (i < 2 || i > 6)
|
||||||
|
sprite(canvas, 9 + i * 27, yLogo - 2, *ornament);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
paintLogo(canvas, 69, yLogo, light, shade);
|
||||||
|
}
|
||||||
|
} else if (m_page == Page::Load) {
|
||||||
|
if (m_lastTurn > 0) {
|
||||||
|
paintProgressBar(canvas, 6, xTurnSlider, yTurnSlider, 0, m_loadTurn * wTurnSlider / m_lastTurn,
|
||||||
|
wTurnSlider, *MainTexture);
|
||||||
|
frame(canvas, xTurnSlider - 2, yTurnSlider - 2, xTurnSlider + wTurnSlider + 1, yTurnSlider + 8,
|
||||||
|
QColor(0xB0, 0xB0, 0xB0), Qt::white);
|
||||||
|
rframe(canvas, xTurnSlider - 3, yTurnSlider - 3, xTurnSlider + wTurnSlider + 2, yTurnSlider + 9,
|
||||||
|
Qt::white, QColor(0xB0, 0xB0, 0xB0));
|
||||||
|
} else {
|
||||||
|
dLine(canvas, 344, 514, y0Mini + 61 + 19, light, shade);
|
||||||
|
}
|
||||||
|
risedTextOut(canvas, 344, y0Mini + 61, startControl(8));
|
||||||
|
const QString s = Term::turnToString(m_loadTurn);
|
||||||
|
risedTextOut(canvas, 514 - biColorTextWidth(canvas, s), y0Mini + 61, s);
|
||||||
|
} else if (m_page == Page::EditRandom) {
|
||||||
|
const QPoint world = WorldSizes[m_worldSize];
|
||||||
|
underlinedTitleValue(canvas, startControl(5),
|
||||||
|
QString::number((world.x() * world.y() * 20 + DefaultWorldTiles / 2) / DefaultWorldTiles * 5) +
|
||||||
|
QLatin1Char('%'),
|
||||||
|
344, y0Mini - 77, 170);
|
||||||
|
underlinedTitleValue(canvas, startControl(6), QString::number(m_startLandMass) + QLatin1Char('%'), 344,
|
||||||
|
y0Mini + 61, 170);
|
||||||
|
} else if (m_page == Page::EditMap) {
|
||||||
|
const QString s = phraseToQtFormat(phrases2.lookup(QStringLiteral("MAPPROP")))
|
||||||
|
.arg((m_mapLandTiles * 100 + 556) / 1112) // 1112 is typical for a world with 100% size and default land mass
|
||||||
|
.arg(m_mapStartPositions);
|
||||||
|
risedTextOut(canvas, x0Mini - biColorTextWidth(canvas, s) / 2, y0Mini + 61, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto frameButtonUp = [&](const QWidget *button, int height) {
|
||||||
|
if (button->isVisible())
|
||||||
|
rframe(canvas, button->x() - 1, button->y() - 1, button->x() + 12, button->y() + height, shade, light);
|
||||||
|
};
|
||||||
|
if (ui->startBtn->isVisible())
|
||||||
|
btnFrame(canvas, ui->startBtn->geometry(), *MainTexture);
|
||||||
|
frameButtonUp(ui->up2Btn, 24);
|
||||||
|
frameButtonUp(ui->up1Btn, 24);
|
||||||
|
frameButtonUp(ui->autoDiffUpBtn, 24);
|
||||||
|
frameButtonUp(ui->autoEnemyUpBtn, 24);
|
||||||
|
frameButtonUp(ui->customizeBtn, 12);
|
||||||
|
if (ui->list->isVisible())
|
||||||
|
editFrame(canvas, ui->list->geometry(), *MainTexture);
|
||||||
|
if (ui->renameBtn->isVisible())
|
||||||
|
btnFrame(canvas, ui->renameBtn->geometry(), *MainTexture);
|
||||||
|
if (ui->deleteBtn->isVisible())
|
||||||
|
btnFrame(canvas, ui->deleteBtn->geometry(), *MainTexture);
|
||||||
|
if (m_page == Page::Load)
|
||||||
|
btnFrame(canvas, ui->replayBtn->geometry(), *MainTexture);
|
||||||
|
|
||||||
|
if (m_page != Page::Main && m_page != Page::NoLoad) {
|
||||||
|
const int xMini = x0Mini - m_miniMap.size.x();
|
||||||
|
const int yMini = y0Mini - m_miniMap.size.y() / 2;
|
||||||
|
frame(canvas, xMini, yMini, xMini + 3 + m_miniMap.size.x() * 2, yMini + 3 + m_miniMap.size.y(), light, shade);
|
||||||
|
frame(canvas, xMini + 1, yMini + 1, xMini + 2 + m_miniMap.size.x() * 2, yMini + 2 + m_miniMap.size.y(), shade,
|
||||||
|
light);
|
||||||
|
|
||||||
|
QString s;
|
||||||
|
if (m_miniMap.mode == MiniMap::Mode::Picture) {
|
||||||
|
canvas.draw(xMini + 2, yMini + 2, m_miniMap.bitmap.image());
|
||||||
|
if (m_page == Page::StartRandom)
|
||||||
|
s = phrases.lookup(QStringLiteral("RANMAP"));
|
||||||
|
} else if (m_miniMap.mode == MiniMap::Mode::MultiPlayer) {
|
||||||
|
s = phrases.lookup(QStringLiteral("MPMAP"));
|
||||||
|
} else if (m_page == Page::StartMap) {
|
||||||
|
s = QFileInfo(m_mapFileName).completeBaseName();
|
||||||
|
} else if (m_page == Page::EditMap) {
|
||||||
|
if (ui->list->currentItem())
|
||||||
|
s = ui->list->currentItem()->text();
|
||||||
|
}
|
||||||
|
if (!s.isEmpty())
|
||||||
|
risedTextOut(canvas, x0Mini + 2 - biColorTextWidth(canvas, s) / 2, y0Mini - 8, s);
|
||||||
|
}
|
||||||
|
canvas.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Cevo
|
||||||
+1335
File diff suppressed because it is too large.
Load diff
+173
@@ -0,0 +1,173 @@
|
|||||||
|
// This file is part of c-evo-evo.
|
||||||
|
//
|
||||||
|
// This software is governed by the CeCILL license under French law and
|
||||||
|
// abiding by the rules of distribution of free software. You can use,
|
||||||
|
// modify and/or redistribute the software under the terms of the CeCILL
|
||||||
|
// license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
|
// "http://www.cecill.info".
|
||||||
|
//
|
||||||
|
// As a counterpart to the access to the source code and rights to copy,
|
||||||
|
// modify and redistribute granted by the license, users are provided only
|
||||||
|
// with a limited warranty and the software's author, the holder of the
|
||||||
|
// economic rights, and the successive licensors have only limited
|
||||||
|
// liability.
|
||||||
|
//
|
||||||
|
// In this respect, the user's attention is drawn to the risks associated
|
||||||
|
// with loading, using, modifying and/or developing or reproducing the
|
||||||
|
// software by the user in light of its specific status of free software,
|
||||||
|
// that may mean that it is complicated to manipulate, and that also
|
||||||
|
// therefore means that it is reserved for developers and experienced
|
||||||
|
// professionals having in-depth computer knowledge. Users are therefore
|
||||||
|
// encouraged to load and test the software's suitability as regards their
|
||||||
|
// requirements in conditions enabling the security of their systems and/or
|
||||||
|
// data to be ensured and, more generally, to use and operate it in the
|
||||||
|
// same conditions as regards security.
|
||||||
|
//
|
||||||
|
// The fact that you are presently reading this means that you have had
|
||||||
|
// knowledge of the CeCILL license and that you accept its terms.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Back.h"
|
||||||
|
#include "Brain.h"
|
||||||
|
#include "Cevo/CevoBaseWin.h"
|
||||||
|
#include "Cevo/FileList.h"
|
||||||
|
#include "Languages.h"
|
||||||
|
#include "MiniMap.h"
|
||||||
|
|
||||||
|
#include <QPoint>
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class QMenu;
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
namespace Ui {
|
||||||
|
class StartDlg;
|
||||||
|
}
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Cevo {
|
||||||
|
|
||||||
|
class ButtonC;
|
||||||
|
class DirectDlg;
|
||||||
|
|
||||||
|
// Equivalent of Start.pas's TStartDlg: the start screen - tabs for the main
|
||||||
|
// menu, the map editor, new games and earlier games, with the player slot
|
||||||
|
// setup, difficulty/world options, the map preview and the Start button.
|
||||||
|
class StartDlg : public BufferedDrawDlg {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
enum class Page { StartRandom, StartMap, NoLoad, Load, EditRandom, EditMap, Main };
|
||||||
|
enum class Tab { Main, Map, NewGame, PreviousGame };
|
||||||
|
enum class MainAction { Config, Manual, Credits, AIDev, Web, None };
|
||||||
|
|
||||||
|
explicit StartDlg(DirectDlg *direct, QWidget *parent = nullptr);
|
||||||
|
~StartDlg() override;
|
||||||
|
|
||||||
|
Background *background() const { return m_background.get(); }
|
||||||
|
Languages &languages() { return m_languages; }
|
||||||
|
|
||||||
|
// Called by DirectDlg when a game ends or a map was edited.
|
||||||
|
void updateFormerGames();
|
||||||
|
void updateMaps(bool selectLastMap);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void offscreenPaint() override;
|
||||||
|
void mousePressEvent(QMouseEvent *event) override;
|
||||||
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||||
|
void mouseMoveEvent(QMouseEvent *event) override;
|
||||||
|
void keyPressEvent(QKeyEvent *event) override;
|
||||||
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct PlayerSlot {
|
||||||
|
ButtonC *diffUpBtn = nullptr;
|
||||||
|
ButtonC *diffDownBtn = nullptr;
|
||||||
|
ButtonC *multiBtn = nullptr;
|
||||||
|
bool offerMultiple = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Persisted settings (Registry in the original, QSettings here).
|
||||||
|
void loadConfig();
|
||||||
|
void saveConfig();
|
||||||
|
void loadLanguages();
|
||||||
|
void loadAiBrainsPictures();
|
||||||
|
void updateInterface();
|
||||||
|
void showSettings();
|
||||||
|
void updateMusic();
|
||||||
|
|
||||||
|
void drawAction(int y, int iconIndex, const QString &headerItem, const QString &textItem);
|
||||||
|
void paintInfo();
|
||||||
|
void changePage(Page newPage);
|
||||||
|
void changeTab(Tab newTab);
|
||||||
|
void smartInvalidate(int x0, int y0, int x1, int y1, bool invalidateTab0 = false);
|
||||||
|
void applyPageVisibility();
|
||||||
|
void unlistBackupFile(QString fileName);
|
||||||
|
// The list shown on the current tab.
|
||||||
|
FileList ¤tFileList();
|
||||||
|
FileItem *selectedFileItem();
|
||||||
|
|
||||||
|
void initPopup(int playerIndex);
|
||||||
|
void offerBrain(QMenu &menu, Brain *brain, int fixedLines);
|
||||||
|
void brainClicked(int brainIndex);
|
||||||
|
|
||||||
|
void startClicked();
|
||||||
|
void listClicked();
|
||||||
|
void listSelectionChanged();
|
||||||
|
void renameClicked();
|
||||||
|
void deleteClicked();
|
||||||
|
void diffClicked(QWidget *sender);
|
||||||
|
void multiClicked(QWidget *sender);
|
||||||
|
void up1Clicked();
|
||||||
|
void down1Clicked();
|
||||||
|
void up2Clicked();
|
||||||
|
void down2Clicked();
|
||||||
|
void customizeClicked();
|
||||||
|
void autoDiffUpClicked();
|
||||||
|
void autoDiffDownClicked();
|
||||||
|
void autoEnemyUpClicked();
|
||||||
|
void autoEnemyDownClicked();
|
||||||
|
void replayClicked();
|
||||||
|
|
||||||
|
int m_worldSize = 0;
|
||||||
|
int m_startLandMass = 0;
|
||||||
|
int m_maxTurn = 800;
|
||||||
|
int m_autoEnemies = 8;
|
||||||
|
int m_autoDiff = 1;
|
||||||
|
int m_multiControl = 0;
|
||||||
|
Page m_page = Page::Main;
|
||||||
|
Tab m_showTab = Tab::NewGame;
|
||||||
|
Tab m_tab = Tab::NewGame;
|
||||||
|
int m_diff0 = 2;
|
||||||
|
Brain *m_brainDefault = nullptr;
|
||||||
|
int m_mapLandTiles = 0;
|
||||||
|
int m_mapStartPositions = 0;
|
||||||
|
int m_loadTurn = 0;
|
||||||
|
int m_lastTurn = 0; // last turn of the selected former game
|
||||||
|
int m_slotAvailable = -1;
|
||||||
|
int m_playerPopupIndex = -1; // slot concerned by the brain context menu
|
||||||
|
std::array<int, 4> m_listIndex{};
|
||||||
|
QString m_mapFileName;
|
||||||
|
FileList m_formerGames;
|
||||||
|
FileList m_maps;
|
||||||
|
std::array<PlayerSlot, 9> m_playerSlots;
|
||||||
|
std::vector<MainAction> m_actionsOffered;
|
||||||
|
MainAction m_selectedAction = MainAction::None;
|
||||||
|
bool m_turnValid = false;
|
||||||
|
bool m_tracking = false;
|
||||||
|
QString m_defaultAI;
|
||||||
|
QString m_lastGame;
|
||||||
|
QString m_lastMap;
|
||||||
|
|
||||||
|
DirectDlg *m_direct;
|
||||||
|
std::unique_ptr<Background> m_background;
|
||||||
|
Dpi::Bitmap m_emptyPicture;
|
||||||
|
MiniMap m_miniMap;
|
||||||
|
Languages m_languages;
|
||||||
|
Ui::StartDlg *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Cevo
|
||||||
Vendored
+143
@@ -0,0 +1,143 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
This file is part of c-evo-evo.
|
||||||
|
|
||||||
|
This software is governed by the CeCILL license under French law and
|
||||||
|
abiding by the rules of distribution of free software. You can use,
|
||||||
|
modify and/or redistribute the software under the terms of the CeCILL
|
||||||
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
|
"http://www.cecill.info".
|
||||||
|
|
||||||
|
As a counterpart to the access to the source code and rights to copy,
|
||||||
|
modify and redistribute granted by the license, users are provided only
|
||||||
|
with a limited warranty and the software's author, the holder of the
|
||||||
|
economic rights, and the successive licensors have only limited
|
||||||
|
liability.
|
||||||
|
|
||||||
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
|
software by the user in light of its specific status of free software,
|
||||||
|
that may mean that it is complicated to manipulate, and that also
|
||||||
|
therefore means that it is reserved for developers and experienced
|
||||||
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
|
encouraged to load and test the software's suitability as regards their
|
||||||
|
systems and/or data to be ensured and, more generally, to use and operate
|
||||||
|
it in the same conditions as regards security.
|
||||||
|
|
||||||
|
The fact that you are presently reading this means that you have had
|
||||||
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
|
-->
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>StartDlg</class>
|
||||||
|
<widget class="QWidget" name="StartDlg">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>556</width>
|
||||||
|
<height>326</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>C-evo</string>
|
||||||
|
</property>
|
||||||
|
<widget class="Cevo::ButtonA" name="startBtn">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect><x>389</x><y>286</y><width>100</width><height>25</height></rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="Cevo::ButtonC" name="down1Btn">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect><x>522</x><y>111</y><width>12</width><height>12</height></rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="Cevo::ButtonC" name="up1Btn">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect><x>522</x><y>99</y><width>12</width><height>12</height></rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="Cevo::ButtonB" name="renameBtn">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect><x>412</x><y>98</y><width>25</width><height>25</height></rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="Cevo::ButtonB" name="deleteBtn">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect><x>441</x><y>98</y><width>25</width><height>25</height></rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="Cevo::ButtonC" name="down2Btn">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect><x>522</x><y>249</y><width>12</width><height>12</height></rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="Cevo::ButtonC" name="up2Btn">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect><x>522</x><y>237</y><width>12</width><height>12</height></rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="Cevo::ButtonB" name="quitBtn">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect><x>530</x><y>7</y><width>25</width><height>25</height></rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="Cevo::ButtonC" name="customizeBtn">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect><x>120</x><y>302</y><width>12</width><height>12</height></rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="Cevo::ButtonC" name="autoDiffUpBtn">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect><x>280</x><y>237</y><width>12</width><height>12</height></rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="Cevo::ButtonC" name="autoDiffDownBtn">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect><x>280</x><y>249</y><width>12</width><height>12</height></rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="Cevo::ButtonC" name="autoEnemyUpBtn">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect><x>206</x><y>152</y><width>12</width><height>12</height></rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="Cevo::ButtonC" name="autoEnemyDownBtn">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect><x>206</x><y>164</y><width>12</width><height>12</height></rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="Cevo::ButtonB" name="replayBtn">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect><x>352</x><y>286</y><width>25</width><height>25</height></rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="Cevo::ListBoxEx" name="list">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect><x>45</x><y>64</y><width>266</width><height>238</height></rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>Cevo::ButtonA</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>Cevo/CevoButtonA.h</header>
|
||||||
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>Cevo::ButtonB</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>Cevo/CevoButtonB.h</header>
|
||||||
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>Cevo::ButtonC</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>Cevo/CevoButtonC.h</header>
|
||||||
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>Cevo::ListBoxEx</class>
|
||||||
|
<extends>QListWidget</extends>
|
||||||
|
<header>Cevo/CevoListBoxEx.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
|
</ui>
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
// This file is part of c-evo-evo.
|
||||||
|
//
|
||||||
|
// This software is governed by the CeCILL license under French law and
|
||||||
|
// abiding by the rules of distribution of free software. You can use,
|
||||||
|
// modify and/or redistribute the software under the terms of the CeCILL
|
||||||
|
// license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
|
// "http://www.cecill.info".
|
||||||
|
//
|
||||||
|
// As a counterpart to the access to the source code and rights to copy,
|
||||||
|
// modify and redistribute granted by the license, users are provided only
|
||||||
|
// with a limited warranty and the software's author, the holder of the
|
||||||
|
// economic rights, and the successive licensors have only limited
|
||||||
|
// liability.
|
||||||
|
//
|
||||||
|
// In this respect, the user's attention is drawn to the risks associated
|
||||||
|
// with loading, using, modifying and/or developing or reproducing the
|
||||||
|
// software by the user in light of its specific status of free software,
|
||||||
|
// that may mean that it is complicated to manipulate, and that also
|
||||||
|
// therefore means that it is reserved for developers and experienced
|
||||||
|
// professionals having in-depth computer knowledge. Users are therefore
|
||||||
|
// encouraged to load and test the software's suitability as regards their
|
||||||
|
// requirements in conditions enabling the security of their systems and/or
|
||||||
|
// data to be ensured and, more generally, to use and operate it in the
|
||||||
|
// same conditions as regards security.
|
||||||
|
//
|
||||||
|
// The fact that you are presently reading this means that you have had
|
||||||
|
// knowledge of the CeCILL license and that you accept its terms.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Start.pas's implementation-section constants, shared by Start.cpp and
|
||||||
|
// Start.Paint.cpp.
|
||||||
|
|
||||||
|
#include <QPoint>
|
||||||
|
|
||||||
|
namespace Cevo {
|
||||||
|
namespace StartLayout {
|
||||||
|
|
||||||
|
// predefined world sizes
|
||||||
|
// attention: lx * ly + 1 must be prime!
|
||||||
|
constexpr int MaxWorldSize = 6;
|
||||||
|
constexpr QPoint WorldSizes[MaxWorldSize] = { QPoint(30, 46), QPoint(40, 52), QPoint(50, 60),
|
||||||
|
QPoint(60, 70), QPoint(75, 82), QPoint(100, 96) };
|
||||||
|
constexpr int DefaultWorldTiles = 4150;
|
||||||
|
constexpr int DefaultWorldSize = 3;
|
||||||
|
constexpr int DefaultLandMass = 30;
|
||||||
|
|
||||||
|
constexpr int nPlOffered = 9;
|
||||||
|
constexpr int yMain = 14;
|
||||||
|
constexpr int xActionIcon = 55;
|
||||||
|
constexpr int xAction = 111;
|
||||||
|
constexpr int yAction = 60;
|
||||||
|
constexpr int ActionPitch = 56;
|
||||||
|
constexpr int ActionSideBorder = 24;
|
||||||
|
constexpr int ActionBottomBorder = 10;
|
||||||
|
constexpr int x0Mini = 437;
|
||||||
|
constexpr int y0Mini = 178;
|
||||||
|
constexpr int xTurnSlider = 346;
|
||||||
|
constexpr int yTurnSlider = 262;
|
||||||
|
constexpr int wTurnSlider = 168;
|
||||||
|
constexpr int yLogo = 74;
|
||||||
|
constexpr int xDefault = 234;
|
||||||
|
constexpr int yDefault = 148;
|
||||||
|
constexpr int x0Brain = 146;
|
||||||
|
constexpr int y0Brain = 148;
|
||||||
|
constexpr int dxBrain = 104;
|
||||||
|
constexpr int dyBrain = 80;
|
||||||
|
constexpr int xBrain[nPlOffered] = { x0Brain, x0Brain, x0Brain + dxBrain, x0Brain + dxBrain, x0Brain + dxBrain,
|
||||||
|
x0Brain, x0Brain - dxBrain, x0Brain - dxBrain, x0Brain - dxBrain };
|
||||||
|
constexpr int yBrain[nPlOffered] = { y0Brain, y0Brain - dyBrain, y0Brain - dyBrain, y0Brain, y0Brain + dyBrain,
|
||||||
|
y0Brain + dyBrain, y0Brain + dyBrain, y0Brain, y0Brain - dyBrain };
|
||||||
|
constexpr int TabOffset = -115;
|
||||||
|
constexpr int TabSize = 159;
|
||||||
|
constexpr int TabHeight = 40;
|
||||||
|
|
||||||
|
// Bit set of the player slots offered for n (1-based) players.
|
||||||
|
constexpr int InitAlive[15] = { 1, 1 + 2, 1 + 2 + 32, 1 + 2 + 8 + 128, 1 + 2 + 8 + 32 + 128,
|
||||||
|
1 + 2 + 8 + 16 + 64 + 128, 1 + 2 + 4 + 16 + 32 + 64 + 256, 511 - 32, 511,
|
||||||
|
511 - 32, 511, 511 - 32, 511, 511 - 32, 511 };
|
||||||
|
// Multi-controlled slots for n = 10..15 players.
|
||||||
|
constexpr int InitMulti[6] = { 256, 256, 256 + 128, 256 + 128, 256 + 128 + 64, 256 + 128 + 64 };
|
||||||
|
|
||||||
|
constexpr int PlayerAutoDiff[5] = { 1, 1, 2, 2, 3 };
|
||||||
|
constexpr int EnemyAutoDiff[5] = { 4, 3, 2, 1, 1 };
|
||||||
|
|
||||||
|
} // namespace StartLayout
|
||||||
|
} // namespace Cevo
|
||||||
@@ -26,9 +26,14 @@
|
|||||||
// The fact that you are presently reading this means that you have had
|
// The fact that you are presently reading this means that you have had
|
||||||
// knowledge of the CeCILL license and that you accept its terms.
|
// knowledge of the CeCILL license and that you accept its terms.
|
||||||
|
|
||||||
|
#include "game/Direct.h"
|
||||||
|
#include "game/GameServer.h"
|
||||||
|
#include <QDebug>
|
||||||
#include "game/Global.h"
|
#include "game/Global.h"
|
||||||
|
#include "game/Start.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QTimer>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
|
|
||||||
@@ -38,6 +43,7 @@ int main(int argc, char *argv[])
|
|||||||
QCoreApplication::setOrganizationName(QStringLiteral("c-evo-evo"));
|
QCoreApplication::setOrganizationName(QStringLiteral("c-evo-evo"));
|
||||||
QCoreApplication::setApplicationName(QStringLiteral("c-evo-evo"));
|
QCoreApplication::setApplicationName(QStringLiteral("c-evo-evo"));
|
||||||
Cevo::initDirectories(QCoreApplication::arguments());
|
Cevo::initDirectories(QCoreApplication::arguments());
|
||||||
|
Cevo::loadConfig();
|
||||||
Cevo::loadAssets();
|
Cevo::loadAssets();
|
||||||
|
|
||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
@@ -49,5 +55,15 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DirectDlg (created first, as in the original) is the main window; it
|
||||||
|
// shows the start screen once the game engine is up.
|
||||||
|
Cevo::DirectDlg direct;
|
||||||
|
Cevo::StartDlg start(&direct);
|
||||||
|
direct.setStartDlg(&start);
|
||||||
|
direct.show();
|
||||||
|
QTimer::singleShot(2000, [] { for (int i = 0; i < Cevo::GameServer::brains.count(); ++i) qWarning() << "BRAIN" << i << Cevo::GameServer::brains[i].fileName << Cevo::GameServer::brains[i].name() << int(Cevo::GameServer::brains[i].kind) << Cevo::GameServer::brains[i].beginner; }); // TEMP-GRAB
|
||||||
|
QTimer::singleShot(2500, [&start] { start.grab().save(QStringLiteral("/tmp/start-shot.png")); }); // TEMP-GRAB
|
||||||
|
QTimer::singleShot(3000, [] { QCoreApplication::quit(); }); // TEMP-GRAB
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
@@ -58,9 +58,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// TGraphicSet equivalent: a sprite sheet (data) with its transparency mask
|
// TGraphicSet equivalent: a sprite sheet (data) with its transparency mask
|
||||||
// (mask), plus a set of named item rectangles. Persisted as XML, though not
|
// (mask), plus a set of named item rectangles. Persisted as XML in the
|
||||||
// in the same node layout as the original (custom WriteString/WriteInteger
|
// original .grs layout (each item field a child element).
|
||||||
// helper), so files are not binary-compatible with the original .grs format.
|
|
||||||
class GraphicSet {
|
class GraphicSet {
|
||||||
public:
|
public:
|
||||||
GraphicSet() = default;
|
GraphicSet() = default;
|
||||||
|
|||||||
@@ -250,5 +250,7 @@ void paintLogo(Dpi::Canvas &canvas, int x, int y, QColor lightColor, QColor shad
|
|||||||
// ScreenTools.pas's InitOrnament(): recolours the ornament sprite to the
|
// ScreenTools.pas's InitOrnament(): recolours the ornament sprite to the
|
||||||
// current texture's bevel colours (once).
|
// current texture's bevel colours (once).
|
||||||
void initOrnament();
|
void initOrnament();
|
||||||
|
// ScreenTools.pas's DarkenImage(): subtracts `change` from every colour channel (clamped at 0).
|
||||||
|
void darkenImage(Dpi::Bitmap &bitmap, int change);
|
||||||
|
|
||||||
} // namespace Cevo
|
} // namespace Cevo
|
||||||
@@ -59,7 +59,9 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QImage *m_image = nullptr;
|
QImage *m_image = nullptr;
|
||||||
int m_x = 0;
|
int m_baseX = 0; // position of the pointer's origin in the image
|
||||||
|
int m_baseY = 0;
|
||||||
|
int m_x = 0; // current position, relative to the origin
|
||||||
int m_y = 0;
|
int m_y = 0;
|
||||||
int m_width = 0;
|
int m_width = 0;
|
||||||
int m_height = 0;
|
int m_height = 0;
|
||||||
|
|||||||
@@ -86,14 +86,40 @@ void GraphicSet::loadFromFile(const QString &fileName)
|
|||||||
QXmlStreamReader xml(&file);
|
QXmlStreamReader xml(&file);
|
||||||
while (!xml.atEnd()) {
|
while (!xml.atEnd()) {
|
||||||
xml.readNext();
|
xml.readNext();
|
||||||
if (xml.isStartElement() && xml.name() == QLatin1String("Item")) {
|
if (!xml.isStartElement() || xml.name() != QLatin1String("Item"))
|
||||||
const QXmlStreamAttributes attrs = xml.attributes();
|
continue;
|
||||||
GraphicSetItem *newItem = addNew(attrs.value("Name").toString());
|
// The original format stores each field as a child element (<Name>, <Left>, ...);
|
||||||
newItem->left = attrs.value("Left").toInt();
|
// attributes are accepted too.
|
||||||
newItem->top = attrs.value("Top").toInt();
|
const QXmlStreamAttributes attrs = xml.attributes();
|
||||||
newItem->width = attrs.value("Width").toInt();
|
QString name = attrs.value("Name").toString();
|
||||||
newItem->height = attrs.value("Height").toInt();
|
int left = attrs.value("Left").toInt();
|
||||||
|
int top = attrs.value("Top").toInt();
|
||||||
|
int width = attrs.value("Width").toInt();
|
||||||
|
int height = attrs.value("Height").toInt();
|
||||||
|
while (!xml.atEnd()) {
|
||||||
|
xml.readNext();
|
||||||
|
if (xml.isEndElement() && xml.name() == QLatin1String("Item"))
|
||||||
|
break;
|
||||||
|
if (!xml.isStartElement())
|
||||||
|
continue;
|
||||||
|
const QString field = xml.name().toString();
|
||||||
|
const QString text = xml.readElementText();
|
||||||
|
if (field == QLatin1String("Name"))
|
||||||
|
name = text;
|
||||||
|
else if (field == QLatin1String("Left"))
|
||||||
|
left = text.toInt();
|
||||||
|
else if (field == QLatin1String("Top"))
|
||||||
|
top = text.toInt();
|
||||||
|
else if (field == QLatin1String("Width"))
|
||||||
|
width = text.toInt();
|
||||||
|
else if (field == QLatin1String("Height"))
|
||||||
|
height = text.toInt();
|
||||||
}
|
}
|
||||||
|
GraphicSetItem *newItem = addNew(name);
|
||||||
|
newItem->left = left;
|
||||||
|
newItem->top = top;
|
||||||
|
newItem->width = width;
|
||||||
|
newItem->height = height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,11 +136,11 @@ void GraphicSet::saveToFile(const QString &fileName) const
|
|||||||
xml.writeStartElement(QLatin1String("Items"));
|
xml.writeStartElement(QLatin1String("Items"));
|
||||||
for (GraphicSetItem *item : m_items) {
|
for (GraphicSetItem *item : m_items) {
|
||||||
xml.writeStartElement(QLatin1String("Item"));
|
xml.writeStartElement(QLatin1String("Item"));
|
||||||
xml.writeAttribute(QLatin1String("Name"), item->name);
|
xml.writeTextElement(QLatin1String("Name"), item->name);
|
||||||
xml.writeAttribute(QLatin1String("Left"), QString::number(item->left));
|
xml.writeTextElement(QLatin1String("Left"), QString::number(item->left));
|
||||||
xml.writeAttribute(QLatin1String("Top"), QString::number(item->top));
|
xml.writeTextElement(QLatin1String("Top"), QString::number(item->top));
|
||||||
xml.writeAttribute(QLatin1String("Width"), QString::number(item->width));
|
xml.writeTextElement(QLatin1String("Width"), QString::number(item->width));
|
||||||
xml.writeAttribute(QLatin1String("Height"), QString::number(item->height));
|
xml.writeTextElement(QLatin1String("Height"), QString::number(item->height));
|
||||||
xml.writeEndElement();
|
xml.writeEndElement();
|
||||||
}
|
}
|
||||||
xml.writeEndElement();
|
xml.writeEndElement();
|
||||||
|
|||||||
@@ -956,6 +956,19 @@ void paintLogo(Dpi::Canvas &canvas, int x, int y, QColor lightColor, QColor shad
|
|||||||
canvas.copyRect(QRect(x, y, logo->width, logo->height), drawBuffer.canvas(), QRect(0, 0, logo->width, logo->height));
|
canvas.copyRect(QRect(x, y, logo->width, logo->height), drawBuffer.canvas(), QRect(0, 0, logo->width, logo->height));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void darkenImage(Dpi::Bitmap &bitmap, int change)
|
||||||
|
{
|
||||||
|
QImage &image = bitmap.image();
|
||||||
|
for (int y = 0; y < image.height(); ++y) {
|
||||||
|
for (int x = 0; x < image.width(); ++x) {
|
||||||
|
const QRgb c = image.pixel(x, y);
|
||||||
|
image.setPixel(x, y,
|
||||||
|
qRgba(std::max(qRed(c) - change, 0), std::max(qGreen(c) - change, 0),
|
||||||
|
std::max(qBlue(c) - change, 0), qAlpha(c)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
bool ornamentInitialized = false;
|
bool ornamentInitialized = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,13 +31,12 @@
|
|||||||
namespace Dpi {
|
namespace Dpi {
|
||||||
|
|
||||||
PixelPointer::PixelPointer(QImage *image, int baseX, int baseY)
|
PixelPointer::PixelPointer(QImage *image, int baseX, int baseY)
|
||||||
: m_image(image)
|
: m_image(image), m_baseX(baseX), m_baseY(baseY)
|
||||||
{
|
{
|
||||||
if (m_image) {
|
if (m_image) {
|
||||||
m_width = m_image->width();
|
m_width = m_image->width();
|
||||||
m_height = m_image->height();
|
m_height = m_image->height();
|
||||||
}
|
}
|
||||||
setXY(baseX, baseY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PixelPointer::setXY(int x, int y)
|
void PixelPointer::setXY(int x, int y)
|
||||||
@@ -64,30 +63,34 @@ void PixelPointer::previousPixel()
|
|||||||
void PixelPointer::nextLine()
|
void PixelPointer::nextLine()
|
||||||
{
|
{
|
||||||
++m_y;
|
++m_y;
|
||||||
|
m_x = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PixelPointer::previousLine()
|
void PixelPointer::previousLine()
|
||||||
{
|
{
|
||||||
--m_y;
|
--m_y;
|
||||||
|
m_x = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PixelPointer::posValid() const
|
bool PixelPointer::posValid() const
|
||||||
{
|
{
|
||||||
return m_image && m_x >= 0 && m_x < m_width && m_y >= 0 && m_y < m_height;
|
const int x = m_baseX + m_x;
|
||||||
|
const int y = m_baseY + m_y;
|
||||||
|
return m_image && x >= 0 && x < m_width && y >= 0 && y < m_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRgb PixelPointer::pixelARGB() const
|
QRgb PixelPointer::pixelARGB() const
|
||||||
{
|
{
|
||||||
if (!posValid())
|
if (!posValid())
|
||||||
return 0;
|
return 0;
|
||||||
return reinterpret_cast<const QRgb *>(m_image->constScanLine(m_y))[m_x];
|
return reinterpret_cast<const QRgb *>(m_image->constScanLine(m_baseY + m_y))[m_baseX + m_x];
|
||||||
}
|
}
|
||||||
|
|
||||||
void PixelPointer::setPixelARGB(QRgb value)
|
void PixelPointer::setPixelARGB(QRgb value)
|
||||||
{
|
{
|
||||||
if (!posValid())
|
if (!posValid())
|
||||||
return;
|
return;
|
||||||
reinterpret_cast<QRgb *>(m_image->scanLine(m_y))[m_x] = value;
|
reinterpret_cast<QRgb *>(m_image->scanLine(m_baseY + m_y))[m_baseX + m_x] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRgb PixelPointer::pixelRGB() const
|
QRgb PixelPointer::pixelRGB() const
|
||||||
|
|||||||
Reference in new issue
Block a user