[Orxonox-commit 127] r2819 - branches/miniprojects/src/orxonox/objects/infos
landauf at orxonox.net
landauf at orxonox.net
Sun Mar 22 21:59:34 CET 2009
Author: landauf
Date: 2009-03-22 20:59:34 +0000 (Sun, 22 Mar 2009)
New Revision: 2819
Modified:
branches/miniprojects/src/orxonox/objects/infos/HumanPlayer.cc
branches/miniprojects/src/orxonox/objects/infos/HumanPlayer.h
branches/miniprojects/src/orxonox/objects/infos/PlayerInfo.cc
branches/miniprojects/src/orxonox/objects/infos/PlayerInfo.h
Log:
moved gametype-HUD from PlayerInfo to HumanPlayer
Modified: branches/miniprojects/src/orxonox/objects/infos/HumanPlayer.cc
===================================================================
--- branches/miniprojects/src/orxonox/objects/infos/HumanPlayer.cc 2009-03-22 20:40:35 UTC (rev 2818)
+++ branches/miniprojects/src/orxonox/objects/infos/HumanPlayer.cc 2009-03-22 20:59:34 UTC (rev 2819)
@@ -53,6 +53,7 @@
this->defaultController_ = Class(HumanController);
this->humanHud_ = 0;
+ this->gametypeHud_ = 0;
this->setConfigValues();
this->registerVariables();
@@ -60,8 +61,14 @@
HumanPlayer::~HumanPlayer()
{
- if (this->BaseObject::isInitialized() && this->humanHud_)
- delete this->humanHud_;
+ if (this->BaseObject::isInitialized())
+ {
+ if (this->humanHud_)
+ delete this->humanHud_;
+
+ if (this->gametypeHud_)
+ delete this->gametypeHud_;
+ }
}
void HumanPlayer::setConfigValues()
@@ -114,6 +121,7 @@
this->setName(this->nick_);
this->createController();
+ this->updateHumanHUD();
}
}
@@ -149,12 +157,24 @@
this->networkcallback_clientIDchanged();
}
+ void HumanPlayer::changedGametype()
+ {
+ PlayerInfo::changedGametype();
+
+ if (this->isInitialized() && this->isLocalPlayer())
+ if (this->getGametype()->getHUDTemplate() != "")
+ this->setGametypeHUDTemplate(this->getGametype()->getHUDTemplate());
+ }
+
void HumanPlayer::changedControllableEntity()
{
PlayerInfo::changedControllableEntity();
if (this->humanHud_)
this->humanHud_->setOwner(this->getControllableEntity());
+
+ if (this->gametypeHud_)
+ this->gametypeHud_->setOwner(this->getControllableEntity());
}
void HumanPlayer::updateHumanHUD()
@@ -165,11 +185,27 @@
this->humanHud_ = 0;
}
- if (this->humanHudTemplate_ != "")
+ if (this->isLocalPlayer() && this->humanHudTemplate_ != "")
{
this->humanHud_ = new OverlayGroup(this);
this->humanHud_->addTemplate(this->humanHudTemplate_);
this->humanHud_->setOwner(this->getControllableEntity());
}
}
+
+ void HumanPlayer::updateGametypeHUD()
+ {
+ if (this->gametypeHud_)
+ {
+ delete this->gametypeHud_;
+ this->gametypeHud_ = 0;
+ }
+
+ if (this->isLocalPlayer() && this->gametypeHudTemplate_ != "")
+ {
+ this->gametypeHud_ = new OverlayGroup(this);
+ this->gametypeHud_->addTemplate(this->gametypeHudTemplate_);
+ this->gametypeHud_->setOwner(this->getControllableEntity());
+ }
+ }
}
Modified: branches/miniprojects/src/orxonox/objects/infos/HumanPlayer.h
===================================================================
--- branches/miniprojects/src/orxonox/objects/infos/HumanPlayer.h 2009-03-22 20:40:35 UTC (rev 2818)
+++ branches/miniprojects/src/orxonox/objects/infos/HumanPlayer.h 2009-03-22 20:59:34 UTC (rev 2819)
@@ -50,6 +50,7 @@
void setClientID(unsigned int clientID);
+ virtual void changedGametype();
virtual void changedControllableEntity();
inline void setHumanHUDTemplate(const std::string& name)
@@ -62,10 +63,22 @@
}
inline const std::string& getHumanHUDTemplate() const
{ return this->humanHudTemplate_; }
-
inline OverlayGroup* getHumanHUD() const
{ return this->humanHud_; }
+ inline void setGametypeHUDTemplate(const std::string& name)
+ {
+ if (name != this->gametypeHudTemplate_)
+ {
+ this->gametypeHudTemplate_ = name;
+ this->updateGametypeHUD();
+ }
+ }
+ inline const std::string& getGametypeHUDTemplate() const
+ { return this->gametypeHudTemplate_; }
+ inline OverlayGroup* getGametypeHUD() const
+ { return this->gametypeHud_; }
+
protected:
void configvaluecallback_changednick();
void configvaluecallback_changedHUDTemplate();
@@ -75,6 +88,7 @@
void networkcallback_client_initialized();
void updateHumanHUD();
+ void updateGametypeHUD();
std::string nick_;
std::string synchronize_nick_;
@@ -84,6 +98,8 @@
std::string humanHudTemplate_;
OverlayGroup* humanHud_;
+ std::string gametypeHudTemplate_;
+ OverlayGroup* gametypeHud_;
};
}
Modified: branches/miniprojects/src/orxonox/objects/infos/PlayerInfo.cc
===================================================================
--- branches/miniprojects/src/orxonox/objects/infos/PlayerInfo.cc 2009-03-22 20:40:35 UTC (rev 2818)
+++ branches/miniprojects/src/orxonox/objects/infos/PlayerInfo.cc 2009-03-22 20:59:34 UTC (rev 2819)
@@ -34,7 +34,6 @@
#include "core/CoreIncludes.h"
#include "network/ClientInformation.h"
#include "objects/gametypes/Gametype.h"
-#include "overlays/OverlayGroup.h"
namespace orxonox
{
@@ -50,7 +49,6 @@
this->controller_ = 0;
this->controllableEntity_ = 0;
this->controllableEntityID_ = CLIENTID_UNKNOWN;
- this->gametypeHud_ = 0;
this->registerVariables();
}
@@ -69,9 +67,6 @@
if (this->getGametype())
this->getGametype()->playerLeft(this);
-
- if (this->BaseObject::isInitialized() && this->gametypeHud_)
- delete this->gametypeHud_;
}
}
@@ -108,10 +103,6 @@
this->getGametype()->playerSwitchedBack(this, this->getOldGametype());
else
this->getGametype()->playerEntered(this);
-
- if (this->isLocalPlayer() && this->isHumanPlayer())
- if (this->getGametype()->getHUDTemplate() != "")
- this->setGametypeHUDTemplate(this->getGametype()->getHUDTemplate());
}
}
}
@@ -184,26 +175,4 @@
this->stopControl(this->controllableEntity_);
}
}
-
- void PlayerInfo::changedControllableEntity()
- {
- if (this->gametypeHud_)
- this->gametypeHud_->setOwner(this->getControllableEntity());
- }
-
- void PlayerInfo::updateGametypeHUD()
- {
- if (this->gametypeHud_)
- {
- delete this->gametypeHud_;
- this->gametypeHud_ = 0;
- }
-
- if (this->isLocalPlayer() && this->isHumanPlayer() && this->gametypeHudTemplate_ != "")
- {
- this->gametypeHud_ = new OverlayGroup(this);
- this->gametypeHud_->addTemplate(this->gametypeHudTemplate_);
- this->gametypeHud_->setOwner(this->getControllableEntity());
- }
- }
}
Modified: branches/miniprojects/src/orxonox/objects/infos/PlayerInfo.h
===================================================================
--- branches/miniprojects/src/orxonox/objects/infos/PlayerInfo.h 2009-03-22 20:40:35 UTC (rev 2818)
+++ branches/miniprojects/src/orxonox/objects/infos/PlayerInfo.h 2009-03-22 20:59:34 UTC (rev 2819)
@@ -49,7 +49,7 @@
virtual void changedGametype();
virtual void changedController() {}
- virtual void changedControllableEntity();
+ virtual void changedControllableEntity() {}
inline bool isHumanPlayer() const
{ return this->bHumanPlayer_; }
@@ -76,20 +76,6 @@
inline Controller* getController() const
{ return this->controller_; }
- inline void setGametypeHUDTemplate(const std::string& name)
- {
- if (name != this->gametypeHudTemplate_)
- {
- this->gametypeHudTemplate_ = name;
- this->updateGametypeHUD();
- }
- }
- inline const std::string& getGametypeHUDTemplate() const
- { return this->gametypeHudTemplate_; }
-
- inline OverlayGroup* getGametypeHUD() const
- { return this->gametypeHud_; }
-
protected:
void createController();
@@ -101,14 +87,11 @@
private:
void networkcallback_changedcontrollableentityID();
- void updateGametypeHUD();
bool bReadyToSpawn_;
Controller* controller_;
ControllableEntity* controllableEntity_;
unsigned int controllableEntityID_;
- std::string gametypeHudTemplate_;
- OverlayGroup* gametypeHud_;
};
}
More information about the Orxonox-commit
mailing list