コード例 #1
0
        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].Activate +=
                delegate() {
                if (Ok != null)
                {
                    Ok();
                }
            };

            ListBoxElement list     = (ListBoxElement)Elements[HELPLIST_ELEMENT_INDEX];
            Tbl            help_txt = (Tbl)mpq.GetResource(Builtins.rez_HelpTxtTbl);

            for (int i = 0; i < help_txt.Strings.Length; i++)
            {
                list.AddItem(help_txt.Strings[i]);
            }
        }
コード例 #2
0
ファイル: ConnectionScreen.cs プロジェクト: xerohour/scsharp
        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);
            }

            titles       = new string[num_choices];
            descriptions = new string[num_choices];

            for (int i = 0; i < num_choices; i++)
            {
                titles[i]       = GlobalResources.Instance.GluAllTbl[title_startidx + i];
                descriptions[i] = GlobalResources.Instance.GluAllTbl[description_startidx + i];
            }
            listbox = (ListBoxElement)Elements[LISTBOX_ELEMENT_INDEX];

            foreach (string s in titles)
            {
                listbox.AddItem(s);
            }

            listbox.SelectedIndex = 0;
            HandleSelectionChanged(0);

            listbox.SelectionChanged += HandleSelectionChanged;

            Elements[OK_ELEMENT_INDEX].Activate +=
                delegate() {
                if (listbox.SelectedItem == "Battle.net")
                {
                    ShowDialog(new OkDialog(this, mpq,
                                            "insert battle.net code here"));
                }
                else
                {
                    ShowDialog(new OkDialog(this, mpq,
                                            "scsharp will only support battle.net play"));
                }
            };

            Elements[CANCEL_ELEMENT_INDEX].Activate +=
                delegate() {
                Game.Instance.SwitchToScreen(UIScreenType.MainMenu);
            };
        }
コード例 #3
0
		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);

			titles = new string[num_choices];
			descriptions = new string[num_choices];

			for (int i = 0; i < num_choices; i ++) {
				titles[i] = GlobalResources.Instance.GluAllTbl[ title_startidx + i ];
				descriptions[i] = GlobalResources.Instance.GluAllTbl[ description_startidx + i ];
			}
			listbox = (ListBoxElement)Elements[LISTBOX_ELEMENT_INDEX];

			foreach (string s in titles)
				listbox.AddItem (s);

			listbox.SelectedIndex = 0;
			HandleSelectionChanged (0);

			listbox.SelectionChanged += HandleSelectionChanged;

			Elements[OK_ELEMENT_INDEX].Activate +=
				delegate () {
					if (listbox.SelectedItem == "Battle.net")
						ShowDialog (new OkDialog (this, mpq,
									  "insert battle.net code here"));
					else
						ShowDialog (new OkDialog (this, mpq,
									  "scsharp will only support battle.net play"));
				};

			Elements[CANCEL_ELEMENT_INDEX].Activate +=
				delegate () {
					Game.Instance.SwitchToScreen (UIScreenType.MainMenu);
				};
		}
コード例 #4
0
ファイル: PlayCustomScreen.cs プロジェクト: xerohour/scsharp
        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);
            }

            /* these don't ever show up in the UI, that i know of... */
            Elements[GAMESUBTYPE_LABEL_ELEMENT_INDEX].Visible = false;
            Elements[GAMESUBTYPE_COMBO_ELEMENT_INDEX].Visible = false;

            /* initialize all the race combo boxes */
            for (int i = 0; i < max_players; i++)
            {
                InitializePlayerCombo((ComboBoxElement)Elements[PLAYER1_COMBOBOX_PLAYER + i]);
                InitializeRaceCombo((ComboBoxElement)Elements[PLAYER1_COMBOBOX_RACE + i]);
            }

            file_listbox   = (ListBoxElement)Elements[FILELISTBOX_ELEMENT_INDEX];
            gametype_combo = (ComboBoxElement)Elements[GAMETYPECOMBO_ELEMENT_INDEX];

            /* initially populate the map list by scanning the maps/ directory in the starcraftdir */
            mapdir = Path.Combine(Game.Instance.RootDirectory, "maps");
            curdir = mapdir;

            PopulateGameTypes();
            PopulateFileList();

            file_listbox.SelectionChanged   += FileListSelectionChanged;
            gametype_combo.SelectionChanged += GameTypeSelectionChanged;

            Elements[OK_ELEMENT_INDEX].Activate +=
                delegate() {
                if (selectedScenario == null)
                {
                    // the selected entry is a directory, switch to it
                    if (curdir != mapdir && file_listbox.SelectedIndex == 0)
                    {
                        curdir = Directory.GetParent(curdir).FullName;
                    }
                    else
                    {
                        curdir = directories[file_listbox.SelectedIndex];
                    }

                    PopulateFileList();
                }
                else
                {
                    Game.Instance.SwitchToScreen(new GameScreen(mpq,
                                                                selectedScenario,
                                                                selectedChk,
                                                                selectedGot));
                }
            };

            Elements[CANCEL_ELEMENT_INDEX].Activate +=
                delegate() {
                Game.Instance.SwitchToScreen(new RaceSelectionScreen(mpq));
            };


            /* make sure the PLAYER1 player combo reads
             * the player's name and is desensitized */
            ((ComboBoxElement)Elements[PLAYER1_COMBOBOX_PLAYER]).AddItem(/*XXX player name*/ "toshok");
            Elements[PLAYER1_COMBOBOX_PLAYER].Sensitive = false;
        }
コード例 #5
0
ファイル: PlayCustomScreen.cs プロジェクト: directhex/scsharp
        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);

            /* these don't ever show up in the UI, that i know of... */
            Elements[GAMESUBTYPE_LABEL_ELEMENT_INDEX].Visible = false;
            Elements[GAMESUBTYPE_COMBO_ELEMENT_INDEX].Visible = false;

            /* initialize all the race combo boxes */
            for (int i = 0; i < max_players; i ++) {
                InitializePlayerCombo ((ComboBoxElement)Elements[PLAYER1_COMBOBOX_PLAYER + i]);
                InitializeRaceCombo ((ComboBoxElement)Elements[PLAYER1_COMBOBOX_RACE + i]);
            }

            file_listbox = (ListBoxElement)Elements[FILELISTBOX_ELEMENT_INDEX];
            gametype_combo = (ComboBoxElement)Elements[GAMETYPECOMBO_ELEMENT_INDEX];

            /* initially populate the map list by scanning the maps/ directory in the starcraftdir */
            mapdir = Path.Combine (Game.Instance.RootDirectory, "maps");
            curdir = mapdir;

            PopulateGameTypes ();
            PopulateFileList ();

            file_listbox.SelectionChanged += FileListSelectionChanged;
            gametype_combo.SelectionChanged += GameTypeSelectionChanged;

            Elements[OK_ELEMENT_INDEX].Activate +=
                delegate () {
                    if (selectedScenario == null) {
                        // the selected entry is a directory, switch to it
                        if (curdir != mapdir && file_listbox.SelectedIndex == 0)
                            curdir = Directory.GetParent (curdir).FullName;
                        else
                            curdir = directories[file_listbox.SelectedIndex];

                        PopulateFileList ();
                    }
                    else {
                        Game.Instance.SwitchToScreen (new GameScreen (mpq,
                                                  selectedScenario,
                                                  selectedChk,
                                                  selectedGot));
                    }
                };

            Elements[CANCEL_ELEMENT_INDEX].Activate +=
                delegate () {
                    Game.Instance.SwitchToScreen (new RaceSelectionScreen (mpq));
                };

            /* make sure the PLAYER1 player combo reads
             * the player's name and is desensitized */
            ((ComboBoxElement)Elements[PLAYER1_COMBOBOX_PLAYER]).AddItem (/*XXX player name*/"toshok");
            Elements[PLAYER1_COMBOBOX_PLAYER].Sensitive = false;
        }
コード例 #6
0
		protected virtual void ResourceLoader ()
		{
			Stream s;

			fontpal = null;
			effectpal = null;

			if (fontpal_path != null) {
				Console.WriteLine ("loading font palette");
				s = (Stream)mpq.GetResource (fontpal_path);
				if (s != null) {
					fontpal = new Pcx ();
					fontpal.ReadFromStream (s, -1, -1);
				}
			}
			if (effectpal_path != null) {
				Console.WriteLine ("loading cursor palette");
				s = (Stream)mpq.GetResource (effectpal_path);
				if (s != null) {
					effectpal = new Pcx ();
					effectpal.ReadFromStream (s, -1, -1);
				}
				if (effectpal != null && arrowgrp_path != null) {
					Console.WriteLine ("loading arrow cursor");
					Grp arrowgrp = (Grp)mpq.GetResource (arrowgrp_path);
					if (arrowgrp != null) {
						Cursor = new CursorAnimator (arrowgrp, effectpal.Palette);
						Cursor.SetHotSpot (64, 64);
					}
				}
			}

			if (background_path != null) {
				Console.WriteLine ("loading background");
				background = GuiUtil.SurfaceFromStream ((Stream)mpq.GetResource (background_path),
									background_translucent, background_transparent);
			}

			Elements = new List<UIElement> ();
			if (binFile != null) {
				Console.WriteLine ("loading ui elements");
				Bin = (Bin)mpq.GetResource (binFile);

				if (Bin == null)
					throw new Exception (String.Format ("specified file '{0}' does not exist",
									    binFile));

				/* convert all the BinElements to UIElements for our subclasses to use */
				foreach (BinElement el in Bin.Elements) {
					//					Console.WriteLine ("{0}: {1}", el.text, el.flags);

					UIElement ui_el = null;
					switch (el.type) {
					case ElementType.DialogBox:
						ui_el = new DialogBoxElement (this, el, fontpal.RgbData);
						break;
					case ElementType.Image:
						ui_el = new ImageElement (this, el, fontpal.RgbData, translucentIndex);
						break;
					case ElementType.TextBox:
						ui_el = new TextBoxElement (this, el, fontpal.RgbData);
						break;
					case ElementType.ListBox:
						ui_el = new ListBoxElement (this, el, fontpal.RgbData);
						break;
					case ElementType.ComboBox:
						ui_el = new ComboBoxElement (this, el, fontpal.RgbData);
						break;
					case ElementType.LabelLeftAlign:
					case ElementType.LabelCenterAlign:
					case ElementType.LabelRightAlign:
						ui_el = new LabelElement (this, el, fontpal.RgbData);
						break;
					case ElementType.Button:
					case ElementType.DefaultButton:
					case ElementType.ButtonWithoutBorder:
						ui_el = new ButtonElement(this, el, fontpal.RgbData);
						break;
					case ElementType.Slider:
					case ElementType.OptionButton:
					case ElementType.CheckBox:
						ui_el = new UIElement (this, el, fontpal.RgbData);
						break;
					default:
						Console.WriteLine ("unhandled case {0}", el.type);
						ui_el = new UIElement (this, el, fontpal.RgbData);
						break;
					}

					Elements.Add (ui_el);
				}
			}

			UIPainter = new UIPainter (Elements);
		}
コード例 #7
0
ファイル: LoginScreen.cs プロジェクト: directhex/scsharp
        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 ();
        }
コード例 #8
0
        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();
        }