Move bad version dialogs to a separate file.

This commit is contained in:
Bartosz Taudul 2018-04-21 23:19:48 +02:00
parent ea2be1bce9
commit 28380f2d25
5 changed files with 78 additions and 33 deletions

View File

@ -0,0 +1,50 @@
#include <assert.h>
#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();
}
}
}
}

View File

@ -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

View File

@ -89,6 +89,7 @@
<ClCompile Include="..\..\..\imgui\imgui_draw.cpp" />
<ClCompile Include="..\..\..\nfd\nfd_common.c" />
<ClCompile Include="..\..\..\nfd\nfd_win.cpp" />
<ClCompile Include="..\..\..\server\TracyBadVersion.cpp" />
<ClCompile Include="..\..\..\server\TracyMemory.cpp" />
<ClCompile Include="..\..\..\server\TracyView.cpp" />
<ClCompile Include="..\..\..\server\TracyWorker.cpp" />
@ -115,6 +116,7 @@
<ClInclude Include="..\..\..\nfd\common.h" />
<ClInclude Include="..\..\..\nfd\nfd.h" />
<ClInclude Include="..\..\..\nfd\nfd_common.h" />
<ClInclude Include="..\..\..\server\TracyBadVersion.hpp" />
<ClInclude Include="..\..\..\server\TracyCharUtil.hpp" />
<ClInclude Include="..\..\..\server\TracyEvent.hpp" />
<ClInclude Include="..\..\..\server\TracyFileHeader.hpp" />

View File

@ -63,6 +63,9 @@
<ClCompile Include="..\..\..\nfd\nfd_win.cpp">
<Filter>nfd</Filter>
</ClCompile>
<ClCompile Include="..\..\..\server\TracyBadVersion.cpp">
<Filter>server</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\common\tracy_lz4.hpp">
@ -170,6 +173,9 @@
<ClInclude Include="..\..\..\server\TracyFileHeader.hpp">
<Filter>server</Filter>
</ClInclude>
<ClInclude Include="..\..\..\server\TracyBadVersion.hpp">
<Filter>server</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Natvis Include="DebugVis.natvis" />

View File

@ -7,6 +7,7 @@
#include "../nfd/nfd.h"
#include <sys/stat.h>
#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();
}