Added Player Gadget names to GUI.
This commit is contained in:
parent
f160cfb2f3
commit
8bee607981
11 changed files with 56 additions and 2 deletions
|
@ -42,7 +42,11 @@ Game::Game(tgui::Window& window) :
|
|||
mAmmo = window.add<tgui::Label>();
|
||||
mAmmo->setTextSize(20);
|
||||
mCurrentWeapon = window.add<tgui::Label>();
|
||||
mCurrentWeapon->setTextSize(14);
|
||||
mCurrentWeapon->setTextSize(14);
|
||||
mLeftGadget = window.add<tgui::Label>();
|
||||
mLeftGadget->setTextSize(14);
|
||||
mRightGadget = window.add<tgui::Label>();
|
||||
mRightGadget->setTextSize(14);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,12 +98,18 @@ Game::updateGui() {
|
|||
mHealth->setText(tgui::to_string(mPlayer->getHealth()));
|
||||
mAmmo->setText(magString + "/" + totalString);
|
||||
mCurrentWeapon->setText(mPlayer->getWeaponName());
|
||||
mLeftGadget->setText(mPlayer->getLeftGadgetName());
|
||||
mRightGadget->setText(mPlayer->getRightGadgetName());
|
||||
|
||||
mHealth->setPosition(0, mWindow.getSize().y - mHealth->getSize().y);
|
||||
mAmmo->setPosition(mWindow.getSize().x - mAmmo->getSize().x,
|
||||
mWindow.getSize().y - mAmmo->getSize().y);
|
||||
mCurrentWeapon->setPosition(mWindow.getSize().x - mCurrentWeapon->getSize().x,
|
||||
mAmmo->getPosition().y - mCurrentWeapon->getSize().y);
|
||||
mLeftGadget->setPosition(mWindow.getSize().x / 2 - mLeftGadget->getSize().x - 10,
|
||||
mWindow.getSize().y - mLeftGadget->getSize().y);
|
||||
mRightGadget->setPosition(mWindow.getSize().x / 2 + 10,
|
||||
mWindow.getSize().y - mRightGadget->getSize().y);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -48,6 +48,8 @@ private:
|
|||
tgui::Label* mHealth;
|
||||
tgui::Label* mAmmo;
|
||||
tgui::Label* mCurrentWeapon;
|
||||
tgui::Label* mLeftGadget;
|
||||
tgui::Label* mRightGadget;
|
||||
|
||||
World mWorld;
|
||||
Pathfinder mPathfinder;
|
||||
|
|
|
@ -240,6 +240,16 @@ Character::useRightGadget() {
|
|||
mRightGadget->use(*this);
|
||||
}
|
||||
|
||||
std::string
|
||||
Character::getLeftGadgetName() const {
|
||||
return mLeftGadget->getName();
|
||||
}
|
||||
|
||||
std::string
|
||||
Character::getRightGadgetName() const {
|
||||
return mRightGadget->getName();
|
||||
}
|
||||
|
||||
int
|
||||
Character::getHealth() const {
|
||||
return mCurrentHealth;
|
||||
|
|
|
@ -61,6 +61,8 @@ protected:
|
|||
void setRightGadget(std::shared_ptr<Gadget> gadget);
|
||||
void useLeftGadget();
|
||||
void useRightGadget();
|
||||
std::string getLeftGadgetName() const;
|
||||
std::string getRightGadgetName() const;
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
|
||||
#include "../abstract/Character.h"
|
||||
|
||||
Gadget::Gadget(std::string name) :
|
||||
mName(name) {
|
||||
}
|
||||
|
||||
void
|
||||
Gadget::use(Character& character) {
|
||||
if (mCooldownTimer.isExpired()) {
|
||||
|
@ -16,3 +20,8 @@ Gadget::use(Character& character) {
|
|||
mCooldownTimer.restart(getCooldownTime());
|
||||
}
|
||||
}
|
||||
|
||||
std::string
|
||||
Gadget::getName() const {
|
||||
return mName;
|
||||
}
|
||||
|
|
|
@ -14,8 +14,10 @@ class Character;
|
|||
|
||||
class Gadget {
|
||||
public:
|
||||
virtual void use(Character& character);
|
||||
Gadget(std::string name);
|
||||
void use(Character& character);
|
||||
virtual void onThink(int elapsed) = 0;
|
||||
std::string getName() const;
|
||||
|
||||
protected:
|
||||
virtual void onUse(Character& character) = 0;
|
||||
|
@ -23,6 +25,9 @@ protected:
|
|||
|
||||
protected:
|
||||
thor::Timer mCooldownTimer;
|
||||
|
||||
private:
|
||||
std::string mName;
|
||||
};
|
||||
|
||||
#endif /* DG_GADGET_H_ */
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
|
||||
#include "../abstract/Character.h"
|
||||
|
||||
Heal::Heal() :
|
||||
Gadget("Heal") {
|
||||
}
|
||||
|
||||
void
|
||||
Heal::onUse(Character& character) {
|
||||
mCharacter = &character;
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
#include "Gadget.h"
|
||||
|
||||
class Heal : public Gadget {
|
||||
public:
|
||||
Heal();
|
||||
|
||||
protected:
|
||||
void onUse(Character& character) override;
|
||||
void onThink(int elapsed) override;
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
#include "../sprites/RotatingShield.h"
|
||||
#include "../World.h"
|
||||
|
||||
Shield::Shield() :
|
||||
Gadget("Shield") {
|
||||
}
|
||||
|
||||
void
|
||||
Shield::onUse(Character& character) {
|
||||
mCharacter = &character;
|
||||
|
|
|
@ -14,6 +14,9 @@ class RotatingShield;
|
|||
class Sprite;
|
||||
|
||||
class Shield : public Gadget {
|
||||
public:
|
||||
Shield();
|
||||
|
||||
protected:
|
||||
void onUse(Character& character) override;
|
||||
void onThink(int elapsed) override;
|
||||
|
|
|
@ -48,6 +48,8 @@ public:
|
|||
using Character::useLeftGadget;
|
||||
using Character::useRightGadget;
|
||||
using Character::getHealth;
|
||||
using Character::getLeftGadgetName;
|
||||
using Character::getRightGadgetName;
|
||||
|
||||
private:
|
||||
void onThink(int elapsed) override;
|
||||
|
|
Reference in a new issue