Skip to content
Merged
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
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,17 @@ foreach(FEATURE_PATH ${FEATURE_CONFIG_FILES})
"Feature config file '${FEATURE_PATH}' is empty or contains only whitespace. Skipping version detection for this feature."
)
endif()

# Detect core features by checking for the CORE marker file in the
# feature root (features/<Folder>/CORE). FEATURE_PATH is
# features/<Folder>/Shaders/Features/<ShortName>.ini, so the feature
# root is three directories up.
get_filename_component(_FEATURE_DIR "${FEATURE_PATH}" DIRECTORY)
get_filename_component(_FEATURE_DIR "${_FEATURE_DIR}" DIRECTORY)
get_filename_component(_FEATURE_DIR "${_FEATURE_DIR}" DIRECTORY)
if(EXISTS "${_FEATURE_DIR}/CORE")
list(APPEND FEATURE_CORE_NAMES "\t\t\"${FEATURE}\"sv")
endif()
endforeach()

set_property(
Expand All @@ -234,6 +245,7 @@ set_property(
)

string(REPLACE ";" ",\n" FEATURE_VERSIONS "${FEATURE_VERSIONS}")
string(REPLACE ";" ",\n" FEATURE_CORE_NAMES "${FEATURE_CORE_NAMES}")

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/FeatureVersions.h.in
Expand Down
7 changes: 7 additions & 0 deletions cmake/FeatureVersions.h.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <unordered_set>

namespace FeatureVersions
{
using namespace std::literals::string_view_literals;
Expand All @@ -8,4 +10,9 @@ namespace FeatureVersions
{
@FEATURE_VERSIONS@
};

static const std::unordered_set<std::string_view> FEATURE_CORE_NAMES
{
@FEATURE_CORE_NAMES@
};
}
11 changes: 7 additions & 4 deletions src/Feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ struct Feature
/**
* Whether the feature is a CORE feature
* This will place it under "Core Features" in UI
* Also need to create a file named "CORE" in the root of the feature folder
* if it should be merged into main cs zip file
* If "CORE" file is present in the root of the feature folder,
* it will be merged into main cs zip file and automatically considered core
*/
virtual bool IsCore() const { return false; }
virtual bool IsCore() const
{
return FeatureVersions::FEATURE_CORE_NAMES.contains(const_cast<Feature*>(this)->GetShortName());
}

/**
* Get the category for UI grouping (e.g., "Terrain", "Lighting", "Characters", etc.)
Expand Down Expand Up @@ -243,4 +246,4 @@ struct Feature
}
}
}
};
};
Loading