]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
event consumption work
authorClyne Sullivan <tullivan99@gmail.com>
Thu, 7 Sep 2017 17:38:56 +0000 (13:38 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Thu, 7 Sep 2017 17:38:56 +0000 (13:38 -0400)
Makefile
entityx/3rdparty/simplesignal.h
entityx/Makefile
lib/libentityx.a
src/inventory.cpp
src/systems/dialog.cpp
src/ui.cpp
src/ui_menu.cpp
xml/!town.xml

index 59158de3948d9181ccee2599a1940b56db321804..8b3bd5e92af34ee4c10728f90057b1fa029fa385 100644 (file)
--- 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    " $<
index 3c60273dc756427320e3d55e18121193a2e58416..864c1c60c11798cfa1401908acc61a0b0f33d61e 100644 (file)
@@ -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_; }
 
index 58b18a73c28a78398e08cb5acab1ce5d8c3753c2..d5c748f7f67f4debfe8907c9496cad44e7634c5b 100644 (file)
@@ -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
index 86e8ce5b711957eeef9a4d27b3244f2e4f2f03d1..a91851c6810badeeff2ac38c4cdc5e0163870cbd 100644 (file)
Binary files a/lib/libentityx.a and b/lib/libentityx.a differ
index b96d5cfe857fc567c4db12a8a1e25dc9027cc637..1fdaf63ba4d4c6c90195022438b8ec2030056030 100644 (file)
@@ -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)
index ee7c8341b3ce27486a1d1e6f87982cc59e348965..f4f479f5a508215650b648f56dc2618f5cb0029b 100644 (file)
@@ -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)
index 1043ae967d96c220309280be23abdb7456bae5cc..4eed4a38db734297e270e2e235cb5d59d3958545 100644 (file)
@@ -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;
 
index a48182b6308dd5b65b90f0eb0b250adc47dd867b..fd316ce0865c039f9af95fbf54c5ccb41c22852a 100644 (file)
@@ -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;
index c2a7cd25ea16ba67c6c1c55a2f53ff0207cf87d0..a86461a2a5b1b6aacb2ac6b39edf221d8fdb921a 100644 (file)
@@ -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"/>