diff --git a/code/addons/CMakeLists.txt b/code/addons/CMakeLists.txt index 4818d8c46..c8a61596e 100644 --- a/code/addons/CMakeLists.txt +++ b/code/addons/CMakeLists.txt @@ -11,4 +11,4 @@ add_subdirectory(scripting) #add_subdirectory(staticui) add_subdirectory(tinyxml) add_subdirectory(nsharp) -add_subdirectory(tbui) +add_addon(tbui) diff --git a/code/addons/graphicsfeature/CMakeLists.txt b/code/addons/graphicsfeature/CMakeLists.txt index 646a0cdf2..1f54dc9eb 100644 --- a/code/addons/graphicsfeature/CMakeLists.txt +++ b/code/addons/graphicsfeature/CMakeLists.txt @@ -1,6 +1,7 @@ nebula_begin_module(graphicsfeature) nebula_flatc(SYSTEM graphicsfeature/graphicsfeatureschema.fbs graphicsfeature/terrainschema.fbs graphicsfeature/vegetationschema.fbs) -fips_deps(render application dynui tbui nflatbuffer) +fips_deps(render application dynui nflatbuffer) +add_addon_hook(tbui) target_precompile_headers(graphicsfeature PRIVATE ) fips_ide_group(features) fips_files( diff --git a/code/addons/graphicsfeature/graphicsfeatureunit.cc b/code/addons/graphicsfeature/graphicsfeatureunit.cc index 3c6c8547c..7069b22ed 100644 --- a/code/addons/graphicsfeature/graphicsfeatureunit.cc +++ b/code/addons/graphicsfeature/graphicsfeatureunit.cc @@ -9,7 +9,9 @@ #include "graphics/cameracontext.h" #include "visibility/visibilitycontext.h" #include "dynui/imguicontext.h" +#if WITH_NEBULA_ADDON_TBUI #include "tbui/tbuicontext.h" +#endif #include "characters/charactercontext.h" #include "dynui/im3d/im3dcontext.h" #include "appgame/gameapplication.h" @@ -160,7 +162,9 @@ GraphicsFeatureUnit::OnActivate() Im3d::Im3dContext::Create(); Dynui::ImguiContext::Create(); //StaticUI::StaticUIContext::Create(); +#if WITH_NEBULA_ADDON_TBUI TBUI::TBUIContext::Create(); +#endif CameraContext::Create(); ModelContext::Create(); @@ -292,7 +296,9 @@ GraphicsFeatureUnit::OnActivate() Util::Array preLogicCalls = { Dynui::ImguiContext::NewFrame, +#if WITH_NEBULA_ADDON_TBUI TBUI::TBUIContext::FrameUpdate, +#endif CameraContext::UpdateCameras, ModelContext::UpdateTransforms, Characters::CharacterContext::UpdateAnimations, @@ -383,7 +389,9 @@ GraphicsFeatureUnit::OnDeactivate() Raytracing::RaytracingContext::Discard(); Im3d::Im3dContext::Discard(); Dynui::ImguiContext::Discard(); +#if WITH_NEBULA_ADDON_TBUI TBUI::TBUIContext::Discard(); +#endif FeatureUnit::OnDeactivate(); DestroyWindow(this->wnd); this->gfxServer->DiscardStage(this->defaultStage); diff --git a/code/foundation/io/jsonreader.cc b/code/foundation/io/jsonreader.cc index 23ee98116..0feb62144 100644 --- a/code/foundation/io/jsonreader.cc +++ b/code/foundation/io/jsonreader.cc @@ -323,6 +323,19 @@ JsonReader::GetChildNodeName(SizeT childIndex) return ""; } +//------------------------------------------------------------------------------ +/** + +*/ +bool +JsonReader::IsString() const +{ + n_assert(this->IsOpen()); + n_assert(0 != this->curNode); + return this->curNode->is_string(); +} + + //------------------------------------------------------------------------------ /** diff --git a/code/foundation/io/jsonreader.h b/code/foundation/io/jsonreader.h index bd77ddcf6..da511f4bc 100644 --- a/code/foundation/io/jsonreader.h +++ b/code/foundation/io/jsonreader.h @@ -60,6 +60,8 @@ class JsonReader : public StreamReader /// gets the childname of the child at index, or empty string if no child exists or has no name. Util::String GetChildNodeName(SizeT childIndex); + /// check if current node is a string + bool IsString() const; /// check if current node is an array bool IsArray() const; /// check if current node is an object (can have keys) diff --git a/fips-files/include.cmake b/fips-files/include.cmake index cbd1fd420..291906646 100644 --- a/fips-files/include.cmake +++ b/fips-files/include.cmake @@ -1,5 +1,8 @@ fips_ide_group(nebula) +if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.31") +cmake_policy(SET CMP0175 OLD) +endif() if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.27") cmake_policy(SET CMP0147 NEW) endif() @@ -425,6 +428,26 @@ macro(nebula_idl_generate_cs_target) endforeach() endmacro() +macro(add_addon) + set_nebula_export_dir() + foreach(addon ${ARGN}) + if(${addon} IN_LIST ADDON_LIST) + add_subdirectory(${addon}) + endif() + endforeach() +endmacro() + +macro(add_addon_hook) + set_nebula_export_dir() + foreach(addon ${ARGN}) + if(${addon} IN_LIST ADDON_LIST) + fips_deps(${addon}) + string(TOUPPER ${addon} addon) + add_compile_definitions(WITH_NEBULA_ADDON_${addon}) + endif() + endforeach() +endmacro() + macro(add_frameshader_intern) foreach(frm ${ARGN}) get_filename_component(basename ${frm} NAME) @@ -539,40 +562,29 @@ macro(set_nebula_export_dir) MESSAGE(WARNING "Registry keys for project not found, did you set your workdir?") return() endif() - if(EXISTS ${workdir}/projectinfo.json) - FILE(READ "${workdir}/projectinfo.json" projectJson) - sbeParseJson(projectInfo projectJson) - resolve_assigns(${projectInfo.DestDir} targetdir ${workdir}) - SET(EXPORT_DIR ${targetdir}) - set(WORK_DIR "${workdir}") - else() - MESSAGE(WARNING "No projectinfo found in project folder, setting default export") - set(EXPORT_DIR "${workdir}/export") - set(WORK_DIR "${workdir}") - endif() - + elseif(EXISTS $ENV{HOME}/.config/nebula/gscept.cfg) + FILE(READ "$ENV{HOME}/.config/nebula/gscept.cfg" SettingsJson) + sbeParseJson(Settings SettingsJson) + set(workdir ${Settings.ToolkitShared.workdir}) else() - if(EXISTS $ENV{HOME}/.config/nebula/gscept.cfg) - FILE(READ "$ENV{HOME}/.config/nebula/gscept.cfg" SettingsJson) - sbeParseJson(Settings SettingsJson) - set(workdir ${Settings.ToolkitShared.workdir}) - - if(EXISTS ${workdir}/projectinfo.json) - FILE(READ "${workdir}/projectinfo.json" projectJson) - sbeParseJson(projectInfo projectJson) - resolve_assigns(${projectInfo.DestDir} targetdir ${workdir}) - SET(EXPORT_DIR ${targetdir}) - set(WORK_DIR "${workdir}") - else() - MESSAGE(WARNING "No projectinfo found in project folder, setting default export") - set(EXPORT_DIR "${workdir}/export") - set(WORK_DIR "${workdir}") - endif() - else() - # use environment - set(EXPORT_DIR $ENV{NEBULA_WORK}/export) - set(WORK_DIR $ENV{NEBULA_WORK}) - endif() + # use environment + set(workdir $ENV{NEBULA_WORK}) + endif() + if(EXISTS ${workdir}/projectinfo.json) + file(READ "${workdir}/projectinfo.json" projectJson) + sbeParseJson(projectInfo projectJson) + resolve_assigns(${projectInfo.DestDir} targetdir ${workdir}) + set(EXPORT_DIR ${targetdir}) + set(WORK_DIR "${workdir}") + set(ADDON_LIST "") + foreach(addon ${projectInfo.Addons}) + list(APPEND ADDON_LIST ${projectInfo.Addons_${addon}}) + endforeach() + else() + MESSAGE(WARNING "No projectinfo found in project folder, setting default export") + set(EXPORT_DIR "${workdir}/export") + set(WORK_DIR "${workdir}") + set(ADDON_LIST tbui) endif() endmacro() diff --git a/tests/projectinfo.json b/tests/projectinfo.json index f4f2725e4..c2c5ad2e6 100644 --- a/tests/projectinfo.json +++ b/tests/projectinfo.json @@ -50,4 +50,8 @@ "Value": "proj:work/materials" } ], + "Addons": + [ + "tbui", + ], } \ No newline at end of file diff --git a/toolkit/toolkit-common/projectinfo.cc b/toolkit/toolkit-common/projectinfo.cc index b038ea8ef..6e67cc64d 100644 --- a/toolkit/toolkit-common/projectinfo.cc +++ b/toolkit/toolkit-common/projectinfo.cc @@ -200,11 +200,8 @@ ProjectInfo::ParseProjectInfoFile(const IO::URI & path) if (jsonReader->SetToFirstChild()) do { - if (!jsonReader->HasChildren()) - { - this->attrs.Add(jsonReader->GetCurrentNodeName(), jsonReader->GetString()); - } - else + String thing = jsonReader->GetCurrentNodeName(); + if (jsonReader->HasChildren()) { String currentKey = jsonReader->GetCurrentNodeName(); Dictionary values; @@ -212,10 +209,13 @@ ProjectInfo::ParseProjectInfoFile(const IO::URI & path) do { values.Add(jsonReader->GetString("Name"), jsonReader->GetString("Value")); - } - while (jsonReader->SetToNextChild()); + } while (jsonReader->SetToNextChild()); this->listAttrs.Add(currentKey, values); } + else if (jsonReader->IsString()) + { + this->attrs.Add(jsonReader->GetCurrentNodeName(), jsonReader->GetString()); + } } while (jsonReader->SetToNextChild()); return Success;