233 lines
11 KiB
C++
233 lines
11 KiB
C++
// 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/CevoScreenTools.h"
|
|
#include "Cevo/Protocol.h"
|
|
#include "ClientTools.h"
|
|
#include "MessgEx.h"
|
|
|
|
#include <QString>
|
|
|
|
#include <array>
|
|
#include <cstdint>
|
|
#include <functional>
|
|
|
|
namespace Cevo {
|
|
namespace Term {
|
|
|
|
// PORT STATUS: Term.pas itself (~7500 lines, the main game screen) is NOT
|
|
// ported - it needs ~14 other LocalPlayer dialogs that don't exist yet
|
|
// (see /memories/repo/cevo-evo-game.md for the port order). This file only
|
|
// pre-seeds the handful of Term.pas globals/constants/helpers that the
|
|
// LEAF dialogs (CityType, ...) need from it; real Term.pas content gets
|
|
// added into this same namespace/file set once its turn comes.
|
|
|
|
constexpr int nCityType = 4;
|
|
// Term.pas's own pseudo-advance ids (adjacent to Protocol.pas's adMilitary
|
|
// = 0x800) used by the tech-selection dialog (Select.pas).
|
|
constexpr int adNone = 0x801;
|
|
constexpr int adFar = 0x802;
|
|
constexpr int adNexus = 0x803;
|
|
// icons.bmp properties: lines of system icons before improvements start.
|
|
constexpr int xSizeSmall = 36;
|
|
constexpr int ySizeSmall = 20;
|
|
constexpr int SystemIconLines = 2;
|
|
|
|
// TModel.Status bit flags.
|
|
constexpr int msObsolete = 0x1;
|
|
constexpr int msAllowConscripts = 0x2;
|
|
|
|
// Term.pas's `MainScreen.mNames.Checked` (menu checkbox: show real model
|
|
// names vs. generic "Model #n" names) - defaults to the more useful true.
|
|
extern bool mainScreenNamesChecked;
|
|
// Term.pas's `Buffer: TBitmap` - a shared general-purpose scratch bitmap;
|
|
// callers must setSize() it themselves before use (no central owner
|
|
// resizes it yet since Term.pas's own usage isn't ported).
|
|
extern Dpi::Bitmap buffer;
|
|
|
|
// Term.pas's `TPersistentData` (per-player persisted client-side settings,
|
|
// e.g. city build-order preferences) - only the fields some leaf dialog
|
|
// needs are ported so far; add more as needed.
|
|
struct PersistentData {
|
|
int farTech = 0;
|
|
int toldAge = 0;
|
|
int toldModels = 0;
|
|
int toldAlive = 0;
|
|
int toldContact = 0;
|
|
int toldOwnCredibility = 0;
|
|
int coldWarStart = 0;
|
|
int peaceEvaHappened = 0;
|
|
ClientTools::TEnhancementJobs enhancementJobs{};
|
|
std::array<ClientTools::TImpOrder, nCityType> impOrder{};
|
|
std::array<TWonderInfo, nWonder> toldWonders{};
|
|
std::array<std::int8_t, nAdv> toldTech{};
|
|
};
|
|
|
|
// Term.pas's `MyData: ^TPersistentData;` - null until a real game/turn is
|
|
// active (set by Term.pas's InitTurn(), not yet ported).
|
|
extern PersistentData *myData;
|
|
|
|
// Term.pas's `SmallImp: TBitmap;` (icons.bmp sprite sheet, small size) -
|
|
// populated by Term.pas's asset loading, not yet ported.
|
|
extern Dpi::Bitmap *smallImp;
|
|
|
|
// Equivalent of Term.pas's ImpImage(): draws an improvement/wonder icon
|
|
// from bigImp, substituting the age-specific palace graphic for imPalace.
|
|
void impImage(Dpi::Canvas &canvas, int x, int y, int iix, int government = -1, bool isControl = false);
|
|
|
|
// Term.pas's `OptionChecked: TSaveOptions;` (user-configurable UI options).
|
|
extern ClientTools::SaveOptions optionChecked;
|
|
// Term.pas's `Supervising: Boolean;` (true when controlling player 0 is
|
|
// just observing rather than playing a nation).
|
|
extern bool supervising;
|
|
|
|
// Term.pas's `TDipMem` (per-nation negotiation session memory) - only the
|
|
// one field (`pContact`) anything needs so far.
|
|
struct DipMemEntry {
|
|
int pContact = -1;
|
|
};
|
|
extern std::array<DipMemEntry, nPl> dipMem;
|
|
|
|
// Term.pas's RoughCredibility(): buckets a 0..100 credibility value into a
|
|
// 4-level rating (0..3) for display.
|
|
int roughCredibility(int credibility);
|
|
|
|
// ScreenTools.pas's TurnToString(): turnToYear() formatted as "<n> BC"/"AD
|
|
// <n>" (or the plain turn number if `generateNames` is off). Lives here
|
|
// rather than in the widget-layer CevoScreenTools.h since it needs
|
|
// Global::generateNames (a game-layer symbol widget/ mustn't depend on).
|
|
QString turnToString(int turn);
|
|
|
|
// Term.pas's `MainScreen: TMainScreen` instance isn't ported; these mirror
|
|
// its DipCall()/ContactRefused() methods as injection points other leaf
|
|
// dialogs can call into once Term.pas/Nego.pas exist. Default to safe
|
|
// no-ops (DipCall "not executed", ContactRefused "not refused") so callers
|
|
// relying on them just see "nothing happened" rather than crashing.
|
|
extern std::function<int(int command)> mainScreenDipCall;
|
|
extern std::function<bool(int p, const QString &item)> mainScreenContactRefused;
|
|
|
|
// Term.pas's ChooseModelPicture()/InitMyModel(): assigns a visual "picture"
|
|
// to a developed/enemy unit model. Simplified - always takes the
|
|
// "non-original tribe" path (dispatches straight through
|
|
// Tribe::setModelPicture()) since the network cSet*ModelPicture command
|
|
// plumbing isn't ported, and the mkSlaves (Code==74) special case isn't
|
|
// handled either (narrow edge case, not reached by anything ported so far).
|
|
void chooseModelPicture(int p, int mix, int code, int hash, int turn, bool forceNew, bool final);
|
|
void initMyModel(int mix, bool final);
|
|
|
|
// Term.pas's `GameMode: Integer;` (cNewGame/cLoadGame/cMovie/... - which
|
|
// top-level mode the client is running in). NOT the same thing as
|
|
// Database::GameMode (a different, server-side enum of the same name in a
|
|
// 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 `CityRepMask: Cardinal;` (user-configurable "which city
|
|
// events to report" bitmask, persisted via QSettings in the original -
|
|
// not wired to settings here yet, just the documented default value).
|
|
extern std::uint32_t cityRepMask;
|
|
|
|
// Term.pas's `AdvIcon: array[0..nAdv-1] of Integer;` (per-advance icon
|
|
// index into SmallImp/HGrSystem, computed by a Term.pas init routine not
|
|
// yet ported) - stays -1 ("no icon assigned yet") for every entry until
|
|
// Term.pas is ported; harmless if read before that (just selects an
|
|
// arbitrary/wrong icon, not a crash - same "pre-seed stays default" policy
|
|
// as lostArmy[]/nLostArmy).
|
|
extern std::array<int, nAdv> advIcon;
|
|
|
|
// 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.
|
|
constexpr int MapCenterUp = 39;
|
|
|
|
// Term.pas's `LostArmy`/`nLostArmy` (model-indexed lost-unit counts shown
|
|
// by MessgEx.pas's "army destroyed" report) - stay all-zero until Term.pas
|
|
// itself is ported and populates them for real.
|
|
extern std::array<int, nPl * nMmax> lostArmy;
|
|
extern int nLostArmy;
|
|
|
|
// Term.pas's InitAllEnemyModels()/InitEnemyModel(): resolves a picture for
|
|
// every known enemy unit model so MessgEx.pas's "enemy army" report can
|
|
// 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
|