diff --git a/Engine.cpp b/Engine.cpp index f727d04..b43ceb7 100644 --- a/Engine.cpp +++ b/Engine.cpp @@ -400,6 +400,7 @@ void Engine::run() if (this->m_LoadedMesh != nullptr) { if (isPlaying) { this->m_LoadedMesh->setLoopMode(true); + this->m_UserInterface->playbackSetFrameEditBox->setText(Utility::toWstring(this->m_LoadedMesh->getFrameNr()).c_str()); } else { this->m_LoadedMesh->setLoopMode(false); diff --git a/UserInterface.cpp b/UserInterface.cpp index 064c8e9..0c48575 100644 --- a/UserInterface.cpp +++ b/UserInterface.cpp @@ -78,6 +78,15 @@ void UserInterface::setupUserInterface() nullptr ); + y += size_y + spacing_y; + playbackSetFrameEditBox = m_Gui->addEditBox( + L"", + rect( vector2d( spacing_x, y ), dimension2d( size_x, size_y )), + true, + playbackWindow, + UIE_PLAYBACKSETFRAMEEDITBOX + ); + // Set Font for UI Elements m_GuiFontFace = new CGUITTFace(); // irrString defines stringc as string @@ -288,6 +297,20 @@ bool UserInterface::OnEvent( const SEvent &event ) else if (event.KeyInput.Char == L' ') { m_Engine->toggleAnimation(); } + else if (event.KeyInput.Key == irr::KEY_LEFT) { + if (this->m_Engine->m_LoadedMesh != nullptr) { + if (m_Engine->isPlaying) m_Engine->toggleAnimation(); + this->m_Engine->m_LoadedMesh->setCurrentFrame(round(this->m_Engine->m_LoadedMesh->getFrameNr())-1); + this->playbackSetFrameEditBox->setText(Utility::toWstring(this->m_Engine->m_LoadedMesh->getFrameNr()).c_str()); + } + } + else if (event.KeyInput.Key == irr::KEY_RIGHT) { + if (this->m_Engine->m_LoadedMesh != nullptr) { + if (m_Engine->isPlaying) m_Engine->toggleAnimation(); + this->m_Engine->m_LoadedMesh->setCurrentFrame(round(this->m_Engine->m_LoadedMesh->getFrameNr())+1); + this->playbackSetFrameEditBox->setText(Utility::toWstring(this->m_Engine->m_LoadedMesh->getFrameNr()).c_str()); + } + } // std::wcerr << "Char: " << event.KeyInput.Char << endl; } m_Engine->KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown; @@ -372,6 +395,13 @@ bool UserInterface::OnEvent( const SEvent &event ) } } break; + case UIE_PLAYBACKSETFRAMEEDITBOX: + if ( ge->EventType == EGET_EDITBOX_ENTER) { + if (this->m_Engine->m_LoadedMesh != nullptr) { + this->m_Engine->m_LoadedMesh->setCurrentFrame(Utility::toF32(this->playbackSetFrameEditBox->getText())); + } + } + break; default: break; diff --git a/UserInterface.h b/UserInterface.h index 869d039..3ca5eb2 100644 --- a/UserInterface.h +++ b/UserInterface.h @@ -17,7 +17,8 @@ enum UserInterfaceElements UIE_VIEWMENU = 1005, UIE_LOADTEXTUREDIALOG = 1006, UIE_PLAYBACKINCREASEBUTTON = 1007, - UIE_PLAYBACKDECREASEBUTTON = 1008 + UIE_PLAYBACKDECREASEBUTTON = 1008, + UIE_PLAYBACKSETFRAMEEDITBOX = 1009 }; enum UserInterfaceCommands @@ -49,6 +50,7 @@ public: irr::gui::IGUIButton *playbackStartStopButton; irr::gui::IGUIButton *playbackIncreaseButton; irr::gui::IGUIButton *playbackDecreaseButton; + irr::gui::IGUIEditBox *playbackSetFrameEditBox; UserInterface( Engine *device ); ~UserInterface(); diff --git a/Utils.cpp b/Utils.cpp index def9fe9..f434db1 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -7,6 +7,7 @@ #include #include // #include #include +#include #include "Debug.h" @@ -176,6 +177,24 @@ wstring Utility::toLower(const wstring &s) return ret; } +wstring Utility::toWstring(irr::f32 val) +{ + return std::to_wstring(val); +} + +wstring Utility::toWstring(int val) +{ + return std::to_wstring(val); +} + +irr::f32 Utility::toF32(wstring val) +{ + std::wstringstream ss(val); + irr::f32 ret = 0; + ss >> ret; + return ret; +} + bool Utility::isFile(const std::wstring& name) { std::string name_s = toString(name); if (FILE *file = fopen(name_s.c_str(), "r")) { @@ -186,6 +205,11 @@ bool Utility::isFile(const std::wstring& name) { } } +std::string Utility::toString(irr::f32 val) +{ + return std::to_string(val); +} + //don't do late instantiation (see header file) //template diff --git a/Utils.h b/Utils.h index 5257ba9..7ee7c89 100644 --- a/Utils.h +++ b/Utils.h @@ -17,9 +17,13 @@ public: static std::wstring delimiter(const std::wstring &path); static bool isFile(const std::string &name); static bool isFile(const std::wstring &name); + static std::string toString(irr::f32 val); static std::string toString(const std::wstring &name); static std::string toLower(const std::string &s); static std::wstring toLower(const std::wstring &s); + static std::wstring toWstring(irr::f32 val); + static std::wstring toWstring(int val); + static irr::f32 toF32(std::wstring val); // compiler doesn't like template function when class is not a template--instantiate immediately // see http://processors.wiki.ti.com/index.php/C%2B%2B_Template_Instantiation_Issues template diff --git a/build/install.sh b/build/install.sh old mode 100644 new mode 100755 diff --git a/build/owner/.local/share/applications/org.poikilos.b3view.desktop b/build/owner/.local/share/applications/org.poikilos.b3view.desktop new file mode 100644 index 0000000..7546bea --- /dev/null +++ b/build/owner/.local/share/applications/org.poikilos.b3view.desktop @@ -0,0 +1,20 @@ +[Desktop Entry] +Comment[en_US]= +Comment= +GenericName[en_US]=Irrlicht Model Viewer +GenericName=Irrlicht Model Viewer +MimeType= +Name[en_US]=b3view +Name=b3view +Path= +StartupNotify=true +Terminal=false +TerminalOptions= +Type=Application +X-DBUS-ServiceName= +X-DBUS-StartupType= +X-KDE-SubstituteUID=false +X-KDE-Username= +Exec=owner/.local/bin/b3view +Icon=owner/.local/share/icons/b3view.png + diff --git a/build/owner/.local/share/icons/b3view.png b/build/owner/.local/share/icons/b3view.png new file mode 100644 index 0000000..fb1039f Binary files /dev/null and b/build/owner/.local/share/icons/b3view.png differ diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..73b1ba8 --- /dev/null +++ b/install.sh @@ -0,0 +1,4 @@ +#!/bin/sh +echo "Use the install.sh in build instead. Switching to build/install.sh..." && cd build || echo "ERROR: No build directory" && exit 1 +chmod +x install.sh +./install.sh