コード例 #1
0
ファイル: frmMines.cs プロジェクト: DmitryPerkov/Homm5IRMG
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            Program.frmTemplateEdit.thTemplate.SetLinkAttribute(iZoneIndex, "Mines", checkBox1.Checked.ToString());
            if (checkBox1.Checked)
            {//dwp необходимо подстветить галочки в каждой зоне в каждом сете, если их там нет конечно
                XmlElement xObjects1, xObjects2, xObjects3;
                XmlNode    xndNodeToTemplate, Xlink, xndFromObjects;

                ObjectsReader obrdUpdater = new ObjectsReader();

                xndFromObjects    = obrdUpdater.GetObjectsData().SelectSingleNode("//Object[@Name='Mines']");
                xObjects1         = Program.frmTemplateEdit.thTemplate.GetObjectsSet(iZoneIndex, 1);
                xndNodeToTemplate = xObjects1.SelectSingleNode(".//Object[@Name='Mines']");

                if (xndNodeToTemplate == null)
                {
                    Xlink = xndFromObjects.CloneNode(true);
                    xObjects1.SelectSingleNode(".//BattleObjects").AppendChild(Program.frmTemplateEdit.thTemplate.xdocTemplateFile.ImportNode(Xlink, true));
                }
                xObjects2         = Program.frmTemplateEdit.thTemplate.GetObjectsSet(iZoneIndex, 2);
                xndNodeToTemplate = xObjects2.SelectSingleNode(".//Object[@Name='Mines']");
                if (xndNodeToTemplate == null)
                {
                    Xlink = xndFromObjects.CloneNode(true);
                    xObjects2.SelectSingleNode(".//BattleObjects").AppendChild(Program.frmTemplateEdit.thTemplate.xdocTemplateFile.ImportNode(Xlink, true));
                }
                xObjects3         = Program.frmTemplateEdit.thTemplate.GetObjectsSet(iZoneIndex, 3);
                xndNodeToTemplate = xObjects3.SelectSingleNode(".//Object[@Name='Mines']");
                if (xndNodeToTemplate == null)
                {
                    Xlink = xndFromObjects.CloneNode(true);
                    xObjects3.SelectSingleNode(".//BattleObjects").AppendChild(Program.frmTemplateEdit.thTemplate.xdocTemplateFile.ImportNode(Xlink, true));
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// updates all data from gui to template
        /// </summary>
        public void UpdateTemplate()
        {
            //used to read object data and update gui changes
            ObjectsReader obrdUpdater = new ObjectsReader();

            //Program.frmTemplateEdit.thTemplate.GetObjectsSet (

            //this updates all gui changes to all objects
            #region iterates through all chklists and update all changes

            for (int i = 1; i < chklstBattleObjects.Items.Count; i++)
            {
                TemplateMapObject tmoObject = (TemplateMapObject)chklstBattleObjects.Items[i];

                if (this.chklstBattleObjects.CheckedItems.Contains(tmoObject))
                {
                    obrdUpdater.UpdateObject(tmoObject);
                }
                else
                {
                    obrdUpdater.UpdateObjectWithZeroChance(tmoObject);
                }
            }

            for (int i = 1; i < chklstEnhancingObjects.Items.Count; i++)
            {
                TemplateMapObject tmoObject = (TemplateMapObject)chklstEnhancingObjects.Items[i];

                if (this.chklstEnhancingObjects.CheckedItems.Contains(tmoObject))
                {
                    obrdUpdater.UpdateObject(tmoObject);
                }
                else
                {
                    obrdUpdater.UpdateObjectWithZeroChance(tmoObject);
                }
            }

            for (int i = 1; i < chklstArtifacts.Items.Count; i++)
            {
                TemplateMapObject tmoObject = (TemplateMapObject)chklstArtifacts.Items[i];

                if (this.chklstArtifacts.CheckedItems.Contains(tmoObject))
                {
                    obrdUpdater.UpdateObject(tmoObject);
                }
                else
                {
                    obrdUpdater.UpdateObjectWithZeroChance(tmoObject);
                }
            }

            #endregion

            //update zones general appear chance
            Program.frmTemplateEdit.thTemplate.UpdateZoneAttribute(iZoneIndex, "ObjectsSet" + iObjectSet.ToString(), msktxtChance.Text, "Appear_Chance");
            Program.frmTemplateEdit.thTemplate.UpdateZoneAttribute(iZoneIndex, "ObjectsSet" + iObjectSet.ToString(), msktxtDwellNumber.Text, "Dwelling_Number");


            //this will insert the new Objects node inside right zone and object set
            Program.frmTemplateEdit.thTemplate.UpdateObjectSetProperty(obrdUpdater.GetObjectsData(), iZoneIndex, iObjectSet);
        }