Make the sfml parts a separate dependency so you can use them if you want.

main
Zed A. Shaw 2 days ago
parent de0d957c66
commit b7c49711b6
  1. 33
      meson.build
  2. 42
      src/guecs/lel_parser.cpp
  3. 2
      src/guecs/lel_parser.rl
  4. 1
      src/guecs/ui.cpp

@ -1,5 +1,7 @@
# clang might need _LIBCPP_ENABLE_CXX26_REMOVED_CODECVT # clang might need _LIBCPP_ENABLE_CXX26_REMOVED_CODECVT
# HEY BUG: when you have a . spec in a LEL it doesn't work on text
project('lel-guecs', 'cpp', project('lel-guecs', 'cpp',
version: '0.2.0', version: '0.2.0',
default_options: [ default_options: [
@ -63,11 +65,12 @@ sfml_window = subproject('sfml').get_variable('sfml_window_dep')
lib_depends = [ fmt, sfml_graphics, sfml_system, sfml_window ] lib_depends = [ fmt, sfml_graphics, sfml_system, sfml_window ]
dependencies += [ lib_sfml_depends = [
json, freetype2, flac, ogg, fmt, json, freetype2, flac, ogg,
vorbis, vorbisfile, vorbisenc, sfml_audio, vorbis, vorbisfile, vorbisenc, sfml_audio,
] + lib_depends ]
dependencies += lib_depends + lib_sfml_depends
sources = [ sources = [
'src/guecs/ui.cpp', 'src/guecs/ui.cpp',
@ -98,7 +101,19 @@ lel_guecs_dep = declare_dependency(
link_with: lel_guecs_lib, link_with: lel_guecs_lib,
include_directories: lel_guecs_inc) include_directories: lel_guecs_inc)
executable('runtests', sfml_impl + [ lel_guecs_sfml_lib = static_library('lel-guecs-sfml',
sfml_impl,
pic: true,
cpp_args: cpp_args,
include_directories: lel_guecs_inc,
override_options: exe_defaults,
dependencies: lib_sfml_depends)
lel_guecs_sfml_dep = declare_dependency(
link_with: lel_guecs_sfml_lib,
include_directories: lel_guecs_inc)
executable('runtests', [
'tests/lel.cpp', 'tests/lel.cpp',
'tests/shaders.cpp', 'tests/shaders.cpp',
'tests/sound.cpp', 'tests/sound.cpp',
@ -109,25 +124,25 @@ executable('runtests', sfml_impl + [
link_args: link_args, link_args: link_args,
override_options: exe_defaults, override_options: exe_defaults,
include_directories: lel_guecs_inc, include_directories: lel_guecs_inc,
link_with: [lel_guecs_lib], link_with: [lel_guecs_lib, lel_guecs_sfml_lib],
dependencies: dependencies + [catch2]) dependencies: dependencies + [catch2])
executable('clicker_game', sfml_impl + [ executable('clicker_game', [
'demos/clicker_game.cpp', 'demos/clicker_game.cpp',
], ],
cpp_args: cpp_args, cpp_args: cpp_args,
link_args: link_args, link_args: link_args,
override_options: exe_defaults, override_options: exe_defaults,
include_directories: lel_guecs_inc, include_directories: lel_guecs_inc,
link_with: [lel_guecs_lib], link_with: [lel_guecs_lib, lel_guecs_sfml_lib],
dependencies: dependencies) dependencies: dependencies)
executable('calc', sfml_impl + [ executable('calc', [
'demos/calc.cpp', 'demos/calc.cpp',
], ],
cpp_args: cpp_args, cpp_args: cpp_args,
link_args: link_args, link_args: link_args,
override_options: exe_defaults, override_options: exe_defaults,
include_directories: lel_guecs_inc, include_directories: lel_guecs_inc,
link_with: [lel_guecs_lib], link_with: [lel_guecs_lib, lel_guecs_sfml_lib],
dependencies: dependencies) dependencies: dependencies)

@ -21,8 +21,8 @@ static const char _Parser_actions[] = {
}; };
static const char _Parser_key_offsets[] = { static const char _Parser_key_offsets[] = {
0, 0, 4, 20, 33, 35, 39, 41, 0, 0, 4, 20, 33, 35, 39, 44,
44, 56, 61 47, 59, 64
}; };
static const char _Parser_trans_keys[] = { static const char _Parser_trans_keys[] = {
@ -30,26 +30,26 @@ static const char _Parser_trans_keys[] = {
46, 61, 94, 95, 9, 13, 60, 62, 46, 61, 94, 95, 9, 13, 60, 62,
65, 90, 97, 122, 37, 40, 42, 46, 65, 90, 97, 122, 37, 40, 42, 46,
61, 94, 95, 60, 62, 65, 90, 97, 61, 94, 95, 60, 62, 65, 90, 97,
122, 48, 57, 41, 44, 48, 57, 48, 122, 48, 57, 41, 44, 48, 57, 32,
57, 41, 48, 57, 32, 93, 95, 124, 9, 13, 48, 57, 41, 48, 57, 32,
9, 13, 48, 57, 65, 90, 97, 122, 93, 95, 124, 9, 13, 48, 57, 65,
32, 93, 124, 9, 13, 32, 91, 9, 90, 97, 122, 32, 93, 124, 9, 13,
13, 0 32, 91, 9, 13, 0
}; };
static const char _Parser_single_lengths[] = { static const char _Parser_single_lengths[] = {
0, 2, 8, 7, 0, 2, 0, 1, 0, 2, 8, 7, 0, 2, 1, 1,
4, 3, 2 4, 3, 2
}; };
static const char _Parser_range_lengths[] = { static const char _Parser_range_lengths[] = {
0, 1, 4, 3, 1, 1, 1, 1, 0, 1, 4, 3, 1, 1, 2, 1,
4, 1, 1 4, 1, 1
}; };
static const char _Parser_index_offsets[] = { static const char _Parser_index_offsets[] = {
0, 0, 4, 17, 28, 30, 34, 36, 0, 0, 4, 17, 28, 30, 34, 38,
39, 48, 53 41, 50, 55
}; };
static const char _Parser_indicies[] = { static const char _Parser_indicies[] = {
@ -57,24 +57,24 @@ static const char _Parser_indicies[] = {
7, 9, 7, 10, 3, 8, 10, 10, 7, 9, 7, 10, 3, 8, 10, 10,
1, 4, 5, 6, 7, 9, 7, 10, 1, 4, 5, 6, 7, 9, 7, 10,
8, 10, 10, 1, 11, 1, 12, 13, 8, 10, 10, 1, 11, 1, 12, 13,
14, 1, 15, 1, 16, 17, 1, 18, 14, 1, 15, 15, 16, 1, 17, 18,
20, 19, 21, 18, 19, 19, 19, 1, 1, 19, 21, 20, 22, 19, 20, 20,
22, 23, 24, 22, 1, 25, 2, 25, 20, 1, 23, 24, 25, 23, 1, 26,
1, 0 2, 26, 1, 0
}; };
static const char _Parser_trans_targs[] = { static const char _Parser_trans_targs[] = {
1, 0, 2, 2, 3, 4, 3, 3, 1, 0, 2, 2, 3, 4, 3, 3,
3, 3, 8, 5, 3, 6, 5, 7, 3, 3, 8, 5, 3, 6, 5, 6,
3, 7, 9, 8, 10, 2, 9, 10, 7, 3, 7, 9, 8, 10, 2, 9,
2, 10 10, 2, 10
}; };
static const char _Parser_trans_actions[] = { static const char _Parser_trans_actions[] = {
0, 0, 3, 0, 17, 0, 13, 5, 0, 0, 3, 0, 17, 0, 13, 5,
11, 15, 21, 19, 23, 23, 0, 19, 11, 15, 21, 19, 23, 23, 0, 0,
26, 0, 7, 0, 32, 29, 0, 9, 19, 26, 0, 7, 0, 32, 29, 0,
1, 0 9, 1, 0
}; };
static const int Parser_start = 1; static const int Parser_start = 1;

@ -31,7 +31,7 @@ namespace lel {
percent = "%" $percent; percent = "%" $percent;
halign = ("<" | ">") $align; halign = ("<" | ">") $align;
number = digit+ >{ start = fpc; } %token; number = digit+ >{ start = fpc; } %token;
setw = ("(" number %setwidth ("," number %setheight)? ")") ; setw = ("(" number %setwidth ("," space* number %setheight)? ")") ;
modifiers = (percent | center | expand | valign | halign | setw); modifiers = (percent | center | expand | valign | halign | setw);
id = ((alpha | '_')+ :>> (alnum | '_')*) >{start = fpc;} %id; id = ((alpha | '_')+ :>> (alnum | '_')*) >{start = fpc;} %id;
cell = modifiers* id; cell = modifiers* id;

@ -143,6 +143,7 @@ namespace guecs {
bool UI::mouse(float x, float y, bool hover) { bool UI::mouse(float x, float y, bool hover) {
int action_count = 0; int action_count = 0;
// BUG: use lel::Parser.hit instead of this
query<lel::Cell>([&](auto ent, auto& cell) { query<lel::Cell>([&](auto ent, auto& cell) {
if((x >= cell.x && x <= cell.x + cell.w) && if((x >= cell.x && x <= cell.x + cell.w) &&

Loading…
Cancel
Save