Changeset View
Changeset View
Standalone View
Standalone View
source/gui/ObjectTypes/CMiniMap.h
/* Copyright (C) 2019 Wildfire Games. | /* Copyright (C) 2020 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 "graphics/ShaderProgramPtr.h" | #include "graphics/ShaderProgramPtr.h" | ||||
#include "graphics/Texture.h" | |||||
#include "gui/ObjectBases/IGUIObject.h" | #include "gui/ObjectBases/IGUIObject.h" | ||||
#include "renderer/VertexArray.h" | #include "renderer/VertexArray.h" | ||||
Stan: Forward decl? | |||||
Done Inline ActionsDidn't work because of the usage in the struct. Imarok: Didn't work because of the usage in the struct. | |||||
class CCamera; | class CCamera; | ||||
class CMatrix3D; | class CMatrix3D; | ||||
Done Inline ActionsCColor is struct, also if you use CColor as type in the header then you need to use include instead of forward declaration. The same for CVector2D. vladislavbelov: `CColor` is `struct`, also if you use `CColor` as type in the header then you need to use… | |||||
Done Inline ActionsHmm, yeah. Shouldn't change things in the mid of the night xD Imarok: Hmm, yeah. Shouldn't change things in the mid of the night xD | |||||
class CTerrain; | class CTerrain; | ||||
struct MapFlareObj | |||||
{ | |||||
Done Inline ActionsThe Obj suffix is useless. vladislavbelov: The `Obj` suffix is useless. | |||||
Done Inline ActionsIf it's used only for the CMiniMap class then it might moved to its protected/private section. vladislavbelov: If it's used only for the `CMiniMap` class then it might moved to its protected/private section. | |||||
CPos pos; | |||||
CColor color; | |||||
double time; | |||||
}; | |||||
class CMiniMap : public IGUIObject | class CMiniMap : public IGUIObject | ||||
{ | { | ||||
GUI_OBJECT(CMiniMap) | GUI_OBJECT(CMiniMap) | ||||
public: | public: | ||||
CMiniMap(CGUI& pGUI); | CMiniMap(CGUI& pGUI); | ||||
virtual ~CMiniMap(); | virtual ~CMiniMap(); | ||||
protected: | protected: | ||||
Done Inline ActionsYou might add an empty line before. vladislavbelov: You might add an empty line before. | |||||
virtual void Draw(); | virtual void Draw(); | ||||
Done Inline Actionsprotected or private? Stan: protected or private? | |||||
Done Inline Actionssame as the rest Imarok: same as the rest | |||||
virtual void RegisterScriptFunctions(); | |||||
Done Inline ActionsNeed an include Stan: Need an include | |||||
/** | /** | ||||
* @see IGUIObject#HandleMessage() | * @see IGUIObject#HandleMessage() | ||||
*/ | */ | ||||
virtual void HandleMessage(SGUIMessage& Message); | virtual void HandleMessage(SGUIMessage& Message); | ||||
/** | /** | ||||
* Script accessors to this GUI object. | |||||
*/ | |||||
static JSFunctionSpec JSI_methods[]; | |||||
Done Inline ActionsUn-needed wraitii: Un-needed | |||||
static bool FlareProxy(JSContext* cx, uint argc, JS::Value* vp); | |||||
bool Flare(JSContext* cx, uint argc, JS::Value* vp); | |||||
/** | |||||
* @see IGUIObject#IsMouseOver() | * @see IGUIObject#IsMouseOver() | ||||
*/ | */ | ||||
virtual bool IsMouseOver() const; | virtual bool IsMouseOver() const; | ||||
// create the minimap textures | // create the minimap textures | ||||
void CreateTextures(); | void CreateTextures(); | ||||
// rebuild the terrain texture map | // rebuild the terrain texture map | ||||
Show All 11 Lines | protected: | ||||
// 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<MapFlareObj> m_MapFlares; | |||||
Done Inline Actions#include <deque> Stan: #include <deque> | |||||
// minimap texture handles | // minimap texture handles | ||||
GLuint m_TerrainTexture; | GLuint m_TerrainTexture; | ||||
CTexturePtr m_FlareTexture; | |||||
Done Inline ActionsUse constant instead of the magic number. vladislavbelov: Use constant instead of the magic number. | |||||
Done Inline ActionsUsually we use upper case with underscores for such constants. vladislavbelov: Usually we use upper case with underscores for such constants. | |||||
Done Inline ActionsCould use std::array maybe. Stan: Could use std::array maybe. | |||||
Done Inline ActionsMight need another include for CTexturePtr Stan: Might need another include for CTexturePtr | |||||
Done Inline ActionsNah, that's from Texture.h Imarok: Nah, that's from `Texture.h` | |||||
// 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; | ||||
ssize_t m_Width, m_Height; | ssize_t m_Width, m_Height; | ||||
// map size | // map size | ||||
ssize_t m_MapSize; | ssize_t m_MapSize; | ||||
// texture size | // texture size | ||||
GLsizei m_TextureSize; | GLsizei m_TextureSize; | ||||
// 1.f if map is circular or 1.414f if square (to shrink it inside the circle) | // 1.f if map is circular or 1.414f if square (to shrink it inside the circle) | ||||
float m_MapScale; | float m_MapScale; | ||||
// 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) const; | void DrawTexture(CShaderProgramPtr shader, float coordMax, float angle, float x, float y, float x2, float y2, float z) const; | ||||
void DrawViewRect(CMatrix3D transform) const; | void DrawViewRect(const CMatrix3D& transform) const; | ||||
void DrawFlare(CShaderProgramPtr shader, const MapFlareObj& flare, double cur_time) const; | |||||
void GetMouseWorldCoordinates(float& x, float& z) const; | void GetMouseWorldCoordinates(float& x, float& z) const; | ||||
CPos GetMapCoordinates(float x, float z) const; | |||||
float GetAngle() const; | float GetAngle() const; | ||||
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
Forward decl?