From 28380f2d25091ea4b2b406295be3d471a10cd3e4 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 21 Apr 2018 23:19:48 +0200 Subject: [PATCH] Move bad version dialogs to a separate file. --- server/TracyBadVersion.cpp | 50 ++++++++++++++++++++ server/TracyBadVersion.hpp | 18 +++++++ standalone/build/win32/Tracy.vcxproj | 2 + standalone/build/win32/Tracy.vcxproj.filters | 6 +++ standalone/src/main.cpp | 35 +------------- 5 files changed, 78 insertions(+), 33 deletions(-) create mode 100644 server/TracyBadVersion.cpp create mode 100644 server/TracyBadVersion.hpp diff --git a/server/TracyBadVersion.cpp b/server/TracyBadVersion.cpp new file mode 100644 index 00000000..9853dd80 --- /dev/null +++ b/server/TracyBadVersion.cpp @@ -0,0 +1,50 @@ +#include + +#include "TracyBadVersion.hpp" +#include "TracyImGui.hpp" + +namespace tracy +{ + +namespace detail +{ + +void BadVersionImpl( int& badVer ) +{ + assert( badVer != 0 ); + + if( badVer > 0 ) + { + ImGui::OpenPopup( "Unsupported file version" ); + } + else + { + ImGui::OpenPopup( "Bad file" ); + } + if( ImGui::BeginPopupModal( "Unsupported file version", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) ) + { + ImGui::Text( "The file you are trying to open is unsupported.\nYou should update to tracy %i.%i.%i or newer and try again.", badVer >> 16, ( badVer >> 8 ) & 0xFF, badVer & 0xFF ); + ImGui::Separator(); + if( ImGui::Button( "I understand" ) ) + { + ImGui::CloseCurrentPopup(); + badVer = 0; + } + ImGui::EndPopup(); + } + if( ImGui::BeginPopupModal( "Bad file", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) ) + { + ImGui::Text( "The file you are trying to open is not a tracy dump." ); + ImGui::Separator(); + if( ImGui::Button( "Oops" ) ) + { + ImGui::CloseCurrentPopup(); + badVer = 0; + } + ImGui::EndPopup(); + } +} + +} + +} diff --git a/server/TracyBadVersion.hpp b/server/TracyBadVersion.hpp new file mode 100644 index 00000000..608e865d --- /dev/null +++ b/server/TracyBadVersion.hpp @@ -0,0 +1,18 @@ +#ifndef __TRACYBADVERSION_HPP__ +#define __TRACYBADVERSION_HPP__ + +#include "../common/TracyForceInline.hpp" + +namespace tracy +{ + +namespace detail +{ +void BadVersionImpl( int& badVer ); +} + +tracy_force_inline void BadVersion( int& badVer ) { if( badVer != 0 ) detail::BadVersionImpl( badVer ); } + +} + +#endif diff --git a/standalone/build/win32/Tracy.vcxproj b/standalone/build/win32/Tracy.vcxproj index 8aa4e9a7..51be8646 100644 --- a/standalone/build/win32/Tracy.vcxproj +++ b/standalone/build/win32/Tracy.vcxproj @@ -89,6 +89,7 @@ + @@ -115,6 +116,7 @@ + diff --git a/standalone/build/win32/Tracy.vcxproj.filters b/standalone/build/win32/Tracy.vcxproj.filters index 963db2b8..6982ab8b 100644 --- a/standalone/build/win32/Tracy.vcxproj.filters +++ b/standalone/build/win32/Tracy.vcxproj.filters @@ -63,6 +63,9 @@ nfd + + server + @@ -170,6 +173,9 @@ server + + server + diff --git a/standalone/src/main.cpp b/standalone/src/main.cpp index 18c555a0..7fe494fe 100644 --- a/standalone/src/main.cpp +++ b/standalone/src/main.cpp @@ -7,6 +7,7 @@ #include "../nfd/nfd.h" #include +#include "../../server/TracyBadVersion.hpp" #include "../../server/TracyFileRead.hpp" #include "../../server/TracyView.hpp" @@ -120,39 +121,7 @@ int main( int argc, char** argv ) } } - if( badVer != 0 ) - { - if( badVer > 0 ) - { - ImGui::OpenPopup( "Unsupported file version" ); - } - else - { - ImGui::OpenPopup( "Bad file" ); - } - } - if( ImGui::BeginPopupModal( "Unsupported file version", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) ) - { - ImGui::Text( "The file you are trying to open is unsupported.\nYou should update to tracy %i.%i.%i or newer and try again.", badVer >> 16, ( badVer >> 8 ) & 0xFF, badVer & 0xFF ); - ImGui::Separator(); - if( ImGui::Button( "I understand" ) ) - { - ImGui::CloseCurrentPopup(); - badVer = 0; - } - ImGui::EndPopup(); - } - if( ImGui::BeginPopupModal( "Bad file", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) ) - { - ImGui::Text( "The file you are trying to open is not a tracy dump." ); - ImGui::Separator(); - if( ImGui::Button( "Oops" ) ) - { - ImGui::CloseCurrentPopup(); - badVer = 0; - } - ImGui::EndPopup(); - } + tracy::BadVersion( badVer ); ImGui::End(); }