Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- // Include the minimal set of headers required for Unreal Engine functionality.
- // This ensures access to core Unreal Engine types and macros.
- #include "CoreMinimal.h"
- // Include the generated header for this class, which is automatically created by Unreal Engine
- // for UCLASS and USTRUCT definitions, ensuring proper reflection and serialization.
- #include "GameID.generated.h"
- // Enum to identify different Bethesda games, each with a unique value for easy selection in Blueprints.
- // This enum replaces the original GameId enum, where some games (e.g., Fallout 3, New Vegas, Fallout 4)
- // shared the same value as Skyrim, to avoid confusion when selecting games in Blueprints.
- // The UMETA(DisplayName) attribute provides a human-readable name for each game, which is displayed
- // in Blueprints for better usability and accessibility for modders.
- // Using uint8 as the underlying type ensures memory efficiency given the small number of games.
- UENUM(BlueprintType)
- enum class EGameID : uint8
- {
- Oblivion UMETA(DisplayName = "Oblivion"), // Identifier for The Elder Scrolls IV: Oblivion
- Skyrim UMETA(DisplayName = "Skyrim"), // Identifier for The Elder Scrolls V: Skyrim
- Fallout3 UMETA(DisplayName = "Fallout 3"), // Identifier for Fallout 3
- FalloutNV UMETA(DisplayName = "Fallout: New Vegas"), // Identifier for Fallout: New Vegas
- Morrowind UMETA(DisplayName = "Morrowind"), // Identifier for The Elder Scrolls III: Morrowind
- Fallout4 UMETA(DisplayName = "Fallout 4") // Identifier for Fallout 4
- };
- // Enum to group games that share similar parsing logic for .ESM, .ESP, and .ESL files.
- // This preserves the original functionality where certain games (e.g., Skyrim, Fallout 3, New Vegas,
- // Fallout 4) are treated the same way during parsing, reflecting shared file formats due to similar
- // game engines (e.g., Creation Engine).
- // Each group corresponds to a set of games with compatible file formats, allowing for efficient
- // handling of game-specific data in the parsing system.
- // The UMETA(DisplayName) attribute ensures clear naming in Blueprints for modders.
- UENUM(BlueprintType)
- enum class EGameGroup : uint8
- {
- Oblivion UMETA(DisplayName = "Oblivion"), // Group for Oblivion, which has unique parsing logic
- SkyrimLike UMETA(DisplayName = "Skyrim/Fallout 3/NV/4"), // Group for Skyrim, Fallout 3, New Vegas, and Fallout 4,
- // which share similar parsing logic due to engine similarities
- Morrowind UMETA(DisplayName = "Morrowind") // Group for Morrowind, which has unique parsing logic
- };
- // Helper class providing utility functions for working with game IDs in Blueprints.
- // This class is a Blueprint Function Library, allowing its functions to be easily called from Blueprints
- // without needing to instantiate an object, enhancing usability for modders.
- // It contains static functions that do not modify any state (BlueprintPure), making them safe and
- // efficient for use in Blueprints, aligning with the project's goal of exposing data to Blueprints.
- UCLASS()
- class UNREALCREATIONENGINE_API UGameIDHelper : public UBlueprintFunctionLibrary
- {
- GENERATED_BODY()
- public:
- // Function to retrieve the name of a game as a string based on its EGameID.
- // This is useful for logging, displaying game names in the UI, or any other context where
- // a human-readable game name is needed, enhancing modder experience.
- // The function uses a switch statement to map each EGameID to its corresponding string representation,
- // ensuring a clear and maintainable mapping.
- // Marked as BlueprintPure to indicate it has no side effects and can be used in Blueprint graphs.
- // Categorized under "GameID" for easy discovery in Blueprint function lists.
- UFUNCTION(BlueprintPure, Category = "GameID")
- static FString GetGameName(EGameID GameID)
- {
- switch (GameID)
- {
- case EGameID::Oblivion: return "Oblivion"; // Returns the name for Oblivion
- case EGameID::Skyrim: return "Skyrim"; // Returns the name for Skyrim
- case EGameID::Fallout3: return "Fallout 3"; // Returns the name for Fallout 3
- case EGameID::FalloutNV: return "Fallout: New Vegas"; // Returns the name for Fallout: New Vegas
- case EGameID::Morrowind: return "Morrowind"; // Returns the name for Morrowind
- case EGameID::Fallout4: return "Fallout 4"; // Returns the name for Fallout 4
- default: return "Unknown"; // Returns "Unknown" for any unrecognized EGameID,
- // ensuring robustness against invalid inputs
- }
- }
- // Function to determine the game group for a given EGameID.
- // This helps in identifying which parsing logic to use for the game's .ESM, .ESP, or .ESL files,
- // preserving the original system's behavior where certain games share parsing logic.
- // The function maps each EGameID to its corresponding EGameGroup, reflecting the grouping in the
- // original enum (e.g., Skyrim, Fallout 3, New Vegas, Fallout 4 all map to SkyrimLike).
- // Uses a switch statement for clear and maintainable logic, with fall-through cases for grouped games.
- // The default case returns SkyrimLike to handle unrecognized inputs, aligning with the most common group.
- // Marked as BlueprintPure for use in Blueprints without side effects, categorized under "GameID".
- UFUNCTION(BlueprintPure, Category = "GameID")
- static EGameGroup GetGameGroup(EGameID GameID)
- {
- switch (GameID)
- {
- case EGameID::Oblivion: return EGameGroup::Oblivion; // Oblivion has its own unique group
- case EGameID::Skyrim:
- case EGameID::Fallout3:
- case EGameID::FalloutNV:
- case EGameID::Fallout4: return EGameGroup::SkyrimLike; // These games share the SkyrimLike group,
- // reflecting shared file formats and engine similarities
- case EGameID::Morrowind: return EGameGroup::Morrowind; // Morrowind has its own unique group
- default: return EGameGroup::SkyrimLike; // Default to SkyrimLike for any unrecognized EGameID,
- // ensuring consistent behavior for unknown cases
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement