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
53
render.hpp
Normal file
53
render.hpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
#pragma once
|
||||
|
||||
#include <ftxui/screen/screen.hpp>
|
||||
#include <ftxui/dom/canvas.hpp>
|
||||
#include <SFML/Window.hpp>
|
||||
#include <SFML/System.hpp>
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include "point.hpp"
|
||||
#include <codecvt>
|
||||
|
||||
using ftxui::Canvas, ftxui::Screen;
|
||||
|
||||
constexpr int VIDEO_X = 1600;
|
||||
constexpr int VIDEO_Y = 900;
|
||||
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 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 SFMLRender {
|
||||
sf::RenderWindow $window;
|
||||
int $map_font_size;
|
||||
float $line_spacing;
|
||||
std::unordered_map<wchar_t, sf::Sprite> $sprites;
|
||||
sf::Font $font;
|
||||
sf::Texture $font_texture;
|
||||
sf::Glyph $base_glyph;
|
||||
Canvas& $canvas;
|
||||
Screen& $map_screen;
|
||||
Screen& $screen;
|
||||
sf::Text $ui_text;
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> $converter;
|
||||
|
||||
SFMLRender(Canvas &canvas, Screen &map_screen, Screen &screen);
|
||||
|
||||
// disable copy
|
||||
SFMLRender(SFMLRender &other) = delete;
|
||||
|
||||
sf::Color color(int val);
|
||||
sf::Color color(Value val);
|
||||
sf::Sprite &get_text_sprite(wchar_t tile);
|
||||
bool resize_map(int new_size);
|
||||
void draw_screen(bool clear=true, float map_off_x=0.0f, float map_off_y=0.0f);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue