Compare commits
7 Commits
bd665cfc35
...
03a1a8abca
Author | SHA1 | Date | |
---|---|---|---|
03a1a8abca | |||
4e0ce57594 | |||
220f272867 | |||
79e6838ab3 | |||
78eeb30b15 | |||
8679f6b5a3 | |||
323d5d8d53 |
13
deps/ox/src/ox/std/CMakeLists.txt
vendored
13
deps/ox/src/ox/std/CMakeLists.txt
vendored
@ -38,10 +38,15 @@ add_library(
|
||||
trace.cpp
|
||||
typetraits.cpp
|
||||
uuid.cpp
|
||||
vec.cpp
|
||||
)
|
||||
|
||||
if(NOT MSVC)
|
||||
target_compile_options(OxStd PRIVATE -Wsign-conversion)
|
||||
if(UNIX AND NOT APPLE)
|
||||
target_compile_options(OxStd PUBLIC -export-dynamic)
|
||||
#target_link_options(OxStd PUBLIC -W1,-E)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT OX_BARE_METAL)
|
||||
@ -77,14 +82,15 @@ install(
|
||||
array.hpp
|
||||
assert.hpp
|
||||
bit.hpp
|
||||
bounds.hpp
|
||||
bstring.hpp
|
||||
buffer.hpp
|
||||
buildinfo.hpp
|
||||
byteswap.hpp
|
||||
concepts.hpp
|
||||
def.hpp
|
||||
defines.hpp
|
||||
defer.hpp
|
||||
defines.hpp
|
||||
error.hpp
|
||||
fmt.hpp
|
||||
hardware.hpp
|
||||
@ -96,12 +102,14 @@ install(
|
||||
memory.hpp
|
||||
new.hpp
|
||||
optional.hpp
|
||||
point.hpp
|
||||
random.hpp
|
||||
ranges.hpp
|
||||
serialize.hpp
|
||||
size.hpp
|
||||
stacktrace.hpp
|
||||
std.hpp
|
||||
stddef.hpp
|
||||
stacktrace.hpp
|
||||
string.hpp
|
||||
stringview.hpp
|
||||
strongint.hpp
|
||||
@ -112,6 +120,7 @@ install(
|
||||
typetraits.hpp
|
||||
units.hpp
|
||||
uuid.hpp
|
||||
vec.hpp
|
||||
vector.hpp
|
||||
writer.hpp
|
||||
DESTINATION
|
||||
|
@ -1,5 +1,9 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@ -10,12 +14,12 @@
|
||||
|
||||
#include "point.hpp"
|
||||
|
||||
namespace nostalgia::geo {
|
||||
namespace ox {
|
||||
|
||||
class Bounds {
|
||||
|
||||
public:
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.geo.Bounds";
|
||||
static constexpr auto TypeName = "net.drinkingtea.ox.Bounds";
|
||||
static constexpr auto TypeVersion = 1;
|
||||
int x = 0;
|
||||
int y = 0;
|
@ -1,5 +1,9 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@ -7,11 +11,11 @@
|
||||
#include <ox/model/def.hpp>
|
||||
#include <ox/std/error.hpp>
|
||||
|
||||
namespace nostalgia::geo {
|
||||
namespace ox {
|
||||
|
||||
class Point {
|
||||
public:
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.geo.Point";
|
||||
static constexpr auto TypeName = "net.drinkingtea.ox.Point";
|
||||
static constexpr auto TypeVersion = 1;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
@ -20,22 +24,22 @@ class Point {
|
||||
|
||||
constexpr Point(int x, int y) noexcept;
|
||||
|
||||
constexpr Point operator+(const geo::Point &p) const noexcept;
|
||||
constexpr Point operator+(const Point &p) const noexcept;
|
||||
|
||||
constexpr Point operator-(const geo::Point &p) const noexcept;
|
||||
constexpr Point operator-(const Point &p) const noexcept;
|
||||
|
||||
constexpr Point operator*(const geo::Point &p) const noexcept;
|
||||
constexpr Point operator*(const Point &p) const noexcept;
|
||||
|
||||
constexpr Point operator/(const geo::Point &p) const noexcept;
|
||||
constexpr Point operator/(const Point &p) const noexcept;
|
||||
|
||||
|
||||
constexpr Point operator+=(const geo::Point &p) noexcept;
|
||||
constexpr Point operator+=(const Point &p) noexcept;
|
||||
|
||||
constexpr Point operator-=(const geo::Point &p) noexcept;
|
||||
constexpr Point operator-=(const Point &p) noexcept;
|
||||
|
||||
constexpr Point operator*=(const geo::Point &p) noexcept;
|
||||
constexpr Point operator*=(const Point &p) noexcept;
|
||||
|
||||
constexpr Point operator/=(const geo::Point &p) noexcept;
|
||||
constexpr Point operator/=(const Point &p) noexcept;
|
||||
|
||||
|
||||
constexpr Point operator+(int i) const noexcept;
|
||||
@ -67,53 +71,53 @@ constexpr Point::Point(int x, int y) noexcept {
|
||||
this->y = y;
|
||||
}
|
||||
|
||||
constexpr Point Point::operator+(const geo::Point &p) const noexcept {
|
||||
constexpr Point Point::operator+(const Point &p) const noexcept {
|
||||
auto out = *this;
|
||||
out.x += p.x;
|
||||
out.y += p.y;
|
||||
return out;
|
||||
}
|
||||
|
||||
constexpr Point Point::operator-(const geo::Point &p) const noexcept {
|
||||
constexpr Point Point::operator-(const Point &p) const noexcept {
|
||||
auto out = *this;
|
||||
out.x -= p.x;
|
||||
out.y -= p.y;
|
||||
return out;
|
||||
}
|
||||
|
||||
constexpr Point Point::operator*(const geo::Point &p) const noexcept {
|
||||
constexpr Point Point::operator*(const Point &p) const noexcept {
|
||||
auto out = *this;
|
||||
out.x *= p.x;
|
||||
out.y *= p.y;
|
||||
return out;
|
||||
}
|
||||
|
||||
constexpr Point Point::operator/(const geo::Point &p) const noexcept {
|
||||
constexpr Point Point::operator/(const Point &p) const noexcept {
|
||||
auto out = *this;
|
||||
out.x /= p.x;
|
||||
out.y /= p.y;
|
||||
return out;
|
||||
}
|
||||
|
||||
constexpr Point Point::operator+=(const geo::Point &p) noexcept {
|
||||
constexpr Point Point::operator+=(const Point &p) noexcept {
|
||||
x += p.x;
|
||||
y += p.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr Point Point::operator-=(const geo::Point &p) noexcept {
|
||||
constexpr Point Point::operator-=(const Point &p) noexcept {
|
||||
x -= p.x;
|
||||
y -= p.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr Point Point::operator*=(const geo::Point &p) noexcept {
|
||||
constexpr Point Point::operator*=(const Point &p) noexcept {
|
||||
x *= p.x;
|
||||
y *= p.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr Point Point::operator/=(const geo::Point &p) noexcept {
|
||||
constexpr Point Point::operator/=(const Point &p) noexcept {
|
||||
x /= p.x;
|
||||
y /= p.y;
|
||||
return *this;
|
@ -1,16 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/std/error.hpp>
|
||||
|
||||
namespace nostalgia::geo {
|
||||
namespace ox {
|
||||
|
||||
class Size {
|
||||
public:
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.geo.Size";
|
||||
static constexpr auto TypeName = "net.drinkingtea.ox.Size";
|
||||
static constexpr auto TypeVersion = 1;
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
@ -19,22 +23,22 @@ class Size {
|
||||
|
||||
constexpr Size(int width, int height) noexcept;
|
||||
|
||||
constexpr Size operator+(geo::Size p) const noexcept;
|
||||
constexpr Size operator+(Size p) const noexcept;
|
||||
|
||||
constexpr Size operator-(geo::Size p) const noexcept;
|
||||
constexpr Size operator-(Size p) const noexcept;
|
||||
|
||||
constexpr Size operator*(geo::Size p) const noexcept;
|
||||
constexpr Size operator*(Size p) const noexcept;
|
||||
|
||||
constexpr Size operator/(geo::Size p) const noexcept;
|
||||
constexpr Size operator/(Size p) const noexcept;
|
||||
|
||||
|
||||
constexpr Size operator+=(geo::Size p) noexcept;
|
||||
constexpr Size operator+=(Size p) noexcept;
|
||||
|
||||
constexpr Size operator-=(geo::Size p) noexcept;
|
||||
constexpr Size operator-=(Size p) noexcept;
|
||||
|
||||
constexpr Size operator*=(geo::Size p) noexcept;
|
||||
constexpr Size operator*=(Size p) noexcept;
|
||||
|
||||
constexpr Size operator/=(geo::Size p) noexcept;
|
||||
constexpr Size operator/=(Size p) noexcept;
|
||||
|
||||
|
||||
constexpr Size operator+(int i) const noexcept;
|
||||
@ -66,51 +70,51 @@ constexpr Size::Size(int width, int height) noexcept {
|
||||
this->height = height;
|
||||
}
|
||||
|
||||
constexpr Size Size::operator+(geo::Size p) const noexcept {
|
||||
constexpr Size Size::operator+(Size p) const noexcept {
|
||||
p.width += width;
|
||||
p.height += height;
|
||||
return p;
|
||||
}
|
||||
|
||||
constexpr Size Size::operator-(geo::Size p) const noexcept {
|
||||
constexpr Size Size::operator-(Size p) const noexcept {
|
||||
auto out = *this;
|
||||
out.width -= p.width;
|
||||
out.height -= p.height;
|
||||
return out;
|
||||
}
|
||||
|
||||
constexpr Size Size::operator*(geo::Size p) const noexcept {
|
||||
constexpr Size Size::operator*(Size p) const noexcept {
|
||||
p.width *= width;
|
||||
p.height *= height;
|
||||
return p;
|
||||
}
|
||||
|
||||
constexpr Size Size::operator/(geo::Size p) const noexcept {
|
||||
constexpr Size Size::operator/(Size p) const noexcept {
|
||||
auto out = *this;
|
||||
out.width /= p.width;
|
||||
out.height /= p.height;
|
||||
return out;
|
||||
}
|
||||
|
||||
constexpr Size Size::operator+=(geo::Size p) noexcept {
|
||||
constexpr Size Size::operator+=(Size p) noexcept {
|
||||
width += p.width;
|
||||
height += p.height;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr Size Size::operator-=(geo::Size p) noexcept {
|
||||
constexpr Size Size::operator-=(Size p) noexcept {
|
||||
width -= p.width;
|
||||
height -= p.height;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr Size Size::operator*=(geo::Size p) noexcept {
|
||||
constexpr Size Size::operator*=(Size p) noexcept {
|
||||
width *= p.width;
|
||||
height *= p.height;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr Size Size::operator/=(geo::Size p) noexcept {
|
||||
constexpr Size Size::operator/=(Size p) noexcept {
|
||||
width /= p.width;
|
||||
height /= p.height;
|
||||
return *this;
|
6
deps/ox/src/ox/std/std.hpp
vendored
6
deps/ox/src/ox/std/std.hpp
vendored
@ -11,11 +11,12 @@
|
||||
#include "array.hpp"
|
||||
#include "assert.hpp"
|
||||
#include "bit.hpp"
|
||||
#include "bounds.hpp"
|
||||
#include "bstring.hpp"
|
||||
#include "byteswap.hpp"
|
||||
#include "concepts.hpp"
|
||||
#include "defer.hpp"
|
||||
#include "def.hpp"
|
||||
#include "defer.hpp"
|
||||
#include "defines.hpp"
|
||||
#include "error.hpp"
|
||||
#include "fmt.hpp"
|
||||
@ -28,9 +29,11 @@
|
||||
#include "memory.hpp"
|
||||
#include "new.hpp"
|
||||
#include "optional.hpp"
|
||||
#include "point.hpp"
|
||||
#include "random.hpp"
|
||||
#include "realstd.hpp"
|
||||
#include "serialize.hpp"
|
||||
#include "size.hpp"
|
||||
#include "stacktrace.hpp"
|
||||
#include "stddef.hpp"
|
||||
#include "string.hpp"
|
||||
@ -43,4 +46,5 @@
|
||||
#include "typetraits.hpp"
|
||||
#include "units.hpp"
|
||||
#include "uuid.hpp"
|
||||
#include "vec.hpp"
|
||||
#include "vector.hpp"
|
||||
|
20
deps/ox/src/ox/std/vec.cpp
vendored
Normal file
20
deps/ox/src/ox/std/vec.cpp
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <ox/std/defines.hpp>
|
||||
|
||||
#include "vec.hpp"
|
||||
|
||||
namespace ox {
|
||||
|
||||
static_assert([] {
|
||||
Vec2 v(1, 2);
|
||||
return v.x == 1 && v.y == 2 && v[0] == 1 && v[1] == 2 && v.size() == 2;
|
||||
}());
|
||||
|
||||
}
|
@ -1,5 +1,9 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2015 - 2023 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@ -17,7 +21,7 @@
|
||||
#include <ox/std/math.hpp>
|
||||
#include <ox/std/types.hpp>
|
||||
|
||||
namespace nostalgia::geo {
|
||||
namespace ox {
|
||||
|
||||
template<typename T>
|
||||
struct Vec {
|
||||
@ -25,7 +29,7 @@ struct Vec {
|
||||
using value_type = T;
|
||||
using size_type = std::size_t;
|
||||
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.geo.Point";
|
||||
static constexpr auto TypeName = "net.drinkingtea.ox.Point";
|
||||
static constexpr auto TypeVersion = 1;
|
||||
|
||||
T x = 0;
|
@ -1,4 +1,4 @@
|
||||
include_directories(".")
|
||||
|
||||
add_subdirectory(keel)
|
||||
add_subdirectory(nostalgia)
|
||||
add_subdirectory(nostalgia)
|
@ -3,7 +3,6 @@
|
||||
|
||||
add_subdirectory(appmodules)
|
||||
add_subdirectory(core)
|
||||
add_subdirectory(geo)
|
||||
add_subdirectory(scene)
|
||||
|
||||
if(NOSTALGIA_BUILD_PLAYER)
|
||||
|
@ -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/std/types.hpp>
|
||||
#include <nostalgia/geo/point.hpp>
|
||||
#include <ox/std/point.hpp>
|
||||
|
||||
#include "context.hpp"
|
||||
|
||||
|
@ -7,17 +7,18 @@
|
||||
#include <ox/fs/fs.hpp>
|
||||
#include <ox/model/desctypes.hpp>
|
||||
#include <ox/std/buffer.hpp>
|
||||
#include <ox/std/size.hpp>
|
||||
|
||||
#include <keel/context.hpp>
|
||||
#include <nostalgia/geo/size.hpp>
|
||||
|
||||
#include "event.hpp"
|
||||
#include "input.hpp"
|
||||
|
||||
namespace nostalgia::core::gl {
|
||||
void setMainViewEnabled(core::Context *ctx, bool enabled) noexcept;
|
||||
void drawMainView(core::Context*) noexcept;
|
||||
void setRenderSize(core::Context*, int width, int height) noexcept;
|
||||
geo::Size getRenderSize(core::Context*) noexcept;
|
||||
ox::Size getRenderSize(core::Context*) noexcept;
|
||||
void clearRenderSize(core::Context *ctx) noexcept;
|
||||
}
|
||||
|
||||
@ -25,7 +26,7 @@ namespace nostalgia::core::renderer {
|
||||
ox::Error init(Context *ctx) noexcept;
|
||||
}
|
||||
|
||||
namespace nostalgia::geo {
|
||||
namespace ox {
|
||||
class Size;
|
||||
}
|
||||
|
||||
@ -66,7 +67,7 @@ class Context: public keel::Context {
|
||||
friend constexpr void setConstantRefresh(Context *ctx, bool) noexcept;
|
||||
friend bool bgStatus(Context *ctx, unsigned bg) noexcept;
|
||||
friend bool buttonDown(Context *ctx, Key) noexcept;
|
||||
friend geo::Size getScreenSize(Context *ctx) noexcept;
|
||||
friend ox::Size getScreenSize(Context *ctx) noexcept;
|
||||
friend int getScreenHeight(Context *ctx) noexcept;
|
||||
friend int getScreenWidth(Context *ctx) noexcept;
|
||||
friend ox::Error initGfx(Context *ctx) noexcept;
|
||||
@ -105,9 +106,10 @@ class Context: public keel::Context {
|
||||
unsigned spriteSize,
|
||||
unsigned flipX) noexcept;
|
||||
friend void hideSprite(Context *ctx, unsigned idx) noexcept;
|
||||
friend void gl::setMainViewEnabled(core::Context *ctx, bool enabled) noexcept;
|
||||
friend void gl::drawMainView(core::Context*) noexcept;
|
||||
friend void gl::setRenderSize(core::Context*, int width, int height) noexcept;
|
||||
friend geo::Size gl::getRenderSize(core::Context*) noexcept;
|
||||
friend ox::Size gl::getRenderSize(core::Context*) noexcept;
|
||||
friend void gl::clearRenderSize(core::Context *ctx) noexcept;
|
||||
|
||||
public:
|
||||
|
@ -7,9 +7,9 @@
|
||||
#include <ox/fs/fs.hpp>
|
||||
#include <ox/model/desctypes.hpp>
|
||||
#include <ox/std/buffer.hpp>
|
||||
#include <ox/std/size.hpp>
|
||||
|
||||
#include <keel/context.hpp>
|
||||
#include <nostalgia/geo/size.hpp>
|
||||
|
||||
#include <nostalgia/core/context.hpp>
|
||||
|
||||
|
@ -100,7 +100,7 @@ int getScreenHeight(Context*) noexcept {
|
||||
return 160;
|
||||
}
|
||||
|
||||
geo::Size getScreenSize(Context*) noexcept {
|
||||
ox::Size getScreenSize(Context*) noexcept {
|
||||
return {240, 160};
|
||||
}
|
||||
|
||||
|
@ -1,16 +1,15 @@
|
||||
/*
|
||||
* 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/std/array.hpp>
|
||||
#include <ox/std/point.hpp>
|
||||
#include <ox/std/size.hpp>
|
||||
#include <ox/std/types.hpp>
|
||||
#include <ox/model/def.hpp>
|
||||
|
||||
#include <nostalgia/geo/point.hpp>
|
||||
#include <nostalgia/geo/size.hpp>
|
||||
|
||||
#include "color.hpp"
|
||||
#include "context.hpp"
|
||||
#include "ptidxconv.hpp"
|
||||
@ -18,12 +17,6 @@
|
||||
|
||||
namespace nostalgia::core {
|
||||
|
||||
namespace gl {
|
||||
|
||||
void setMainViewEnabled(bool) noexcept;
|
||||
|
||||
}
|
||||
|
||||
extern ox::Array<char, 128> charMap;
|
||||
|
||||
class Drawer {
|
||||
@ -75,7 +68,7 @@ int getScreenWidth(Context *ctx) noexcept;
|
||||
int getScreenHeight(Context *ctx) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
geo::Size getScreenSize(Context *ctx) noexcept;
|
||||
ox::Size getScreenSize(Context *ctx) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
uint8_t bgStatus(Context *ctx) noexcept;
|
||||
|
@ -2,12 +2,10 @@
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include <keel/keel.hpp>
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <nostalgia/core/input.hpp>
|
||||
#include <nostalgia/core/opengl/gfx.hpp>
|
||||
|
||||
#include "core.hpp"
|
||||
|
@ -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 <glad/glad.h>
|
||||
@ -246,7 +246,7 @@ int getScreenHeight(Context *ctx) noexcept {
|
||||
return h;
|
||||
}
|
||||
|
||||
geo::Size getScreenSize(Context *ctx) noexcept {
|
||||
ox::Size getScreenSize(Context *ctx) noexcept {
|
||||
auto id = ctx->windowerData<GlfwImplData>();
|
||||
int w = 0, h = 0;
|
||||
glfwGetFramebufferSize(id->window, &w, &h);
|
||||
|
@ -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_impl_opengl3.h>
|
||||
|
||||
#include <ox/std/array.hpp>
|
||||
#include <ox/std/fmt.hpp>
|
||||
#include <ox/std/vec.hpp>
|
||||
|
||||
#include <nostalgia/geo/vec.hpp>
|
||||
#include <nostalgia/glutils/glutils.hpp>
|
||||
|
||||
#include <nostalgia/core/context.hpp>
|
||||
@ -18,16 +18,6 @@ namespace nostalgia::core {
|
||||
|
||||
void ImGui_Impl_NewFrame() noexcept;
|
||||
|
||||
namespace gl {
|
||||
|
||||
static bool mainViewEnabled = true;
|
||||
|
||||
void setMainViewEnabled(bool enabled) noexcept {
|
||||
mainViewEnabled = enabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace renderer {
|
||||
|
||||
constexpr uint64_t TileRows = 128;
|
||||
@ -73,11 +63,12 @@ struct GlImplData {
|
||||
glutils::GLProgram spriteShader;
|
||||
int64_t prevFpsCheckTime = 0;
|
||||
uint64_t draws = 0;
|
||||
bool mainViewEnabled = true;
|
||||
ox::Array<CBB, 4> cbbs;
|
||||
SpriteBlockset spriteBlocks;
|
||||
ox::Array<Sprite, 128> spriteStates;
|
||||
ox::Array<Background, 4> backgrounds;
|
||||
ox::Optional<geo::Size> renderSize;
|
||||
ox::Optional<ox::Size> renderSize;
|
||||
};
|
||||
|
||||
constexpr ox::StringView bgvshadTmpl = R"(
|
||||
@ -448,7 +439,7 @@ void draw(Context *ctx) noexcept {
|
||||
glClearColor(0, 0, 0, 1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
// render
|
||||
if (gl::mainViewEnabled) {
|
||||
if (id->mainViewEnabled) {
|
||||
gl::drawMainView(ctx);
|
||||
}
|
||||
for (const auto cd : ctx->drawers) {
|
||||
@ -487,7 +478,7 @@ void setSprite(Context *ctx,
|
||||
//oxTracef("nostalgia::core::gfx::gl", "setSprite(ctx, {}, {}, {}, {}, {}, {}, {})",
|
||||
// idx, x, y, tileIdx, spriteShape, spriteSize, flipX);
|
||||
// Tonc Table 8.4
|
||||
static constexpr ox::Array<geo::Vec<unsigned>, 12> dimensions{
|
||||
static constexpr ox::Array<ox::Vec<unsigned>, 12> dimensions{
|
||||
// col 0
|
||||
{1, 1}, // 0, 0
|
||||
{2, 2}, // 0, 1
|
||||
@ -557,6 +548,11 @@ void setTile(Context *ctx, unsigned bgIdx, int column, int row, uint8_t tile) no
|
||||
|
||||
namespace gl {
|
||||
|
||||
void setMainViewEnabled(core::Context *ctx, bool enabled) noexcept {
|
||||
const auto id = ctx->rendererData<renderer::GlImplData>();
|
||||
id->mainViewEnabled = enabled;
|
||||
}
|
||||
|
||||
void drawMainView(core::Context *ctx) noexcept {
|
||||
const auto id = ctx->rendererData<renderer::GlImplData>();
|
||||
renderer::drawBackgrounds(ctx, id);
|
||||
@ -575,7 +571,7 @@ void clearRenderSize(core::Context *ctx) noexcept {
|
||||
id->renderSize.reset();
|
||||
}
|
||||
|
||||
geo::Size getRenderSize(core::Context *ctx) noexcept {
|
||||
ox::Size getRenderSize(core::Context *ctx) noexcept {
|
||||
const auto id = ctx->rendererData<renderer::GlImplData>();
|
||||
if (id->renderSize.has_value()) {
|
||||
return id->renderSize.value();
|
||||
|
@ -5,11 +5,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <ox/std/array.hpp>
|
||||
#include <ox/std/point.hpp>
|
||||
#include <ox/std/size.hpp>
|
||||
#include <ox/std/types.hpp>
|
||||
#include <ox/model/def.hpp>
|
||||
|
||||
#include <nostalgia/geo/point.hpp>
|
||||
#include <nostalgia/geo/size.hpp>
|
||||
|
||||
#include "color.hpp"
|
||||
#include "context.hpp"
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
* 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 <nostalgia/geo/point.hpp>
|
||||
#include <ox/std/point.hpp>
|
||||
|
||||
#include "consts.hpp"
|
||||
|
||||
@ -22,12 +22,12 @@ constexpr std::size_t ptToIdx(int x, int y, int c) noexcept {
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr std::size_t ptToIdx(const geo::Point &pt, int c) noexcept {
|
||||
constexpr std::size_t ptToIdx(const ox::Point &pt, int c) noexcept {
|
||||
return ptToIdx(pt.x, pt.y, c * TileWidth);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr geo::Point idxToPt(int i, int c) noexcept {
|
||||
constexpr ox::Point idxToPt(int i, int c) noexcept {
|
||||
// prevent divide by zeros
|
||||
if (!c) {
|
||||
++c;
|
||||
@ -44,13 +44,13 @@ constexpr geo::Point idxToPt(int i, int c) noexcept {
|
||||
};
|
||||
}
|
||||
|
||||
static_assert(idxToPt(4, 1) == geo::Point{4, 0});
|
||||
static_assert(idxToPt(8, 1) == geo::Point{0, 1});
|
||||
static_assert(idxToPt(8, 2) == geo::Point{0, 1});
|
||||
static_assert(idxToPt(64, 2) == geo::Point{8, 0});
|
||||
static_assert(idxToPt(128, 2) == geo::Point{0, 8});
|
||||
static_assert(idxToPt(129, 2) == geo::Point{1, 8});
|
||||
static_assert(idxToPt(192, 2) == geo::Point{8, 8});
|
||||
static_assert(idxToPt(384, 8) == geo::Point{48, 0});
|
||||
static_assert(idxToPt(4, 1) == ox::Point{4, 0});
|
||||
static_assert(idxToPt(8, 1) == ox::Point{0, 1});
|
||||
static_assert(idxToPt(8, 2) == ox::Point{0, 1});
|
||||
static_assert(idxToPt(64, 2) == ox::Point{8, 0});
|
||||
static_assert(idxToPt(128, 2) == ox::Point{0, 8});
|
||||
static_assert(idxToPt(129, 2) == ox::Point{1, 8});
|
||||
static_assert(idxToPt(192, 2) == ox::Point{8, 8});
|
||||
static_assert(idxToPt(384, 8) == ox::Point{48, 0});
|
||||
|
||||
}
|
||||
|
@ -5,8 +5,8 @@
|
||||
#include <imgui.h>
|
||||
#include <lodepng.h>
|
||||
|
||||
#include <ox/std/point.hpp>
|
||||
#include <keel/media.hpp>
|
||||
#include <nostalgia/geo/point.hpp>
|
||||
|
||||
#include "tilesheeteditor-imgui.hpp"
|
||||
|
||||
@ -114,7 +114,7 @@ void TileSheetEditorImGui::keyStateChanged(core::Key key, bool down) {
|
||||
void TileSheetEditorImGui::draw(core::Context*) noexcept {
|
||||
const auto paneSize = ImGui::GetContentRegionAvail();
|
||||
const auto tileSheetParentSize = ImVec2(paneSize.x - m_palViewWidth, paneSize.y);
|
||||
const auto fbSize = geo::Vec2(tileSheetParentSize.x - 16, tileSheetParentSize.y - 16);
|
||||
const auto fbSize = ox::Vec2(tileSheetParentSize.x - 16, tileSheetParentSize.y - 16);
|
||||
ImGui::BeginChild("TileSheetView", tileSheetParentSize, true);
|
||||
{
|
||||
drawTileSheet(fbSize);
|
||||
@ -240,7 +240,7 @@ studio::UndoStack *TileSheetEditorImGui::undoStack() noexcept {
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
geo::Vec2 TileSheetEditorImGui::clickPos(const ImVec2 &winPos, geo::Vec2 clickPos) noexcept {
|
||||
ox::Vec2 TileSheetEditorImGui::clickPos(const ImVec2 &winPos, ox::Vec2 clickPos) noexcept {
|
||||
clickPos.x -= winPos.x + 10;
|
||||
clickPos.y -= winPos.y + 10;
|
||||
return clickPos;
|
||||
@ -274,9 +274,9 @@ void TileSheetEditorImGui::exportSubhseetToPng() noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
void TileSheetEditorImGui::drawTileSheet(const geo::Vec2 &fbSize) noexcept {
|
||||
void TileSheetEditorImGui::drawTileSheet(const ox::Vec2 &fbSize) noexcept {
|
||||
const auto winPos = ImGui::GetWindowPos();
|
||||
const auto fbSizei = geo::Size(static_cast<int>(fbSize.x), static_cast<int>(fbSize.y));
|
||||
const auto fbSizei = ox::Size(static_cast<int>(fbSize.x), static_cast<int>(fbSize.y));
|
||||
if (m_framebuffer.width != fbSizei.width || m_framebuffer.height != fbSizei.height) {
|
||||
glutils::resizeInitFrameBuffer(&m_framebuffer, fbSizei.width, fbSizei.height);
|
||||
m_tileSheetEditor.resizeView(fbSize);
|
||||
@ -296,7 +296,7 @@ void TileSheetEditorImGui::drawTileSheet(const geo::Vec2 &fbSize) noexcept {
|
||||
ImVec2(1, 0));
|
||||
// handle input, this must come after drawing
|
||||
const auto &io = ImGui::GetIO();
|
||||
const auto mousePos = geo::Vec2(io.MousePos);
|
||||
const auto mousePos = ox::Vec2(io.MousePos);
|
||||
if (ImGui::IsItemHovered()) {
|
||||
const auto wheel = io.MouseWheel;
|
||||
const auto wheelh = io.MouseWheelH;
|
||||
@ -326,7 +326,7 @@ void TileSheetEditorImGui::drawTileSheet(const geo::Vec2 &fbSize) noexcept {
|
||||
}
|
||||
}
|
||||
if (ImGui::BeginPopupContextItem("TileMenu", ImGuiPopupFlags_MouseButtonRight)) {
|
||||
const auto popupPos = geo::Vec2(ImGui::GetWindowPos());
|
||||
const auto popupPos = ox::Vec2(ImGui::GetWindowPos());
|
||||
if (ImGui::MenuItem("Insert Tile")) {
|
||||
m_tileSheetEditor.insertTile(fbSize, clickPos(winPos, popupPos));
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
/*
|
||||
* 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/def.hpp>
|
||||
#include <ox/std/vec.hpp>
|
||||
|
||||
#include <nostalgia/geo/vec.hpp>
|
||||
#include <nostalgia/glutils/glutils.hpp>
|
||||
#include <nostalgia/studio/studio.hpp>
|
||||
|
||||
@ -51,7 +51,7 @@ class TileSheetEditorImGui: public studio::BaseEditor {
|
||||
glutils::FrameBuffer m_framebuffer;
|
||||
TileSheetEditorView m_tileSheetEditor;
|
||||
float m_palViewWidth = 300;
|
||||
geo::Vec2 m_prevMouseDownPos;
|
||||
ox::Vec2 m_prevMouseDownPos;
|
||||
Tool m_tool = Tool::Draw;
|
||||
|
||||
public:
|
||||
@ -80,7 +80,7 @@ class TileSheetEditorImGui: public studio::BaseEditor {
|
||||
studio::UndoStack *undoStack() noexcept final;
|
||||
|
||||
[[nodiscard]]
|
||||
static geo::Vec2 clickPos(const ImVec2 &winPos, geo::Vec2 clickPos) noexcept;
|
||||
static ox::Vec2 clickPos(const ImVec2 &winPos, ox::Vec2 clickPos) noexcept;
|
||||
|
||||
protected:
|
||||
ox::Error saveItem() noexcept override;
|
||||
@ -112,7 +112,7 @@ class TileSheetEditorImGui: public studio::BaseEditor {
|
||||
[[nodiscard]]
|
||||
ox::String palettePath(const ox::String &palettePath) const;
|
||||
|
||||
void drawTileSheet(const geo::Vec2 &fbSize) noexcept;
|
||||
void drawTileSheet(const ox::Vec2 &fbSize) noexcept;
|
||||
|
||||
void drawPaletteSelector() noexcept;
|
||||
|
||||
|
@ -30,8 +30,8 @@ class TileSheetClipboard: public ClipboardObject<TileSheetClipboard> {
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.studio.TileSheetClipboard.Pixel";
|
||||
static constexpr auto TypeVersion = 1;
|
||||
uint16_t colorIdx = 0;
|
||||
geo::Point pt;
|
||||
constexpr Pixel(uint16_t pColorIdx, geo::Point pPt) noexcept {
|
||||
ox::Point pt;
|
||||
constexpr Pixel(uint16_t pColorIdx, ox::Point pPt) noexcept {
|
||||
colorIdx = pColorIdx;
|
||||
pt = pPt;
|
||||
}
|
||||
@ -40,7 +40,7 @@ class TileSheetClipboard: public ClipboardObject<TileSheetClipboard> {
|
||||
ox::Vector<Pixel> m_pixels;
|
||||
|
||||
public:
|
||||
constexpr void addPixel(const geo::Point &pt, uint16_t colorIdx) noexcept {
|
||||
constexpr void addPixel(const ox::Point &pt, uint16_t colorIdx) noexcept {
|
||||
m_pixels.emplace_back(colorIdx, pt);
|
||||
}
|
||||
|
||||
@ -189,7 +189,7 @@ class CutPasteCommand: public TileSheetCommand {
|
||||
ox::Vector<Change> m_changes;
|
||||
|
||||
public:
|
||||
constexpr CutPasteCommand(TileSheet *img, const TileSheet::SubSheetIdx &subSheetIdx, const geo::Point &dstStart, const geo::Point &dstEnd, const TileSheetClipboard &cb) noexcept {
|
||||
constexpr CutPasteCommand(TileSheet *img, const TileSheet::SubSheetIdx &subSheetIdx, const ox::Point &dstStart, const ox::Point &dstEnd, const TileSheetClipboard &cb) noexcept {
|
||||
m_img = img;
|
||||
m_subSheetIdx = subSheetIdx;
|
||||
const auto &subsheet = m_img->getSubSheet(subSheetIdx);
|
||||
@ -553,7 +553,7 @@ void TileSheetEditorModel::cut() {
|
||||
const auto s = activeSubSheet();
|
||||
for (int y = m_selectionBounds.y; y <= m_selectionBounds.y2(); ++y) {
|
||||
for (int x = m_selectionBounds.x; x <= m_selectionBounds.x2(); ++x) {
|
||||
auto pt = geo::Point(x, y);
|
||||
auto pt = ox::Point(x, y);
|
||||
const auto idx = s->idx(pt);
|
||||
const auto c = s->getPixel(m_img.bpp, idx);
|
||||
pt.x -= m_selectionBounds.x;
|
||||
@ -562,8 +562,8 @@ void TileSheetEditorModel::cut() {
|
||||
blankCb.addPixel(pt, 0);
|
||||
}
|
||||
}
|
||||
const auto pt1 = m_selectionOrigin == geo::Point(-1, -1) ? geo::Point(0, 0) : m_selectionOrigin;
|
||||
const auto pt2 = geo::Point(s->columns * TileWidth, s->rows * TileHeight);
|
||||
const auto pt1 = m_selectionOrigin == ox::Point(-1, -1) ? ox::Point(0, 0) : m_selectionOrigin;
|
||||
const auto pt2 = ox::Point(s->columns * TileWidth, s->rows * TileHeight);
|
||||
setClipboardObject(m_ctx, std::move(cb));
|
||||
pushCommand(ox::make<CutPasteCommand<CommandId::Cut>>(&m_img, m_activeSubsSheetIdx, pt1, pt2, blankCb));
|
||||
}
|
||||
@ -572,7 +572,7 @@ void TileSheetEditorModel::copy() {
|
||||
auto cb = ox::make_unique<TileSheetClipboard>();
|
||||
for (int y = m_selectionBounds.y; y <= m_selectionBounds.y2(); ++y) {
|
||||
for (int x = m_selectionBounds.x; x <= m_selectionBounds.x2(); ++x) {
|
||||
auto pt = geo::Point(x, y);
|
||||
auto pt = ox::Point(x, y);
|
||||
const auto s = activeSubSheet();
|
||||
const auto idx = s->idx(pt);
|
||||
const auto c = s->getPixel(m_img.bpp, idx);
|
||||
@ -592,8 +592,8 @@ void TileSheetEditorModel::paste() {
|
||||
return;
|
||||
}
|
||||
const auto s = activeSubSheet();
|
||||
const auto pt1 = m_selectionOrigin == geo::Point(-1, -1) ? geo::Point(0, 0) : m_selectionOrigin;
|
||||
const auto pt2 = geo::Point(s->columns * TileWidth, s->rows * TileHeight);
|
||||
const auto pt1 = m_selectionOrigin == ox::Point(-1, -1) ? ox::Point(0, 0) : m_selectionOrigin;
|
||||
const auto pt2 = ox::Point(s->columns * TileWidth, s->rows * TileHeight);
|
||||
pushCommand(ox::make<CutPasteCommand<CommandId::Paste>>(&m_img, m_activeSubsSheetIdx, pt1, pt2, *cb));
|
||||
}
|
||||
|
||||
@ -621,7 +621,7 @@ ox::Error TileSheetEditorModel::setPalette(const ox::String &path) noexcept {
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
void TileSheetEditorModel::drawCommand(const geo::Point &pt, std::size_t palIdx) noexcept {
|
||||
void TileSheetEditorModel::drawCommand(const ox::Point &pt, std::size_t palIdx) noexcept {
|
||||
const auto &activeSubSheet = m_img.getSubSheet(m_activeSubsSheetIdx);
|
||||
if (pt.x >= activeSubSheet.columns * TileWidth || pt.y >= activeSubSheet.rows * TileHeight) {
|
||||
return;
|
||||
@ -664,7 +664,7 @@ void TileSheetEditorModel::setActiveSubsheet(const TileSheet::SubSheetIdx &idx)
|
||||
this->activeSubsheetChanged.emit(m_activeSubsSheetIdx);
|
||||
}
|
||||
|
||||
void TileSheetEditorModel::fill(const geo::Point &pt, int palIdx) noexcept {
|
||||
void TileSheetEditorModel::fill(const ox::Point &pt, int palIdx) noexcept {
|
||||
const auto &s = m_img.getSubSheet(m_activeSubsSheetIdx);
|
||||
// build idx list
|
||||
ox::Array<bool, PixelsPerTile> updateMap = {};
|
||||
@ -689,7 +689,7 @@ void TileSheetEditorModel::fill(const geo::Point &pt, int palIdx) noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
void TileSheetEditorModel::select(const geo::Point &pt) noexcept {
|
||||
void TileSheetEditorModel::select(const ox::Point &pt) noexcept {
|
||||
if (!m_selectionOngoing) {
|
||||
m_selectionOrigin = pt;
|
||||
m_selectionOngoing = true;
|
||||
@ -755,16 +755,16 @@ bool TileSheetEditorModel::pixelSelected(std::size_t idx) const noexcept {
|
||||
return m_selectionBounds.contains(pt);
|
||||
}
|
||||
|
||||
void TileSheetEditorModel::getFillPixels(bool *pixels, const geo::Point &pt, int oldColor) const noexcept {
|
||||
void TileSheetEditorModel::getFillPixels(bool *pixels, const ox::Point &pt, int oldColor) const noexcept {
|
||||
const auto &activeSubSheet = *this->activeSubSheet();
|
||||
const auto tileIdx = [activeSubSheet](const geo::Point &pt) noexcept {
|
||||
const auto tileIdx = [activeSubSheet](const ox::Point &pt) noexcept {
|
||||
return ptToIdx(pt, activeSubSheet.columns) / PixelsPerTile;
|
||||
};
|
||||
// get points
|
||||
const auto leftPt = pt + geo::Point(-1, 0);
|
||||
const auto rightPt = pt + geo::Point(1, 0);
|
||||
const auto topPt = pt + geo::Point(0, -1);
|
||||
const auto bottomPt = pt + geo::Point(0, 1);
|
||||
const auto leftPt = pt + ox::Point(-1, 0);
|
||||
const auto rightPt = pt + ox::Point(1, 0);
|
||||
const auto topPt = pt + ox::Point(0, -1);
|
||||
const auto bottomPt = pt + ox::Point(0, 1);
|
||||
// calculate indices
|
||||
const auto idx = ptToIdx(pt, activeSubSheet.columns);
|
||||
const auto leftIdx = ptToIdx(leftPt, activeSubSheet.columns);
|
||||
|
@ -4,12 +4,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/std/bounds.hpp>
|
||||
#include <ox/std/point.hpp>
|
||||
#include <ox/std/trace.hpp>
|
||||
#include <ox/std/string.hpp>
|
||||
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <nostalgia/geo/bounds.hpp>
|
||||
#include <nostalgia/geo/point.hpp>
|
||||
#include <nostalgia/studio/studio.hpp>
|
||||
|
||||
namespace nostalgia::core {
|
||||
@ -30,8 +30,8 @@ class TileSheetEditorModel: public ox::SignalHandler {
|
||||
Context *m_ctx = nullptr;
|
||||
ox::String m_path;
|
||||
bool m_selectionOngoing = false;
|
||||
geo::Point m_selectionOrigin = {-1, -1};
|
||||
geo::Bounds m_selectionBounds = {{-1, -1}, {-1, -1}};
|
||||
ox::Point m_selectionOrigin = {-1, -1};
|
||||
ox::Bounds m_selectionBounds = {{-1, -1}, {-1, -1}};
|
||||
|
||||
public:
|
||||
TileSheetEditorModel(Context *ctx, ox::String path);
|
||||
@ -58,7 +58,7 @@ class TileSheetEditorModel: public ox::SignalHandler {
|
||||
|
||||
ox::Error setPalette(const ox::String &path) noexcept;
|
||||
|
||||
void drawCommand(const geo::Point &pt, std::size_t palIdx) noexcept;
|
||||
void drawCommand(const ox::Point &pt, std::size_t palIdx) noexcept;
|
||||
|
||||
void endDrawCommand() noexcept;
|
||||
|
||||
@ -91,9 +91,9 @@ class TileSheetEditorModel: public ox::SignalHandler {
|
||||
return m_activeSubsSheetIdx;
|
||||
}
|
||||
|
||||
void fill(const geo::Point &pt, int palIdx) noexcept;
|
||||
void fill(const ox::Point &pt, int palIdx) noexcept;
|
||||
|
||||
void select(const geo::Point &pt) noexcept;
|
||||
void select(const ox::Point &pt) noexcept;
|
||||
|
||||
void completeSelection() noexcept;
|
||||
|
||||
@ -116,7 +116,7 @@ class TileSheetEditorModel: public ox::SignalHandler {
|
||||
bool pixelSelected(std::size_t idx) const noexcept;
|
||||
|
||||
protected:
|
||||
void getFillPixels(bool *pixels, const geo::Point &pt, int oldColor) const noexcept;
|
||||
void getFillPixels(bool *pixels, const ox::Point &pt, int oldColor) const noexcept;
|
||||
|
||||
private:
|
||||
void pushCommand(studio::UndoCommand *cmd) noexcept;
|
||||
|
@ -2,9 +2,10 @@
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nostalgia/core/consts.hpp>
|
||||
#include <ox/std/point.hpp>
|
||||
#include <keel/media.hpp>
|
||||
#include <nostalgia/geo/point.hpp>
|
||||
|
||||
#include <nostalgia/core/consts.hpp>
|
||||
|
||||
#include "tilesheeteditorview.hpp"
|
||||
|
||||
@ -25,7 +26,7 @@ void TileSheetEditorView::draw() noexcept {
|
||||
m_pixelGridDrawer.draw(updated(), m_scrollOffset);
|
||||
}
|
||||
|
||||
void TileSheetEditorView::scrollV(const geo::Vec2 &paneSz, float wheel, bool zoomMod) noexcept {
|
||||
void TileSheetEditorView::scrollV(const ox::Vec2 &paneSz, float wheel, bool zoomMod) noexcept {
|
||||
const auto pixelSize = m_pixelsDrawer.pixelSize(paneSz);
|
||||
const ImVec2 sheetSize(pixelSize.x * static_cast<float>(m_model.activeSubSheet()->columns) * TileWidth,
|
||||
pixelSize.y * static_cast<float>(m_model.activeSubSheet()->rows) * TileHeight);
|
||||
@ -42,7 +43,7 @@ void TileSheetEditorView::scrollV(const geo::Vec2 &paneSz, float wheel, bool zoo
|
||||
m_scrollOffset.y = ox::clamp(m_scrollOffset.y, 0.f, sheetSize.y / 2);
|
||||
}
|
||||
|
||||
void TileSheetEditorView::scrollH(const geo::Vec2 &paneSz, float wheelh) noexcept {
|
||||
void TileSheetEditorView::scrollH(const ox::Vec2 &paneSz, float wheelh) noexcept {
|
||||
const auto pixelSize = m_pixelsDrawer.pixelSize(paneSz);
|
||||
const ImVec2 sheetSize(pixelSize.x * static_cast<float>(m_model.activeSubSheet()->columns) * TileWidth,
|
||||
pixelSize.y * static_cast<float>(m_model.activeSubSheet()->rows) * TileHeight);
|
||||
@ -50,31 +51,31 @@ void TileSheetEditorView::scrollH(const geo::Vec2 &paneSz, float wheelh) noexcep
|
||||
m_scrollOffset.x = ox::clamp(m_scrollOffset.x, -(sheetSize.x / 2), 0.f);
|
||||
}
|
||||
|
||||
void TileSheetEditorView::insertTile(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) noexcept {
|
||||
void TileSheetEditorView::insertTile(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept {
|
||||
const auto pt = clickPoint(paneSize, clickPos);
|
||||
const auto s = m_model.activeSubSheet();
|
||||
const auto tileIdx = ptToIdx(pt, s->columns) / PixelsPerTile;
|
||||
m_model.insertTiles(m_model.activeSubSheetIdx(), tileIdx, 1);
|
||||
}
|
||||
|
||||
void TileSheetEditorView::deleteTile(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) noexcept {
|
||||
void TileSheetEditorView::deleteTile(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept {
|
||||
const auto pt = clickPoint(paneSize, clickPos);
|
||||
const auto s = m_model.activeSubSheet();
|
||||
const auto tileIdx = ptToIdx(pt, s->columns) / PixelsPerTile;
|
||||
m_model.deleteTiles(m_model.activeSubSheetIdx(), tileIdx, 1);
|
||||
}
|
||||
|
||||
void TileSheetEditorView::clickDraw(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) noexcept {
|
||||
void TileSheetEditorView::clickDraw(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept {
|
||||
const auto pt = clickPoint(paneSize, clickPos);
|
||||
m_model.drawCommand(pt, m_palIdx);
|
||||
}
|
||||
|
||||
void TileSheetEditorView::clickSelect(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) noexcept {
|
||||
void TileSheetEditorView::clickSelect(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept {
|
||||
const auto pt = clickPoint(paneSize, clickPos);
|
||||
m_model.select(pt);
|
||||
}
|
||||
|
||||
void TileSheetEditorView::clickFill(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) noexcept {
|
||||
void TileSheetEditorView::clickFill(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept {
|
||||
const auto pt = clickPoint(paneSize, clickPos);
|
||||
m_model.fill(pt, static_cast<int>(m_palIdx));
|
||||
}
|
||||
@ -84,7 +85,7 @@ void TileSheetEditorView::releaseMouseButton() noexcept {
|
||||
m_model.completeSelection();
|
||||
}
|
||||
|
||||
void TileSheetEditorView::resizeView(const geo::Vec2 &sz) noexcept {
|
||||
void TileSheetEditorView::resizeView(const ox::Vec2 &sz) noexcept {
|
||||
m_viewSize = sz;
|
||||
initView();
|
||||
}
|
||||
@ -109,7 +110,7 @@ void TileSheetEditorView::initView() noexcept {
|
||||
m_pixelGridDrawer.initBufferSet(m_viewSize, *m_model.activeSubSheet());
|
||||
}
|
||||
|
||||
geo::Point TileSheetEditorView::clickPoint(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) const noexcept {
|
||||
ox::Point TileSheetEditorView::clickPoint(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) const noexcept {
|
||||
auto [x, y] = clickPos;
|
||||
const auto pixDrawSz = m_pixelsDrawer.pixelSize(paneSize);
|
||||
x /= paneSize.x;
|
||||
|
@ -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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/std/vec.hpp>
|
||||
#include <ox/model/def.hpp>
|
||||
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <nostalgia/geo/vec.hpp>
|
||||
#include <nostalgia/glutils/glutils.hpp>
|
||||
#include <nostalgia/studio/studio.hpp>
|
||||
|
||||
@ -42,10 +42,10 @@ class TileSheetEditorView: public ox::SignalHandler {
|
||||
TileSheetEditorModel m_model;
|
||||
TileSheetGrid m_pixelGridDrawer;
|
||||
TileSheetPixels m_pixelsDrawer;
|
||||
geo::Vec2 m_viewSize;
|
||||
ox::Vec2 m_viewSize;
|
||||
float m_pixelSizeMod = 1;
|
||||
bool m_updated = false;
|
||||
geo::Vec2 m_scrollOffset;
|
||||
ox::Vec2 m_scrollOffset;
|
||||
std::size_t m_palIdx = 0;
|
||||
|
||||
public:
|
||||
@ -55,23 +55,23 @@ class TileSheetEditorView: public ox::SignalHandler {
|
||||
|
||||
void draw() noexcept;
|
||||
|
||||
void insertTile(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) noexcept;
|
||||
void insertTile(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept;
|
||||
|
||||
void deleteTile(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) noexcept;
|
||||
void deleteTile(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept;
|
||||
|
||||
void clickDraw(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) noexcept;
|
||||
void clickDraw(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept;
|
||||
|
||||
void clickSelect(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) noexcept;
|
||||
void clickSelect(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept;
|
||||
|
||||
void clickFill(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) noexcept;
|
||||
void clickFill(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) noexcept;
|
||||
|
||||
void releaseMouseButton() noexcept;
|
||||
|
||||
void scrollV(const geo::Vec2 &paneSz, float wheel, bool zoomMod) noexcept;
|
||||
void scrollV(const ox::Vec2 &paneSz, float wheel, bool zoomMod) noexcept;
|
||||
|
||||
void scrollH(const geo::Vec2 &paneSz, float wheel) noexcept;
|
||||
void scrollH(const ox::Vec2 &paneSz, float wheel) noexcept;
|
||||
|
||||
void resizeView(const geo::Vec2 &sz) noexcept;
|
||||
void resizeView(const ox::Vec2 &sz) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr const TileSheet &img() const noexcept;
|
||||
@ -111,7 +111,7 @@ class TileSheetEditorView: public ox::SignalHandler {
|
||||
private:
|
||||
void initView() noexcept;
|
||||
|
||||
geo::Point clickPoint(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) const noexcept;
|
||||
ox::Point clickPoint(const ox::Vec2 &paneSize, const ox::Vec2 &clickPos) const noexcept;
|
||||
|
||||
ox::Error setActiveSubsheet(const TileSheet::SubSheetIdx &idx) 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 <nostalgia/core/consts.hpp>
|
||||
@ -18,7 +18,7 @@ ox::Error TileSheetGrid::buildShader() noexcept {
|
||||
return glutils::buildShaderProgram(pixelLineVshad, pixelLineFshad, pixelLineGshad).moveTo(&m_shader);
|
||||
}
|
||||
|
||||
void TileSheetGrid::draw(bool update, const geo::Vec2 &scroll) noexcept {
|
||||
void TileSheetGrid::draw(bool update, const ox::Vec2 &scroll) noexcept {
|
||||
glLineWidth(3 * m_pixelSizeMod * 0.5f);
|
||||
glUseProgram(m_shader);
|
||||
glBindVertexArray(m_bufferSet.vao);
|
||||
@ -32,7 +32,7 @@ void TileSheetGrid::draw(bool update, const geo::Vec2 &scroll) noexcept {
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
void TileSheetGrid::initBufferSet(const geo::Vec2 &paneSize, const TileSheet::SubSheet &subsheet) noexcept {
|
||||
void TileSheetGrid::initBufferSet(const ox::Vec2 &paneSize, const TileSheet::SubSheet &subsheet) noexcept {
|
||||
// vao
|
||||
m_bufferSet.vao = glutils::generateVertexArrayObject();
|
||||
glBindVertexArray(m_bufferSet.vao);
|
||||
@ -54,7 +54,7 @@ void TileSheetGrid::initBufferSet(const geo::Vec2 &paneSize, const TileSheet::Su
|
||||
reinterpret_cast<void*>(4 * sizeof(float)));
|
||||
}
|
||||
|
||||
void TileSheetGrid::setBufferObject(geo::Point pt1, geo::Point pt2, Color32 c, float *vbo, const geo::Vec2 &pixSize) noexcept {
|
||||
void TileSheetGrid::setBufferObject(ox::Point pt1, ox::Point pt2, Color32 c, float *vbo, const ox::Vec2 &pixSize) noexcept {
|
||||
const auto x1 = static_cast<float>(pt1.x) * pixSize.x - 1.f;
|
||||
const auto y1 = 1.f - static_cast<float>(pt1.y) * pixSize.y;
|
||||
const auto x2 = static_cast<float>(pt2.x) * pixSize.x - 1.f;
|
||||
@ -64,9 +64,9 @@ void TileSheetGrid::setBufferObject(geo::Point pt1, geo::Point pt2, Color32 c, f
|
||||
memcpy(vbo, vertices, sizeof(vertices));
|
||||
}
|
||||
|
||||
void TileSheetGrid::setBufferObjects(const geo::Vec2 &paneSize, const TileSheet::SubSheet &subsheet) noexcept {
|
||||
void TileSheetGrid::setBufferObjects(const ox::Vec2 &paneSize, const TileSheet::SubSheet &subsheet) noexcept {
|
||||
const auto pixSize = pixelSize(paneSize);
|
||||
const auto set = [&](unsigned i, geo::Point pt1, geo::Point pt2, Color32 c) {
|
||||
const auto set = [&](unsigned i, ox::Point pt1, ox::Point pt2, Color32 c) {
|
||||
const auto vbo = &m_bufferSet.vertices[i * VertexVboLength];
|
||||
setBufferObject(pt1, pt2, c, vbo, pixSize);
|
||||
};
|
||||
@ -100,7 +100,7 @@ void TileSheetGrid::setBufferObjects(const geo::Vec2 &paneSize, const TileSheet:
|
||||
}
|
||||
}
|
||||
|
||||
geo::Vec2 TileSheetGrid::pixelSize(const geo::Vec2 &paneSize) const noexcept {
|
||||
ox::Vec2 TileSheetGrid::pixelSize(const ox::Vec2 &paneSize) const noexcept {
|
||||
const auto [sw, sh] = paneSize;
|
||||
constexpr float ymod = 0.35f / 10.0f;
|
||||
const auto xmod = ymod * sh / sw;
|
||||
|
@ -1,12 +1,10 @@
|
||||
/*
|
||||
* 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 <nostalgia/core/gfx.hpp>
|
||||
#include <nostalgia/geo/point.hpp>
|
||||
#include <nostalgia/geo/vec.hpp>
|
||||
#include <nostalgia/glutils/glutils.hpp>
|
||||
#include <nostalgia/studio/studio.hpp>
|
||||
|
||||
@ -67,17 +65,17 @@ class TileSheetGrid {
|
||||
|
||||
ox::Error buildShader() noexcept;
|
||||
|
||||
void draw(bool update, const geo::Vec2 &scroll) noexcept;
|
||||
void draw(bool update, const ox::Vec2 &scroll) noexcept;
|
||||
|
||||
void initBufferSet(const geo::Vec2 &paneSize, const TileSheet::SubSheet &subsheet) noexcept;
|
||||
void initBufferSet(const ox::Vec2 &paneSize, const TileSheet::SubSheet &subsheet) noexcept;
|
||||
|
||||
private:
|
||||
static void setBufferObject(geo::Point pt1, geo::Point pt2, Color32 c, float *vbo, const geo::Vec2 &pixSize) noexcept;
|
||||
static void setBufferObject(ox::Point pt1, ox::Point pt2, Color32 c, float *vbo, const ox::Vec2 &pixSize) noexcept;
|
||||
|
||||
void setBufferObjects(const geo::Vec2 &paneSize, const TileSheet::SubSheet &subsheet) noexcept;
|
||||
void setBufferObjects(const ox::Vec2 &paneSize, const TileSheet::SubSheet &subsheet) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
geo::Vec2 pixelSize(const geo::Vec2 &paneSize) const noexcept;
|
||||
ox::Vec2 pixelSize(const ox::Vec2 &paneSize) const 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 <nostalgia/core/consts.hpp>
|
||||
@ -22,7 +22,7 @@ ox::Error TileSheetPixels::buildShader() noexcept {
|
||||
return glutils::buildShaderProgram(Vshad, Fshad).moveTo(&m_shader);
|
||||
}
|
||||
|
||||
void TileSheetPixels::draw(bool update, const geo::Vec2 &scroll) noexcept {
|
||||
void TileSheetPixels::draw(bool update, const ox::Vec2 &scroll) noexcept {
|
||||
glUseProgram(m_shader);
|
||||
glBindVertexArray(m_bufferSet.vao);
|
||||
if (update) {
|
||||
@ -35,7 +35,7 @@ void TileSheetPixels::draw(bool update, const geo::Vec2 &scroll) noexcept {
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
void TileSheetPixels::initBufferSet(geo::Vec2 const&paneSize) noexcept {
|
||||
void TileSheetPixels::initBufferSet(ox::Vec2 const&paneSize) noexcept {
|
||||
m_bufferSet.vao = glutils::generateVertexArrayObject();
|
||||
m_bufferSet.vbo = glutils::generateBuffer();
|
||||
m_bufferSet.ebo = glutils::generateBuffer();
|
||||
@ -50,14 +50,14 @@ void TileSheetPixels::initBufferSet(geo::Vec2 const&paneSize) noexcept {
|
||||
reinterpret_cast<void*>(2 * sizeof(float)));
|
||||
}
|
||||
|
||||
void TileSheetPixels::update(geo::Vec2 const&paneSize) noexcept {
|
||||
void TileSheetPixels::update(ox::Vec2 const&paneSize) noexcept {
|
||||
glBindVertexArray(m_bufferSet.vao);
|
||||
setBufferObjects(paneSize);
|
||||
glutils::sendVbo(m_bufferSet);
|
||||
glutils::sendEbo(m_bufferSet);
|
||||
}
|
||||
|
||||
geo::Vec2 TileSheetPixels::pixelSize(const geo::Vec2 &paneSize) const noexcept {
|
||||
ox::Vec2 TileSheetPixels::pixelSize(const ox::Vec2 &paneSize) const noexcept {
|
||||
const auto [sw, sh] = paneSize;
|
||||
constexpr float ymod = 0.35f / 10.0f;
|
||||
const auto xmod = ymod * sh / sw;
|
||||
@ -65,7 +65,7 @@ geo::Vec2 TileSheetPixels::pixelSize(const geo::Vec2 &paneSize) const noexcept {
|
||||
}
|
||||
|
||||
void TileSheetPixels::setPixelBufferObject(
|
||||
geo::Vec2 const&paneSize,
|
||||
ox::Vec2 const&paneSize,
|
||||
unsigned vertexRow,
|
||||
float x, float y,
|
||||
Color16 color,
|
||||
@ -92,7 +92,7 @@ void TileSheetPixels::setPixelBufferObject(
|
||||
memcpy(ebo, elms.data(), sizeof(elms));
|
||||
}
|
||||
|
||||
void TileSheetPixels::setBufferObjects(const geo::Vec2 &paneSize) noexcept {
|
||||
void TileSheetPixels::setBufferObjects(const ox::Vec2 &paneSize) noexcept {
|
||||
// set buffer lengths
|
||||
const auto subSheet = m_model->activeSubSheet();
|
||||
const auto pal = m_model->pal();
|
||||
|
@ -1,11 +1,12 @@
|
||||
/*
|
||||
* 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/std/vec.hpp>
|
||||
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <nostalgia/geo/vec.hpp>
|
||||
#include <nostalgia/glutils/glutils.hpp>
|
||||
#include <nostalgia/studio/studio.hpp>
|
||||
|
||||
@ -49,19 +50,19 @@ class TileSheetPixels {
|
||||
|
||||
ox::Error buildShader() noexcept;
|
||||
|
||||
void draw(bool update, const geo::Vec2 &scroll) noexcept;
|
||||
void draw(bool update, const ox::Vec2 &scroll) noexcept;
|
||||
|
||||
void initBufferSet(geo::Vec2 const&paneSize) noexcept;
|
||||
void initBufferSet(ox::Vec2 const&paneSize) noexcept;
|
||||
|
||||
void update(geo::Vec2 const&paneSize) noexcept;
|
||||
void update(ox::Vec2 const&paneSize) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
geo::Vec2 pixelSize(const geo::Vec2 &paneSize) const noexcept;
|
||||
ox::Vec2 pixelSize(const ox::Vec2 &paneSize) const noexcept;
|
||||
|
||||
private:
|
||||
void setPixelBufferObject(const geo::Vec2 &paneS, unsigned vertexRow, float x, float y, Color16 color, float *vbo, GLuint *ebo) const noexcept;
|
||||
void setPixelBufferObject(const ox::Vec2 &paneS, unsigned vertexRow, float x, float y, Color16 color, float *vbo, GLuint *ebo) const noexcept;
|
||||
|
||||
void setBufferObjects(const geo::Vec2 &paneS) noexcept;
|
||||
void setBufferObjects(const ox::Vec2 &paneS) noexcept;
|
||||
|
||||
};
|
||||
|
||||
|
@ -5,11 +5,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <ox/std/array.hpp>
|
||||
#include <ox/std/point.hpp>
|
||||
#include <ox/std/size.hpp>
|
||||
#include <ox/std/types.hpp>
|
||||
#include <ox/model/def.hpp>
|
||||
|
||||
#include <nostalgia/geo/point.hpp>
|
||||
#include <nostalgia/geo/size.hpp>
|
||||
|
||||
#include "color.hpp"
|
||||
#include "context.hpp"
|
||||
@ -122,7 +122,7 @@ struct TileSheet {
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr auto idx(const geo::Point &pt) const noexcept {
|
||||
constexpr auto idx(const ox::Point &pt) const noexcept {
|
||||
return ptToIdx(pt, columns);
|
||||
}
|
||||
|
||||
@ -130,13 +130,13 @@ struct TileSheet {
|
||||
* Reads all pixels of this sheet or its children into the given pixel list
|
||||
* @param pixels
|
||||
*/
|
||||
constexpr void readPixelsTo(ox::Vector<uint8_t> *pPixels, int8_t bpp) const noexcept {
|
||||
if (subsheets.size()) {
|
||||
constexpr void readPixelsTo(ox::Vector<uint8_t> *pPixels, int8_t pBpp) const noexcept {
|
||||
if (!subsheets.empty()) {
|
||||
for (auto &s: subsheets) {
|
||||
s.readPixelsTo(pPixels);
|
||||
}
|
||||
} else {
|
||||
if (bpp == 4) {
|
||||
if (pBpp == 4) {
|
||||
for (auto p: this->pixels) {
|
||||
pPixels->emplace_back(p & 0b1111);
|
||||
pPixels->emplace_back(p >> 4);
|
||||
@ -154,7 +154,7 @@ struct TileSheet {
|
||||
* @param pixels
|
||||
*/
|
||||
constexpr void readPixelsTo(ox::Vector<uint8_t> *pPixels) const noexcept {
|
||||
if (subsheets.size()) {
|
||||
if (!subsheets.empty()) {
|
||||
for (auto &s: subsheets) {
|
||||
s.readPixelsTo(pPixels);
|
||||
}
|
||||
@ -203,19 +203,19 @@ struct TileSheet {
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr auto getPixel4Bpp(const geo::Point &pt) const noexcept {
|
||||
constexpr auto getPixel4Bpp(const ox::Point &pt) const noexcept {
|
||||
const auto idx = ptToIdx(pt, columns);
|
||||
return getPixel4Bpp(idx);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr auto getPixel8Bpp(const geo::Point &pt) const noexcept {
|
||||
constexpr auto getPixel8Bpp(const ox::Point &pt) const noexcept {
|
||||
const auto idx = ptToIdx(pt, columns);
|
||||
return getPixel8Bpp(idx);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr auto getPixel(int8_t pBpp, const geo::Point &pt) const noexcept {
|
||||
constexpr auto getPixel(int8_t pBpp, const ox::Point &pt) const noexcept {
|
||||
const auto idx = ptToIdx(pt, columns);
|
||||
return getPixel(pBpp, idx);
|
||||
}
|
||||
@ -254,7 +254,7 @@ struct TileSheet {
|
||||
}
|
||||
}
|
||||
|
||||
constexpr void setPixel(int8_t pBpp, const geo::Point &pt, uint8_t palIdx) noexcept {
|
||||
constexpr void setPixel(int8_t pBpp, const ox::Point &pt, uint8_t palIdx) noexcept {
|
||||
const auto idx = ptToIdx(pt, columns);
|
||||
setPixel(pBpp, idx, palIdx);
|
||||
}
|
||||
@ -384,7 +384,7 @@ struct TileSheet {
|
||||
const auto currentIdx = pIdx[pIdxIt];
|
||||
if (pSubsheet->subsheets.size() <= currentIdx) {
|
||||
auto out = pIdx;
|
||||
if (pSubsheet->subsheets.size()) {
|
||||
if (!pSubsheet->subsheets.empty()) {
|
||||
out.back().value = pSubsheet->subsheets.size() - 1;
|
||||
} else {
|
||||
out.pop_back();
|
||||
@ -471,7 +471,7 @@ struct TileSheet {
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr auto getPixel4Bpp(
|
||||
const geo::Point &pt,
|
||||
const ox::Point &pt,
|
||||
const SubSheetIdx &subsheetIdx) const noexcept {
|
||||
oxAssert(bpp == 4, "TileSheet::getPixel4Bpp: wrong bpp");
|
||||
auto &s = this->getSubSheet(subsheetIdx);
|
||||
@ -481,7 +481,7 @@ struct TileSheet {
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr auto getPixel8Bpp(
|
||||
const geo::Point &pt,
|
||||
const ox::Point &pt,
|
||||
const SubSheetIdx &subsheetIdx) const noexcept {
|
||||
oxAssert(bpp == 8, "TileSheet::getPixel8Bpp: wrong bpp");
|
||||
auto &s = this->getSubSheet(subsheetIdx);
|
||||
|
@ -1,21 +0,0 @@
|
||||
|
||||
add_library(
|
||||
NostalgiaGeo OBJECT
|
||||
vec.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaGeo PUBLIC
|
||||
OxStd
|
||||
)
|
||||
|
||||
install(
|
||||
FILES
|
||||
bounds.hpp
|
||||
geo.hpp
|
||||
point.hpp
|
||||
size.hpp
|
||||
vec.hpp
|
||||
DESTINATION
|
||||
include/nostalgia/geo
|
||||
)
|
@ -1,9 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "bounds.hpp"
|
||||
#include "point.hpp"
|
||||
#include "size.hpp"
|
@ -1,16 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <ox/std/defines.hpp>
|
||||
|
||||
#include "vec.hpp"
|
||||
|
||||
namespace nostalgia::geo {
|
||||
|
||||
static_assert([] {
|
||||
Vec2 v(1, 2);
|
||||
return v.x == 1 && v.y == 2 && v[0] == 1 && v[1] == 2 && v.size() == 2;
|
||||
}());
|
||||
|
||||
}
|
@ -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 <ox/std/assert.hpp>
|
||||
@ -46,6 +46,13 @@ template struct GLObject<deleteVertexArray>;
|
||||
template struct GLObject<deleteProgram>;
|
||||
template struct GLObject<deleteShader>;
|
||||
|
||||
|
||||
void bind(const FrameBuffer &fb) noexcept {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fb);
|
||||
glViewport(0, 0, fb.width, fb.height);
|
||||
}
|
||||
|
||||
|
||||
static ox::Result<GLShader> buildShader(GLuint shaderType, const GLchar *src, ox::CRStringView shaderName) noexcept {
|
||||
GLShader shader(glCreateShader(shaderType));
|
||||
glShaderSource(shader, 1, &src, nullptr);
|
||||
|
@ -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
|
||||
@ -134,6 +134,8 @@ struct FrameBuffer {
|
||||
}
|
||||
};
|
||||
|
||||
void bind(const FrameBuffer &fb) noexcept;
|
||||
|
||||
|
||||
ox::Result<GLProgram> buildShaderProgram(const GLchar *vert, const GLchar *frag, const GLchar *geo = nullptr) noexcept;
|
||||
|
||||
|
@ -10,7 +10,6 @@ add_library(
|
||||
target_link_libraries(
|
||||
NostalgiaScene PUBLIC
|
||||
NostalgiaCore
|
||||
NostalgiaGeo
|
||||
)
|
||||
|
||||
install(
|
||||
|
@ -6,11 +6,11 @@
|
||||
|
||||
#include <ox/fs/fs.hpp>
|
||||
#include <ox/std/error.hpp>
|
||||
#include <ox/std/size.hpp>
|
||||
#include <ox/std/types.hpp>
|
||||
#include <ox/std/vector.hpp>
|
||||
|
||||
#include <nostalgia/core/tilesheet.hpp>
|
||||
#include <nostalgia/geo/size.hpp>
|
||||
|
||||
namespace nostalgia::scene {
|
||||
|
||||
@ -78,7 +78,7 @@ struct SceneDoc {
|
||||
TileMap tiles;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr geo::Size size(std::size_t layerIdx) const noexcept {
|
||||
constexpr ox::Size size(std::size_t layerIdx) const noexcept {
|
||||
const auto &layer = this->tiles[layerIdx];
|
||||
const auto rowCnt = static_cast<int>(layer.size());
|
||||
if (!rowCnt) {
|
||||
@ -170,7 +170,7 @@ struct SceneStatic {
|
||||
constexpr Tile tile(std::size_t i) noexcept {
|
||||
return {tileMapIdx[i], tileType[i], layerAttachments[i]};
|
||||
}
|
||||
constexpr auto setDimensions(geo::Size dim) noexcept {
|
||||
constexpr auto setDimensions(ox::Size dim) noexcept {
|
||||
columns = dim.width;
|
||||
rows = dim.height;
|
||||
const auto tileCnt = static_cast<unsigned>(columns * rows);
|
||||
|
@ -14,11 +14,7 @@ ox::Vector<studio::EditorMaker> StudioModule::editors(core::Context *ctx) noexce
|
||||
{
|
||||
{"nscn"},
|
||||
[ctx](ox::CRStringView path) -> ox::Result<studio::BaseEditor*> {
|
||||
try {
|
||||
return ox::make<SceneEditorImGui>(ctx, path);
|
||||
} catch (const ox::Exception &ex) {
|
||||
return ex.toError();
|
||||
}
|
||||
return ox::makeCatch<SceneEditorImGui>(ctx, path);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
@ -4,9 +4,9 @@
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
#include <keel/media.hpp>
|
||||
#include <ox/std/memory.hpp>
|
||||
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
|
||||
#include "sceneeditor-imgui.hpp"
|
||||
|
||||
@ -32,7 +32,7 @@ ox::CRString SceneEditorImGui::itemDisplayName() const noexcept {
|
||||
|
||||
void SceneEditorImGui::draw(core::Context*) noexcept {
|
||||
const auto paneSize = ImGui::GetContentRegionAvail();
|
||||
const geo::Size fbSize{
|
||||
const ox::Size fbSize{
|
||||
static_cast<int>(paneSize.x),
|
||||
static_cast<int>(paneSize.y)};
|
||||
m_view.draw(fbSize.width, fbSize.height);
|
||||
@ -46,7 +46,7 @@ void SceneEditorImGui::draw(core::Context*) noexcept {
|
||||
}
|
||||
|
||||
void SceneEditorImGui::onActivated() noexcept {
|
||||
m_view.setupScene();
|
||||
oxLogError(m_view.setupScene());
|
||||
}
|
||||
|
||||
ox::Error SceneEditorImGui::saveItem() noexcept {
|
||||
|
@ -2,31 +2,29 @@
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
|
||||
#include "sceneeditorview.hpp"
|
||||
|
||||
namespace nostalgia::scene {
|
||||
|
||||
SceneEditorView::SceneEditorView(core::Context *ctx, const SceneStatic &sceneStatic) noexcept:
|
||||
m_ctx(*ctx),
|
||||
m_ctx(ctx),
|
||||
m_sceneStatic(sceneStatic),
|
||||
m_scene(m_sceneStatic) {
|
||||
}
|
||||
|
||||
void SceneEditorView::setupScene() noexcept {
|
||||
oxIgnoreError(m_scene.setupDisplay(&m_ctx));
|
||||
ox::Error SceneEditorView::setupScene() noexcept {
|
||||
return m_scene.setupDisplay(m_ctx);
|
||||
}
|
||||
|
||||
void SceneEditorView::draw(int width, int height) noexcept {
|
||||
if (width != m_frameBuffer.width || height != m_frameBuffer.height) {
|
||||
glutils::resizeInitFrameBuffer(&m_frameBuffer, width, height);
|
||||
core::gl::setRenderSize(&m_ctx, width, height);
|
||||
oxIgnoreError(m_scene.setupDisplay(&m_ctx));
|
||||
}
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_frameBuffer);
|
||||
glViewport(0, 0, m_frameBuffer.width, m_frameBuffer.height);
|
||||
// draw begin
|
||||
core::gl::drawMainView(&m_ctx);
|
||||
// draw end
|
||||
glutils::bind(m_frameBuffer);
|
||||
core::gl::setRenderSize(m_ctx, width, height);
|
||||
core::gl::drawMainView(m_ctx);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ namespace nostalgia::scene {
|
||||
class SceneEditorView {
|
||||
|
||||
private:
|
||||
core::Context &m_ctx;
|
||||
core::Context *const m_ctx = nullptr;
|
||||
const SceneStatic &m_sceneStatic;
|
||||
Scene m_scene;
|
||||
glutils::FrameBuffer m_frameBuffer;
|
||||
@ -21,7 +21,7 @@ class SceneEditorView {
|
||||
public:
|
||||
SceneEditorView(core::Context *ctx, const SceneStatic &sceneStatic) noexcept;
|
||||
|
||||
void setupScene() noexcept;
|
||||
ox::Error setupScene() noexcept;
|
||||
|
||||
void draw(int width, int height) 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/event/signal.hpp>
|
||||
#include <ox/std/string.hpp>
|
||||
#include <ox/std/vec.hpp>
|
||||
|
||||
#include <nostalgia/geo/vec.hpp>
|
||||
#include <nostalgia/core/context.hpp>
|
||||
|
||||
#include "imguiuitl.hpp"
|
||||
@ -17,7 +17,7 @@ namespace nostalgia::studio {
|
||||
|
||||
class Popup {
|
||||
private:
|
||||
geo::Vec2 m_size;
|
||||
ox::Vec2 m_size;
|
||||
ox::String m_title;
|
||||
public:
|
||||
// emits path parameter
|
||||
@ -35,7 +35,7 @@ class Popup {
|
||||
virtual void draw(core::Context *ctx) noexcept = 0;
|
||||
|
||||
protected:
|
||||
constexpr void setSize(geo::Size sz) noexcept {
|
||||
constexpr void setSize(ox::Size sz) noexcept {
|
||||
m_size = {static_cast<float>(sz.width), static_cast<float>(sz.height)};
|
||||
}
|
||||
|
||||
@ -59,4 +59,4 @@ class Popup {
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ static ox::Error run(ox::UniquePtr<ox::FileSystem> fs) noexcept {
|
||||
core::setUpdateHandler(ctx.get(), updateHandler);
|
||||
core::setKeyEventHandler(ctx.get(), keyEventHandler);
|
||||
core::setConstantRefresh(ctx.get(), false);
|
||||
core::gl::setMainViewEnabled(false);
|
||||
core::gl::setMainViewEnabled(ctx.get(), false);
|
||||
studio::StudioContext studioCtx;
|
||||
core::setApplicationData(ctx.get(), &studioCtx);
|
||||
StudioUI ui(ctx.get());
|
||||
|
@ -1,13 +1,11 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
#include <nostalgia/geo/bounds.hpp>
|
||||
|
||||
#include "projectexplorer.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
|
@ -45,7 +45,7 @@ StudioUI::StudioUI(core::Context *ctx) noexcept {
|
||||
for (const auto &f : config.openFiles) {
|
||||
auto openFileErr = openFileActiveTab(f, config.activeTabItemName == f);
|
||||
if (openFileErr) {
|
||||
oxErrorf("Could not open editor: {}\n", toStr(openFileErr));
|
||||
oxErrorf("\nCould not open editor for file:\n\t{}\nReason:\n\t{}\n", f, toStr(openFileErr));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user