forked from Return-To-The-Roots/s25client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameWorldView.h
More file actions
141 lines (112 loc) · 4.71 KB
/
GameWorldView.h
File metadata and controls
141 lines (112 loc) · 4.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org)
//
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "DrawPoint.h"
#include "gameTypes/MapCoordinates.h"
#include "gameTypes/MapTypes.h"
#include <boost/signals2.hpp>
#include <vector>
class GameWorldBase;
class GameWorldViewer;
class noBaseBuilding;
class SoundManager;
class TerrainRenderer;
struct RoadBuildState;
class IDrawNodeCallback
{
public:
virtual ~IDrawNodeCallback() = default;
/// Called when a node is going to be drawn at displayPt
/// Can e.g. print coordinates
virtual void onDraw(const MapPoint& pt, const DrawPoint& displayPt) = 0;
};
struct ObjectBetweenLines;
class GameWorldView
{
/// Currently selected point (where the mouse points to)
MapPoint selPt;
/// Offset to selected point
Position selPtOffset;
/// Callbacks called when node is printed
std::vector<IDrawNodeCallback*> drawNodeCallbacks;
/// Show building quality icons
bool show_bq;
/// Show building names
bool show_names;
/// Show productivities
bool show_productivity;
/// Offset from world origin in screen units (not map units): "scroll position"
DrawPoint offset;
/// Last scroll position (before jump)
DrawPoint lastOffset;
/// First drawn map point (might be slightly outside map -> Wrapping)
DrawPoint firstPt;
/// Last drawn map point
DrawPoint lastPt;
const GameWorldViewer& gwv;
/// Top-Left position of the view (window)
Position origin_;
/// Size of the view
Extent size_;
/// How much the view is scaled (1=normal, >1=bigger, >0 && <1=smaller)
float zoomFactor_;
float targetZoomFactor_;
float zoomSpeed_;
public:
GameWorldView(const GameWorldViewer& gwv, const Position& pos, const Extent& size);
const GameWorldViewer& GetViewer() const { return gwv; }
const GameWorldBase& GetWorld() const;
SoundManager& GetSoundMgr();
void SetPos(const Position& newPos) { origin_ = newPos; }
Position GetPos() const { return origin_; }
Extent GetSize() const { return size_; }
void SetZoomFactor(float zoomFactor, bool smoothTransition = true);
float GetCurrentTargetZoomFactor() const;
void SetNextZoomFactor();
/// Show or hide construction aid
void ToggleShowBQ();
/// Show or hide building names
void ToggleShowNames();
/// Show or hide productivity
void ToggleShowProductivity();
/// Toggle names and productivity completely on or off
void ToggleShowNamesAndProductivity();
/// Copy visibility of HUD elements from this view to another
void CopyHudSettingsTo(GameWorldView& other, bool copyBQ) const;
void Draw(const RoadBuildState& rb, MapPoint selected, bool drawMouse, unsigned* water = nullptr);
/// Moves the map view by the given offset in pixels
void MoveBy(const DrawPoint& numPixels);
/// Moves a position on the map in pixels
void MoveTo(const DrawPoint& newPos);
/// Zentriert den Bildschirm auf ein bestimmtes Map-Object
void MoveToMapPt(MapPoint pt);
/// Springt zur letzten Position, bevor man "weggesprungen" ist
void MoveToLastPosition();
DrawPoint GetOffset() const { return offset; }
/// Add a debug node printer
void AddDrawNodeCallback(IDrawNodeCallback* newCallback);
void RemoveDrawNodeCallback(IDrawNodeCallback* callbackToRemove);
/// Gibt selektierten Punkt zurück
MapPoint GetSelectedPt() const { return selPt; }
/// Gibt ersten Punkt an, der beim Zeichnen angezeigt wird
Position GetFirstPt() const { return firstPt; }
/// Gibt letzten Punkt an, der beim Zeichnen angezeigt wird
Position GetLastPt() const { return lastPt; }
void Resize(const Extent& newSize);
/// Triggered when visibility of HUD elements changes
boost::signals2::signal<void()> onHudSettingsChanged;
private:
void CalcFxLx();
void DrawBoundaryStone(const MapPoint& pt, DrawPoint pos, Visibility vis);
void DrawObject(const MapPoint& pt, const DrawPoint& curPos) const;
void DrawConstructionAid(const MapPoint& pt, const DrawPoint& curPos);
void DrawFigures(const MapPoint& pt, const DrawPoint& curPos, std::vector<ObjectBetweenLines>& between_lines) const;
void DrawMovingFiguresFromBelow(const TerrainRenderer& terrainRenderer, const DrawPoint& curPos,
std::vector<ObjectBetweenLines>& between_lines);
void DrawNameProductivityOverlay(const TerrainRenderer& terrainRenderer);
void DrawProductivity(const noBaseBuilding& no, const DrawPoint& curPos);
void DrawGUI(const RoadBuildState& rb, const TerrainRenderer& terrainRenderer, const MapPoint& selectedPt,
bool drawMouse);
void SaveIngameSettingsValues() const;
};