Exemplo n.º 1
0
        protected override void SaveTypeByIndex(List <string> values, int selectedIndex, Skriptum changed = null)
        {
            string tmp = values[0] + " " + values[1] + " " + GetFlags() + " " + menuID_cbb.SelectedIndex + " " + faction_cbb.SelectedIndex + " " + GetPersonality();

            for (int i = 0; i < stack_troops_lb.Items.Count; i++)
            {
                tmp += " " + CodeReader.Troops.IndexOf("trp_" + stack_troops_lb.Items[i].ToString()) + " " + memberValues[i][0] + " " + memberValues[i][1] + " " + memberValues[i][2];
            }

            //for invalid troops
            for (int i = 0; i < 6 - stack_troops_lb.Items.Count; i++)
            {
                tmp += " -1 0 0 0";
            }
            //for invalid troops

            values.Clear();
            foreach (string value in tmp.Split())
            {
                values.Add(value);
            }
            values[0] = values[0].Substring(3);

            string[]      valuesX = values.ToArray();
            PartyTemplate p       = new PartyTemplate(valuesX);

            CodeWriter.SavePseudoCodeByType(p, valuesX);

            base.SaveTypeByIndex(values, selectedIndex, p);
        }
Exemplo n.º 2
0
        protected override void SetupType(Skriptum type)
        {
            base.SetupType(type);

            PartyTemplate partyTemplate = (PartyTemplate)type;

            #region GROUP2 - Flags

            List <string> flags    = new List <string>(partyTemplate.Flags.Split('|'));
            List <string> mapicons = new List <string>(CodeReader.MapIcons);

            map_icon_cbb.SelectedIndex = mapicons.IndexOf(flags[0]);

            if (flags.Contains("pf_label_large"))
            {
                large_label_rb.Checked = true;
            }
            else if (flags.Contains("pf_label_medium"))
            {
                medium_label_rb.Checked = true;
            }
            else if (flags.Contains("pf_label_small"))
            {
                small_label_rb.Checked = true;
            }
            if (flags.Contains("pf_no_label"))
            {
                no_label_rb.Checked = true;
            }

            Control c;
            string  nameEnd;
            bool    found = false;
            foreach (string flag in flags)
            {
                for (int i = 0; i < groupBox_1_gb.Controls.Count; i++)
                {
                    c       = groupBox_1_gb.Controls[i];
                    nameEnd = GetNameEndOfControl(c);
                    if (flag.Equals("pf_" + c.Name.Remove(c.Name.LastIndexOf('_'))))
                    {
                        if (nameEnd.Equals("rb"))
                        {
                            ((RadioButton)c).Checked = true;
                        }
                        else
                        {
                            ((CheckBox)c).CheckState = CheckState.Checked;
                        }
                        found = true;
                    }
                    else if (flag.Contains("carries_"))
                    {
                        string f = flag.Substring(flag.IndexOf('(') + 1).Split(')')[0];
                        if (flag.Contains("goods"))
                        {
                            carries_goods_txt.Text = f;
                        }
                        else
                        {
                            carries_gold_txt.Text = f;
                        }
                        found = true;
                    }
                    if (found)
                    {
                        i = groupBox_1_gb.Controls.Count;
                    }
                }
            }

            #endregion

            #region GROUP3

            menuID_cbb.SelectedIndex  = partyTemplate.MenuID;
            faction_cbb.SelectedIndex = partyTemplate.FactionID;

            #endregion

            #region GROUP4

            char[] personality = HexConverter.Dec2Hex(partyTemplate.Personality).ToString().Substring(5).ToCharArray();
            courage_num.Value        = int.Parse(personality[0].ToString());
            aggressiveness_num.Value = int.Parse(personality[1].ToString());
            if (personality[2] != '0')
            {
                banditness_cb.CheckState = CheckState.Checked;
            }

            #endregion

            #region Stack Troops - GROUP5

            memberValues.Clear();
            stack_troops_lb.Items.Clear();
            if (!partyTemplate.Members[0].Troop.Equals("-1"))
            {
                foreach (PMember member in partyTemplate.Members)
                {
                    if (!member.Troop.Equals("-1"))
                    {
                        stack_troops_lb.Items.Add(member.Troop);
                        int[] values = new int[3];
                        values[0] = member.MinimumTroops;
                        values[1] = member.MaximumTroops;
                        values[2] = member.Flags;
                        memberValues.Add(values);
                    }
                }
                if (partyTemplate.Members.Length > 0)
                {
                    stack_troops_lb.SelectedIndex = 0;
                }
            }

            #endregion
        }