コード例 #1
0
        public void ToWorkshop(WorkshopBuilder builder)
        {
            List <LobbySetting> allSettings = GetAllSettings();

            builder.AppendKeywordLine("settings");
            builder.AppendLine("{");
            builder.Indent();

            // Get the lobby settings.
            if (Lobby != null)
            {
                builder.AppendKeywordLine("lobby");
                builder.AppendLine("{");
                builder.Indent();
                Lobby.ToWorkshop(builder, allSettings);
                builder.Unindent();
                builder.AppendLine("}");
            }

            // Get the mode settings.
            if (Modes != null)
            {
                Modes.ToWorkshop(builder, allSettings);
            }

            // Get the hero settings.
            if (Heroes != null)
            {
                Heroes.ToWorkshop(builder, allSettings);
            }

            builder.Unindent();
            builder.AppendLine("}");
        }
コード例 #2
0
        public void ToWorkshop(WorkshopBuilder builder, List <LobbySetting> allSettings)
        {
            builder.AppendKeywordLine("modes");
            builder.AppendLine("{");
            builder.Indent();

            if (All != null)
            {
                builder.AppendKeywordLine("General");
                builder.AppendLine("{");
                builder.Indent();
                All.ToWorkshop(builder, allSettings);
                builder.Unindent();
                builder.AppendLine("}");
            }

            Assault?.ToWorkshop(builder, allSettings, "Assault");
            CaptureTheFlag?.ToWorkshop(builder, allSettings, "CaptureTheFlag");
            Control?.ToWorkshop(builder, allSettings, "Control");
            Deathmatch?.ToWorkshop(builder, allSettings, "Deathmatch");
            Elimination?.ToWorkshop(builder, allSettings, "Elimination");
            Escort?.ToWorkshop(builder, allSettings, "Escort");
            Hybrid?.ToWorkshop(builder, allSettings, "Hybrid");
            PracticeRange?.ToWorkshop(builder, allSettings, "PracticeRange");
            Skirmish?.ToWorkshop(builder, allSettings, "Skirmish");
            TeamDeathmatch?.ToWorkshop(builder, allSettings, "TeamDeathmatch");

            builder.Unindent();
            builder.AppendLine("}");
        }
コード例 #3
0
        public void ToWorkshop(WorkshopBuilder builder)
        {
            List <LobbySetting> allSettings = GetAllSettings();

            builder.AppendKeywordLine("settings");
            builder.AppendLine("{");
            builder.Indent();

            // Get the description
            if (Description != null)
            {
                builder.AppendKeywordLine("main")
                .AppendLine("{")
                .Indent()
                .AppendKeyword("Description").Append(": \"" + Description + "\"").AppendLine()
                .Unindent()
                .AppendLine("}");
            }

            // Get the lobby settings.
            if (Lobby != null)
            {
                builder.AppendKeywordLine("lobby");
                builder.AppendLine("{");
                builder.Indent();
                Lobby.ToWorkshop(builder, allSettings);
                builder.Unindent();
                builder.AppendLine("}");
            }

            // Get the mode settings.
            if (Modes != null)
            {
                Modes.ToWorkshop(builder, allSettings);
            }

            // Get the hero settings.
            if (Heroes != null)
            {
                Heroes.ToWorkshop(builder, allSettings);
            }

            // Get the custom workshop settings.
            if (Workshop != null)
            {
                builder.AppendKeywordLine("workshop");
                builder.AppendLine("{");
                builder.Indent();
                Workshop.ToWorkshopCustom(builder);
                builder.Unindent();
                builder.AppendLine("}");
            }

            builder.Unindent();
            builder.AppendLine("}");
        }
コード例 #4
0
 public void ToWorkshop(WorkshopBuilder builder, List <LobbySetting> allSettings)
 {
     if (Settings != null)
     {
         foreach (var hero in Settings)
         {
             if (hero.Key != "General")
             {
                 builder.AppendLine($"{hero.Key}");
                 builder.AppendLine("{");
                 builder.Indent();
                 WorkshopValuePair.ToWorkshop(((JObject)hero.Value).ToObject <Dictionary <string, object> >(), builder, allSettings);
                 builder.Outdent();
                 builder.AppendLine("}");
             }
             else
             {
                 WorkshopValuePair.ToWorkshop(((JObject)hero.Value).ToObject <Dictionary <string, object> >(), builder, allSettings);
             }
         }
     }
     if (EnabledHeroes != null)
     {
         builder.AppendLine();
         builder.AppendKeywordLine("enabled heroes");
         Ruleset.WriteList(builder, EnabledHeroes);
     }
     if (DisabledHeroes != null)
     {
         builder.AppendLine();
         builder.AppendKeywordLine("disabled heroes");
         Ruleset.WriteList(builder, DisabledHeroes);
     }
 }
コード例 #5
0
        public void ToWorkshop(WorkshopBuilder builder, List <LobbySetting> allSettings, string modeName)
        {
            builder.AppendKeywordLine(modeName);

            Settings?.Remove("Enabled");

            if (EnabledMaps != null || DisabledMaps != null || (Settings != null && Settings.Count > 0))
            {
                builder.AppendLine("{");
                builder.Indent();

                if (Settings != null)
                {
                    WorkshopValuePair.ToWorkshop(Settings, builder, allSettings);
                }

                if (EnabledMaps != null)
                {
                    builder.AppendKeywordLine("enabled maps");
                    Ruleset.WriteList(builder, EnabledMaps);
                }
                if (DisabledMaps != null)
                {
                    builder.AppendKeywordLine("disabled maps");
                    Ruleset.WriteList(builder, DisabledMaps);
                }

                builder.Unindent();
                builder.AppendLine("}");
            }
        }
コード例 #6
0
        public static void WriteList(WorkshopBuilder builder, string[] maps)
        {
            builder.AppendLine("{");
            builder.Indent();

            foreach (string map in maps)
            {
                builder.AppendLine(builder.Translate(map).RemoveStructuralChars());
            }

            builder.Outdent();
            builder.AppendLine("}");
        }
コード例 #7
0
        public void ToWorkshop(WorkshopBuilder builder, List <LobbySetting> allSettings)
        {
            builder.AppendKeywordLine("heroes");
            builder.AppendLine("{");
            builder.Indent();

            if (General != null)
            {
                builder.AppendKeywordLine("General");
                builder.AppendLine("{");
                builder.Indent();
                General.ToWorkshop(builder, allSettings);
                builder.Outdent();
                builder.AppendLine("}");
            }
            if (Team1 != null)
            {
                builder.AppendKeywordLine("Team 1");
                builder.AppendLine("{");
                builder.Indent();
                Team1.ToWorkshop(builder, allSettings);
                builder.Outdent();
                builder.AppendLine("}");
            }
            if (Team2 != null)
            {
                builder.AppendKeywordLine("Team 2");
                builder.AppendLine("{");
                builder.Indent();
                Team2.ToWorkshop(builder, allSettings);
                builder.Outdent();
                builder.AppendLine("}");
            }

            builder.Outdent();
            builder.AppendLine("}");
        }
コード例 #8
0
        public virtual void ToWorkshop(WorkshopBuilder b, ToWorkshopContext context)
        {
            var action = Function as ElementJsonAction;

            if (action != null && (action.Indentation == "outdent" || action.Indentation == "drop"))
            {
                b.Outdent();
            }

            // Add a comment and newline
            if (Comment != null)
            {
                b.AppendLine($"\"{Comment}\"");
            }

            // Add the disabled tag if the element is disabled.
            if (Function is ElementJsonAction && Disabled)
            {
                b.AppendKeyword("disabled").Append(" ");
            }

            // Add the name of the element.
            b.AppendKeyword(Function.Name);

            // Add the parameters.
            AddMissingParameters();
            if (ParameterValues.Length > 0)
            {
                b.Append("(");
                ParametersToWorkshop(b);
                b.Append(")");
            }

            if (action != null)
            {
                b.AppendLine(";");
                if (action.Indentation == "indent" || action.Indentation == "drop")
                {
                    b.Indent();
                }
            }
        }
コード例 #9
0
        public void ToWorkshop(WorkshopBuilder builder)
        {
            if (Subroutines.Count == 0)
            {
                return;
            }

            builder.AppendKeywordLine("subroutines");
            builder.AppendLine("{");
            builder.Indent();

            foreach (Subroutine routine in Subroutines)
            {
                builder.AppendLine(routine.ID.ToString() + ": " + routine.Name);
            }

            builder.Unindent();
            builder.AppendLine("}");
            builder.AppendLine();
        }
コード例 #10
0
        public void ToWorkshop(WorkshopBuilder builder, List <LobbySetting> allSettings, string modeName)
        {
            bool enabled = Settings == null || !Settings.TryGetValue("Enabled", out object value) || (value is bool b && b);

            Settings?.Remove("Enabled");

            if (!enabled)
            {
                builder.AppendKeyword("disabled").Append(" ");
            }
            builder.AppendKeywordLine(modeName);

            if (EnabledMaps != null || DisabledMaps != null || (Settings != null && Settings.Count > 0))
            {
                builder.AppendLine("{");
                builder.Indent();

                if (Settings != null)
                {
                    WorkshopValuePair.ToWorkshop(Settings, builder, allSettings);
                }

                if (EnabledMaps != null)
                {
                    builder.AppendKeywordLine("enabled maps");
                    Ruleset.WriteList(builder, EnabledMaps);
                }
                if (DisabledMaps != null)
                {
                    builder.AppendKeywordLine("disabled maps");
                    Ruleset.WriteList(builder, DisabledMaps);
                }

                builder.Unindent();
                builder.AppendLine("}");
            }
        }
コード例 #11
0
        public void ToWorkshop(WorkshopBuilder builder)
        {
            List <LobbySetting> allSettings = GetAllSettings();

            builder.AppendKeywordLine("settings");
            builder.AppendLine("{");
            builder.Indent();

            // Get the description and/or mode name
            if (Description != null || ModeName != null)
            {
                builder.AppendKeywordLine("main")
                .AppendLine("{")
                .Indent();
                if (Description != null)
                {
                    builder.AppendKeyword("Description").Append(": \"" + Description + "\"").AppendLine();
                }
                if (ModeName != null)
                {
                    builder.AppendKeyword("Mode Name").Append(": \"" + ModeName + "\"").AppendLine();
                }
                builder.Outdent()
                .AppendLine("}");
            }

            // Get the lobby settings.
            if (Lobby != null)
            {
                builder.AppendKeywordLine("lobby");
                builder.AppendLine("{");
                builder.Indent();
                Lobby.ToWorkshop(builder, allSettings);
                builder.Outdent();
                builder.AppendLine("}");
            }

            // Get the mode settings.
            if (Modes != null)
            {
                Modes.ToWorkshop(builder, allSettings);
            }

            // Get the hero settings.
            if (Heroes != null)
            {
                Heroes.ToWorkshop(builder, allSettings);
            }

            // Get the custom workshop settings.
            if (Workshop != null)
            {
                builder.AppendKeywordLine("workshop");
                builder.AppendLine("{");
                builder.Indent();
                Workshop.ToWorkshopCustom(builder);
                builder.Outdent();
                builder.AppendLine("}");
            }

            // Get extensions.
            if (Extensions != null)
            {
                builder.AppendKeywordLine("extensions");
                builder.AppendLine("{");
                builder.Indent();

                foreach (var ext in Extensions)
                {
                    if ((bool)ext.Value)
                    {
                        builder.AppendKeywordLine(ext.Key);
                    }
                }

                builder.Outdent();
                builder.AppendLine("}");
            }

            builder.Outdent();
            builder.AppendLine("}");
        }
コード例 #12
0
        public void ToWorkshop(WorkshopBuilder builder)
        {
            if (globalLimitReached || playerLimitReached || extGlobalLimitReached || extPlayerLimitReached)
            {
                List <string> collectionLimitsReached = new List <string>();

                // Add names of the collections that exceed their variable limit.
                if (globalLimitReached)
                {
                    collectionLimitsReached.Add("global");
                }
                if (playerLimitReached)
                {
                    collectionLimitsReached.Add("player");
                }
                if (extGlobalLimitReached)
                {
                    collectionLimitsReached.Add("ext. global");
                }
                if (extPlayerLimitReached)
                {
                    collectionLimitsReached.Add("ext. player");
                }

                builder.AppendLine(string.Format(
                                       "// The {0} reached the variable limit. Only a maximum of 128 variables and 1000 extended variables can be assigned.",
                                       Extras.ListJoin("variable collection", collectionLimitsReached.ToArray())
                                       ));
                builder.AppendLine();
            }

            builder.AppendKeywordLine("variables");
            builder.AppendLine("{");
            builder.Indent();
            builder.AppendKeyword("global"); builder.Append(":"); builder.AppendLine();
            builder.Indent();
            WriteCollection(builder, variableList(true));
            builder.Unindent();

            builder.AppendKeyword("player"); builder.Append(":"); builder.AppendLine();
            builder.Indent();
            WriteCollection(builder, variableList(false));
            builder.Unindent();
            builder.Unindent();
            builder.AppendLine("}");

            bool anyExtendedGlobal = ExtendedVariableList(true).Any(v => v != null);
            bool anyExtendedPlayer = ExtendedVariableList(false).Any(v => v != null);

            if (anyExtendedGlobal || anyExtendedPlayer)
            {
                builder.AppendLine();
                builder.AppendLine($"// Extended collection variables:");

                foreach (var ex in ExtendedVariableList(true))
                {
                    builder.AppendLine($"// global [{ex.Index}]: {ex.DebugName}");
                }
                foreach (var ex in ExtendedVariableList(false))
                {
                    builder.AppendLine($"// player [{ex.Index}]: {ex.DebugName}");
                }
            }
        }