From 0639018d114c8c2504fb75d638dab7d61f341443 Mon Sep 17 00:00:00 2001 From: Kirito <1362050620@qq.com> Date: Fri, 24 Feb 2017 13:19:20 +0800 Subject: [PATCH] Update MiniEngine_SimpleWidgets.hpp --- MiniEngine_SimpleWidgets.hpp | 102 ++--------------------------------- 1 file changed, 4 insertions(+), 98 deletions(-) diff --git a/MiniEngine_SimpleWidgets.hpp b/MiniEngine_SimpleWidgets.hpp index 11a95d0..165148a 100644 --- a/MiniEngine_SimpleWidgets.hpp +++ b/MiniEngine_SimpleWidgets.hpp @@ -1,107 +1,10 @@ -#include "MiniEngine.h" +#include "MiniEngine_Simple.h" #include #include #include #include using namespace MiniEngine; - -using DispatcherType = function ; -map disvec; - -mutex mdisvec_counter; -int disvec_counter=0; - - - -using UpdaterType = function ; -map upvec; - -mutex mupvec_counter; -int upvec_counter=0; - -int RegistDispatcher(DispatcherType func) -{ - mdisvec_counter.lock(); - int id=disvec_counter++; - mdisvec_counter.unlock(); - - disvec.insert(make_pair(id,func)); - return id; -} -int UnregistDispatcher(int callbackid) -{ - for(auto it=disvec.begin();it!=disvec.end();it++) - { - if(callbackid==it->first) - { - disvec.erase(it); - return 0; - } - } - return -1; -} -int RegistUpdater(UpdaterType func) -{ - mupvec_counter.lock(); - int id=upvec_counter++; - mupvec_counter.unlock(); - - upvec.insert(make_pair(id,func)); - return id; -} -int UnregistUpdater(int callbackid) -{ - for(auto it=upvec.begin();it!=upvec.end();it++) - { - if(callbackid==it->first) - { - upvec.erase(it); - return 0; - } - } - return -1; -} - -void EventDispatcher(SDL_Event e,int& running,int& update) -{ - for(auto& func:disvec) - { - int r=1; - int u=0; - func.second(e,r,u); - running&=r; - update|=u; - } -} - -void EventUpdater(Renderer& rnd) -{ - for(auto& func:upvec) - { - func.second(rnd); - } -} - -void EventLoop(Renderer& rnd) -{ - SDL_Event e; - int running=1; - int update=1; - while(running) - { - while(!update&&SDL_WaitEvent(&e)) - { - EventDispatcher(e,running,update); - } - - rnd.clear(); - EventUpdater(rnd); - rnd.update(); - update=0; - } -} - class Drawable { public: @@ -256,6 +159,8 @@ private: ButtonStatus bstatus; }; +/** +//Example Code int main() { SDLSystem::Init(); @@ -279,3 +184,4 @@ int main() SDLSystem::Quit(); return 0; } +*/