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
59 // Git-repo helpers for the per-row "Open in Version Control" /
60 // "Init Git" actions. HasGitRepo does a libgit2 discover under the
61 // hood (filesystem walk) — caching per row avoids re-running it every
62 // frame across the full installed-addon list. Cache invalidates when
63 // the active project changes.
64 bool DoesAddonHaveGitRepo(const std::string& addonId);
65 void InvalidateAddonGitRepoCacheIfProjectChanged();
66 std::string GetAddonDirectory(const std::string& addonId) const;
67 void OpenAddonInVersionControl(const std::string& addonId);
68 void InitAddonGitRepo(const std::string& addonId);
69 void OnAddRepository();
70 void OnRemoveRepository(const std::string& url);
71 void OnRefreshRepositories();
72 void OnResolveDependencies();
73
74 // Native addon operations
75 void OnBuildNativeAddon(const std::string& addonId);
76 void OnReloadNativeAddon(const std::string& addonId);
77 void OnToggleNativeEnabled(const std::string& addonId);
78 void OnToggleNativeMode(const std::string& addonId);
79 void OnSyncNativeAddonBinary(const std::string& addonId);
80
81 bool mIsOpen = false;
82 int mSelectedTab = 0; // 0=Browse, 1=Installed, 2=Repositories
83
84 // View mode: true = table (default), false = cards. Persisted to disk via JsonSettings.
85 bool mUseTableView = true;
86
87 // Popup state
88 bool mShowAddonDetails = false;
89 bool mShowAddRepoPopup = false;
90 std::string mSelectedAddonId;
91 char mRepoUrlBuffer[512] = {};
92 std::string mErrorMessage;
93 std::string mStatusMessage;
94
95 // Filter
96 char mSearchBuffer[256] = {};
97 std::vector<std::string> mSelectedTags;
98
99 // Available tags (collected from addons)
100 std::vector<std::string> mAvailableTags;
101
102 // Refresh state
103 bool mNeedsRefresh = true;
104 bool mIsRefreshing = false;
105
106 // Uninstall confirmation
107 bool mShowUninstallConfirm = false;
108 std::string mUninstallAddonId;
109 void DrawUninstallConfirmPopup();
110
111 // Build log popup
112 bool mShowBuildLog = false;
113 std::string mBuildLogAddonId;
114
115 // Thumbnail cache
116 struct ThumbnailEntry
117 {
118 ImTextureID mTexId = 0;
119 Image* mImage = nullptr;
120 };
121 ImTextureID GetAddonThumbnail(const std::string& addonId);
122 void ClearThumbnailCache();
123 std::unordered_map<std::string, ThumbnailEntry> mThumbnailCache;
124
125 // Per-addon "is this dir inside a git repo" cache. Keyed by addonId
126 // (the Packages/ subdir name). Cleared on project switch.
127 std::unordered_map<std::string, bool> mAddonGitRepoCache;
128 std::string mGitRepoCacheProjectDir;
129};
130
131AddonsWindow* GetAddonsWindow();
132
133#endif
void Shutdown()
Definition Engine.cpp:1026