Build viewer/editor #13
2 changed files with 265 additions and 0 deletions
|
@ -104,6 +104,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
|||
auto drawDeleteStagedMassPopup(const std::string& filename) -> ImGuiID;
|
||||
|
||||
void drawMassViewer();
|
||||
void drawFrameInfo();
|
||||
|
||||
void drawAbout();
|
||||
void drawGameState();
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include "../Maps/StyleNames.h"
|
||||
|
||||
#include "../FontAwesome/IconsFontAwesome5.h"
|
||||
|
||||
#include "SaveTool.h"
|
||||
|
@ -61,6 +63,7 @@ void SaveTool::drawMassViewer() {
|
|||
|
||||
if(ImGui::BeginTabBar("##MassTabBar")) {
|
||||
if(ImGui::BeginTabItem("Frame")) {
|
||||
drawFrameInfo();
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
|
@ -85,3 +88,264 @@ void SaveTool::drawMassViewer() {
|
|||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void SaveTool::drawFrameInfo() {
|
||||
if(!_currentMass || _currentMass->state() != Mass::State::Valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui::TextUnformatted("Frame type: Skeleton"); // Placeholder for now, replace with actual code once other frames are implemented.
|
||||
|
||||
if(ImGui::CollapsingHeader("Joint sliders")) {
|
||||
static Joints sliders = _currentMass->jointSliders();
|
||||
static bool edit = false;
|
||||
static bool dirty = false;
|
||||
|
||||
ImGui::TextWrapped("In-game values are multiplied by 100.\nFor example, 0.500 here is equal to 50 in-game.");
|
||||
|
||||
if(ImGui::BeginTable("##JointSliderTable", 2, ImGuiTableFlags_Borders)) {
|
||||
ImGui::TableSetupColumn("##SliderLabel", ImGuiTableColumnFlags_WidthFixed);
|
||||
ImGui::TableSetupColumn("##Sliders", ImGuiTableColumnFlags_WidthStretch);
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::TextUnformatted("Neck");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
if(edit) {
|
||||
ImGui::SetNextItemWidth(-1.0f);
|
||||
if(ImGui::SliderFloat("##NeckSlider", &sliders.neck, 0.0f, 1.0f)) {
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::Text("%.3f", Double(_currentMass->jointSliders().neck));
|
||||
}
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::TextUnformatted("Body");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
if(edit) {
|
||||
ImGui::SetNextItemWidth(-1.0f);
|
||||
if(ImGui::SliderFloat("##BodySlider", &sliders.body, 0.0f, 1.0f)) {
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::Text("%.3f", Double(_currentMass->jointSliders().body));
|
||||
}
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::TextUnformatted("Shoulders");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
if(edit) {
|
||||
ImGui::SetNextItemWidth(-1.0f);
|
||||
if(ImGui::SliderFloat("##ShouldersSlider", &sliders.shoulders, 0.0f, 1.0f)) {
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::Text("%.3f", Double(_currentMass->jointSliders().shoulders));
|
||||
}
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::TextUnformatted("Hips");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
if(edit) {
|
||||
ImGui::SetNextItemWidth(-1.0f);
|
||||
if(ImGui::SliderFloat("##HipsSlider", &sliders.hips, 0.0f, 1.0f)) {
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::Text("%.3f", Double(_currentMass->jointSliders().hips));
|
||||
}
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
if(ImGui::BeginTable("##UpperLowerLayoutTable", 2, ImGuiTableFlags_BordersInnerV)) {
|
||||
ImGui::TableSetupColumn("##Upper", ImGuiTableColumnFlags_WidthStretch);
|
||||
ImGui::TableSetupColumn("##Lower", ImGuiTableColumnFlags_WidthStretch);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::TextUnformatted("Upper");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::TextUnformatted("Lower");
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::TextUnformatted("Arms");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
if(ImGui::BeginTable("##UpperLowerArmsLayoutTable", 2, ImGuiTableFlags_BordersInnerV)) {
|
||||
ImGui::TableSetupColumn("##UpperArms", ImGuiTableColumnFlags_WidthStretch);
|
||||
ImGui::TableSetupColumn("##LowerArms", ImGuiTableColumnFlags_WidthStretch);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
if(edit) {
|
||||
ImGui::SetNextItemWidth(-1.0f);
|
||||
if(ImGui::SliderFloat("##UpperArmsSlider", &sliders.upperArms, 0.0f, 1.0f)) {
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::Text("%.3f", Double(_currentMass->jointSliders().upperArms));
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
if(edit) {
|
||||
ImGui::SetNextItemWidth(-1.0f);
|
||||
if(ImGui::SliderFloat("##LowerArmsSlider", &sliders.lowerArms, 0.0f, 1.0f)) {
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::Text("%.3f", Double(_currentMass->jointSliders().lowerArms));
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::TextUnformatted("Legs");
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
if(ImGui::BeginTable("##UpperLowerLegsLayoutTable", 2, ImGuiTableFlags_BordersInnerV)) {
|
||||
ImGui::TableSetupColumn("##UpperLegs", ImGuiTableColumnFlags_WidthStretch);
|
||||
ImGui::TableSetupColumn("##LowerLegs", ImGuiTableColumnFlags_WidthStretch);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
if(edit) {
|
||||
ImGui::SetNextItemWidth(-1.0f);
|
||||
if(ImGui::SliderFloat("##UpperLegsSlider", &sliders.upperLegs, 0.0f, 1.0f)) {
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::Text("%.3f", Double(_currentMass->jointSliders().upperLegs));
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
if(edit) {
|
||||
ImGui::SetNextItemWidth(-1.0f);
|
||||
if(ImGui::SliderFloat("##LowerLegsSlider", &sliders.lowerLegs, 0.0f, 1.0f)) {
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::Text("%.3f", Double(_currentMass->jointSliders().lowerLegs));
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
if(edit) {
|
||||
if(!dirty) {
|
||||
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.5f);
|
||||
ImGui::Button(ICON_FA_SAVE " Save changes");
|
||||
ImGui::SameLine();
|
||||
ImGui::Button(ICON_FA_UNDO " Reset sliders");
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopItemFlag();
|
||||
}
|
||||
else {
|
||||
if(drawUnsafeWidget([]{ return ImGui::Button(ICON_FA_SAVE " Save changes"); })) {
|
||||
dirty = false;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if(ImGui::Button(ICON_FA_UNDO " Reset sliders")) {
|
||||
sliders = _currentMass->jointSliders();
|
||||
dirty = false;
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if(ImGui::Button(ICON_FA_TIMES " Cancel editing")) {
|
||||
sliders = _currentMass->jointSliders();
|
||||
dirty = false;
|
||||
edit = false;
|
||||
}
|
||||
|
||||
ImGui::TextUnformatted("To input out-of-range values, hold Ctrl and click on a slider.");
|
||||
}
|
||||
else {
|
||||
if(ImGui::Button(ICON_FA_EDIT " Edit sliders")) {
|
||||
edit = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(ImGui::CollapsingHeader("Paint")) {
|
||||
ImGui::TextUnformatted("Frame styles:");
|
||||
for(Int i = 0; i < 4; i++) {
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::Text("Slot %d:", i + 1);
|
||||
ImGui::SameLine();
|
||||
ImGui::PushID(i);
|
||||
GameState game_state = _gameState;
|
||||
if(!_unsafeMode && game_state != GameState::NotRunning) {
|
||||
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.5f);
|
||||
}
|
||||
if(ImGui::BeginCombo("##Style", style_names.at(_currentMass->frameStyles()[i]))) {
|
||||
for(const auto& style : style_names) {
|
||||
if(ImGui::Selectable(style.second, _currentMass->frameStyles()[i] == style.first)) {
|
||||
if(!_currentMass->setFrameStyle(i, style.first)) {
|
||||
_queue.addToast(Toast::Type::Error, Mass::lastError());
|
||||
}
|
||||
else {
|
||||
_currentMass->refreshValues();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
if(!_unsafeMode && game_state != GameState::NotRunning) {
|
||||
ImGui::PopItemFlag();
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
static const Int hex_literals[] = {0x3DF68F08, 0x3E791C4C, 0x00000000};
|
||||
static Float colour_components[3];
|
||||
static bool run_once = true;
|
||||
if(run_once) {
|
||||
std::memcpy(colour_components, hex_literals, sizeof(Float) * 3);
|
||||
run_once = false;
|
||||
}
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::TextUnformatted("Eye flare colour:");
|
||||
ImGui::SameLine();
|
||||
ImGui::SetNextItemWidth(-1.0f);
|
||||
ImGui::ColorEdit3("##EyeFlarePicker", &colour_components[0]);
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::TextUnformatted("The frame's custom styles will go here.");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue