mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
cleaned up statistics screen
This commit is contained in:
@@ -48,6 +48,7 @@ namespace battleship{
|
||||
}
|
||||
|
||||
ActiveGameState::~ActiveGameState() {
|
||||
removeDragbox();
|
||||
}
|
||||
|
||||
void ActiveGameState::initDragbox(){
|
||||
@@ -66,6 +67,11 @@ namespace battleship{
|
||||
root->getGuiNode()->attachChild(dragboxNode);
|
||||
}
|
||||
|
||||
void ActiveGameState::removeDragbox(){
|
||||
Root::getSingleton()->getRootNode()->dettachChild(dragboxNode);
|
||||
delete dragboxNode;
|
||||
}
|
||||
|
||||
void ActiveGameState::onAttached() {
|
||||
AbstractAppState::onAttached();
|
||||
ConcreteGuiManager::getSingleton()->readLuaScreenScript("activeGameState.lua");
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace battleship{
|
||||
private:
|
||||
void updateGameObjHoveredOn();
|
||||
void initDragbox();
|
||||
void removeDragbox();
|
||||
void deselectUnits();
|
||||
void renderUnits();
|
||||
void updateSelectionBox();
|
||||
|
||||
+6
-1
@@ -91,7 +91,12 @@ namespace battleship{
|
||||
stateManager->attachAppState(activeState);
|
||||
}
|
||||
|
||||
void InGameAppState::onDettached() {}
|
||||
void InGameAppState::onDettached() {
|
||||
StateManager *sm = GameManager::getSingleton()->getStateManager();
|
||||
ActiveGameState *activeState = (ActiveGameState*)sm->getAppStateByType(int(AppStateType::ACTIVE_STATE));
|
||||
sm->dettachAppState(activeState);
|
||||
delete activeState;
|
||||
}
|
||||
|
||||
void InGameAppState::update() {
|
||||
Game::getSingleton()->update();
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <solUtil.h>
|
||||
|
||||
#include "map.h"
|
||||
#include "game.h"
|
||||
#include "player.h"
|
||||
#include "gameObject.h"
|
||||
#include "gameObjectFactory.h"
|
||||
@@ -262,7 +263,59 @@ namespace battleship{
|
||||
}
|
||||
}
|
||||
|
||||
void Map::unload() {}
|
||||
void Map::unloadSkybox(){
|
||||
Root::getSingleton()->removeSkybox();
|
||||
//unload skybox assets
|
||||
}
|
||||
|
||||
void Map::unloadCells(){
|
||||
while(cellNode->getNumChildren() > 0){
|
||||
Node *node = cellNode->getChild(0);
|
||||
cellNode->dettachChild(node);
|
||||
//delete node;
|
||||
}
|
||||
|
||||
cells.clear();
|
||||
}
|
||||
|
||||
void Map::unloadTerrainObjects(){
|
||||
//unload terrain assets
|
||||
while(terrainNode->getNumChildren() > 0){
|
||||
Node *node = terrainNode->getChild(0);
|
||||
terrainNode->dettachChild(node);
|
||||
//delete node;
|
||||
}
|
||||
}
|
||||
|
||||
void Map::unloadPlayerObjects(){
|
||||
for(Player *pl : Game::getSingleton()->getPlayers()){
|
||||
while(pl->getNumUnits() > 0){
|
||||
pl->removeUnit(0);
|
||||
}
|
||||
|
||||
while(pl->getNumResourceDeposits() > 0){
|
||||
pl->removeResourceDeposit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Map::destroyScene(){
|
||||
Node *rootNode = Root::getSingleton()->getRootNode();
|
||||
rootNode->dettachChild(terrainNode);
|
||||
rootNode->dettachChild(cellNode);
|
||||
|
||||
delete terrainNode;
|
||||
delete cellNode;
|
||||
}
|
||||
|
||||
void Map::unload(){
|
||||
unloadSkybox();
|
||||
unloadCells();
|
||||
unloadTerrainObjects();
|
||||
unloadPlayerObjects();
|
||||
spawnPoints.clear();
|
||||
destroyScene();
|
||||
}
|
||||
|
||||
template<typename T> int Map::bsearch(vector<T> haystack, T needle, float eps){
|
||||
T haystackMidVal;
|
||||
|
||||
@@ -71,6 +71,11 @@ namespace battleship{
|
||||
void loadSkybox();
|
||||
void loadCells();
|
||||
void loadTerrainObject(int);
|
||||
void unloadTerrainObjects();
|
||||
void unloadCells();
|
||||
void unloadSkybox();
|
||||
void unloadPlayerObjects();
|
||||
void destroyScene();
|
||||
template<typename T> int bsearch(std::vector<T>, T, float);
|
||||
};
|
||||
}
|
||||
|
||||
+2
-2
@@ -42,9 +42,9 @@ namespace battleship{
|
||||
Game::getSingleton()->addPlayer(player);
|
||||
}
|
||||
|
||||
ConcreteGuiManager::getSingleton()->readLuaScreenScript("inGame.lua");
|
||||
|
||||
StateManager *stateManager = GameManager::getSingleton()->getStateManager();
|
||||
stateManager->attachAppState(new InGameAppState(difficulties, factions));
|
||||
|
||||
ConcreteGuiManager::getSingleton()->readLuaScreenScript("inGame.lua");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +114,11 @@ namespace battleship{
|
||||
units.erase(units.begin() + id);
|
||||
}
|
||||
|
||||
void Player::removeResourceDeposit(int id){
|
||||
delete resourceDeposits[id];
|
||||
resourceDeposits.erase(resourceDeposits.begin() + id);
|
||||
}
|
||||
|
||||
vector<Unit*> Player::getSelectedUnitsByClass(UnitClass uc){
|
||||
vector<Unit*> selectedUnits = getSelectedUnits(), unitsByClass;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace battleship{
|
||||
void issueOrder(Order::TYPE, vb01::Vector3, std::vector<Order::Target>, bool);
|
||||
void removeUnit(Unit*);
|
||||
void removeUnit(int);
|
||||
void removeResourceDeposit(int);
|
||||
bool isThisPlayersUnit(GameObject*);
|
||||
std::vector<Unit*> getSelectedUnitsByClass(UnitClass);
|
||||
void selectUnits(std::vector<Unit*>);
|
||||
@@ -30,6 +31,7 @@ namespace battleship{
|
||||
inline void addUnit(Unit *u){units.push_back(u);}
|
||||
inline std::vector<ResourceDeposit*>& getResourceDeposits(){return resourceDeposits;}
|
||||
inline void addResourceDeposit(ResourceDeposit *rd){resourceDeposits.push_back(rd);}
|
||||
inline int getNumResourceDeposits(){return resourceDeposits.size();}
|
||||
inline Unit* getUnit(int i){return units[i];}
|
||||
inline std::vector<Unit*>& getUnits(){return units;}
|
||||
inline void setTeam(int t){team = t;}
|
||||
|
||||
@@ -1,14 +1,26 @@
|
||||
#include "statsButton.h"
|
||||
#include "gameManager.h"
|
||||
#include "concreteGuiManager.h"
|
||||
#include "inGameAppState.h"
|
||||
#include "map.h"
|
||||
|
||||
#include <stateManager.h>
|
||||
|
||||
namespace battleship{
|
||||
using namespace std;
|
||||
using namespace vb01;
|
||||
using namespace gameBase;
|
||||
|
||||
StatsButton::StatsButton(Vector2 pos, Vector2 size, string name, int trigger, string imagePath) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, true, imagePath){}
|
||||
|
||||
void StatsButton::onClick(){
|
||||
Map::getSingleton()->unload();
|
||||
|
||||
StateManager *sm = GameManager::getSingleton()->getStateManager();
|
||||
InGameAppState *inGameState = (InGameAppState*)sm->getAppStateByType(int(AppStateType::IN_GAME_STATE));
|
||||
sm->dettachAppState(inGameState);
|
||||
delete inGameState;
|
||||
|
||||
ConcreteGuiManager::getSingleton()->readLuaScreenScript("statistics.lua");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user