[jasper/world/studio] Put map resize in a popup
This commit is contained in:
parent
2a55a5762d
commit
d3578ab5bd
@ -32,21 +32,6 @@ ox::Error EditWorldSizeCommand::undo() noexcept {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditWorldSizeCommand::mergeWith(studio::UndoCommand const&cmd) noexcept {
|
|
||||||
auto const es = dynamic_cast<EditWorldSizeCommand const*>(&cmd);
|
|
||||||
if (!es || dimensionChanged() != es->dimensionChanged()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
m_newSize = es->m_newSize;
|
|
||||||
// undo
|
|
||||||
resize(m_doc, m_oldSize);
|
|
||||||
m_doc.tiles = m_oldMap;
|
|
||||||
// redo
|
|
||||||
resize(m_doc, m_newSize);
|
|
||||||
oxLogError(loadWorldStatic(m_objCache, m_doc).moveTo(m_worldStatic));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int EditWorldSizeCommand::commandId() const noexcept {
|
int EditWorldSizeCommand::commandId() const noexcept {
|
||||||
return static_cast<int>(WorldEditorCommand::EditWorldSize);
|
return static_cast<int>(WorldEditorCommand::EditWorldSize);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ class EditWorldSizeCommand: public studio::UndoCommand {
|
|||||||
ox::Size const&size);
|
ox::Size const&size);
|
||||||
ox::Error redo() noexcept override;
|
ox::Error redo() noexcept override;
|
||||||
ox::Error undo() noexcept override;
|
ox::Error undo() noexcept override;
|
||||||
bool mergeWith(studio::UndoCommand const&cmd) noexcept override;
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
int commandId() const noexcept override;
|
int commandId() const noexcept override;
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
|
@ -94,11 +94,12 @@ void WorldEditorImGui::draw(studio::StudioContext&) noexcept {
|
|||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
{
|
{
|
||||||
ig::ChildStackItem const worldView{"RightPane"};
|
ig::ChildStackItem const worldView{"RightPane"};
|
||||||
drawPropEditor();
|
drawMenu();
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
drawResources();
|
drawResources();
|
||||||
}
|
}
|
||||||
m_objSetPicker.draw();
|
m_objSetPicker.draw();
|
||||||
|
drawPropEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorImGui::onActivated() noexcept {
|
void WorldEditorImGui::onActivated() noexcept {
|
||||||
@ -155,14 +156,31 @@ void WorldEditorImGui::drawObjSelector() noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorImGui::drawPropEditor() noexcept {
|
void WorldEditorImGui::drawPropEditor() noexcept {
|
||||||
ig::IDStackItem const idStackItem("PropEditor");
|
if (m_sizeEditor.show) {
|
||||||
int width{m_doc.columns};
|
constexpr auto popupSz = ImVec2{285, 0};
|
||||||
int height{m_doc.rows};
|
ig::IDStackItem const idStackItem("EditMapSize");
|
||||||
if (ImGui::InputInt("Map Width", &width, 1)) {
|
if (ig::BeginPopup(m_sctx.tctx, "Edit Map Size", m_sizeEditor.show, popupSz)) {
|
||||||
std::ignore = pushCommand<EditWorldSizeCommand>(m_objCache, m_doc, m_worldStatic, ox::Size{width, m_doc.rows});
|
ImGui::InputInt("Map Width", &m_sizeEditor.columns, 1);
|
||||||
|
ImGui::InputInt("Map Height", &m_sizeEditor.rows, 1);
|
||||||
|
const bool changed = m_doc.columns != m_sizeEditor.columns
|
||||||
|
|| m_doc.rows != m_sizeEditor.rows;
|
||||||
|
if (ig::PopupControlsOkCancel(popupSz.x, m_sizeEditor.show) == ig::PopupResponse::OK) {
|
||||||
|
if (changed) {
|
||||||
|
std::ignore = pushCommand<EditWorldSizeCommand>(
|
||||||
|
m_objCache, m_doc, m_worldStatic, ox::Size{m_sizeEditor.columns, m_sizeEditor.rows});
|
||||||
}
|
}
|
||||||
if (ImGui::InputInt("Map Height", &height, 1)) {
|
}
|
||||||
std::ignore = pushCommand<EditWorldSizeCommand>(m_objCache, m_doc, m_worldStatic, ox::Size{m_doc.columns, height});
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorldEditorImGui::drawMenu() noexcept {
|
||||||
|
ig::IDStackItem const idStackItem("Menu");
|
||||||
|
if (ig::PushButton("Resize")) {
|
||||||
|
m_sizeEditor.show = true;
|
||||||
|
m_sizeEditor.columns = m_doc.columns;
|
||||||
|
m_sizeEditor.rows = m_doc.rows;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,11 @@ class WorldEditorImGui: public studio::Editor {
|
|||||||
struct {
|
struct {
|
||||||
size_t selectedIdx{};
|
size_t selectedIdx{};
|
||||||
} m_palMgr;
|
} m_palMgr;
|
||||||
|
struct {
|
||||||
|
bool show{};
|
||||||
|
int columns{};
|
||||||
|
int rows{};
|
||||||
|
} m_sizeEditor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WorldEditorImGui(studio::StudioContext &ctx, ox::StringView path);
|
WorldEditorImGui(studio::StudioContext &ctx, ox::StringView path);
|
||||||
@ -63,6 +68,8 @@ class WorldEditorImGui: public studio::Editor {
|
|||||||
|
|
||||||
void drawPropEditor() noexcept;
|
void drawPropEditor() noexcept;
|
||||||
|
|
||||||
|
void drawMenu() noexcept;
|
||||||
|
|
||||||
void drawResources() noexcept;
|
void drawResources() noexcept;
|
||||||
|
|
||||||
void drawWorldView() noexcept;
|
void drawWorldView() noexcept;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user