5 Commits

Author SHA1 Message Date
9b173c64a6 add pkg-config fallback and imported target to sdl find module 2023-10-31 17:06:11 +01:00
3a885ee250 update entt to v3.12.2 2023-09-07 01:51:33 +02:00
00e48f9967 update spdlog to v1.12.0 2023-09-05 11:56:50 +02:00
c791f4c6a1 fix print formatter 2023-09-04 23:46:12 +02:00
7a3823db78 update ImGui to v1.89.9
and reenable obsolte bc of text editor (temp, will be replaced)
2023-09-04 20:57:00 +02:00
9 changed files with 95 additions and 85 deletions

View File

@ -14,7 +14,7 @@ env:
jobs:
linux:
timeout-minutes: 10
timeout-minutes: 15
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.

View File

@ -105,7 +105,7 @@
if(NOT EMSCRIPTEN)
FIND_PATH(SDL2_INCLUDE_DIR SDL.h
FIND_PATH(SDL2_INCLUDE_DIR_TEMP SDL.h
HINTS
$ENV{SDL2}
PATH_SUFFIXES include/SDL2 include SDL2
@ -153,7 +153,7 @@ ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8)
ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
IF(NOT SDL2_BUILDING_LIBRARY)
IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
IF(NOT "${SDL2_INCLUDE_DIR_TEMP}" MATCHES ".framework")
# Non-OS X framework versions expect you to also dynamically link to
# SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms
# seem to provide SDL2main for compatibility even though they don't
@ -189,7 +189,7 @@ IF(NOT SDL2_BUILDING_LIBRARY)
/opt
)
ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
ENDIF(NOT "${SDL2_INCLUDE_DIR_TEMP}" MATCHES ".framework")
ENDIF(NOT SDL2_BUILDING_LIBRARY)
# SDL2 may require threads on your system.
@ -208,58 +208,67 @@ IF(MINGW)
ENDIF(MINGW)
SET(SDL2_FOUND "NO")
IF(SDL2_LIBRARY_TEMP)
# For SDL2main
IF(NOT SDL2_BUILDING_LIBRARY)
IF(SDL2MAIN_LIBRARY)
SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP})
ENDIF(SDL2MAIN_LIBRARY)
ENDIF(NOT SDL2_BUILDING_LIBRARY)
IF(SDL2_LIBRARY_TEMP)
# For SDL2main
IF(NOT SDL2_BUILDING_LIBRARY)
IF(SDL2MAIN_LIBRARY)
SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP})
ENDIF(SDL2MAIN_LIBRARY)
ENDIF(NOT SDL2_BUILDING_LIBRARY)
# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
# CMake doesn't display the -framework Cocoa string in the UI even
# though it actually is there if I modify a pre-used variable.
# I think it has something to do with the CACHE STRING.
# So I use a temporary variable until the end so I can set the
# "real" variable in one-shot.
IF(APPLE)
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
ENDIF(APPLE)
# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
# CMake doesn't display the -framework Cocoa string in the UI even
# though it actually is there if I modify a pre-used variable.
# I think it has something to do with the CACHE STRING.
# So I use a temporary variable until the end so I can set the
# "real" variable in one-shot.
IF(APPLE)
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
ENDIF(APPLE)
# For threads, as mentioned Apple doesn't need this.
# In fact, there seems to be a problem if I used the Threads package
# and try using this line, so I'm just skipping it entirely for OS X.
IF(NOT APPLE)
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
ENDIF(NOT APPLE)
# For threads, as mentioned Apple doesn't need this.
# In fact, there seems to be a problem if I used the Threads package
# and try using this line, so I'm just skipping it entirely for OS X.
IF(NOT APPLE)
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
ENDIF(NOT APPLE)
# For MinGW library
IF(MINGW)
SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
ENDIF(MINGW)
# For MinGW library
IF(MINGW)
SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
ENDIF(MINGW)
# Set the final string here so the GUI reflects the final state.
SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
# Set the final string here so the GUI reflects the final state.
SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
############add_library(SDL UNKNOWN IMPORTED)
#target_link_libraries(SDL INTERFACE ${SDL2_LIBRARY})
#target_include_directories(SDL INTERFACE ${SDL2_INCLUDE_DIR})
#set_target_properties(SDL PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES "${SDL2_LIBRARY}")
set(SDL2_INCLUDE_DIR ${SDL2_INCLUDE_DIR_TEMP} CACHE STRING "Where the SDL2 Headers can be found")
SET(SDL2_INCLUDE_DIR_TEMP "${SDL2_INCLUDE_DIR_TEMP}" CACHE INTERNAL "")
#set_target_properties(SDL PROPERTIES
#INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}")
SET(SDL2_FOUND "YES")
else() # SDL2_LIBRARY_TEMP
# try to pkg-config fallback
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(PKG_C_SDL2 QUIET sdl2)
if (PKG_C_SDL2_FOUND)
SET(SDL2_LIBRARY_TEMP ${PKG_C_SDL2_LIBRARIES})
SET(SDL2_INCLUDE_DIR_TEMP ${PKG_C_SDL2_INCLUDE_DIRS})
#set_target_properties(SDL PROPERTIES
#IMPORTED_LINK_INTERFACE_LANGUAGES "C"
#IMPORTED_LINK_INTERFACE_LIBRARIES "${SDL2_LIBRARY}"
#LINK_INTERFACE_LIBRARIES "${SDL2_LIBRARY}")
# Set the final string here so the GUI reflects the final state.
SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
#IMPORTED_LOCATION "${SDL2_LIBRARY}")
set(SDL2_INCLUDE_DIR ${SDL2_INCLUDE_DIR_TEMP} CACHE STRING "Where the SDL2 Headers can be found")
SET(SDL2_INCLUDE_DIR_TEMP "${SDL2_INCLUDE_DIR_TEMP}" CACHE INTERNAL "")
#message("II set include dir to ${SDL2_INCLUDE_DIR}")
SET(SDL2_FOUND "YES")
SET(SDL2_FOUND "YES")
endif()
endif()
ENDIF(SDL2_LIBRARY_TEMP)
else() #emsripten
@ -288,4 +297,11 @@ INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR)
if (SDL2_FOUND)
if (NOT TARGET SDL2::SDL2)
add_library(SDL2::SDL2 INTERFACE IMPORTED)
target_include_directories(SDL2::SDL2 INTERFACE ${SDL2_INCLUDE_DIR})
target_link_libraries(SDL2::SDL2 INTERFACE ${SDL2_LIBRARY})
endif()
endif()

2
external/entt vendored

View File

@ -41,7 +41,7 @@ target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
#target_include_directories(imgui PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/imgui")
target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/imgui") # im sad
target_compile_definitions(imgui PUBLIC IMGUI_DISABLE_OBSOLETE_FUNCTIONS=1)
#target_compile_definitions(imgui PUBLIC IMGUI_DISABLE_OBSOLETE_FUNCTIONS=1) # more sad
if(EMSCRIPTEN)
target_compile_options(imgui PUBLIC -sUSE_SDL=2)

View File

@ -134,10 +134,10 @@ public:
e = registry.create();
// create a copy of an entity component by component
for (auto &&curr: registry.storage()) {
if (auto &storage = curr.second; storage.contains(old_e)) {
for(auto &&curr: registry.storage()) {
if(auto &storage = curr.second; storage.contains(old_e)) {
// TODO: do something with the return value. returns false on failure.
storage.emplace(e, storage.get(old_e));
storage.push(e, storage.value(old_e));
}
}
}
@ -237,11 +237,11 @@ public:
if (comp_list.empty()) {
ImGui::Text("Orphans:");
registry.each([&registry](auto e){
for (EntityType e : registry.template storage<EntityType>()) {
if (registry.orphan(e)) {
MM_IEEE_ENTITY_WIDGET(e, registry, false);
}
});
}
} else {
entt::runtime_view view{};
for (const auto type : comp_list) {
@ -264,17 +264,6 @@ public:
}
}
[[deprecated("Use renderEditor() instead. And manage the window yourself.")]]
void render(Registry& registry, EntityType& e)
{
if (show_window) {
if (ImGui::Begin("Entity Editor", &show_window)) {
renderEditor(registry, e);
}
ImGui::End();
}
}
// displays both, editor and list
// uses static internally, use only as a quick way to get going!
void renderSimpleCombo(Registry& registry, EntityType& e)

View File

@ -4,6 +4,7 @@
#include <imgui.h>
#include <nlohmann/json.hpp>
#include <imgui/misc/cpp/imgui_stdlib.h>
#include <cinttypes>
namespace MM::ImGuiWidgets {
@ -55,16 +56,16 @@ void JsonViewerSimple(const char* name, const JsonObjectType& json) {
}
break;
case JsonObjectType::value_t::number_integer:
ImGui::TextColored(int_color, "%ld", json.template get<int64_t>());
ImGui::TextColored(int_color, "%" PRId64, json.template get<int64_t>());
break;
case JsonObjectType::value_t::number_unsigned:
ImGui::TextColored(unsigned_color, "%lu", json.template get<uint64_t>());
ImGui::TextColored(unsigned_color, "%" PRIu64, json.template get<uint64_t>());
break;
case JsonObjectType::value_t::number_float:
ImGui::TextColored(float_color, "%f", json.template get<float>());
break;
case JsonObjectType::value_t::object:
ImGui::TextDisabled("{%d}", json.size());
ImGui::TextDisabled("{%zu}", json.size());
ImGui::Indent();
for (auto& [key, value] : json.items()) {
@ -74,7 +75,7 @@ void JsonViewerSimple(const char* name, const JsonObjectType& json) {
break;
case JsonObjectType::value_t::array:
ImGui::TextDisabled("[%d]", json.size());
ImGui::TextDisabled("[%zu]", json.size());
ImGui::Indent();
for (auto& [key, value] : json.items()) {
@ -103,9 +104,9 @@ void JsonViewerTree(const char* name, const JsonObjectType& json) {
ImGui::SameLine();
if (json.is_object()) {
ImGui::TextDisabled("{%d}", json.size());
ImGui::TextDisabled("{%zu}", json.size());
} else { // is_array()
ImGui::TextDisabled("[%d]", json.size());
ImGui::TextDisabled("[%zu]", json.size());
}
if (tree_open) {
@ -143,10 +144,10 @@ void JsonViewerTree(const char* name, const JsonObjectType& json) {
}
break;
case JsonObjectType::value_t::number_integer:
ImGui::TextColored(int_color, "%ld", json.template get<int64_t>());
ImGui::TextColored(int_color, "%" PRId64, json.template get<int64_t>());
break;
case JsonObjectType::value_t::number_unsigned:
ImGui::TextColored(unsigned_color, "%lu", json.template get<uint64_t>());
ImGui::TextColored(unsigned_color, "%" PRIu64, json.template get<uint64_t>());
break;
case JsonObjectType::value_t::number_float:
ImGui::TextColored(float_color, "%f", json.template get<float>());
@ -200,9 +201,9 @@ void JsonEditor(const char* name, JsonObjectType& json) {
ImGui::SameLine();
if (json.is_object()) {
ImGui::TextDisabled("{%d}", json.size());
ImGui::TextDisabled("{%zu}", json.size());
} else { // is_array()
ImGui::TextDisabled("[%d]", json.size());
ImGui::TextDisabled("[%zu]", json.size());
}
if (tree_open) {

View File

@ -1,4 +1,5 @@
#include "./scene_tools.hpp"
#include "mm/engine_fwd.hpp"
#include <mm/engine.hpp>
@ -109,16 +110,19 @@ namespace MM::Services {
if (_show_scene_metrics) {
if (ImGui::Begin("Scene Metrics##ImGuiSceneToolsService", &_show_scene_metrics)) {
ImGui::Text("capacity: %lu", scene.capacity());
ImGui::Text("size: %lu", scene.size());
ImGui::Text("alive: %lu", scene.alive());
size_t orphans = 0;
scene.each([&orphans, &scene](auto entity) {
if (scene.orphan(entity)) {
orphans++;
ImGui::Text("capacity: %zu", scene.storage<::MM::Entity>().capacity());
ImGui::Text("size: %zu", scene.storage<::MM::Entity>().size());
ImGui::Text("alive: %zu", scene.storage<::MM::Entity>().in_use());
if (ImGui::CollapsingHeader("orphans")) {
// iterating all entities is expensive
size_t orphans = 0;
for (const auto it : scene.storage<MM::Entity>().each()) {
if (scene.orphan(std::get<0>(it))) {
orphans++;
}
}
});
ImGui::Text("orphans: %lu", orphans);
ImGui::Text("orphans: %lu", orphans);
}
}
ImGui::End();
}