Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for addons #239

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/addons/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ add_subdirectory(scripting)
#add_subdirectory(staticui)
add_subdirectory(tinyxml)
add_subdirectory(nsharp)
add_subdirectory(tbui)
add_addon(tbui)
3 changes: 2 additions & 1 deletion code/addons/graphicsfeature/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 <application/stdneb.h>)
fips_ide_group(features)
fips_files(
Expand Down
8 changes: 8 additions & 0 deletions code/addons/graphicsfeature/graphicsfeatureunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -292,7 +296,9 @@ GraphicsFeatureUnit::OnActivate()
Util::Array<Graphics::ViewIndependentCall> preLogicCalls =
{
Dynui::ImguiContext::NewFrame,
#if WITH_NEBULA_ADDON_TBUI
TBUI::TBUIContext::FrameUpdate,
#endif
CameraContext::UpdateCameras,
ModelContext::UpdateTransforms,
Characters::CharacterContext::UpdateAnimations,
Expand Down Expand Up @@ -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);
Expand Down
13 changes: 13 additions & 0 deletions code/foundation/io/jsonreader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}


//------------------------------------------------------------------------------
/**

Expand Down
2 changes: 2 additions & 0 deletions code/foundation/io/jsonreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
78 changes: 45 additions & 33 deletions fips-files/include.cmake
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()

Expand Down
4 changes: 4 additions & 0 deletions tests/projectinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@
"Value": "proj:work/materials"
}
],
"Addons":
[
"tbui",
],
}
14 changes: 7 additions & 7 deletions toolkit/toolkit-common/projectinfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,22 +200,22 @@ 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<String, String> values;
jsonReader->SetToFirstChild();
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;
Expand Down
Loading