示例#1
0
    public void SetupSteam()
    {
        // C++ Flags
        PublicDefinitions.Add("WARRIORB_WITH_STEAM=" + BoolToIntString(WARRIORB_WITH_STEAM));
        PublicDefinitions.Add("WARRIORB_STEAM_APP_ID=" + IntToString(WARRIORB_STEAM_APP_ID));
        PublicDefinitions.Add("WARRIORB_STEAM_DEMO_APP_ID=" + IntToString(WARRIORB_STEAM_DEMO_APP_ID));
        PublicDefinitions.Add("WARRIORB_RELAUNCH_IN_STEAM=" + BoolToIntString(WARRIORB_RELAUNCH_IN_STEAM));
        PublicDefinitions.Add("WARRIORB_STEAM_CHECK_IF_LIBRARY_CHECKSUM_MATCHES=" + BoolToIntString(WARRIORB_STEAM_CHECK_IF_LIBRARY_CHECKSUM_MATCHES));
        PublicDefinitions.Add(String.Format("WARRIORB_STEAM_LIBRARY_WINDOWS_API64_SHA1_SUM=\"{0}\"", WARRIORB_STEAM_LIBRARY_WINDOWS_API64_SHA1_SUM));

        ConfigHierarchy             ConfigEngineHierarchy = ConfigCache.ReadHierarchy(ConfigHierarchyType.Engine, new DirectoryReference(ProjectRootPath), Target.Platform);
        Dictionary <string, string> SteamReplacements     = new Dictionary <string, string>();

        // Steam
        if (WARRIORB_WITH_STEAM)
        {
            // Replace the steam id with our own defined one
            // Same for the Game Version

            // SteamDevAppId
            {
                int CurrentAppid;
                ConfigEngineHierarchy.GetInt32("OnlineSubsystemSteam", "SteamDevAppId", out CurrentAppid);
                string FormatString = "SteamDevAppId={0}";
                SteamReplacements.Add(String.Format(FormatString, CurrentAppid), String.Format(FormatString, SteamAppid));
            }

            // GameVersion
            {
                string CurrentGameVersion;
                ConfigEngineHierarchy.GetString("OnlineSubsystemSteam", "GameVersion", out CurrentGameVersion);
                string FormatString = "GameVersion={0}";
                SteamReplacements.Add(String.Format(FormatString, CurrentGameVersion), String.Format(FormatString, WARRIORB_BUILD_VERSION));
            }

            // Relaunch in Steam?
            // https://partner.steamgames.com/doc/api/steam_api#SteamAPI_RestartAppIfNecessary
            // NOTE: disabled at it is broken anyways
            // {
            //  bool CurrentRelaunchInSteam;
            //  ConfigEngineHierarchy.GetBool("OnlineSubsystemSteam", "bRelaunchInSteam", out CurrentRelaunchInSteam);
            //  string FormatString = "bRelaunchInSteam={0}";
            //  SteamReplacements.Add(String.Format(FormatString, CurrentRelaunchInSteam), String.Format(FormatString, WARRIORB_RELAUNCH_IN_STEAM));
            // }

            // Include plugins
            PrivateDependencyModuleNames.Add("NotYetSteam");
            DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");
        }

        // bEnabled
        // {
        //  bool CurrentEnabled;
        //  ConfigEngineHierarchy.GetBool("OnlineSubsystemSteam", "bEnabled", out CurrentEnabled);
        //  string FormatString = "bEnabled={0}";
        //  SteamReplacements.Add(String.Format(FormatString, CurrentEnabled), String.Format(FormatString, WARRIORB_WITH_STEAM));
        // }

        PatchFile(DefaultEngineConfigPath, SteamReplacements);
    }
        public static void LoadBundleConfig <TPlatformBundleSettings>(DirectoryReference ProjectDir, UnrealTargetPlatform Platform,
                                                                      out IReadOnlyDictionary <string, TPlatformBundleSettings> Bundles,
                                                                      Action <TPlatformBundleSettings, ConfigHierarchy, string> GetPlatformSettings)
            where TPlatformBundleSettings : BundleSettings, new()
        {
            var Results = new List <TPlatformBundleSettings>();

            ConfigHierarchy BundleConfig = ConfigCache.ReadHierarchy(ConfigHierarchyType.InstallBundle, ProjectDir, Platform);

            const string BundleDefinitionPrefix = "InstallBundleDefinition ";

            foreach (string SectionName in BundleConfig.SectionNames)
            {
                if (!SectionName.StartsWith(BundleDefinitionPrefix))
                {
                    continue;
                }

                TPlatformBundleSettings Bundle = new TPlatformBundleSettings();
                Bundle.Name = SectionName.Substring(BundleDefinitionPrefix.Length);
                {
                    int Order;
                    if (BundleConfig.GetInt32(SectionName, "Order", out Order))
                    {
                        Bundle.Order = Order;
                    }
                    else
                    {
                        Bundle.Order = int.MaxValue;
                    }
                }
                {
                    List <string> Tags;
                    if (BundleConfig.GetArray(SectionName, "Tags", out Tags))
                    {
                        Bundle.Tags = Tags;
                    }
                    else
                    {
                        Bundle.Tags = new List <string>();
                    }
                }
                {
                    List <string> Dependencies;
                    if (BundleConfig.GetArray(SectionName, "Dependencies", out Dependencies))
                    {
                        Bundle.Dependencies = Dependencies;
                    }
                    else
                    {
                        Bundle.Dependencies = new List <string>();
                    }
                }
                {
                    List <string> FileRegex;
                    if (BundleConfig.GetArray(SectionName, "FileRegex", out FileRegex))
                    {
                        Bundle.FileRegex = FileRegex;
                    }
                    else
                    {
                        Bundle.FileRegex = new List <string>();
                    }
                }
                {
                    bool bContainsShaderLibrary;
                    if (BundleConfig.GetBool(SectionName, "ContainsShaderLibrary", out bContainsShaderLibrary))
                    {
                        Bundle.bContainsShaderLibrary = bContainsShaderLibrary;
                    }
                    else
                    {
                        Bundle.bContainsShaderLibrary = false;
                    }
                }

                GetPlatformSettings(Bundle, BundleConfig, BundleDefinitionPrefix + Bundle.Name);

                Results.Add(Bundle);
            }

            // Use OrderBy and not Sort because OrderBy is stable
            Bundles = Results.OrderBy(b => b.Order).ToDictionary(b => b.Name, b => b);
        }
        public static void LoadBundleConfig <TPlatformBundleSettings>(DirectoryReference ProjectDir, UnrealTargetPlatform Platform,
                                                                      out List <TPlatformBundleSettings> Bundles,
                                                                      Action <TPlatformBundleSettings, ConfigHierarchy, string> GetPlatformSettings)
            where TPlatformBundleSettings : BundleSettings, new()
        {
            Bundles = new List <TPlatformBundleSettings>();

            ConfigHierarchy BundleConfig = ConfigCache.ReadHierarchy(ConfigHierarchyType.InstallBundle, ProjectDir, Platform);

            const string BundleDefinitionPrefix = "InstallBundleDefinition ";

            foreach (string SectionName in BundleConfig.SectionNames)
            {
                if (!SectionName.StartsWith(BundleDefinitionPrefix))
                {
                    continue;
                }

                TPlatformBundleSettings Bundle = new TPlatformBundleSettings();
                Bundle.Name = SectionName.Substring(BundleDefinitionPrefix.Length);
                {
                    int Order;
                    if (BundleConfig.GetInt32(SectionName, "Order", out Order))
                    {
                        Bundle.Order = Order;
                    }
                    else
                    {
                        Bundle.Order = int.MaxValue;
                    }
                }
                {
                    string ExecFileName;
                    BundleConfig.GetString(SectionName, "ExecFileName", out ExecFileName);
                    Bundle.ExecFileName = ExecFileName;
                }
                {
                    List <string> Tags;
                    BundleConfig.GetArray(SectionName, "Tags", out Tags);
                    Bundle.Tags = Tags;
                }
                {
                    List <string> FileRegex;
                    BundleConfig.GetArray(SectionName, "FileRegex", out FileRegex);
                    Bundle.FileRegex = FileRegex;
                }
                {
                    bool bContainsShaderLibrary;
                    BundleConfig.GetBool(SectionName, "ContainsShaderLibrary", out bContainsShaderLibrary);
                    Bundle.bContainsShaderLibrary = bContainsShaderLibrary;
                }
                if (Bundle.Tags == null)
                {
                    Bundle.Tags = new List <string>();
                }

                GetPlatformSettings(Bundle, BundleConfig, BundleDefinitionPrefix + Bundle.Name);

                Bundles.Add(Bundle);
            }

            // Use OrderBy and not Sort because OrderBy is stable
            Bundles = Bundles.OrderBy(Bundle => Bundle.Order).ToList();
        }