1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Move OpenWebpage() to a separate source file.

This commit is contained in:
Bartosz Taudul 2021-06-04 14:33:12 +02:00
parent 86510c48e0
commit 39cf98f98c
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
5 changed files with 60 additions and 31 deletions

View File

@ -134,6 +134,7 @@
<ClCompile Include="..\..\..\server\TracyThreadCompress.cpp" />
<ClCompile Include="..\..\..\server\TracyUserData.cpp" />
<ClCompile Include="..\..\..\server\TracyView.cpp" />
<ClCompile Include="..\..\..\server\TracyWeb.cpp" />
<ClCompile Include="..\..\..\server\TracyWorker.cpp" />
<ClCompile Include="..\..\..\zstd\common\debug.c" />
<ClCompile Include="..\..\..\zstd\common\entropy_common.c" />
@ -236,6 +237,7 @@
<ClInclude Include="..\..\..\server\TracyVersion.hpp" />
<ClInclude Include="..\..\..\server\TracyView.hpp" />
<ClInclude Include="..\..\..\server\TracyViewData.hpp" />
<ClInclude Include="..\..\..\server\TracyWeb.hpp" />
<ClInclude Include="..\..\..\server\TracyWorker.hpp" />
<ClInclude Include="..\..\..\server\tracy_pdqsort.h" />
<ClInclude Include="..\..\..\server\tracy_robin_hood.h" />

View File

@ -249,6 +249,9 @@
<ClCompile Include="..\..\..\common\TracyStackFrames.cpp">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="..\..\..\server\TracyWeb.cpp">
<Filter>server</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\common\tracy_lz4.hpp">
@ -578,6 +581,9 @@
<ClInclude Include="..\..\..\common\TracyYield.hpp">
<Filter>common</Filter>
</ClInclude>
<ClInclude Include="..\..\..\server\TracyWeb.hpp">
<Filter>server</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Natvis Include="DebugVis.natvis" />

View File

@ -22,11 +22,6 @@
# include "../nfd/nfd.h"
#endif
#ifdef _WIN32
# include <windows.h>
# include <shellapi.h>
#endif
#define STB_IMAGE_IMPLEMENTATION
#define STBI_ONLY_PNG
#include "stb_image.h"
@ -43,6 +38,7 @@
#include "../../server/TracyStorage.hpp"
#include "../../server/TracyVersion.hpp"
#include "../../server/TracyView.hpp"
#include "../../server/TracyWeb.hpp"
#include "../../server/TracyWorker.hpp"
#include "../../server/TracyVersion.hpp"
#include "../../server/IconsFontAwesome5.h"
@ -61,21 +57,6 @@ static void glfw_error_callback(int error, const char* description)
fprintf(stderr, "Error %d: %s\n", error, description);
}
static void OpenWebpage( const char* url )
{
#ifdef _WIN32
ShellExecuteA( nullptr, nullptr, url, nullptr, nullptr, 0 );
#elif defined __APPLE__
char buf[1024];
sprintf( buf, "open %s", url );
system( buf );
#else
char buf[1024];
sprintf( buf, "xdg-open %s", url );
system( buf );
#endif
}
GLFWwindow* s_glfwWindow = nullptr;
static bool s_customTitle = false;
static void SetWindowTitleCallback( const char* title )
@ -619,7 +600,7 @@ static void DrawContents()
ImGui::Spacing();
if( ImGui::Button( ICON_FA_BOOK " Manual" ) )
{
OpenWebpage( "https://github.com/wolfpld/tracy/releases" );
tracy::OpenWebpage( "https://github.com/wolfpld/tracy/releases" );
}
ImGui::SameLine();
if( ImGui::Button( ICON_FA_GLOBE_AMERICAS " Web" ) )
@ -630,44 +611,44 @@ static void DrawContents()
{
if( ImGui::Selectable( ICON_FA_HOME " Tracy Profiler home page" ) )
{
OpenWebpage( "https://github.com/wolfpld/tracy" );
tracy::OpenWebpage( "https://github.com/wolfpld/tracy" );
}
ImGui::Separator();
if( ImGui::Selectable( ICON_FA_VIDEO " Overview of v0.2" ) )
{
OpenWebpage( "https://www.youtube.com/watch?v=fB5B46lbapc" );
tracy::OpenWebpage( "https://www.youtube.com/watch?v=fB5B46lbapc" );
}
if( ImGui::Selectable( ICON_FA_VIDEO " New features in v0.3" ) )
{
OpenWebpage( "https://www.youtube.com/watch?v=3SXpDpDh2Uo" );
tracy::OpenWebpage( "https://www.youtube.com/watch?v=3SXpDpDh2Uo" );
}
if( ImGui::Selectable( ICON_FA_VIDEO " New features in v0.4" ) )
{
OpenWebpage( "https://www.youtube.com/watch?v=eAkgkaO8B9o" );
tracy::OpenWebpage( "https://www.youtube.com/watch?v=eAkgkaO8B9o" );
}
if( ImGui::Selectable( ICON_FA_VIDEO " New features in v0.5" ) )
{
OpenWebpage( "https://www.youtube.com/watch?v=P6E7qLMmzTQ" );
tracy::OpenWebpage( "https://www.youtube.com/watch?v=P6E7qLMmzTQ" );
}
if( ImGui::Selectable( ICON_FA_VIDEO " New features in v0.6" ) )
{
OpenWebpage( "https://www.youtube.com/watch?v=uJkrFgriuOo" );
tracy::OpenWebpage( "https://www.youtube.com/watch?v=uJkrFgriuOo" );
}
if( ImGui::Selectable( ICON_FA_VIDEO " New features in v0.7" ) )
{
OpenWebpage( "https://www.youtube.com/watch?v=_hU7vw00MZ4" );
tracy::OpenWebpage( "https://www.youtube.com/watch?v=_hU7vw00MZ4" );
}
ImGui::EndPopup();
}
ImGui::SameLine();
if( ImGui::Button( ICON_FA_COMMENT " Chat" ) )
{
OpenWebpage( "https://discord.gg/pk78auc" );
tracy::OpenWebpage( "https://discord.gg/pk78auc" );
}
ImGui::SameLine();
if( ImGui::Button( ICON_FA_HEART " Sponsor" ) )
{
OpenWebpage( "https://github.com/sponsors/wolfpld/" );
tracy::OpenWebpage( "https://github.com/sponsors/wolfpld/" );
}
if( updateVersion != 0 && updateVersion > tracy::FileVersion( tracy::Version::Major, tracy::Version::Minor, tracy::Version::Patch ) )
{
@ -928,7 +909,7 @@ static void DrawContents()
ImGui::Begin( "Update available!", &showReleaseNotes );
if( ImGui::Button( ICON_FA_DOWNLOAD " Download" ) )
{
OpenWebpage( "https://github.com/wolfpld/tracy/releases" );
tracy::OpenWebpage( "https://github.com/wolfpld/tracy/releases" );
}
ImGui::BeginChild( "###notes", ImVec2( 0, 0 ), true );
if( releaseNotes.empty() )

29
server/TracyWeb.cpp Normal file
View File

@ -0,0 +1,29 @@
#ifdef _WIN32
# include <windows.h>
# include <shellapi.h>
#else
# include <stdio.h>
# include <stdlib.h>
#endif
#include "TracyWeb.hpp"
namespace tracy
{
void OpenWebpage( const char* url )
{
#ifdef _WIN32
ShellExecuteA( nullptr, nullptr, url, nullptr, nullptr, 0 );
#elif defined __APPLE__
char buf[1024];
sprintf( buf, "open %s", url );
system( buf );
#else
char buf[1024];
sprintf( buf, "xdg-open %s", url );
system( buf );
#endif
}
}

11
server/TracyWeb.hpp Normal file
View File

@ -0,0 +1,11 @@
#ifndef __TRACYWEB_HPP__
#define __TRACYWEB_HPP__
namespace tracy
{
void OpenWebpage( const char* url );
}
#endif