Пример #1
0
 public void CopyAIObject <T>(string title, T selected, AITable <T> aitable, BrightIdeasSoftware.ObjectListView olv)
     where T : class, IAIObject
 {
     if (selected == null)
     {
         return;
     }
     InputBox.InputResult res = InputBox.Show(title, "Enter name:", selected.Name);
     if (res.ReturnCode == DialogResult.OK)
     {
         T newai = selected.Copy(nextID(), res.Text) as T;
         aitable.Add(newai);
         olv.BeginUpdate();
         olv.AddObject(newai);
         olv.EndUpdate();
         olv.SelectedObject = newai;
         olv.EnsureVisible();
     }
 }
Пример #2
0
        private void LoadData(string rulesPath, string aiPath)
        {
            IniDictionary rules = IniParser.ParseToDictionary(rulesPath, logger);
            IniDictionary ai    = IniParser.ParseToDictionary(aiPath, logger);
            IniDictionary config;
            string        appPath    = "";
            string        configPath = "";

            appPath    = System.AppDomain.CurrentDomain.BaseDirectory;
            configPath = appPath + "config\\ts.ini";

            // autodetect yr
            if (rules["General"].Contains("DominatorWarhead"))
            {
                configPath = appPath + "config\\yr.ini";
            }
            // autodetect ra2
            else if (rules["General"].Contains("PrismType"))
            {
                configPath = appPath + "config\\ra2.ini";
            }

            config = IniParser.ParseToDictionary(configPath, logger);

            idCounter = ID_BASE;
            if (config.ContainsKey("General"))
            {
                if (config["General"].Contains("StartIndex"))
                {
                    try
                    {
                        idCounter = uint.Parse(config["General"].GetString("StartIndex"), NumberStyles.AllowHexSpecifier);
                    }
                    catch (Exception)
                    {
                        idCounter = ID_BASE;
                    }
                }

                string idPrefixTemp = "";
                string idSuffixTemp = "";
                idPrefix = "";
                idSuffix = "-G";

                if (config["General"].Contains("IDPrefix"))
                {
                    idPrefixTemp = config["General"].GetString("IDPrefix");
                }
                if (config["General"].Contains("IDSuffix"))
                {
                    idSuffixTemp = config["General"].GetString("IDSuffix");
                }
                if (!String.IsNullOrEmpty(idPrefixTemp))
                {
                    if (Regex.IsMatch(idPrefixTemp, @"^[a-zA-Z0-9_-]+$") && idPrefixTemp.Length < 16)
                    {
                        idPrefix = idPrefixTemp.ToUpper();
                    }
                }
                if (!String.IsNullOrEmpty(idSuffixTemp))
                {
                    if (Regex.IsMatch(idSuffixTemp, @"^[a-zA-Z0-9_-]+$"))
                    {
                        idSuffix = idSuffixTemp.ToUpper();
                    }
                }

                string unitMultiEntry = "";
                if (config["General"].Contains("SameUnitMultiEntry"))
                {
                    unitMultiEntry = config["General"].GetString("SameUnitMultiEntry");
                }
                if (!String.IsNullOrEmpty(unitMultiEntry) && (unitMultiEntry.Equals("yes", StringComparison.InvariantCultureIgnoreCase) ||
                                                              unitMultiEntry.Equals("true", StringComparison.InvariantCultureIgnoreCase)))
                {
                    sameUnitMultiEntry = true;
                }
            }

            if (ai.ContainsKey("Digest"))
            {
                digestString = ai["Digest"].GetString("1");
            }
            else
            {
                digestString = config["General"].GetString("Digest");
            }

            string sectionHouses = config["General"].GetString("Houses");
            string editorName    = config["General"].GetString("EditorName");

            LoadTechnoTypes(rules, editorName);

            teamHouseTypes = LoadAITypeList(rules, sectionHouses);
            teamHouseTypes.Add(new AITypeListEntry(-1, "<none>"));
            teamHouseTypes.Sort();

            triggerHouseTypes = LoadAITypeList(rules, sectionHouses);
            triggerHouseTypes.Add(new AITypeListEntry(-1, "<all>"));
            triggerHouseTypes.Sort();

            scriptTypes = new AITable <ScriptType>("ScriptTypes", new List <ScriptType>());
            teamTypes   = new AITable <TeamType>("TeamTypes", new List <TeamType>());

            actionTypes      = LoadActionTypes(config);
            groupTypes       = LoadAITypeList(config, "Group");
            veterancyTypes   = LoadAITypeList(config, "VeteranLevels");
            mindControlTypes = LoadAITypeList(config, "MCDecisions");
            sides            = LoadAITypeList(config, "Sides");
            conditionTypes   = LoadAITypeList(config, "Conditions");
            operatorTypes    = LoadAITypeList(config, "Operators");

            // TaskForces being 1st of the 4 types, ID duplicates accross ai(md).ini is not checked.
            taskForces = LoadTaskForces(ai, technoTypes, groupTypes);

            scriptTypes = LoadScriptTypes(ai, actionTypes);

            teamTypeOptions = LoadTeamTypeOptions(config);
            teamTypes       = LoadTeamTypes(ai, teamTypeOptions);

            triggerTypeOptions = LoadTriggerTypeOptions(config);
            triggerTypes       = LoadTriggerTypes(ai);
        }