[jasper/world/studio/worldeditor] Cleanup
All checks were successful
Build / build (push) Successful in 3m44s
All checks were successful
Build / build (push) Successful in 3m44s
This commit is contained in:
parent
a4045cfae5
commit
8f5ab51158
@ -330,7 +330,7 @@ void WorldEditorImGui::handleMouseSelection(float const fbPaneScale) noexcept {
|
|||||||
if (io.MouseDown[0]) {
|
if (io.MouseDown[0]) {
|
||||||
auto const fbPos = world::fbPos(ox::Vec2{io.MousePos});
|
auto const fbPos = world::fbPos(ox::Vec2{io.MousePos});
|
||||||
auto const startSel = io.MouseClicked[0] && ImGui::IsItemHovered();
|
auto const startSel = io.MouseClicked[0] && ImGui::IsItemHovered();
|
||||||
auto const scaledViewSz = static_cast<ox::Vec2>(m_view.drawSize()) * fbPaneScale;
|
auto const scaledViewSz = ox::Vec2{m_view.drawSize()} * fbPaneScale;
|
||||||
m_selTracker.updateCursorPoint(fbPtToTileAddr(fbPos, scaledViewSz), startSel);
|
m_selTracker.updateCursorPoint(fbPtToTileAddr(fbPos, scaledViewSz), startSel);
|
||||||
if (m_selTracker.selectionOngoing()) {
|
if (m_selTracker.selectionOngoing()) {
|
||||||
m_view.setSelection(m_selTracker.selection());
|
m_view.setSelection(m_selTracker.selection());
|
||||||
@ -351,7 +351,7 @@ ox::Error WorldEditorImGui::handleDrop(float const fbPaneScale) noexcept {
|
|||||||
auto const viewSz = m_view.drawSize();
|
auto const viewSz = m_view.drawSize();
|
||||||
auto const tileAddr = fbPtToTileAddr(
|
auto const tileAddr = fbPtToTileAddr(
|
||||||
fbPos,
|
fbPos,
|
||||||
ox::Vec2{
|
{
|
||||||
static_cast<float>(viewSz.width) * fbPaneScale,
|
static_cast<float>(viewSz.width) * fbPaneScale,
|
||||||
static_cast<float>(viewSz.height) * fbPaneScale});
|
static_cast<float>(viewSz.height) * fbPaneScale});
|
||||||
if (tileAddr.x < m_doc.columns && tileAddr.y < m_doc.rows) {
|
if (tileAddr.x < m_doc.columns && tileAddr.y < m_doc.rows) {
|
||||||
|
@ -48,7 +48,7 @@ class WorldEditorImGui: public studio::Editor {
|
|||||||
} m_sizeEditor;
|
} m_sizeEditor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WorldEditorImGui(studio::StudioContext &ctx, ox::StringParam path);
|
WorldEditorImGui(studio::StudioContext &sctx, ox::StringParam path);
|
||||||
|
|
||||||
void draw(studio::StudioContext&) noexcept final;
|
void draw(studio::StudioContext&) noexcept final;
|
||||||
|
|
||||||
|
@ -10,9 +10,9 @@ namespace jasper::world {
|
|||||||
|
|
||||||
WorldEditorView::WorldEditorView(studio::StudioContext &sctx, WorldStatic const&worldStatic):
|
WorldEditorView::WorldEditorView(studio::StudioContext &sctx, WorldStatic const&worldStatic):
|
||||||
m_sctx{sctx},
|
m_sctx{sctx},
|
||||||
m_cctx{ncore::init(m_sctx.tctx, {.glInstallDrawer = false}).unwrapThrow()},
|
m_nctx{ncore::init(m_sctx.tctx, {.glInstallDrawer = false}).unwrapThrow()},
|
||||||
m_worldStatic{worldStatic},
|
m_worldStatic{worldStatic},
|
||||||
m_world{*m_cctx, m_worldStatic} {}
|
m_world{*m_nctx, m_worldStatic} {}
|
||||||
|
|
||||||
ox::Error WorldEditorView::setupTile(
|
ox::Error WorldEditorView::setupTile(
|
||||||
uint32_t const lyr,
|
uint32_t const lyr,
|
||||||
@ -51,7 +51,7 @@ void WorldEditorView::draw(ox::Size const&targetSz) noexcept {
|
|||||||
turbine::setRefreshWithin(m_sctx.tctx, wakeUp.value);
|
turbine::setRefreshWithin(m_sctx.tctx, wakeUp.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ncore::gl::draw(*m_cctx, m_scale);
|
ncore::gl::draw(*m_nctx, m_scale);
|
||||||
m_highlighter.draw();
|
m_highlighter.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,32 +79,4 @@ ox::Size WorldEditorView::drawSize() const noexcept {
|
|||||||
return ncore::gl::drawSize(m_scale);
|
return ncore::gl::drawSize(m_scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldEditorView::setPixelBufferObject(
|
|
||||||
unsigned vertexRow,
|
|
||||||
float x, float y,
|
|
||||||
bool const selected,
|
|
||||||
float *vbo,
|
|
||||||
GLuint *ebo) const noexcept {
|
|
||||||
auto constexpr xmod = static_cast<float>(ncore::TileWidth) / 240.f * 4;
|
|
||||||
auto constexpr ymod = static_cast<float>(ncore::TileHeight) / 160.f * 4;
|
|
||||||
x *= xmod;
|
|
||||||
y *= -ymod;
|
|
||||||
x -= 1.0f;
|
|
||||||
y += 1.0f - ymod;
|
|
||||||
auto const selection = 1.f * static_cast<float>(selected);
|
|
||||||
// don't worry, these memcpys gets optimized to something much more ideal
|
|
||||||
std::array const vertices{
|
|
||||||
x, y, selection, // bottom left
|
|
||||||
x + xmod, y, selection, // bottom right
|
|
||||||
x + xmod, y + ymod, selection, // top right
|
|
||||||
x, y + ymod, selection, // top left
|
|
||||||
};
|
|
||||||
memcpy(vbo, vertices.data(), sizeof(vertices));
|
|
||||||
ox::Array<GLuint, 6> const elms{
|
|
||||||
vertexRow + 0, vertexRow + 1, vertexRow + 2,
|
|
||||||
vertexRow + 2, vertexRow + 3, vertexRow + 0,
|
|
||||||
};
|
|
||||||
memcpy(ebo, elms.data(), sizeof(elms));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ class WorldEditorView: public ox::SignalHandler {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
studio::StudioContext &m_sctx;
|
studio::StudioContext &m_sctx;
|
||||||
ncore::ContextUPtr m_cctx;
|
ncore::ContextUPtr m_nctx;
|
||||||
WorldStatic const&m_worldStatic;
|
WorldStatic const&m_worldStatic;
|
||||||
int m_columns{}, m_rows{};
|
int m_columns{}, m_rows{};
|
||||||
World m_world;
|
World m_world;
|
||||||
@ -63,14 +63,6 @@ class WorldEditorView: public ox::SignalHandler {
|
|||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
ox::Size drawSize() const noexcept;
|
ox::Size drawSize() const noexcept;
|
||||||
|
|
||||||
private:
|
|
||||||
void setPixelBufferObject(
|
|
||||||
unsigned vertexRow,
|
|
||||||
float x, float y,
|
|
||||||
bool selected,
|
|
||||||
float *vbo,
|
|
||||||
GLuint *ebo) const noexcept;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,15 +6,6 @@
|
|||||||
|
|
||||||
namespace jasper::world {
|
namespace jasper::world {
|
||||||
|
|
||||||
ObjectSetEntry const*objSetEntry(WorldDoc const&doc, size_t id) noexcept {
|
|
||||||
for (auto const&e : doc.objSets) {
|
|
||||||
if (e.id == id) {
|
|
||||||
return &e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void resize(WorldDoc &doc, ox::Size const&sz) noexcept {
|
void resize(WorldDoc &doc, ox::Size const&sz) noexcept {
|
||||||
doc.columns = sz.width;
|
doc.columns = sz.width;
|
||||||
doc.rows = sz.height;
|
doc.rows = sz.height;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user