This commit is contained in:
parent
dc96e9de79
commit
1ac3ace95c
@ -19,15 +19,15 @@ namespace jasper::world {
|
|||||||
|
|
||||||
namespace ig = studio::ig;
|
namespace ig = studio::ig;
|
||||||
|
|
||||||
constexpr auto btnSize = ImVec2(22, ig::BtnSz.y);
|
constexpr auto btnSize = ImVec2{22, ig::BtnSz.y};
|
||||||
|
|
||||||
WorldObjectSetEditorImGui::WorldObjectSetEditorImGui(
|
WorldObjectSetEditorImGui::WorldObjectSetEditorImGui(
|
||||||
studio::StudioContext &ctx,
|
studio::StudioContext &ctx,
|
||||||
ox::StringView path):
|
ox::StringParam path):
|
||||||
Editor(path),
|
Editor(std::move(path)),
|
||||||
m_sctx(ctx),
|
m_sctx(ctx),
|
||||||
m_itemPath(path),
|
m_itemPath(itemPath()),
|
||||||
m_doc(*readObj<WorldObjectSet>(keelCtx(m_sctx), path).unwrapThrow()),
|
m_doc(*readObj<WorldObjectSet>(keelCtx(m_sctx), itemPath()).unwrapThrow()),
|
||||||
m_tileSheet(readObj<ncore::TileSheet>(keelCtx(m_sctx), m_doc.tilesheet).unwrapThrow()) {
|
m_tileSheet(readObj<ncore::TileSheet>(keelCtx(m_sctx), m_doc.tilesheet).unwrapThrow()) {
|
||||||
auto const&tilesheetList = m_sctx.project->fileList(ncore::FileExt_ng);
|
auto const&tilesheetList = m_sctx.project->fileList(ncore::FileExt_ng);
|
||||||
auto &kctx = keelCtx(m_sctx);
|
auto &kctx = keelCtx(m_sctx);
|
||||||
@ -43,13 +43,13 @@ WorldObjectSetEditorImGui::WorldObjectSetEditorImGui(
|
|||||||
void WorldObjectSetEditorImGui::draw(studio::StudioContext&) noexcept {
|
void WorldObjectSetEditorImGui::draw(studio::StudioContext&) noexcept {
|
||||||
const auto paneSize = ImGui::GetContentRegionAvail();
|
const auto paneSize = ImGui::GetContentRegionAvail();
|
||||||
constexpr auto resourcesWidth = 300.f;
|
constexpr auto resourcesWidth = 300.f;
|
||||||
ImGui::BeginChild("ObjEditor", ImVec2(paneSize.x - resourcesWidth, 0));
|
ImGui::BeginChild("ObjEditor", {paneSize.x - resourcesWidth, 0});
|
||||||
if (m_selectedObj < m_doc.objects.size()) {
|
if (m_selectedObj < m_doc.objects.size()) {
|
||||||
drawObjEditor();
|
drawObjEditor();
|
||||||
}
|
}
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::BeginChild("Resources", ImVec2(0, 0));
|
ImGui::BeginChild("Resources", {0, 0});
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
ig::IDStackItem const idStackItem("TileSheetSelector");
|
ig::IDStackItem const idStackItem("TileSheetSelector");
|
||||||
@ -184,7 +184,7 @@ void WorldObjectSetEditorImGui::drawObjEditor() noexcept {
|
|||||||
}
|
}
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::Text("Subsheet:");
|
ImGui::Text("Subsheet:");
|
||||||
ImGui::BeginChild("SubsheetSelector", ImVec2{300, 300});
|
ImGui::BeginChild("SubsheetSelector", {300, 300});
|
||||||
{
|
{
|
||||||
ImGui::SetNextItemOpen(true);
|
ImGui::SetNextItemOpen(true);
|
||||||
if (m_tileSheet) {
|
if (m_tileSheet) {
|
||||||
@ -206,16 +206,16 @@ void WorldObjectSetEditorImGui::drawObjEditor() noexcept {
|
|||||||
auto const height = static_cast<float>(m_subsheet->rows * ncore::TileHeight);
|
auto const height = static_cast<float>(m_subsheet->rows * ncore::TileHeight);
|
||||||
auto const horzPct = width / 240.f;
|
auto const horzPct = width / 240.f;
|
||||||
auto const vertPct = height / 160.f;
|
auto const vertPct = height / 160.f;
|
||||||
auto const imageSz = ImVec2(width * scale, height * scale);
|
auto const imageSz = ImVec2{width * scale, height * scale};
|
||||||
auto const imagePos = ImGui::GetCursorScreenPos();
|
auto const imagePos = ImGui::GetCursorScreenPos();
|
||||||
ImGui::Image(
|
ImGui::Image(
|
||||||
std::bit_cast<void*>(buffId),
|
std::bit_cast<void*>(buffId),
|
||||||
imageSz,
|
imageSz,
|
||||||
ImVec2(0, 1.0),
|
{0, 1.0},
|
||||||
ImVec2(horzPct, 1 - vertPct));
|
{horzPct, 1 - vertPct});
|
||||||
auto const&io = ImGui::GetIO();
|
auto const&io = ImGui::GetIO();
|
||||||
if (ImGui::IsItemClicked()) {
|
if (ImGui::IsItemClicked()) {
|
||||||
auto const mousePos = clickPos(imageSz, imagePos, ox::Vec2(io.MousePos));
|
auto const mousePos = clickPos(imageSz, imagePos, ox::Vec2{io.MousePos});
|
||||||
auto &obj = activeObj();
|
auto &obj = activeObj();
|
||||||
auto intermediate = obj.collisionMap;
|
auto intermediate = obj.collisionMap;
|
||||||
if (m_colView.click(mousePos, intermediate)) {
|
if (m_colView.click(mousePos, intermediate)) {
|
||||||
|
@ -37,7 +37,7 @@ class WorldObjectSetEditorImGui: public studio::Editor {
|
|||||||
} m_objEditor;
|
} m_objEditor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WorldObjectSetEditorImGui(studio::StudioContext &ctx, ox::StringView path);
|
WorldObjectSetEditorImGui(studio::StudioContext &ctx, ox::StringParam path);
|
||||||
|
|
||||||
void draw(studio::StudioContext&) noexcept final;
|
void draw(studio::StudioContext&) noexcept final;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user