MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / DrawSimpleModMenu

Function DrawSimpleModMenu

Source/GUI/dimgui/modmenu.cpp:145–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145static void DrawSimpleModMenu() {
146 CategorizedModsList& categmods = GetCachedCategorizedMods();
147 CategorizedModsList::iterator modcatit = categmods.begin();
148
149 for (; modcatit != categmods.end(); modcatit++) {
150 const std::vector<ModInstance*> mods = modcatit->second;
151 if (mods.size() > 0 && ImGui::TreeNodeEx(modcatit->first, ImGuiTreeNodeFlags_DefaultOpen)) {
152 for (auto mod : mods) {
153 bool active = mod->IsActive();
154 ModID sid = mod->GetSid();
155 ImGui::PushID(sid.id);
156 if (CanActivateModInstance(mod)) {
157 if (ImGui::Checkbox(mod->name, &active)) {
158 ModLoading::Instance().GetMod(mod->GetSid())->Activate(active);
159 mod_can_activate_check_cache_map_.clear();
160 }
161 } else {
162 ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyle().Colors[ImGuiCol_TextDisabled]);
163 ImGui::Checkbox(mod->name, &active);
164 ImGui::PopStyleColor(1);
165 }
166 ImGui::PopID();
167 if (ImGui::IsItemHovered()) {
168 ImGui::BeginTooltip();
169 ImGui::PushTextWrapPos(450.0f);
170 const int kBufSize = 512;
171 char buf[kBufSize];
172
173 if (mod->GetValidityErrors().size() > 0) {
174 FormatString(
175 buf, kBufSize,
176 "%s %s\nWarnings:\n%s",
177 mod->name.c_str(), mod->version.c_str(), mod->GetValidityErrors().c_str());
178 } else {
179 FormatString(
180 buf, kBufSize,
181 "%s %s\n",
182 mod->name.c_str(), mod->version.c_str());
183 }
184 ImGui::TextUnformatted(buf);
185 ImGui::PopTextWrapPos();
186 ImGui::EndTooltip();
187 }
188 }
189 ImGui::TreePop();
190 }
191 }
192}
193
194static void ImGuiYesNo(bool v) {
195 ImGui::Text("%s", v ? "Yes" : "No");

Callers 1

DrawModMenuFunction · 0.85

Calls 15

CanActivateModInstanceFunction · 0.85
PushStyleColorFunction · 0.85
PopStyleColorFunction · 0.85
FormatStringFunction · 0.85
GetSidMethod · 0.80
GetModMethod · 0.80
GetValidityErrorsMethod · 0.80
CheckboxClass · 0.50
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
IsActiveMethod · 0.45

Tested by

no test coverage detected