Skip to content

Commit b46a517

Browse files
committed
add behaviour context for configs | update profile bus
Signed-off-by: Wojciech Czerski <[email protected]>
1 parent cddb207 commit b46a517

File tree

3 files changed

+115
-30
lines changed

3 files changed

+115
-30
lines changed

Gems/FPSProfiler/Code/Include/FPSProfiler/FPSProfilerBus.h

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -138,49 +138,62 @@ namespace FPSProfiler
138138

139139
/**
140140
* @brief Called when a new file is created.
141-
* @param filePath The path of the newly created file.
141+
* @param config File Save Settings Configuration.
142142
*/
143-
virtual void OnFileCreated(const AZStd::string& filePath)
143+
virtual void OnFileCreated(const Configs::FileSaveSettings& config)
144144
{
145145
}
146146

147147
/**
148148
* @brief Called when an existing file is updated.
149-
* @param filePath The path of the file that was modified.
149+
* @param config File Save Settings Configuration.
150150
*/
151-
virtual void OnFileUpdate(const AZStd::string& filePath)
151+
virtual void OnFileUpdate(const Configs::FileSaveSettings& config)
152152
{
153153
}
154154

155155
/**
156156
* @brief Called when a file is successfully saved.
157-
* @param filePath The path of the saved file.
157+
* @param config File Save Settings Configuration.
158158
*/
159-
virtual void OnFileSaved(const AZStd::string& filePath)
159+
virtual void OnFileSaved(const Configs::FileSaveSettings& config)
160160
{
161161
}
162162

163163
/**
164164
* @brief Called when the profiling process starts.
165-
* @param config The configuration settings used for the profiling session.
165+
* @param recordConfig The configuration settings used for the record session.
166+
* @param precisionConfig The configuration settings used for the precision.
167+
* @param debugConfig The configuration settings used for the debugging.
166168
*/
167-
virtual void OnProfileStart(const Configs::FileSaveSettings& config)
169+
virtual void OnProfileStart(
170+
const Configs::RecordSettings& recordConfig,
171+
const Configs::PrecisionSettings& precisionConfig,
172+
const Configs::DebugSettings& debugConfig)
168173
{
169174
}
170175

171176
/**
172177
* @brief Called when the profiling data is reset.
173-
* @param config The configuration settings used for the profiling session.
178+
* @param recordConfig The configuration settings used for the record session.
179+
* @param precisionConfig The configuration settings used for the precision.
174180
*/
175-
virtual void OnProfileReset(const Configs::FileSaveSettings& config)
181+
virtual void OnProfileReset(const Configs::RecordSettings& recordConfig, const Configs::PrecisionSettings& precisionConfig)
176182
{
177183
}
178184

179185
/**
180186
* @brief Called when the profiling process stops.
181-
* @param config The configuration settings used for the profiling session.
187+
* @param saveConfig The configuration settings used for the file operations.
188+
* @param recordConfig The configuration settings used for the record session.
189+
* @param precisionConfig The configuration settings used for the precision.
190+
* @param debugConfig The configuration settings used for the debugging.
182191
*/
183-
virtual void OnProfileStop(const Configs::FileSaveSettings& config)
192+
virtual void OnProfileStop(
193+
const Configs::FileSaveSettings& saveConfig,
194+
const Configs::RecordSettings& recordConfig,
195+
const Configs::PrecisionSettings& precisionConfig,
196+
const Configs::DebugSettings& debugConfig)
184197
{
185198
}
186199
};
@@ -213,34 +226,41 @@ namespace FPSProfiler
213226
OnProfileReset,
214227
OnProfileStop);
215228

216-
void OnFileCreated(const AZStd::string& filePath) override
229+
void OnFileCreated(const Configs::FileSaveSettings& config) override
217230
{
218-
Call(FN_OnFileCreated, filePath);
231+
Call(FN_OnFileCreated, config);
219232
}
220233

221-
void OnFileUpdate(const AZStd::string& filePath) override
234+
void OnFileUpdate(const Configs::FileSaveSettings& config) override
222235
{
223-
Call(FN_OnFileUpdate, filePath);
236+
Call(FN_OnFileUpdate, config);
224237
}
225238

226-
void OnFileSaved(const AZStd::string& filePath) override
239+
void OnFileSaved(const Configs::FileSaveSettings& config) override
227240
{
228-
Call(FN_OnFileSaved, filePath);
241+
Call(FN_OnFileSaved, config);
229242
}
230243

231-
void OnProfileStart(const Configs::FileSaveSettings& config) override
244+
void OnProfileStart(
245+
const Configs::RecordSettings& recordConfig,
246+
const Configs::PrecisionSettings& precisionConfig,
247+
const Configs::DebugSettings& debugConfig) override
232248
{
233-
Call(FN_OnProfileStart, config);
249+
Call(FN_OnProfileStart, recordConfig, precisionConfig, debugConfig);
234250
}
235251

236-
void OnProfileReset(const Configs::FileSaveSettings& config) override
252+
void OnProfileReset(const Configs::RecordSettings& recordConfig, const Configs::PrecisionSettings& precisionConfig) override
237253
{
238-
Call(FN_OnProfileReset, config);
254+
Call(FN_OnProfileReset, recordConfig, precisionConfig);
239255
}
240256

241-
void OnProfileStop(const Configs::FileSaveSettings& config) override
257+
void OnProfileStop(
258+
const Configs::FileSaveSettings& saveConfig,
259+
const Configs::RecordSettings& recordConfig,
260+
const Configs::PrecisionSettings& precisionConfig,
261+
const Configs::DebugSettings& debugConfig) override
242262
{
243-
Call(FN_OnProfileStop, config);
263+
Call(FN_OnProfileStop, saveConfig, recordConfig, precisionConfig, debugConfig);
244264
}
245265
};
246266

Gems/FPSProfiler/Code/Source/Clients/FPSProfilerComponent.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ namespace FPSProfiler
144144
}
145145

146146
// Notify - File Saved
147-
FPSProfilerNotificationBus::Broadcast(&FPSProfilerNotifications::OnFileSaved, m_configFile.m_OutputFilename.c_str());
147+
FPSProfilerNotificationBus::Broadcast(&FPSProfilerNotifications::OnFileSaved, m_configFile);
148148
FPSProfilerRequestBus::Handler::BusDisconnect();
149149
}
150150

@@ -255,7 +255,7 @@ namespace FPSProfiler
255255
}
256256

257257
// Notify - Profile Started
258-
FPSProfilerNotificationBus::Broadcast(&FPSProfilerNotifications::OnProfileStart, m_configFile);
258+
FPSProfilerNotificationBus::Broadcast(&FPSProfilerNotifications::OnProfileStart, m_configRecord, m_configPrecision, m_configDebug);
259259
AZ_Printf("FPS Profiler", "Profiling started.");
260260
}
261261

@@ -277,7 +277,8 @@ namespace FPSProfiler
277277
SaveLogToFile();
278278

279279
// Notify - Profile Stopped
280-
FPSProfilerNotificationBus::Broadcast(&FPSProfilerNotifications::OnProfileStop, m_configFile);
280+
FPSProfilerNotificationBus::Broadcast(
281+
&FPSProfilerNotifications::OnProfileStop, m_configFile, m_configRecord, m_configPrecision, m_configDebug);
281282
AZ_Printf("FPS Profiler", "Profiling stopped.");
282283
}
283284

@@ -294,7 +295,7 @@ namespace FPSProfiler
294295
m_logBuffer.clear();
295296

296297
// Notify - Profile Reset
297-
FPSProfilerNotificationBus::Broadcast(&FPSProfilerNotifications::OnProfileReset, m_configFile);
298+
FPSProfilerNotificationBus::Broadcast(&FPSProfilerNotifications::OnProfileReset, m_configRecord, m_configPrecision);
298299
AZ_Printf("FPS Profiler", "Profiling data reseted.");
299300
}
300301

@@ -483,7 +484,7 @@ namespace FPSProfiler
483484
file.Close();
484485

485486
// Notify - File Created
486-
FPSProfilerNotificationBus::Broadcast(&FPSProfilerNotifications::OnFileCreated, m_configFile.m_OutputFilename.c_str());
487+
FPSProfilerNotificationBus::Broadcast(&FPSProfilerNotifications::OnFileCreated, m_configFile);
487488
}
488489

489490
void FPSProfilerComponent::WriteDataToFile()
@@ -507,7 +508,7 @@ namespace FPSProfiler
507508
m_logBuffer.clear();
508509

509510
// Notify - File Update
510-
FPSProfilerNotificationBus::Broadcast(&FPSProfilerNotifications::OnFileUpdate, m_configFile.m_OutputFilename.c_str());
511+
FPSProfilerNotificationBus::Broadcast(&FPSProfilerNotifications::OnFileUpdate, m_configFile);
511512
}
512513

513514
float FPSProfilerComponent::BytesToMB(AZStd::size_t bytes)

Gems/FPSProfiler/Code/Source/Configurations/FPSProfilerConfig.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "FPSProfilerConfig.h"
22

3+
#include <AzCore/RTTI/BehaviorContext.h>
34
#include <AzCore/Serialization/EditContext.h>
45

56
namespace FPSProfiler::Configs
@@ -63,6 +64,22 @@ namespace FPSProfiler::Configs
6364
"seconds. This allows you to save automatically without manual input each time.");
6465
}
6566
}
67+
68+
if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
69+
{
70+
if (behaviorContext->m_classes.contains("FileSaveSettings"))
71+
{
72+
return;
73+
}
74+
75+
behaviorContext->Class<FileSaveSettings>("FileSaveSettings")
76+
->Attribute(AZ::Script::Attributes::Category, "FPSProfiler")
77+
->Constructor<>()
78+
->Property("outputFilename", BehaviorValueProperty(&FileSaveSettings::m_OutputFilename))
79+
->Property("autoSave", BehaviorValueProperty(&FileSaveSettings::m_AutoSave))
80+
->Property("autoSaveAtFrame", BehaviorValueProperty(&FileSaveSettings::m_AutoSaveAtFrame))
81+
->Property("saveWithTimestamp", BehaviorValueProperty(&FileSaveSettings::m_SaveWithTimestamp));
82+
}
6683
}
6784

6885
void RecordSettings::Reflect(AZ::ReflectContext* context)
@@ -132,6 +149,22 @@ namespace FPSProfiler::Configs
132149
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::EntireTree);
133150
}
134151
}
152+
153+
if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
154+
{
155+
if (behaviorContext->m_classes.contains("RecordSettings"))
156+
{
157+
return;
158+
}
159+
160+
behaviorContext->Class<RecordSettings>("RecordSettings")
161+
->Attribute(AZ::Script::Attributes::Category, "FPSProfiler")
162+
->Constructor<>()
163+
->Property("recordType", BehaviorValueProperty(&RecordSettings::m_recordType))
164+
->Property("framesToSkip", BehaviorValueProperty(&RecordSettings::m_framesToSkip))
165+
->Property("framesToRecord", BehaviorValueProperty(&RecordSettings::m_framesToRecord))
166+
->Property("recordStats", BehaviorValueProperty(&RecordSettings::m_RecordStats));
167+
}
135168
}
136169

137170
void PrecisionSettings::Reflect(AZ::ReflectContext* context)
@@ -194,6 +227,22 @@ namespace FPSProfiler::Configs
194227
"enabled.");
195228
}
196229
}
230+
231+
if (auto* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
232+
{
233+
if (behaviorContext->m_classes.contains("PrecisionSettings"))
234+
{
235+
return;
236+
}
237+
238+
behaviorContext->Class<PrecisionSettings>("PrecisionSettings")
239+
->Attribute(AZ::Script::Attributes::Category, "FPSProfiler")
240+
->Constructor<>()
241+
->Property("NearZeroPrecision", BehaviorValueProperty(&PrecisionSettings::m_NearZeroPrecision))
242+
->Property("AvgFpsType", BehaviorValueProperty(&PrecisionSettings::m_avgFpsType))
243+
->Property("SmoothingFactor", BehaviorValueProperty(&PrecisionSettings::m_smoothingFactor))
244+
->Property("KeepHistory", BehaviorValueProperty(&PrecisionSettings::m_keepHistory));
245+
}
197246
}
198247

199248
void DebugSettings::Reflect(AZ::ReflectContext* context)
@@ -236,5 +285,20 @@ namespace FPSProfiler::Configs
236285
});
237286
}
238287
}
288+
289+
if (auto* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
290+
{
291+
if (behaviorContext->m_classes.contains("DebugSettings"))
292+
{
293+
return;
294+
}
295+
296+
behaviorContext->Class<DebugSettings>("DebugSettings")
297+
->Attribute(AZ::Script::Attributes::Category, "FPSProfiler")
298+
->Constructor<>()
299+
->Property("PrintDebugInfo", BehaviorValueProperty(&DebugSettings::m_PrintDebugInfo))
300+
->Property("ShowFps", BehaviorValueProperty(&DebugSettings::m_ShowFps))
301+
->Property("Color", BehaviorValueProperty(&DebugSettings::m_Color));
302+
}
239303
}
240304
} // namespace FPSProfiler::Configs

0 commit comments

Comments
 (0)