Polyphase Game Engine
Loading...
Searching...
No Matches
PackagingWindow.h
Go to the documentation of this file.
1#pragma once
2
3#if EDITOR
4
5#include <string>
6#include <thread>
7#include <mutex>
8#include <atomic>
9#include <set>
10#if PLATFORM_LINUX
11#include <sys/types.h>
12#endif
13#include "BuildProfile.h"
14
18struct DockerBuildState
19{
20 std::thread mBuildThread;
21 std::atomic<bool> mRunning{false};
22 std::atomic<bool> mCancelRequested{false};
23 std::atomic<bool> mComplete{false};
24 std::atomic<bool> mSuccess{false};
25 std::atomic<int> mExitCode{0};
26
27 std::mutex mOutputMutex;
28 std::string mOutput;
29 bool mOutputDirty{false};
30
31 std::string mCommand;
32 bool mRunAfterBuild{false};
33 bool mRunOnDevice{false};
34 bool mOpenDirectoryOnFinish{true};
35 Platform mTargetPlatform{Platform::Linux};
36 std::string mOutputPath;
37
38#if PLATFORM_LINUX
39 pid_t mProcessId{0};
40#elif PLATFORM_WINDOWS
41 void* mProcessHandle{nullptr};
42#endif
43};
44
52class PackagingWindow
53{
54public:
55 PackagingWindow();
56 ~PackagingWindow();
57
61 void Open();
62
66 void Close();
67
72 void Draw();
73
78 bool IsOpen() const { return mIsOpen; }
79
90 void BuildAndRunWithProfile(Platform platform, bool embedded, bool runOnDevice = false);
91
92private:
96 void DrawProfileList();
97
101 void DrawProfileSettings();
102
106 void DrawBuildButtons();
107
111 void DrawDockerWarningPopup();
112
116 void Draw3dsLinkWarningPopup();
117
121 void DrawWiiloadWarningPopup();
122
126 void DrawBuildOutputModal();
127
129 std::string BuildAllOutputLinesText() const;
130
132 std::string BuildSelectedOutputLinesText() const;
133
137 void OpenLauncherSettings();
138
142 void OnBuild();
143
147 void OnBuildAndRun();
148
152 void OnBuildAndRunOnDevice();
153
159 void ExecuteBuild(bool runAfterBuild, bool runOnDevice = false);
160
167 void ExecuteDockerBuild(const BuildProfile& profile, bool runAfterBuild, bool runOnDevice = false);
168
175 void StartAsyncDockerBuild(const BuildProfile& profile, bool runAfterBuild, bool runOnDevice);
176
180 void DockerBuildThreadFunc();
181
185 void CancelDockerBuild();
186
190 void FinalizeBuild();
191
198 void ExecuteLocalBuild(const BuildProfile& profile, bool runAfterBuild, bool runOnDevice = false);
199
205 void LaunchEmulator(const BuildProfile& profile, const std::string& outputPath);
206
211 void Launch3dsLink(const std::string& outputPath);
212
217 void LaunchWiiload(const std::string& outputPath);
218
223 bool CheckDockerAvailable();
224
230 std::string BuildDockerCommand(const BuildProfile& profile);
231
237 std::string GetOutputDirectory(const BuildProfile& profile);
238
240 bool mIsOpen = false;
241
243 bool mShowDockerWarning = false;
244
246 bool mShow3dsLinkWarning = false;
247
249 bool mShowWiiloadWarning = false;
250
252 bool mBuildInProgress = false;
253
255 std::string mPendingOutputPath;
256
258 char mNameBuffer[256] = {};
259
261 char mOutputDirBuffer[512] = {};
262
264 bool mShowBuildModal = false;
265
267 DockerBuildState mBuildState;
268
270 std::string mDisplayOutput;
271
273 std::set<int> mSelectedLineIndices;
274
276 int mSelectionAnchor = -1;
277
279 int mSelectionLineCount = 0;
280
282 bool mAutoScroll = true;
283
285 bool mAutoCloseOnFinish = false;
286
288 bool mForceRebuild = false;
289};
290
295PackagingWindow* GetPackagingWindow();
296
297#endif
Platform
Definition EngineTypes.h:31