110 lines
2.5 KiB
C++
110 lines
2.5 KiB
C++
/*
|
|
* Copyright 2023 - 2024 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <ox/std/smallmap.hpp>
|
|
|
|
#include <studio/studio.hpp>
|
|
|
|
#include <turbine/context.hpp>
|
|
|
|
#include <jasper/world/objectcache.hpp>
|
|
|
|
#include "worldeditorview.hpp"
|
|
|
|
namespace jasper::world {
|
|
|
|
class WorldEditorImGui: public studio::Editor {
|
|
|
|
private:
|
|
studio::SelectionTracker m_selTracker;
|
|
ox::Optional<studio::Selection> m_selection;
|
|
uint8_t m_activeLayer{};
|
|
studio::StudioContext &m_sctx;
|
|
studio::ig::FilePicker m_objSetPicker{
|
|
m_sctx, ox::String("Choose Object Set"), ox::String(FileExt_jwob)};
|
|
WorldDoc m_doc;
|
|
ObjectCache m_objCache;
|
|
struct ObjSetRef {
|
|
ox::String name;
|
|
uint64_t id{};
|
|
keel::AssetRef<WorldObjectSet> set;
|
|
ObjSetRef(ox::String pName, uint64_t pId, keel::AssetRef<WorldObjectSet> pSet):
|
|
name(std::move(pName)),
|
|
id(pId),
|
|
set(std::move(pSet)) {}
|
|
constexpr ObjSetRef() = default;
|
|
};
|
|
ox::Vector<ObjSetRef> m_objSets;
|
|
ox::SmallMap<ox::UUID, bool> m_dependencies;
|
|
WorldStatic m_worldStatic;
|
|
WorldEditorView m_view;
|
|
struct {
|
|
size_t selectedIdx{};
|
|
} m_palMgr;
|
|
struct {
|
|
bool show{};
|
|
int columns{};
|
|
int rows{};
|
|
} m_sizeEditor;
|
|
|
|
public:
|
|
WorldEditorImGui(studio::StudioContext &ctx, ox::StringView path);
|
|
|
|
void draw(studio::StudioContext&) noexcept final;
|
|
|
|
void onActivated() noexcept override;
|
|
|
|
protected:
|
|
void copy() noexcept override;
|
|
|
|
void cut() noexcept override;
|
|
|
|
void paste() override;
|
|
|
|
bool acceptsClipboardPayload() const noexcept override;
|
|
|
|
ox::Error saveItem() noexcept final;
|
|
|
|
private:
|
|
void drawObjSetSelector() noexcept;
|
|
|
|
void drawObjSelector() noexcept;
|
|
|
|
void drawPropEditor() noexcept;
|
|
|
|
void drawMenu() noexcept;
|
|
|
|
void drawResources() noexcept;
|
|
|
|
void drawWorldView() noexcept;
|
|
|
|
void handleMouseSelection(ox::Size const&paneSz, float fbPaneScale) noexcept;
|
|
|
|
ox::Error handleDrop(float fbPaneScale) noexcept;
|
|
|
|
ox::Error addObjSet(ox::StringView path) noexcept;
|
|
|
|
void rmObjSet() noexcept;
|
|
|
|
// handles the updating of an object set in case it is one used by this world
|
|
ox::Error handleDepUpdate(ox::StringView path, ox::UUID const&) noexcept;
|
|
|
|
ox::Error loadObjectSets() noexcept;
|
|
|
|
ox::Error undoStackChanged(studio::UndoCommand const*);
|
|
|
|
[[nodiscard]]
|
|
bool tileSelected(ox::Point const&pt) const noexcept;
|
|
|
|
void clearSelection() noexcept;
|
|
|
|
ox::Result<ox::UUID> assetId() const noexcept;
|
|
|
|
ox::Error addDependency(ox::FileAddress const&fileAddr) noexcept;
|
|
};
|
|
|
|
}
|