Compare commits
2 Commits
release-d2
...
1ed9949bf3
| Author | SHA1 | Date | |
|---|---|---|---|
| 1ed9949bf3 | |||
| 9d5915d54a |
5
deps/ox/src/ox/std/stringview.hpp
vendored
5
deps/ox/src/ox/std/stringview.hpp
vendored
@@ -104,16 +104,13 @@ constexpr ox::Result<int> strToInt(StringViewCR str) noexcept {
|
||||
OX_ALLOW_UNSAFE_BUFFERS_BEGIN
|
||||
int total = 0;
|
||||
int multiplier = 1;
|
||||
if (str.len() == 0) [[unlikely]] {
|
||||
return Error{1, "Empty string passed to strToInt"};
|
||||
}
|
||||
for (auto i = static_cast<int64_t>(str.len()) - 1; i != -1; --i) {
|
||||
auto s = static_cast<std::size_t>(i);
|
||||
if (str[s] >= '0' && str[s] <= '9') {
|
||||
total += (str[s] - '0') * multiplier;
|
||||
multiplier *= 10;
|
||||
} else {
|
||||
return ox::Error{1};
|
||||
return ox::Error(1);
|
||||
}
|
||||
}
|
||||
return total;
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
# d2025.06.0
|
||||
|
||||
* Add ability to remember recent projects in config
|
||||
* Add navigation support (back and forward)
|
||||
* Fix file deletion to close file even if not active
|
||||
* Fix file copy to work when creating a copy with the name of a previously
|
||||
deleted file
|
||||
* Fix crash that could occur after switching projects
|
||||
* Make file picker popup accept on double click of a file
|
||||
* TileSheetEditor: Fix copy/cut/paste enablement when there is no selection
|
||||
* TileSheetEditor: Fix manual redo of draw actions, fix drawing to pixel 0, 0
|
||||
as first action
|
||||
* TileSheetEditor: Fix draw command to work on same pixel after switching
|
||||
subsheets
|
||||
* PaletteEditor: Add RGB key shortcuts for focusing color channels
|
||||
* PaletteEditor: Add color preview to color editor
|
||||
* PaletteEditor: Make RGB key shortcuts work when color channel inputs are
|
||||
focused
|
||||
|
||||
# d2025.05.2
|
||||
|
||||
* TileSheetEditor: Fix manual redo of draw actions, fix drawing to pixel 0, 0 as first action (cce5f52f96511694afd98f0b9b6b1f19c06ecd20)
|
||||
* TileSheetEditor: Fix draw command to work on same pixel after switching subsheets (514cb978351ee4b0a5335c22a506a6d9f608f0a7)
|
||||
|
||||
# d2025.05.1
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ AddSubSheetCommand::AddSubSheetCommand(
|
||||
auto &parent = getSubSheet(m_img, m_parentIdx);
|
||||
if (!parent.subsheets.empty()) {
|
||||
auto idx = m_parentIdx;
|
||||
idx.emplace_back(static_cast<uint32_t>(parent.subsheets.size()));
|
||||
idx.emplace_back(parent.subsheets.size());
|
||||
m_addedSheets.push_back(idx);
|
||||
} else {
|
||||
auto idx = m_parentIdx;
|
||||
|
||||
@@ -192,9 +192,6 @@ void TileSheetEditorImGui::keyStateChanged(turbine::Key const key, bool const do
|
||||
}
|
||||
|
||||
void TileSheetEditorImGui::draw(studio::Context&) noexcept {
|
||||
setCopyEnabled(m_model.hasSelection());
|
||||
setCutEnabled(m_model.hasSelection());
|
||||
setPasteEnabled(m_model.hasSelection());
|
||||
if (ig::mainWinHasFocus() && m_tool == TileSheetTool::Select) {
|
||||
if (ImGui::IsKeyDown(ImGuiKey_ModCtrl) && !m_palPathFocused) {
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_A)) {
|
||||
@@ -279,7 +276,7 @@ void TileSheetEditorImGui::draw(studio::Context&) noexcept {
|
||||
auto insertOnIdx = m_model.activeSubSheetIdx();
|
||||
auto const &parent = m_model.activeSubSheet();
|
||||
m_model.addSubsheet(insertOnIdx);
|
||||
insertOnIdx.emplace_back(static_cast<uint32_t>(parent.subsheets.size() - 1));
|
||||
insertOnIdx.emplace_back(parent.subsheets.size() - 1);
|
||||
setActiveSubsheet(insertOnIdx);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
|
||||
@@ -315,10 +315,6 @@ void TileSheetEditorModel::clearSelection() noexcept {
|
||||
m_selection.reset();
|
||||
}
|
||||
|
||||
bool TileSheetEditorModel::hasSelection() const noexcept {
|
||||
return m_selection.has_value();
|
||||
}
|
||||
|
||||
bool TileSheetEditorModel::updated() const noexcept {
|
||||
return m_updated;
|
||||
}
|
||||
|
||||
@@ -118,9 +118,6 @@ class TileSheetEditorModel final: public ox::SignalHandler {
|
||||
|
||||
void clearSelection() noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
bool hasSelection() const noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
bool updated() const noexcept;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ target_link_libraries(
|
||||
|
||||
target_compile_definitions(
|
||||
NostalgiaStudio PUBLIC
|
||||
OLYMPIC_APP_VERSION="d2025.06.0"
|
||||
OLYMPIC_APP_VERSION="dev build"
|
||||
)
|
||||
|
||||
install(
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<string>APPL</string>
|
||||
|
||||
<key>CFBundleVersion</key>
|
||||
<string>d2025.06.0</string>
|
||||
<string>dev build</string>
|
||||
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>12.0.0</string>
|
||||
|
||||
@@ -28,15 +28,10 @@ class StudioUIDrawer: public turbine::gl::Drawer {
|
||||
};
|
||||
|
||||
static void keyEventHandler(turbine::Context &ctx, turbine::Key key, bool down) noexcept {
|
||||
auto const sctx = turbine::applicationData<studio::Context>(ctx);
|
||||
auto sctx = turbine::applicationData<studio::Context>(ctx);
|
||||
sctx->ui.handleKeyEvent(key, down);
|
||||
}
|
||||
|
||||
static void mouseButtonEventHandler(turbine::Context &ctx, int const btn, bool const down) noexcept {
|
||||
auto const sctx = turbine::applicationData<studio::Context>(ctx);
|
||||
sctx->ui.handleMouseButtonEvent(btn, down);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
ox::Vector<ox::SpanView<uint8_t>> WindowIcons() noexcept;
|
||||
|
||||
@@ -48,7 +43,6 @@ static ox::Error runApp(
|
||||
oxLogError(turbine::setWindowIcon(*ctx, WindowIcons()));
|
||||
turbine::setWindowTitle(*ctx, keelCtx(*ctx).appName);
|
||||
turbine::setKeyEventHandler(*ctx, keyEventHandler);
|
||||
turbine::setMouseButtonEventHandler(*ctx, mouseButtonEventHandler);
|
||||
turbine::requireRefreshWithin(*ctx, 0);
|
||||
StudioUI ui(*ctx, projectDataDir);
|
||||
StudioUIDrawer drawer(ui);
|
||||
|
||||
@@ -80,9 +80,9 @@ void NewMenu::addItemMaker(ox::UPtr<ItemMaker> &&im) noexcept {
|
||||
});
|
||||
}
|
||||
|
||||
void NewMenu::installItemTemplate(ox::UPtr<ItemTemplate> &&tmplt) noexcept {
|
||||
void NewMenu::installItemTemplate(ox::UPtr<ItemTemplate> &tmplt) noexcept {
|
||||
for (auto const&im : m_types) {
|
||||
if (im->installTemplate(std::move(tmplt))) {
|
||||
if (im->installTemplate(tmplt)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ class NewMenu final: public Popup {
|
||||
|
||||
void addItemMaker(ox::UPtr<ItemMaker> &&im) noexcept;
|
||||
|
||||
void installItemTemplate(ox::UPtr<ItemTemplate> &&tmplt) noexcept;
|
||||
void installItemTemplate(ox::UPtr<ItemTemplate> &tmplt) noexcept;
|
||||
|
||||
private:
|
||||
void drawNewItemType(Context const&sctx) noexcept;
|
||||
|
||||
@@ -177,16 +177,6 @@ void StudioUI::handleKeyEvent(turbine::Key const key, bool const down) noexcept
|
||||
}
|
||||
}
|
||||
|
||||
void StudioUI::handleMouseButtonEvent(int const btn, bool const down) noexcept {
|
||||
if (down) {
|
||||
if (btn == 3) { // back button
|
||||
navigateBack(m_sctx);
|
||||
} else if (btn == 4) { // forward button
|
||||
navigateForward(m_sctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StudioUI::handleNavigationChange(ox::StringParam path, ox::StringParam navArgs) noexcept {
|
||||
m_navAction.emplace(std::move(path), std::move(navArgs));
|
||||
}
|
||||
@@ -312,13 +302,11 @@ void StudioUI::drawMenu() noexcept {
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::BeginMenu("Navigate")) {
|
||||
constexpr auto backShortcut = ox::defines::OS == ox::OS::Darwin ? "Cmd+[" : "Alt+Left Arrow";
|
||||
constexpr auto fwdShortcut = ox::defines::OS == ox::OS::Darwin ? "Cmd+]" : "Alt+Right Arrow";
|
||||
if (ImGui::MenuItem("Back", backShortcut, false, m_sctx.navIdx > 1)) {
|
||||
if (ImGui::MenuItem("Back", STUDIO_CTRL "+{", false, m_sctx.navIdx > 1)) {
|
||||
navigateBack(m_sctx);
|
||||
}
|
||||
if (ImGui::MenuItem(
|
||||
"Forward", fwdShortcut, false,
|
||||
"Forward", STUDIO_CTRL "+}", false,
|
||||
m_sctx.navIdx < m_sctx.navStack.size())) {
|
||||
navigateForward(m_sctx);
|
||||
}
|
||||
@@ -419,6 +407,10 @@ void StudioUI::drawTabs() noexcept {
|
||||
if (!openFile(m_navAction->path)) {
|
||||
m_activeEditor->navigateTo(m_navAction->args);
|
||||
m_navAction.reset();
|
||||
} else {
|
||||
//auto const i = m_sctx.navIdx - 1;
|
||||
//oxDebugf("deleting {}", m_sctx.navStack[i].filePath);
|
||||
//std::ignore = m_sctx.navStack.erase(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -438,7 +430,7 @@ void StudioUI::loadModule(Module const &mod) noexcept {
|
||||
}
|
||||
auto tmplts = mod.itemTemplates(m_sctx);
|
||||
for (auto &t : tmplts) {
|
||||
m_newMenu.installItemTemplate(std::move(t));
|
||||
m_newMenu.installItemTemplate(t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -649,9 +641,6 @@ ox::Error StudioUI::openProjectPath(ox::StringParam path) noexcept {
|
||||
ox::make_unique_catch<Project>(keelCtx(m_tctx), std::move(path), m_projectDataDir)
|
||||
.moveTo(m_project));
|
||||
m_sctx.project = m_project.get();
|
||||
m_activeEditor = nullptr;
|
||||
m_activeEditorOnLastDraw = nullptr;
|
||||
m_activeEditorUpdatePending = nullptr;
|
||||
turbine::setWindowTitle(
|
||||
m_tctx, ox::sfmt("{} - {}", keelCtx(m_tctx).appName, m_project->projectPath()));
|
||||
m_deleteConfirmation.deleteFile.connect(m_sctx.project, &Project::deleteItem);
|
||||
|
||||
@@ -87,8 +87,6 @@ class StudioUI final: public ox::SignalHandler {
|
||||
|
||||
void handleKeyEvent(turbine::Key, bool down) noexcept;
|
||||
|
||||
void handleMouseButtonEvent(int btn, bool down) noexcept;
|
||||
|
||||
void handleNavigationChange(ox::StringParam path, ox::StringParam navArgs) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
|
||||
@@ -13,11 +13,7 @@ class FilePickerPopup {
|
||||
|
||||
private:
|
||||
ox::String m_name;
|
||||
struct Explorer: public FileExplorer {
|
||||
mutable bool opened{};
|
||||
explicit Explorer(keel::Context &kctx);
|
||||
void fileOpened(ox::StringViewCR path) const noexcept override;
|
||||
} m_explorer;
|
||||
FileExplorer m_explorer;
|
||||
ox::Vector<ox::String> const m_fileExts;
|
||||
bool m_open{};
|
||||
|
||||
@@ -37,10 +33,6 @@ class FilePickerPopup {
|
||||
|
||||
ox::Optional<ox::String> draw(Context &ctx) noexcept;
|
||||
|
||||
private:
|
||||
[[nodiscard]]
|
||||
ox::Optional<ox::String> handlePick() noexcept;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ class ItemMaker {
|
||||
return m_typeDisplayName;
|
||||
}
|
||||
|
||||
bool installTemplate(ox::UPtr<ItemTemplate> &&tmpl) {
|
||||
bool installTemplate(ox::UPtr<ItemTemplate> &tmpl) {
|
||||
if (typeName() == tmpl->typeName() &&
|
||||
typeVersion() <= tmpl->typeVersion()) {
|
||||
m_templates.emplace_back(std::move(tmpl));
|
||||
@@ -120,6 +120,10 @@ class ItemMaker {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool installTemplate(ox::UPtr<ItemTemplate> &&tmpl) {
|
||||
return installTemplate(tmpl);
|
||||
}
|
||||
|
||||
constexpr ox::Vector<ox::UPtr<ItemTemplate>> const&itemTemplates() const noexcept {
|
||||
return m_templates;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace studio {
|
||||
void navigateTo(Context &ctx, ox::StringParam filePath, ox::StringParam navArgs) noexcept {
|
||||
ox::String path = std::move(filePath);
|
||||
if (beginsWith(path, "uuid://")) {
|
||||
auto const [p, err] = keel::uuidUrlToPath(keelCtx(ctx), path);
|
||||
auto [p, err] = keel::uuidUrlToPath(keelCtx(ctx), path);
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
@@ -17,12 +17,7 @@ void navigateTo(Context &ctx, ox::StringParam filePath, ox::StringParam navArgs)
|
||||
}
|
||||
ctx.navStack.resize(ctx.navIdx + 1);
|
||||
ctx.navStack.emplace_back(ox::String{path}, ox::String{navArgs.view()});
|
||||
try {
|
||||
ctx.navCallback(std::move(path), std::move(navArgs));
|
||||
} catch (std::exception const &e) {
|
||||
oxErrf("Nav error: {}", e.what());
|
||||
oxAssert(false, "Nav error");
|
||||
}
|
||||
}
|
||||
|
||||
void navigateBack(Context &ctx) noexcept {
|
||||
@@ -30,26 +25,19 @@ void navigateBack(Context &ctx) noexcept {
|
||||
return;
|
||||
}
|
||||
--ctx.navIdx;
|
||||
while (ctx.navIdx < ctx.navStack.size() && ctx.navIdx) {
|
||||
auto const i = ctx.navIdx - 1;
|
||||
auto const &n = ctx.navStack[i];
|
||||
if (!ctx.project->exists(n.filePath)) {
|
||||
std::ignore = ctx.navStack.erase(i);
|
||||
--ctx.navIdx;
|
||||
continue;
|
||||
}
|
||||
if (ctx.navIdx < ctx.navStack.size() && ctx.navIdx) {
|
||||
auto const &n = ctx.navStack[ctx.navIdx - 1];
|
||||
try {
|
||||
ctx.navCallback(n.filePath, n.navArgs);
|
||||
} catch (std::exception const &e) {
|
||||
oxAssert(ctx.navCallback != nullptr, "navCallback is null");
|
||||
oxErrf("navigateForward failed: {}", e.what());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void navigateForward(Context &ctx) noexcept {
|
||||
while (ctx.navIdx < ctx.navStack.size()) {
|
||||
if (ctx.navIdx < ctx.navStack.size()) {
|
||||
auto const &n = ctx.navStack[ctx.navIdx];
|
||||
try {
|
||||
ctx.navCallback(n.filePath, n.navArgs);
|
||||
@@ -57,12 +45,7 @@ void navigateForward(Context &ctx) noexcept {
|
||||
oxAssert(ctx.navCallback != nullptr, "navCallback is null");
|
||||
oxErrf("navigateForward failed: {}", e.what());
|
||||
}
|
||||
if (!ctx.project->exists(n.filePath)) {
|
||||
std::ignore = ctx.navStack.erase(ctx.navIdx);
|
||||
continue;
|
||||
}
|
||||
++ctx.navIdx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,33 +72,27 @@ bool BaseEditor::exportable() const noexcept {
|
||||
}
|
||||
|
||||
void BaseEditor::setCutEnabled(bool v) {
|
||||
if (m_cutEnabled != v) {
|
||||
m_cutEnabled = v;
|
||||
cutEnabledChanged.emit(v);
|
||||
}
|
||||
}
|
||||
|
||||
bool BaseEditor::cutEnabled() const noexcept {
|
||||
return m_cutEnabled;
|
||||
}
|
||||
|
||||
void BaseEditor::setCopyEnabled(bool v) {
|
||||
if (m_copyEnabled != v) {
|
||||
m_copyEnabled = v;
|
||||
copyEnabledChanged.emit(v);
|
||||
}
|
||||
}
|
||||
|
||||
bool BaseEditor::copyEnabled() const noexcept {
|
||||
return m_copyEnabled;
|
||||
}
|
||||
|
||||
void BaseEditor::setPasteEnabled(bool v) {
|
||||
if (m_pasteEnabled != v) {
|
||||
m_pasteEnabled = v;
|
||||
pasteEnabledChanged.emit(v);
|
||||
}
|
||||
}
|
||||
|
||||
bool BaseEditor::pasteEnabled() const noexcept {
|
||||
return m_pasteEnabled && acceptsClipboardPayload();
|
||||
|
||||
@@ -8,15 +8,6 @@
|
||||
|
||||
namespace studio {
|
||||
|
||||
FilePickerPopup::Explorer::Explorer(keel::Context &kctx):
|
||||
FileExplorer{kctx} {
|
||||
}
|
||||
|
||||
void FilePickerPopup::Explorer::fileOpened(ox::StringViewCR) const noexcept {
|
||||
opened = true;
|
||||
}
|
||||
|
||||
|
||||
FilePickerPopup::FilePickerPopup(
|
||||
ox::StringParam name,
|
||||
keel::Context &kctx,
|
||||
@@ -50,7 +41,6 @@ void FilePickerPopup::refresh() noexcept {
|
||||
void FilePickerPopup::open() noexcept {
|
||||
refresh();
|
||||
m_open = true;
|
||||
m_explorer.opened = false;
|
||||
}
|
||||
|
||||
void FilePickerPopup::close() noexcept {
|
||||
@@ -70,22 +60,16 @@ ox::Optional<ox::String> FilePickerPopup::draw(Context &ctx) noexcept {
|
||||
if (ig::BeginPopup(ctx.tctx, m_name, m_open, {380, 340})) {
|
||||
auto const vp = ImGui::GetContentRegionAvail();
|
||||
m_explorer.draw(ctx, {vp.x, vp.y - 30});
|
||||
if (ig::PopupControlsOkCancel(m_open) == ig::PopupResponse::OK || m_explorer.opened) {
|
||||
out = handlePick();
|
||||
if (ig::PopupControlsOkCancel(m_open) == ig::PopupResponse::OK) {
|
||||
auto p = m_explorer.selectedPath();
|
||||
if (p) {
|
||||
out.emplace(*p);
|
||||
}
|
||||
close();
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
ox::Optional<ox::String> FilePickerPopup::handlePick() noexcept {
|
||||
ox::Optional<ox::String> out;
|
||||
auto p = m_explorer.selectedPath();
|
||||
if (p) {
|
||||
out.emplace(*p);
|
||||
}
|
||||
close();
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -101,8 +101,8 @@ ox::Result<ox::FileStat> Project::stat(ox::StringViewCR path) const noexcept {
|
||||
ox::Error Project::copyItem(ox::StringViewCR src, ox::StringViewCR dest) noexcept {
|
||||
OX_REQUIRE_M(buff, loadBuff(src));
|
||||
OX_REQUIRE(id, keel::regenerateUuidHeader(buff));
|
||||
OX_RETURN_ERROR(writeBuff(dest, buff));
|
||||
createUuidMapping(m_kctx, dest, id);
|
||||
OX_RETURN_ERROR(writeBuff(dest, ox::BufferView{buff} + keel::K1HdrSz));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@@ -79,14 +79,11 @@ enum Key {
|
||||
};
|
||||
|
||||
using KeyEventHandler = void(*)(Context&, Key, bool);
|
||||
using MouseButtonEventHandler = void(*)(Context&, int btn, bool);
|
||||
|
||||
void setKeyEventHandler(Context &ctx, KeyEventHandler h) noexcept;
|
||||
|
||||
void setMouseButtonEventHandler(Context &ctx, MouseButtonEventHandler h) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
KeyEventHandler keyEventHandler(Context const &ctx) noexcept;
|
||||
KeyEventHandler keyEventHandler(Context &ctx) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
bool buttonDown(Context const&ctx, Key) noexcept;
|
||||
|
||||
@@ -133,9 +133,7 @@ void setKeyEventHandler(Context &ctx, KeyEventHandler h) noexcept {
|
||||
ctx.keyEventHandler = h;
|
||||
}
|
||||
|
||||
void setMouseButtonEventHandler(Context&, MouseButtonEventHandler) noexcept {}
|
||||
|
||||
KeyEventHandler keyEventHandler(Context const &ctx) noexcept {
|
||||
KeyEventHandler keyEventHandler(Context &ctx) noexcept {
|
||||
return ctx.keyEventHandler;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ class Context {
|
||||
UpdateHandler updateHandler = [](Context&) -> int {return -1;};
|
||||
keel::Context keelCtx;
|
||||
KeyEventHandler keyEventHandler = nullptr;
|
||||
MouseButtonEventHandler mouseButtonEventHandler = nullptr;
|
||||
ox::AnyPtr applicationData;
|
||||
|
||||
// GLFW impl data ////////////////////////////////////////////////////////
|
||||
|
||||
@@ -299,14 +299,9 @@ static void handleKeyPress(Context &ctx, int const key, bool const down) noexcep
|
||||
static void handleGlfwCursorPosEvent(GLFWwindow*, double, double) noexcept {
|
||||
}
|
||||
|
||||
static void handleGlfwMouseButtonEvent(
|
||||
GLFWwindow *window,
|
||||
int const btn,
|
||||
int const action,
|
||||
int) noexcept {
|
||||
static void handleGlfwMouseButtonEvent(GLFWwindow *window, int, int, int) noexcept {
|
||||
auto &ctx = *static_cast<Context*>(glfwGetWindowUserPointer(window));
|
||||
setMandatoryRefreshPeriod(ctx, ticksMs(ctx) + config::MandatoryRefreshPeriod);
|
||||
ctx.mouseButtonEventHandler(ctx, btn, action == 1);
|
||||
}
|
||||
|
||||
static void handleGlfwKeyEvent(GLFWwindow *window, int const key, int, int const action, int) noexcept {
|
||||
@@ -344,8 +339,7 @@ ox::Result<ox::UPtr<Context>> init(
|
||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
|
||||
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
|
||||
constexpr auto Scale = 5;
|
||||
ctx->window = glfwCreateWindow(
|
||||
240 * Scale, 160 * Scale, ctx->keelCtx.appName.c_str(), nullptr, nullptr);
|
||||
ctx->window = glfwCreateWindow(240 * Scale, 160 * Scale, ctx->keelCtx.appName.c_str(), nullptr, nullptr);
|
||||
//ctx.window = glfwCreateWindow(876, 743, ctx.keelCtx.appName.c_str(), nullptr, nullptr);
|
||||
if (ctx->window == nullptr) {
|
||||
return ox::Error(1, "Could not open GLFW window");
|
||||
@@ -453,19 +447,15 @@ void setShutdownHandler(Context &ctx, ShutdownHandler const handler) noexcept {
|
||||
ctx.shutdownHandler = handler;
|
||||
}
|
||||
|
||||
void setUpdateHandler(Context &ctx, UpdateHandler const h) noexcept {
|
||||
void setUpdateHandler(Context &ctx, UpdateHandler h) noexcept {
|
||||
ctx.updateHandler = h;
|
||||
}
|
||||
|
||||
void setKeyEventHandler(Context &ctx, KeyEventHandler const h) noexcept {
|
||||
void setKeyEventHandler(Context &ctx, KeyEventHandler h) noexcept {
|
||||
ctx.keyEventHandler = h;
|
||||
}
|
||||
|
||||
void setMouseButtonEventHandler(Context &ctx, MouseButtonEventHandler const h) noexcept {
|
||||
ctx.mouseButtonEventHandler = h;
|
||||
}
|
||||
|
||||
KeyEventHandler keyEventHandler(Context const &ctx) noexcept {
|
||||
KeyEventHandler keyEventHandler(Context &ctx) noexcept {
|
||||
return ctx.keyEventHandler;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user