WoW Model Viewer
Your premiere tool for viewing, equipping and animating World of Warcraft models.
Loading...
Searching...
No Matches
PresetsPanel.cpp
Go to the documentation of this file.
1#include "PresetsPanel.h"
2
3#include <cassert>
4
5#include "imgui.h"
6#include "imgui_stdlib.h"
7
9{
10 assert(ctx.presetPath && "DrawContext::presetPath must not be null");
11 assert(ctx.presetStatus && "DrawContext::presetStatus must not be null");
12
13 ImGui::SeparatorText("Character Preset");
14 ImGui::Text("File:");
15 ImGui::SetNextItemWidth(-1);
16 ImGui::InputText("##presetPath", ctx.presetPath);
17
18 {
19 bool canSave = ctx.isChar && ctx.hasModel;
20 if (!canSave) ImGui::BeginDisabled();
21
22 if (ImGui::Button("Save Preset", ImVec2(-1, 0)))
23 ctx.savePreset(ctx.presetPath->c_str());
24
25 if (!canSave) ImGui::EndDisabled();
26 }
27
28 {
29 bool canLoad = ctx.isChar && ctx.hasModel;
30 if (!canLoad) ImGui::BeginDisabled();
31
32 if (ImGui::Button("Load Preset", ImVec2(-1, 0)))
33 ctx.loadPreset(ctx.presetPath->c_str());
34
35 if (!canLoad) ImGui::EndDisabled();
36 }
37
38 if (!ctx.presetStatus->empty())
39 {
40 bool isError = ctx.presetStatus->find("not found") != std::string::npos ||
41 ctx.presetStatus->find("No ") != std::string::npos;
42 if (isError)
43 ImGui::TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f), "%s", ctx.presetStatus->c_str());
44 else
45 ImGui::TextColored(ImVec4(0.4f, 1.0f, 0.4f, 1.0f), "%s", ctx.presetStatus->c_str());
46 }
47
48 if (!ctx.isChar)
49 ImGui::TextDisabled("Load a character model first.");
50}
void draw(DrawContext &ctx)
Per-frame context for the presets panel.
std::function< void(const char *)> loadPreset
std::function< void(const char *)> savePreset