implemented main window
This commit is contained in:
1 parent
a11ce3005c
commit
5d5a502976
11 files changed
+2876
-37
No files matched your search
@@ -44,13 +44,20 @@
|
||||
// include all 17 dialog headers below.
|
||||
|
||||
#include "Battle.h"
|
||||
#include "Cevo/CevoArea.h"
|
||||
#include "Cevo/CevoButtonB.h"
|
||||
#include "Cevo/CevoButtonC.h"
|
||||
#include "Cevo/CevoEOTButton.h"
|
||||
#include "Cevo/CevoPVScrollBar.h"
|
||||
#include "CityScreen.h"
|
||||
#include "CityType.h"
|
||||
#include "Diagram.h"
|
||||
#include "Draft.h"
|
||||
#include "Enhance.h"
|
||||
#include "Help.h"
|
||||
#include "IsoEngine.h"
|
||||
#include "Log.h"
|
||||
#include "MiniMap.h"
|
||||
#include "MessgEx.h"
|
||||
#include "NatStat.h"
|
||||
#include "Nego.h"
|
||||
@@ -61,6 +68,11 @@
|
||||
#include "UnitStat.h"
|
||||
#include "Wonders.h"
|
||||
|
||||
#include <QPoint>
|
||||
#include <QRegion>
|
||||
#include <QTimer>
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
|
||||
namespace Cevo {
|
||||
@@ -103,9 +115,8 @@ public:
|
||||
// ecoChange()/CityDlg::smartUpdateContent()) runs for now.
|
||||
void updateViews(bool updateCityScreen = false);
|
||||
bool contactRefused(int p, const QString &item);
|
||||
// TODO: needs the real main map/panel (not ported yet) - no-op until
|
||||
// then (matches the original's RepaintAll()'s sole purpose).
|
||||
void repaintAll() {}
|
||||
// Repaints the map, minimap and panel from scratch.
|
||||
void repaintAll();
|
||||
void setAIName(int p, const QString &name);
|
||||
void rememberPeaceViolation();
|
||||
// Term.pas's GetTribeList(): fills unusedTribeFiles from the Tribes directory.
|
||||
@@ -123,8 +134,137 @@ public:
|
||||
void client(int command, int newPlayer, void *data);
|
||||
// Term.pas's EndNego(): leaves the negotiation screen.
|
||||
void endNego();
|
||||
// Term.pas's ZoomToCity()/CityClosed(): open the city screen for a city
|
||||
// and refocus once it is closed.
|
||||
bool zoomToCity(int loc, bool nextUnitOnClose = false, int showEvent = 0);
|
||||
void cityClosed(int activateUix, bool stepFocus = false, bool selectFocus = false);
|
||||
|
||||
// ---- Map view (Term.MainScreen.Window.cpp) ----
|
||||
// Scrolls the base map position by (dx, dy) tiles and repaints.
|
||||
void scroll(int dx, int dy);
|
||||
// Puts location `loc` at pixel `mapPos` of the map view.
|
||||
void setMapPos(int loc, QPoint mapPos);
|
||||
void centre(int loc);
|
||||
int locationOfScreenPixel(int x, int y) const;
|
||||
int getCenterLoc() const;
|
||||
void setTroopLoc(int loc);
|
||||
void paintLoc(int loc, int radius = 0);
|
||||
void paintLocBeforeMove(int fromLoc);
|
||||
void paintLocTemp(int loc, PaintLocTempStyle style = PaintLocTempStyle::Normal);
|
||||
void paintDestination();
|
||||
void paintAll();
|
||||
void paintAllMaps();
|
||||
void panelPaint();
|
||||
void setUnFocus(int uix);
|
||||
void focusOnLoc(int loc, int options = 0);
|
||||
void setTileSize(IsoEngine::TileSize tileSize, int loc, QPoint mapPos);
|
||||
void setTileSizeCenter(IsoEngine::TileSize tileSize);
|
||||
void checkTerrainBtnVisible();
|
||||
void checkMovieSpeedBtnState();
|
||||
void setMapOptions();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void showEvent(QShowEvent *event) override;
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
void wheelEvent(QWheelEvent *event) override;
|
||||
|
||||
private:
|
||||
void createControls();
|
||||
void resizeControls();
|
||||
void arrangeMidPanel();
|
||||
void mainOffscreenPaint();
|
||||
void miniMapPaint();
|
||||
void copyMiniToPanel();
|
||||
void processRect(int x0, int y0, int nx, int ny, int options);
|
||||
void timerTick();
|
||||
void invalidateRect(int left, int top, int right, int bottom);
|
||||
void invalidateMiniMap();
|
||||
void initTurn(int newPlayer);
|
||||
void nextUnit(int nearLoc, bool autoTurn);
|
||||
bool endTurn(bool wasSkipped = false);
|
||||
void paintTopBar();
|
||||
void paintPanelBackground();
|
||||
void paintPanelBrushes();
|
||||
void paintPanelSelectedUnit();
|
||||
void paintPanelTroops();
|
||||
void paintPanelTerrain();
|
||||
void paintPanelButtons();
|
||||
void paintZoomedTile(Dpi::Bitmap &dst, int x, int y, int loc);
|
||||
// Immediately repaints what invalidateRect() collected (Pascal's Update).
|
||||
void updateNow();
|
||||
|
||||
// Map view state (Term.pas's private fields of the same names).
|
||||
int m_xw = 0; // base map x
|
||||
int m_yw = 0; // base map y
|
||||
int m_xwd = 0;
|
||||
int m_ywd = 0;
|
||||
int m_xwMini = 0;
|
||||
int m_ywMini = 0;
|
||||
int m_xMidPanel = 0;
|
||||
int m_xRightPanel = 0;
|
||||
int m_xTroop = 0;
|
||||
int m_xTerrain = 0;
|
||||
int m_xMini = 0;
|
||||
int m_yMini = 0;
|
||||
int m_ywmax = 0;
|
||||
int m_ywcenter = 0;
|
||||
int m_troopLoc = -1;
|
||||
int m_trCnt = 0;
|
||||
int m_trRow = 0;
|
||||
int m_trPitch = 66;
|
||||
int m_mapWidth = 0;
|
||||
int m_mapOffset = 0;
|
||||
int m_mapHeight = 0;
|
||||
int m_blinkTime = 0;
|
||||
int m_markCityLoc = -1;
|
||||
int m_brushLoc = -1;
|
||||
bool m_edited = false;
|
||||
std::uint32_t m_brushType = fGrass;
|
||||
std::array<int, 64> m_trix{}; // what each visible panel slot shows (unit index or brush)
|
||||
bool m_mapValid = false;
|
||||
bool m_smallScreen = false;
|
||||
bool m_turnComplete = false;
|
||||
bool m_tracking = false;
|
||||
bool m_skipped = false;
|
||||
bool m_goOnPhase = false;
|
||||
bool m_haveStrategyAdvice = false;
|
||||
int m_pTurn = -1;
|
||||
bool m_repaintOnResize = false;
|
||||
bool m_locCodesChecked = false;
|
||||
QRegion m_dirty;
|
||||
std::array<std::unique_ptr<Dpi::Bitmap>, nPl> m_aiLogo;
|
||||
int m_lastResizeWidth = 0;
|
||||
int m_lastResizeHeight = 0;
|
||||
|
||||
Dpi::Bitmap m_offscreen; // the map view, window-sized
|
||||
Dpi::Bitmap m_panel;
|
||||
Dpi::Bitmap m_topBar;
|
||||
// Temporarily painted tile (unit blink), drawn over the map layer.
|
||||
Dpi::Bitmap m_blinkTile;
|
||||
QPoint m_blinkTilePos;
|
||||
bool m_blinkTileValid = false;
|
||||
std::unique_ptr<IsoEngine::IsoMap> m_mainMap;
|
||||
std::unique_ptr<IsoEngine::IsoMap> m_noMap;
|
||||
std::unique_ptr<IsoEngine::IsoMap> m_noMapPanel;
|
||||
std::unique_ptr<MiniMap> m_miniMap;
|
||||
std::unique_ptr<PVScrollBar> m_verticalScrollBar;
|
||||
ButtonB *m_unitBtn = nullptr;
|
||||
ButtonB *m_unitInfoBtn = nullptr;
|
||||
ButtonB *m_terrainBtn = nullptr;
|
||||
std::array<ButtonB *, 4> m_movieSpeedBtn{};
|
||||
ButtonC *m_mapBtn0 = nullptr;
|
||||
ButtonC *m_mapBtn1 = nullptr;
|
||||
ButtonC *m_mapBtn4 = nullptr;
|
||||
ButtonC *m_mapBtn5 = nullptr;
|
||||
ButtonC *m_mapBtn6 = nullptr;
|
||||
EOTButton *m_eot = nullptr;
|
||||
Area *m_menuArea = nullptr;
|
||||
Area *m_treasuryArea = nullptr;
|
||||
Area *m_researchArea = nullptr;
|
||||
Area *m_managementArea = nullptr;
|
||||
QTimer *m_timer = nullptr;
|
||||
// Term.pas's implementation-level state (Jump/pLogo/GameOK/Idle/...).
|
||||
std::array<int, nPl> m_jump{};
|
||||
int m_pLogo = -1;
|
||||
|
||||
Reference in new issue
Block a user