Ejemplo n.º 1
0
 private void btnSaveCountry_Click(object sender, EventArgs e)
 {
     setCountry();
     if (!battle.countryList.Exists(i => i.name.Equals(country.name)))
     {
         battle.countryList.Add(country);
     }
     country = new Country();
     MessageBox.Show("儲存國家成功。", "歐三戰役編輯器",
     MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
 }
Ejemplo n.º 2
0
 public frmCountry(Battle battle, Country country)
 {
     InitializeComponent();
     this.battle = battle;
     this.country = country;
     if (battle.countryList != null)
     {
         foreach (Country tempcountry in battle.countryList)
         {
             cboCountryName.Items.Add(tempcountry.name);
         }
     }
     displayCountry(country);
 }
Ejemplo n.º 3
0
 public frmCountry(Battle battle)
 {
     InitializeComponent();
     this.battle = battle;
     country = new Country();
     if (battle.countryList != null)
     {
         foreach (Country tempcountry in battle.countryList)
         {
             cboCountryName.Items.Add(tempcountry.name);
         }
     }
     cboCountryName.Text = "de";
     rdbAiYes.Checked = true;
     txtMoney.Text = "100";
     txtIndustry.Text = "100";
     txtTechLevel.Text = "3";
     rdbAllianceA.Checked = true;
     txtColorR.Text = "0";
     txtColorG.Text = "0";
     txtColorB.Text = "0";
     txtColorA.Text = "0";
 }
Ejemplo n.º 4
0
 private void displayCountry(Country country)
 {
     cboCountryName.Text = country.name;
     if (country.ai == 0)
     {
         rdbAiNo.Checked = true;
     }
     else
     {
         rdbAiYes.Checked = true;
     }
     txtMoney.Text = country.money.ToString();
     txtIndustry.Text = country.industry.ToString();
     txtTechLevel.Text = country.techlevel.ToString();
     if (country.alliance == Alliance.a)
     {
         rdbAllianceA.Checked = true;
     }
     if (country.alliance == Alliance.b)
     {
         rdbAllianceB.Checked = true;
     }
     if (country.alliance == Alliance.c)
     {
         rdbAllianceC.Checked = true;
     }
     if (country.alliance == Alliance.n)
     {
         rdbAllianceN.Checked = true;
     }
     txtColorR.Text = country.color.r.ToString();
     txtColorG.Text = country.color.g.ToString();
     txtColorB.Text = country.color.b.ToString();
     txtColorA.Text = country.color.a.ToString();
 }
Ejemplo n.º 5
0
 private void cboCountryName_Validating(object sender, CancelEventArgs e)
 {
     if (cboCountryName.Text.Equals(""))
     {
         MessageBox.Show("請設定國家ID。", "歐三戰役編輯器",
         MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
         e.Cancel = true;
     }
     else if (battle.countryList.Exists(i => i.name.Equals(cboCountryName.Text)))
     {
         country = battle.countryList.Find(i => i.name.Equals(cboCountryName.Text));
         displayCountry(country);
     }
 }
Ejemplo n.º 6
0
        public string ReadFile(string filePath)
        {
            XDocument battleXml = new XDocument();
            battleXml = XDocument.Load(filePath, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo | LoadOptions.SetBaseUri);

            XmlSchemaSet schemas = new XmlSchemaSet();
            schemas.Add("", "Battle.xsd");
            schemas.Compile();
            String errorMessage = "";

            Console.WriteLine("Attempting to validate");
            bool errors = false;
            battleXml.Validate(schemas, (o, e) =>
            {
                errorMessage += "XML " + e.Severity + ": " + e.Message + "(Line " + e.Exception.LineNumber + ")" + "\n";
                errors = true;
            });

            Console.WriteLine("Reading Xml {0}", errors ? "did not validate" : "validated");
            Console.WriteLine();

            if (errors) { return errorMessage; }

            IEnumerable<XElement> countryNode;
            IEnumerable<XElement> areaNode;

            if (battleXml.Element("battle").Attribute("areasenable") != null)
            {
                battleName = battleXml.Element("battle").Attribute("areasenable").Value;
                battleName = battleName.Substring(0, battleName.IndexOf("."));
            }
            else
            {
                battleName = "";
            }

            map = int.Parse(battleXml.Element("battle").Attribute("map").Value);
            countryNode = battleXml.Element("battle").Elements("list").Where(x => x.Attribute("name").Value.Equals("country")).SingleOrDefault().Elements("country");
            areaNode = battleXml.Element("battle").Elements("list").Where(x => x.Attribute("name").Value.Equals("area")).SingleOrDefault().Elements("area");

            foreach (XElement country in countryNode)
            {
                Country tempCountry = new Country(country);
                if (!countryList.Exists(i => i.name.Equals(tempCountry.name)))
                {
                    countryList.Add(tempCountry);
                }
                else
                {
                    errors = true;
                    errorMessage += "國家名稱: \"" + tempCountry.name + "\" 重複出現!\n";
                }
            }
            foreach (XElement area in areaNode)
            {
                Area tempArea = new Area(area);
                if (!areaList.Exists(i => i.id == tempArea.id))
                {
                    areaList.Add(tempArea);
                }
                else
                {
                    errors = true;
                    errorMessage += "地塊ID: \"" + tempArea.id + "\" 重複出現!\n";
                }
            }

            return errorMessage;
        }