mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-29 16:54:35 +00:00
Add achievement wrapper function to TracyView.
This commit is contained in:
parent
aff60a6a36
commit
6aa9401b95
@ -394,12 +394,12 @@ int main( int argc, char** argv )
|
|||||||
|
|
||||||
if( initFileOpen )
|
if( initFileOpen )
|
||||||
{
|
{
|
||||||
view = std::make_unique<tracy::View>( RunOnMainThread, *initFileOpen, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config );
|
view = std::make_unique<tracy::View>( RunOnMainThread, *initFileOpen, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config, &s_achievements );
|
||||||
initFileOpen.reset();
|
initFileOpen.reset();
|
||||||
}
|
}
|
||||||
else if( connectTo )
|
else if( connectTo )
|
||||||
{
|
{
|
||||||
view = std::make_unique<tracy::View>( RunOnMainThread, connectTo, port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config );
|
view = std::make_unique<tracy::View>( RunOnMainThread, connectTo, port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config, &s_achievements );
|
||||||
}
|
}
|
||||||
|
|
||||||
tracy::Fileselector::Init();
|
tracy::Fileselector::Init();
|
||||||
@ -921,11 +921,11 @@ static void DrawContents()
|
|||||||
{
|
{
|
||||||
std::string addrPart = std::string( addr, ptr );
|
std::string addrPart = std::string( addr, ptr );
|
||||||
uint16_t portPart = (uint16_t)atoi( ptr+1 );
|
uint16_t portPart = (uint16_t)atoi( ptr+1 );
|
||||||
view = std::make_unique<tracy::View>( RunOnMainThread, addrPart.c_str(), portPart, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config );
|
view = std::make_unique<tracy::View>( RunOnMainThread, addrPart.c_str(), portPart, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config, &s_achievements );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
view = std::make_unique<tracy::View>( RunOnMainThread, addr, port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config );
|
view = std::make_unique<tracy::View>( RunOnMainThread, addr, port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config, &s_achievements );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( s_config.memoryLimit )
|
if( s_config.memoryLimit )
|
||||||
@ -948,7 +948,7 @@ static void DrawContents()
|
|||||||
loadThread = std::thread( [f] {
|
loadThread = std::thread( [f] {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
view = std::make_unique<tracy::View>( RunOnMainThread, *f, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config );
|
view = std::make_unique<tracy::View>( RunOnMainThread, *f, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config, &s_achievements );
|
||||||
}
|
}
|
||||||
catch( const tracy::UnsupportedVersion& e )
|
catch( const tracy::UnsupportedVersion& e )
|
||||||
{
|
{
|
||||||
@ -1081,7 +1081,7 @@ static void DrawContents()
|
|||||||
}
|
}
|
||||||
if( selected && !loadThread.joinable() )
|
if( selected && !loadThread.joinable() )
|
||||||
{
|
{
|
||||||
view = std::make_unique<tracy::View>( RunOnMainThread, v.second.address.c_str(), v.second.port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config );
|
view = std::make_unique<tracy::View>( RunOnMainThread, v.second.address.c_str(), v.second.port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config, &s_achievements );
|
||||||
}
|
}
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
const auto acttime = ( v.second.activeTime + ( time - v.second.time ) / 1000 ) * 1000000000ll;
|
const auto acttime = ( v.second.activeTime + ( time - v.second.time ) / 1000 ) * 1000000000ll;
|
||||||
@ -1250,7 +1250,7 @@ static void DrawContents()
|
|||||||
viewShutdown.store( ViewShutdown::False, std::memory_order_relaxed );
|
viewShutdown.store( ViewShutdown::False, std::memory_order_relaxed );
|
||||||
if( reconnect )
|
if( reconnect )
|
||||||
{
|
{
|
||||||
view = std::make_unique<tracy::View>( RunOnMainThread, reconnectAddr.c_str(), reconnectPort, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config );
|
view = std::make_unique<tracy::View>( RunOnMainThread, reconnectAddr.c_str(), reconnectPort, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback, s_config, &s_achievements );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -35,7 +35,7 @@ namespace tracy
|
|||||||
|
|
||||||
double s_time = 0;
|
double s_time = 0;
|
||||||
|
|
||||||
View::View( void(*cbMainThread)(const std::function<void()>&, bool), const char* addr, uint16_t port, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb, const Config& config )
|
View::View( void(*cbMainThread)(const std::function<void()>&, bool), const char* addr, uint16_t port, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb, const Config& config, AchievementsMgr* amgr )
|
||||||
: m_worker( addr, port, config.memoryLimit == 0 ? -1 : ( config.memoryLimitPercent * tracy::GetPhysicalMemorySize() / 100 ) )
|
: m_worker( addr, port, config.memoryLimit == 0 ? -1 : ( config.memoryLimitPercent * tracy::GetPhysicalMemorySize() / 100 ) )
|
||||||
, m_staticView( false )
|
, m_staticView( false )
|
||||||
, m_viewMode( ViewMode::LastFrames )
|
, m_viewMode( ViewMode::LastFrames )
|
||||||
@ -55,13 +55,15 @@ View::View( void(*cbMainThread)(const std::function<void()>&, bool), const char*
|
|||||||
, m_acb( acb )
|
, m_acb( acb )
|
||||||
, m_userData()
|
, m_userData()
|
||||||
, m_cbMainThread( cbMainThread )
|
, m_cbMainThread( cbMainThread )
|
||||||
|
, m_achievementsMgr( amgr )
|
||||||
|
, m_achievements( config.achievements )
|
||||||
{
|
{
|
||||||
InitTextEditor();
|
InitTextEditor();
|
||||||
|
|
||||||
m_vd.frameTarget = config.targetFps;
|
m_vd.frameTarget = config.targetFps;
|
||||||
}
|
}
|
||||||
|
|
||||||
View::View( void(*cbMainThread)(const std::function<void()>&, bool), FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb, const Config& config )
|
View::View( void(*cbMainThread)(const std::function<void()>&, bool), FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb, const Config& config, AchievementsMgr* amgr )
|
||||||
: m_worker( f )
|
: m_worker( f )
|
||||||
, m_filename( f.GetFilename() )
|
, m_filename( f.GetFilename() )
|
||||||
, m_staticView( true )
|
, m_staticView( true )
|
||||||
@ -78,6 +80,8 @@ View::View( void(*cbMainThread)(const std::function<void()>&, bool), FileRead& f
|
|||||||
, m_acb( acb )
|
, m_acb( acb )
|
||||||
, m_userData( m_worker.GetCaptureProgram().c_str(), m_worker.GetCaptureTime() )
|
, m_userData( m_worker.GetCaptureProgram().c_str(), m_worker.GetCaptureTime() )
|
||||||
, m_cbMainThread( cbMainThread )
|
, m_cbMainThread( cbMainThread )
|
||||||
|
, m_achievementsMgr( amgr )
|
||||||
|
, m_achievements( config.achievements )
|
||||||
{
|
{
|
||||||
m_notificationTime = 4;
|
m_notificationTime = 4;
|
||||||
m_notificationText = std::string( "Trace loaded in " ) + TimeToString( m_worker.GetLoadTime() );
|
m_notificationText = std::string( "Trace loaded in " ) + TimeToString( m_worker.GetLoadTime() );
|
||||||
@ -117,6 +121,12 @@ void View::InitTextEditor()
|
|||||||
m_sourceViewFile = nullptr;
|
m_sourceViewFile = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void View::Achieve( const char* id )
|
||||||
|
{
|
||||||
|
if( !m_achievements || !m_achievementsMgr ) return;
|
||||||
|
m_achievementsMgr->Achieve( id );
|
||||||
|
}
|
||||||
|
|
||||||
void View::ViewSource( const char* fileName, int line )
|
void View::ViewSource( const char* fileName, int line )
|
||||||
{
|
{
|
||||||
assert( fileName );
|
assert( fileName );
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
|
||||||
|
#include "TracyAchievements.hpp"
|
||||||
#include "TracyBadVersion.hpp"
|
#include "TracyBadVersion.hpp"
|
||||||
#include "TracyBuzzAnim.hpp"
|
#include "TracyBuzzAnim.hpp"
|
||||||
#include "TracyConfig.hpp"
|
#include "TracyConfig.hpp"
|
||||||
@ -103,8 +104,8 @@ public:
|
|||||||
using SetScaleCallback = void(*)( float );
|
using SetScaleCallback = void(*)( float );
|
||||||
using AttentionCallback = void(*)();
|
using AttentionCallback = void(*)();
|
||||||
|
|
||||||
View( void(*cbMainThread)(const std::function<void()>&, bool), const char* addr, uint16_t port, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb, const Config& config );
|
View( void(*cbMainThread)(const std::function<void()>&, bool), const char* addr, uint16_t port, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb, const Config& config, AchievementsMgr* amgr );
|
||||||
View( void(*cbMainThread)(const std::function<void()>&, bool), FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb, const Config& config );
|
View( void(*cbMainThread)(const std::function<void()>&, bool), FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb, const Config& config, AchievementsMgr* amgr );
|
||||||
~View();
|
~View();
|
||||||
|
|
||||||
bool Draw();
|
bool Draw();
|
||||||
@ -223,6 +224,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
void InitTextEditor();
|
void InitTextEditor();
|
||||||
|
void Achieve( const char* id );
|
||||||
|
|
||||||
bool DrawImpl();
|
bool DrawImpl();
|
||||||
void DrawNotificationArea();
|
void DrawNotificationArea();
|
||||||
@ -867,6 +869,9 @@ private:
|
|||||||
bool m_attnFailure = false;
|
bool m_attnFailure = false;
|
||||||
bool m_attnWorking = false;
|
bool m_attnWorking = false;
|
||||||
bool m_attnDisconnected = false;
|
bool m_attnDisconnected = false;
|
||||||
|
|
||||||
|
AchievementsMgr* m_achievementsMgr;
|
||||||
|
bool m_achievements = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user