protected override void ResourceLoader ()
		{
			base.ResourceLoader ();

			for (int i = 0; i < Elements.Count; i ++)
				Console.WriteLine ("{0}: {1} '{2}' : {3}", i, Elements[i].Type, Elements[i].Text, Elements[i].Flags);

			Elements[FIRST_CAMPAIGN_ELEMENT_INDEX].Flags |= ElementFlags.BottomAlignText;
			Elements[SECOND_CAMPAIGN_ELEMENT_INDEX].Flags |= ElementFlags.BottomAlignText;
			Elements[THIRD_CAMPAIGN_ELEMENT_INDEX].Flags |= ElementFlags.BottomAlignText;

			Elements[THIRD_CAMPAIGN_ELEMENT_INDEX].MouseEnterEvent += 
				delegate () {
					Console.WriteLine ("over third campaign element");
					if (true /* XXX this should come from the player's file */) {
						Elements[THIRD_BUT_FIRST_INCOMPLETE_INDEX].Visible = true;
					}
				};

			Elements[THIRD_CAMPAIGN_ELEMENT_INDEX].MouseLeaveEvent += 
				delegate () {
					if (true /* XXX this should come from the player's file */) {
						Elements[THIRD_BUT_FIRST_INCOMPLETE_INDEX].Visible = false;
					}
				};

			Elements[SECOND_CAMPAIGN_ELEMENT_INDEX].MouseEnterEvent += 
				delegate () {
					Console.WriteLine ("over second campaign element");
					if (true /* XXX this should come from the player's file */) {
						Elements[SECOND_BUT_FIRST_INCOMPLETE_INDEX].Visible = true;
					}
				};

			Elements[SECOND_CAMPAIGN_ELEMENT_INDEX].MouseLeaveEvent += 
				delegate () {
					if (true /* XXX this should come from the player's file */) {
						Elements[SECOND_BUT_FIRST_INCOMPLETE_INDEX].Visible = false;
					}
				};

			Elements[FIRST_CAMPAIGN_ELEMENT_INDEX].Activate +=
				delegate () {
					SelectCampaign (0);
				};

			Elements[SECOND_CAMPAIGN_ELEMENT_INDEX].Activate +=
				delegate () {
					SelectCampaign (1);
				};

			Elements[THIRD_CAMPAIGN_ELEMENT_INDEX].Activate +=
				delegate () {
					SelectCampaign (2);
				};


			Elements[CANCEL_ELEMENT_INDEX].Activate +=
				delegate () {
					Game.Instance.SwitchToScreen (UIScreenType.Login);
				};

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

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

			smkElements = new List<UIElement>();

			AddMovieElements (FIRST_CAMPAIGN_ELEMENT_INDEX, 0, -40, 0);
			AddMovieElements (SECOND_CAMPAIGN_ELEMENT_INDEX, 1, 0, 0);
			AddMovieElements (THIRD_CAMPAIGN_ELEMENT_INDEX, 2, 0, 0);

			smkPainter = new UIPainter (smkElements);
		}
Beispiel #2
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);
		}
Beispiel #3
0
        protected override void ResourceLoader()
        {
            base.ResourceLoader();

            for (int i = 0; i < Elements.Count; i++)
            {
                Console.WriteLine("{0}: {1} '{2}' : {3}", i, Elements[i].Type, Elements[i].Text, Elements[i].Flags);
            }

            Elements[FIRST_CAMPAIGN_ELEMENT_INDEX].Flags  |= ElementFlags.BottomAlignText;
            Elements[SECOND_CAMPAIGN_ELEMENT_INDEX].Flags |= ElementFlags.BottomAlignText;
            Elements[THIRD_CAMPAIGN_ELEMENT_INDEX].Flags  |= ElementFlags.BottomAlignText;

            Elements[THIRD_CAMPAIGN_ELEMENT_INDEX].MouseEnterEvent +=
                delegate() {
                Console.WriteLine("over third campaign element");
                if (true /* XXX this should come from the player's file */)
                {
                    Elements[THIRD_BUT_FIRST_INCOMPLETE_INDEX].Visible = true;
                }
            };

            Elements[THIRD_CAMPAIGN_ELEMENT_INDEX].MouseLeaveEvent +=
                delegate() {
                if (true /* XXX this should come from the player's file */)
                {
                    Elements[THIRD_BUT_FIRST_INCOMPLETE_INDEX].Visible = false;
                }
            };

            Elements[SECOND_CAMPAIGN_ELEMENT_INDEX].MouseEnterEvent +=
                delegate() {
                Console.WriteLine("over second campaign element");
                if (true /* XXX this should come from the player's file */)
                {
                    Elements[SECOND_BUT_FIRST_INCOMPLETE_INDEX].Visible = true;
                }
            };

            Elements[SECOND_CAMPAIGN_ELEMENT_INDEX].MouseLeaveEvent +=
                delegate() {
                if (true /* XXX this should come from the player's file */)
                {
                    Elements[SECOND_BUT_FIRST_INCOMPLETE_INDEX].Visible = false;
                }
            };

            Elements[FIRST_CAMPAIGN_ELEMENT_INDEX].Activate +=
                delegate() {
                SelectCampaign(0);
            };

            Elements[SECOND_CAMPAIGN_ELEMENT_INDEX].Activate +=
                delegate() {
                SelectCampaign(1);
            };

            Elements[THIRD_CAMPAIGN_ELEMENT_INDEX].Activate +=
                delegate() {
                SelectCampaign(2);
            };


            Elements[CANCEL_ELEMENT_INDEX].Activate +=
                delegate() {
                Game.Instance.SwitchToScreen(UIScreenType.Login);
            };

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

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

            smkElements = new List <UIElement>();

            AddMovieElements(FIRST_CAMPAIGN_ELEMENT_INDEX, 0, -40, 0);
            AddMovieElements(SECOND_CAMPAIGN_ELEMENT_INDEX, 1, 0, 0);
            AddMovieElements(THIRD_CAMPAIGN_ELEMENT_INDEX, 2, 0, 0);

            smkPainter = new UIPainter(smkElements);
        }
Beispiel #4
0
		protected override void ResourceLoader ()
		{
			base.ResourceLoader ();

			for (int i = 0; i < Elements.Count; i ++)
				Console.WriteLine ("{0}: {1} '{2}' : {3}", i, Elements[i].Type, Elements[i].Text, Elements[i].Flags);

			Elements[VERSION_ELEMENT_INDEX].Text = "v" + Consts.Version;

			Elements[SINGLEPLAYER_ELEMENT_INDEX].Flags |= ElementFlags.RightAlignText | ElementFlags.CenterTextVert;

			Elements[SINGLEPLAYER_ELEMENT_INDEX].Activate +=
				delegate () {
					if (Game.Instance.IsBroodWar) {
						ShowGameModeDialog (UIScreenType.Login);
					}
					else {
						GuiUtil.PlaySound (mpq, Builtins.Mousedown2Wav);
						Game.Instance.SwitchToScreen (UIScreenType.Login);
					}
				};

			Elements[MULTIPLAYER_ELEMENT_INDEX].Activate +=
				delegate () {
					if (Game.Instance.IsBroodWar) {
						ShowGameModeDialog (UIScreenType.Connection);
					}
					else {
						GuiUtil.PlaySound (mpq, Builtins.Mousedown2Wav);
						Game.Instance.SwitchToScreen (UIScreenType.Connection);
					}
				};

			Elements[CAMPAIGNEDITOR_ELEMENT_INDEX].Activate +=
				delegate () {
					OkDialog d = new OkDialog (this, mpq,
								   "The campaign editor functionality is not available in SCSharp");
					ShowDialog (d);
				};

			Elements[INTRO_ELEMENT_INDEX].Activate +=
				delegate () {
					Cinematic introScreen = new Cinematic (mpq,
									       Game.Instance.IsBroodWar
									       ? "smk\\starXIntr.smk"
									       : "smk\\starintr.smk");
					introScreen.Finished += delegate () {
						Game.Instance.SwitchToScreen (this);
					};
					Game.Instance.SwitchToScreen (introScreen);
				};

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

			Elements[EXIT_ELEMENT_INDEX].Activate += 
				delegate () {
					Game.Instance.Quit ();
				};

			smkElements = new List<UIElement>();

			AddMovieElements (SINGLEPLAYER_ELEMENT_INDEX, "glue\\mainmenu\\Single.smk", "glue\\mainmenu\\SingleOn.smk", 50, 70, false);
			AddMovieElements (MULTIPLAYER_ELEMENT_INDEX, "glue\\mainmenu\\Multi.smk", "glue\\mainmenu\\MultiOn.smk", 20, 12, true);
			AddMovieElements (CAMPAIGNEDITOR_ELEMENT_INDEX, "glue\\mainmenu\\Editor.smk", "glue\\mainmenu\\EditorOn.smk", 20, 18, true);
			AddMovieElements (EXIT_ELEMENT_INDEX, "glue\\mainmenu\\Exit.smk", "glue\\mainmenu\\ExitOn.smk", 15, 0, true);

			smkPainter = new UIPainter (smkElements);
		}
Beispiel #5
0
        protected override void ResourceLoader()
        {
            base.ResourceLoader();

            for (int i = 0; i < Elements.Count; i++)
            {
                Console.WriteLine("{0}: {1} '{2}' : {3}", i, Elements[i].Type, Elements[i].Text, Elements[i].Flags);
            }

            Elements[VERSION_ELEMENT_INDEX].Text = "v" + Consts.Version;

            Elements[SINGLEPLAYER_ELEMENT_INDEX].Flags |= ElementFlags.RightAlignText | ElementFlags.CenterTextVert;

            Elements[SINGLEPLAYER_ELEMENT_INDEX].Activate +=
                delegate() {
                if (Game.Instance.IsBroodWar)
                {
                    ShowGameModeDialog(UIScreenType.Login);
                }
                else
                {
                    GuiUtil.PlaySound(mpq, Builtins.Mousedown2Wav);
                    Game.Instance.SwitchToScreen(UIScreenType.Login);
                }
            };

            Elements[MULTIPLAYER_ELEMENT_INDEX].Activate +=
                delegate() {
                if (Game.Instance.IsBroodWar)
                {
                    ShowGameModeDialog(UIScreenType.Connection);
                }
                else
                {
                    GuiUtil.PlaySound(mpq, Builtins.Mousedown2Wav);
                    Game.Instance.SwitchToScreen(UIScreenType.Connection);
                }
            };

            Elements[CAMPAIGNEDITOR_ELEMENT_INDEX].Activate +=
                delegate() {
                OkDialog d = new OkDialog(this, mpq,
                                          "The campaign editor functionality is not available in SCSharp");
                ShowDialog(d);
            };

            Elements[INTRO_ELEMENT_INDEX].Activate +=
                delegate() {
                Cinematic introScreen = new Cinematic(mpq,
                                                      Game.Instance.IsBroodWar
                                                                               ? "smk\\starXIntr.smk"
                                                                               : "smk\\starintr.smk");
                introScreen.Finished += delegate() {
                    Game.Instance.SwitchToScreen(this);
                };
                Game.Instance.SwitchToScreen(introScreen);
            };

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

            Elements[EXIT_ELEMENT_INDEX].Activate +=
                delegate() {
                Game.Instance.Quit();
            };

            smkElements = new List <UIElement>();

            AddMovieElements(SINGLEPLAYER_ELEMENT_INDEX, "glue\\mainmenu\\Single.smk", "glue\\mainmenu\\SingleOn.smk", 50, 70, false);
            AddMovieElements(MULTIPLAYER_ELEMENT_INDEX, "glue\\mainmenu\\Multi.smk", "glue\\mainmenu\\MultiOn.smk", 20, 12, true);
            AddMovieElements(CAMPAIGNEDITOR_ELEMENT_INDEX, "glue\\mainmenu\\Editor.smk", "glue\\mainmenu\\EditorOn.smk", 20, 18, true);
            AddMovieElements(EXIT_ELEMENT_INDEX, "glue\\mainmenu\\Exit.smk", "glue\\mainmenu\\ExitOn.smk", 15, 0, true);

            smkPainter = new UIPainter(smkElements);
        }