[nostalgia] Split part of Core out into Foundation, add module system
This commit is contained in:
@@ -1,13 +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/fs/fs.hpp>
|
||||
#include <ox/model/desctypes.hpp>
|
||||
#include <ox/std/buffer.hpp>
|
||||
|
||||
#include "assetmanager.hpp"
|
||||
#include <nostalgia/foundation/context.hpp>
|
||||
|
||||
#include "event.hpp"
|
||||
#include "input.hpp"
|
||||
|
||||
@@ -19,15 +21,14 @@ namespace nostalgia::core {
|
||||
|
||||
class BaseClipboardObject {
|
||||
public:
|
||||
virtual ~BaseClipboardObject() = default;
|
||||
virtual ~BaseClipboardObject() noexcept = default;
|
||||
|
||||
[[nodiscard]]
|
||||
virtual ox::String typeId() const noexcept = 0;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr auto typeMatch(auto name, auto version) const noexcept {
|
||||
auto inId = ox::sfmt("{};{}", name, version);
|
||||
return typeId() == inId;
|
||||
return typeId() == ox::buildTypeId(name, version);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -35,7 +36,7 @@ template<typename T>
|
||||
class ClipboardObject: public BaseClipboardObject {
|
||||
[[nodiscard]]
|
||||
ox::String typeId() const noexcept final {
|
||||
return ox::sfmt("{};{}", T::TypeName, T::TypeVersion);
|
||||
return ox::buildTypeId(T::TypeName, T::TypeVersion);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -46,7 +47,7 @@ struct BgCbbData {
|
||||
};
|
||||
|
||||
// User Input Output
|
||||
class Context {
|
||||
class Context: public foundation::Context {
|
||||
friend constexpr void setApplicationData(Context *ctx, void *applicationData) noexcept;
|
||||
template<typename T>
|
||||
friend constexpr T *applicationData(Context *ctx) noexcept;
|
||||
@@ -68,7 +69,7 @@ class Context {
|
||||
const struct CompactTileSheet &tilesheetAddr) noexcept;
|
||||
friend ox::Error run(Context *ctx) noexcept;
|
||||
friend void shutdown(Context *ctx) noexcept;
|
||||
friend ox::Result<ox::UniquePtr<Context>> init(ox::UniquePtr<ox::FileSystem> fs, ox::CRStringView appName) noexcept;
|
||||
friend ox::Result<ox::UPtr<Context>> init(ox::UPtr<ox::FileSystem> fs, ox::CRStringView appName) noexcept;
|
||||
friend ox::String getClipboardText(Context *ctx) noexcept;
|
||||
friend uint64_t ticksMs(Context *ctx) noexcept;
|
||||
friend uint8_t bgStatus(Context *ctx) noexcept;
|
||||
@@ -93,17 +94,13 @@ class Context {
|
||||
friend void hideSprite(Context *ctx, unsigned idx) noexcept;
|
||||
|
||||
public:
|
||||
ox::UniquePtr<ox::FileSystem> rom;
|
||||
ox::Vector<Drawer*, 5> drawers;
|
||||
ox::StringView appName = "Nostalgia";
|
||||
|
||||
#ifndef OX_BARE_METAL
|
||||
AssetManager assetManager;
|
||||
int uninterruptedRefreshes = 3;
|
||||
ox::UniquePtr<BaseClipboardObject> clipboard;
|
||||
ox::UPtr<BaseClipboardObject> clipboard;
|
||||
#else
|
||||
bool running = true;
|
||||
std::size_t preloadSectionOffset = 0;
|
||||
#endif
|
||||
protected:
|
||||
#ifndef OX_BARE_METAL
|
||||
|
||||
Reference in New Issue
Block a user