[nostalgia/core] Cleanup
This commit is contained in:
parent
41cebff5fc
commit
779dd1fd05
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "assetmanager.hpp"
|
#include "assetmanager.hpp"
|
||||||
#include "event.hpp"
|
#include "event.hpp"
|
||||||
|
#include "input.hpp"
|
||||||
|
|
||||||
namespace nostalgia::common {
|
namespace nostalgia::common {
|
||||||
class Size;
|
class Size;
|
||||||
@ -16,13 +17,7 @@ class Size;
|
|||||||
namespace nostalgia::core {
|
namespace nostalgia::core {
|
||||||
|
|
||||||
class Context;
|
class Context;
|
||||||
|
class Drawer;
|
||||||
class Drawer {
|
|
||||||
public:
|
|
||||||
virtual ~Drawer() = default;
|
|
||||||
|
|
||||||
virtual void draw(Context*) noexcept = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
// User Input Output
|
// User Input Output
|
||||||
class Context {
|
class Context {
|
||||||
@ -31,6 +26,7 @@ class Context {
|
|||||||
friend constexpr T *applicationData(Context *ctx) noexcept;
|
friend constexpr T *applicationData(Context *ctx) noexcept;
|
||||||
friend constexpr void setConstantRefresh(Context *ctx, bool) noexcept;
|
friend constexpr void setConstantRefresh(Context *ctx, bool) noexcept;
|
||||||
friend bool bgStatus(Context *ctx, unsigned bg) noexcept;
|
friend bool bgStatus(Context *ctx, unsigned bg) noexcept;
|
||||||
|
friend bool buttonDown(Context *ctx, Key) noexcept;
|
||||||
friend common::Size getScreenSize(Context *ctx) noexcept;
|
friend common::Size getScreenSize(Context *ctx) noexcept;
|
||||||
friend int getScreenHeight(Context *ctx) noexcept;
|
friend int getScreenHeight(Context *ctx) noexcept;
|
||||||
friend int getScreenWidth(Context *ctx) noexcept;
|
friend int getScreenWidth(Context *ctx) noexcept;
|
||||||
|
@ -17,6 +17,13 @@ namespace nostalgia::core {
|
|||||||
|
|
||||||
extern char charMap[128];
|
extern char charMap[128];
|
||||||
|
|
||||||
|
class Drawer {
|
||||||
|
public:
|
||||||
|
virtual ~Drawer() = default;
|
||||||
|
|
||||||
|
virtual void draw(Context*) noexcept = 0;
|
||||||
|
};
|
||||||
|
|
||||||
enum class TileSheetSpace {
|
enum class TileSheetSpace {
|
||||||
Background,
|
Background,
|
||||||
Sprite
|
Sprite
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#include <imgui_impl_opengl3.h>
|
|
||||||
#include <imgui_impl_glfw.h>
|
#include <imgui_impl_glfw.h>
|
||||||
|
|
||||||
#include <ox/std/defines.hpp>
|
#include <ox/std/defines.hpp>
|
||||||
|
@ -11,24 +11,19 @@
|
|||||||
namespace nostalgia::core {
|
namespace nostalgia::core {
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr std::size_t pointToIdx(int w, int x, int y) noexcept {
|
constexpr std::size_t ptToIdx(int x, int y, int c) noexcept {
|
||||||
constexpr auto colLength = static_cast<std::size_t>(PixelsPerTile);
|
constexpr auto colLength = static_cast<std::size_t>(PixelsPerTile);
|
||||||
const auto rowLength = static_cast<std::size_t>(static_cast<std::size_t>(w / TileWidth) * colLength);
|
const auto rowLength = static_cast<std::size_t>(static_cast<std::size_t>(c / TileWidth) * colLength);
|
||||||
const auto colStart = static_cast<std::size_t>(colLength * static_cast<std::size_t>(x / TileWidth));
|
const auto colStart = static_cast<std::size_t>(colLength * static_cast<std::size_t>(x / TileWidth));
|
||||||
const auto rowStart = static_cast<std::size_t>(rowLength * static_cast<std::size_t>(y / TileHeight));
|
const auto rowStart = static_cast<std::size_t>(rowLength * static_cast<std::size_t>(y / TileHeight));
|
||||||
const auto colOffset = static_cast<std::size_t>(x % TileWidth);
|
const auto colOffset = static_cast<std::size_t>(x % TileWidth);
|
||||||
const auto rowOffset = static_cast<std::size_t>((y % TileHeight) * TileHeight);
|
const auto rowOffset = static_cast<std::size_t>(static_cast<std::size_t>(y % TileHeight) * TileHeight);
|
||||||
return static_cast<std::size_t>(colStart + colOffset + rowStart + rowOffset);
|
return static_cast<std::size_t>(colStart + colOffset + rowStart + rowOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr std::size_t ptToIdx(int x, int y, int c) noexcept {
|
constexpr std::size_t ptToIdx(const common::Point &pt, int c) noexcept {
|
||||||
return pointToIdx(c * TileWidth, x, y);
|
return ptToIdx(pt.x, pt.y, c * TileWidth);
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr std::size_t ptToIdx(common::Point pt, int c) noexcept {
|
|
||||||
return pointToIdx(c * TileWidth, pt.x, pt.y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user