// ==================================================================== // Class: XAdmin.GameConfigSet // Parent: XAdmin.xAdminConfigBase // // This class is responsible for handling changes to a Game default // Behavior like Map List,Mutators and Ini Settings. // ==================================================================== class GameConfigSet extends Object; var LevelInfo Level; // Need access to Level function var protected class GameClass; // Which game class is being edited var protected int GameIndex; // Index of GameClass var protected PlayInfo Settings; // Game Setting Defaults var int CurrentMapList; // Index of maplist we're editing var protected array UsedMutators; // List of Mutators in use var protected array UsedMaps; // Index of maps within active maplist // Maintaining Global Lists var protected string AllMapsPrefix; // Which map prefix is currently loaded var protected array AllMapLists; // List of all maplists for the specified gametype var protected array AllMaps; // List of all Maps for the specified gametype. var protected array AllMutators; // List of all available mutators var protected array< class > AllGameTypes; var string NextMutators; // What mutators were set during this session var protected bool bEdit; // We are currently editing something function bool StartEdit(optional string GameType) { if (Level == None || bEdit) return false; // Load all Game Types, unless already loaded if (AllGameTypes.Length == 0) LoadGameTypes(); // Load All Mutators (Unless already loaded) if (AllMutators.Length == 0) LoadAllMutators(); // If no GameType Specified, use currently loaded one. if (GameType == "") GameType = String(Level.Game.Class); // When editing allow for many ways to find the good game class // Try with Acronym, Class, Alternate class, etc GameClass = FindGameType(GameType); log("GameClass is"@GameClass); if (GameClass == None) return false; LoadAllMaps(); GameIndex = Level.Game.MaplistHandler.GetGameIndex(string(GameClass)); CurrentMapList = GetActiveList(); AllMapLists = GetLists(); // Load Game Setting LoadSettings(GameClass); // Fill in Used Mutators SetUsedMutators(); NextMutators = ""; bEdit = true; return true; } function bool EndEdit(bool bSave) { local int i; if (Level == None || !bEdit) return false; // Save all data where it belongs if (bSave) { // Log("GCS.EndEdit is now Saving All the Data"); // Commit to PlayInfo Settings.SaveSettings(); NextMutators = ""; if (UsedMutators.Length > 0) { NextMutators = AllMutators[UsedMutators[0]]; for (i=1; i GetMaskedParams(string ParamMask) { local array FoundParams; local array FoundMasks; local string SettingName, ShortName; local int i, j, p; Split(ParamMask, " ", FoundMasks); if (FoundMasks.Length > 0) { for (i = 0; i= Settings.Settings.Length) return false; return Settings.StoreSetting(idx, Value); } // Settings Commands Processing function bool SetNamedParam(string Parameter, string Value) { local int i; local string SettingName; for (i = 0; i < Settings.Settings.Length; i++) { SettingName = Settings.Settings[i].SettingName; if (SettingName ~= Parameter || Right(SettingName, Len(Parameter) + 1) ~= ("."$Parameter)) return Settings.StoreSetting(i, Value); } // Parameter not found return false; } // MapList Functions function array GetLists() { local array Names; Names = Level.Game.MaplistHandler.GetMapListNames(GameIndex); return Names; } function int GetActiveList() { return Level.Game.MaplistHandler.GetActiveList(GameIndex); } //function bool SetActiveList(int Index) //{ // if (Index < 0 || Index > AllMapLists.Length || !bEdit) // return false; // // CurrentMapList = Index; // return true; //} function array GetMaps() { return Level.Game.MaplistHandler.GetMapList(GameIndex, CurrentMapList); } function array AddMaps(string MapMask) { local array FoundMasks, AddedMaps, CurrentMaps; local int i, j, k; local bool bFound; Split(MapMask, " ",FoundMasks); if (FoundMasks.Length > 0) { CurrentMaps = GetMaps(); for (i = 0; i RemoveMaps(string MapMask) { local array FoundMasks, DelMaps, CurrentMaps; local int i, j; Split(MapMask, " ", FoundMasks); if (FoundMasks.Length > 0) { CurrentMaps = GetMaps(); for (i=0; i FindMaps(string MapMask) { local array FoundMasks, FoundMaps, CurrentMaps; local int i, j, k; local bool bFound; Split(MapMask, " ", FoundMasks); if (FoundMasks.Length > 0) { CurrentMaps = GetMaps(); for (i = 0; i GetUsedMutators() { local array Strings; local int i; for (i = 0; i GetUnusedMutators() { local array Strings; local int i; Strings.Length = AllMutators.Length; for (i = 0; i TempClass; local String NextGame; local int i; // Compile a list of all gametypes. i = 0; NextGame = Level.GetNextInt("Engine.GameInfo", 0); while (NextGame != "") { TempClass = class(DynamicLoadObject(NextGame, class'Class')); if (TempClass != None) AllGameTypes[AllGameTypes.Length] = TempClass; NextGame = Level.GetNextInt("Engine.GameInfo", ++i); } } protected function class FindGameType(string GameType) { local class TempClass; local int i; TempClass = None; for (i=0; i GameClass) { if (Settings == None) Settings = new(None) class'PlayInfo'; Settings.Clear(); GameClass.static.FillPlayInfo(Settings); return string(GameClass); } // TODO: Have a "native array LoadAllMapNames(string MapPrefix)" somewhere ? protected function LoadAllMaps(optional bool bForceLoad) { local string MapPrefix; if (GameClass == None) return; MapPrefix = GameClass.Default.MapPrefix; if(MapPrefix != "" && (MapPrefix != AllMapsPrefix || bForceLoad)) { GameClass.static.LoadMapList(MapPrefix, AllMaps); AllMapsPrefix = MapPrefix; } } //////////////////////////////////////////////////////////// // TODO: Find Centralized place for the following functions //////////////////////////////////////////////////////////// // Mask can be *|*Name|Name*|*Name*|Name protected function bool MaskedCompare(string SettingName, string Mask) { local bool bMaskLeft, bMaskRight; local int MaskLen; if (Mask == "*" || Mask == "**") return true; MaskLen = Len(Mask); bMaskLeft = Left(Mask, 1) == "*"; bMaskRight = Right(Mask, 1) == "*"; if (bMaskLeft && bMaskRight) return Instr(Caps(SettingName), Mid(Caps(Mask), 1, MaskLen-2)) >= 0; if (bMaskLeft) return Left(SettingName, MaskLen -1) ~= Left(Mask, MaskLen - 1); if (bMaskRight) return Right(SettingName, MaskLen -1) ~= Right(Mask, MaskLen - 1); return SettingName ~= Mask; } defaultproperties { }