public virtual string ToWorkshop(OutputLanguage language) { AddMissingParameters(); List <string> parameters = AdditionalParameters().ToList(); parameters.AddRange(ParameterValues.Select(p => p.ToWorkshop(language))); string result = Extras.Indent(Indent, true); // TODO: option for spaces or tab output. if (!ElementList.IsValue && Disabled) { result += LanguageInfo.Translate(language, "disabled") + " "; } result += LanguageInfo.Translate(language, Name); if (parameters.Count != 0) { result += "(" + string.Join(", ", parameters) + ")"; } else if (AlwaysShowParentheses) { result += "()"; } if (!ElementList.IsValue) { result += ";"; } return(result); }
public virtual string ToWorkshop(OutputLanguage language, ToWorkshopContext context) { // Get the parameters AddMissingParameters(); List <string> parameters = AdditionalParameters().ToList(); parameters.AddRange(ParameterValues.Select(p => p.ToWorkshop(language, ToWorkshopContext.NestedValue))); string result = Extras.Indent(Indent, true); // TODO: option for spaces or tab output. // Add a comment and newline if (Comment != null) { result += $"\"{Comment}\"\n" + Extras.Indent(Indent, true); } // Add the disabled tag if the element is disabled. if (!ElementList.IsValue && Disabled) { result += LanguageInfo.Translate(language, "disabled") + " "; } // Add the name of the element. result += LanguageInfo.Translate(language, Name); // Add the parameters. if (parameters.Count != 0) { result += "(" + string.Join(", ", parameters) + ")"; } else if (AlwaysShowParentheses) { result += "()"; } // Add the ; if the element is an action. if (!ElementList.IsValue) { result += ";"; } return(result); }
public string ToWorkshop(OutputLanguage language, ToWorkshopContext context) { string numTranslate(string name) { return(LanguageInfo.Translate(language, name) + WorkshopName.Substring(name.Length)); } if (@Enum.Type == typeof(PlayerSelector) && WorkshopName.StartsWith("Slot")) { return(numTranslate("Slot")); } if (@Enum.Type == typeof(Button) && WorkshopName.StartsWith("Ability")) { return(numTranslate("Ability")); } if ((@Enum.Type == typeof(Team) || @Enum.Type == typeof(Color)) && WorkshopName.StartsWith("Team")) { return(numTranslate("Team")); } return(LanguageInfo.Translate(language, WorkshopName).RemoveStructuralChars()); }
public string Translate(string keyword) => LanguageInfo.Translate(OutputLanguage, keyword);
public void AppendKeyword(string keyword) { Append(LanguageInfo.Translate(OutputLanguage, keyword)); }
public WorkshopBuilder AppendKeyword(string keyword) { Append(LanguageInfo.Translate(OutputLanguage, keyword)); return(this); }
public string ToWorkshop(OutputLanguage language, bool optimize) { var builder = new TabStringBuilder(true); builder.Indent = 0; if (Disabled) { builder.Append(LanguageInfo.Translate(language, "disabled") + " "); } builder.AppendLine($"{LanguageInfo.Translate(language, "rule")}(\"{Name}\")"); builder.AppendLine("{"); builder.AppendLine(); builder.Indent = 1; builder.AppendLine(LanguageInfo.Translate(language, "event")); builder.AppendLine("{"); builder.Indent = 2; builder.AppendLine(EnumData.GetEnumValue(RuleEvent) .ToWorkshop(language) + ";"); // Add attributes. switch (RuleType) { case RuleType.PlayerBased: // Player based attributes builder.AppendLine(EnumData.GetEnumValue(Team).ToWorkshop(language) + ";"); // Team attribute builder.AppendLine(EnumData.GetEnumValue(Player).ToWorkshop(language) + ";"); // Player attribute break; case RuleType.Subroutine: builder.AppendLine(Subroutine.ToWorkshop(language) + ";"); // Attribute name break; } builder.Indent = 1; builder.AppendLine("}"); if (Conditions?.Length > 0) { builder.AppendLine(); builder.AppendLine(LanguageInfo.Translate(language, "conditions")); builder.AppendLine("{"); builder.Indent = 2; foreach (var condition in Conditions) { builder.AppendLine(condition.ToWorkshop(language, optimize) + ";"); } builder.Indent = 1; builder.AppendLine("}"); } // Add actions. if (Actions?.Length > 0) { builder.AppendLine(); builder.AppendLine("// Action count: " + Actions.Length); // Action count comment. builder.AppendLine(LanguageInfo.Translate(language, "actions")); builder.AppendLine("{"); builder.Indent = 2; foreach (var action in Actions) { if (optimize) { builder.AppendLine(action.Optimize().ToWorkshop(language)); } else { builder.AppendLine(action.ToWorkshop(language)); } } builder.Indent = 1; builder.AppendLine("}"); } builder.Indent = 0; builder.AppendLine("}"); return(builder.ToString()); }