[nostalgia] Break part of core out into Turbine and TeaGBA libraries
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <imgui.h>
|
||||
@@ -21,7 +21,7 @@ bool AboutPopup::isOpen() const noexcept {
|
||||
return m_stage == Stage::Open;
|
||||
}
|
||||
|
||||
void AboutPopup::draw(core::Context *ctx) noexcept {
|
||||
void AboutPopup::draw(turbine::Context *ctx) noexcept {
|
||||
switch (m_stage) {
|
||||
case Stage::Closed:
|
||||
break;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -7,13 +7,13 @@
|
||||
#include <ox/event/signal.hpp>
|
||||
#include <ox/std/string.hpp>
|
||||
|
||||
#include <nostalgia/core/context.hpp>
|
||||
#include <turbine/context.hpp>
|
||||
|
||||
#include "lib/popup.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
|
||||
class AboutPopup: public studio::Popup {
|
||||
class AboutPopup: public studio::Popup {
|
||||
public:
|
||||
enum class Stage {
|
||||
Closed,
|
||||
@@ -32,7 +32,7 @@ namespace nostalgia {
|
||||
[[nodiscard]]
|
||||
bool isOpen() const noexcept override;
|
||||
|
||||
void draw(core::Context *ctx) noexcept override;
|
||||
void draw(turbine::Context *ctx) noexcept override;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <imgui.h>
|
||||
@@ -22,7 +22,7 @@ ox::CRString ClawEditor::itemDisplayName() const noexcept {
|
||||
return m_itemDisplayName;
|
||||
}
|
||||
|
||||
void ClawEditor::draw(core::Context*) noexcept {
|
||||
void ClawEditor::draw(turbine::Context*) noexcept {
|
||||
//const auto paneSize = ImGui::GetContentRegionAvail();
|
||||
ImGui::BeginChild("PaletteEditor");
|
||||
static constexpr auto flags = ImGuiTableFlags_RowBg | ImGuiTableFlags_NoBordersInBody;
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/model/modelvalue.hpp>
|
||||
#include <nostalgia/core/context.hpp>
|
||||
#include <turbine/context.hpp>
|
||||
|
||||
#include "lib/editor.hpp"
|
||||
|
||||
@@ -27,7 +27,7 @@ class ClawEditor: public studio::Editor {
|
||||
|
||||
ox::CRString itemDisplayName() const noexcept final;
|
||||
|
||||
void draw(core::Context*) noexcept final;
|
||||
void draw(turbine::Context*) noexcept final;
|
||||
|
||||
private:
|
||||
static void drawRow(const ox::ModelValue &value) noexcept;
|
||||
|
@@ -1,14 +1,14 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <turbine/gfx.hpp>
|
||||
|
||||
#include "filedialogmanager.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
|
||||
studio::TaskState FileDialogManager::update(core::Context *ctx) noexcept {
|
||||
studio::TaskState FileDialogManager::update(turbine::Context *ctx) noexcept {
|
||||
switch (m_state) {
|
||||
case UpdateProjectPathState::EnableSystemCursor: {
|
||||
// switch to system cursor in this update and open file dialog in the next
|
||||
@@ -20,7 +20,7 @@ studio::TaskState FileDialogManager::update(core::Context *ctx) noexcept {
|
||||
// switch to system cursor
|
||||
auto [path, err] = studio::chooseDirectory();
|
||||
// Mac file dialog doesn't restore focus to main window when closed...
|
||||
core::focusWindow(ctx);
|
||||
turbine::focusWindow(*ctx);
|
||||
if (!err) {
|
||||
err = pathChosen.emitCheckError(path);
|
||||
oxAssert(err, "Path chosen response failed");
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <ox/event/signal.hpp>
|
||||
#include <ox/std/string.hpp>
|
||||
|
||||
#include <nostalgia/core/context.hpp>
|
||||
#include <turbine/context.hpp>
|
||||
|
||||
#include "lib/filedialog.hpp"
|
||||
#include "lib/task.hpp"
|
||||
@@ -33,7 +33,7 @@ class FileDialogManager : public nostalgia::studio::Task {
|
||||
|
||||
~FileDialogManager() noexcept override = default;
|
||||
|
||||
nostalgia::studio::TaskState update(nostalgia::core::Context *ctx) noexcept final;
|
||||
nostalgia::studio::TaskState update(turbine::Context *ctx) noexcept final;
|
||||
|
||||
// signals
|
||||
ox::Signal<ox::Error(const ox::String &)> pathChosen;
|
||||
|
@@ -13,7 +13,7 @@
|
||||
#include <ox/std/trace.hpp>
|
||||
#include <ox/std/string.hpp>
|
||||
|
||||
#include <nostalgia/core/context.hpp>
|
||||
#include <keel/context.hpp>
|
||||
|
||||
namespace nostalgia::studio {
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
@@ -26,7 +26,7 @@ void BaseEditor::paste() {
|
||||
void BaseEditor::exportFile() {
|
||||
}
|
||||
|
||||
void BaseEditor::keyStateChanged(core::Key, bool) {
|
||||
void BaseEditor::keyStateChanged(turbine::Key, bool) {
|
||||
}
|
||||
|
||||
void BaseEditor::onActivated() noexcept {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -49,7 +49,7 @@ class NOSTALGIASTUDIO_EXPORT BaseEditor: public Widget {
|
||||
|
||||
virtual void exportFile();
|
||||
|
||||
virtual void keyStateChanged(core::Key key, bool down);
|
||||
virtual void keyStateChanged(turbine::Key key, bool down);
|
||||
|
||||
virtual void onActivated() noexcept;
|
||||
|
||||
|
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
#include <nostalgia/core/core.hpp>
|
||||
#include <turbine/context.hpp>
|
||||
|
||||
namespace nostalgia::studio::ig {
|
||||
|
||||
void centerNextWindow(core::Context *ctx) noexcept;
|
||||
void centerNextWindow(turbine::Context *ctx) noexcept;
|
||||
|
||||
}
|
@@ -4,12 +4,12 @@
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
#include <nostalgia/core/core.hpp>
|
||||
#include <turbine/gfx.hpp>
|
||||
|
||||
namespace nostalgia::studio::ig {
|
||||
|
||||
void centerNextWindow(core::Context *ctx) noexcept {
|
||||
const auto sz = core::getScreenSize(ctx);
|
||||
void centerNextWindow(turbine::Context *ctx) noexcept {
|
||||
const auto sz = turbine::getScreenSize(*ctx);
|
||||
const auto screenW = static_cast<float>(sz.width);
|
||||
const auto screenH = static_cast<float>(sz.height);
|
||||
const auto mod = ImGui::GetWindowDpiScale() * 2;
|
||||
|
@@ -7,7 +7,7 @@
|
||||
#include <ox/claw/claw.hpp>
|
||||
|
||||
#include <keel/media.hpp>
|
||||
#include <nostalgia/core/context.hpp>
|
||||
#include <turbine/context.hpp>
|
||||
|
||||
#include "context.hpp"
|
||||
|
||||
@@ -24,7 +24,7 @@ class ItemMaker {
|
||||
fileExt(std::move(pFileExt)) {
|
||||
}
|
||||
virtual ~ItemMaker() noexcept = default;
|
||||
virtual ox::Error write(core::Context *ctx, ox::CRStringView pName) const noexcept = 0;
|
||||
virtual ox::Error write(turbine::Context *ctx, ox::CRStringView pName) const noexcept = 0;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@@ -47,9 +47,9 @@ class ItemMakerT: public ItemMaker {
|
||||
item(std::forward(pItem)),
|
||||
fmt(pFmt) {
|
||||
}
|
||||
ox::Error write(core::Context *ctx, ox::CRStringView pName) const noexcept override {
|
||||
ox::Error write(turbine::Context *ctx, ox::CRStringView pName) const noexcept override {
|
||||
const auto path = ox::sfmt("/{}/{}.{}", parentDir, pName, fileExt);
|
||||
auto sctx = core::applicationData<studio::StudioContext>(ctx);
|
||||
auto sctx = turbine::applicationData<studio::StudioContext>(*ctx);
|
||||
keel::createUuidMapping(ctx, path, ox::UUID::generate().unwrap());
|
||||
return sctx->project->writeObj(path, &item, fmt);
|
||||
}
|
||||
|
@@ -6,11 +6,11 @@
|
||||
|
||||
namespace nostalgia::studio {
|
||||
|
||||
ox::Vector<EditorMaker> Module::editors(core::Context*) {
|
||||
ox::Vector<EditorMaker> Module::editors(turbine::Context*) {
|
||||
return {};
|
||||
}
|
||||
|
||||
ox::Vector<ox::UniquePtr<ItemMaker>> Module::itemMakers(core::Context*) {
|
||||
ox::Vector<ox::UniquePtr<ItemMaker>> Module::itemMakers(turbine::Context*) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@@ -9,8 +9,9 @@
|
||||
#include <ox/std/string.hpp>
|
||||
#include <ox/std/vector.hpp>
|
||||
|
||||
#include <turbine/context.hpp>
|
||||
|
||||
#include <nostalgia/studio/studio.hpp>
|
||||
#include <nostalgia/core/context.hpp>
|
||||
|
||||
namespace nostalgia::studio {
|
||||
|
||||
@@ -26,9 +27,9 @@ class Module {
|
||||
public:
|
||||
virtual ~Module() noexcept = default;
|
||||
|
||||
virtual ox::Vector<EditorMaker> editors(core::Context *ctx);
|
||||
virtual ox::Vector<EditorMaker> editors(turbine::Context *ctx);
|
||||
|
||||
virtual ox::Vector<ox::UniquePtr<ItemMaker>> itemMakers(core::Context*);
|
||||
virtual ox::Vector<ox::UniquePtr<ItemMaker>> itemMakers(turbine::Context*);
|
||||
|
||||
};
|
||||
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#include <ox/std/string.hpp>
|
||||
#include <ox/std/vec.hpp>
|
||||
|
||||
#include <nostalgia/core/context.hpp>
|
||||
#include <turbine/context.hpp>
|
||||
|
||||
#include "imguiuitl.hpp"
|
||||
|
||||
@@ -32,7 +32,7 @@ class Popup {
|
||||
[[nodiscard]]
|
||||
virtual bool isOpen() const noexcept = 0;
|
||||
|
||||
virtual void draw(core::Context *ctx) noexcept = 0;
|
||||
virtual void draw(turbine::Context *ctx) noexcept = 0;
|
||||
|
||||
protected:
|
||||
constexpr void setSize(ox::Size sz) noexcept {
|
||||
@@ -47,7 +47,7 @@ class Popup {
|
||||
return m_title;
|
||||
}
|
||||
|
||||
void drawWindow(core::Context *ctx, bool *open, auto drawContents) {
|
||||
void drawWindow(turbine::Context *ctx, bool *open, auto drawContents) {
|
||||
studio::ig::centerNextWindow(ctx);
|
||||
ImGui::SetNextWindowSize(static_cast<ImVec2>(m_size));
|
||||
constexpr auto modalFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize;
|
||||
|
@@ -8,8 +8,8 @@
|
||||
|
||||
namespace nostalgia::studio {
|
||||
|
||||
void TaskRunner::update(core::Context *ctx) noexcept {
|
||||
oxIgnoreError(m_tasks.erase(std::remove_if(m_tasks.begin(), m_tasks.end(), [&](auto &t) {
|
||||
void TaskRunner::update(turbine::Context *ctx) noexcept {
|
||||
oxIgnoreError(m_tasks.erase(std::remove_if(m_tasks.begin(), m_tasks.end(), [&](ox::UPtr<studio::Task> &t) {
|
||||
const auto done = t->update(ctx) == TaskState::Done;
|
||||
if (done) {
|
||||
t->finished.emit();
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <ox/event/signal.hpp>
|
||||
|
||||
#include <nostalgia/core/context.hpp>
|
||||
#include <turbine/context.hpp>
|
||||
|
||||
namespace nostalgia::studio {
|
||||
|
||||
@@ -19,14 +19,14 @@ class Task: public ox::SignalHandler {
|
||||
public:
|
||||
ox::Signal<ox::Error()> finished;
|
||||
~Task() noexcept override = default;
|
||||
virtual TaskState update(nostalgia::core::Context *ctx) noexcept = 0;
|
||||
virtual TaskState update(turbine::Context *ctx) noexcept = 0;
|
||||
};
|
||||
|
||||
class TaskRunner {
|
||||
private:
|
||||
ox::Vector<ox::UniquePtr<studio::Task>> m_tasks;
|
||||
public:
|
||||
void update(core::Context *ctx) noexcept;
|
||||
void update(turbine::Context *ctx) noexcept;
|
||||
void add(Task *task) noexcept;
|
||||
};
|
||||
|
||||
|
@@ -6,14 +6,14 @@
|
||||
|
||||
#include <ox/event/signal.hpp>
|
||||
|
||||
#include <nostalgia/core/context.hpp>
|
||||
#include <turbine/context.hpp>
|
||||
|
||||
namespace nostalgia::studio {
|
||||
|
||||
class Widget: public ox::SignalHandler {
|
||||
public:
|
||||
~Widget() noexcept override = default;
|
||||
virtual void draw(core::Context*) noexcept = 0;
|
||||
virtual void draw(turbine::Context*) noexcept = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -7,56 +7,55 @@
|
||||
#include <ox/logconn/logconn.hpp>
|
||||
#include <ox/std/trace.hpp>
|
||||
#include <ox/std/uuid.hpp>
|
||||
#include <keel/media.hpp>
|
||||
#include <turbine/turbine.hpp>
|
||||
|
||||
#include <nostalgia/appmodules/appmodules.hpp>
|
||||
#include <nostalgia/core/core.hpp>
|
||||
#include <keel/media.hpp>
|
||||
|
||||
#include "lib/context.hpp"
|
||||
#include "studioapp.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
|
||||
class StudioUIDrawer: public core::Drawer {
|
||||
class StudioUIDrawer: public turbine::gl::Drawer {
|
||||
private:
|
||||
StudioUI *m_ui = nullptr;
|
||||
public:
|
||||
explicit StudioUIDrawer(StudioUI *ui) noexcept: m_ui(ui) {
|
||||
}
|
||||
protected:
|
||||
void draw(core::Context*) noexcept final {
|
||||
void draw(turbine::Context&) noexcept final {
|
||||
m_ui->draw();
|
||||
}
|
||||
};
|
||||
|
||||
static int updateHandler(core::Context *ctx) noexcept {
|
||||
auto sctx = core::applicationData<studio::StudioContext>(ctx);
|
||||
static int updateHandler(turbine::Context &ctx) noexcept {
|
||||
auto sctx = turbine::applicationData<studio::StudioContext>(ctx);
|
||||
auto ui = dynamic_cast<StudioUI*>(sctx->ui);
|
||||
ui->update();
|
||||
return 16;
|
||||
}
|
||||
|
||||
static void keyEventHandler(core::Context *ctx, core::Key key, bool down) noexcept {
|
||||
auto sctx = core::applicationData<studio::StudioContext>(ctx);
|
||||
static void keyEventHandler(turbine::Context &ctx, turbine::Key key, bool down) noexcept {
|
||||
auto sctx = turbine::applicationData<studio::StudioContext>(ctx);
|
||||
auto ui = dynamic_cast<StudioUI*>(sctx->ui);
|
||||
ui->handleKeyEvent(key, down);
|
||||
}
|
||||
|
||||
static ox::Error run(ox::UniquePtr<ox::FileSystem> fs) noexcept {
|
||||
oxRequireM(ctx, core::init(std::move(fs), "NostalgiaStudio"));
|
||||
core::setWindowTitle(ctx.get(), "Nostalgia Studio");
|
||||
core::setUpdateHandler(ctx.get(), updateHandler);
|
||||
core::setKeyEventHandler(ctx.get(), keyEventHandler);
|
||||
core::setConstantRefresh(ctx.get(), false);
|
||||
core::gl::setMainViewEnabled(ctx.get(), false);
|
||||
oxRequireM(ctx, turbine::init(std::move(fs), "NostalgiaStudio"));
|
||||
turbine::setWindowTitle(*ctx, "Nostalgia Studio");
|
||||
turbine::setUpdateHandler(*ctx, updateHandler);
|
||||
turbine::setKeyEventHandler(*ctx, keyEventHandler);
|
||||
turbine::setConstantRefresh(*ctx, false);
|
||||
studio::StudioContext studioCtx;
|
||||
core::setApplicationData(ctx.get(), &studioCtx);
|
||||
turbine::setApplicationData(*ctx, &studioCtx);
|
||||
StudioUI ui(ctx.get());
|
||||
studioCtx.ui = &ui;
|
||||
StudioUIDrawer drawer(&ui);
|
||||
core::addCustomDrawer(ctx.get(), &drawer);
|
||||
auto err = core::run(ctx.get());
|
||||
core::removeCustomDrawer(ctx.get(), &drawer);
|
||||
turbine::gl::addDrawer(*ctx, &drawer);
|
||||
const auto err = turbine::run(*ctx);
|
||||
turbine::gl::removeDrawer(*ctx, &drawer);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@@ -30,7 +30,7 @@ bool NewMenu::isOpen() const noexcept {
|
||||
return m_open;
|
||||
}
|
||||
|
||||
void NewMenu::draw(core::Context *ctx) noexcept {
|
||||
void NewMenu::draw(turbine::Context *ctx) noexcept {
|
||||
switch (m_stage) {
|
||||
case Stage::Opening:
|
||||
ImGui::OpenPopup(title().c_str());
|
||||
@@ -53,7 +53,7 @@ void NewMenu::addItemMaker(ox::UniquePtr<studio::ItemMaker> im) noexcept {
|
||||
m_types.emplace_back(std::move(im));
|
||||
}
|
||||
|
||||
void NewMenu::drawNewItemType(core::Context *ctx) noexcept {
|
||||
void NewMenu::drawNewItemType(turbine::Context *ctx) noexcept {
|
||||
drawWindow(ctx, &m_open, [this] {
|
||||
auto items = ox_malloca(m_types.size() * sizeof(const char*), const char*, nullptr);
|
||||
for (auto i = 0u; const auto &im : m_types) {
|
||||
@@ -66,7 +66,7 @@ void NewMenu::drawNewItemType(core::Context *ctx) noexcept {
|
||||
});
|
||||
}
|
||||
|
||||
void NewMenu::drawNewItemName(core::Context *ctx) noexcept {
|
||||
void NewMenu::drawNewItemName(turbine::Context *ctx) noexcept {
|
||||
drawWindow(ctx, &m_open, [this, ctx] {
|
||||
const auto typeIdx = static_cast<std::size_t>(m_selectedType);
|
||||
if (typeIdx < m_types.size()) {
|
||||
@@ -90,7 +90,7 @@ void NewMenu::drawFirstPageButtons() noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
void NewMenu::drawLastPageButtons(core::Context *ctx) noexcept {
|
||||
void NewMenu::drawLastPageButtons(turbine::Context *ctx) noexcept {
|
||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - 138);
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + ImGui::GetContentRegionAvail().y - 20);
|
||||
if (ImGui::Button("Back")) {
|
||||
@@ -107,7 +107,7 @@ void NewMenu::drawLastPageButtons(core::Context *ctx) noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
void NewMenu::finish(core::Context *ctx) noexcept {
|
||||
void NewMenu::finish(turbine::Context *ctx) noexcept {
|
||||
const auto itemName = ox::String(m_itemName);
|
||||
const auto err = m_types[static_cast<std::size_t>(m_selectedType)]->write(ctx, itemName);
|
||||
if (err) {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -8,8 +8,6 @@
|
||||
#include <ox/event/signal.hpp>
|
||||
#include <ox/std/string.hpp>
|
||||
|
||||
#include <nostalgia/core/context.hpp>
|
||||
|
||||
#include "lib/itemmaker.hpp"
|
||||
#include "lib/popup.hpp"
|
||||
|
||||
@@ -45,7 +43,7 @@ class NewMenu: public studio::Popup {
|
||||
[[nodiscard]]
|
||||
bool isOpen() const noexcept override;
|
||||
|
||||
void draw(core::Context *ctx) noexcept override;
|
||||
void draw(turbine::Context *ctx) noexcept override;
|
||||
|
||||
template<typename T>
|
||||
void addItemType(ox::String name, ox::String parentDir, ox::String fileExt, T itemTempl, ox::ClawFormat pFmt = ox::ClawFormat::Metal) noexcept;
|
||||
@@ -56,15 +54,15 @@ class NewMenu: public studio::Popup {
|
||||
void addItemMaker(ox::UniquePtr<studio::ItemMaker> im) noexcept;
|
||||
|
||||
private:
|
||||
void drawNewItemType(core::Context *ctx) noexcept;
|
||||
void drawNewItemType(turbine::Context *ctx) noexcept;
|
||||
|
||||
void drawNewItemName(core::Context *ctx) noexcept;
|
||||
void drawNewItemName(turbine::Context *ctx) noexcept;
|
||||
|
||||
void drawFirstPageButtons() noexcept;
|
||||
|
||||
void drawLastPageButtons(core::Context *ctx) noexcept;
|
||||
void drawLastPageButtons(turbine::Context *ctx) noexcept;
|
||||
|
||||
void finish(core::Context *ctx) noexcept;
|
||||
void finish(turbine::Context *ctx) noexcept;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -31,11 +31,11 @@ buildProjectTreeModel(ProjectExplorer *explorer, ox::CRStringView name, ox::CRSt
|
||||
return out;
|
||||
}
|
||||
|
||||
ProjectExplorer::ProjectExplorer(core::Context *ctx) noexcept {
|
||||
ProjectExplorer::ProjectExplorer(turbine::Context *ctx) noexcept {
|
||||
m_ctx = ctx;
|
||||
}
|
||||
|
||||
void ProjectExplorer::draw(core::Context *ctx) noexcept {
|
||||
void ProjectExplorer::draw(turbine::Context *ctx) noexcept {
|
||||
const auto viewport = ImGui::GetMainViewport();
|
||||
ImGui::SetNextWindowPos(ImVec2(viewport->Pos.x, viewport->Pos.y + 20));
|
||||
ImGui::SetNextWindowSize(ImVec2(313, viewport->Size.y - 20));
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -15,11 +15,11 @@ namespace nostalgia {
|
||||
class ProjectExplorer: public studio::Widget {
|
||||
private:
|
||||
ox::UniquePtr<ProjectTreeModel> m_treeModel;
|
||||
core::Context *m_ctx = nullptr;
|
||||
turbine::Context *m_ctx = nullptr;
|
||||
public:
|
||||
explicit ProjectExplorer(core::Context *ctx) noexcept;
|
||||
explicit ProjectExplorer(turbine::Context *ctx) noexcept;
|
||||
|
||||
void draw(core::Context *ctx) noexcept override;
|
||||
void draw(turbine::Context *ctx) noexcept override;
|
||||
|
||||
void setModel(ox::UniquePtr<ProjectTreeModel> model) noexcept;
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <imgui.h>
|
||||
@@ -23,7 +23,7 @@ ProjectTreeModel::ProjectTreeModel(ProjectTreeModel &&other) noexcept:
|
||||
m_children(std::move(other.m_children)) {
|
||||
}
|
||||
|
||||
void ProjectTreeModel::draw(core::Context *ctx) const noexcept {
|
||||
void ProjectTreeModel::draw(turbine::Context *ctx) const noexcept {
|
||||
constexpr auto dirFlags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick;
|
||||
if (!m_children.empty()) {
|
||||
if (ImGui::TreeNodeEx(m_name.c_str(), dirFlags)) {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <ox/std/memory.hpp>
|
||||
#include <ox/std/string.hpp>
|
||||
|
||||
#include <nostalgia/core/context.hpp>
|
||||
#include <turbine/context.hpp>
|
||||
|
||||
namespace nostalgia {
|
||||
|
||||
@@ -23,7 +23,7 @@ class ProjectTreeModel {
|
||||
|
||||
ProjectTreeModel(ProjectTreeModel &&other) noexcept;
|
||||
|
||||
void draw(core::Context *ctx) const noexcept;
|
||||
void draw(turbine::Context *ctx) const noexcept;
|
||||
|
||||
void setChildren(ox::Vector<ox::UniquePtr<ProjectTreeModel>> children) noexcept;
|
||||
|
||||
|
@@ -4,8 +4,8 @@
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
#include <nostalgia/core/core.hpp>
|
||||
#include <keel/media.hpp>
|
||||
#include <turbine/turbine.hpp>
|
||||
|
||||
#include "lib/configio.hpp"
|
||||
#include "builtinmodules.hpp"
|
||||
@@ -31,7 +31,7 @@ oxModelBegin(StudioConfig)
|
||||
oxModelFieldRename(show_project_explorer, showProjectExplorer)
|
||||
oxModelEnd()
|
||||
|
||||
StudioUI::StudioUI(core::Context *ctx) noexcept {
|
||||
StudioUI::StudioUI(turbine::Context *ctx) noexcept {
|
||||
m_ctx = ctx;
|
||||
m_projectExplorer = ox::make_unique<ProjectExplorer>(m_ctx);
|
||||
m_projectExplorer->fileChosen.connect(this, &StudioUI::openFile);
|
||||
@@ -61,11 +61,11 @@ void StudioUI::update() noexcept {
|
||||
m_taskRunner.update(m_ctx);
|
||||
}
|
||||
|
||||
void StudioUI::handleKeyEvent(core::Key key, bool down) noexcept {
|
||||
const auto ctrlDown = core::buttonDown(m_ctx, core::Key::Mod_Ctrl);
|
||||
void StudioUI::handleKeyEvent(turbine::Key key, bool down) noexcept {
|
||||
const auto ctrlDown = turbine::buttonDown(*m_ctx, turbine::Key::Mod_Ctrl);
|
||||
for (auto p : m_popups) {
|
||||
if (p->isOpen()) {
|
||||
if (key == core::Key::Escape) {
|
||||
if (key == turbine::Key::Escape) {
|
||||
p->close();
|
||||
}
|
||||
return;
|
||||
@@ -73,34 +73,34 @@ void StudioUI::handleKeyEvent(core::Key key, bool down) noexcept {
|
||||
}
|
||||
if (down && ctrlDown) {
|
||||
switch (key) {
|
||||
case core::Key::Num_1:
|
||||
case turbine::Key::Num_1:
|
||||
toggleProjectExplorer();
|
||||
break;
|
||||
case core::Key::Alpha_C:
|
||||
case turbine::Key::Alpha_C:
|
||||
m_activeEditor->copy();
|
||||
break;
|
||||
case core::Key::Alpha_N:
|
||||
case turbine::Key::Alpha_N:
|
||||
m_newMenu.open();
|
||||
break;
|
||||
case core::Key::Alpha_O:
|
||||
case turbine::Key::Alpha_O:
|
||||
m_taskRunner.add(ox::make<FileDialogManager>(this, &StudioUI::openProject));
|
||||
break;
|
||||
case core::Key::Alpha_Q:
|
||||
core::shutdown(m_ctx);
|
||||
case turbine::Key::Alpha_Q:
|
||||
turbine::requestShutdown(*m_ctx);
|
||||
break;
|
||||
case core::Key::Alpha_S:
|
||||
case turbine::Key::Alpha_S:
|
||||
save();
|
||||
break;
|
||||
case core::Key::Alpha_V:
|
||||
case turbine::Key::Alpha_V:
|
||||
m_activeEditor->paste();
|
||||
break;
|
||||
case core::Key::Alpha_X:
|
||||
case turbine::Key::Alpha_X:
|
||||
m_activeEditor->cut();
|
||||
break;
|
||||
case core::Key::Alpha_Y:
|
||||
case turbine::Key::Alpha_Y:
|
||||
redo();
|
||||
break;
|
||||
case core::Key::Alpha_Z:
|
||||
case turbine::Key::Alpha_Z:
|
||||
undo();
|
||||
break;
|
||||
default:
|
||||
@@ -141,7 +141,7 @@ void StudioUI::drawMenu() noexcept {
|
||||
m_activeEditor->save();
|
||||
}
|
||||
if (ImGui::MenuItem("Quit", "Ctrl+Q")) {
|
||||
core::shutdown(m_ctx);
|
||||
turbine::requestShutdown(*m_ctx);
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
@@ -219,7 +219,7 @@ void StudioUI::drawTabs() noexcept {
|
||||
}
|
||||
if (m_activeEditorOnLastDraw != e.get()) [[unlikely]] {
|
||||
m_activeEditor->onActivated();
|
||||
core::setConstantRefresh(m_ctx, m_activeEditor->requiresConstantRefresh());
|
||||
turbine::setConstantRefresh(*m_ctx, m_activeEditor->requiresConstantRefresh());
|
||||
}
|
||||
e->draw(m_ctx);
|
||||
m_activeEditorOnLastDraw = e.get();
|
||||
@@ -292,9 +292,9 @@ void StudioUI::save() noexcept {
|
||||
ox::Error StudioUI::openProject(ox::CRStringView path) noexcept {
|
||||
oxRequireM(fs, keel::loadRomFs(path));
|
||||
oxReturnError(keel::setRomFs(m_ctx, std::move(fs)));
|
||||
core::setWindowTitle(m_ctx, ox::sfmt("Nostalgia Studio - {}", path));
|
||||
turbine::setWindowTitle(*m_ctx, ox::sfmt("Nostalgia Studio - {}", path));
|
||||
m_project = ox::make_unique<studio::Project>(m_ctx, path);
|
||||
auto sctx = applicationData<studio::StudioContext>(m_ctx);
|
||||
auto sctx = applicationData<studio::StudioContext>(*m_ctx);
|
||||
sctx->project = m_project.get();
|
||||
m_project->fileAdded.connect(m_projectExplorer.get(), &ProjectExplorer::refreshProjectTreeModel);
|
||||
m_project->fileDeleted.connect(m_projectExplorer.get(), &ProjectExplorer::refreshProjectTreeModel);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -25,7 +25,7 @@ class StudioUI: public ox::SignalHandler {
|
||||
private:
|
||||
ox::UniquePtr<studio::Project> m_project;
|
||||
studio::TaskRunner m_taskRunner;
|
||||
core::Context *m_ctx = nullptr;
|
||||
turbine::Context *m_ctx = nullptr;
|
||||
ox::Vector<ox::UniquePtr<studio::BaseEditor>> m_editors;
|
||||
ox::Vector<ox::UniquePtr<studio::Widget>> m_widgets;
|
||||
ox::HashMap<ox::String, studio::EditorMaker::Func> m_editorMakers;
|
||||
@@ -43,11 +43,11 @@ class StudioUI: public ox::SignalHandler {
|
||||
bool m_showProjectExplorer = true;
|
||||
|
||||
public:
|
||||
explicit StudioUI(core::Context *ctx) noexcept;
|
||||
explicit StudioUI(turbine::Context *ctx) noexcept;
|
||||
|
||||
void update() noexcept;
|
||||
|
||||
void handleKeyEvent(core::Key, bool down) noexcept;
|
||||
void handleKeyEvent(turbine::Key, bool down) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr auto project() noexcept {
|
||||
|
Reference in New Issue
Block a user