Changeset View
Changeset View
Standalone View
Standalone View
source/gui/MiniMap.h
/* Copyright (C) 2017 Wildfire Games. | /* Copyright (C) 2019 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
* GNU General Public License for more details. | * GNU General Public License for more details. | ||||
* | * | ||||
* You should have received a copy of the GNU General Public License | * You should have received a copy of the GNU General Public License | ||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
#ifndef INCLUDED_MINIMAP | #ifndef INCLUDED_MINIMAP | ||||
#define INCLUDED_MINIMAP | #define INCLUDED_MINIMAP | ||||
#include "gui/GUI.h" | #include "gui/GUI.h" | ||||
#include "renderer/VertexArray.h" | #include "renderer/VertexArray.h" | ||||
//typedef std::pair<std::pair<CPos, CColor>, double> MapPingObj; | |||||
vladislavbelov: Don't use `#define` for new types. Use `typedef` or `using`. Also I think the `first.first` is… | |||||
struct MapPingObj | |||||
{ | |||||
CPos pos; | |||||
CColor color; | |||||
double time; | |||||
}; | |||||
class CCamera; | class CCamera; | ||||
class CTerrain; | class CTerrain; | ||||
class CMiniMap : public IGUIObject | class CMiniMap : public IGUIObject | ||||
{ | { | ||||
GUI_OBJECT(CMiniMap) | GUI_OBJECT(CMiniMap) | ||||
public: | public: | ||||
Show All 18 Lines | protected: | ||||
// rebuild the terrain texture map | // rebuild the terrain texture map | ||||
void RebuildTerrainTexture(); | void RebuildTerrainTexture(); | ||||
// destroy and free any memory and textures | // destroy and free any memory and textures | ||||
void Destroy(); | void Destroy(); | ||||
void SetCameraPos(); | void SetCameraPos(); | ||||
void FireWorldClickEvent(int button, int clicks); | void FireWorldClickEvent(const CStr& eventType); | ||||
// the terrain we are mini-mapping | // the terrain we are mini-mapping | ||||
const CTerrain* m_Terrain; | const CTerrain* m_Terrain; | ||||
const CCamera* m_Camera; | const CCamera* m_Camera; | ||||
//Whether or not the mouse is currently down | //Whether or not the mouse is currently down | ||||
bool m_Clicking; | bool m_Clicking; | ||||
std::deque<MapPingObj> m_MapPings; | |||||
Done Inline Actionsstd::deque here, because the time sequence in monotonic. Also it's not so fragmented as the std::list. vladislavbelov: `std::deque` here, because the time sequence in monotonic. Also it's not so fragmented as the… | |||||
Not Done Inline ActionsThe events could have different durations, then items in the middle could be deleted? elexis: The events could have different durations, then items in the middle could be deleted? | |||||
// minimap texture handles | // minimap texture handles | ||||
GLuint m_TerrainTexture; | GLuint m_TerrainTexture; | ||||
// texture data | // texture data | ||||
u32* m_TerrainData; | u32* m_TerrainData; | ||||
// whether we need to regenerate the terrain texture | // whether we need to regenerate the terrain texture | ||||
bool m_TerrainDirty; | bool m_TerrainDirty; | ||||
Show All 11 Lines | protected: | ||||
// maximal water height to allow the passage of a unit (for underwater shallows). | // maximal water height to allow the passage of a unit (for underwater shallows). | ||||
float m_ShallowPassageHeight; | float m_ShallowPassageHeight; | ||||
float m_WaterHeight; | float m_WaterHeight; | ||||
void DrawTexture(CShaderProgramPtr shader, float coordMax, float angle, float x, float y, float x2, float y2, float z); | void DrawTexture(CShaderProgramPtr shader, float coordMax, float angle, float x, float y, float x2, float y2, float z); | ||||
void DrawViewRect(CMatrix3D transform); | void DrawViewRect(const CMatrix3D& transform); | ||||
void DrawPing(const CMatrix3D& transform, const MapPingObj& ping, double cur_time); | |||||
elexisUnsubmitted Not Done Inline Actions(Didn't check, perhaps this can become a const function) elexis: (Didn't check, perhaps this can become a const function) | |||||
void GetMouseWorldCoordinates(float& x, float& z); | void GetMouseWorldCoordinates(float& x, float& z); | ||||
Done Inline Actionsconst CMatrix3D& transform, because of 16 floats. Also I'd prefer to pass const MapPingObj& instead of multiple params. vladislavbelov: `const CMatrix3D& transform`, because of 16 floats. Also I'd prefer to pass `const MapPingObj&`… | |||||
CPos GetMapCoordinates(float x, float z) const; | |||||
Done Inline ActionsCPos GetMapCoordinates(float x, float z) const. vladislavbelov: `CPos GetMapCoordinates(float x, float z) const`. | |||||
float GetAngle(); | float GetAngle(); | ||||
VertexIndexArray m_IndexArray; | VertexIndexArray m_IndexArray; | ||||
VertexArray m_VertexArray; | VertexArray m_VertexArray; | ||||
VertexArray::Attribute m_AttributePos; | VertexArray::Attribute m_AttributePos; | ||||
VertexArray::Attribute m_AttributeColor; | VertexArray::Attribute m_AttributeColor; | ||||
size_t m_EntitiesDrawn; | size_t m_EntitiesDrawn; | ||||
double m_PingDuration; | double m_PingDuration; | ||||
double m_HalfBlinkDuration; | double m_HalfBlinkDuration; | ||||
double m_NextBlinkTime; | double m_NextBlinkTime; | ||||
bool m_BlinkState; | bool m_BlinkState; | ||||
}; | }; | ||||
#endif // INCLUDED_MINIMAP | #endif // INCLUDED_MINIMAP |
Wildfire Games · Phabricator
Don't use #define for new types. Use typedef or using. Also I think the first.first is not obvious for a reader in this case.