MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / resources_ui

Function resources_ui

TheForceEngine/TFE_Editor/editorResources.cpp:43–154  ·  view source on GitHub ↗

TODO: Add drag and drop functionality.

Source from the content-addressed store, hash-verified

41
42 // TODO: Add drag and drop functionality.
43 bool resources_ui()
44 {
45 pushFont(TFE_Editor::FONT_SMALL);
46 s32 menuHeight = 6 + (s32)ImGui::GetFontSize();
47
48 bool finished = false;
49 f32 winWidth = UI_SCALE(550);
50 ImGui::SetWindowSize("Editor Resources", { winWidth, 70.0f + UI_SCALE(260) });
51 ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoResize;
52
53 if (ImGui::BeginPopupModal("Editor Resources", nullptr, window_flags))
54 {
55 if (ImGui::Checkbox("Ignore Vanilla Assets", &s_ignoreVanilla))
56 {
57 s_resChanged = true;
58 }
59
60 if (ImGui::BeginListBox("##ResourceList", ImVec2(UI_SCALE(480), UI_SCALE(200))))
61 {
62 const size_t count = s_extResources.size();
63 const EditorResource* res = s_extResources.data();
64 for (size_t i = 0; i < count; i++, res++)
65 {
66 bool isSelected = s_curResource == i;
67 if (ImGui::Selectable(res->name, &isSelected))
68 {
69 s_curResource = s32(i);
70 }
71 }
72 ImGui::EndListBox();
73 }
74
75 if (ImGui::Button("Add Archive"))
76 {
77 FileResult res = TFE_Ui::openFileDialog("Open Archive", s_selectPath, filters[s_gameId]);
78 if (!res.empty())
79 {
80 EditorResource eRes;
81 eRes.type = RES_ARCHIVE;
82 const char* filepath = res[0].c_str();
83 FileUtil::getFileNameFromPath(filepath, eRes.name, true);
84
85 char ext[16];
86 FileUtil::getFileExtension(filepath, ext);
87
88 eRes.archive = nullptr;
89 if (strcasecmp(ext, "GOB") == 0)
90 {
91 eRes.archive = Archive::getArchive(ARCHIVE_GOB, eRes.name, filepath);
92 }
93 else if (strcasecmp(ext, "ZIP") == 0)
94 {
95 eRes.archive = Archive::getArchive(ARCHIVE_ZIP, eRes.name, filepath);
96 }
97 if (eRes.archive)
98 {
99 s_extResources.push_back(eRes);
100 }

Callers 1

handlePopupEndFunction · 0.85

Calls 15

pushFontFunction · 0.85
ImVec2Function · 0.85
ButtonEnum · 0.85
openFileDialogFunction · 0.85
directorySelectDialogFunction · 0.85
resources_clearFunction · 0.85
popFontFunction · 0.85
project_saveFunction · 0.85
dataMethod · 0.80
c_strMethod · 0.80
push_backMethod · 0.80
getArchiveFunction · 0.70

Tested by

no test coverage detected