[nostalgia] Collapse NostalgiaCore down to a single library and cleanup impl data access

This commit is contained in:
2022-02-03 19:57:43 -06:00
parent d4e903b593
commit 8174d04b06
20 changed files with 152 additions and 182 deletions
+42 -4
View File
@@ -7,6 +7,11 @@
#include <ox/fs/fs.hpp>
#include "assetmanager.hpp"
#include "event.hpp"
namespace nostalgia::common {
class Size;
}
namespace nostalgia::core {
@@ -18,8 +23,40 @@ class Drawer {
virtual void draw(Context*) noexcept = 0;
};
namespace renderer {
ox::Error init(Context *ctx) noexcept;
ox::Error shutdown(Context *ctx) noexcept;
ox::Error loadBgTexture(Context *ctx, int section, void *pixels, int w, int h) noexcept;
}
// User Input Output
class Context {
friend bool bgStatus(Context *ctx, unsigned bg) noexcept;
friend common::Size getScreenSize(Context *ctx) noexcept;
friend int getScreenHeight(Context *ctx) noexcept;
friend int getScreenWidth(Context *ctx) noexcept;
friend ox::Error initGfx(Context *ctx) noexcept;
friend ox::Error renderer::init(Context *ctx) noexcept;
friend ox::Error renderer::loadBgTexture(Context *ctx, int section, void *pixels, int w, int h) noexcept;
friend ox::Error renderer::shutdown(Context *ctx) noexcept;
friend ox::Error run(Context *ctx) noexcept;
friend ox::Error shutdown(Context *ctx) noexcept;
friend ox::Result<ox::UniquePtr<Context>> init(ox::UniquePtr<ox::FileSystem> fs, const char *appName) noexcept;
friend ox::String getClipboardText(Context *ctx) noexcept;
friend uint64_t ticksMs(Context *ctx) noexcept;
friend uint8_t bgStatus(Context *ctx) noexcept;
friend void clearTileLayer(Context *ctx, int layer) noexcept;
friend void draw(Context *ctx) noexcept;
friend void focusWindow(Context *ctx) noexcept;
friend void setBgStatus(Context *ctx, uint32_t status) noexcept;
friend void setBgStatus(Context *ctx, unsigned bg, bool status) noexcept;
friend void setClipboardText(Context *ctx, const ox::String &text) noexcept;
friend void setEventHandler(Context *ctx, event_handler h) noexcept;
friend void setRendererData(Context *ctx, void *rendererData) noexcept;
friend void setTile(Context *ctx, int layer, int column, int row, uint8_t tile) noexcept;
friend void setWindowTitle(Context *ctx, const char *title) noexcept;
friend void setWindowerData(Context *ctx, void *windowerData) noexcept;
public:
ox::UniquePtr<ox::FileSystem> rom;
ox::Vector<Drawer*, 5> drawers;
@@ -49,16 +86,17 @@ class Context {
return static_cast<T*>(m_customData);
}
constexpr void setWindowerData(void *windowerData) noexcept {
m_windowerData = windowerData;
}
protected:
template<typename T>
[[nodiscard]]
constexpr T *windowerData() noexcept {
return static_cast<T*>(m_windowerData);
}
constexpr void setWindowerData(void *windowerData) noexcept {
m_windowerData = windowerData;
}
constexpr void setRendererData(void *rendererData) noexcept {
m_rendererData = rendererData;
}