Polyphase Game Engine
Loading...
Searching...
No Matches
AddonsWindow.h
Go to the documentation of this file.
1#pragma once
2
3#if EDITOR
4
5#include <string>
6#include <vector>
7#include <unordered_map>
8
9#include "imgui.h"
10
11struct Addon;
12struct InstalledAddon;
13class Image;
14
23class AddonsWindow
24{
25public:
26 AddonsWindow();
27 ~AddonsWindow();
28
29 void Open();
30 void Close();
31 void Draw();
32 bool IsOpen() const { return mIsOpen; }
33
34 // Release Vulkan-backed thumbnail resources. Must be called while the
35 // Vulkan device is still valid (i.e. from EditorImguiPreShutdown), not
36 // from the static destructor.
37 void Shutdown();
38
39private:
40 void DrawAddonBrowser();
41 void DrawInstalledAddons();
42 void DrawRepositoryManager();
43 void DrawAddonCard(const Addon& addon, float cardWidth);
44 void DrawAddonDetailsPopup();
45 void DrawAddRepoPopup();
46
47 // Table-view + shared helpers
48 void DrawViewModeToggle();
49 void DrawAddonTable_Browse(const std::vector<const Addon*>& filtered);
50 void DrawAddonTable_Installed(const std::vector<InstalledAddon>& installed);
51 void DrawClampedName(const char* name, float maxWidth);
52 void LoadViewSettings();
53 void SaveViewSettings();
54
55 void OnDownloadAddon(const std::string& addonId);
56 void OnViewMore(const std::string& addonId);
57 void OnUninstallAddon(const std::string& addonId);
58 void OnAddRepository();
59 void OnRemoveRepository(const std::string& url);
60 void OnRefreshRepositories();
61
62 // Native addon operations
63 void OnBuildNativeAddon(const std::string& addonId);
64 void OnReloadNativeAddon(const std::string& addonId);
65 void OnToggleNativeEnabled(const std::string& addonId);
66 void OnToggleNativeMode(const std::string& addonId);
67 void OnSyncNativeAddonBinary(const std::string& addonId);
68
69 bool mIsOpen = false;
70 int mSelectedTab = 0; // 0=Browse, 1=Installed, 2=Repositories
71
72 // View mode: true = table (default), false = cards. Persisted to disk via JsonSettings.
73 bool mUseTableView = true;
74
75 // Popup state
76 bool mShowAddonDetails = false;
77 bool mShowAddRepoPopup = false;
78 std::string mSelectedAddonId;
79 char mRepoUrlBuffer[512] = {};
80 std::string mErrorMessage;
81 std::string mStatusMessage;
82
83 // Filter
84 char mSearchBuffer[256] = {};
85 std::vector<std::string> mSelectedTags;
86
87 // Available tags (collected from addons)
88 std::vector<std::string> mAvailableTags;
89
90 // Refresh state
91 bool mNeedsRefresh = true;
92 bool mIsRefreshing = false;
93
94 // Uninstall confirmation
95 bool mShowUninstallConfirm = false;
96 std::string mUninstallAddonId;
97 void DrawUninstallConfirmPopup();
98
99 // Build log popup
100 bool mShowBuildLog = false;
101 std::string mBuildLogAddonId;
102
103 // Thumbnail cache
104 struct ThumbnailEntry
105 {
106 ImTextureID mTexId = 0;
107 Image* mImage = nullptr;
108 };
109 ImTextureID GetAddonThumbnail(const std::string& addonId);
110 void ClearThumbnailCache();
111 std::unordered_map<std::string, ThumbnailEntry> mThumbnailCache;
112};
113
114AddonsWindow* GetAddonsWindow();
115
116#endif
void Shutdown()
Definition Engine.cpp:916