Confusing refactor of library (Trust me it'll come out making sense)
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace LevelFormat
|
||||
{
|
||||
|
||||
};
|
@@ -1,5 +0,0 @@
|
||||
#include <Data/Entity.hpp>
|
||||
#include <Data/Layer.hpp>
|
||||
#include <Data/Tileset.hpp>
|
||||
#include <Data/Level.hpp>
|
||||
#include <Data/Tile.hpp>
|
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "Data/Entity.hpp"
|
||||
#include "Format/Entity.hpp"
|
||||
|
||||
|
||||
namespace TestGame {
|
@@ -1,7 +1,7 @@
|
||||
#include "GameEntity.hpp"
|
||||
#include "Player.hpp"
|
||||
#include "App/EditorCamera.hpp"
|
||||
#include "Data/Level.hpp"
|
||||
#include "Editor/EditorCamera.hpp"
|
||||
#include "Format/Level.hpp"
|
||||
#include "JUI/Widgets/Scene.hpp"
|
||||
#include "ReWindow/types/Window.h"
|
||||
|
@@ -13,11 +13,11 @@
|
||||
#include "NewMapDialog.hpp"
|
||||
#include "JUI/Widgets/ColorPicker.hpp"
|
||||
#include "Preferences.hpp"
|
||||
#include <Data/Level.hpp>
|
||||
#include <Data/Tileset.hpp>
|
||||
#include <Format/Level.hpp>
|
||||
#include <Format/Tileset.hpp>
|
||||
#include <JUI/Widgets/Checkbox.hpp>
|
||||
#include <App/LayerView.hpp>
|
||||
#include <App/TilesetView.hpp>
|
||||
#include <Editor/LayerView.hpp>
|
||||
#include <Editor/TilesetView.hpp>
|
||||
|
||||
#include "JUI/Widgets/FpsGraph.hpp"
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
using namespace ReWindow;
|
||||
using namespace JUI::UDimLiterals;
|
||||
|
||||
#include <App/EditorCamera.hpp>
|
||||
#include <Editor/EditorCamera.hpp>
|
||||
|
||||
// TODO: Support loading an entity_prefab.json file which defines template entities to copy.
|
||||
// TODO: Support sprites for these?
|
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <J3ML/LinearAlgebra.hpp>
|
||||
#include <Utils.hpp>
|
||||
#include <Re2DLevelAPI.hpp>
|
||||
|
||||
struct EditorCamera {
|
||||
Lerped<Vector2> translation;
|
@@ -6,7 +6,7 @@
|
||||
#include <JUI/Widgets/ListLayout.hpp>
|
||||
#include <JUI/Widgets/Checkbox.hpp>
|
||||
|
||||
#include <Data/Level.hpp>
|
||||
#include <Format/Level.hpp>
|
||||
|
||||
using namespace JUI::UDimLiterals;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include <Data/Tileset.hpp>
|
||||
#include <Format/Tileset.hpp>
|
||||
#include <JUI/Base/Widget.hpp>
|
||||
#include <JUI/Widgets/Window.hpp>
|
||||
#include <JUI/Widgets/Checkbox.hpp>
|
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <App/Grid.hpp>
|
||||
#include <Editor/Grid.hpp>
|
||||
|
||||
#include "TileMetaDialog.hpp"
|
||||
|
@@ -1,11 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <JJX/JSON.hpp>
|
||||
#include <json.hpp>
|
||||
#include <Color4.hpp>
|
||||
#include <Utils.hpp>
|
||||
|
||||
using namespace JJX;
|
||||
#include <Re2DLevelAPI.hpp>
|
||||
|
||||
enum class EntityRepresentativeShape {
|
||||
Point, AABB, Sphere, OBB
|
5
include/Format/Format.hpp
Normal file
5
include/Format/Format.hpp
Normal file
@@ -0,0 +1,5 @@
|
||||
#include <Format/Entity.hpp>
|
||||
#include <Format/Layer.hpp>
|
||||
#include <Format/Tileset.hpp>
|
||||
#include <Format/Level.hpp>
|
||||
#include <Format/Tile.hpp>
|
@@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <Data/Layer.hpp>
|
||||
#include <JJX/JSON.hpp>
|
||||
#include <Colors.hpp>
|
||||
#include <Utils.hpp>
|
||||
#include <json.hpp>
|
||||
|
||||
#include <Format/Layer.hpp>
|
||||
|
||||
#include <Re2DLevelAPI.hpp>
|
||||
|
||||
using namespace JJX;
|
||||
|
||||
enum class DataFormat
|
||||
{
|
@@ -1,15 +1,12 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <Data/Layer.hpp>
|
||||
#include <Data/Entity.hpp>
|
||||
#include <JJX/JSON.hpp>
|
||||
#include <Colors.hpp>
|
||||
#include <Utils.hpp>
|
||||
#include <Format/Layer.hpp>
|
||||
#include <Format/Entity.hpp>
|
||||
#include <json.hpp>
|
||||
#include <Re2DLevelAPI.hpp>
|
||||
#include <Format/Tileset.hpp>
|
||||
|
||||
#include "Tileset.hpp"
|
||||
|
||||
using namespace JJX;
|
||||
|
||||
const float REDACTED_EDITOR_LIB_VERSION = 1;
|
||||
|
2
include/Format/LevelFormat.hpp
Normal file
2
include/Format/LevelFormat.hpp
Normal file
@@ -0,0 +1,2 @@
|
||||
#pragma once
|
||||
|
@@ -1,28 +1,52 @@
|
||||
/// Redacted Software 2D Level Library
|
||||
/// Level File Format Specification
|
||||
///
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <JJX/JSON.hpp>
|
||||
#include <json.hpp>
|
||||
#include <filesystem>
|
||||
#include <format>
|
||||
#include <Utils.hpp>
|
||||
#include <Re2DLevelAPI.hpp>
|
||||
#include <J3ML/Geometry/AABB2D.hpp>
|
||||
|
||||
|
||||
/// Represents a rectangular sub-region of a larger space, such as a texture.
|
||||
/// @see J2D::DrawPartialSprite();
|
||||
struct Quad {
|
||||
int x; int y;
|
||||
int w; int h;
|
||||
#ifdef QUAD_EXTENDED_API
|
||||
Vector2i Position() const { return {x, y};}
|
||||
Vector2i Size() const { return {w, h};}
|
||||
void Position(const Vector2i& value) { x = value.x; y = value.y; }
|
||||
void Size(const Vector2i& value) { w = value.x; h = value.y; }
|
||||
void Set(AABB2D& rect) { }
|
||||
|
||||
|
||||
Quad Translated(const Vector2i& translation) {
|
||||
Quad copy;
|
||||
}
|
||||
|
||||
void Translate(const Vector2i& translation) {
|
||||
x += translation.x;
|
||||
y += translation.y;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
#include <J3ML/Math.hpp>
|
||||
#include <J3ML/LinearAlgebra.hpp>
|
||||
#include "JGL/types/Texture.h"
|
||||
|
||||
using namespace JJX;
|
||||
|
||||
struct Quad {
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
int h;
|
||||
};
|
||||
|
||||
struct Tile
|
||||
{
|
||||
int id;
|
||||
std::string name;
|
||||
/// The portion of the Tilesheet that corresponds to this tile-object.
|
||||
/// @note Non-uniform tile width and height are technically possible, but not generally designed for.\n
|
||||
/// The quad.w, quad.h should match the Tileset.tile_width, and Tileseh.tile_height.
|
||||
Quad quad;
|
||||
json::value metadata;
|
||||
bool collides;
|
||||
@@ -30,8 +54,6 @@ struct Tile
|
||||
bool persistent = false;
|
||||
};
|
||||
|
||||
/// TODO: Only generate tile entry for tiles that are used in the level, or have been assigned custom metadata.
|
||||
/// TODO: Large tilesets generate unwieldy file sizes and cause our rudimentary json parser to crash out.
|
||||
|
||||
/// @class Tileset
|
||||
/// @brief Represents a collection of tiles, typically from a single texture atlas, used in a level.
|
||||
@@ -39,6 +61,9 @@ struct Tile
|
||||
/// The Tileset class defines the properties of a set of tiles, including their dimensions,
|
||||
/// spacing, and how they are arranged within a source texture. It also provides metadata
|
||||
/// about the tileset itself, such as its name and author.
|
||||
///
|
||||
/// @note As a space-saving measure, tiles are only saved to file if they contain non-generic metadata, or a custom name or ID. Otherwise, tiles are simply generated in incrementing order at runtime.
|
||||
///
|
||||
class Tileset {
|
||||
public:
|
||||
#pragma region json fields
|
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <Color4.hpp>
|
||||
#include <J3ML/LinearAlgebra.hpp>
|
||||
#include <JJX/JSON.hpp>
|
||||
#include <json.hpp>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
inline int CellToIndex(Vector2i cell, int width)
|
||||
{
|
||||
return cell.y*width + cell.x;
|
||||
@@ -18,14 +19,12 @@ inline int CellToIndex(Vector2i cell, int width)
|
||||
|
||||
namespace JsonConversions
|
||||
{
|
||||
using namespace JJX;
|
||||
Color4 parse_color(const JJX::json::value& v);
|
||||
Color4 parse_color(const json::value& v);
|
||||
json::value deparse_color_to_hex(const Color4& color);
|
||||
|
||||
JJX::json::value deparse_color_to_hex(const Color4& color);
|
||||
std::vector<std::string> parse_string_list(const json::value& v);
|
||||
|
||||
std::vector<std::string> parse_string_list(const JJX::json::value& v);
|
||||
|
||||
JJX::json::value deparse_string_list(const std::vector<std::string>& list);
|
||||
json::value deparse_string_list(const std::vector<std::string>& list);
|
||||
} // namespace JsonConversions
|
||||
|
||||
template <typename T>
|
Reference in New Issue
Block a user