parent
26685279ce
commit
103793204d
@ -0,0 +1 @@ |
|||||||
|
set makeprg=meson\ compile\ -C\ . |
@ -0,0 +1,58 @@ |
|||||||
|
all: build test |
||||||
|
|
||||||
|
reset: |
||||||
|
ifeq '$(OS)' 'Windows_NT' |
||||||
|
powershell -executionpolicy bypass .\scripts\reset_build.ps1
|
||||||
|
else |
||||||
|
sh -x ./scripts/reset_build.sh
|
||||||
|
endif |
||||||
|
|
||||||
|
%.cpp : %.rl |
||||||
|
ragel -o $@ $<
|
||||||
|
|
||||||
|
build: lel_parser.cpp |
||||||
|
meson compile -j 10 -C builddir
|
||||||
|
|
||||||
|
release_build: |
||||||
|
meson --wipe builddir -Db_ndebug=true --buildtype release
|
||||||
|
meson compile -j 10 -C builddir
|
||||||
|
|
||||||
|
debug_build: |
||||||
|
meson setup --wipe builddir -Db_ndebug=true --buildtype debugoptimized
|
||||||
|
meson compile -j 10 -C builddir
|
||||||
|
|
||||||
|
tracy_build: |
||||||
|
meson setup --wipe builddir --buildtype debugoptimized -Dtracy_enable=true -Dtracy:on_demand=true
|
||||||
|
meson compile -j 10 -C builddir
|
||||||
|
|
||||||
|
test: build |
||||||
|
./builddir/runtests
|
||||||
|
|
||||||
|
run: build test |
||||||
|
ifeq '$(OS)' 'Windows_NT' |
||||||
|
powershell "cp ./builddir/calculator.exe ."
|
||||||
|
./calculator
|
||||||
|
else |
||||||
|
./builddir/calculator
|
||||||
|
endif |
||||||
|
|
||||||
|
debug: build |
||||||
|
gdb --nx -x .gdbinit --ex run --args builddir/calculator
|
||||||
|
|
||||||
|
debug_run: build |
||||||
|
gdb --nx -x .gdbinit --batch --ex run --ex bt --ex q --args builddir/calculator
|
||||||
|
|
||||||
|
debug_walk: build test |
||||||
|
gdb --nx -x .gdbinit --batch --ex run --ex bt --ex q --args builddir/calculator t
|
||||||
|
|
||||||
|
clean: |
||||||
|
meson compile --clean -C builddir
|
||||||
|
|
||||||
|
debug_test: build |
||||||
|
gdb --nx -x .gdbinit --ex run --args builddir/runtests -e
|
||||||
|
|
||||||
|
win_installer: |
||||||
|
powershell 'start "C:\Program Files (x86)\solicus\InstallForge\bin\ifbuilderenvx86.exe" scripts\win_installer.ifp'
|
||||||
|
|
||||||
|
coverage_report: |
||||||
|
powershell 'scripts/coverage_report.ps1'
|
@ -0,0 +1,47 @@ |
|||||||
|
#include "dbc.hpp" |
||||||
|
#include <iostream> |
||||||
|
|
||||||
|
void dbc::log(const string &message, const std::source_location location) { |
||||||
|
std::cout << '[' << location.file_name() << ':' |
||||||
|
<< location.line() << "|" |
||||||
|
<< location.function_name() << "] " |
||||||
|
<< message << std::endl; |
||||||
|
} |
||||||
|
|
||||||
|
void dbc::sentinel(const string &message, const std::source_location location) { |
||||||
|
string err = fmt::format("[SENTINEL!] {}", message); |
||||||
|
dbc::log(err, location); |
||||||
|
throw dbc::SentinelError{err}; |
||||||
|
} |
||||||
|
|
||||||
|
void dbc::pre(const string &message, bool test, const std::source_location location) { |
||||||
|
if(!test) { |
||||||
|
string err = fmt::format("[PRE!] {}", message); |
||||||
|
dbc::log(err, location); |
||||||
|
throw dbc::PreCondError{err}; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void dbc::pre(const string &message, std::function<bool()> tester, const std::source_location location) { |
||||||
|
dbc::pre(message, tester(), location); |
||||||
|
} |
||||||
|
|
||||||
|
void dbc::post(const string &message, bool test, const std::source_location location) { |
||||||
|
if(!test) { |
||||||
|
string err = fmt::format("[POST!] {}", message); |
||||||
|
dbc::log(err, location); |
||||||
|
throw dbc::PostCondError{err}; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void dbc::post(const string &message, std::function<bool()> tester, const std::source_location location) { |
||||||
|
dbc::post(message, tester(), location); |
||||||
|
} |
||||||
|
|
||||||
|
void dbc::check(bool test, const string &message, const std::source_location location) { |
||||||
|
if(!test) { |
||||||
|
string err = fmt::format("[CHECK!] {}\n", message); |
||||||
|
dbc::log(err, location); |
||||||
|
throw dbc::CheckError{err}; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,50 @@ |
|||||||
|
#pragma once |
||||||
|
|
||||||
|
#include <string> |
||||||
|
#include <fmt/core.h> |
||||||
|
#include <functional> |
||||||
|
#include <source_location> |
||||||
|
|
||||||
|
using std::string; |
||||||
|
|
||||||
|
namespace dbc { |
||||||
|
class Error { |
||||||
|
public: |
||||||
|
const string message; |
||||||
|
Error(string m) : message{m} {} |
||||||
|
Error(const char *m) : message{m} {} |
||||||
|
}; |
||||||
|
|
||||||
|
class CheckError : public Error {}; |
||||||
|
class SentinelError : public Error {}; |
||||||
|
class PreCondError : public Error {}; |
||||||
|
class PostCondError : public Error {}; |
||||||
|
|
||||||
|
void log(const string &message, |
||||||
|
const std::source_location location = |
||||||
|
std::source_location::current()); |
||||||
|
|
||||||
|
[[noreturn]] void sentinel(const string &message, |
||||||
|
const std::source_location location = |
||||||
|
std::source_location::current()); |
||||||
|
|
||||||
|
void pre(const string &message, bool test, |
||||||
|
const std::source_location location = |
||||||
|
std::source_location::current()); |
||||||
|
|
||||||
|
void pre(const string &message, std::function<bool()> tester, |
||||||
|
const std::source_location location = |
||||||
|
std::source_location::current()); |
||||||
|
|
||||||
|
void post(const string &message, bool test, |
||||||
|
const std::source_location location = |
||||||
|
std::source_location::current()); |
||||||
|
|
||||||
|
void post(const string &message, std::function<bool()> tester, |
||||||
|
const std::source_location location = |
||||||
|
std::source_location::current()); |
||||||
|
|
||||||
|
void check(bool test, const string &message, |
||||||
|
const std::source_location location = |
||||||
|
std::source_location::current()); |
||||||
|
} |
@ -0,0 +1,354 @@ |
|||||||
|
#include "guecs.hpp" |
||||||
|
#include "shaders.hpp" |
||||||
|
#include "sound.hpp" |
||||||
|
#include "textures.hpp" |
||||||
|
#include <typeinfo> |
||||||
|
|
||||||
|
namespace guecs { |
||||||
|
using std::make_shared; |
||||||
|
|
||||||
|
void Textual::init(lel::Cell &cell, shared_ptr<sf::Font> font_ptr) { |
||||||
|
dbc::check(font_ptr != nullptr, "you failed to initialize this WideText"); |
||||||
|
if(font == nullptr) font = font_ptr; |
||||||
|
if(text == nullptr) text = make_shared<sf::Text>(*font, content, size); |
||||||
|
text->setFillColor(color); |
||||||
|
|
||||||
|
if(centered) { |
||||||
|
auto bounds = text->getLocalBounds(); |
||||||
|
auto text_cell = lel::center(bounds.size.x, bounds.size.y, cell); |
||||||
|
// this stupid / 2 is because SFML renders from baseline rather than from the claimed bounding box
|
||||||
|
text->setPosition({float(text_cell.x), float(text_cell.y) - text_cell.h / 2}); |
||||||
|
} else { |
||||||
|
text->setPosition({float(cell.x + padding * 2), float(cell.y + padding * 2)}); |
||||||
|
} |
||||||
|
|
||||||
|
text->setCharacterSize(size); |
||||||
|
} |
||||||
|
|
||||||
|
void Textual::update(const wstring& new_content) { |
||||||
|
content = new_content; |
||||||
|
text->setString(content); |
||||||
|
} |
||||||
|
|
||||||
|
void Sprite::update(const string& new_name) { |
||||||
|
if(new_name != name) { |
||||||
|
name = new_name; |
||||||
|
auto sprite_texture = textures::get(name); |
||||||
|
sprite->setTexture(*sprite_texture.texture); |
||||||
|
sprite->setTextureRect(sprite_texture.sprite->getTextureRect()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void Sprite::init(lel::Cell &cell) { |
||||||
|
auto sprite_texture = textures::get(name); |
||||||
|
|
||||||
|
sprite = make_shared<sf::Sprite>( |
||||||
|
*sprite_texture.texture, |
||||||
|
sprite_texture.sprite->getTextureRect()); |
||||||
|
|
||||||
|
sprite->setPosition({ |
||||||
|
float(cell.x + padding), |
||||||
|
float(cell.y + padding)}); |
||||||
|
|
||||||
|
auto bounds = sprite->getLocalBounds(); |
||||||
|
|
||||||
|
sprite->setScale({ |
||||||
|
float(cell.w - padding * 2) / bounds.size.x, |
||||||
|
float(cell.h - padding * 2) / bounds.size.y}); |
||||||
|
} |
||||||
|
|
||||||
|
void Rectangle::init(lel::Cell& cell) { |
||||||
|
sf::Vector2f size{float(cell.w) - padding * 2, float(cell.h) - padding * 2}; |
||||||
|
if(shape == nullptr) shape = make_shared<sf::RectangleShape>(size); |
||||||
|
shape->setPosition({float(cell.x + padding), float(cell.y + padding)}); |
||||||
|
shape->setFillColor(color); |
||||||
|
shape->setOutlineColor(border_color); |
||||||
|
shape->setOutlineThickness(border_px); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
void Meter::init(lel::Cell& cell) { |
||||||
|
bar.init(cell); |
||||||
|
} |
||||||
|
|
||||||
|
void Meter::render(lel::Cell& cell) { |
||||||
|
float level = std::clamp(percent, 0.0f, 1.0f) * float(cell.w); |
||||||
|
// ZED: this 6 is a border width, make it a thing
|
||||||
|
bar.shape->setSize({std::max(level, 0.0f), float(cell.h - 6)}); |
||||||
|
} |
||||||
|
|
||||||
|
void Sound::play(bool hover) { |
||||||
|
if(!hover) { |
||||||
|
sound::play(on_click); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void Sound::stop(bool hover) { |
||||||
|
if(!hover) { |
||||||
|
sound::stop(on_click); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void Background::init() { |
||||||
|
sf::Vector2f size{float(w), float(h)}; |
||||||
|
if(shape == nullptr) shape = make_shared<sf::RectangleShape>(size); |
||||||
|
shape->setPosition({float(x), float(y)}); |
||||||
|
shape->setFillColor(color); |
||||||
|
} |
||||||
|
|
||||||
|
void Effect::init(lel::Cell &cell) { |
||||||
|
$shader_version = shaders::version(); |
||||||
|
$shader = shaders::get(name); |
||||||
|
$shader->setUniform("u_resolution", sf::Vector2f({float(cell.w), float(cell.h)})); |
||||||
|
$clock = std::make_shared<sf::Clock>(); |
||||||
|
} |
||||||
|
|
||||||
|
void Effect::step() { |
||||||
|
sf::Time cur_time = $clock->getElapsedTime(); |
||||||
|
float u_time = cur_time.asSeconds(); |
||||||
|
|
||||||
|
if(u_time < $u_time_end) { |
||||||
|
$shader->setUniform("u_duration", duration); |
||||||
|
$shader->setUniform("u_time_end", $u_time_end); |
||||||
|
$shader->setUniform("u_time", u_time); |
||||||
|
} else { |
||||||
|
$active = false; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void Effect::run() { |
||||||
|
$active = true; |
||||||
|
sf::Time u_time = $clock->getElapsedTime(); |
||||||
|
$u_time_end = u_time.asSeconds() + duration; |
||||||
|
} |
||||||
|
|
||||||
|
shared_ptr<sf::Shader> Effect::checkout_ptr() { |
||||||
|
if(shaders::updated($shader_version)) { |
||||||
|
$shader = shaders::get(name); |
||||||
|
$shader_version = shaders::version(); |
||||||
|
} |
||||||
|
|
||||||
|
return $shader; |
||||||
|
} |
||||||
|
|
||||||
|
void Effect::stop() { |
||||||
|
$active = false; |
||||||
|
} |
||||||
|
|
||||||
|
UI::UI() { |
||||||
|
$font = make_shared<sf::Font>(FONT_FILE_NAME); |
||||||
|
} |
||||||
|
|
||||||
|
void UI::position(int x, int y, int width, int height) { |
||||||
|
$parser.position(x, y, width, height); |
||||||
|
} |
||||||
|
|
||||||
|
sf::Vector2f UI::get_position() { |
||||||
|
return {float($parser.grid_x), float($parser.grid_y)}; |
||||||
|
} |
||||||
|
|
||||||
|
sf::Vector2f UI::get_size() { |
||||||
|
return {float($parser.grid_w), float($parser.grid_h)}; |
||||||
|
} |
||||||
|
|
||||||
|
void UI::layout(const string& grid) { |
||||||
|
$grid = grid; |
||||||
|
bool good = $parser.parse($grid); |
||||||
|
dbc::check(good, "LEL parsing failed."); |
||||||
|
|
||||||
|
for(auto& [name, cell] : $parser.cells) { |
||||||
|
auto ent = init_entity(name); |
||||||
|
set<lel::Cell>(ent, cell); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
Entity UI::init_entity(const string& name) { |
||||||
|
auto ent = entity(); |
||||||
|
// this lets you look up an entity by name
|
||||||
|
$name_ents.insert_or_assign(name, ent); |
||||||
|
// this makes it easier to get the name during querying
|
||||||
|
set<CellName>(ent, {name}); |
||||||
|
return ent; |
||||||
|
} |
||||||
|
|
||||||
|
Entity UI::entity(const string& name) { |
||||||
|
dbc::check($name_ents.contains(name), |
||||||
|
fmt::format("GUECS entity {} does not exist. Mispelled cell name?", name)); |
||||||
|
return $name_ents.at(name); |
||||||
|
} |
||||||
|
|
||||||
|
Entity UI::entity(const string& name, int id) { |
||||||
|
return entity(fmt::format("{}{}", name, id)); |
||||||
|
} |
||||||
|
|
||||||
|
void UI::init() { |
||||||
|
query<Background>([](auto, auto& bg) { |
||||||
|
bg.init(); |
||||||
|
}); |
||||||
|
|
||||||
|
query<lel::Cell, Rectangle>([](auto, auto& cell, auto& rect) { |
||||||
|
rect.init(cell); |
||||||
|
}); |
||||||
|
|
||||||
|
query<lel::Cell, Effect>([](auto, auto& cell, auto& shader) { |
||||||
|
shader.init(cell); |
||||||
|
}); |
||||||
|
|
||||||
|
query<Rectangle, Meter>([](auto, auto& bg, auto &meter) { |
||||||
|
bg.shape->setFillColor(meter.color); |
||||||
|
}); |
||||||
|
|
||||||
|
query<lel::Cell, Meter>([](auto, auto &cell, auto& meter) { |
||||||
|
meter.init(cell); |
||||||
|
}); |
||||||
|
|
||||||
|
query<lel::Cell, Textual>([this](auto, auto& cell, auto& text) { |
||||||
|
text.init(cell, $font); |
||||||
|
}); |
||||||
|
|
||||||
|
query<lel::Cell, Label>([this](auto, auto& cell, auto& text) { |
||||||
|
text.init(cell, $font); |
||||||
|
}); |
||||||
|
|
||||||
|
query<lel::Cell, Sprite>([&](auto, auto &cell, auto &sprite) { |
||||||
|
sprite.init(cell); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void UI::debug_layout(sf::RenderWindow& window) { |
||||||
|
query<lel::Cell>([&](const auto, auto &cell) { |
||||||
|
sf::RectangleShape rect{{float(cell.w), float(cell.h)}}; |
||||||
|
rect.setPosition({float(cell.x), float(cell.y)}); |
||||||
|
rect.setFillColor(sf::Color::Transparent); |
||||||
|
rect.setOutlineColor(sf::Color::Red); |
||||||
|
rect.setOutlineThickness(2.0f); |
||||||
|
window.draw(rect); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void UI::render(sf::RenderWindow& window) { |
||||||
|
if(auto bg = get_if<Background>(MAIN)) { |
||||||
|
window.draw(*(bg->shape)); |
||||||
|
} |
||||||
|
|
||||||
|
query<Effect>([&](auto, auto& shader) { |
||||||
|
if(shader.$active) shader.step(); |
||||||
|
}); |
||||||
|
|
||||||
|
query<Rectangle>([&](auto ent, auto& rect) { |
||||||
|
render_helper(window, ent, true, rect.shape); |
||||||
|
}); |
||||||
|
|
||||||
|
query<lel::Cell, Meter>([&](auto ent, auto& cell, auto &meter) { |
||||||
|
meter.render(cell); |
||||||
|
render_helper(window, ent, true, meter.bar.shape); |
||||||
|
}); |
||||||
|
|
||||||
|
query<Sprite>([&](auto ent, auto& sprite) { |
||||||
|
render_helper(window, ent, false, sprite.sprite); |
||||||
|
}); |
||||||
|
|
||||||
|
query<Label>([&](auto ent, auto& text) { |
||||||
|
render_helper(window, ent, false, text.text); |
||||||
|
}); |
||||||
|
|
||||||
|
query<Textual>([&](auto ent, auto& text) { |
||||||
|
render_helper(window, ent, true, text.text); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
bool UI::mouse(float x, float y, bool hover) { |
||||||
|
int action_count = 0; |
||||||
|
|
||||||
|
query<lel::Cell>([&](auto ent, auto& cell) { |
||||||
|
if((x >= cell.x && x <= cell.x + cell.w) && |
||||||
|
(y >= cell.y && y <= cell.y + cell.h)) |
||||||
|
{ |
||||||
|
do_if<Effect>(ent, [hover](auto& effect) { |
||||||
|
effect.$shader->setUniform("hover", hover); |
||||||
|
effect.run(); |
||||||
|
}); |
||||||
|
|
||||||
|
do_if<Sound>(ent, [hover](auto& sound) { |
||||||
|
// here set that it played then only play once
|
||||||
|
sound.play(hover); |
||||||
|
}); |
||||||
|
|
||||||
|
if(hover) return; |
||||||
|
|
||||||
|
click_on(ent); |
||||||
|
|
||||||
|
action_count++; |
||||||
|
} else { |
||||||
|
do_if<Effect>(ent, [hover](auto& effect) { |
||||||
|
effect.stop(); |
||||||
|
}); |
||||||
|
|
||||||
|
do_if<Sound>(ent, [hover](auto& sound) { |
||||||
|
// here set that it played then only play once
|
||||||
|
sound.stop(hover); |
||||||
|
}); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
return action_count > 0; |
||||||
|
} |
||||||
|
|
||||||
|
void UI::show_sprite(const string& region, const string& sprite_name) { |
||||||
|
auto ent = entity(region); |
||||||
|
|
||||||
|
if(auto sprite = get_if<Sprite>(ent)) { |
||||||
|
sprite->update(sprite_name); |
||||||
|
} else { |
||||||
|
set_init<Sprite>(ent, {sprite_name}); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void UI::show_text(const string& region, const wstring& content) { |
||||||
|
auto ent = entity(region); |
||||||
|
|
||||||
|
if(auto tc = get_if<Textual>(ent)) { |
||||||
|
tc->text->setString(content); |
||||||
|
} else { |
||||||
|
auto &cell = cell_for(ent); |
||||||
|
Textual to_set{content, TEXT_SIZE}; |
||||||
|
to_set.init(cell, $font); |
||||||
|
set<Textual>(ent, to_set); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void UI::click_on(const string& name, bool required) { |
||||||
|
auto ent = entity(name); |
||||||
|
|
||||||
|
if(required) { |
||||||
|
dbc::check(has<Clickable>(ent), |
||||||
|
fmt::format("click_on required '{}' to exist but it doesn't", name)); |
||||||
|
} |
||||||
|
|
||||||
|
click_on(ent); |
||||||
|
} |
||||||
|
|
||||||
|
void UI::click_on(Entity ent) { |
||||||
|
if(auto clicked = get_if<Clickable>(ent)) { |
||||||
|
if(auto action_data = get_if<ActionData>(ent)) { |
||||||
|
clicked->action(ent, action_data->data); |
||||||
|
} else { |
||||||
|
clicked->action(ent, {}); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void UI::show_label(const string& region, const wstring& content) { |
||||||
|
auto ent = entity(region); |
||||||
|
|
||||||
|
if(auto tc = get_if<Label>(ent)) { |
||||||
|
tc->text->setString(content); |
||||||
|
} else { |
||||||
|
auto &cell = cell_for(ent); |
||||||
|
Label to_set{content, LABEL_SIZE}; |
||||||
|
to_set.init(cell, $font); |
||||||
|
to_set.text->setFillColor(TEXT_COLOR); |
||||||
|
set<Label>(ent, to_set); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,340 @@ |
|||||||
|
#pragma once |
||||||
|
#include "dbc.hpp" |
||||||
|
#include "color.hpp" |
||||||
|
#include "lel.hpp" |
||||||
|
#include <string> |
||||||
|
#include <memory> |
||||||
|
#include <SFML/Graphics.hpp> |
||||||
|
#include <functional> |
||||||
|
#include "events.hpp" |
||||||
|
#include <any> |
||||||
|
#include <queue> |
||||||
|
#include <typeindex> |
||||||
|
#include <unordered_map> |
||||||
|
|
||||||
|
namespace guecs { |
||||||
|
constexpr const int PADDING = 3; |
||||||
|
constexpr const int BORDER_PX = 1; |
||||||
|
constexpr const int TEXT_SIZE = 30; |
||||||
|
constexpr const int LABEL_SIZE = 20; |
||||||
|
constexpr const sf::Color FILL_COLOR = ColorValue::DARK_MID; |
||||||
|
constexpr const sf::Color TEXT_COLOR = ColorValue::LIGHT_LIGHT; |
||||||
|
constexpr const sf::Color BG_COLOR = ColorValue::MID; |
||||||
|
constexpr const sf::Color BORDER_COLOR = ColorValue::MID; |
||||||
|
constexpr const char *FONT_FILE_NAME="assets/text.otf"; |
||||||
|
|
||||||
|
using std::shared_ptr, std::wstring, std::string; |
||||||
|
|
||||||
|
using Entity = unsigned long; |
||||||
|
|
||||||
|
using EntityMap = std::unordered_map<Entity, size_t>; |
||||||
|
|
||||||
|
template <typename T> |
||||||
|
struct ComponentStorage { |
||||||
|
std::vector<T> data; |
||||||
|
std::queue<size_t> free_indices; |
||||||
|
}; |
||||||
|
|
||||||
|
struct Textual { |
||||||
|
std::wstring content; |
||||||
|
unsigned int size = TEXT_SIZE; |
||||||
|
sf::Color color = TEXT_COLOR; |
||||||
|
int padding = PADDING; |
||||||
|
bool centered = false; |
||||||
|
shared_ptr<sf::Font> font = nullptr; |
||||||
|
shared_ptr<sf::Text> text = nullptr; |
||||||
|
|
||||||
|
void init(lel::Cell &cell, shared_ptr<sf::Font> font_ptr); |
||||||
|
void update(const std::wstring& new_content); |
||||||
|
}; |
||||||
|
|
||||||
|
struct Label : public Textual { |
||||||
|
template<typename... Args> |
||||||
|
Label(Args... args) : Textual(args...) |
||||||
|
{ |
||||||
|
centered = true; |
||||||
|
size = LABEL_SIZE; |
||||||
|
} |
||||||
|
|
||||||
|
Label() { |
||||||
|
centered = true; |
||||||
|
}; |
||||||
|
}; |
||||||
|
|
||||||
|
struct Clickable { |
||||||
|
/* This is actually called by UI::mouse and passed the entity ID of the
|
||||||
|
* button pressed so you can interact with it in the event handler. |
||||||
|
*/ |
||||||
|
std::function<void(Entity ent, std::any data)> action; |
||||||
|
}; |
||||||
|
|
||||||
|
struct Sprite { |
||||||
|
string name; |
||||||
|
int padding = PADDING; |
||||||
|
std::shared_ptr<sf::Sprite> sprite = nullptr; |
||||||
|
|
||||||
|
void init(lel::Cell &cell); |
||||||
|
void update(const string& new_name); |
||||||
|
}; |
||||||
|
|
||||||
|
struct Rectangle { |
||||||
|
int padding = PADDING; |
||||||
|
sf::Color color = FILL_COLOR; |
||||||
|
sf::Color border_color = BORDER_COLOR; |
||||||
|
int border_px = BORDER_PX; |
||||||
|
shared_ptr<sf::RectangleShape> shape = nullptr; |
||||||
|
|
||||||
|
void init(lel::Cell& cell); |
||||||
|
}; |
||||||
|
|
||||||
|
struct Meter { |
||||||
|
float percent = 1.0f; |
||||||
|
sf::Color color = ColorValue::BLACK; |
||||||
|
Rectangle bar; |
||||||
|
|
||||||
|
void init(lel::Cell& cell); |
||||||
|
void render(lel::Cell& cell); |
||||||
|
}; |
||||||
|
|
||||||
|
struct ActionData { |
||||||
|
std::any data; |
||||||
|
}; |
||||||
|
|
||||||
|
struct CellName { |
||||||
|
string name; |
||||||
|
}; |
||||||
|
|
||||||
|
struct Effect { |
||||||
|
float duration = 0.1f; |
||||||
|
string name{"ui_shader"}; |
||||||
|
float $u_time_end = 0.0; |
||||||
|
bool $active = false; |
||||||
|
std::shared_ptr<sf::Clock> $clock = nullptr; |
||||||
|
std::shared_ptr<sf::Shader> $shader = nullptr; |
||||||
|
int $shader_version = 0; |
||||||
|
|
||||||
|
void init(lel::Cell &cell); |
||||||
|
void run(); |
||||||
|
void stop(); |
||||||
|
void step(); |
||||||
|
shared_ptr<sf::Shader> checkout_ptr(); |
||||||
|
}; |
||||||
|
|
||||||
|
struct Sound { |
||||||
|
string on_click{"ui_click"}; |
||||||
|
void play(bool hover); |
||||||
|
void stop(bool hover); |
||||||
|
}; |
||||||
|
|
||||||
|
struct Background { |
||||||
|
float x = 0.0f; |
||||||
|
float y = 0.0f; |
||||||
|
float w = 0.0f; |
||||||
|
float h = 0.0f; |
||||||
|
sf::Color color = BG_COLOR; |
||||||
|
shared_ptr<sf::RectangleShape> shape = nullptr; |
||||||
|
|
||||||
|
Background(lel::Parser& parser, sf::Color bg_color=BG_COLOR) : |
||||||
|
x(parser.grid_x), |
||||||
|
y(parser.grid_y), |
||||||
|
w(parser.grid_w), |
||||||
|
h(parser.grid_h), |
||||||
|
color(bg_color) |
||||||
|
{} |
||||||
|
|
||||||
|
Background() {} |
||||||
|
|
||||||
|
void init(); |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
class UI { |
||||||
|
public: |
||||||
|
Entity MAIN = 0; |
||||||
|
unsigned long entity_count = 1; |
||||||
|
std::unordered_map<std::type_index, EntityMap> $components; |
||||||
|
std::unordered_map<std::type_index, std::any> $component_storages; |
||||||
|
std::unordered_map<string, Entity> $name_ents; |
||||||
|
shared_ptr<sf::Font> $font = nullptr; |
||||||
|
lel::Parser $parser; |
||||||
|
string $grid = ""; |
||||||
|
|
||||||
|
UI(); |
||||||
|
|
||||||
|
void position(int x, int y, int width, int height); |
||||||
|
sf::Vector2f get_position(); |
||||||
|
sf::Vector2f get_size(); |
||||||
|
void layout(const string& grid); |
||||||
|
Entity init_entity(const string& name); |
||||||
|
Entity entity(const string& name); |
||||||
|
Entity entity(const string& name, int id); |
||||||
|
|
||||||
|
inline lel::CellMap& cells() { |
||||||
|
return $parser.cells; |
||||||
|
} |
||||||
|
|
||||||
|
void init(); |
||||||
|
void render(sf::RenderWindow& window); |
||||||
|
bool mouse(float x, float y, bool hover); |
||||||
|
void click_on(const string& name, bool required=false); |
||||||
|
void click_on(Entity slot_id); |
||||||
|
void debug_layout(sf::RenderWindow& window); |
||||||
|
|
||||||
|
Entity entity() { return ++entity_count; } |
||||||
|
|
||||||
|
template <typename Comp> |
||||||
|
size_t make_component() { |
||||||
|
auto &storage = component_storage_for<Comp>(); |
||||||
|
size_t index; |
||||||
|
|
||||||
|
if(!storage.free_indices.empty()) { |
||||||
|
index = storage.free_indices.front(); |
||||||
|
storage.free_indices.pop(); |
||||||
|
} else { |
||||||
|
storage.data.emplace_back(); |
||||||
|
index = storage.data.size() - 1; |
||||||
|
} |
||||||
|
|
||||||
|
return index; |
||||||
|
} |
||||||
|
|
||||||
|
template <typename Comp> |
||||||
|
ComponentStorage<Comp> &component_storage_for() { |
||||||
|
auto type_index = std::type_index(typeid(Comp)); |
||||||
|
$component_storages.try_emplace(type_index, ComponentStorage<Comp>{}); |
||||||
|
return std::any_cast<ComponentStorage<Comp> &>( |
||||||
|
$component_storages.at(type_index)); |
||||||
|
} |
||||||
|
|
||||||
|
template <typename Comp> |
||||||
|
EntityMap &entity_map_for() { |
||||||
|
return $components[std::type_index(typeid(Comp))]; |
||||||
|
} |
||||||
|
|
||||||
|
template <typename Comp> |
||||||
|
void set(Entity ent, Comp val) { |
||||||
|
EntityMap &map = entity_map_for<Comp>(); |
||||||
|
|
||||||
|
if(has<Comp>(ent)) { |
||||||
|
get<Comp>(ent) = val; |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
map.insert_or_assign(ent, make_component<Comp>()); |
||||||
|
get<Comp>(ent) = val; |
||||||
|
} |
||||||
|
|
||||||
|
template <typename Comp> |
||||||
|
Comp& get(Entity ent) { |
||||||
|
EntityMap &map = entity_map_for<Comp>(); |
||||||
|
auto &storage = component_storage_for<Comp>(); |
||||||
|
auto index = map.at(ent); |
||||||
|
return storage.data[index]; |
||||||
|
} |
||||||
|
|
||||||
|
template <typename Comp> |
||||||
|
Comp* get_if(Entity entity) { |
||||||
|
EntityMap &map = entity_map_for<Comp>(); |
||||||
|
auto &storage = component_storage_for<Comp>(); |
||||||
|
if(map.contains(entity)) { |
||||||
|
auto index = map.at(entity); |
||||||
|
return &storage.data[index]; |
||||||
|
} else { |
||||||
|
return nullptr; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
template <typename Comp> |
||||||
|
bool has(Entity ent) { |
||||||
|
EntityMap &map = entity_map_for<Comp>(); |
||||||
|
return map.contains(ent); |
||||||
|
} |
||||||
|
|
||||||
|
template <typename Comp> |
||||||
|
void remove(Entity ent) { |
||||||
|
EntityMap &map = entity_map_for<Comp>(); |
||||||
|
|
||||||
|
if(map.contains(ent)) { |
||||||
|
size_t index = map.at(ent); |
||||||
|
component_storage_for<Comp>().free_indices.push(index); |
||||||
|
} |
||||||
|
|
||||||
|
map.erase(ent); |
||||||
|
} |
||||||
|
|
||||||
|
template <typename Comp> |
||||||
|
void query(std::function<void(Entity, Comp &)> cb) { |
||||||
|
EntityMap &map = entity_map_for<Comp>(); |
||||||
|
|
||||||
|
for(auto &[entity, index] : map) { |
||||||
|
cb(entity, get<Comp>(entity)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
template <typename CompA, typename CompB> |
||||||
|
void query(std::function<void(Entity, CompA &, CompB &)> cb) { |
||||||
|
EntityMap &map_a = entity_map_for<CompA>(); |
||||||
|
EntityMap &map_b = entity_map_for<CompB>(); |
||||||
|
|
||||||
|
for(auto &[entity, index_a] : map_a) { |
||||||
|
if(map_b.contains(entity)) { |
||||||
|
cb(entity, get<CompA>(entity), get<CompB>(entity)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
template <typename Comp> |
||||||
|
void set_init(Entity ent, Comp val) { |
||||||
|
dbc::check(has<lel::Cell>(ent),"WRONG! slot is missing its cell?!"); |
||||||
|
auto& cell = get<lel::Cell>(ent); |
||||||
|
val.init(cell); |
||||||
|
set<Comp>(ent, val); |
||||||
|
} |
||||||
|
|
||||||
|
template <typename Comp> |
||||||
|
void do_if(Entity ent, std::function<void(Comp &)> cb) { |
||||||
|
if(has<Comp>(ent)) { |
||||||
|
cb(get<Comp>(ent)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
lel::Cell& cell_for(Entity ent) { |
||||||
|
return get<lel::Cell>(ent); |
||||||
|
} |
||||||
|
|
||||||
|
lel::Cell& cell_for(const string& name) { |
||||||
|
Entity ent = entity(name); |
||||||
|
return get<lel::Cell>(ent); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
// BUG: close could just be remove with overload
|
||||||
|
template <typename Comp> |
||||||
|
void close(string region) { |
||||||
|
auto ent = entity(region); |
||||||
|
if(has<Comp>(ent)) { |
||||||
|
remove<Comp>(ent); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
template<typename T> |
||||||
|
void render_helper(sf::RenderWindow& window, Entity ent, bool is_shape, T& target) { |
||||||
|
sf::Shader *shader_ptr = nullptr; |
||||||
|
|
||||||
|
if(auto shader = get_if<Effect>(ent)) { |
||||||
|
if(shader->$active && !is_shape) { |
||||||
|
auto ptr = shader->checkout_ptr(); |
||||||
|
ptr->setUniform("is_shape", is_shape); |
||||||
|
// NOTE: this is needed because SFML doesn't handle shared_ptr
|
||||||
|
shader_ptr = ptr.get(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
window.draw(*target, shader_ptr); |
||||||
|
} |
||||||
|
|
||||||
|
void show_sprite(const string& region, const string& sprite_name); |
||||||
|
void show_text(const string& region, const wstring& content); |
||||||
|
void show_label(const string& region, const wstring& content); |
||||||
|
}; |
||||||
|
} |
@ -0,0 +1,18 @@ |
|||||||
|
#include "guecstra.hpp" |
||||||
|
|
||||||
|
namespace guecs { |
||||||
|
|
||||||
|
Clickable make_action(DinkyECS::World& target, Events::GUI event) { |
||||||
|
return {[&, event](auto ent, auto data){ |
||||||
|
// remember that ent is passed in from the UI::mouse handler
|
||||||
|
target.send<Events::GUI>(event, ent, data); |
||||||
|
}}; |
||||||
|
} |
||||||
|
|
||||||
|
Clickable make_action(DinkyECS::World& target, Events::GUI event, std::any data) { |
||||||
|
return {[&, event, data](auto ent, auto){ |
||||||
|
// remember that ent is passed in from the UI::mouse handler
|
||||||
|
target.send<Events::GUI>(event, ent, data); |
||||||
|
}}; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,7 @@ |
|||||||
|
#include "components.hpp" |
||||||
|
#include "guecs.hpp" |
||||||
|
|
||||||
|
namespace guecs { |
||||||
|
Clickable make_action(DinkyECS::World& target, Events::GUI event); |
||||||
|
Clickable make_action(DinkyECS::World& target, Events::GUI event, std::any data); |
||||||
|
} |
@ -0,0 +1,117 @@ |
|||||||
|
#include "lel.hpp" |
||||||
|
#include <fmt/core.h> |
||||||
|
#include "dbc.hpp" |
||||||
|
#include <numeric> |
||||||
|
|
||||||
|
#include "lel_parser.cpp" |
||||||
|
|
||||||
|
namespace lel { |
||||||
|
|
||||||
|
Parser::Parser(int x, int y, int width, int height) : |
||||||
|
grid_x(x), |
||||||
|
grid_y(y), |
||||||
|
grid_w(width), |
||||||
|
grid_h(height), |
||||||
|
cur(0, 0) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
Parser::Parser() : cur(0, 0) { } |
||||||
|
|
||||||
|
void Parser::position(int x, int y, int width, int height) { |
||||||
|
grid_x = x; |
||||||
|
grid_y = y; |
||||||
|
grid_w = width; |
||||||
|
grid_h = height; |
||||||
|
} |
||||||
|
|
||||||
|
void Parser::id(std::string name) { |
||||||
|
if(name != "_") { |
||||||
|
dbc::check(!cells.contains(name), |
||||||
|
fmt::format("duplicate cell name {}", name)); |
||||||
|
cells.insert_or_assign(name, cur); |
||||||
|
} |
||||||
|
|
||||||
|
cur = {cur.col + 1, cur.row}; |
||||||
|
auto& row = grid.back(); |
||||||
|
row.push_back(name); |
||||||
|
} |
||||||
|
|
||||||
|
void Parser::finalize() { |
||||||
|
size_t rows = grid.size(); |
||||||
|
int cell_height = grid_h / rows; |
||||||
|
|
||||||
|
for(auto& row : grid) { |
||||||
|
size_t columns = row.size(); |
||||||
|
int cell_width = grid_w / columns; |
||||||
|
dbc::check(cell_width > 0, "invalid cell width calc"); |
||||||
|
dbc::check(cell_height > 0, "invalid cell height calc"); |
||||||
|
|
||||||
|
for(auto& name : row) { |
||||||
|
if(name == "_") continue; |
||||||
|
auto& cell = cells.at(name); |
||||||
|
|
||||||
|
// ZED: getting a bit hairy but this should work
|
||||||
|
if(cell.percent) { |
||||||
|
// when percent mode we have to take unset to 100%
|
||||||
|
if(cell.max_w == 0) cell.max_w = 100; |
||||||
|
if(cell.max_h == 0) cell.max_h = 100; |
||||||
|
cell.max_w *= cell_width * 0.01; |
||||||
|
cell.max_h *= cell_height * 0.01; |
||||||
|
} else { |
||||||
|
if(cell.max_w == 0) cell.max_w = cell_width; |
||||||
|
if(cell.max_h == 0) cell.max_h = cell_height; |
||||||
|
} |
||||||
|
|
||||||
|
cell.w = cell.expand ? std::min(cell.max_w, grid_w) : std::min(cell_width, cell.max_w); |
||||||
|
cell.h = cell.expand ? std::min(cell.max_h, grid_h) : std::min(cell_height, cell.max_h); |
||||||
|
|
||||||
|
dbc::check(cell.h > 0, fmt::format("invalid height cell {}", name)); |
||||||
|
dbc::check(cell.w > 0, fmt::format("invalid width cell {}", name)); |
||||||
|
|
||||||
|
cell.x = grid_x + (cell.col * cell_width); |
||||||
|
cell.y = grid_y + (cell.row * cell_height); |
||||||
|
|
||||||
|
// keep the midpoint since it is used a lot
|
||||||
|
cell.mid_x = std::midpoint(cell.x, cell.x + cell.w); |
||||||
|
cell.mid_y = std::midpoint(cell.y, cell.y + cell.h); |
||||||
|
|
||||||
|
// perform alignments
|
||||||
|
if(cell.right) cell.x += cell_width - cell.w; |
||||||
|
if(cell.bottom) cell.y += cell_height - cell.h; |
||||||
|
if(cell.center) { |
||||||
|
cell.x = cell.mid_x - cell.w / 2; |
||||||
|
cell.y = cell.mid_y - cell.h / 2; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void Parser::reset() { |
||||||
|
cur = {0, 0}; |
||||||
|
grid.clear(); |
||||||
|
cells.clear(); |
||||||
|
} |
||||||
|
|
||||||
|
std::optional<std::string> Parser::hit(int x, int y) { |
||||||
|
for(auto& [name, cell] : cells) { |
||||||
|
if((x >= cell.x && x <= cell.x + cell.w) && |
||||||
|
(y >= cell.y && y <= cell.y + cell.h)) { |
||||||
|
return name; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return std::nullopt; |
||||||
|
} |
||||||
|
|
||||||
|
Cell center(int width, int height, Cell &parent) { |
||||||
|
Cell copy = parent; |
||||||
|
|
||||||
|
copy.x = parent.mid_x - width / 2; |
||||||
|
copy.y = parent.mid_y - height / 2; |
||||||
|
copy.w = width; |
||||||
|
copy.h = height; |
||||||
|
|
||||||
|
return copy; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,54 @@ |
|||||||
|
#pragma once |
||||||
|
#include <string> |
||||||
|
#include <unordered_map> |
||||||
|
#include <optional> |
||||||
|
#include <vector> |
||||||
|
|
||||||
|
namespace lel { |
||||||
|
|
||||||
|
struct Cell { |
||||||
|
int x = 0; |
||||||
|
int y = 0; |
||||||
|
int w = 0; |
||||||
|
int h = 0; |
||||||
|
int mid_x = 0; |
||||||
|
int mid_y = 0; |
||||||
|
int max_w = 0; |
||||||
|
int max_h = 0; |
||||||
|
int col = 0; |
||||||
|
int row = 0; |
||||||
|
bool right = false; |
||||||
|
bool bottom = false; |
||||||
|
bool expand = false; |
||||||
|
bool center = false; |
||||||
|
bool percent = false; |
||||||
|
|
||||||
|
Cell(int col, int row) : col(col), row(row) {} |
||||||
|
Cell() {} |
||||||
|
}; |
||||||
|
|
||||||
|
using Row = std::vector<std::string>; |
||||||
|
using CellMap = std::unordered_map<std::string, Cell>; |
||||||
|
|
||||||
|
struct Parser { |
||||||
|
int grid_x = 0; |
||||||
|
int grid_y = 0; |
||||||
|
int grid_w = 0; |
||||||
|
int grid_h = 0; |
||||||
|
Cell cur; |
||||||
|
std::vector<Row> grid; |
||||||
|
CellMap cells; |
||||||
|
|
||||||
|
Parser(int x, int y, int width, int height); |
||||||
|
Parser(); |
||||||
|
|
||||||
|
void position(int x, int y, int width, int height); |
||||||
|
void id(std::string name); |
||||||
|
void reset(); |
||||||
|
bool parse(std::string input); |
||||||
|
void finalize(); |
||||||
|
std::optional<std::string> hit(int x, int y); |
||||||
|
}; |
||||||
|
|
||||||
|
Cell center(int width, int height, Cell &parent); |
||||||
|
} |
@ -0,0 +1,261 @@ |
|||||||
|
|
||||||
|
#line 1 "lel_parser.rl" |
||||||
|
#include "lel.hpp" |
||||||
|
#include <fmt/core.h> |
||||||
|
#include <iostream> |
||||||
|
|
||||||
|
namespace lel { |
||||||
|
|
||||||
|
|
||||||
|
#line 40 "lel_parser.rl" |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#line 10 "lel_parser.cpp" |
||||||
|
static const char _Parser_actions[] = { |
||||||
|
0, 1, 1, 1, 2, 1, 3, 1,
|
||||||
|
4, 1, 5, 1, 6, 1, 9, 1,
|
||||||
|
10, 1, 11, 1, 12, 1, 13, 2,
|
||||||
|
0, 7, 2, 0, 8, 2, 4, 1,
|
||||||
|
2, 4, 5 |
||||||
|
}; |
||||||
|
|
||||||
|
static const char _Parser_key_offsets[] = { |
||||||
|
0, 0, 4, 20, 33, 35, 39, 41,
|
||||||
|
44, 56, 61 |
||||||
|
}; |
||||||
|
|
||||||
|
static const char _Parser_trans_keys[] = { |
||||||
|
32, 91, 9, 13, 32, 37, 40, 42,
|
||||||
|
46, 61, 94, 95, 9, 13, 60, 62,
|
||||||
|
65, 90, 97, 122, 37, 40, 42, 46,
|
||||||
|
61, 94, 95, 60, 62, 65, 90, 97,
|
||||||
|
122, 48, 57, 41, 44, 48, 57, 48,
|
||||||
|
57, 41, 48, 57, 32, 93, 95, 124,
|
||||||
|
9, 13, 48, 57, 65, 90, 97, 122,
|
||||||
|
32, 93, 124, 9, 13, 32, 91, 9,
|
||||||
|
13, 0 |
||||||
|
}; |
||||||
|
|
||||||
|
static const char _Parser_single_lengths[] = { |
||||||
|
0, 2, 8, 7, 0, 2, 0, 1,
|
||||||
|
4, 3, 2 |
||||||
|
}; |
||||||
|
|
||||||
|
static const char _Parser_range_lengths[] = { |
||||||
|
0, 1, 4, 3, 1, 1, 1, 1,
|
||||||
|
4, 1, 1 |
||||||
|
}; |
||||||
|
|
||||||
|
static const char _Parser_index_offsets[] = { |
||||||
|
0, 0, 4, 17, 28, 30, 34, 36,
|
||||||
|
39, 48, 53 |
||||||
|
}; |
||||||
|
|
||||||
|
static const char _Parser_indicies[] = { |
||||||
|
0, 2, 0, 1, 3, 4, 5, 6,
|
||||||
|
7, 9, 7, 10, 3, 8, 10, 10,
|
||||||
|
1, 4, 5, 6, 7, 9, 7, 10,
|
||||||
|
8, 10, 10, 1, 11, 1, 12, 13,
|
||||||
|
14, 1, 15, 1, 16, 17, 1, 18,
|
||||||
|
20, 19, 21, 18, 19, 19, 19, 1,
|
||||||
|
22, 23, 24, 22, 1, 25, 2, 25,
|
||||||
|
1, 0 |
||||||
|
}; |
||||||
|
|
||||||
|
static const char _Parser_trans_targs[] = { |
||||||
|
1, 0, 2, 2, 3, 4, 3, 3,
|
||||||
|
3, 3, 8, 5, 3, 6, 5, 7,
|
||||||
|
3, 7, 9, 8, 10, 2, 9, 10,
|
||||||
|
2, 10 |
||||||
|
}; |
||||||
|
|
||||||
|
static const char _Parser_trans_actions[] = { |
||||||
|
0, 0, 3, 0, 17, 0, 13, 5,
|
||||||
|
11, 15, 21, 19, 23, 23, 0, 19,
|
||||||
|
26, 0, 7, 0, 32, 29, 0, 9,
|
||||||
|
1, 0 |
||||||
|
}; |
||||||
|
|
||||||
|
static const int Parser_start = 1; |
||||||
|
static const int Parser_first_final = 10; |
||||||
|
static const int Parser_error = 0; |
||||||
|
|
||||||
|
static const int Parser_en_main = 1; |
||||||
|
|
||||||
|
|
||||||
|
#line 43 "lel_parser.rl" |
||||||
|
|
||||||
|
bool Parser::parse(std::string input) { |
||||||
|
reset(); |
||||||
|
int cs = 0; |
||||||
|
const char *start = nullptr; |
||||||
|
const char *begin = input.data(); |
||||||
|
const char *p = input.data(); |
||||||
|
const char *pe = p + input.size(); |
||||||
|
std::string tk; |
||||||
|
|
||||||
|
|
||||||
|
#line 91 "lel_parser.cpp" |
||||||
|
{ |
||||||
|
cs = Parser_start; |
||||||
|
} |
||||||
|
|
||||||
|
#line 54 "lel_parser.rl" |
||||||
|
|
||||||
|
#line 94 "lel_parser.cpp" |
||||||
|
{ |
||||||
|
int _klen; |
||||||
|
unsigned int _trans; |
||||||
|
const char *_acts; |
||||||
|
unsigned int _nacts; |
||||||
|
const char *_keys; |
||||||
|
|
||||||
|
if ( p == pe ) |
||||||
|
goto _test_eof; |
||||||
|
if ( cs == 0 ) |
||||||
|
goto _out; |
||||||
|
_resume: |
||||||
|
_keys = _Parser_trans_keys + _Parser_key_offsets[cs]; |
||||||
|
_trans = _Parser_index_offsets[cs]; |
||||||
|
|
||||||
|
_klen = _Parser_single_lengths[cs]; |
||||||
|
if ( _klen > 0 ) { |
||||||
|
const char *_lower = _keys; |
||||||
|
const char *_mid; |
||||||
|
const char *_upper = _keys + _klen - 1; |
||||||
|
while (1) { |
||||||
|
if ( _upper < _lower ) |
||||||
|
break; |
||||||
|
|
||||||
|
_mid = _lower + ((_upper-_lower) >> 1); |
||||||
|
if ( (*p) < *_mid ) |
||||||
|
_upper = _mid - 1; |
||||||
|
else if ( (*p) > *_mid ) |
||||||
|
_lower = _mid + 1; |
||||||
|
else { |
||||||
|
_trans += (unsigned int)(_mid - _keys); |
||||||
|
goto _match; |
||||||
|
} |
||||||
|
} |
||||||
|
_keys += _klen; |
||||||
|
_trans += _klen; |
||||||
|
} |
||||||
|
|
||||||
|
_klen = _Parser_range_lengths[cs]; |
||||||
|
if ( _klen > 0 ) { |
||||||
|
const char *_lower = _keys; |
||||||
|
const char *_mid; |
||||||
|
const char *_upper = _keys + (_klen<<1) - 2; |
||||||
|
while (1) { |
||||||
|
if ( _upper < _lower ) |
||||||
|
break; |
||||||
|
|
||||||
|
_mid = _lower + (((_upper-_lower) >> 1) & ~1); |
||||||
|
if ( (*p) < _mid[0] ) |
||||||
|
_upper = _mid - 2; |
||||||
|
else if ( (*p) > _mid[1] ) |
||||||
|
_lower = _mid + 2; |
||||||
|
else { |
||||||
|
_trans += (unsigned int)((_mid - _keys)>>1); |
||||||
|
goto _match; |
||||||
|
} |
||||||
|
} |
||||||
|
_trans += _klen; |
||||||
|
} |
||||||
|
|
||||||
|
_match: |
||||||
|
_trans = _Parser_indicies[_trans]; |
||||||
|
cs = _Parser_trans_targs[_trans]; |
||||||
|
|
||||||
|
if ( _Parser_trans_actions[_trans] == 0 ) |
||||||
|
goto _again; |
||||||
|
|
||||||
|
_acts = _Parser_actions + _Parser_trans_actions[_trans]; |
||||||
|
_nacts = (unsigned int) *_acts++; |
||||||
|
while ( _nacts-- > 0 ) |
||||||
|
{ |
||||||
|
switch ( *_acts++ ) |
||||||
|
{ |
||||||
|
case 0: |
||||||
|
#line 11 "lel_parser.rl" |
||||||
|
{tk = input.substr(start - begin, p - start); } |
||||||
|
break; |
||||||
|
case 1: |
||||||
|
#line 13 "lel_parser.rl" |
||||||
|
{} |
||||||
|
break; |
||||||
|
case 2: |
||||||
|
#line 14 "lel_parser.rl" |
||||||
|
{ grid.push_back(Row()); } |
||||||
|
break; |
||||||
|
case 3: |
||||||
|
#line 15 "lel_parser.rl" |
||||||
|
{ cur.bottom = (*p) == '.'; } |
||||||
|
break; |
||||||
|
case 4: |
||||||
|
#line 16 "lel_parser.rl" |
||||||
|
{ id(input.substr(start - begin, p - start)); } |
||||||
|
break; |
||||||
|
case 5: |
||||||
|
#line 17 "lel_parser.rl" |
||||||
|
{ cur.col = 0; cur.row++; } |
||||||
|
break; |
||||||
|
case 6: |
||||||
|
#line 18 "lel_parser.rl" |
||||||
|
{ cur.right = (*p) == '>'; } |
||||||
|
break; |
||||||
|
case 7: |
||||||
|
#line 19 "lel_parser.rl" |
||||||
|
{cur.max_w = std::stoi(tk); } |
||||||
|
break; |
||||||
|
case 8: |
||||||
|
#line 20 "lel_parser.rl" |
||||||
|
{ cur.max_h = std::stoi(tk); } |
||||||
|
break; |
||||||
|
case 9: |
||||||
|
#line 21 "lel_parser.rl" |
||||||
|
{ cur.expand = true; } |
||||||
|
break; |
||||||
|
case 10: |
||||||
|
#line 22 "lel_parser.rl" |
||||||
|
{ cur.center = true; } |
||||||
|
break; |
||||||
|
case 11: |
||||||
|
#line 23 "lel_parser.rl" |
||||||
|
{ cur.percent = true; } |
||||||
|
break; |
||||||
|
case 12: |
||||||
|
#line 33 "lel_parser.rl" |
||||||
|
{ start = p; } |
||||||
|
break; |
||||||
|
case 13: |
||||||
|
#line 36 "lel_parser.rl" |
||||||
|
{start = p;} |
||||||
|
break; |
||||||
|
#line 209 "lel_parser.cpp" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
_again: |
||||||
|
if ( cs == 0 ) |
||||||
|
goto _out; |
||||||
|
if ( ++p != pe ) |
||||||
|
goto _resume; |
||||||
|
_test_eof: {} |
||||||
|
_out: {} |
||||||
|
} |
||||||
|
|
||||||
|
#line 55 "lel_parser.rl" |
||||||
|
|
||||||
|
bool good = pe - p == 0; |
||||||
|
if(good) { |
||||||
|
finalize(); |
||||||
|
} else { |
||||||
|
dbc::log("error at:"); |
||||||
|
std::cout << p; |
||||||
|
} |
||||||
|
return good; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,66 @@ |
|||||||
|
#include "lel.hpp" |
||||||
|
#include <fmt/core.h> |
||||||
|
#include <iostream> |
||||||
|
|
||||||
|
namespace lel { |
||||||
|
|
||||||
|
%%{ |
||||||
|
machine Parser; |
||||||
|
alphtype char; |
||||||
|
|
||||||
|
action token {tk = input.substr(start - begin, fpc - start); } |
||||||
|
|
||||||
|
action col {} |
||||||
|
action ltab { grid.push_back(Row()); } |
||||||
|
action valign { cur.bottom = fc == '.'; } |
||||||
|
action id { id(input.substr(start - begin, fpc - start)); } |
||||||
|
action row { cur.col = 0; cur.row++; } |
||||||
|
action align { cur.right = fc == '>'; } |
||||||
|
action setwidth {cur.max_w = std::stoi(tk); } |
||||||
|
action setheight { cur.max_h = std::stoi(tk); } |
||||||
|
action expand { cur.expand = true; } |
||||||
|
action center { cur.center = true; } |
||||||
|
action percent { cur.percent = true; } |
||||||
|
|
||||||
|
col = "|" $col; |
||||||
|
ltab = "[" $ltab; |
||||||
|
rtab = "]" $row; |
||||||
|
valign = ("^" | ".") $valign; |
||||||
|
expand = "*" $expand; |
||||||
|
center = "=" $center; |
||||||
|
percent = "%" $percent; |
||||||
|
halign = ("<" | ">") $align; |
||||||
|
number = digit+ >{ start = fpc; } %token; |
||||||
|
setw = ("(" number %setwidth ("," number %setheight)? ")") ; |
||||||
|
modifiers = (percent | center | expand | valign | halign | setw); |
||||||
|
id = modifiers* ((alpha | '_')+ :>> (alnum | '_')*) >{start = fpc;} %id; |
||||||
|
row = space* ltab space* id space* (col space* id space*)* space* rtab space*; |
||||||
|
|
||||||
|
main := row+; |
||||||
|
}%% |
||||||
|
|
||||||
|
%% write data; |
||||||
|
|
||||||
|
bool Parser::parse(std::string input) { |
||||||
|
reset(); |
||||||
|
int cs = 0; |
||||||
|
const char *start = nullptr; |
||||||
|
const char *begin = input.data(); |
||||||
|
const char *p = input.data(); |
||||||
|
const char *pe = p + input.size(); |
||||||
|
std::string tk; |
||||||
|
|
||||||
|
%% write init; |
||||||
|
%% write exec; |
||||||
|
|
||||||
|
bool good = pe - p == 0; |
||||||
|
if(good) { |
||||||
|
finalize(); |
||||||
|
} else { |
||||||
|
dbc::log("error at:"); |
||||||
|
std::cout << p; |
||||||
|
} |
||||||
|
return good; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,91 @@ |
|||||||
|
# clang might need _LIBCPP_ENABLE_CXX26_REMOVED_CODECVT |
||||||
|
|
||||||
|
project('lel-guecs', 'cpp', |
||||||
|
version: '0.1.0', |
||||||
|
default_options: [ |
||||||
|
'cpp_std=c++20', |
||||||
|
'cpp_args=-D_GLIBCXX_DEBUG=1 -D_GLIBCXX_DEBUG_PEDANTIC=1', |
||||||
|
]) |
||||||
|
|
||||||
|
# use this for common options only for our executables |
||||||
|
cpp_args=[] |
||||||
|
link_args=[] |
||||||
|
# these are passed as override_defaults |
||||||
|
exe_defaults = [ 'warning_level=2' ] |
||||||
|
|
||||||
|
cc = meson.get_compiler('cpp') |
||||||
|
dependencies = [] |
||||||
|
|
||||||
|
if build_machine.system() == 'windows' |
||||||
|
add_global_link_arguments( |
||||||
|
'-static-libgcc', |
||||||
|
'-static-libstdc++', |
||||||
|
'-static', |
||||||
|
language: 'cpp', |
||||||
|
) |
||||||
|
|
||||||
|
sfml_main = dependency('sfml_main') |
||||||
|
opengl32 = cc.find_library('opengl32', required: true) |
||||||
|
winmm = cc.find_library('winmm', required: true) |
||||||
|
gdi32 = cc.find_library('gdi32', required: true) |
||||||
|
|
||||||
|
dependencies += [ |
||||||
|
opengl32, winmm, gdi32, sfml_main |
||||||
|
] |
||||||
|
exe_defaults += ['werror=true'] |
||||||
|
|
||||||
|
elif build_machine.system() == 'darwin' |
||||||
|
add_global_link_arguments( |
||||||
|
language: 'cpp', |
||||||
|
) |
||||||
|
|
||||||
|
opengl = dependency('OpenGL') |
||||||
|
corefoundation = dependency('CoreFoundation') |
||||||
|
carbon = dependency('Carbon') |
||||||
|
cocoa = dependency('Cocoa') |
||||||
|
iokit = dependency('IOKit') |
||||||
|
corevideo = dependency('CoreVideo') |
||||||
|
|
||||||
|
link_args += ['-ObjC'] |
||||||
|
exe_defaults += ['werror=false'] |
||||||
|
dependencies += [ |
||||||
|
opengl, corefoundation, carbon, cocoa, iokit, corevideo |
||||||
|
] |
||||||
|
endif |
||||||
|
|
||||||
|
catch2 = subproject('catch2').get_variable('catch2_with_main_dep') |
||||||
|
fmt = subproject('fmt').get_variable('fmt_dep') |
||||||
|
json = subproject('nlohmann_json').get_variable('nlohmann_json_dep') |
||||||
|
freetype2 = subproject('freetype2').get_variable('freetype_dep') |
||||||
|
|
||||||
|
flac = subproject('flac').get_variable('flac_dep') |
||||||
|
ogg = subproject('ogg').get_variable('libogg_dep') |
||||||
|
vorbis = subproject('vorbis').get_variable('vorbis_dep') |
||||||
|
vorbisfile = subproject('vorbis').get_variable('vorbisfile_dep') |
||||||
|
vorbisenc = subproject('vorbis').get_variable('vorbisenc_dep') |
||||||
|
sfml_audio = subproject('sfml').get_variable('sfml_audio_dep') |
||||||
|
sfml_graphics = subproject('sfml').get_variable('sfml_graphics_dep') |
||||||
|
sfml_network = subproject('sfml').get_variable('sfml_network_dep') |
||||||
|
sfml_system = subproject('sfml').get_variable('sfml_system_dep') |
||||||
|
sfml_window = subproject('sfml').get_variable('sfml_window_dep') |
||||||
|
|
||||||
|
dependencies += [ |
||||||
|
fmt, json, freetype2, |
||||||
|
flac, ogg, vorbis, vorbisfile, vorbisenc, |
||||||
|
sfml_audio, sfml_graphics, |
||||||
|
sfml_network, sfml_system, |
||||||
|
sfml_window |
||||||
|
] |
||||||
|
|
||||||
|
sources = [ |
||||||
|
'dbc.cpp', |
||||||
|
'lel.cpp' |
||||||
|
] |
||||||
|
|
||||||
|
executable('runtests', sources + [ |
||||||
|
'tests/lel.cpp', |
||||||
|
], |
||||||
|
cpp_args: cpp_args, |
||||||
|
link_args: link_args, |
||||||
|
override_options: exe_defaults, |
||||||
|
dependencies: dependencies + [catch2]) |
@ -0,0 +1,13 @@ |
|||||||
|
rm -recurse -force coverage/* |
||||||
|
cp *.cpp,*.hpp,*.rl builddir |
||||||
|
|
||||||
|
. .venv/Scripts/activate |
||||||
|
|
||||||
|
rm -recurse -force coverage |
||||||
|
cp scripts\gcovr_patched_coverage.py .venv\Lib\site-packages\gcovr\coverage.py |
||||||
|
|
||||||
|
gcovr -o coverage/ --html --html-details --html-theme github.dark-blue --gcov-ignore-errors all --gcov-ignore-parse-errors negative_hits.warn_once_per_file -e builddir/subprojects -e builddir -e subprojects -j 10 . |
||||||
|
|
||||||
|
rm *.gcov.json.gz |
||||||
|
|
||||||
|
start .\coverage\coverage_details.html |
@ -0,0 +1,7 @@ |
|||||||
|
mv .\subprojects\packagecache . |
||||||
|
rm -recurse -force .\subprojects\,.\builddir\ |
||||||
|
mkdir subprojects |
||||||
|
mv .\packagecache .\subprojects\ |
||||||
|
mkdir builddir |
||||||
|
cp wraps\*.wrap subprojects\ |
||||||
|
meson setup --default-library=static --prefer-static -Db_coverage=true builddir |
@ -0,0 +1,11 @@ |
|||||||
|
#!/usr/bin/env bash |
||||||
|
set -e |
||||||
|
|
||||||
|
mv -f ./subprojects/packagecache . |
||||||
|
rm -rf subprojects builddir |
||||||
|
mkdir subprojects |
||||||
|
mv packagecache ./subprojects/ |
||||||
|
mkdir builddir |
||||||
|
cp wraps/*.wrap subprojects/ |
||||||
|
# on OSX you can't do this with static |
||||||
|
meson setup -Db_coverage=true builddir |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@ |
|||||||
|
mv .\subprojects\packagecache . |
||||||
|
rm -recurse -force .\subprojects\,.\builddir\ |
||||||
|
mkdir subprojects |
||||||
|
mv .\packagecache .\subprojects\ |
||||||
|
mkdir builddir |
||||||
|
cp wraps\*.wrap subprojects\ |
||||||
|
meson setup --default-library=static --prefer-static builddir |
@ -0,0 +1,10 @@ |
|||||||
|
#!/usr/bin/env bash |
||||||
|
|
||||||
|
mv -f ./subprojects/packagecache . |
||||||
|
rm -rf subprojects builddir |
||||||
|
mkdir subprojects |
||||||
|
mv -f packagecache ./subprojects/ && true |
||||||
|
mkdir builddir |
||||||
|
cp wraps/*.wrap subprojects/ |
||||||
|
# on OSX you can't do this with static |
||||||
|
meson setup --default-library=static --prefer-static builddir |
Binary file not shown.
@ -0,0 +1,32 @@ |
|||||||
|
#include <catch2/catch_test_macros.hpp> |
||||||
|
#include <fmt/core.h> |
||||||
|
#include "constants.hpp" |
||||||
|
#include "guecs.hpp" |
||||||
|
#include "textures.hpp" |
||||||
|
#include <fmt/xchar.h> |
||||||
|
|
||||||
|
using namespace guecs; |
||||||
|
|
||||||
|
TEST_CASE("prototype one gui", "[ecs-gui]") { |
||||||
|
guecs::UI gui; |
||||||
|
textures::init(); |
||||||
|
|
||||||
|
gui.position(0, 0, 1000, 500); |
||||||
|
gui.layout("[test1|test2|test3][test4|_|test5]"); |
||||||
|
|
||||||
|
for(auto& [name, cell] : gui.cells()) { |
||||||
|
auto button = gui.entity(name); |
||||||
|
gui.set<lel::Cell>(button, cell); |
||||||
|
gui.set<Rectangle>(button, {}); |
||||||
|
gui.set<Clickable>(button, {}); |
||||||
|
gui.set<Textual>(button, {L"whatever"}); |
||||||
|
} |
||||||
|
|
||||||
|
gui.init(); |
||||||
|
|
||||||
|
// at this point it's mostly ready but I'd need to render it to a window real quick
|
||||||
|
sf::RenderWindow window; |
||||||
|
window.setSize({SCREEN_WIDTH, SCREEN_HEIGHT}); |
||||||
|
gui.render(window); |
||||||
|
window.display(); |
||||||
|
} |
@ -0,0 +1,52 @@ |
|||||||
|
#include "lel.hpp" |
||||||
|
#include <catch2/catch_test_macros.hpp> |
||||||
|
#include <fmt/core.h> |
||||||
|
#include <string> |
||||||
|
|
||||||
|
TEST_CASE("test basic ops", "[lel]") { |
||||||
|
lel::Parser parser(0, 0, 500, 500); |
||||||
|
|
||||||
|
bool good = parser.parse( |
||||||
|
"[ label_1 | label3 | test1]" |
||||||
|
"[ *(300,300)text1 | %(150)people | ^test2]" |
||||||
|
"[ >label2 | _ | .test3]" |
||||||
|
"[ =message | buttons | test4]"); |
||||||
|
|
||||||
|
REQUIRE(good); |
||||||
|
|
||||||
|
for(size_t rowcount = 0; rowcount < parser.grid.size(); rowcount++) { |
||||||
|
auto& row = parser.grid[rowcount]; |
||||||
|
|
||||||
|
for(size_t colcount = 0; colcount < row.size(); colcount++) { |
||||||
|
auto &name = row[colcount]; |
||||||
|
if(name == "_") { |
||||||
|
REQUIRE(!parser.cells.contains(name)); |
||||||
|
} else { |
||||||
|
auto &cell = parser.cells.at(name); |
||||||
|
REQUIRE(cell.row == int(rowcount)); |
||||||
|
REQUIRE(cell.col == int(colcount)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
REQUIRE(parser.cells.size() == 11); |
||||||
|
REQUIRE(parser.cells.at("label2").right == true); |
||||||
|
REQUIRE(parser.cells.at("text1").expand == true); |
||||||
|
REQUIRE(parser.cells.at("text1").w == 300); |
||||||
|
REQUIRE(parser.cells.at("text1").h == 300); |
||||||
|
REQUIRE(parser.cells.at("people").expand == false); |
||||||
|
REQUIRE(parser.cells.at("message").expand == false); |
||||||
|
REQUIRE(parser.cells.at("message").center == true); |
||||||
|
|
||||||
|
for(auto& [name, cell] : parser.cells) { |
||||||
|
REQUIRE(cell.w > 0); |
||||||
|
REQUIRE(cell.h > 0); |
||||||
|
} |
||||||
|
|
||||||
|
auto hit = parser.hit(10, 10); |
||||||
|
REQUIRE(*hit == "label_1"); |
||||||
|
|
||||||
|
auto nohit = parser.hit(1000, 1000); |
||||||
|
REQUIRE(!nohit); |
||||||
|
REQUIRE(nohit == std::nullopt); |
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
[wrap-file] |
||||||
|
directory = Catch2-3.7.1 |
||||||
|
source_url = https://github.com/catchorg/Catch2/archive/v3.7.1.tar.gz |
||||||
|
source_filename = Catch2-3.7.1.tar.gz |
||||||
|
source_hash = c991b247a1a0d7bb9c39aa35faf0fe9e19764213f28ffba3109388e62ee0269c |
||||||
|
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/catch2_3.7.1-1/Catch2-3.7.1.tar.gz |
||||||
|
wrapdb_version = 3.7.1-1 |
||||||
|
|
||||||
|
[provide] |
||||||
|
catch2 = catch2_dep |
||||||
|
catch2-with-main = catch2_with_main_dep |
@ -0,0 +1,13 @@ |
|||||||
|
[wrap-file] |
||||||
|
directory = flac-1.4.3 |
||||||
|
source_url = https://github.com/xiph/flac/releases/download/1.4.3/flac-1.4.3.tar.xz |
||||||
|
source_filename = flac-1.4.3.tar.xz |
||||||
|
source_hash = 6c58e69cd22348f441b861092b825e591d0b822e106de6eb0ee4d05d27205b70 |
||||||
|
patch_filename = flac_1.4.3-2_patch.zip |
||||||
|
patch_url = https://wrapdb.mesonbuild.com/v2/flac_1.4.3-2/get_patch |
||||||
|
patch_hash = 3eace1bd0769d3e0d4ff099960160766a5185d391c8f583293b087a1f96c2a9c |
||||||
|
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/flac_1.4.3-2/flac-1.4.3.tar.xz |
||||||
|
wrapdb_version = 1.4.3-2 |
||||||
|
|
||||||
|
[provide] |
||||||
|
flac = flac_dep |
@ -0,0 +1,13 @@ |
|||||||
|
[wrap-file] |
||||||
|
directory = fmt-11.0.2 |
||||||
|
source_url = https://github.com/fmtlib/fmt/archive/11.0.2.tar.gz |
||||||
|
source_filename = fmt-11.0.2.tar.gz |
||||||
|
source_hash = 6cb1e6d37bdcb756dbbe59be438790db409cdb4868c66e888d5df9f13f7c027f |
||||||
|
patch_filename = fmt_11.0.2-1_patch.zip |
||||||
|
patch_url = https://wrapdb.mesonbuild.com/v2/fmt_11.0.2-1/get_patch |
||||||
|
patch_hash = 90c9e3b8e8f29713d40ca949f6f93ad115d78d7fb921064112bc6179e6427c5e |
||||||
|
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/fmt_11.0.2-1/fmt-11.0.2.tar.gz |
||||||
|
wrapdb_version = 11.0.2-1 |
||||||
|
|
||||||
|
[provide] |
||||||
|
fmt = fmt_dep |
@ -0,0 +1,11 @@ |
|||||||
|
[wrap-file] |
||||||
|
directory = freetype-2.13.3 |
||||||
|
source_url = https://download.savannah.gnu.org/releases/freetype/freetype-2.13.3.tar.xz |
||||||
|
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/freetype2_2.13.3-1/freetype-2.13.3.tar.xz |
||||||
|
source_filename = freetype-2.13.3.tar.xz |
||||||
|
source_hash = 0550350666d427c74daeb85d5ac7bb353acba5f76956395995311a9c6f063289 |
||||||
|
wrapdb_version = 2.13.3-1 |
||||||
|
|
||||||
|
[provide] |
||||||
|
freetype2 = freetype_dep |
||||||
|
freetype = freetype_dep |
@ -0,0 +1,13 @@ |
|||||||
|
[wrap-file] |
||||||
|
directory = libpng-1.6.44 |
||||||
|
source_url = https://github.com/glennrp/libpng/archive/v1.6.44.tar.gz |
||||||
|
source_filename = libpng-1.6.44.tar.gz |
||||||
|
source_hash = 0ef5b633d0c65f780c4fced27ff832998e71478c13b45dfb6e94f23a82f64f7c |
||||||
|
patch_filename = libpng_1.6.44-1_patch.zip |
||||||
|
patch_url = https://wrapdb.mesonbuild.com/v2/libpng_1.6.44-1/get_patch |
||||||
|
patch_hash = 394b07614c45fbd1beac8b660386216a490fe12f841a1a445799b676c9c892fb |
||||||
|
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/libpng_1.6.44-1/libpng-1.6.44.tar.gz |
||||||
|
wrapdb_version = 1.6.44-1 |
||||||
|
|
||||||
|
[provide] |
||||||
|
libpng = libpng_dep |
@ -0,0 +1,11 @@ |
|||||||
|
[wrap-file] |
||||||
|
directory = nlohmann_json-3.11.3 |
||||||
|
lead_directory_missing = true |
||||||
|
source_url = https://github.com/nlohmann/json/releases/download/v3.11.3/include.zip |
||||||
|
source_filename = nlohmann_json-3.11.3.zip |
||||||
|
source_hash = a22461d13119ac5c78f205d3df1db13403e58ce1bb1794edc9313677313f4a9d |
||||||
|
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/nlohmann_json_3.11.3-1/nlohmann_json-3.11.3.zip |
||||||
|
wrapdb_version = 3.11.3-1 |
||||||
|
|
||||||
|
[provide] |
||||||
|
nlohmann_json = nlohmann_json_dep |
@ -0,0 +1,13 @@ |
|||||||
|
[wrap-file] |
||||||
|
directory = libogg-1.3.5 |
||||||
|
source_url = https://downloads.xiph.org/releases/ogg/libogg-1.3.5.tar.xz |
||||||
|
source_filename = libogg-1.3.5.tar.xz |
||||||
|
source_hash = c4d91be36fc8e54deae7575241e03f4211eb102afb3fc0775fbbc1b740016705 |
||||||
|
patch_filename = ogg_1.3.5-6_patch.zip |
||||||
|
patch_url = https://wrapdb.mesonbuild.com/v2/ogg_1.3.5-6/get_patch |
||||||
|
patch_hash = 8be6dcd5f93bbf9c0b9c8ec1fa29810226a60f846383074ca05b313a248e78b2 |
||||||
|
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/ogg_1.3.5-6/libogg-1.3.5.tar.xz |
||||||
|
wrapdb_version = 1.3.5-6 |
||||||
|
|
||||||
|
[provide] |
||||||
|
ogg = libogg_dep |
@ -0,0 +1,14 @@ |
|||||||
|
[wrap-git] |
||||||
|
directory=SFML-3.0.0 |
||||||
|
url=https://github.com/SFML/SFML.git |
||||||
|
revision=3.0.0 |
||||||
|
depth=1 |
||||||
|
method=cmake |
||||||
|
|
||||||
|
[provide] |
||||||
|
sfml_audio = sfml_audio_dep |
||||||
|
sfml_graphics = sfml_graphics_dep |
||||||
|
sfml_main = sfml_main_dep |
||||||
|
sfml_network = sfml_network_dep |
||||||
|
sfml_system = sfml_system_dep |
||||||
|
sfml_window = sfml_window_dep |
@ -0,0 +1,7 @@ |
|||||||
|
[wrap-git] |
||||||
|
url=https://github.com/wolfpld/tracy.git |
||||||
|
revision=v0.11.1 |
||||||
|
depth=1 |
||||||
|
|
||||||
|
[provide] |
||||||
|
tracy = tracy_dep |
@ -0,0 +1,14 @@ |
|||||||
|
[wrap-file] |
||||||
|
directory = libvorbis-1.3.7 |
||||||
|
source_url = https://downloads.xiph.org/releases/vorbis/libvorbis-1.3.7.tar.xz |
||||||
|
source_filename = libvorbis-1.3.7.tar.xz |
||||||
|
source_hash = b33cc4934322bcbf6efcbacf49e3ca01aadbea4114ec9589d1b1e9d20f72954b |
||||||
|
patch_filename = vorbis_1.3.7-4_patch.zip |
||||||
|
patch_url = https://wrapdb.mesonbuild.com/v2/vorbis_1.3.7-4/get_patch |
||||||
|
patch_hash = 979e22b24b16c927040700dfd8319cd6ba29bf52a14dbc66b1cb4ea60504f14a |
||||||
|
wrapdb_version = 1.3.7-4 |
||||||
|
|
||||||
|
[provide] |
||||||
|
vorbis = vorbis_dep |
||||||
|
vorbisfile = vorbisfile_dep |
||||||
|
vorbisenc = vorbisenc_dep |
Loading…
Reference in new issue