Skip to content

Commit

Permalink
restore build & basic functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
ScrelliCopter committed Apr 9, 2024
1 parent ebe83ff commit 385f7b0
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 159 deletions.
1 change: 1 addition & 0 deletions ext/base64/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
add_library(base64
base64.cpp base64.h)
add_library(base64::base64 ALIAS base64)
set_target_properties(base64 PROPERTIES CXX_STANDARD 17)
target_include_directories(base64
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
10 changes: 8 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
add_executable(tmx2gba
argparse.hpp argparse.cpp
$<$<NOT:$<TARGET_EXISTS:ZLIB::ZLIB>>:gzip.hpp gzip.cpp>
tmxlayer.hpp
tmxobject.hpp
tmxtileset.hpp
Expand All @@ -15,16 +16,21 @@ target_include_directories(tmx2gba PRIVATE ${CMAKE_CURRENT_BINARY_DIR})

set_target_properties(tmx2gba PROPERTIES CXX_STANDARD 20)

target_compile_definitions(${PROJECT_NAME} PRIVATE
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS> # disable msvc warning
$<$<TARGET_EXISTS:ZLIB::ZLIB>:USE_ZLIB>)

# Enable strong warnings
target_compile_options(tmx2gba PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/Wall>
$<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-Wall -Wextra -pedantic>
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded>)

target_link_libraries(${PROJECT_NAME} base64::base64 pugixml Zstd::Zstd
target_link_libraries(tmx2gba External::rapidxml)
#pugixml)
target_link_libraries(tmx2gba base64::base64 Zstd::Zstd
$<$<TARGET_EXISTS:ZLIB::ZLIB>:ZLIB::ZLIB>
$<$<TARGET_EXISTS:miniz::miniz>:miniz::miniz>)
target_link_libraries(${PROJECT_NAME} External::rapidxml)

if (TMX2GBA_DKP_INSTALL)
if (DEFINED ENV{DEVKITPRO})
Expand Down
27 changes: 13 additions & 14 deletions src/tmxlayer.hpp
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
/* tmxlayer.hpp - Copyright (C) 2015-2022 a dinosaur (zlib, see COPYING.txt) */
/* tmxlayer.hpp - Copyright (C) 2015-2024 a dinosaur (zlib, see COPYING.txt) */

#ifndef TMXLAYER_HPP
#define TMXLAYER_HPP

#include <vector>
#include <span>
#include <string>
#include <string_view>
#include <cstdint>
#include <utility>

class TmxLayer
{
std::string mName;
int mWidth, mHeight;
std::vector<uint32_t> mTileDat;

public:
static constexpr uint32_t FLIP_HORZ = 0x80000000;
static constexpr uint32_t FLIP_VERT = 0x40000000;
static constexpr uint32_t FLIP_DIAG = 0x20000000;
static constexpr uint32_t FLIP_MASK = 0xE0000000;

TmxLayer() : mWidth(0), mHeight(0), mTileDat(nullptr) {}
TmxLayer(int aWidth, int aHeight, std::string aName, uint32_t* aTileDat)
: mName(std::move(aName)), mWidth(aWidth), mHeight(aHeight), mTileDat(aTileDat) {}
inline ~TmxLayer() { delete[] mTileDat; }
TmxLayer(int width, int height, const std::string_view name, std::vector<uint32_t>&& tileDat) noexcept
: mName(name), mWidth(width), mHeight(height), mTileDat(std::move(tileDat)) {}

constexpr const std::string& GetName() const { return mName; }
constexpr int GetWidth() const { return mWidth; }
constexpr int GetHeight() const { return mHeight; }
constexpr const uint32_t* GetData() const { return mTileDat; }

private:
std::string mName;
int mWidth, mHeight;
uint32_t* mTileDat;
[[nodiscard]] constexpr const std::string_view Name() const noexcept { return mName; }
[[nodiscard]] constexpr std::pair<int, int> TileCount() const noexcept { return { mWidth, mHeight }; }
[[nodiscard]] constexpr const std::span<const uint32_t> Tiles() const noexcept { return mTileDat; }
};

#endif//TMXLAYER_HPP
16 changes: 8 additions & 8 deletions src/tmxobject.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* tmxobject.hpp - Copyright (C) 2015-2022 a dinosaur (zlib, see COPYING.txt) */
/* tmxobject.hpp - Copyright (C) 2015-2024 a dinosaur (zlib, see COPYING.txt) */

#ifndef TMXOBJECT_HPP
#define TMXOBJECT_HPP
Expand All @@ -9,17 +9,17 @@
class TmxObject
{
public:
TmxObject() : mX(0.0f), mY(0.0f) {}
TmxObject(std::string aName, float aX, float aY)
: mName(std::move(aName)), mX(aX), mY(aY) {}
~TmxObject() = default;
TmxObject(std::string_view name, float x, float y) : mName(name), mPos{ x, y } {}

constexpr const std::string& GetName() const { return mName; }
inline void GetPos(float& aOutX, float& aOutY) const { aOutX = mX; aOutY = mY; }
template <typename T>
struct Position { T x, y; };

constexpr const std::string_view Name() const noexcept { return mName; }
constexpr Position<float> Pos() const noexcept { return mPos; }

private:
std::string mName;
float mX, mY;
Position<float> mPos;
};

#endif//TMXOBJECT_HPP
Loading

0 comments on commit 385f7b0

Please sign in to comment.