Converted the buttons to reflect the actions you can take.

master
Zed A. Shaw 3 weeks ago
parent d7e9944e58
commit b5d93399d5
  1. 13
      combat_ui.cpp
  2. 3
      combat_ui.hpp
  3. 4
      events.hpp
  4. 5
      gui_fsm.cpp

@ -1,7 +1,6 @@
#include "combat_ui.hpp" #include "combat_ui.hpp"
#include "constants.hpp" #include "constants.hpp"
#include "color.hpp" #include "color.hpp"
#include "events.hpp"
namespace gui { namespace gui {
using namespace guecs; using namespace guecs;
@ -14,21 +13,21 @@ namespace gui {
"[*%(100,150)button_attack | *%(100,150)button_block | *%(100,150)button_evade | *%(100,150)button_heal]"); "[*%(100,150)button_attack | *%(100,150)button_block | *%(100,150)button_evade | *%(100,150)button_heal]");
} }
void CombatUI::make_button(std::string name, std::wstring label) { void CombatUI::make_button(std::string name, std::wstring label, Events::GUI event) {
auto button = $gui.entity(name); auto button = $gui.entity(name);
// $gui.set<Sprite>(button, {"leather_pouch-128"}); // $gui.set<Sprite>(button, {"leather_pouch-128"});
$gui.set<Rectangle>(button, {}); $gui.set<Rectangle>(button, {});
$gui.set<Label>(button, {label}); $gui.set<Label>(button, {label});
$gui.set<Clickable>(button, $gui.set<Clickable>(button,
guecs::make_action(*$level.world, Events::GUI::ATTACK)); guecs::make_action(*$level.world, event));
} }
void CombatUI::init() { void CombatUI::init() {
$gui.world().set_the<Background>({$gui.$parser, ColorValue::DARK_MID}); $gui.world().set_the<Background>({$gui.$parser, ColorValue::DARK_MID});
make_button("button_attack", L"Attack"); make_button("button_attack", L"Attack", Events::GUI::ATTACK);
make_button("button_block", L"Block"); make_button("button_block", L"Block", Events::GUI::BLOCK);
make_button("button_evade", L"Evade"); make_button("button_evade", L"Evade", Events::GUI::EVADE);
make_button("button_heal", L"Heal"); make_button("button_heal", L"Heal", Events::GUI::HEAL);
$gui.init(); $gui.init();
} }

@ -3,6 +3,7 @@
#include <SFML/Graphics/RenderWindow.hpp> #include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/Font.hpp> #include <SFML/Graphics/Font.hpp>
#include "guecs.hpp" #include "guecs.hpp"
#include "events.hpp"
namespace gui { namespace gui {
class CombatUI { class CombatUI {
@ -17,6 +18,6 @@ namespace gui {
void update_level(GameLevel &level); void update_level(GameLevel &level);
void set_damage(float percent); void set_damage(float percent);
bool mouse(float x, float y); bool mouse(float x, float y);
void make_button(std::string name, std::wstring label); void make_button(std::string name, std::wstring label, Events::GUI event);
}; };
} }

@ -3,7 +3,9 @@
namespace Events { namespace Events {
enum GUI { enum GUI {
START, COMBAT, LOOT, DEATH, STAIRS_UP, STAIRS_DOWN, TRAP, START, COMBAT, LOOT, DEATH, STAIRS_UP, STAIRS_DOWN, TRAP,
COMBAT_START, NO_NEIGHBORS, ATTACK, UPDATE_SPRITE, ENEMY_SPAWN, NOOP COMBAT_START, NO_NEIGHBORS,
ATTACK, BLOCK, EVADE, HEAL,
UPDATE_SPRITE, ENEMY_SPAWN, NOOP
}; };
struct Combat { struct Combat {

@ -387,6 +387,11 @@ namespace gui {
// std::string(item.data["name"]))); // std::string(item.data["name"])));
$status_ui.log(L"You picked up an item."); $status_ui.log(L"You picked up an item.");
} break; } break;
case eGUI::EVADE:
case eGUI::BLOCK:
case eGUI::HEAL:
dbc::log("YOU NEED TO IMPLEMENT THIS!!!!!");
break;
case eGUI::ATTACK: case eGUI::ATTACK:
event(Event::ATTACK); event(Event::ATTACK);
break; break;

Loading…
Cancel
Save