|
|
|
#pragma once
|
|
|
|
#include <SFML/Graphics/Color.hpp>
|
|
|
|
#include <SFML/Graphics/Font.hpp>
|
|
|
|
#include <SFML/Graphics/RenderWindow.hpp>
|
|
|
|
#include <SFML/Graphics/Text.hpp>
|
|
|
|
#include <SFML/Graphics/Sprite.hpp>
|
|
|
|
#include <ftxui/component/component.hpp>
|
|
|
|
#include <ftxui/screen/screen.hpp>
|
|
|
|
#include <ftxui/dom/canvas.hpp>
|
|
|
|
#include <locale>
|
|
|
|
#include <string>
|
|
|
|
#include "map.hpp"
|
|
|
|
#include "dinkyecs.hpp"
|
|
|
|
#include "components.hpp"
|
|
|
|
#include "sound.hpp"
|
|
|
|
#include "render.hpp"
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
using ftxui::Canvas, ftxui::Component, ftxui::Screen;
|
|
|
|
|
|
|
|
constexpr int SCREEN_X = 40;
|
|
|
|
constexpr int SCREEN_Y = 30;
|
|
|
|
|
|
|
|
struct ActionLog {
|
|
|
|
std::deque<std::string> messages;
|
|
|
|
|
|
|
|
void log(std::string msg) {
|
|
|
|
messages.push_front(msg);
|
|
|
|
if(messages.size() > 20) {
|
|
|
|
messages.pop_back();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class GUI {
|
|
|
|
string $status_text = "NOT DEAD";
|
|
|
|
Canvas $canvas;
|
|
|
|
Component $status_ui;
|
|
|
|
Component $prompt;
|
|
|
|
Component $map_view;
|
|
|
|
Map& $game_map;
|
|
|
|
ActionLog $log;
|
|
|
|
Point $view_port;
|
|
|
|
Screen $status_screen;
|
|
|
|
Screen $map_screen;
|
|
|
|
DinkyECS::World& $world;
|
|
|
|
SoundManager $sounds;
|
|
|
|
SFMLRender $renderer;
|
|
|
|
|
|
|
|
public:
|
|
|
|
GUI(DinkyECS::World& world, Map& game_map);
|
|
|
|
// disable copying
|
|
|
|
GUI(GUI &gui) = delete;
|
|
|
|
|
|
|
|
void resize_map(int new_size);
|
|
|
|
void create_renderer();
|
|
|
|
void render_scene();
|
|
|
|
bool handle_ui_events();
|
|
|
|
void handle_world_events();
|
|
|
|
void draw_screen(bool clear=true, float map_off_x=0.0f, float map_off_y=0.0f);
|
|
|
|
void run_systems();
|
|
|
|
void save_world();
|
|
|
|
void shake();
|
|
|
|
|
|
|
|
int main();
|
|
|
|
};
|