Mouse handling is way better but still want to refine it more if I can.
This commit is contained in:
parent
e41651aa38
commit
190748af3c
10 changed files with 47 additions and 22 deletions
2
Makefile
2
Makefile
|
|
@ -65,7 +65,7 @@ debug: build
|
|||
gdb --nx -x .gdbinit --ex run --args builddir/runtests
|
||||
|
||||
debug_run: build
|
||||
gdb --nx -x .gdbinit --batch --ex run --ex bt --ex q --args builddir/multiscreen
|
||||
gdb --nx -x .gdbinit --batch --ex run --ex bt --ex q --args builddir/under_the_dome
|
||||
|
||||
debug_walk: build test
|
||||
gdb --nx -x .gdbinit --batch --ex run --ex bt --ex q --args builddir/under_the_dome t
|
||||
|
|
|
|||
|
|
@ -65,6 +65,9 @@ json = subproject('nlohmann_json').get_variable('nlohmann_json_dep')
|
|||
freetype2 = subproject('freetype2').get_variable('freetype_dep')
|
||||
|
||||
flac = subproject('flac').get_variable('flac_dep')
|
||||
magic_enum_proj = subproject('magic_enum', default_options: {
|
||||
'test': false})
|
||||
magic_enum = magic_enum_proj.get_variable('magic_enum_dep')
|
||||
ogg = subproject('ogg').get_variable('libogg_dep')
|
||||
vorbis = subproject('vorbis').get_variable('vorbis_dep')
|
||||
vorbisfile = subproject('vorbis').get_variable('vorbisfile_dep')
|
||||
|
|
@ -82,7 +85,7 @@ subdir('src')
|
|||
subdir('tests')
|
||||
|
||||
dependencies += [
|
||||
fmt, json, freetype2,
|
||||
fmt, json, freetype2, magic_enum,
|
||||
flac, ogg, vorbis, vorbisfile, vorbisenc,
|
||||
sfml_audio, sfml_graphics,
|
||||
sfml_network, sfml_system,
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <fmt/core.h>
|
||||
|
||||
#ifndef FSM_DEBUG
|
||||
#define FSM_STATE(C, S, E, ...) case C::S: S(E, ##__VA_ARGS__); break
|
||||
#else
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
static int last_event=-1;
|
||||
#define FSM_STATE(C, S, E, ...) case C::S: if(last_event != int(E)) { last_event = int(E); fmt::println(">> [{}] " #C " " #S " event={}, state={}", __FILE__, int(E), int($state));}; S(E, ##__VA_ARGS__); break
|
||||
#define FSM_STATE(C, S, E, ...) case C::S: if(last_event != int(E)) { last_event = int(E); fmt::println(">> [{}:EVENT] " #S " event={}", FSM_DEBUG, magic_enum::enum_name(E));}; S(E, ##__VA_ARGS__); break
|
||||
#endif
|
||||
|
||||
template<typename S, typename E>
|
||||
|
|
@ -21,7 +21,7 @@ public:
|
|||
|
||||
void state(S next_state) {
|
||||
#ifdef FSM_DEBUG
|
||||
fmt::println("<< STATE: {} -> {}", int($state), int(next_state));
|
||||
fmt::println(">> [{}:TRANS]: {} -> {}", FSM_DEBUG, magic_enum::enum_name($state), magic_enum::enum_name(next_state));
|
||||
#endif
|
||||
$state = next_state;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#define FSM_DEBUG 1
|
||||
#define FSM_DEBUG "dnd_loot"
|
||||
#include "gui/guecstra.hpp"
|
||||
#include "gui/dnd_loot.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#define FSM_DEBUG "router"
|
||||
#include "event_router.hpp"
|
||||
#include "dbc.hpp"
|
||||
#include "events.hpp"
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@
|
|||
namespace gui {
|
||||
namespace routing {
|
||||
enum class State {
|
||||
START,
|
||||
IDLE,
|
||||
MOUSE_ACTIVE,
|
||||
MOUSE_MOVING,
|
||||
MOUSE_DRAGGING
|
||||
START=__LINE__,
|
||||
IDLE=__LINE__,
|
||||
MOUSE_ACTIVE=__LINE__,
|
||||
MOUSE_MOVING=__LINE__,
|
||||
MOUSE_DRAGGING=__LINE__
|
||||
};
|
||||
|
||||
enum class Event {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#define FSM_DEBUG 1
|
||||
#define FSM_DEBUG "fsm"
|
||||
#include "gui/fsm.hpp"
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
|
|
@ -321,8 +321,15 @@ namespace gui {
|
|||
break; // ignored
|
||||
}
|
||||
} else {
|
||||
// event(gui_ev, {mouse_mods});
|
||||
mouse_action();
|
||||
switch(gui_ev) {
|
||||
case game::Event::MOUSE_DRAG_START:
|
||||
case game::Event::MOUSE_CLICK:
|
||||
case game::Event::MOUSE_DROP:
|
||||
mouse_action();
|
||||
break;
|
||||
default:
|
||||
event(gui_ev, {mouse_mods});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +1,22 @@
|
|||
#include "gui/guecstra.hpp"
|
||||
#include "game/level.hpp"
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
#include "dbc.hpp"
|
||||
|
||||
namespace guecs {
|
||||
|
||||
Clickable make_action(guecs::Entity gui_id, game::Event event) {
|
||||
return {[&, gui_id, event](auto){
|
||||
Clickable make_action(guecs::Entity gui_id, game::Event event, const std::source_location location) {
|
||||
return {[&, gui_id, event, location](guecs::Modifiers mods){
|
||||
auto world = GameDB::current_world();
|
||||
fmt::println("!!!!! SENDING EVENT: {}", int(event));
|
||||
dbc::log($F("SENDING EVENT: {}: {}", magic_enum::enum_name(event), mods.to_string()), location);
|
||||
world->send<game::Event>(event, gui_id, {});
|
||||
}};
|
||||
}
|
||||
|
||||
Clickable make_action(guecs::Entity gui_id, game::Event event, std::any data) {
|
||||
return {[&, event, data](auto){
|
||||
Clickable make_action(guecs::Entity gui_id, game::Event event, std::any data, const std::source_location location) {
|
||||
return {[&, event, data, location](auto){
|
||||
auto world = GameDB::current_world();
|
||||
fmt::println("!!!!! SENDING EVENT with data: {}", int(event));
|
||||
dbc::log($F("SENDING EVENT: {}", magic_enum::enum_name(event)), location);
|
||||
world->send<game::Event>(event, gui_id, data);
|
||||
}};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,10 @@
|
|||
#include "graphics/textures.hpp"
|
||||
|
||||
namespace guecs {
|
||||
Clickable make_action(guecs::Entity gui_id, game::Event event);
|
||||
Clickable make_action(guecs::Entity gui_id, game::Event event, std::any data);
|
||||
Clickable make_action(guecs::Entity gui_id, game::Event event,
|
||||
const std::source_location location = std::source_location::current());
|
||||
Clickable make_action(guecs::Entity gui_id, game::Event event, std::any data,
|
||||
const std::source_location location = std::source_location::current());
|
||||
|
||||
struct GrabSource {
|
||||
DinkyECS::Entity world_entity;
|
||||
|
|
|
|||
10
wraps/magic_enum.wrap
Normal file
10
wraps/magic_enum.wrap
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
[wrap-file]
|
||||
directory = magic_enum-0.9.7
|
||||
source_url = https://github.com/Neargye/magic_enum/archive/refs/tags/v0.9.7.tar.gz
|
||||
source_filename = magic_enum-v0.9.7.tar.gz
|
||||
source_hash = b403d3dad4ef542fdc3024fa37d3a6cedb4ad33c72e31b6d9bab89dcaf69edf7
|
||||
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/magic_enum_0.9.7-1/magic_enum-v0.9.7.tar.gz
|
||||
wrapdb_version = 0.9.7-1
|
||||
|
||||
[provide]
|
||||
magic_enum = magic_enum_dep
|
||||
Loading…
Add table
Add a link
Reference in a new issue