Rendering code stripped out of the GUI code.
This commit is contained in:
parent
009b1e63a7
commit
9397af2a11
9 changed files with 239 additions and 203 deletions
43
gui.hpp
43
gui.hpp
|
@ -4,7 +4,6 @@
|
|||
#include <SFML/Graphics/RenderWindow.hpp>
|
||||
#include <SFML/Graphics/Text.hpp>
|
||||
#include <SFML/Graphics/Sprite.hpp>
|
||||
#include <codecvt>
|
||||
#include <ftxui/component/component.hpp>
|
||||
#include <ftxui/screen/screen.hpp>
|
||||
#include <ftxui/dom/canvas.hpp>
|
||||
|
@ -14,27 +13,13 @@
|
|||
#include "dinkyecs.hpp"
|
||||
#include "components.hpp"
|
||||
#include "sound.hpp"
|
||||
#include "render.hpp"
|
||||
|
||||
using std::string;
|
||||
using ftxui::Canvas, ftxui::Component, ftxui::Screen;
|
||||
|
||||
constexpr int MIN_FONT_SIZE = 20;
|
||||
constexpr int MAX_FONT_SIZE = 140;
|
||||
constexpr int GAME_MAP_X = 90;
|
||||
constexpr int GAME_MAP_Y = 90;
|
||||
constexpr int GAME_MAP_POS = 600;
|
||||
constexpr int SCREEN_X = 40;
|
||||
constexpr int SCREEN_Y = 30;
|
||||
constexpr int VIDEO_X = 1600;
|
||||
constexpr int VIDEO_Y = 900;
|
||||
constexpr int UI_FONT_SIZE=30;
|
||||
constexpr int BASE_MAP_FONT_SIZE=90;
|
||||
|
||||
enum class Value {
|
||||
BLACK=0, DARK_DARK, DARK_MID,
|
||||
DARK_LIGHT, MID, LIGHT_DARK, LIGHT_MID,
|
||||
LIGHT_LIGHT, WHITE, TRANSPARENT
|
||||
};
|
||||
|
||||
struct ActionLog {
|
||||
std::deque<std::string> messages;
|
||||
|
@ -49,42 +34,30 @@ struct ActionLog {
|
|||
|
||||
class GUI {
|
||||
string $status_text = "NOT DEAD";
|
||||
Canvas $canvas;
|
||||
Component $document;
|
||||
Component $map_view;
|
||||
Canvas $canvas;
|
||||
sf::Font $font;
|
||||
sf::Text $ui_text;
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> $converter;
|
||||
sf::RenderWindow $window;
|
||||
Map& $game_map;
|
||||
ActionLog $log;
|
||||
Point $view_port;
|
||||
Screen $screen;
|
||||
Screen $map_screen;
|
||||
sf::Texture $font_texture;
|
||||
std::unordered_map<wchar_t, sf::Sprite> $sprites;
|
||||
Point $view_port;
|
||||
int $map_font_size;
|
||||
sf::Glyph $base_glyph;
|
||||
float $line_spacing;
|
||||
SoundManager $sounds;
|
||||
ActionLog $log;
|
||||
DinkyECS::World& $world;
|
||||
Map& $game_map;
|
||||
SoundManager $sounds;
|
||||
SFMLRender $renderer;
|
||||
|
||||
public:
|
||||
GUI(DinkyECS::World& world, Map& game_map);
|
||||
// disable copying
|
||||
GUI(GUI &gui) = delete;
|
||||
|
||||
sf::Color color(Value val);
|
||||
sf::Color color(int val);
|
||||
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 shake();
|
||||
void run_systems();
|
||||
void resize_map(int new_size);
|
||||
sf::Sprite &get_text_sprite(wchar_t tile);
|
||||
|
||||
int main();
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue