载入中...
搜索中...
未找到
ScenarioRecorder.h
浏览该文件的文档.
1#pragma once
2
3#include "common/Export.h"
4
5#include <functional>
6#include <string>
7#include <vector>
8
9struct SQVM;
10typedef struct SQVM* HSQUIRRELVM;
11
13class PlatformEvent;
14class Message;
15} // namespace eve::platform_event
16
17namespace eve::dev {
18
21 std::string name;
22 std::vector<std::string> args;
23};
24
27 int frame = 0;
28 std::vector<ScenarioEvent> events;
29};
30
48public:
50 static ScenarioRecorder& instance();
51
54
55 // ---- recording -----------------------------------------------------
60 bool begin(HSQUIRRELVM vm, std::string* err = nullptr);
62 void markFrame();
68 bool end(const std::string& path, std::string* err = nullptr);
70 void cancel();
72 bool recording() const { return vm_ != nullptr && recording_; }
73
74 // ---- replay ---------------------------------------------------------
79 bool beginReplay(HSQUIRRELVM vm, const std::string& path, std::string* err = nullptr);
84 bool stageFrame();
86 bool replaying() const { return replay_; }
88 int framesRemaining() const { return replay_ ? static_cast<int>(frames_.size()) - replayIndex_ : 0; }
89
90 // ---- DevTool wiring --------------------------------------------------
92 void setErrorInfo(const std::string& report, const std::string& site);
94 void onEventConsumed(const eve::platform_event::Message& msg);
96 void detachObserver();
97
98 // ---- accessors --------------------------------------------------------
100 const std::string& baseline() const { return baseline_; }
102 const std::vector<ScenarioFrame>& frames() const { return frames_; }
104 const std::string& errorReport() const { return errorReport_; }
106 const std::string& errorSite() const { return errorSite_; }
107
109 static bool save(const std::string& baseline, const std::vector<ScenarioFrame>& frames,
110 const std::string& errorReport, const std::string& errorSite,
111 const std::string& path, std::string* err = nullptr);
113 static bool load(const std::string& path, std::string* baseline,
114 std::vector<ScenarioFrame>* frames, std::string* errorReport,
115 std::string* errorSite, std::string* err = nullptr);
116
117private:
118 ScenarioRecorder() = default;
119
120 void setObserver();
121
122 HSQUIRRELVM vm_ = nullptr;
123 bool recording_ = false;
124 bool replay_ = false;
125 int replayIndex_ = 0;
126 int currentFrame_ = 0;
127 std::string baseline_;
128 std::vector<ScenarioFrame> frames_;
129 std::string errorReport_;
130 std::string errorSite_;
131 std::function<void(const eve::platform_event::Message&)> savedObserver_;
132 eve::platform_event::PlatformEvent* eventModule_ = nullptr;
133};
134
135} // namespace eve::dev
struct SQVM * HSQUIRRELVM
HSQUIRRELVM vm
Definition ECS.cpp:20
#define EVENGINE_API_FOUNDATION_INLINE
仅供"只有内联成员"的类型使用的组宏:拥有者 dllexport,消费方不导入。
Definition Export.h:170
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Definition Export.h:106
std::string path
Definition PlayHost.cpp:110
float begin
struct SQVM * HSQUIRRELVM
A state-driven bug scenario: baseline snapshot + ordered per-frame inputs.
ScenarioRecorder(const ScenarioRecorder &)=delete
const std::string & errorSite() const
Error site.
int framesRemaining() const
Number of frames remaining to stage.
const std::string & errorReport() const
Error report.
bool replaying() const
True while a replay is in progress with frames remaining.
bool recording() const
True while a scenario is being recorded.
const std::vector< ScenarioFrame > & frames() const
Frames.
const std::string & baseline() const
Baseline.
ScenarioRecorder & operator=(const ScenarioRecorder &)=delete
A named event carrying an ordered list of Variant payloads. Pushed messages are heap-allocated; the q...
EVENGINE_API_FOUNDATION public API.
One serializable event payload recorded from the event queue.
std::vector< std::string > args
String payloads (non-string payloads dropped).
std::string name
Event/message name ("keypressed", ...).
All events consumed during one game frame.
std::vector< ScenarioEvent > events
Events consumed that frame, in order.