Merge commit '2da3579818c8cbb50ad4b346f5fbc9e5304e682f'
This commit is contained in:
commit
62cbe76c1c
36
deps/nostalgia/deps/ox/src/ox/std/conv.hpp
vendored
36
deps/nostalgia/deps/ox/src/ox/std/conv.hpp
vendored
@ -14,32 +14,20 @@
|
||||
|
||||
namespace ox {
|
||||
|
||||
constexpr Vec2::operator Point() const noexcept {
|
||||
return {
|
||||
static_cast<int32_t>(x),
|
||||
static_cast<int32_t>(y),
|
||||
};
|
||||
}
|
||||
constexpr Point::Point(Vec2 const&pt) noexcept:
|
||||
x(static_cast<int32_t>(pt.x)),
|
||||
y(static_cast<int32_t>(pt.y)) {}
|
||||
|
||||
constexpr Vec2::operator Size() const noexcept {
|
||||
return {
|
||||
static_cast<int32_t>(x),
|
||||
static_cast<int32_t>(y),
|
||||
};
|
||||
}
|
||||
constexpr Size::Size(Vec2 const&pt) noexcept:
|
||||
width(static_cast<int32_t>(pt.x)),
|
||||
height(static_cast<int32_t>(pt.y)) {}
|
||||
|
||||
constexpr Point::operator Vec2() const noexcept {
|
||||
return {
|
||||
static_cast<float>(x),
|
||||
static_cast<float>(y),
|
||||
};
|
||||
}
|
||||
constexpr Vec2::Vec2(Point const&pt) noexcept:
|
||||
x(static_cast<float>(pt.x)),
|
||||
y(static_cast<float>(pt.y)) {}
|
||||
|
||||
constexpr Size::operator Vec2() const noexcept {
|
||||
return {
|
||||
static_cast<float>(width),
|
||||
static_cast<float>(height),
|
||||
};
|
||||
}
|
||||
constexpr Vec2::Vec2(Size const&pt) noexcept:
|
||||
x(static_cast<float>(pt.width)),
|
||||
y(static_cast<float>(pt.height)) {}
|
||||
|
||||
}
|
2
deps/nostalgia/deps/ox/src/ox/std/point.hpp
vendored
2
deps/nostalgia/deps/ox/src/ox/std/point.hpp
vendored
@ -24,6 +24,8 @@ class Point {
|
||||
|
||||
constexpr Point(int x, int y) noexcept;
|
||||
|
||||
explicit constexpr Point(class Vec2 const&pt) noexcept;
|
||||
|
||||
constexpr Point operator+(const Point &p) const noexcept;
|
||||
|
||||
constexpr Point operator-(const Point &p) const noexcept;
|
||||
|
2
deps/nostalgia/deps/ox/src/ox/std/size.hpp
vendored
2
deps/nostalgia/deps/ox/src/ox/std/size.hpp
vendored
@ -24,6 +24,8 @@ class Size {
|
||||
|
||||
constexpr Size(int width, int height) noexcept;
|
||||
|
||||
explicit constexpr Size(class Vec2 const&pt) noexcept;
|
||||
|
||||
constexpr Size operator+(Size p) const noexcept;
|
||||
|
||||
constexpr Size operator-(Size p) const noexcept;
|
||||
|
4
deps/nostalgia/deps/ox/src/ox/std/vec.hpp
vendored
4
deps/nostalgia/deps/ox/src/ox/std/vec.hpp
vendored
@ -142,6 +142,10 @@ class Vec2 {
|
||||
|
||||
constexpr Vec2() noexcept = default;
|
||||
|
||||
explicit constexpr Vec2(class Point const&pt) noexcept;
|
||||
|
||||
explicit constexpr Vec2(class Size const&pt) noexcept;
|
||||
|
||||
template<typename ...Args>
|
||||
constexpr Vec2(float pX, float pY) noexcept: x(pX), y(pY) {
|
||||
}
|
||||
|
12
deps/nostalgia/developer-handbook.md
vendored
12
deps/nostalgia/developer-handbook.md
vendored
@ -265,7 +265,7 @@ ox::Error engineCode() noexcept {
|
||||
auto [val, err] = foo(1);
|
||||
oxReturnError(err);
|
||||
doStuff(val);
|
||||
return OxError(0);
|
||||
return {};
|
||||
}
|
||||
|
||||
void anyCode() {
|
||||
@ -288,7 +288,7 @@ ox::Error engineCode() noexcept {
|
||||
auto valerr = foo(1);
|
||||
oxReturnError(valerr);
|
||||
doStuff(valerr.value);
|
||||
return OxError(0);
|
||||
return {};
|
||||
}
|
||||
```
|
||||
|
||||
@ -426,7 +426,7 @@ constexpr ox::Error model(T *h, ox::CommonPtrWith<NostalgiaPalette> auto *pal) n
|
||||
// it is also possible to provide the type name and type version as function arguments
|
||||
//h->setTypeInfo("net.drinkingtea.nostalgia.core.NostalgiaPalette", 1);
|
||||
oxReturnError(h->field("colors", &pal->colors));
|
||||
return OxError(0);
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@ -438,7 +438,7 @@ constexpr ox::Error model(T *h, ox::CommonPtrWith<NostalgiaGraphic> auto *ng) no
|
||||
oxReturnError(h->field("defaultPalette", &ng->defaultPalette));
|
||||
oxReturnError(h->field("pal", &ng->pal));
|
||||
oxReturnError(h->field("pixels", &ng->pixels));
|
||||
return OxError(0);
|
||||
return {};
|
||||
}
|
||||
```
|
||||
|
||||
@ -475,7 +475,7 @@ constexpr Error model(T *h, ox::CommonPtrWith<FileAddress::Data> auto *obj) noex
|
||||
oxReturnError(h->fieldCString("path", &obj->path));
|
||||
oxReturnError(h->fieldCString("constPath", &obj->path));
|
||||
oxReturnError(h->field("inode", &obj->inode));
|
||||
return OxError(0);
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@ -492,7 +492,7 @@ constexpr Error model(T *io, ox::CommonPtrWith<FileAddress> auto *fa) noexcept {
|
||||
fa->m_type = static_cast<FileAddressType>(type);
|
||||
oxReturnError(io->field("data", UnionView(&fa->m_data, static_cast<int>(fa->m_type))));
|
||||
}
|
||||
return OxError(0);
|
||||
return {};
|
||||
}
|
||||
|
||||
```
|
||||
|
@ -39,7 +39,7 @@ ox::Result<T> readConfig(keel::Context &ctx, ox::CRStringView name) noexcept {
|
||||
ox::PassThroughFS fs(configPath(ctx));
|
||||
auto const [buff, err] = fs.read(path);
|
||||
if (err) {
|
||||
oxErrf("Could not read config file: {}\n", toStr(err));
|
||||
//oxErrf("Could not read config file: {} - {}\n", path, toStr(err));
|
||||
return err;
|
||||
}
|
||||
return ox::readOC<T>(buff);
|
||||
@ -57,13 +57,13 @@ ox::Error writeConfig(keel::Context &ctx, ox::CRStringView name, T const&data) n
|
||||
auto const path = ox::sfmt("/{}.json", detail::slashesToPct(name));
|
||||
ox::PassThroughFS fs(configPath(ctx));
|
||||
if (auto const err = fs.mkdir("/", true)) {
|
||||
oxErrf("Could not create config directory: {}\n", toStr(err));
|
||||
//oxErrf("Could not create config directory: {} - {}\n", path, toStr(err));
|
||||
return err;
|
||||
}
|
||||
oxRequireM(buff, ox::writeOC(data));
|
||||
*buff.back().value = '\n';
|
||||
if (auto const err = fs.write(path, buff.data(), buff.size())) {
|
||||
oxErrf("Could not read config file: {}\n", toStr(err));
|
||||
//oxErrf("Could not read config file: {} - {}\n", path, toStr(err));
|
||||
return OxError(2, "Could not read config file");
|
||||
}
|
||||
return {};
|
||||
|
@ -14,7 +14,7 @@ namespace turbine {
|
||||
|
||||
class Context {
|
||||
public:
|
||||
UpdateHandler updateHandler = [](Context&) -> int {return 0;};
|
||||
UpdateHandler updateHandler = [](Context&) -> int {return -1;};
|
||||
keel::Context keelCtx;
|
||||
KeyEventHandler keyEventHandler = nullptr;
|
||||
ox::AnyPtr applicationData;
|
||||
|
@ -68,24 +68,26 @@ static void tickFps(Context &ctx, uint64_t nowMs) noexcept {
|
||||
}
|
||||
|
||||
ox::Error run(Context &ctx) noexcept {
|
||||
int sleepTime = 0;
|
||||
uint64_t sleepTime = 0;
|
||||
while (!glfwWindowShouldClose(ctx.window)) {
|
||||
ctx.refreshWithinMs = 10 * 1000; // refresh within 10 seconds
|
||||
glfwPollEvents();
|
||||
auto const ticks = ticksMs(ctx);
|
||||
if (ctx.wakeupTime <= ticks) {
|
||||
sleepTime = ctx.updateHandler(ctx);
|
||||
if (sleepTime >= 0) {
|
||||
ctx.wakeupTime = ticks + static_cast<unsigned>(sleepTime);
|
||||
auto const st = ctx.updateHandler(ctx);
|
||||
if (st >= 0) {
|
||||
ctx.wakeupTime = ticks + static_cast<unsigned>(st);
|
||||
sleepTime = static_cast<uint64_t>(st);
|
||||
} else {
|
||||
ctx.wakeupTime = ~uint64_t(0);
|
||||
sleepTime = ctx.wakeupTime - ticks;
|
||||
}
|
||||
} else {
|
||||
sleepTime = static_cast<int>(ctx.wakeupTime - ticks);
|
||||
sleepTime = ctx.wakeupTime - ticks;
|
||||
}
|
||||
tickFps(ctx, ticks);
|
||||
draw(ctx);
|
||||
auto const realSleepTime = ox::min(ctx.refreshWithinMs, sleepTime);
|
||||
auto const realSleepTime = ox::min(static_cast<uint64_t>(ctx.refreshWithinMs), sleepTime);
|
||||
if (realSleepTime) {
|
||||
if (ctx.uninterruptedRefreshes) {
|
||||
--ctx.uninterruptedRefreshes;
|
||||
|
Loading…
x
Reference in New Issue
Block a user