protected override void ResourceLoader() { base.ResourceLoader (); for (int i = 0; i < Elements.Count; i ++) Console.WriteLine ("{0}: {1} '{2}'", i, Elements[i].Type, Elements[i].Text); Elements[OK_ELEMENT_INDEX].Sensitive = false; Elements[OK_ELEMENT_INDEX].Activate += delegate () { if (listbox.SelectedIndex == -1) return; Game.Instance.SwitchToScreen (new RaceSelectionScreen (mpq)); }; Elements[CANCEL_ELEMENT_INDEX].Activate += delegate () { Game.Instance.SwitchToScreen (UIScreenType.MainMenu); }; Elements[NEW_ELEMENT_INDEX].Activate += delegate () { EntryDialog d = new EntryDialog (this, mpq, GlobalResources.Instance.GluAllTbl.Strings[22]); d.Cancel += delegate () { DismissDialog (); }; d.Ok += delegate () { if (listbox.Contains (d.Value)) { NameAlreadyExists (d); } else { DismissDialog (); listbox.AddItem (d.Value); } }; ShowDialog (d); }; Elements[DELETE_ELEMENT_INDEX].Sensitive = false; Elements[DELETE_ELEMENT_INDEX].Activate += delegate () { OkCancelDialog okd = new OkCancelDialog (this, mpq, GlobalResources.Instance.GluAllTbl.Strings[23]); okd.Cancel += delegate () { DismissDialog (); }; okd.Ok += delegate () { DismissDialog (); /* actually delete the file */ listbox.RemoveAt (listbox.SelectedIndex); }; ShowDialog (okd); }; listbox = (ListBoxElement)Elements[LISTBOX_ELEMENT_INDEX]; listbox.SelectionChanged += delegate (int selectedIndex) { Elements[OK_ELEMENT_INDEX].Sensitive = true; Elements[DELETE_ELEMENT_INDEX].Sensitive = true; }; spcdir = Path.Combine (Game.Instance.RootDirectory, "characters"); if (!Directory.Exists (spcdir)) Directory.CreateDirectory (spcdir); PopulateUIFromDir (); }
protected override void ResourceLoader() { base.ResourceLoader(); for (int i = 0; i < Elements.Count; i++) { Console.WriteLine("{0}: {1} '{2}'", i, Elements[i].Type, Elements[i].Text); } Elements[OK_ELEMENT_INDEX].Sensitive = false; Elements[OK_ELEMENT_INDEX].Activate += delegate() { if (listbox.SelectedIndex == -1) { return; } Game.Instance.SwitchToScreen(new RaceSelectionScreen(mpq)); }; Elements[CANCEL_ELEMENT_INDEX].Activate += delegate() { Game.Instance.SwitchToScreen(UIScreenType.MainMenu); }; Elements[NEW_ELEMENT_INDEX].Activate += delegate() { EntryDialog d = new EntryDialog(this, mpq, GlobalResources.Instance.GluAllTbl.Strings[22]); d.Cancel += delegate() { DismissDialog(); }; d.Ok += delegate() { if (listbox.Contains(d.Value)) { NameAlreadyExists(d); } else { DismissDialog(); listbox.AddItem(d.Value); } }; ShowDialog(d); }; Elements[DELETE_ELEMENT_INDEX].Sensitive = false; Elements[DELETE_ELEMENT_INDEX].Activate += delegate() { OkCancelDialog okd = new OkCancelDialog(this, mpq, GlobalResources.Instance.GluAllTbl.Strings[23]); okd.Cancel += delegate() { DismissDialog(); }; okd.Ok += delegate() { DismissDialog(); /* actually delete the file */ listbox.RemoveAt(listbox.SelectedIndex); }; ShowDialog(okd); }; listbox = (ListBoxElement)Elements[LISTBOX_ELEMENT_INDEX]; listbox.SelectionChanged += delegate(int selectedIndex) { Elements[OK_ELEMENT_INDEX].Sensitive = true; Elements[DELETE_ELEMENT_INDEX].Sensitive = true; }; spcdir = Path.Combine(Game.Instance.RootDirectory, "characters"); if (!Directory.Exists(spcdir)) { Directory.CreateDirectory(spcdir); } PopulateUIFromDir(); }