|
|
|
@ -23,8 +23,11 @@ namespace lunarium { namespace editor
|
|
|
|
MapCanvas::MapCanvas(MapEditor* editor)
|
|
|
|
MapCanvas::MapCanvas(MapEditor* editor)
|
|
|
|
: Panel("Map Canvas", gui::PanelDockZone::DDZ_CENTER, true),
|
|
|
|
: Panel("Map Canvas", gui::PanelDockZone::DDZ_CENTER, true),
|
|
|
|
mpMapEditor(editor), mpCanvasImage(nullptr), mMap(nullptr), mSelectedTile({-1, -1}), mFrameBuffer(-1), mMapSizeChanged(false),
|
|
|
|
mpMapEditor(editor), mpCanvasImage(nullptr), mMap(nullptr), mSelectedTile({-1, -1}), mFrameBuffer(-1), mMapSizeChanged(false),
|
|
|
|
mZoomFactor(1.0f), mScrollDragged(false)
|
|
|
|
mZoomFactor(1.0f), mScrollDragged(false), mCurrentRegion({0, 0}), mRegionString("")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
mRegionString = std::to_string(mCurrentRegion.X);
|
|
|
|
|
|
|
|
mRegionString += ",";
|
|
|
|
|
|
|
|
mRegionString += std::to_string(mCurrentRegion.Y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MapCanvas::Update(float delta)
|
|
|
|
void MapCanvas::Update(float delta)
|
|
|
|
@ -146,14 +149,12 @@ namespace lunarium { namespace editor
|
|
|
|
ImVec2 pos = ImGui::GetWindowPos();
|
|
|
|
ImVec2 pos = ImGui::GetWindowPos();
|
|
|
|
ImVec2 size = ImGui::GetWindowSize();
|
|
|
|
ImVec2 size = ImGui::GetWindowSize();
|
|
|
|
|
|
|
|
|
|
|
|
// tool bar
|
|
|
|
|
|
|
|
float child_height = ImGui::GetFrameHeight() * 2;
|
|
|
|
float child_height = ImGui::GetFrameHeight() * 2;
|
|
|
|
ImGui::BeginChild("Map Tool Bar", ImVec2(ImGui::GetWindowSize().x, child_height), true);
|
|
|
|
ImGui::BeginChild("Map Tool Bar", ImVec2(ImGui::GetWindowSize().x, child_height), true);
|
|
|
|
ImGui::Text("Zoom: ");
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
// tool bar
|
|
|
|
ImGui::PushItemWidth(100.0f);
|
|
|
|
DoToolBar();
|
|
|
|
ImGui::InputFloat("", &mZoomFactor, 0.05f, 0.1f, "%.2f");
|
|
|
|
|
|
|
|
ImGui::PopItemWidth();
|
|
|
|
|
|
|
|
ImGui::EndChild();
|
|
|
|
ImGui::EndChild();
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::BeginChild("Map Canvas", ImVec2(ImGui::GetWindowSize().x, ImGui::GetWindowSize().y - child_height), true);
|
|
|
|
ImGui::BeginChild("Map Canvas", ImVec2(ImGui::GetWindowSize().x, ImGui::GetWindowSize().y - child_height), true);
|
|
|
|
@ -221,4 +222,86 @@ namespace lunarium { namespace editor
|
|
|
|
mpCanvasImage = nullptr;
|
|
|
|
mpCanvasImage = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// RENDER HELPERS
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void MapCanvas::DoToolBar()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (ImGui::BeginTable("tool bar", 2, ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_SizingFixedFit))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ImGui::AlignTextToFramePadding();
|
|
|
|
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
|
|
|
|
ImGui::Text("Zoom: ");
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
ImGui::PushItemWidth(100.0f);
|
|
|
|
|
|
|
|
ImGui::InputFloat("##zoom_factor", &mZoomFactor, 0.05f, 0.1f, "%.2f");
|
|
|
|
|
|
|
|
ImGui::PopItemWidth();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Region Selecting
|
|
|
|
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
|
|
|
|
ImGui::Text("Regions: ");
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
if (ImGui::Button("<="))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// TODO: Move to the next region to the left
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ImGui::IsItemHovered())
|
|
|
|
|
|
|
|
ImGui::SetTooltip("Move to the west");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
if (ImGui::Button("^"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// TODO: Move to the next region to the north
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ImGui::IsItemHovered())
|
|
|
|
|
|
|
|
ImGui::SetTooltip("Move to the north");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
if (ImGui::Button("V"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// TODO: Move to the next region to the south
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ImGui::IsItemHovered())
|
|
|
|
|
|
|
|
ImGui::SetTooltip("Move to the south");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
if (ImGui::Button("=>"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// TODO: Move to the next region to the right
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ImGui::IsItemHovered())
|
|
|
|
|
|
|
|
ImGui::SetTooltip("Move to the east");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
ImGui::Text("Current: ");
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
ImGui::PushItemWidth(50.0f);
|
|
|
|
|
|
|
|
if (ImGui::InputText("##current_region", mRegionString.data(), mRegionString.size() + 1, ImGuiInputTextFlags_EnterReturnsTrue)
|
|
|
|
|
|
|
|
&& mRegionString.size() > 2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int x = -1, y = -1;
|
|
|
|
|
|
|
|
if (std::isdigit(mRegionString[0]))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
x = std::atoi(&mRegionString[0]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (std::isdigit(mRegionString[2]))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mCurrentRegion.X = x;
|
|
|
|
|
|
|
|
mCurrentRegion.Y = std::atoi(&mRegionString[2]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::PopItemWidth();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ImGui::TableNextColumn();
|
|
|
|
|
|
|
|
// ImGui::Text("Status Bar");
|
|
|
|
|
|
|
|
ImGui::EndTable();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}}
|
|
|
|
}}
|