public CaNew(CaBase cab, string strTitle, string strKind, Type[] atype, string[] astrName) { // // Required for Windows Form Designer support // InitializeComponent(); m_atype = atype; m_cab = null; m_strParse = null; m_strKind = strKind; // To do - might want to pretty print these type names Text = strTitle; m_labelWhatType.Text = m_labelWhatType.Text.Replace("$1", strKind); m_labelText.Text = m_labelText.Text.Replace("$1", strKind); Array.Sort(astrName, atype); Array.Sort(astrName); m_comboBoxType.DataSource = astrName; m_cab = cab; if (cab != null) { m_comboBoxType.SelectedIndex = Array.IndexOf(atype, m_cab.GetType()); } else { m_comboBoxType.SelectedIndex = 0; } SelectCa(m_comboBoxType.SelectedIndex); }
public static CaBase DoModal(CaBase cab, string strTitle, string strKind) { string strEndsWith = strKind; System.Reflection.Assembly ass = typeof(CaBase).Module.Assembly; Type[] atype = ass.GetTypes(); ArrayList alsType = new ArrayList(); ArrayList alsName = new ArrayList(); foreach (Type type in atype) { string strName = type.ToString(); if (strName.EndsWith(strEndsWith)) { alsType.Add(type); string strDisplayName = Helper.GetDisplayName(type); if (strDisplayName == null) { int ichDot = strName.IndexOf('.'); strDisplayName = strName.Substring(ichDot + 1, strName.Length - (ichDot + 1 + strEndsWith.Length)); } alsName.Add(strDisplayName); } } CaNew frmCaNew = new CaNew(cab, strTitle, strKind, (Type[])alsType.ToArray(typeof(Type)), (string[])alsName.ToArray(typeof(string))); frmCaNew.ShowDialog(); if (frmCaNew.DialogResult == DialogResult.Cancel) { return(null); } return(frmCaNew.GetCab()); }
// Displays the UI for value selection. public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { CaBase cab = (CaBase)value; cab = CaNew.DoModal(cab.Clone(), "Modify Action", "UnitAction"); return(cab == null ? value : cab); }
void SelectCa(int n) { if (m_cab == null || m_cab.GetType() != m_atype[n]) { m_cab = (CaBase)System.Activator.CreateInstance(m_atype[n]); } m_labelDescription.Text = Helper.GetDescription(m_cab.GetType()); m_richTextBox.Clear(); // String replacement, order independent string str = m_cab.GetString(); CaType[] acat = m_cab.GetTypes(); for (int j = 0; j < acat.Length; j++) { str = str.Replace("$" + (j + 1), "~" + j + acat[j].ToString() + "~" + j); } // Save this away for hittesting purposes m_strParse = (string)str.Clone(); // && delimited pieces are links while (str.Length != 0) { int ichT = str.IndexOf("~"); if (ichT == -1) { m_richTextBox.AppendText(str); break; } if (ichT != 0) { m_richTextBox.AppendText(str.Substring(0, ichT)); } str = str.Remove(0, ichT + 2); // Now add the underlined text int ichStart = m_richTextBox.TextLength; int cchLink = str.IndexOf("~"); Debug.Assert(cchLink != -1); m_richTextBox.AppendText(str.Substring(0, cchLink)); str = str.Remove(0, cchLink + 2); m_richTextBox.Select(ichStart, cchLink); Color clr = m_richTextBox.SelectionColor; Font fnt = m_richTextBox.SelectionFont; m_richTextBox.SelectionColor = Color.Blue; m_richTextBox.SelectionFont = new Font(fnt.FontFamily, fnt.Size, /* FontStyle.Bold | */ FontStyle.Underline); m_richTextBox.Select(m_richTextBox.TextLength, 0); m_richTextBox.SelectionFont = fnt; m_richTextBox.SelectionColor = clr; } }
private void buttonNewCondition_Click(object sender, System.EventArgs e) { CaBase cab = CaNew.DoModal(null, "New Condition", "Condition"); if (cab != null) { m_tgr.Conditions.Add(cab); InitConditionsListBox(m_tgr.Conditions.Count - 1); } }
private void buttonNewAction_Click(object sender, System.EventArgs e) { CaBase cab = CaNew.DoModal(null, "New Action", "UnitGroupAction"); if (cab != null) { m_ugSelected.Actions.Add(cab); InitActionsListBox(m_ugSelected.Actions.Count - 1); } }
public static UnitGroup FromIniSection(Ini.Section sec) { UnitGroup ug = new UnitGroup(sec["Name"].Value); ug.Side = (Side)int.Parse(sec["Side"].Value); ug.Aggressiveness = (Aggressiveness)int.Parse(sec["Aggressiveness"].Value); ug.LoopForever = (int.Parse(sec["LoopForever"].Value) != 0); ug.CreateAtLevelLoad = (int.Parse(sec["CreateAtLevelLoad"].Value) != 0); ug.RandomGroup = (int.Parse(sec["RandomGroup"].Value) != 0); ug.Spawn = (int.Parse(sec["Spawn"].Value) != 0); ug.ReplaceDestroyedGroup = (int.Parse(sec["ReplaceGroup"].Value) != 0); if (sec["SpawnArea"] != null) { ug.SpawnArea = CaTypeArea.GetAreaNameFromIndex(int.Parse(sec["SpawnArea"].Value)); } ug.Health = int.Parse(sec["Health"].Value); // Units string strUTC = null; if (sec["Units"] != null) { strUTC = sec["Units"].Value; } if (strUTC != null) { Regex re = new Regex(@"^(?<count>\d+),(?<end>.*)$"); Match m = re.Match(strUTC); string strT = m.Groups["end"].Value; while (strT.Length != 0) { UnitTypeAndCount utc = new UnitTypeAndCount(); strT = utc.FromSaveString(strT); ug.UnitTypeAndCounts.Add(utc); re = new Regex(@"^\s*,(?<end>.*)$"); m = re.Match(strT); strT = m.Groups["end"].Value; } } // UnitGroup actions foreach (Ini.Property prop in sec.Properties) { if (prop.Name != "A") { continue; } CaBase cab = UnitGroupActionLoader.LoadIni(prop.Value); ug.Actions.Add(cab); } return(ug); }
private void buttonCopyAction_Click(object sender, System.EventArgs e) { int n = checkedListBoxActions.SelectedIndex; if (n < 0) { return; } CaBase cab = (CaBase)m_ugSelected.Actions[n]; m_ugSelected.Actions.Add(cab.Clone()); InitActionsListBox(m_ugSelected.Actions.Count - 1); }
private void checkedListBoxConditions_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e) { if (e.CurrentValue == CheckState.Unchecked && e.NewValue == CheckState.Checked) { CaBase cab = (CaBase)m_tgr.Conditions[e.Index]; cab.Active = true; } if (e.CurrentValue == CheckState.Checked && e.NewValue == CheckState.Unchecked) { CaBase cab = (CaBase)m_tgr.Conditions[e.Index]; cab.Active = false; } }
private void buttonMoveDownAction_Click(object sender, System.EventArgs e) { int n = checkedListBoxActions.SelectedIndex; if (n < 0 || n >= checkedListBoxActions.Items.Count - 1) { return; } CaBase cab = (CaBase)m_ugSelected.Actions[n]; m_ugSelected.Actions.RemoveAt(n); m_ugSelected.Actions.Insert(n + 1, cab); InitActionsListBox(n + 1); }
private void buttonMoveUpAction_Click(object sender, System.EventArgs e) { int n = checkedListBoxActions.SelectedIndex; if (n <= 0) { return; } CaBase cab = (CaBase)m_tgr.Actions[n]; m_tgr.Actions.RemoveAt(n); m_tgr.Actions.Insert(n - 1, cab); InitActionsListBox(n - 1); }
private void buttonModifyAction_Click(object sender, System.EventArgs e) { int n = checkedListBoxActions.SelectedIndex; if (n < 0) { return; } CaBase cab = (CaBase)m_ugSelected.Actions[n]; cab = CaNew.DoModal(cab.Clone(), "Modify Action", "UnitGroupAction"); if (cab != null) { m_ugSelected.Actions[n] = cab; InitActionsListBox(n); } }
public MediumTank(Side side, int tx, int ty, Aggressiveness aggr, CaBase cab) : base(side, tx, ty, aggr, cab) { }
public RocketVehicle(Side side, int tx, int ty, Aggressiveness aggr, CaBase cab) : base(side, tx, ty, aggr, cab) { }
public GalaxMiner(Side side, int tx, int ty, Aggressiveness aggr, CaBase cab) : base(side, tx, ty, aggr, cab) { m_aggr = Aggressiveness.Coward; }
public MobileHeadquarters(Side side, int tx, int ty, Aggressiveness aggr, CaBase cab) : base(side, tx, ty, aggr, cab) { m_aggr = Aggressiveness.Coward; }
public Fox(Side side, int tx, int ty, Aggressiveness aggr, CaBase cab) : base(side, tx, ty, aggr, cab) { }
public MachineGunVehicle(Side side, int tx, int ty, Aggressiveness aggr, CaBase cab) : base(side, tx, ty, aggr, cab) { }
public TakeoverSpecialist(Side side, int tx, int ty, Aggressiveness aggr, CaBase cab) : base(side, tx, ty, aggr, cab) { m_aggr = Aggressiveness.Coward; }
public LongRangeInfantry(Side side, int tx, int ty, Aggressiveness aggr, CaBase cab) : base(side, tx, ty, aggr, cab) { }
public MobileUnit(Side side, int tx, int ty, Aggressiveness aggr, CaBase cab) : base(side, tx, ty) { m_aggr = aggr; m_cab = cab; }