A bit of a quick test for the GUI system, but not sure how to make this do more.

This commit is contained in:
Zed A. Shaw 2024-12-02 17:02:59 -05:00
parent 48df9248b2
commit c7607533ce
6 changed files with 48 additions and 7 deletions

41
tests/gui.cpp Normal file
View file

@ -0,0 +1,41 @@
#include <catch2/catch_test_macros.hpp>
#include <fmt/core.h>
#include "gui.hpp"
#include "map.hpp"
#include "dinkyecs.hpp"
#include "worldbuilder.hpp"
#include "save.hpp"
#include "systems.hpp"
#include "collider.hpp"
#include "components.hpp"
using namespace fmt;
using namespace components;
using std::string;
TEST_CASE("load a basic gui run but don't loop", "[render]") {
DinkyECS::World world;
save::load_configs(world);
Map game_map(40, 40);
WorldBuilder builder(game_map);
builder.generate();
const auto &config = world.get_the<MapConfig>();
// configure a player as a fact of the world
Player player{world.entity()};
world.set_the<Player>(player);
world.set<Position>(player.entity, {game_map.place_entity(0)});
world.set<Motion>(player.entity, {0, 0});
world.set<Combat>(player.entity, {100, 10});
world.set<Tile>(player.entity, {config.PLAYER_TILE});
world.set<Inventory>(player.entity, {5});
world.set<LightSource>(player.entity, {6,1});
spatial_map collider;
world.set_the<spatial_map>(collider);
System::init_positions(world);
GUI gui(world, game_map);
gui.main(true); // runs once
}

View file

@ -47,7 +47,7 @@ TEST_CASE("can render a text", "[render]") {
save::load_configs(world);
const auto& config = world.get_the<MapConfig>();
Panel map_view(0, 0, 20, 5, true);
Panel map_view(0, 0, 20, 20, true);
Map map(20,20);
WorldBuilder builder(map);
builder.generate();
@ -72,6 +72,7 @@ TEST_CASE("can render a text", "[render]") {
for(int i = 2; i < 14; i++) {
renderer.resize_grid(i * 10, map_view);
map_canvas = Canvas(map_view.width * 2, map_view.height * 4);
run_renderer(renderer, map_view);
}