From 0fcfeb1fee8d4aad821356164324e203ce8b0ba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Fri, 24 Nov 2017 10:08:41 +0100 Subject: [PATCH] UI - Resolved last build issues + Tool has name! + Finished renaming files + Fixed common sync code that still had some SDL shit left --- .gitignore | 4 +-- .vim.local/scripts/vimmake.test | 4 +-- Makefile | 58 +++++++++++++++++---------------- c-sync.cc | 14 +------- c-sync.hh | 2 -- parsercheck.cc => m-builder.cc | 0 main.cc => m-tool.cc | 0 ui-app.cc | 2 +- ui-demo.cc | 9 +++-- ui-sync.cc | 15 +++++++++ ui-sync.hh | 23 +++++++++---- 11 files changed, 73 insertions(+), 58 deletions(-) rename parsercheck.cc => m-builder.cc (100%) rename main.cc => m-tool.cc (100%) diff --git a/.gitignore b/.gitignore index ffd2d94..ca795b7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ -demo -parsercheck +tourista +tourista-builder *.o fd-*.h imgui.ini diff --git a/.vim.local/scripts/vimmake.test b/.vim.local/scripts/vimmake.test index a7b25ef..b086c00 100755 --- a/.vim.local/scripts/vimmake.test +++ b/.vim.local/scripts/vimmake.test @@ -1,8 +1,8 @@ #!/bin/bash if make -j 8; then if [ -x /usr/bin/optirun ]; then - optirun ./demo + optirun ./tourista else - ./demo + ./tourista fi fi diff --git a/Makefile b/Makefile index 215483c..4ec0c9a 100644 --- a/Makefile +++ b/Makefile @@ -7,8 +7,10 @@ CPPFLAGS += -I. -I$(OUTDIR) \ -I3rdparty/icon-font-headers \ -I3rdparty/ebcl/include \ -DREAL_BUILD -DGLM_ENABLE_EXPERIMENTAL -LIBS += $(shell sdl2-config --libs) -lGL -lGLEW -ldl \ - $(LIBEBCL) -latomic + +BUILDER_LIBS = $(LIBEBCL) -latomic +TOOL_LIBS = $(shell sdl2-config --libs) -lGL -lGLEW -ldl $(BUILDER_LIBS) + FILEDUMPS = @@ -32,8 +34,8 @@ COMMON = \ c-syncoverrides.cc \ # END COMMON -DEMO = \ - main.cc \ +TOOL = \ + m-tool.cc \ ui.cc \ ui-actions.cc \ ui-app.cc \ @@ -51,45 +53,45 @@ DEMO = \ ui-sync.cc \ ui-texture.cc \ ui-utilities.cc \ -# END DEMO +# END TOOL -PARSERCHECK = \ - parsercheck.cc \ -# END PARSERCHECK +BUILDER = \ + m-builder.cc \ +# END BUILDER IMGUI_OBJS = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(basename $(IMGUI)))) COMMON_OBJS = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(basename $(COMMON)))) -DEMO_OBJS = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(basename $(DEMO)))) -PARSERCHECK_OBJS = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(basename $(PARSERCHECK)))) +TOOL_OBJS = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(basename $(TOOL)))) +BUILDER_OBJS = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(basename $(BUILDER)))) LIBEBCL = $(OUTDIR)/ebcl/libebcorelib.a PCH=externals.hh.gch COMMON_DEPS = $(COMMON_OBJS:$(OUTDIR)/%.o=$(OUTDIR)/%.d) -DEMO_DEPS = $(DEMO_OBJS:$(OUTDIR)/%.o=$(OUTDIR)/%.d) -PARSERCHECK_DEPS = $(PARSERCHECK_OBJS:$(OUTDIR)/%.o=$(OUTDIR)/%.d) +DEMO_DEPS = $(TOOL_OBJS:$(OUTDIR)/%.o=$(OUTDIR)/%.d) +BUILDER_DEPS = $(BUILDER_OBJS:$(OUTDIR)/%.o=$(OUTDIR)/%.d) -COMMON_REQ = $(COMMON_OBJS) $(IMGUI_OBJS) +COMMON_REQ = $(COMMON_OBJS) -DEMO_BUILD = $(DEMO_OBJS) $(COMMON_REQ) -PARSERCHECK_BUILD = $(PARSERCHECK_OBJS) $(COMMON_REQ) +DEMO_BUILD = $(TOOL_OBJS) $(COMMON_REQ) $(IMGUI_OBJS) +BUILDER_BUILD = $(BUILDER_OBJS) $(COMMON_REQ) -ALL_OBJS = $(DEMO_OBJS) $(PARSERCHECK_OBJS) $(COMMON_REQ) -ALL_DEPS = $(COMMON_DEPS) $(DEMO_DEPS) $(PARSERCHECK_DEPS) +ALL_OBJS = $(TOOL_OBJS) $(BUILDER_OBJS) $(COMMON_REQ) +ALL_DEPS = $(COMMON_DEPS) $(DEMO_DEPS) $(BUILDER_DEPS) -all: demo parsercheck +all: tourista tourista-builder -demo: $(LIBEBCL) $(DEMO_BUILD) - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o demo \ - $(DEMO_BUILD) $(LIBS) +tourista: $(LIBEBCL) $(DEMO_BUILD) + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o tourista \ + $(DEMO_BUILD) $(TOOL_LIBS) -parsercheck: $(LIBEBCL) $(PARSERCHECK_BUILD) - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o parsercheck \ - $(PARSERCHECK_BUILD) $(LIBS) +tourista-builder: $(LIBEBCL) $(BUILDER_BUILD) + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o tourista-builder \ + $(BUILDER_BUILD) $(BUILDER_LIBS) clean: - rm -f $(ALL_OBJS) $(FILEDUMPS) demo parsercheck $(PCH) $(OUTDIR)/font-awesome.inl + rm -f $(ALL_OBJS) $(FILEDUMPS) tourista tourista-builder $(PCH) $(OUTDIR)/font-awesome.inl depclean: clean rm -f $(ALL_DEPS) @@ -117,7 +119,7 @@ $(IMGUI_OBJS): $(OUTDIR)/%.o: 3rdparty/imgui/%.cpp | outdir #------------------------------------------------------------------------------- -include $(DEMO_DEPS) -$(DEMO_OBJS): $(OUTDIR)/%.o: %.cc $(PCH) | outdir $(FILEDUMPS) +$(TOOL_OBJS): $(OUTDIR)/%.o: %.cc $(PCH) | outdir $(FILEDUMPS) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $< $(CXX) $(CXXFLAGS) $(CPPFLAGS) -M -MF $(@:%.o=%.d) -MT $@ $< @@ -130,8 +132,8 @@ $(COMMON_OBJS): $(OUTDIR)/%.o: %.cc $(PCH) | outdir $(FILEDUMPS) #------------------------------------------------------------------------------- --include $(PARSERCHECK_DEPS) -$(PARSERCHECK_OBJS): $(OUTDIR)/%.o: %.cc $(PCH) | outdir $(FILEDUMPS) +-include $(BUILDER_DEPS) +$(BUILDER_OBJS): $(OUTDIR)/%.o: %.cc $(PCH) | outdir $(FILEDUMPS) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $< $(CXX) $(CXXFLAGS) $(CPPFLAGS) -M -MF $(@:%.o=%.d) -MT $@ $< diff --git a/c-sync.cc b/c-sync.cc index 47d83ee..7c1fc3c 100644 --- a/c-sync.cc +++ b/c-sync.cc @@ -512,19 +512,7 @@ void T_SyncManager::setTime( { time_.setTime( time ); updateValues( ); -} - -void T_SyncManager::updateTime( ) noexcept -{ - if ( playing_ ) { - const float time( SDL_GetTicks( ) * 1e-3 ); - if ( playingPrevious_ ) { - timeDelta( time - lastFrame_ ); - playing_ = !finished( ); - } - lastFrame_ = time; - } - playingPrevious_ = playing_; + playing_ = playing_ && !finished( ); } /*----------------------------------------------------------------------------*/ diff --git a/c-sync.hh b/c-sync.hh index f34d0ee..e25862a 100644 --- a/c-sync.hh +++ b/c-sync.hh @@ -387,8 +387,6 @@ struct T_SyncManager T_SyncTime time_; // Duration/time information bool playing_{ false }; // Is it playing? - bool playingPrevious_{ false }; // Was it playing before? - float lastFrame_{ 0 }; // Time of last frame T_SyncValues values_; // Value storage T_SyncCurves curves_; // Curves storage diff --git a/parsercheck.cc b/m-builder.cc similarity index 100% rename from parsercheck.cc rename to m-builder.cc diff --git a/main.cc b/m-tool.cc similarity index 100% rename from main.cc rename to m-tool.cc diff --git a/ui-app.cc b/ui-app.cc index 8e8e493..659c6a7 100644 --- a/ui-app.cc +++ b/ui-app.cc @@ -31,7 +31,7 @@ T_UIApp::T_UIApp( ) SDL_DisplayMode current; SDL_GetCurrentDisplayMode( 0 , ¤t ); - window_ = SDL_CreateWindow( "DEMO", + window_ = SDL_CreateWindow( "Tourista", SDL_WINDOWPOS_CENTERED , SDL_WINDOWPOS_CENTERED , 1280 , 720 , SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE ); diff --git a/ui-demo.cc b/ui-demo.cc index 0eda5c8..cfdcb5f 100644 --- a/ui-demo.cc +++ b/ui-demo.cc @@ -4,9 +4,11 @@ #include "c-opcomp.hh" #include "c-sync.hh" +#include "ui.hh" #include "ui-demo.hh" #include "ui-opemu.hh" #include "ui-rendertarget.hh" +#include "ui-sync.hh" #include #include @@ -30,12 +32,13 @@ void T_Demo::render( ) } } - auto& sync( Common::Sync( ) ); - sync.updateTime( ); + UI::Sync( ).updateTime( ); if ( context && !context->aborted ) { try { - context->run( ops::T_OpContext::R_RENDER , sync.time( ) , width , height ); + context->run( ops::T_OpContext::R_RENDER , + Common::Sync( ).time( ) , + width , height ); } catch ( ops::X_OpFailure const& fail ) { printf( "FAILED TO RUN FRAME!\n\t%s\n" , fail.what( ) ); context->aborted = true; diff --git a/ui-sync.cc b/ui-sync.cc index 1b2a64e..bef5757 100644 --- a/ui-sync.cc +++ b/ui-sync.cc @@ -175,6 +175,21 @@ void T_UISync::makeOverridesWindow( ) /*----------------------------------------------------------------------------*/ +void T_UISync::updateTime( ) noexcept +{ + auto& s{ Common::Sync( ) }; + if ( s.playing( ) ) { + const float time( SDL_GetTicks( ) * 1e-3f ); + if ( playingPrevious_ ) { + s.timeDelta( time - lastFrame_ ); + } + lastFrame_ = time; + } + playingPrevious_ = s.playing( ); +} + +/*----------------------------------------------------------------------------*/ + void T_UISync::delegateMouse( T_String const& id , P_MouseCtrl delegate ) noexcept diff --git a/ui-sync.hh b/ui-sync.hh index 525559a..f965717 100644 --- a/ui-sync.hh +++ b/ui-sync.hh @@ -6,21 +6,26 @@ class T_UISync : public A_MouseCtrl { public: - - using F_Override = std::function< - void( A_SyncOverride& , uint32_t& , T_StringBuilder& ) >; - T_UISync( ); ~T_UISync( ); + //---------------------------------------------------------------------- + bool& overridesWindowEnabled( ) noexcept { return ovWindow_; } void makeOverridesWindow( ); + using F_Override = std::function< + void( A_SyncOverride& , uint32_t& , T_StringBuilder& ) >; + F_Override uiFor( A_SyncOverride& target ) const noexcept; //---------------------------------------------------------------------- + void updateTime( ) noexcept; + + //---------------------------------------------------------------------- + void delegateMouse( T_String const& id , P_MouseCtrl delegate ) noexcept; void clearMouseDelegate( ) noexcept; @@ -40,8 +45,12 @@ class T_UISync : public A_MouseCtrl T_MouseButtons buttons ) noexcept override; private: - bool ovWindow_{ false }; - T_String mouseDelegateName_{ }; + bool ovWindow_{ false }; // Overrides window open + T_KeyValueTable< T_String , F_Override > sovuis_; // Override UI table + + T_String mouseDelegateName_{ }; // Name and pointer for mouse delegation T_OwnPtr< A_MouseCtrl > mouseDelegate_{ }; - T_KeyValueTable< T_String , F_Override > sovuis_; + + bool playingPrevious_{ false }; // Was it playing before? + float lastFrame_{ 0 }; // Time of last frame };