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;
13
22class AddonsWindow
23{
24public:
25 AddonsWindow();
26 ~AddonsWindow();
27
28 void Open();
29 void Close();
30 void Draw();
31 bool IsOpen() const { return mIsOpen; }
32
33 // Drop the thumbnail path memo and ask the shared EditorImageCache to
34 // forget our entries. Called from EditorImguiPreShutdown; the GPU release
35 // itself is the cache's business.
36 void Shutdown();
37
38private:
39 void DrawAddonBrowser();
40 void DrawInstalledAddons();
41 void DrawRepositoryManager();
42 void DrawAddonCard(const Addon& addon, float cardWidth);
43 void DrawAddonDetailsPopup();
44 void DrawAddRepoPopup();
45
46 // Table-view + shared helpers
47 void DrawViewModeToggle();
48 void DrawAddonTable_Browse(const std::vector<const Addon*>& filtered);
49 void DrawAddonTable_Installed(const std::vector<InstalledAddon>& installed);
50 void DrawClampedName(const char* name, float maxWidth);
51 void LoadViewSettings();
52 void SaveViewSettings();
53
54 void OnDownloadAddon(const std::string& addonId);
55 void OnViewMore(const std::string& addonId);
56 void OnUninstallAddon(const std::string& addonId);
57
58 // Git-repo helpers for the per-row "Open in Version Control" /
59 // "Init Git" actions. HasGitRepo does a libgit2 discover under the
60 // hood (filesystem walk) — caching per row avoids re-running it every
61 // frame across the full installed-addon list. Cache invalidates when
62 // the active project changes.
63 bool DoesAddonHaveGitRepo(const std::string& addonId);
64 void InvalidateAddonGitRepoCacheIfProjectChanged();
65 std::string GetAddonDirectory(const std::string& addonId) const;
66 void OpenAddonInVersionControl(const std::string& addonId);
67 void InitAddonGitRepo(const std::string& addonId);
68 void OnAddRepository();
69 void OnRemoveRepository(const std::string& url);
70 void OnRefreshRepositories();
71 void OnResolveDependencies();
72
73 // Native addon operations
74 void OnBuildNativeAddon(const std::string& addonId);
75 void OnReloadNativeAddon(const std::string& addonId);
76 void OnToggleNativeEnabled(const std::string& addonId);
77 void OnToggleNativeMode(const std::string& addonId);
78 void OnSyncNativeAddonBinary(const std::string& addonId);
79
80 bool mIsOpen = false;
81 int mSelectedTab = 0; // 0=Browse, 1=Installed, 2=Repositories
82
83 // View mode: true = table (default), false = cards. Persisted to disk via JsonSettings.
84 bool mUseTableView = true;
85
86 // Popup state
87 bool mShowAddonDetails = false;
88 bool mShowAddRepoPopup = false;
89 std::string mSelectedAddonId;
90 char mRepoUrlBuffer[512] = {};
91 std::string mErrorMessage;
92 std::string mStatusMessage;
93
94 // Filter
95 char mSearchBuffer[256] = {};
96 std::vector<std::string> mSelectedTags;
97 std::string mSelectedCategory; // empty = "All"
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 path memo: addonId -> resolved absolute PNG path ("" when the
116 // addon has none). The decoded texture lives in the shared
117 // EditorImageCache, which owns it for the editor session; this map only
118 // memoizes the two-location path search so we don't stat the filesystem
119 // once per card per frame.
120 ImTextureID GetAddonThumbnail(const std::string& addonId);
121 void ClearThumbnailCache();
122 std::unordered_map<std::string, std::string> mThumbnailPaths;
123
124 // Per-addon "is this dir inside a git repo" cache. Keyed by addonId
125 // (the Packages/ subdir name). Cleared on project switch.
126 std::unordered_map<std::string, bool> mAddonGitRepoCache;
127 std::string mGitRepoCacheProjectDir;
128};
129
130AddonsWindow* GetAddonsWindow();
131
132#endif
void Shutdown()
Definition Engine.cpp:1147