UI - Resolved last build issues

+ Tool has name!
+ Finished renaming files
+ Fixed common sync code that still had some SDL shit left
This commit is contained in:
Emmanuel BENOîT 2017-11-24 10:08:41 +01:00
parent 81a60d7832
commit 0fcfeb1fee
11 changed files with 73 additions and 58 deletions

4
.gitignore vendored
View file

@ -1,5 +1,5 @@
demo tourista
parsercheck tourista-builder
*.o *.o
fd-*.h fd-*.h
imgui.ini imgui.ini

View file

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
if make -j 8; then if make -j 8; then
if [ -x /usr/bin/optirun ]; then if [ -x /usr/bin/optirun ]; then
optirun ./demo optirun ./tourista
else else
./demo ./tourista
fi fi
fi fi

View file

@ -7,8 +7,10 @@ CPPFLAGS += -I. -I$(OUTDIR) \
-I3rdparty/icon-font-headers \ -I3rdparty/icon-font-headers \
-I3rdparty/ebcl/include \ -I3rdparty/ebcl/include \
-DREAL_BUILD -DGLM_ENABLE_EXPERIMENTAL -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 = FILEDUMPS =
@ -32,8 +34,8 @@ COMMON = \
c-syncoverrides.cc \ c-syncoverrides.cc \
# END COMMON # END COMMON
DEMO = \ TOOL = \
main.cc \ m-tool.cc \
ui.cc \ ui.cc \
ui-actions.cc \ ui-actions.cc \
ui-app.cc \ ui-app.cc \
@ -51,45 +53,45 @@ DEMO = \
ui-sync.cc \ ui-sync.cc \
ui-texture.cc \ ui-texture.cc \
ui-utilities.cc \ ui-utilities.cc \
# END DEMO # END TOOL
PARSERCHECK = \ BUILDER = \
parsercheck.cc \ m-builder.cc \
# END PARSERCHECK # END BUILDER
IMGUI_OBJS = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(basename $(IMGUI)))) IMGUI_OBJS = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(basename $(IMGUI))))
COMMON_OBJS = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(basename $(COMMON)))) COMMON_OBJS = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(basename $(COMMON))))
DEMO_OBJS = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(basename $(DEMO)))) TOOL_OBJS = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(basename $(TOOL))))
PARSERCHECK_OBJS = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(basename $(PARSERCHECK)))) BUILDER_OBJS = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(basename $(BUILDER))))
LIBEBCL = $(OUTDIR)/ebcl/libebcorelib.a LIBEBCL = $(OUTDIR)/ebcl/libebcorelib.a
PCH=externals.hh.gch PCH=externals.hh.gch
COMMON_DEPS = $(COMMON_OBJS:$(OUTDIR)/%.o=$(OUTDIR)/%.d) COMMON_DEPS = $(COMMON_OBJS:$(OUTDIR)/%.o=$(OUTDIR)/%.d)
DEMO_DEPS = $(DEMO_OBJS:$(OUTDIR)/%.o=$(OUTDIR)/%.d) DEMO_DEPS = $(TOOL_OBJS:$(OUTDIR)/%.o=$(OUTDIR)/%.d)
PARSERCHECK_DEPS = $(PARSERCHECK_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) DEMO_BUILD = $(TOOL_OBJS) $(COMMON_REQ) $(IMGUI_OBJS)
PARSERCHECK_BUILD = $(PARSERCHECK_OBJS) $(COMMON_REQ) BUILDER_BUILD = $(BUILDER_OBJS) $(COMMON_REQ)
ALL_OBJS = $(DEMO_OBJS) $(PARSERCHECK_OBJS) $(COMMON_REQ) ALL_OBJS = $(TOOL_OBJS) $(BUILDER_OBJS) $(COMMON_REQ)
ALL_DEPS = $(COMMON_DEPS) $(DEMO_DEPS) $(PARSERCHECK_DEPS) ALL_DEPS = $(COMMON_DEPS) $(DEMO_DEPS) $(BUILDER_DEPS)
all: demo parsercheck all: tourista tourista-builder
demo: $(LIBEBCL) $(DEMO_BUILD) tourista: $(LIBEBCL) $(DEMO_BUILD)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o demo \ $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o tourista \
$(DEMO_BUILD) $(LIBS) $(DEMO_BUILD) $(TOOL_LIBS)
parsercheck: $(LIBEBCL) $(PARSERCHECK_BUILD) tourista-builder: $(LIBEBCL) $(BUILDER_BUILD)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o parsercheck \ $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o tourista-builder \
$(PARSERCHECK_BUILD) $(LIBS) $(BUILDER_BUILD) $(BUILDER_LIBS)
clean: 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 depclean: clean
rm -f $(ALL_DEPS) rm -f $(ALL_DEPS)
@ -117,7 +119,7 @@ $(IMGUI_OBJS): $(OUTDIR)/%.o: 3rdparty/imgui/%.cpp | outdir
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
-include $(DEMO_DEPS) -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) -c -o $@ $<
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -M -MF $(@:%.o=%.d) -MT $@ $< $(CXX) $(CXXFLAGS) $(CPPFLAGS) -M -MF $(@:%.o=%.d) -MT $@ $<
@ -130,8 +132,8 @@ $(COMMON_OBJS): $(OUTDIR)/%.o: %.cc $(PCH) | outdir $(FILEDUMPS)
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
-include $(PARSERCHECK_DEPS) -include $(BUILDER_DEPS)
$(PARSERCHECK_OBJS): $(OUTDIR)/%.o: %.cc $(PCH) | outdir $(FILEDUMPS) $(BUILDER_OBJS): $(OUTDIR)/%.o: %.cc $(PCH) | outdir $(FILEDUMPS)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $< $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -M -MF $(@:%.o=%.d) -MT $@ $< $(CXX) $(CXXFLAGS) $(CPPFLAGS) -M -MF $(@:%.o=%.d) -MT $@ $<

View file

@ -512,19 +512,7 @@ void T_SyncManager::setTime(
{ {
time_.setTime( time ); time_.setTime( time );
updateValues( ); updateValues( );
} playing_ = playing_ && !finished( );
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_;
} }
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/

View file

@ -387,8 +387,6 @@ struct T_SyncManager
T_SyncTime time_; // Duration/time information T_SyncTime time_; // Duration/time information
bool playing_{ false }; // Is it playing? 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_SyncValues values_; // Value storage
T_SyncCurves curves_; // Curves storage T_SyncCurves curves_; // Curves storage

View file

View file

@ -31,7 +31,7 @@ T_UIApp::T_UIApp( )
SDL_DisplayMode current; SDL_DisplayMode current;
SDL_GetCurrentDisplayMode( 0 , &current ); SDL_GetCurrentDisplayMode( 0 , &current );
window_ = SDL_CreateWindow( "DEMO", window_ = SDL_CreateWindow( "Tourista",
SDL_WINDOWPOS_CENTERED , SDL_WINDOWPOS_CENTERED , SDL_WINDOWPOS_CENTERED , SDL_WINDOWPOS_CENTERED ,
1280 , 720 , 1280 , 720 ,
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE ); SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE );

View file

@ -4,9 +4,11 @@
#include "c-opcomp.hh" #include "c-opcomp.hh"
#include "c-sync.hh" #include "c-sync.hh"
#include "ui.hh"
#include "ui-demo.hh" #include "ui-demo.hh"
#include "ui-opemu.hh" #include "ui-opemu.hh"
#include "ui-rendertarget.hh" #include "ui-rendertarget.hh"
#include "ui-sync.hh"
#include <ebcl/Files.hh> #include <ebcl/Files.hh>
#include <ebcl/SRDText.hh> #include <ebcl/SRDText.hh>
@ -30,12 +32,13 @@ void T_Demo::render( )
} }
} }
auto& sync( Common::Sync( ) ); UI::Sync( ).updateTime( );
sync.updateTime( );
if ( context && !context->aborted ) { if ( context && !context->aborted ) {
try { 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 ) { } catch ( ops::X_OpFailure const& fail ) {
printf( "FAILED TO RUN FRAME!\n\t%s\n" , fail.what( ) ); printf( "FAILED TO RUN FRAME!\n\t%s\n" , fail.what( ) );
context->aborted = true; context->aborted = true;

View file

@ -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( void T_UISync::delegateMouse(
T_String const& id , T_String const& id ,
P_MouseCtrl delegate ) noexcept P_MouseCtrl delegate ) noexcept

View file

@ -6,21 +6,26 @@
class T_UISync : public A_MouseCtrl class T_UISync : public A_MouseCtrl
{ {
public: public:
using F_Override = std::function<
void( A_SyncOverride& , uint32_t& , T_StringBuilder& ) >;
T_UISync( ); T_UISync( );
~T_UISync( ); ~T_UISync( );
//----------------------------------------------------------------------
bool& overridesWindowEnabled( ) noexcept bool& overridesWindowEnabled( ) noexcept
{ return ovWindow_; } { return ovWindow_; }
void makeOverridesWindow( ); void makeOverridesWindow( );
using F_Override = std::function<
void( A_SyncOverride& , uint32_t& , T_StringBuilder& ) >;
F_Override uiFor( A_SyncOverride& target ) const noexcept; F_Override uiFor( A_SyncOverride& target ) const noexcept;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void updateTime( ) noexcept;
//----------------------------------------------------------------------
void delegateMouse( T_String const& id , void delegateMouse( T_String const& id ,
P_MouseCtrl delegate ) noexcept; P_MouseCtrl delegate ) noexcept;
void clearMouseDelegate( ) noexcept; void clearMouseDelegate( ) noexcept;
@ -40,8 +45,12 @@ class T_UISync : public A_MouseCtrl
T_MouseButtons buttons ) noexcept override; T_MouseButtons buttons ) noexcept override;
private: private:
bool ovWindow_{ false }; bool ovWindow_{ false }; // Overrides window open
T_String mouseDelegateName_{ }; 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_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
}; };