diff --git a/.DS_Store b/.DS_Store
deleted file mode 100644
index 61a4a25..0000000
Binary files a/.DS_Store and /dev/null differ
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..053f31e
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,3 @@
+UseTab: Always
+IndentWidth: 4
+TabWidth: 4
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
new file mode 100644
index 0000000..f5e6193
--- /dev/null
+++ b/.github/workflows/codeql.yml
@@ -0,0 +1,108 @@
+# For most projects, this workflow file will not need changing; you simply need
+# to commit it to your repository.
+#
+# You may wish to alter this file to override the set of languages analyzed,
+# or to provide custom queries or build logic.
+#
+# ******** NOTE ********
+# We have attempted to detect the languages in your repository. Please check
+# the `language` matrix defined below to confirm you have the correct set of
+# supported CodeQL languages.
+#
+name: "CodeQL Advanced"
+
+on:
+ push:
+ branches: ["main", "tgui-fresh"]
+ pull_request:
+ branches: ["main", "tgui-fresh"]
+ schedule:
+ - cron: "19 2 * * 1"
+
+jobs:
+ analyze:
+ name: Analyze (${{ matrix.language }})
+ # Runner size impacts CodeQL analysis time. To learn more, please see:
+ # - https://gh.io/recommended-hardware-resources-for-running-codeql
+ # - https://gh.io/supported-runners-and-hardware-resources
+ # - https://gh.io/using-larger-runners (GitHub.com only)
+ # Consider using larger runners or machines with greater resources for possible analysis time improvements.
+ runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
+ permissions:
+ # required for all workflows
+ security-events: write
+
+ # required to fetch internal or private CodeQL packs
+ packages: read
+
+ # only required for workflows in private repositories
+ actions: read
+ contents: read
+
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - language: c-cpp
+ build-mode: manual
+ # CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift'
+ # Use `c-cpp` to analyze code written in C, C++ or both
+ # Use 'java-kotlin' to analyze code written in Java, Kotlin or both
+ # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
+ # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
+ # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
+ # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
+ # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ submodules: recursive
+
+ # Add any setup steps before running the `github/codeql-action/init` action.
+ # This includes steps like installing compilers or runtimes (`actions/setup-node`
+ # or others). This is typically only required for manual builds.
+ # - name: Setup runtime (example)
+ # uses: actions/setup-example@v1
+
+ # Initializes the CodeQL tools for scanning.
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@v4
+ with:
+ languages: ${{ matrix.language }}
+ build-mode: ${{ matrix.build-mode }}
+ # If you wish to specify custom queries, you can do so here or in a config file.
+ # By default, queries listed here will override any specified in a config file.
+ # Prefix the list here with "+" to use these queries and those in the config file.
+
+ # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
+ # queries: security-extended,security-and-quality
+
+ # If the analyze step fails for one of the languages you are analyzing with
+ # "We were unable to automatically build your code", modify the matrix above
+ # to set the build mode to "manual" for that language. Then modify this step
+ # to build your code.
+ # âšī¸ Command-line programs to run using the OS shell.
+ # đ See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
+ - name: Run manual build steps
+ if: matrix.build-mode == 'manual'
+ shell: bash
+ run: |
+ sudo add-apt-repository ppa:xmake-io/xmake
+ sudo apt-get update
+ sudo apt-get install -y \
+ libx11-dev \
+ libxrandr-dev \
+ libxinerama-dev \
+ libxcursor-dev \
+ libxi-dev \
+ libgl1-mesa-dev \
+ mesa-common-dev \
+ xmake
+ xmake build --all -y
+
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@v4
+ with:
+ category: "/language:${{matrix.language}}"
diff --git a/.gitignore b/.gitignore
index 8fe3f33..680960f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,7 +40,6 @@ game-src/*/lib/
/game
build/
bin/
-libs/
execs/**
*.bin
.cache/
@@ -58,3 +57,4 @@ imgui.ini
clangd/
game-src/
compile_commands.json
+xmake-*.exe
diff --git a/.gitmodules b/.gitmodules
index c9753d7..e69de29 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,9 +0,0 @@
-[submodule "libs/luajit"]
- path = libs/luajit
- url = https://luajit.org/git/luajit.git
-[submodule "libs/raylib"]
- path = libs/raylib
- url = https://github.com/raysan5/raylib.git
-[submodule "rlImGui"]
- path = rlImGui
- url = https://github.com/raylib-extras/rlImGui
diff --git a/.zed/debug.json b/.zed/debug.json
new file mode 100644
index 0000000..8c4ea15
--- /dev/null
+++ b/.zed/debug.json
@@ -0,0 +1,14 @@
+[
+ {
+ "label": "Debug RPG++ Editor (Linux)",
+ "build": {
+ "command": "xmake",
+ "args": ["build", "--all"],
+ "cwd": "${ZED_WORKTREE_ROOT}",
+ },
+ "program": "${ZED_WORKTREE_ROOT}/build/linux/x86_64/debug/editor",
+ "request": "launch",
+ "adapter": "CodeLLDB",
+ "cwd": "${ZED_WORKTREE_ROOT}/build/linux/x86_64/debug",
+ },
+]
diff --git a/.zed/settings.json b/.zed/settings.json
new file mode 100644
index 0000000..ad1810c
--- /dev/null
+++ b/.zed/settings.json
@@ -0,0 +1,11 @@
+{
+ "show_whitespaces": "selection",
+ "indent_guides": {
+ "active_line_width": 1,
+ "enabled": true,
+ },
+ "tab_size": 4,
+ "hard_tabs": true,
+ "show_wrap_guides": true,
+ "project_name": "RPG++",
+}
diff --git a/.zed/tasks.json b/.zed/tasks.json
new file mode 100644
index 0000000..86d4579
--- /dev/null
+++ b/.zed/tasks.json
@@ -0,0 +1,17 @@
+// Project tasks configuration. See https://zed.dev/docs/tasks for documentation.
+//
+// Example:
+[
+ {
+ "label": "Run Editor",
+ "command": "xmake run editor",
+ },
+ {
+ "label": "Run translation checker",
+ "command": "xmake check_translation",
+ },
+ {
+ "label": "Build All",
+ "command": "xmake build --all",
+ },
+]
diff --git a/README.md b/README.md
index 73417d7..43d060b 100644
--- a/README.md
+++ b/README.md
@@ -1,35 +1,87 @@
-# RPG++
-

+---
RPG++ is an experimental 2D RPG game engine written in C++. It is currently in early development, but contributions are welcome!
-## Building
+***This is a fresh restart, there are currently no RPG++ lua bindings, the engine hasn't been implemented in this branch yet.***
+
+
+
+Requirements
+---
+
+To build RPG++, you'll need to install the following tools/packages:
+- **For all platforms**:
+ - [xmake](https://xmake.io/) (follow the instructions on the website to install XMake on your system)
+ - [git](https://git-scm.com/)
+- Specifically for _Linux_:
+ - gcc, g++, make, and ninja (on Debian-based distros, you can install this via `sudo apt install build-essential`)
+ - libx11-dev, libxrandr-dev, libxinerama-dev, libxcursor-dev, libxi-dev, libgl1-mesa-dev, and mesa-common-dev (Debian-based distros can install this via `sudo apt install libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl1-mesa-dev mesa-common-dev`)
+- Specifically for _Windows_:
+ - Visual Studio 2019 or later with Desktop development with C++ (community edition will suffice)
+
+Building
+---
+
+Clone the project using git with
-This project uses [XMake](https://xmake.io/) so you may need to download it for your system.
+```bash
+git clone https://github.com/CDevv/rpgpp
+```
-First, you have to initialize the specified submodules. use `git submodule init` to initialize the paths. Then use, `git submodule update` to clone the submodules to your system.
+To build all targets, run
-After cloning the submodules to the paths, check your `/rlImGui` directory.
+```bash
+xmake build --all
+```
-Additional dependency is LuaJIT. After getting the luajit xmake package, you need to copy the luajit executable into the `execs/` directory.
+If xmake failed to build, try force reinstalling the packages with
+```bash
+xmake clean --all # remove build artifacts
+xmake require --clean # remove installed package cache for project
+xmake require --force # force install of package
+```
-Here are the xmake directories on different platforms:
+Running
+---
-Linux: `/home/name/.xmake/packages/l/luajitv2.1.0-beta3/aaeb029456e54f29b904a191c96508d2/bin/`
+To start the editor, run
-Windows: `AppData\Local\.xmake\packages\l\luajit\v2.1.0-beta3\7780bd1b1c8146cd984bf13d60e49407\bin`
+```bash
+xmake run editor
+```
-Mac: `/Users/nikodev/.xmake/packages/l/luajit/v2.1.0-beta3/bin`
+Translation
+---
-(Do not copy it blindly, the commit number might be different)
+Translation are located in `resources/translations`, containing JSON files with their names being the language code.
-Finally, use `xmake build --all` to build all targets.
+Each JSON files is structured as either flattened JSON:
+```json
+{
+ "language": "",
+ "translation.key": ""
+}
+```
+or nested JSON:
+```json
+{
+ "language": "",
+ "translation": {
+ "key": ""
+ }
+}
+```
+Both types are supported, though we recommend using nested JSON for better organization.
-## Running
+If you wish to improve an existing language, you can do so by modifying the language file of the language you know. Or if you want to add a new language, create a new JSON file within the folder, specify the language via the `language` key, and then translate the root translation file (en_us.json). The engine will automatically pick it up.
-Use `xmake run editor` to run the editor.
+To check for translation progress, you can do so via
+```
+xmake check_translation
+```
-## License
+License
+---
-This software uses the MIT License.
+This software is licensed under the MIT License.
diff --git a/docs/readme_img1.png b/docs/readme_img1.png
new file mode 100644
index 0000000..235ee3b
Binary files /dev/null and b/docs/readme_img1.png differ
diff --git a/include/.DS_Store b/include/.DS_Store
deleted file mode 100644
index c7f7fd7..0000000
Binary files a/include/.DS_Store and /dev/null differ
diff --git a/include/actor.hpp b/include/actor.hpp
index de71831..f68be71 100644
--- a/include/actor.hpp
+++ b/include/actor.hpp
@@ -3,8 +3,10 @@
#include "atlasTile.hpp"
#include "gamedata.hpp"
+#include "saveable.hpp"
#include "tileset.hpp"
#include
+#include
#include
#include
#include
@@ -12,110 +14,129 @@
using json = nlohmann::json;
+#define RPGPP_MAX_DIRECTION 7
/** Direction enum, representing an animation state. */
-enum Direction {
- RPGPP_DOWN_IDLE = 0, ///< Down Idle state.
- RPGPP_DOWN = 1, ///< Down state.
- RPGPP_UP_IDLE = 2, ///< Up Idle state.
- RPGPP_UP = 3, ///< Up state.
- RPGPP_LEFT_IDLE = 4, ///< Left Idle state.
- RPGPP_LEFT = 5, ///< Left state.
- RPGPP_RIGHT_IDLE = 6, ///< Right Idle state.
- RPGPP_RIGHT = 7 ///< Right state.
+enum Direction : short {
+ RPGPP_DOWN_IDLE = 0, ///< Down Idle state.
+ RPGPP_DOWN = 1, ///< Down state.
+ RPGPP_UP_IDLE = 2, ///< Up Idle state.
+ RPGPP_UP = 3, ///< Up state.
+ RPGPP_LEFT_IDLE = 4, ///< Left Idle state.
+ RPGPP_LEFT = 5, ///< Left state.
+ RPGPP_RIGHT_IDLE = 6, ///< Right Idle state.
+ RPGPP_RIGHT = 7 ///< Right state.
};
/** The Actor class represents an Actor in the game's world.
* @see [Direction](Direction.md)
*/
-class Actor {
-private:
- std::string sourcePath;
- /** The used TileSet for this Actor's sprites. */
- std::unique_ptr tileSet;
- /** The path to the TileSet file. */
- std::string tileSetSource;
- /** The currently shown tile from the TileSet. */
- AtlasTile tile;
- /** Current position in the world of this Actor. */
- Vector2 position{};
- /** Current tile position of this Actor if such is set. */
- Vector2 tilePosition{};
- int frameCounter{};
- int frameSpeed{};
- int currentFrame{};
- /** Rectangle, representing the collision of this Actor. */
- Rectangle collisionRect{};
- /** An array of the animations. Each std::vector represents the
- * frames of an animation. */
- std::array>, 8> animations;
- /** A Direction enum, showing the current animation that is being played. */
- Direction currentAnimation;
+class Actor : public ISaveable {
+ private:
+ std::string sourcePath;
+ /** The used TileSet for this Actor's sprites. */
+ std::unique_ptr tileSet;
+ /** The path to the TileSet file. */
+ std::string tileSetSource;
+ /** The currently shown tile from the TileSet. */
+ AtlasTile tile;
+ /** Current position in the world of this Actor. */
+ Vector2 position{};
+ /** Current tile position of this Actor if such is set. */
+ Vector2 tilePosition{};
+ int frameCounter{};
+ int frameSpeed{};
+ int currentFrame{};
+ /** Rectangle, representing the collision of this Actor. */
+ Rectangle collisionRect{};
+ /** An array of the animations. Each std::vector represents the
+ * frames of an animation. */
+ std::array, 8> animations;
+ /** A Direction enum, showing the current animation that is being played. */
+ Direction currentAnimation;
-public:
- /** Empty constructor. */
- Actor() = default;
- /** Constructor that takes a path to the .ractor file. */
- Actor(const std::string &fileName);
- /** Constructor that takes a TileSet, the atlas position of the tile to use,
- * and the path to the TileSet. */
- Actor(std::unique_ptr tileSet, Vector2 atlasPos,
- std::string tileSetSource);
- /** Constructor that takes an ActorBin binary structure */
- Actor(ActorBin bin);
- /** Dump this Actor's data to a nlohmann::json object. */
- json dumpJson();
- /** Unload routine. The UnloadTexture function will called here. */
- void unload() const;
- /** Update routine. */
- void update();
- /** Draw routine. */
- void draw() const;
- /** Get the source file's path for this Actor. */
- std::string getSourcePath() const;
- /** Get this actor's position in the world. */
- Vector2 getPosition() const;
- /** Set this Actor's position. */
- void setPosition(Vector2 newPosition);
- /** Set Actor position relative to a tile in the world. */
- void setTilePosition(Vector2 newPosition, Vector2 tileSize);
- /** Get this Actor's tile position. */
- Vector2 getTilePosition() const;
- /** Move the Actor using a velocity vector. */
- void moveByVelocity(Vector2 velocity);
- /** Get the bounding box of this Actor. */
- Rectangle getRect() const;
- /** Get a reference to this Actor's TileSet. */
- TileSet &getTileSet() const;
- /** Set this Actor's TileSet using a path to the tileset file. */
- void setTileSet(const std::string &newTileSetSource);
- /** Get the collision rectangle of this Actor if it was moved by the velocity
- * vector */
- Rectangle getCollisionRect(Vector2 velocity) const;
- /** Get collision center point. */
- Vector2 getCollisionCenter() const;
- /** Add a frame in the chosen animation. The frame represents an atlas tile
- * from this Actor's TileSet. */
- void addAnimationFrame(Direction id, Vector2 atlasPos) const;
- /** Remove a frame in the chosen animation, specified by an index. */
- void removeAnimationFrame(Direction id, int frameIndex);
- /** Change a frame in the chosen animation to another atlas tile from the
- * TileSet. */
- void setAnimationFrame(Direction id, int frameIndex, Vector2 atlasTile) const;
- /** Add multiple frames to the chosen animation. */
- void addAnimationFrames(Direction id,
- const std::vector> &frames) const;
- /** Change the Actor's current animation and play it. */
- void changeAnimation(Direction id);
- /** Get the path of the used TileSet. */
- std::string getTileSetSource() const;
- /** Get an array of this Actor's animations */
- std::array, 8> getAnimationsRaw() const;
- /** Get a specific animation */
- std::vector getAnimationRaw(Direction id) const;
- /** Get the collision Rectangle of this Actor */
- Rectangle getCollisionRect() const;
- /** Set the Actor's collision Rectangle */
- void setCollisionRect(Rectangle rect);
+ public:
+ /** Empty constructor. */
+ Actor() = default;
+ /** Constructor that takes a path to the .ractor file. */
+ Actor(const std::string &fileName);
+ /** Constructor that takes a TileSet, the atlas position of the tile to use,
+ * and the path to the TileSet. */
+ Actor(std::unique_ptr tileSet, Vector2 atlasPos,
+ std::string tileSetSource);
+ /** Constructor that takes an ActorBin binary structure */
+ Actor(ActorBin bin);
+ /** Dump this Actor's data to a nlohmann::json object. */
+ json dumpJson() override;
+ /** Unload routine. The UnloadTexture function will called here. */
+ void unload() const;
+ /** Update routine. */
+ void update();
+ /** Draw routine. */
+ void draw() const;
+ /** Get the source file's path for this Actor. */
+ std::string getSourcePath() const;
+ /** Get this actor's position in the world. */
+ Vector2 getPosition() const;
+ /** Set this Actor's position. */
+ void setPosition(Vector2 newPosition);
+ /** Set Actor position relative to a tile in the world. */
+ void setTilePosition(Vector2 newPosition, Vector2 tileSize);
+ /** Get this Actor's tile position. */
+ Vector2 getTilePosition() const;
+ /** Move the Actor using a velocity vector. */
+ void moveByVelocity(Vector2 velocity);
+ /** Get the bounding box of this Actor. */
+ Rectangle getRect() const;
+ /** Get a reference to this Actor's TileSet. */
+ TileSet &getTileSet() const;
+ /** Get the current frame of this actor. */
+ int getCurrentFrame() const;
+ /** Reset the animation back to frame 0. */
+ void resetAnimation() { this->setAnimationFrame(0); }
+ /** Get the current direction of this actor. */
+ Direction getAnimationDirection() const;
+ /** Get the current animation atlas of this actor. */
+ Vector2 getCurrentAnimationAtlas() const;
+ /** Get the current animation rectangle of this actor. */
+ Rectangle getCurrentAnimationRectangle() const;
+ /** Get an atlas of this actor by frame index. */
+ Vector2 getAnimationAtlasByIdx(int frameIndex) const;
+ /** Set the current frame. */
+ void setAnimationFrame(int frameIndex);
+ /** Get the current size of the animation in the direction. */
+ int getAnimationCount() const;
+ /** Set this Actor's TileSet using a path to the tileset file. */
+ void setTileSet(const std::string &newTileSetSource);
+ /** The callback when the current frame changes. */
+ std::function onFrameChanged;
+ /** Get the collision rectangle of this Actor if it was moved by the
+ * velocity vector */
+ Rectangle getCollisionRect(Vector2 velocity) const;
+ /** Get collision center point. */
+ Vector2 getCollisionCenter() const;
+ /** Add a frame in the chosen animation. The frame represents an atlas tile
+ * from this Actor's TileSet. */
+ void addAnimationFrame(Direction id, Vector2 atlasPos);
+ /** Remove a frame in the chosen animation, specified by an index. */
+ void removeAnimationFrame(Direction id, int frameIndex);
+ /** Change a frame in the chosen animation to another atlas tile from the
+ * TileSet. */
+ void setAnimationFrame(Direction id, int frameIndex, Vector2 atlasTile);
+ /** Add multiple frames to the chosen animation. */
+ void addAnimationFrames(Direction id,
+ const std::vector> &frames);
+ /** Change the Actor's current animation and play it. */
+ void changeAnimation(Direction id);
+ /** Get the path of the used TileSet. */
+ std::string getTileSetSource() const;
+ /** Get an array of this Actor's animations */
+ std::array, 8> getAnimationsRaw() const;
+ /** Get a specific animation */
+ std::vector getAnimationRaw(Direction id) const;
+ /** Get the collision Rectangle of this Actor */
+ Rectangle getCollisionRect() const;
+ /** Set the Actor's collision Rectangle */
+ void setCollisionRect(Rectangle rect);
};
#endif
diff --git a/include/atlasTile.hpp b/include/atlasTile.hpp
index fb66302..6baaa43 100644
--- a/include/atlasTile.hpp
+++ b/include/atlasTile.hpp
@@ -7,27 +7,29 @@
* Represents a source atlas tile from a TileSet.
*/
class AtlasTile {
-private:
- /** Pointer to the used Texture */
- Texture *texture;
- /** The atlas (source) coordinates from the TileSet. */
- Vector2 atlasCoords;
-public:
- /**
- * Empty constructor
- */
- AtlasTile();
+ private:
+ /** Pointer to the used Texture */
+ Texture *texture;
+ /** The atlas (source) coordinates from the TileSet. */
+ Vector2 atlasCoords;
- /**
- * Constructor that takes in a texture and coordinates on the atlas (the tileset)
- */
- AtlasTile(Texture *texture, Vector2 atlasCoords);
+ public:
+ /**
+ * Empty constructor
+ */
+ AtlasTile();
- /**
- * Get the atlas coordinates
- * @returns A Vector2 which represents the atlas coordinates
- */
- Vector2 getAtlasCoords() const;
+ /**
+ * Constructor that takes in a texture and coordinates on the atlas (the
+ * tileset)
+ */
+ AtlasTile(Texture *texture, Vector2 atlasCoords);
+
+ /**
+ * Get the atlas coordinates
+ * @returns A Vector2 which represents the atlas coordinates
+ */
+ Vector2 getAtlasCoords() const;
};
#endif
diff --git a/include/collisionsContainer.hpp b/include/collisionsContainer.hpp
index e505b97..6d38a4b 100644
--- a/include/collisionsContainer.hpp
+++ b/include/collisionsContainer.hpp
@@ -1,23 +1,25 @@
#ifndef _RPGPP_COLLISIONSCONTAINER_H
#define _RPGPP_COLLISIONSCONTAINER_H
-#include
#include
+#include
/** A container of collision tiles to be used by a Room */
class CollisionsContainer {
-private:
- /** A vector that contains the tile positions of the collision tiles */
- std::vector vec;
-public:
- /** Empty constructor */
- CollisionsContainer();
- /** Add a collision tile to this container */
- void addCollisionTile(int x, int y);
- /** Remove a collision tile by its tile position */
- void removeCollisionTile(int x, int y);
- /** Get a reference to this container's vector. Items are tile positions of the collision tiles. */
- const std::vector& getVector();
+ private:
+ /** A vector that contains the tile positions of the collision tiles */
+ std::vector vec;
+
+ public:
+ /** Empty constructor */
+ CollisionsContainer();
+ /** Add a collision tile to this container */
+ void addCollisionTile(int x, int y);
+ /** Remove a collision tile by its tile position */
+ void removeCollisionTile(int x, int y);
+ /** Get a reference to this container's vector. Items are tile positions of
+ * the collision tiles. */
+ const std::vector &getVector() const;
};
#endif
\ No newline at end of file
diff --git a/include/colorRect.hpp b/include/colorRect.hpp
index 7d9c7a1..8022a3e 100644
--- a/include/colorRect.hpp
+++ b/include/colorRect.hpp
@@ -1,19 +1,21 @@
#ifndef _RPGPP_COLORRECT_H
#define _RPGPP_COLORRECT_H
-#include
#include "uiElement.hpp"
+#include
class ColorRect : public UIElement {
-private:
- Rectangle rect;
- Color color;
-public:
- ColorRect();
- ColorRect(Rectangle rect);
- void setColor(Color newColor);
- void update() override;
- void draw() override;
+ private:
+ Rectangle rect;
+ Color color;
+
+ public:
+ ColorRect();
+
+ explicit ColorRect(Rectangle rect);
+ void setColor(Color newColor);
+ void update() override;
+ void draw() override;
};
#endif
diff --git a/include/constants/room.hpp b/include/constants/room.hpp
new file mode 100644
index 0000000..f30b48b
--- /dev/null
+++ b/include/constants/room.hpp
@@ -0,0 +1,13 @@
+enum class RoomLayer {
+ LAYER_TILES,
+ LAYER_COLLISION,
+ LAYER_INTERACTABLES,
+ LAYER_PROPS
+};
+enum class RoomTool {
+ TOOL_NONE,
+ TOOL_PLACE,
+ TOOL_ERASE,
+ TOOL_EDIT,
+ TOOL_STARTPOINT
+};
diff --git a/include/dialogue.hpp b/include/dialogue.hpp
new file mode 100644
index 0000000..38a18c2
--- /dev/null
+++ b/include/dialogue.hpp
@@ -0,0 +1,19 @@
+#ifndef _RPGPP_DIALOGUE
+#define _RPGPP_DIALOGUE
+
+#include "dialogueBalloon.hpp"
+#include "saveable.hpp"
+#include
+class Dialogue : public ISaveable {
+ private:
+ DialogueBin dialogueBin;
+
+ public:
+ Dialogue() = default;
+ Dialogue(const std::string &filePath);
+ DialogueLine addNewLine();
+ nlohmann::json dumpJson() override;
+ DialogueBin &getData();
+};
+
+#endif
\ No newline at end of file
diff --git a/include/dialogueBalloon.hpp b/include/dialogueBalloon.hpp
index b9c9406..0d2c0e6 100644
--- a/include/dialogueBalloon.hpp
+++ b/include/dialogueBalloon.hpp
@@ -1,13 +1,13 @@
#ifndef _RPGPP_DIALOGUEBALLOON_H
#define _RPGPP_DIALOGUEBALLOON_H
+#include
#include
#include
-#include
struct DialogueTextSection {
- std::string key;
- std::string text;
+ std::string key;
+ std::string text;
};
struct DialogueLine {
@@ -18,17 +18,17 @@ struct DialogueLine {
std::vector sections;
};
-struct Dialogue {
- std::string title;
+struct DialogueBin {
+ std::string title;
std::vector lines;
};
class DialogueBalloon {
-private:
+ private:
Rectangle rect;
Rectangle textRect;
Rectangle textPortraitRect;
- Dialogue dialogue;
+ DialogueBin dialogue;
std::string text;
DialogueTextSection sectionText;
bool firstCharTyped;
@@ -41,14 +41,15 @@ class DialogueBalloon {
int lastSectionLen;
Vector2 textPos;
void drawPortrait() const;
-public:
+
+ public:
DialogueBalloon();
DialogueBalloon(Rectangle rect);
void update();
void draw();
- void showDialogue(const Dialogue &newDialogue);
+ void showDialogue(const DialogueBin &newDialogue);
void hideDialogue();
- void charP(Vector2 charMeasure, const char* c, Color color);
+ void charP(Vector2 charMeasure, const char *c, Color color);
};
#endif
diff --git a/include/editor/dialogueParser.hpp b/include/dialogueParser.hpp
similarity index 65%
rename from include/editor/dialogueParser.hpp
rename to include/dialogueParser.hpp
index f36ad18..99f26ca 100644
--- a/include/editor/dialogueParser.hpp
+++ b/include/dialogueParser.hpp
@@ -1,12 +1,11 @@
#ifndef _RPGPP_EDITOR_DIALOGUEPARSER_H
#define _RPGPP_EDITOR_DIALOGUEPARSER_H
-#include
#include
#include
+#include
using json = nlohmann::json;
-Dialogue parseDialogueText(std::string text);
-json dialogueDumpJson(const Dialogue &diag);
+std::vector parseDialogueContent(const std::string &t);
-#endif
+#endif
\ No newline at end of file
diff --git a/include/editor/actions/action.hpp b/include/editor/actions/action.hpp
new file mode 100644
index 0000000..8a04ebf
--- /dev/null
+++ b/include/editor/actions/action.hpp
@@ -0,0 +1,12 @@
+#ifndef _RPGPP_ACTION_H
+#define _RPGPP_ACTION_H
+
+class Action {
+ public:
+ bool executeOnAdd = true;
+ Action() = default;
+ virtual void execute() {};
+ virtual void undo() {};
+};
+
+#endif
\ No newline at end of file
diff --git a/include/editor/actions/editTileAction.hpp b/include/editor/actions/editTileAction.hpp
new file mode 100644
index 0000000..9fc43af
--- /dev/null
+++ b/include/editor/actions/editTileAction.hpp
@@ -0,0 +1,17 @@
+#ifndef _RPGPP_EDITTILEACTION_H
+#define _RPGPP_EDITTILEACTION_H
+
+#include "mapAction.hpp"
+#include "views/tileSetView.hpp"
+
+class EditTileAction : public MapAction {
+ public:
+ EditTileAction(MapActionData a);
+ void execute() override;
+ void undo() override;
+
+ TileSetView *tileSetView;
+ void init();
+};
+
+#endif
diff --git a/include/editor/actions/eraseTileAction.hpp b/include/editor/actions/eraseTileAction.hpp
new file mode 100644
index 0000000..54716f0
--- /dev/null
+++ b/include/editor/actions/eraseTileAction.hpp
@@ -0,0 +1,13 @@
+#ifndef _RPGPP_ERASETILEACTION_H
+#define _RPGPP_ERASETILEACTION_H
+
+#include "mapAction.hpp"
+
+class EraseTileAction : public MapAction {
+ public:
+ EraseTileAction(MapActionData data);
+ void execute() override;
+ void undo() override;
+};
+
+#endif
diff --git a/include/editor/actions/mapAction.hpp b/include/editor/actions/mapAction.hpp
new file mode 100644
index 0000000..5436041
--- /dev/null
+++ b/include/editor/actions/mapAction.hpp
@@ -0,0 +1,32 @@
+#ifndef _RPGPP_MAPACTION_H
+#define _RPGPP_MAPACTION_H
+
+#include "action.hpp"
+#include "room.hpp"
+#include "views/roomView.hpp"
+#include
+#include
+#include
+
+struct MapActionData {
+ RoomView *view;
+ Room *room;
+ RoomLayer layer;
+ std::string interactable;
+ std::string interactableFullPath;
+ Vector2 worldTile;
+ Vector2 tile;
+ Vector2 prevTile;
+};
+
+class MapAction : public Action {
+ public:
+ std::unique_ptr prevRoom;
+ MapAction(MapActionData a) {
+ data = a;
+ prevRoom.reset(std::move(a.room));
+ }
+ MapActionData data;
+};
+
+#endif
diff --git a/include/editor/actions/placeTileAction.hpp b/include/editor/actions/placeTileAction.hpp
new file mode 100644
index 0000000..433d8fa
--- /dev/null
+++ b/include/editor/actions/placeTileAction.hpp
@@ -0,0 +1,13 @@
+#ifndef _RPGPP_PLACETILEACTION_H
+#define _RPGPP_PLACETILEACTION_H
+
+#include "mapAction.hpp"
+
+class PlaceTileAction : public MapAction {
+ public:
+ PlaceTileAction(MapActionData a);
+ void execute() override;
+ void undo() override;
+};
+
+#endif
diff --git a/include/editor/actions/startPointAction.hpp b/include/editor/actions/startPointAction.hpp
new file mode 100644
index 0000000..4e87c37
--- /dev/null
+++ b/include/editor/actions/startPointAction.hpp
@@ -0,0 +1,12 @@
+#ifndef _RPGPP_STARTPOINTACTION_H
+#define _RPGPP_STARTPOINTACTION_H
+
+#include "actions/mapAction.hpp"
+class StartPointAction : public MapAction {
+ public:
+ StartPointAction(MapActionData data);
+ void execute() override;
+ void undo() override;
+};
+
+#endif
\ No newline at end of file
diff --git a/include/editor/actorInfoPanel.hpp b/include/editor/actorInfoPanel.hpp
deleted file mode 100644
index 3cba444..0000000
--- a/include/editor/actorInfoPanel.hpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef _RPGPP_EDITOR_ACTORINFOPANEL_H
-#define _RPGPP_EDITOR_ACTORINFOPANEL_H
-
-#include "worldViewBox.hpp"
-#include
-
-class ActorInfoPanel {
-private:
- Rectangle rect;
- RoomAction action;
- std::string actorConcat;
- int currentActor;
-public:
- ActorInfoPanel();
- ActorInfoPanel(Rectangle rect);
- void setRect(Rectangle rect);
- void setActionMode(RoomAction action);
- int getCurrentActorIndex() const;
- void update() const;
- void draw();
-};
-
-#endif
diff --git a/include/editor/actorPanelView.hpp b/include/editor/actorPanelView.hpp
deleted file mode 100644
index a09a68e..0000000
--- a/include/editor/actorPanelView.hpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef _RPGPP_EDITOR_ACTORPANELVIEW_H
-#define _RPGPP_EDITOR_ACTORPANELVIEW_H
-
-#include
-#include "actorView.hpp"
-#include "propertiesBox.hpp"
-#include "animationsView.hpp"
-
-class ActorPanelView {
-private:
- Rectangle rect;
- ActorView actorView;
- PropertiesBox props;
- AnimationsView animationsView;
-public:
- ActorPanelView();
- ActorPanelView(Rectangle rect);
- void setRect(Rectangle rect);
- void setInitial();
- void update();
- void draw();
-};
-
-#endif
\ No newline at end of file
diff --git a/include/editor/actorPropertiesBox.hpp b/include/editor/actorPropertiesBox.hpp
deleted file mode 100644
index c4fc6a5..0000000
--- a/include/editor/actorPropertiesBox.hpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef _RPGPP_EDITOR_ACTORPROPERTIESBOX_H
-#define _RPGPP_EDITOR_ACTORPROPERTIESBOX_H
-
-#include "actor.hpp"
-#include
-
-class ActorPropertiesBox {
-private:
- Rectangle rect;
- Vector2 scrollVec;
- Rectangle viewRec;
- Actor* actor;
- bool collisionViewActive;
-public:
- ActorPropertiesBox();
- ActorPropertiesBox(Rectangle rect);
- void setDefaults();
- void update();
- void draw();
- bool getCollisionViewActive();
-};
-
-#endif
\ No newline at end of file
diff --git a/include/editor/actorView.hpp b/include/editor/actorView.hpp
deleted file mode 100644
index c111b19..0000000
--- a/include/editor/actorView.hpp
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef _RPGPP_EDITOR_ACTORVIEW_H
-#define _RPGPP_EDITOR_ACTORVIEW_H
-
-#include
-#include
-#include
-#include "mouseInput.hpp"
-#include "collisionbox.hpp"
-
-class ActorView {
-private:
- int frameCounter;
- Rectangle rect;
- Rectangle renderRect;
- RenderTexture2D renderTexture;
- Camera2D camera;
- Vector2 mouseWorldPos;
- CollisionBox collisionBox;
- bool collisionViewActive;
- int currentAnim;
- int currentFrame;
- std::vector currentAnimFrames;
- bool animPlaying;
- Rectangle actorRect;
- void drawActor();
-public:
- ActorView();
- ActorView(Rectangle rect);
- void setRect(Rectangle rect);
- void setInitial();
- void updateData();
- void update();
- void draw();
- void setCollisionActive(bool value);
- void setAnimation(int id);
- void setAnimPlaying(bool value);
- void setFrame(int frame);
- int getFrame();
-};
-
-#endif
diff --git a/include/editor/animationsView.hpp b/include/editor/animationsView.hpp
deleted file mode 100644
index 04d767b..0000000
--- a/include/editor/animationsView.hpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef _RPGPP_EDITOR_ANIMATIONSVIEW_H
-#define _RPGPP_EDITOR_ANIMATIONSVIEW_H
-
-#include
-#include
-#include
-#include "actor.hpp"
-#include "actorView.hpp"
-
-class AnimationsView {
-private:
- ActorView* actorView;
- Rectangle rect;
- bool animDropdownActive;
- bool animDropdownEditMode;
- int currentAnim;
- bool animPlaying;
- std::vector animFrames;
- std::vector animNames;
-public:
- AnimationsView();
- AnimationsView(Rectangle rect);
- void setRect(Rectangle rect);
- void update();
- void draw();
- void setActorView(ActorView* actorView);
- int getCurrentAnim();
- bool getAnimPlaying();
-};
-
-#endif
\ No newline at end of file
diff --git a/include/editor/bindTranslation.hpp b/include/editor/bindTranslation.hpp
new file mode 100644
index 0000000..838448d
--- /dev/null
+++ b/include/editor/bindTranslation.hpp
@@ -0,0 +1,65 @@
+#include "editor.hpp"
+#include "services/translationService.hpp"
+#include
+#include
+
+class TSConnection {
+ public:
+ TSConnection(TranslationService::ListenerID id) : id(id) {}
+ ~TSConnection() { Editor::instance->getTranslations().removeListener(id); }
+
+ private:
+ TranslationService::ListenerID id;
+};
+
+template
+void bindTranslation(std::shared_ptr widget, const std::string &key,
+ void (WidgetType::*setter)(const tgui::String &)) {
+ auto &ts = Editor::instance->getTranslations();
+ std::weak_ptr weakWidget = widget;
+
+ // Initial set
+ (widget.get()->*setter)(ts.getKey(key));
+
+ auto id = ts.addListener(
+ [weakWidget, key, setter](TranslationService &ts,
+ TranslationService::ListenerID id,
+ bool checkingAlive) {
+ if (auto w = weakWidget.lock()) {
+ if (!checkingAlive)
+ (w.get()->*setter)(ts.getKey(key));
+ return true;
+ } else {
+ return false;
+ }
+ });
+
+ // TODO: Implement a cleaner way to detect when the widget is destroyed, and
+ // call
+ // Editor::instance->getTranslations().removeListener(id);
+ // There's currently an issue on TGUI's repo to add support for callback
+ // when a widget gets destroyed https://github.com/texus/TGUI/issues/326
+}
+
+template
+void bindCustomTranslation(
+ std::shared_ptr widget,
+ std::function widget,
+ TranslationService &)>
+ cb) {
+ auto &ts = Editor::instance->getTranslations();
+ std::weak_ptr weakWidget = widget;
+
+ cb(widget, ts);
+ auto id = ts.addListener([weakWidget, cb](TranslationService &ts,
+ TranslationService::ListenerID id,
+ bool checkingAlive) {
+ if (auto w = weakWidget.lock()) {
+ if (!checkingAlive)
+ cb(w, ts);
+ return true;
+ } else {
+ return false;
+ }
+ });
+}
diff --git a/include/editor/childWindows/aboutWindow.hpp b/include/editor/childWindows/aboutWindow.hpp
new file mode 100644
index 0000000..99c58d7
--- /dev/null
+++ b/include/editor/childWindows/aboutWindow.hpp
@@ -0,0 +1,12 @@
+#ifndef RPGPP_ABOUTWINDOW_H
+#define RPGPP_ABOUTWINDOW_H
+
+#include "TGUI/Widgets/Label.hpp"
+#include "childWindows/popupWindow.hpp"
+#include
+class AboutWindow : public PopupWindow {
+ public:
+ AboutWindow(const std::string &title);
+};
+
+#endif /* RPGPP_ABOUTWINDOW_H */
diff --git a/include/editor/childWindows/popupWindow.hpp b/include/editor/childWindows/popupWindow.hpp
new file mode 100644
index 0000000..7ce23c6
--- /dev/null
+++ b/include/editor/childWindows/popupWindow.hpp
@@ -0,0 +1,18 @@
+#ifndef RPGPP_POPUPWINDOW_H
+#define RPGPP_POPUPWINDOW_H
+
+#include "TGUI/Widgets/ChildWindow.hpp"
+#include
+class PopupWindow {
+ public:
+ bool windowIsOpen = false;
+
+ tgui::ChildWindow::Ptr currentWindow;
+ PopupWindow(const std::string &title);
+ ~PopupWindow() { close(); };
+
+ void open();
+ void close();
+};
+
+#endif /* RPGPP_POPUPWINDOW_H */
diff --git a/include/editor/childWindows/settingsWindow.hpp b/include/editor/childWindows/settingsWindow.hpp
new file mode 100644
index 0000000..3d82ccf
--- /dev/null
+++ b/include/editor/childWindows/settingsWindow.hpp
@@ -0,0 +1,10 @@
+#ifndef RPGPP_SETTINGSWINDOW_H
+#define RPGPP_SETTINGSWINDOW_H
+
+#include "childWindows/popupWindow.hpp"
+class SettingsWindow : public PopupWindow {
+ public:
+ SettingsWindow(const std::string &title);
+};
+
+#endif /* RPGPP_SETTINGSWINDOW_H */
diff --git a/include/editor/collisionInfoPanel.hpp b/include/editor/collisionInfoPanel.hpp
deleted file mode 100644
index 3dc7300..0000000
--- a/include/editor/collisionInfoPanel.hpp
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef _RPGPP_EDITOR_COLLISIONINFOPANEL_H
-#define _RPGPP_EDITOR_COLLISIONINFOPANEL_H
-
-#include
-#include "worldViewBox.hpp"
-
-class CollisionInfoPanel {
-private:
- Rectangle rect;
- RoomAction action;
-public:
- CollisionInfoPanel();
- CollisionInfoPanel(Rectangle rect);
- void setRect(Rectangle rect);
- void draw();
- void setActionMode(RoomAction mode);
-};
-
-#endif
\ No newline at end of file
diff --git a/include/editor/collisionbox.hpp b/include/editor/collisionbox.hpp
deleted file mode 100644
index ca70ee7..0000000
--- a/include/editor/collisionbox.hpp
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef _RPGPP_EDITOR_COLLISIONBOX_H
-#define _RPGPP_EDITOR_COLLISIONBOX_H
-
-#include
-
-enum ResizeMode {
- RESIZE_TOP_LEFT, RESIZE_TOP_RIGHT, RESIZE_BOTTOM_LEFT, RESIZE_BOTTOM_RIGHT, RESIZE_MOVE
-};
-
-class CollisionBox {
-private:
- Rectangle rect;
- Vector2 mouseWorldPos;
- Rectangle topLeft;
- Rectangle topRight;
- Rectangle bottomLeft;
- Rectangle bottomRight;
- Vector2 oldMousePos;
- Rectangle newRect;
- Vector2 mouseOffset;
- ResizeMode resizeMode;
- Vector2 mouseDelta;
- bool holdingMouse;
-public:
- CollisionBox();
- CollisionBox(Rectangle rect);
- void setMouseWorldPos(Vector2 pos);
- void setRect(Rectangle rect);
- Rectangle getRect();
- void update();
- void draw();
-};
-
-#endif
\ No newline at end of file
diff --git a/include/editor/components/frameButton.hpp b/include/editor/components/frameButton.hpp
new file mode 100644
index 0000000..456d750
--- /dev/null
+++ b/include/editor/components/frameButton.hpp
@@ -0,0 +1,29 @@
+#ifndef RPGPP_FRAMEBUTTON_H
+#define RPGPP_FRAMEBUTTON_H
+
+#include "TGUI/Signal.hpp"
+#include "TGUI/Sprite.hpp"
+#include "TGUI/Widgets/Button.hpp"
+#include "actor.hpp"
+#include
+class FrameButton : public tgui::Button {
+ private:
+ int frameIndex;
+ Actor *actor;
+ tgui::Sprite sprite{};
+
+ public:
+ FrameButton(int frameIndex, Actor *actor);
+
+ typedef std::shared_ptr Ptr;
+ static FrameButton::Ptr create(int frameIndex, Actor *actor);
+
+ void draw(tgui::BackendRenderTarget &target,
+ tgui::RenderStates states) const override;
+ void updateSprite(bool reImport = false);
+
+ // When the frame button is pressed. Optional parameters: frame index
+ tgui::SignalInt onFrameChange = {"OnFrameChange"};
+};
+
+#endif // RPGPP_FRAMEBUTTON_H
diff --git a/include/editor/components/perfOverlay.hpp b/include/editor/components/perfOverlay.hpp
new file mode 100644
index 0000000..26dd8b6
--- /dev/null
+++ b/include/editor/components/perfOverlay.hpp
@@ -0,0 +1,35 @@
+#ifndef _RPGPP_PERFOVERLAY_H
+#define _RPGPP_PERFOVERLAY_H
+#include "raylib.h"
+
+class PerformanceOverlay {
+ public:
+ PerformanceOverlay();
+
+ void Update();
+ void Draw(int x, int y, int w = 420, int h = 120);
+
+ void Toggle();
+ bool IsEnabled() const;
+
+ private:
+ bool enabled{false};
+ static const int SAMPLE_COUNT = 240;
+
+ float samples[SAMPLE_COUNT];
+ int index;
+
+ float minTime;
+ float avgTime;
+ float maxTime;
+
+ float graphMax;
+ float spikeThreshold;
+
+ void ComputeStats();
+ void UpdateScaling();
+ void DrawFPSLine(float ms, int x, int y, int w, int h, Color color);
+ void DrawLegend(int x, int y);
+ ;
+};
+#endif
diff --git a/include/editor/components/resizableCanvasBox.hpp b/include/editor/components/resizableCanvasBox.hpp
new file mode 100644
index 0000000..741b67c
--- /dev/null
+++ b/include/editor/components/resizableCanvasBox.hpp
@@ -0,0 +1,54 @@
+#ifndef RPGPP_RESIZABLECANVASBOX_H
+#define RPGPP_RESIZABLECANVASBOX_H
+#include "raylib.h"
+#include
+
+enum ResizeDirection {
+ NONE = 0,
+ MOVE = 1 << 0,
+ TOP = 1 << 1,
+ BOTTOM = 1 << 2,
+ LEFT = 1 << 3,
+ RIGHT = 1 << 4
+};
+
+class ResizableCanvasBox {
+ public:
+ ResizableCanvasBox(std::string id, float x, float y, float width,
+ float height, Color color, bool isResizable = true);
+ ResizableCanvasBox(std::string id, Rectangle rec, Color color,
+ bool isResizable = true);
+ void draw();
+
+ // @returns true if the box was clicked, false otherwise
+ bool leftMousePressed(Vector2 mousePos);
+ void mouseMoved(Vector2 mousePos, int snapWidth = 1, int snapHeight = 1);
+ // @returns the new rectangle after the mouse is released
+ Rectangle leftMouseReleased(Vector2 mousePos);
+
+ void updatePosition(float x, float y);
+ void updateSize(float width, float height);
+ void updateColor(Color color);
+
+ void updateRec(Rectangle rec);
+ bool focused = false;
+ std::string id{};
+
+ void setMinSize(float size) { minSize = std::max(size, 2.f); }
+ float getMinSize() const { return minSize; }
+
+ private:
+ const float RESIZE_MARGIN = 1.f;
+ float minSize = 2.f;
+ bool isResizable = true;
+
+ float x, y, width, height;
+ Color color = RED;
+
+ bool isResizing = false;
+ Vector2 startMousePos{};
+ float prevX = 0, prevY = 0, prevWidth = 0, prevHeight = 0;
+ int resizeDirection = NONE;
+};
+
+#endif
diff --git a/include/editor/components/resizableContainer.hpp b/include/editor/components/resizableContainer.hpp
new file mode 100644
index 0000000..98609f6
--- /dev/null
+++ b/include/editor/components/resizableContainer.hpp
@@ -0,0 +1,73 @@
+#ifndef RPGPP_RESIZABLECONTAINER_H
+#define RPGPP_RESIZABLECONTAINER_H
+#include "TGUI/Layout.hpp"
+#include "TGUI/Signal.hpp"
+#include "TGUI/Vector2.hpp"
+#include "TGUI/Widgets/Group.hpp"
+
+enum class ResizeDirection {
+ MOVE = 0,
+ LEFT = 1 << 0,
+ RIGHT = 1 << 1,
+ TOP = 1 << 2,
+ BOTTOM = 1 << 3
+};
+
+class ResizableContainer : public tgui::Group {
+ private:
+ char resizeFlags = 0;
+ int grabberSize = 15;
+ int maxResizeWidth = 0;
+ int maxResizeHeight = 0;
+ int minResizeWidth = 0;
+ int minResizeHeight = 0;
+
+ char grabbingFlag = 0;
+ tgui::Vector2f startMousePos;
+ tgui::Layout2d startSize;
+ tgui::Layout2d startPosition;
+ bool isGrabbing = false;
+ bool cursorModified = false;
+
+ bool inEnabledGrabber(ResizeDirection direction,
+ tgui::Vector2f absolutePos);
+
+ public:
+ ResizableContainer(const tgui::Layout2d &size,
+ const tgui::Layout2d &position);
+ void enableResize(ResizeDirection direction);
+ void disableResize(ResizeDirection direction);
+ bool isResizable(ResizeDirection direction);
+
+ void setMaxResizeWidth(int width);
+ void setMaxResizeHeight(int height);
+ int getMaxResizeWidth();
+ int getMaxResizeHeight();
+ void setMinResizeWidth(int width);
+ void setMinResizeHeight(int height);
+ int getMinResizeWidth();
+ int getMinResizeHeight();
+ void setGrabberSize(int size);
+ int getGrabberSize();
+
+ typedef std::shared_ptr Ptr;
+ typedef std::shared_ptr ConstPtr;
+
+ static ResizableContainer::Ptr create(const tgui::Layout2d &size,
+ const tgui::Layout2d &position);
+ static ResizableContainer::Ptr copy(ResizableContainer::ConstPtr widget);
+
+ bool useExternalMouseEvent = false;
+ void mouseMoved(tgui::Vector2f pos) override;
+ void manualMouseMoved(tgui::Vector2f pos);
+ bool leftMousePressed(tgui::Vector2f pos) override;
+ void manualLeftMouseReleased(tgui::Vector2f pos);
+ void leftMouseReleased(tgui::Vector2f pos) override;
+
+ tgui::SignalTyped onResize = {"OnResize"};
+
+ protected:
+ tgui::Widget::Ptr clone() const override;
+};
+
+#endif // RPGPP_RESIZABLECONTAINER_H
diff --git a/include/editor/components/tooltip.hpp b/include/editor/components/tooltip.hpp
new file mode 100644
index 0000000..161021d
--- /dev/null
+++ b/include/editor/components/tooltip.hpp
@@ -0,0 +1,18 @@
+#ifndef RPGPP_TOOLTIP_H
+#define RPGPP_TOOLTIP_H
+
+#include "TGUI/Widgets/Label.hpp"
+class Tooltip : public tgui::Label {
+ public:
+ Tooltip(const std::string &text);
+ typedef std::shared_ptr Ptr;
+ typedef std::shared_ptr ConstPtr;
+
+ static Ptr create(const std::string &text);
+ static Ptr copy(ConstPtr widget);
+
+ protected:
+ tgui::Widget::Ptr clone() const override;
+};
+
+#endif
diff --git a/include/editor/dialoguePanelView.hpp b/include/editor/dialoguePanelView.hpp
deleted file mode 100644
index ad2b2a5..0000000
--- a/include/editor/dialoguePanelView.hpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef _RPGPP_EDITOR_DIALOGUEPANELVIEW_H
-#define _RPGPP_EDITOR_DIALOGUEPANELVIEW_H
-
-#include "dialogueViewer.hpp"
-#include
-
-class DialoguePanelView {
-private:
- Rectangle rect;
- DialogueViewer view;
-public:
- DialoguePanelView();
- DialoguePanelView(Rectangle rect);
- void setInitial();
- void setRect(Rectangle rect);
- void update();
- void draw();
-};
-
-#endif
diff --git a/include/editor/dialogueViewer.hpp b/include/editor/dialogueViewer.hpp
deleted file mode 100644
index 7005931..0000000
--- a/include/editor/dialogueViewer.hpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef _RPGPP_EDITOR_DIALOGUEVIEWER_H
-#define _RPGPP_EDITOR_DIALOGUEVIEWER_H
-
-#include