2018-04-21 21:19:48 +00:00
# include <assert.h>
2022-07-02 14:25:47 +00:00
# include "imgui.h"
2022-08-17 10:07:38 +00:00
# include "IconsFontAwesome6.h"
2018-04-21 21:19:48 +00:00
# include "TracyBadVersion.hpp"
# include "TracyImGui.hpp"
2021-06-04 12:33:31 +00:00
# include "TracyWeb.hpp"
2018-04-21 21:19:48 +00:00
namespace tracy
{
namespace detail
{
2021-11-13 21:20:00 +00:00
void BadVersionImpl ( BadVersionState & badVer , ImFont * big )
2018-04-21 21:19:48 +00:00
{
2019-08-12 10:04:27 +00:00
assert ( badVer . state ! = BadVersionState : : Ok ) ;
2018-04-21 21:19:48 +00:00
2019-08-12 10:04:27 +00:00
switch ( badVer . state )
2018-04-21 21:19:48 +00:00
{
2019-08-12 10:04:27 +00:00
case BadVersionState : : BadFile :
2018-04-21 21:19:48 +00:00
ImGui : : OpenPopup ( " Bad file " ) ;
2019-08-12 10:04:27 +00:00
break ;
2020-02-12 18:53:37 +00:00
case BadVersionState : : ReadError :
ImGui : : OpenPopup ( " File read error " ) ;
break ;
2019-08-12 10:04:27 +00:00
case BadVersionState : : UnsupportedVersion :
ImGui : : OpenPopup ( " Unsupported file version " ) ;
break ;
2019-08-12 10:16:48 +00:00
case BadVersionState : : LegacyVersion :
ImGui : : OpenPopup ( " Legacy file version " ) ;
break ;
2019-08-12 10:04:27 +00:00
default :
assert ( false ) ;
break ;
2018-04-21 21:19:48 +00:00
}
2019-08-12 10:16:48 +00:00
if ( ImGui : : BeginPopupModal ( " Bad file " , nullptr , ImGuiWindowFlags_AlwaysAutoResize ) )
{
2022-04-25 21:29:44 +00:00
ImGui : : PushFont ( big ) ;
2022-08-17 10:07:38 +00:00
TextCentered ( ICON_FA_TRIANGLE_EXCLAMATION ) ;
2022-04-25 21:29:44 +00:00
ImGui : : PopFont ( ) ;
2021-06-04 12:36:25 +00:00
ImGui : : Text ( " The file you are trying to open is not a Tracy dump. " ) ;
2019-08-12 10:16:48 +00:00
ImGui : : Separator ( ) ;
if ( ImGui : : Button ( " Oops " ) )
{
ImGui : : CloseCurrentPopup ( ) ;
badVer . state = BadVersionState : : Ok ;
}
ImGui : : EndPopup ( ) ;
}
2020-02-12 18:53:37 +00:00
if ( ImGui : : BeginPopupModal ( " File read error " , nullptr , ImGuiWindowFlags_AlwaysAutoResize ) )
{
2022-04-25 21:29:44 +00:00
ImGui : : PushFont ( big ) ;
2022-08-17 10:07:38 +00:00
TextCentered ( ICON_FA_TRIANGLE_EXCLAMATION ) ;
2022-04-25 21:29:44 +00:00
ImGui : : PopFont ( ) ;
2020-02-12 18:53:37 +00:00
ImGui : : Text ( " The file you are trying to open cannot be mapped to memory. " ) ;
ImGui : : Separator ( ) ;
if ( ImGui : : Button ( " OK " ) )
{
ImGui : : CloseCurrentPopup ( ) ;
badVer . state = BadVersionState : : Ok ;
}
ImGui : : EndPopup ( ) ;
}
2018-04-21 21:19:48 +00:00
if ( ImGui : : BeginPopupModal ( " Unsupported file version " , nullptr , ImGuiWindowFlags_AlwaysAutoResize ) )
{
2022-04-25 21:29:44 +00:00
ImGui : : PushFont ( big ) ;
2022-08-17 10:07:38 +00:00
TextCentered ( ICON_FA_CLOUD_ARROW_DOWN ) ;
2022-04-25 21:29:44 +00:00
ImGui : : PopFont ( ) ;
2021-06-04 12:36:25 +00:00
ImGui : : Text ( " The file you are trying to open is unsupported. \n You should update to Tracy %i.%i.%i or newer and try again. " , badVer . version > > 16 , ( badVer . version > > 8 ) & 0xFF , badVer . version & 0xFF ) ;
2018-04-21 21:19:48 +00:00
ImGui : : Separator ( ) ;
2021-06-04 12:33:31 +00:00
if ( ImGui : : Button ( ICON_FA_DOWNLOAD " Download update " ) )
{
tracy : : OpenWebpage ( " https://github.com/wolfpld/tracy/releases " ) ;
ImGui : : CloseCurrentPopup ( ) ;
badVer . state = BadVersionState : : Ok ;
}
ImGui : : SameLine ( ) ;
if ( ImGui : : Button ( " Maybe later " ) )
2018-04-21 21:19:48 +00:00
{
ImGui : : CloseCurrentPopup ( ) ;
2019-08-12 10:04:27 +00:00
badVer . state = BadVersionState : : Ok ;
2018-04-21 21:19:48 +00:00
}
ImGui : : EndPopup ( ) ;
}
2019-08-12 10:16:48 +00:00
if ( ImGui : : BeginPopupModal ( " Legacy file version " , nullptr , ImGuiWindowFlags_AlwaysAutoResize ) )
2018-04-21 21:19:48 +00:00
{
2022-04-25 21:29:44 +00:00
ImGui : : PushFont ( big ) ;
2019-08-12 10:16:48 +00:00
TextCentered ( ICON_FA_GHOST ) ;
2022-04-25 21:29:44 +00:00
ImGui : : PopFont ( ) ;
2019-08-12 10:16:48 +00:00
ImGui : : Text ( " You are trying to open a file which was created by legacy version %i.%i.%i. \n Use the update utility from an older version of the profiler to convert the file to a supported version. " , badVer . version > > 16 , ( badVer . version > > 8 ) & 0xFF , badVer . version & 0xFF ) ;
2018-04-21 21:19:48 +00:00
ImGui : : Separator ( ) ;
2019-08-12 10:16:48 +00:00
if ( ImGui : : Button ( " Maybe I don't need it " ) )
2018-04-21 21:19:48 +00:00
{
ImGui : : CloseCurrentPopup ( ) ;
2019-08-12 10:04:27 +00:00
badVer . state = BadVersionState : : Ok ;
2018-04-21 21:19:48 +00:00
}
ImGui : : EndPopup ( ) ;
}
}
}
}