added cityscreen with deps
This commit is contained in:
1 parent
29f47be49b
commit
6773e620cf
6 files changed
+1931
No files matched your search
@@ -157,6 +157,9 @@ set(PROJECT_SOURCES
|
||||
game/localplayer/MessgEx.cpp
|
||||
game/localplayer/MessgEx.h
|
||||
game/localplayer/MessgEx.ui
|
||||
game/localplayer/CityScreen.cpp
|
||||
game/localplayer/CityScreen.h
|
||||
game/localplayer/CityScreen.ui
|
||||
${TS_FILES}
|
||||
)
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,128 @@
|
||||
// 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 "Cevo/CevoBaseWin.h"
|
||||
#include "Cevo/CevoTexture.h"
|
||||
#include "Cevo/Protocol.h"
|
||||
#include "IsoEngine.h"
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
class CityDlg;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Cevo {
|
||||
namespace CityScreen {
|
||||
|
||||
enum class CityCloseAction { None, RestoreFocus, StepFocus };
|
||||
enum class SmallMapMode { SupportedUnits, Improvements };
|
||||
|
||||
// TCityDlg equivalent: the city management screen (build-order, resource
|
||||
// tiles, happiness/food/production/trade bars, small improvement map).
|
||||
class CityDlg : public BufferedDrawDlg {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CityDlg(QWidget *parent = nullptr);
|
||||
~CityDlg() override;
|
||||
|
||||
void offscreenPaint() override;
|
||||
// Equivalent of ShowNewContent(NewMode, Loc, ShowEvent) - Loc may be an
|
||||
// own city (MyMap[Loc] has fOwned) or an enemy city.
|
||||
void showNewContent(WindowMode newMode, int loc, std::uint32_t showEvent);
|
||||
void reset();
|
||||
void checkAge();
|
||||
|
||||
int restoreUnFocus = -1;
|
||||
CityCloseAction closeAction = CityCloseAction::None;
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
private:
|
||||
void initSmallCityMap();
|
||||
void initZoomCityMap();
|
||||
void chooseProject();
|
||||
void changeCity(int d);
|
||||
void changeResourceWeights(int resourceWeights);
|
||||
void onPlaySound();
|
||||
void fillBar(int x, int y, int pos, int growth, int max, int kind, bool indicateComplete);
|
||||
void paintResources(int x, int y, int loc, bool add4Happy);
|
||||
void buyClick();
|
||||
|
||||
TCity c{};
|
||||
TCityReportNew report{};
|
||||
int cOwner = 0;
|
||||
int cGov = 0;
|
||||
int emix = -1; // enemy model index of produced unit
|
||||
int cix = -1;
|
||||
int cLoc = 0;
|
||||
SmallMapMode smallMapMode = SmallMapMode::Improvements;
|
||||
int zoomArea = 1;
|
||||
int page = 0;
|
||||
int pageCount = 0;
|
||||
int blinkTime = 0;
|
||||
int openSoundEvent = -1;
|
||||
int sizeClass = 0;
|
||||
int agePrepared = -2;
|
||||
int optimizeCixTileChange = -1;
|
||||
std::uint32_t optimizeTilesBeforeChange = 0;
|
||||
std::uint32_t happened = 0;
|
||||
std::array<int, 16> imix{};
|
||||
TCityAreaInfo cityAreaInfo{};
|
||||
std::unique_ptr<IsoEngine::IsoMap> areaMap;
|
||||
std::unique_ptr<IsoEngine::IsoMap> noMap;
|
||||
Dpi::Bitmap cityMapTemplate;
|
||||
Dpi::Bitmap smallCityMapTemplate;
|
||||
Dpi::Bitmap back;
|
||||
Dpi::Bitmap smallCityMap;
|
||||
Dpi::Bitmap zoomCityMap;
|
||||
Dpi::Bitmap tmpl;
|
||||
bool isPort = false;
|
||||
bool prodHint = false;
|
||||
bool allowChange = false;
|
||||
Texture redTex;
|
||||
Texture barTex;
|
||||
QTimer *timer1;
|
||||
|
||||
Ui::CityDlg *ui;
|
||||
};
|
||||
|
||||
} // namespace CityScreen
|
||||
} // namespace Cevo
|
||||
Vendored
+231
@@ -0,0 +1,231 @@
|
||||
<?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
|
||||
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.
|
||||
-->
|
||||
<ui version="4.0">
|
||||
<class>CityDlg</class>
|
||||
<widget class="QWidget" name="CityDlg">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>640</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>C-evo</string>
|
||||
</property>
|
||||
<widget class="Cevo::ButtonA" name="closeBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>335</x>
|
||||
<y>447</y>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::ButtonC" name="prevCityBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>6</y>
|
||||
<width>12</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::ButtonC" name="nextCityBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>18</y>
|
||||
<width>12</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::ButtonC" name="pageUpBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>245</x>
|
||||
<y>390</y>
|
||||
<width>12</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::ButtonC" name="pageDownBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>245</x>
|
||||
<y>402</y>
|
||||
<width>12</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::ButtonC" name="buyBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>495</x>
|
||||
<y>317</y>
|
||||
<width>12</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::Area" name="projectArea">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>335</x>
|
||||
<y>280</y>
|
||||
<width>56</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::Area" name="primacyArea">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>11</x>
|
||||
<y>271</y>
|
||||
<width>57</width>
|
||||
<height>57</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::Area" name="imp2Area">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>192</x>
|
||||
<y>352</y>
|
||||
<width>56</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::Area" name="imp4Area">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>408</y>
|
||||
<width>56</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::Area" name="imp0Area">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>48</x>
|
||||
<y>352</y>
|
||||
<width>56</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::Area" name="imp3Area">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>48</x>
|
||||
<y>408</y>
|
||||
<width>56</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::Area" name="imp5Area">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>192</x>
|
||||
<y>408</y>
|
||||
<width>56</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::Area" name="imp1Area">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>352</y>
|
||||
<width>56</width>
|
||||
<height>40</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::Area" name="pop0Area">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>13</x>
|
||||
<y>49</y>
|
||||
<width>278</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::Area" name="pop1Area">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>303</x>
|
||||
<y>30</y>
|
||||
<width>82</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Cevo::Area" name="supportArea">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>271</x>
|
||||
<y>415</y>
|
||||
<width>64</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Cevo::ButtonA</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>Cevo/CevoButtonA.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Cevo::ButtonC</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>Cevo/CevoButtonC.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Cevo::Area</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>Cevo/CevoArea.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
</ui>
|
||||
@@ -29,6 +29,8 @@
|
||||
#include "Term.h"
|
||||
|
||||
#include "Global.h"
|
||||
#include "Help.h"
|
||||
#include "IsoEngine.h"
|
||||
#include "Tribes.h"
|
||||
|
||||
namespace Cevo {
|
||||
@@ -102,9 +104,70 @@ void initMyModel(int mix, bool final)
|
||||
}
|
||||
|
||||
int gameMode = 0;
|
||||
int age = 0;
|
||||
std::array<int, nPl * nMmax> lostArmy{};
|
||||
int nLostArmy = 0;
|
||||
std::function<void()> initAllEnemyModels = [] {};
|
||||
|
||||
const std::array<int, nCityEventPriority> CityEventPriority = {
|
||||
chDisorder, chImprovementLost, chUnitLost, chAllImpsMade,
|
||||
chProduction, chOldWonder, chNoSettlerProd, chPopDecrease,
|
||||
chProductionSabotaged, chNoGrowthWarning, chPollution, chTypeDel,
|
||||
chFounded, chSiege, chAfterCapture, chPopIncrease,
|
||||
};
|
||||
|
||||
const std::array<QString, 16> CityEventSoundItem = {
|
||||
QStringLiteral("CITY_DISORDER"), QStringLiteral(""),
|
||||
QStringLiteral("CITY_POPPLUS"), QStringLiteral("CITY_POPMINUS"),
|
||||
QStringLiteral("CITY_UNITLOST"), QStringLiteral("CITY_IMPLOST"),
|
||||
QStringLiteral("CITY_SABOTAGE"), QStringLiteral("CITY_GROWTHNEEDSIMP"),
|
||||
QStringLiteral("CITY_POLLUTION"), QStringLiteral("CITY_SIEGE"),
|
||||
QStringLiteral("CITY_WONDEREX"), QStringLiteral("CITY_EMDELAY"),
|
||||
QStringLiteral("CITY_FOUNDED"), QStringLiteral("CITY_FOUNDED"),
|
||||
QStringLiteral(""), QStringLiteral("CITY_INVALIDTYPE"),
|
||||
};
|
||||
|
||||
QString cityEventName(int i)
|
||||
{
|
||||
// TODO: needs Phrases/Phrases2 (StringTables.pas not ported) - plain
|
||||
// English fallback descriptions per event index.
|
||||
static const std::array<QString, 16> fallback = {
|
||||
QStringLiteral("Civil disorder"), QStringLiteral("Population grows"),
|
||||
QStringLiteral("Population declines"), QStringLiteral("Unit lost"),
|
||||
QStringLiteral("Improvement lost"), QStringLiteral("Production sabotaged"),
|
||||
QStringLiteral("No growth without aqueduct/sewer"), QStringLiteral("Pollution"),
|
||||
QStringLiteral("City under siege"), QStringLiteral("Wonder obsolete"),
|
||||
QStringLiteral("Settler production delayed"), QStringLiteral("City founded"),
|
||||
QStringLiteral("City founded"), QStringLiteral(""),
|
||||
QStringLiteral("All improvements built"), QStringLiteral(""),
|
||||
};
|
||||
if (i == 14) // chAllImpsMade
|
||||
return fallback[14];
|
||||
if (i >= 0 && i < static_cast<int>(fallback.size()))
|
||||
return fallback[static_cast<std::size_t>(i)];
|
||||
return QString();
|
||||
}
|
||||
|
||||
void helpOnTerrain(int loc, WindowMode newMode)
|
||||
{
|
||||
if (ClientTools::myMap[loc] & fDeadLands) {
|
||||
Help::showNewContent(newMode, Help::LinkCategory::Ter, 3 * 12);
|
||||
} else if ((ClientTools::myMap[loc] & fTerrain) == fForest &&
|
||||
IsoEngine::isJungle(loc / ClientTools::g.lx)) {
|
||||
Help::showNewContent(newMode, Help::LinkCategory::Ter, fJungle + (ClientTools::myMap[loc] >> 5 & 3) * 12);
|
||||
} else {
|
||||
Help::showNewContent(newMode, Help::LinkCategory::Ter,
|
||||
(ClientTools::myMap[loc] & fTerrain) + (ClientTools::myMap[loc] >> 5 & 3) * 12);
|
||||
}
|
||||
}
|
||||
|
||||
std::function<bool(int, bool, int)> mainScreenZoomToCity = [](int, bool, int) { return false; };
|
||||
std::function<void(int, bool, bool)> mainScreenCityClosed = [](int, bool, bool) {};
|
||||
std::function<void(bool)> mainScreenUpdateViews = [](bool) {};
|
||||
std::function<void()> mainScreenRepaintAll = [] {};
|
||||
std::function<int(int)> modalSelectDlgShowCityProject = [](int) { return -1; };
|
||||
std::function<bool(int)> listDlgRenameCity = [](int) { return false; };
|
||||
std::function<MessgEx::MessgExDlg *()> mainScreenMessgExDlg = [] { return static_cast<MessgEx::MessgExDlg *>(nullptr); };
|
||||
|
||||
} // namespace Term
|
||||
} // namespace Cevo
|
||||
@@ -28,9 +28,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Cevo/CevoBaseWin.h"
|
||||
#include "Cevo/CevoScreenTools.h"
|
||||
#include "Cevo/Protocol.h"
|
||||
#include "ClientTools.h"
|
||||
#include "MessgEx.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
@@ -141,6 +143,11 @@ void initMyModel(int mix, bool final);
|
||||
// different Pascal unit) - don't conflate the two.
|
||||
extern int gameMode;
|
||||
|
||||
// Term.pas's `Age: Integer;` (the local player's current era - used as a
|
||||
// palette-row offset into ScreenTools.pas's `Colors` matrix, e.g.
|
||||
// `clkAge0 + Age`). Stays 0 until Term.pas is ported and updates it.
|
||||
extern int age;
|
||||
|
||||
// Term.pas's layout constant (MidPanelHeight - TopBarHeight) div 2; the
|
||||
// two panel-size constants it derives from belong to Term's not-yet-ported
|
||||
// main window layout, so only the resulting fixed value is pre-seeded here.
|
||||
@@ -157,5 +164,50 @@ extern int nLostArmy;
|
||||
// draw them. Injection point (default no-op) until Term.pas is ported.
|
||||
extern std::function<void()> initAllEnemyModels;
|
||||
|
||||
// Term.pas's own "city status flags"/additional "city happened flags"
|
||||
// constants (distinct from Protocol.pas's chXxx flags in ai/Protocol.h).
|
||||
constexpr int csTypeMask = 0x0007;
|
||||
constexpr int csToldDelay = 0x0008;
|
||||
constexpr int csResourceWeightsMask = 0x00F0;
|
||||
constexpr int csToldBombard = 0x0100;
|
||||
constexpr int chAllImpsMade = 0x4000;
|
||||
constexpr int chTypeDel = 0x8000;
|
||||
|
||||
// Term.pas's CityEventPriority[]/CityEventSoundItem[]/CityEventName(): the
|
||||
// city-event-message table shown by CityScreen.pas's "messages" panel.
|
||||
constexpr int nCityEventPriority = 16;
|
||||
extern const std::array<int, nCityEventPriority> CityEventPriority;
|
||||
extern const std::array<QString, 16> CityEventSoundItem;
|
||||
// TODO: needs Phrases/Phrases2 (StringTables.pas not ported) - falls back
|
||||
// to a plain English description per event index.
|
||||
QString cityEventName(int i);
|
||||
|
||||
// Term.pas's HelpOnTerrain(): opens the help dialog on the terrain-info
|
||||
// page matching the given map tile (including the fJungle pseudo-terrain
|
||||
// substitution for forest tiles growing on a jungle-climate row).
|
||||
constexpr int fJungle = 8; // Help.pas's pseudo-terrain id for jungle-grown forest.
|
||||
void helpOnTerrain(int loc, WindowMode newMode);
|
||||
|
||||
// Term.pas's `MainScreen: TMainScreen` instance isn't ported; these mirror
|
||||
// its ZoomToCity()/CityClosed()/UpdateViews()/RepaintAll() methods plus
|
||||
// ModalSelectDlg/ListDlg dialog access as injection points other screens
|
||||
// can call into once Term.pas/Select.pas exist. Default to safe no-ops.
|
||||
extern std::function<bool(int loc, bool nextUnitOnClose, int showEvent)> mainScreenZoomToCity;
|
||||
extern std::function<void(int activateUix, bool stepFocus, bool selectFocus)> mainScreenCityClosed;
|
||||
extern std::function<void(bool updateCityScreen)> mainScreenUpdateViews;
|
||||
extern std::function<void()> mainScreenRepaintAll;
|
||||
// Mirrors `MainScreen.ModalSelectDlg.ShowNewContent_CityProject(wmModal,
|
||||
// cix)` + reading back `.Result` - returns -1 (cancelled) by default.
|
||||
extern std::function<int(int cix)> modalSelectDlgShowCityProject;
|
||||
// Select.pas's own `cpType = $10000` bit (set in ModalSelectDlg.Result when
|
||||
// the user picked a city-type autobuild preset rather than a single
|
||||
// project) - distinct from Protocol.pas's cpXxx bits in ai/Protocol.h.
|
||||
constexpr int cpType = 0x10000;
|
||||
// Mirrors `MainScreen.ListDlg.RenameCity(cix)` - returns false by default.
|
||||
extern std::function<bool(int cix)> listDlgRenameCity;
|
||||
// Mirrors `MainScreen.MessgExDlg` dialog access - returns nullptr by
|
||||
// default until Term.pas creates a real instance.
|
||||
extern std::function<MessgEx::MessgExDlg *()> mainScreenMessgExDlg;
|
||||
|
||||
} // namespace Term
|
||||
} // namespace Cevo
|
||||
Reference in new issue
Block a user