aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2017-09-07 13:38:56 -0400
committerClyne Sullivan <tullivan99@gmail.com>2017-09-07 13:38:56 -0400
commitc3e164c6845b9b32f132aa37cc9707acba0d9eff (patch)
tree549b66f19066863628d74860145a07f6b04ad8ba
parent643e94897ba5fab0570d118a7aafc7772949d4e3 (diff)
event consumption work
-rw-r--r--Makefile3
-rw-r--r--entityx/3rdparty/simplesignal.h4
-rw-r--r--entityx/Makefile1
-rw-r--r--lib/libentityx.abin550610 -> 562752 bytes
-rw-r--r--src/inventory.cpp2
-rw-r--r--src/systems/dialog.cpp16
-rw-r--r--src/ui.cpp4
-rw-r--r--src/ui_menu.cpp18
-rw-r--r--xml/!town.xml2
9 files changed, 29 insertions, 21 deletions
diff --git a/Makefile b/Makefile
index 59158de..8b3bd5e 100644
--- a/Makefile
+++ b/Makefile
@@ -38,12 +38,11 @@ clean:
@mkdir out
@mkdir out/systems
@mkdir out/components
+ @rm -f xml/*.dat
$(EXEC): $(CXXOUTDIR)/$(CXXOBJ) main.cpp
@echo " CXX/LD main"
@$(CXX) $(SPECIAL) $(CXXFLAGS) $(CXXINC) $(CXXWARN) -o $(EXEC) main.cpp out/components/*.o out/systems/*.o out/*.o $(LIBS)
- @rm -rf xml/*.dat
- @rm -rf storyXML/*.dat
$(CXXOUTDIR)/%.o: $(CXXSRCDIR)/%.cpp
@echo " CXX " $<
diff --git a/entityx/3rdparty/simplesignal.h b/entityx/3rdparty/simplesignal.h
index 3c60273..864c1c6 100644
--- a/entityx/3rdparty/simplesignal.h
+++ b/entityx/3rdparty/simplesignal.h
@@ -26,9 +26,9 @@ template <typename Result>
struct CollectorLast {
typedef Result CollectorResult;
explicit CollectorLast() : last_() {}
- inline bool operator()(Result r) {
+ inline CollectorResult operator()(Result r) {
last_ = r;
- return true;
+ return last_;
}
CollectorResult result() { return last_; }
diff --git a/entityx/Makefile b/entityx/Makefile
index 58b18a7..d5c748f 100644
--- a/entityx/Makefile
+++ b/entityx/Makefile
@@ -9,6 +9,7 @@ FILES = help/Pool.cc \
Entity.cc \
System.cc
all:
+ mkdir out
g++ $(INC) $(FLG) -c help/Pool.cc -o out/Pool.o
g++ $(INC) $(FLG) -c help/Timer.cc -o out/Timer.o
g++ $(INC) $(FLG) -c Event.cc -o out/Event.o
diff --git a/lib/libentityx.a b/lib/libentityx.a
index 86e8ce5..a91851c 100644
--- a/lib/libentityx.a
+++ b/lib/libentityx.a
Binary files differ
diff --git a/src/inventory.cpp b/src/inventory.cpp
index b96d5cf..1fdaf63 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -251,7 +251,7 @@ bool InventorySystem::receive(const MouseClickEvent &mce)
game::events.emit<UseItemEvent>(mce.position, items[0].item, &attack->second);
}
}
- return false;
+ return true;
}
bool InventorySystem::receive(const MouseReleaseEvent &mre)
diff --git a/src/systems/dialog.cpp b/src/systems/dialog.cpp
index ee7c834..f4f479f 100644
--- a/src/systems/dialog.cpp
+++ b/src/systems/dialog.cpp
@@ -27,15 +27,17 @@ void DialogSystem::configure(entityx::EventManager &ev)
bool DialogSystem::receive(const MouseClickEvent &mce)
{
+ static bool continueEvent;
+
+ continueEvent = true;
game::entities.each<Position, Solid, Dialog, Name>(
[&](entityx::Entity e, Position &pos, Solid &dim, Dialog &d, Name &name) {
static std::atomic_bool dialogRun;
- (void)e;
- (void)d;
if (((mce.position.x > pos.x) & (mce.position.x < pos.x + dim.width)) &&
((mce.position.y > pos.y) & (mce.position.y < pos.y + dim.height))) {
+ continueEvent = false;
e.replace<Flash>(Color(0, 255, 255));
if (!dialogRun.load()) {
@@ -141,10 +143,12 @@ bool DialogSystem::receive(const MouseClickEvent &mce)
d.talking = false;
dialogRun.store(false);
}).detach();
- }
- }
- });
- return false;
+ } // dialogRun check
+
+ } // mouse check
+ } // .each
+ );
+ return continueEvent;
}
void DialogSystem::update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt)
diff --git a/src/ui.cpp b/src/ui.cpp
index 1043ae9..4eed4a3 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -665,11 +665,11 @@ bool InputSystem::receive(const MainSDLEvent& event)
break;
case SDL_MOUSEBUTTONDOWN:
- ev.emit<MouseClickEvent>(mouse, e.button.button);
-
if (UISystem::isDialog() || pageTexReady) {
if ((e.button.button & SDL_BUTTON_RIGHT))
UISystem::advanceDialog();
+ } else {
+ ev.emit<MouseClickEvent>(mouse, e.button.button);
}
break;
diff --git a/src/ui_menu.cpp b/src/ui_menu.cpp
index a48182b..fd316ce 100644
--- a/src/ui_menu.cpp
+++ b/src/ui_menu.cpp
@@ -13,19 +13,19 @@ static Menu* currentMenu = nullptr;
bool SDLReceiver::receive(const MainSDLEvent& mse)
{
+ if (currentMenu == nullptr)
+ return true;
+
switch (mse.event.type) {
case SDL_QUIT:
game::endGame();
- return true;
- break;
- case SDL_MOUSEMOTION:
- //ui::premouse.x = e.motion.x;
- //ui::premouse.y = e.motion.y;
break;
case SDL_MOUSEBUTTONUP:
if (mse.event.button.button & SDL_BUTTON_LEFT)
clicked = true;
- break;
+ break;
+ case SDL_MOUSEBUTTONDOWN:
+ break; // consume events
case SDL_KEYUP:
if (currentMenu != nullptr && mse.event.key.keysym.sym == SDLK_ESCAPE) {
currentMenu->gotoParent();
@@ -33,10 +33,14 @@ bool SDLReceiver::receive(const MainSDLEvent& mse)
clicked = false;
}
break;
+ case SDL_KEYDOWN:
+ break; // consume events
default:
+ return true;
break;
}
- return true;
+
+ return false;
}
bool SDLReceiver::clicked = false;
diff --git a/xml/!town.xml b/xml/!town.xml
index c2a7cd2..a86461a 100644
--- a/xml/!town.xml
+++ b/xml/!town.xml
@@ -50,7 +50,7 @@
</Dialog>
<Dialog name="Sanc">
- <text id="0">
+ <text id="0" nexit="0" pause="true">
<set id="Slow" value="0"/>
<set id="canSprint" value="1"/>
<set id="canJump" value="1"/>