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
148 void OnBuildAll();
149
155 void CancelBuildAll();
156
162 void TickBuildAllQueue();
163
168 bool IsAnyBuildInProgress() const;
169
173 void OnBuildAndRun();
174
178 void OnBuildAndRunOnDevice();
179
185 void ExecuteBuild(bool runAfterBuild, bool runOnDevice = false);
186
193 void ExecuteDockerBuild(const BuildProfile& profile, bool runAfterBuild, bool runOnDevice = false);
194
201 void StartAsyncDockerBuild(const BuildProfile& profile, bool runAfterBuild, bool runOnDevice);
202
206 void DockerBuildThreadFunc();
207
211 void CancelDockerBuild();
212
216 void FinalizeBuild();
217
224 void ExecuteLocalBuild(const BuildProfile& profile, bool runAfterBuild, bool runOnDevice = false);
225
231 void LaunchEmulator(const BuildProfile& profile, const std::string& outputPath);
232
237 void Launch3dsLink(const std::string& outputPath);
238
243 void LaunchWiiload(const std::string& outputPath);
244
249 bool CheckDockerAvailable();
250
256 std::string BuildDockerCommand(const BuildProfile& profile);
257
263 std::string GetOutputDirectory(const BuildProfile& profile);
264
266 bool mIsOpen = false;
267
269 bool mShowDockerWarning = false;
270
272 bool mShow3dsLinkWarning = false;
273
275 bool mShowWiiloadWarning = false;
276
278 bool mBuildInProgress = false;
279
281 std::string mPendingOutputPath;
282
284 char mNameBuffer[256] = {};
285
287 char mOutputDirBuffer[512] = {};
288
290 bool mShowBuildModal = false;
291
293 DockerBuildState mBuildState;
294
296 std::string mDisplayOutput;
297
299 std::set<int> mSelectedLineIndices;
300
302 int mSelectionAnchor = -1;
303
305 int mSelectionLineCount = 0;
306
308 bool mAutoScroll = true;
309
311 bool mAutoCloseOnFinish = false;
312
314 bool mForceRebuild = false;
315
317 bool mBuildAllRunning = false;
318
320 int32_t mBuildAllIndex = -1;
321
323 int32_t mBuildAllFailedIndex = -1;
324
326 bool mBuildAllLastWasDocker = false;
327
329 std::string mBuildAllFailedName;
330
341 bool mBuildAllSavedForceRebuild = false;
342};
343
348PackagingWindow* GetPackagingWindow();
349
350#endif
Platform
Definition EngineTypes.h:31