forked from storm-devs/storm-engine
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from PiratesAhoy/feature/editor
Implement in-game editor
- Loading branch information
Showing
26 changed files
with
467 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ STORM_SETUP( | |
sentry-native | ||
${SDL2_LIBRARIES} | ||
zlib | ||
cli11 | ||
|
||
# system | ||
${SYSTEM_DEPS} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
STORM_SETUP( | ||
TARGET_NAME core | ||
TYPE library | ||
DEPENDENCIES diagnostics math shared_headers steam_api fast_float ${SDL2_LIBRARIES} window tomlplusplus nlohmann_json | ||
DEPENDENCIES diagnostics editor math shared_headers steam_api fast_float ${SDL2_LIBRARIES} window tomlplusplus nlohmann_json | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,8 @@ class Entity | |
return {}; | ||
} | ||
|
||
virtual void ShowEditor(); | ||
|
||
private: | ||
EntitySelfData data_{}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include "entity.h" | ||
|
||
#include <imgui.h> | ||
|
||
void Entity::ShowEditor() | ||
{ | ||
ImGui::Text("Selected entity does not expose any properties"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
if (NOT WIN32) | ||
set(SYSTEM_DEPS "${NATIVE_D3D9_LIBS}") | ||
endif() | ||
|
||
set(IMGUI_BINGINDS_DIR "${CMAKE_BINARY_DIR}/imgui") | ||
|
||
add_library(imgui_backend STATIC | ||
"${IMGUI_BINGINDS_DIR}/imgui_impl_sdl2.cpp" | ||
) | ||
if (WIN32) | ||
target_sources(imgui_backend PRIVATE "${IMGUI_BINGINDS_DIR}/imgui_impl_dx9.cpp") | ||
endif() | ||
|
||
target_include_directories(imgui_backend PUBLIC ${IMGUI_BINGINDS_DIR}) | ||
target_link_libraries(imgui_backend PUBLIC imgui ${SDL2_LIBRARIES} ${SYSTEM_DEPS}) | ||
|
||
STORM_SETUP( | ||
TARGET_NAME editor | ||
TYPE storm_module | ||
DEPENDENCIES core imgui_backend | ||
TEST_DEPENDENCIES catch2 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#pragma once | ||
|
||
#include <functional> | ||
#include <memory> | ||
#include <string_view> | ||
|
||
struct SDL_Window; | ||
union SDL_Event; | ||
struct IDirect3DDevice9; | ||
|
||
namespace storm::editor | ||
{ | ||
|
||
enum class DebugFlag | ||
{ | ||
RenderWireframe, | ||
SoundDebug, | ||
LocationDebug, | ||
ExtendedLocationDebug, | ||
CannonDebug, | ||
}; | ||
|
||
using EditorToolCallback = std::function<void(bool &active)>; | ||
|
||
class EngineEditor final | ||
{ | ||
public: | ||
explicit EngineEditor(SDL_Window *window, IDirect3DDevice9 *device); | ||
~EngineEditor(); | ||
|
||
void StartFrame(); | ||
void EndFrame(); | ||
|
||
void ProcessEvent(SDL_Event &event); | ||
|
||
bool IsFocused() const; | ||
|
||
bool IsDebugFlagEnabled(DebugFlag flag) const; | ||
|
||
static void RegisterEditorTool(const std::string_view &title, EditorToolCallback callback); | ||
|
||
private: | ||
class Impl; | ||
|
||
std::unique_ptr<Impl> impl_; | ||
}; | ||
|
||
} // namespace storm::editor |
Oops, something went wrong.