Inheritance: UIElement
Example #1
0
        void AddMovieElements(int elementIndex, int campaign, int off_x, int off_y)
        {
            MovieElement normalElement, onElement, diskElement;

            if (diskPlayer == null)
            {
                diskPlayer = new SmackerPlayer((Stream)Mpq.GetResource(Game.Instance.PlayingBroodWar ? "glue\\Expcampaign\\disk.smk" : "glue\\campaign\\disk.smk"), 1);
            }

            diskElement = new MovieElement(this,
                                           Elements[elementIndex].BinElement,
                                           Elements[elementIndex].Palette,
                                           diskPlayer);

            diskElement.X1 = (ushort)(Elements[elementIndex].X1 + ((Elements[elementIndex].Width - diskElement.MovieSize.Width) / 2));
            diskElement.Y1 = (ushort)(((ButtonElement)Elements[elementIndex]).TextPosition.Y - diskElement.MovieSize.Height);

            normalElement = new MovieElement(this,
                                             Elements[elementIndex].BinElement,
                                             Elements[elementIndex].Palette,
                                             (Game.Instance.PlayingBroodWar ? BroodwarCampaigns : StarcraftCampaigns)[campaign].normalMovie);

            normalElement.X1 = (ushort)(Elements[elementIndex].X1 + ((Elements[elementIndex].Width - normalElement.MovieSize.Width) / 2) + off_x);
            normalElement.Y1 = (ushort)(((ButtonElement)Elements[elementIndex]).TextPosition.Y - normalElement.MovieSize.Height + off_y);

            onElement = new MovieElement(this,
                                         Elements[elementIndex].BinElement,
                                         Elements[elementIndex].Palette,
                                         (Game.Instance.PlayingBroodWar ? BroodwarCampaigns : StarcraftCampaigns)[campaign].onMovie);

            onElement.X1 = (ushort)(Elements[elementIndex].X1 + ((Elements[elementIndex].Width - onElement.MovieSize.Width) / 2));
            onElement.Y1 = (ushort)(((ButtonElement)Elements[elementIndex]).TextPosition.Y - onElement.MovieSize.Height);

            smkElements.Add(diskElement);
            smkElements.Add(normalElement);
            smkElements.Add(onElement);

            onElement.Visible = false;
            normalElement.Dim(100);

            Elements[elementIndex].MouseEnterEvent +=
                delegate() {
                normalElement.Dim(0);
                onElement.Visible = true;
            };
            Elements[elementIndex].MouseLeaveEvent +=
                delegate() {
                normalElement.Dim(100);
                onElement.Visible = false;
            };
        }
Example #2
0
        void AddMovieElements(int elementIndex, string normalMovie, string onMovie, ushort off_x, ushort off_y, bool on_movie_on_top)
        {
            UIElement normalElement, onElement;

            normalElement = new MovieElement(this,
                                             Elements[elementIndex].BinElement,
                                             Elements[elementIndex].Palette,
                                             normalMovie);
            onElement = new MovieElement(this,
                                         Elements[elementIndex].BinElement,
                                         Elements[elementIndex].Palette,
                                         onMovie);

            onElement.X1 += off_x;
            onElement.Y1 += off_y;

            if (!on_movie_on_top)
            {
                smkElements.Add(onElement);
            }
            smkElements.Add(normalElement);
            if (on_movie_on_top)
            {
                smkElements.Add(onElement);
            }
            onElement.Visible = false;

            Elements[elementIndex].MouseEnterEvent +=
                delegate() {
                onElement.Visible = true;
            };
            Elements[elementIndex].MouseLeaveEvent +=
                delegate() {
                onElement.Visible = false;
            };
        }
Example #3
0
        protected override void ResourceLoader()
        {
            TranslucentIndex = 138;

            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);

            if (scenario_prefix.EndsWith ("tutorial")) {
                Elements[skiptutorial_element_index].Visible = true;
                /* XXX Activate */
            }

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

            Elements[replay_element_index].Activate +=
                delegate () {
                    StopBriefing ();
                    PlayBriefing ();
                };

            Elements[start_element_index].Activate +=
                delegate () {
                    StopBriefing ();
                    Game.Instance.SwitchToScreen (new GameScreen (mpq, scenario_prefix, scenario));
                };

            runner = new BriefingRunner (this, scenario, scenario_prefix);

            portraits = new List<MovieElement> ();
            hframes = new List<ImageElement> ();
            frames = new List<ImageElement> ();

            for (int i = 0; i < 4; i ++) {
                MovieElement m = new MovieElement (this,
                                   Elements[first_portrait_element_index + i].BinElement,
                                   Elements[first_portrait_element_index + i].Palette,
                                   true);

                m.X1 += 3;
                m.Y1 += 3;
                m.Width -= 6;
                m.Height -= 6;

                ImageElement f = new ImageElement (this,
                                   Elements[first_portrait_element_index + i].BinElement,
                                   Elements[first_portrait_element_index + i].Palette,
                                   TranslucentIndex);
                f.Text = String.Format ("glue\\Ready{0}\\{0}Frame{1}.pcx",
                            Util.RaceChar[(int)Game.Instance.Race],
                            i + 1);

                ImageElement h = new ImageElement (this,
                                   Elements[first_portrait_element_index + i].BinElement,
                                   Elements[first_portrait_element_index + i].Palette,
                                   TranslucentIndex);
                h.Text = String.Format ("glue\\Ready{0}\\{0}FrameH{1}.pcx",
                            Util.RaceChar[(int)Game.Instance.Race],
                            i + 1);

                f.Visible = false;
                h.Visible = false;
                m.Visible = false;

                portraits.Add (m);
                hframes.Add (h);
                frames.Add (f);

                Elements.Add (m);
                Elements.Add (h);
                Elements.Add (f);
            }
        }
		void AddMovieElements (int elementIndex, int campaign, int off_x, int off_y)
		{
			MovieElement normalElement, onElement, diskElement;

			if (diskPlayer == null)
				diskPlayer = new SmackerPlayer ((Stream)Mpq.GetResource (Game.Instance.PlayingBroodWar ? "glue\\Expcampaign\\disk.smk" : "glue\\campaign\\disk.smk"), 1);

			diskElement = new MovieElement (this,
							Elements[elementIndex].BinElement,
							Elements[elementIndex].Palette,
							diskPlayer);

			diskElement.X1 = (ushort)(Elements[elementIndex].X1 + ((Elements[elementIndex].Width - diskElement.MovieSize.Width) / 2));
			diskElement.Y1 = (ushort)(((ButtonElement)Elements[elementIndex]).TextPosition.Y - diskElement.MovieSize.Height);

			normalElement = new MovieElement (this,
							  Elements[elementIndex].BinElement,
							  Elements[elementIndex].Palette,
							  (Game.Instance.PlayingBroodWar ? BroodwarCampaigns : StarcraftCampaigns)[campaign].normalMovie);

			normalElement.X1 = (ushort)(Elements[elementIndex].X1 + ((Elements[elementIndex].Width - normalElement.MovieSize.Width) / 2) + off_x);
			normalElement.Y1 = (ushort)(((ButtonElement)Elements[elementIndex]).TextPosition.Y - normalElement.MovieSize.Height + off_y);

			onElement = new MovieElement (this,
						      Elements[elementIndex].BinElement,
						      Elements[elementIndex].Palette,
						      (Game.Instance.PlayingBroodWar ? BroodwarCampaigns : StarcraftCampaigns)[campaign].onMovie);

			onElement.X1 = (ushort)(Elements[elementIndex].X1 + ((Elements[elementIndex].Width - onElement.MovieSize.Width) / 2));
			onElement.Y1 = (ushort)(((ButtonElement)Elements[elementIndex]).TextPosition.Y - onElement.MovieSize.Height);

			smkElements.Add (diskElement);
			smkElements.Add (normalElement);
			smkElements.Add (onElement);

			onElement.Visible = false;
			normalElement.Dim (100);

			Elements[elementIndex].MouseEnterEvent += 
				delegate () {
					normalElement.Dim (0);
					onElement.Visible = true;
				};
			Elements[elementIndex].MouseLeaveEvent += 
				delegate () {
					normalElement.Dim (100);
					onElement.Visible = false;
				};
		}
Example #5
0
        protected override void ResourceLoader()
        {
            TranslucentIndex = 138;

            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);
            }

            if (scenario_prefix.EndsWith("tutorial"))
            {
                Elements[skiptutorial_element_index].Visible = true;
                /* XXX Activate */
            }

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

            Elements[replay_element_index].Activate +=
                delegate() {
                StopBriefing();
                PlayBriefing();
            };

            Elements[start_element_index].Activate +=
                delegate() {
                StopBriefing();
                Game.Instance.SwitchToScreen(new GameScreen(mpq, scenario_prefix, scenario));
            };

            runner = new BriefingRunner(this, scenario, scenario_prefix);

            portraits = new List <MovieElement> ();
            hframes   = new List <ImageElement> ();
            frames    = new List <ImageElement> ();

            for (int i = 0; i < 4; i++)
            {
                MovieElement m = new MovieElement(this,
                                                  Elements[first_portrait_element_index + i].BinElement,
                                                  Elements[first_portrait_element_index + i].Palette,
                                                  true);

                m.X1     += 3;
                m.Y1     += 3;
                m.Width  -= 6;
                m.Height -= 6;

                ImageElement f = new ImageElement(this,
                                                  Elements[first_portrait_element_index + i].BinElement,
                                                  Elements[first_portrait_element_index + i].Palette,
                                                  TranslucentIndex);
                f.Text = String.Format("glue\\Ready{0}\\{0}Frame{1}.pcx",
                                       Util.RaceChar[(int)Game.Instance.Race],
                                       i + 1);

                ImageElement h = new ImageElement(this,
                                                  Elements[first_portrait_element_index + i].BinElement,
                                                  Elements[first_portrait_element_index + i].Palette,
                                                  TranslucentIndex);
                h.Text = String.Format("glue\\Ready{0}\\{0}FrameH{1}.pcx",
                                       Util.RaceChar[(int)Game.Instance.Race],
                                       i + 1);

                f.Visible = false;
                h.Visible = false;
                m.Visible = false;

                portraits.Add(m);
                hframes.Add(h);
                frames.Add(f);

                Elements.Add(m);
                Elements.Add(h);
                Elements.Add(f);
            }
        }
Example #6
0
		protected override void ResourceLoader ()
		{
			base.ResourceLoader ();

			/* create the element corresponding to the hud */
			hudElement = new ImageElement (this, 0, 0, 640, 480, TranslucentIndex);
			hudElement.Text = String.Format (Builtins.Game_ConsolePcx, Util.RaceCharLower[(int)Game.Instance.Race]);
			hudElement.Visible = true;
			Elements.Add (hudElement);

			/* create the portrait playing area */
			portraitElement = new MovieElement (this, 415, 415, 48, 48, false);
			portraitElement.Visible = true;
			Elements.Add (portraitElement);
			
			Pcx pcx = new Pcx ();
			pcx.ReadFromStream ((Stream)mpq.GetResource ("game\\tunit.pcx"), -1, -1);
			//unit_palette = pcx.Palette;

			pcx = new Pcx ();
			pcx.ReadFromStream ((Stream)mpq.GetResource ("tileset\\badlands\\dark.pcx"), 0, 0);
			tileset_palette = pcx.Palette;

			if (scenario.Tileset == Tileset.Platform) {
				Spk starfield = (Spk)mpq.GetResource ("parallax\\star.spk");

				starfield_layers = new Surface [starfield.Layers.Length];
				for (int i = 0; i < starfield_layers.Length; i ++) {
					starfield_layers[i] = new Surface (Painter.SCREEN_RES_X, Painter.SCREEN_RES_Y);

					starfield_layers[i].TransparentColor = Color.Black;

					for (int o = 0; o < starfield.Layers[i].Objects.Length; o ++) {
						ParallaxObject obj = starfield.Layers[i].Objects[o];

						starfield_layers[i].Fill (new Rectangle (new Point (obj.X, obj.Y), new Size (2,2)),
									  Color.White);
					}
				}
			}

			mapRenderer = new MapRenderer (mpq, scenario, Painter.SCREEN_RES_X, Painter.SCREEN_RES_Y);
			
			// load the cursors we'll show when scrolling with the mouse
			string[] cursornames = new string[] {
				"cursor\\ScrollUL.grp",
				"cursor\\ScrollU.grp",
				"cursor\\ScrollUR.grp",
				"cursor\\ScrollR.grp",
				"cursor\\ScrollDR.grp",
				"cursor\\ScrollD.grp",
				"cursor\\ScrollDL.grp",
				"cursor\\ScrollL.grp",
			};
			ScrollCursors = new CursorAnimator [cursornames.Length];
			for (int i = 0; i < cursornames.Length; i ++) {
				ScrollCursors[i] = new CursorAnimator ((Grp)mpq.GetResource (cursornames[i]),
								       effectpal.Palette);
				ScrollCursors[i].SetHotSpot (60, 60);
			}

			// load the mag cursors
			string[] magcursornames = new string[] {
				"cursor\\MagG.grp",
				"cursor\\MagY.grp",
				"cursor\\MagR.grp"
			};
			MagCursors = new CursorAnimator [magcursornames.Length];
			for (int i = 0; i < magcursornames.Length; i ++) {
				MagCursors[i] = new CursorAnimator ((Grp)mpq.GetResource (magcursornames[i]),
								    effectpal.Palette);
				MagCursors[i].SetHotSpot (60, 60);
			}

			// load the targeting cursors
			string[] targetcursornames = new string[] {
				"cursor\\TargG.grp",
				"cursor\\TargY.grp",
				"cursor\\TargR.grp"
			};
			TargetCursors = new CursorAnimator [targetcursornames.Length];
			for (int i = 0; i < targetcursornames.Length; i ++) {
				TargetCursors[i] = new CursorAnimator ((Grp)mpq.GetResource (targetcursornames[i]),
								       effectpal.Palette);
				TargetCursors[i].SetHotSpot (60, 60);
			}

			/* the following could be made global to speed up the entry to the game screen.. */
			statTxt = (Tbl)mpq.GetResource ("rez\\stat_txt.tbl");

			// load the wireframe image info
			wireframe = (Grp)mpq.GetResource ("unit\\wirefram\\wirefram.grp");

			// load the command icons
			cmdicons = (Grp)mpq.GetResource ("unit\\cmdbtns\\cmdicons.grp");
			pcx = new Pcx ();
			pcx.ReadFromStream ((Stream)mpq.GetResource ("unit\\cmdbtns\\ticon.pcx"), 0, 0);
			cmdicon_palette = pcx.Palette;

			// create the wireframe display element
			wireframeElement = new GrpElement (this, wireframe, cmdicon_palette, 170, 390);
			wireframeElement.Visible = false;
			Elements.Add (wireframeElement);

			labelElements = new LabelElement [(int)HudLabels.Count];

			labelElements[(int)HudLabels.UnitName] = new LabelElement (this, fontpal.Palette,
										   GuiUtil.GetFonts (Mpq)[1],
										   254, 390);
			labelElements[(int)HudLabels.ResourceUsed] = new LabelElement (this, fontpal.Palette,
										       GuiUtil.GetFonts (Mpq)[0],
										       292, 420);
			labelElements[(int)HudLabels.ResourceProvided] = new LabelElement (this, fontpal.Palette,
											   GuiUtil.GetFonts (Mpq)[0],
											   292, 434);
			labelElements[(int)HudLabels.ResourceTotal] = new LabelElement (this, fontpal.Palette,
											GuiUtil.GetFonts (Mpq)[0],
											292, 448);
			labelElements[(int)HudLabels.ResourceMax] = new LabelElement (this, fontpal.Palette,
										      GuiUtil.GetFonts (Mpq)[0],
										      292, 462);

			for (int i = 0; i < labelElements.Length; i ++)
				Elements.Add (labelElements[i]);

			cmdButtonElements = new GrpButtonElement[9];
			int x = 0;
			int y = 0;
			for (int i = 0; i < cmdButtonElements.Length; i ++) {
				cmdButtonElements[i] = new GrpButtonElement (this, cmdicons, cmdicon_palette, button_xs[x], button_ys[y]);
				x++;
				if (x == 3) {
					x = 0;
					y++;
				}
				cmdButtonElements[i].Visible = false;
				Elements.Add (cmdButtonElements[i]);
			}

			PlaceInitialUnits ();

			Events.Tick += ScrollTick;
		}
Example #7
0
		void AddMovieElements (int elementIndex, string normalMovie, string onMovie, ushort off_x, ushort off_y, bool on_movie_on_top)
		{
			UIElement normalElement, onElement;

			normalElement = new MovieElement (this,
							  Elements[elementIndex].BinElement,
							  Elements[elementIndex].Palette,
							  normalMovie);
			onElement = new MovieElement (this,
						      Elements[elementIndex].BinElement,
						      Elements[elementIndex].Palette,
						      onMovie);

			onElement.X1 += off_x;
			onElement.Y1 += off_y;

			if (!on_movie_on_top)
				smkElements.Add (onElement);
			smkElements.Add (normalElement);
			if (on_movie_on_top)
				smkElements.Add (onElement);
			onElement.Visible = false;

			Elements[elementIndex].MouseEnterEvent += 
				delegate () {
					onElement.Visible = true;
				};
			Elements[elementIndex].MouseLeaveEvent += 
				delegate () {
					onElement.Visible = false;
				};
		}
Example #8
0
        protected override void ResourceLoader()
        {
            base.ResourceLoader();

            /* create the element corresponding to the hud */
            hudElement         = new ImageElement(this, 0, 0, 640, 480, TranslucentIndex);
            hudElement.Text    = String.Format(Builtins.Game_ConsolePcx, Util.RaceCharLower[(int)Game.Instance.Race]);
            hudElement.Visible = true;
            Elements.Add(hudElement);

            /* create the portrait playing area */
            portraitElement         = new MovieElement(this, 415, 415, 48, 48, false);
            portraitElement.Visible = true;
            Elements.Add(portraitElement);

            Pcx pcx = new Pcx();

            pcx.ReadFromStream((Stream)mpq.GetResource("game\\tunit.pcx"), -1, -1);
            //unit_palette = pcx.Palette;

            pcx = new Pcx();
            pcx.ReadFromStream((Stream)mpq.GetResource("tileset\\badlands\\dark.pcx"), 0, 0);
            tileset_palette = pcx.Palette;

            if (scenario.Tileset == Tileset.Platform)
            {
                Spk starfield = (Spk)mpq.GetResource("parallax\\star.spk");

                starfield_layers = new Surface [starfield.Layers.Length];
                for (int i = 0; i < starfield_layers.Length; i++)
                {
                    starfield_layers[i] = new Surface(Painter.SCREEN_RES_X, Painter.SCREEN_RES_Y);

                    starfield_layers[i].TransparentColor = Color.Black;

                    for (int o = 0; o < starfield.Layers[i].Objects.Length; o++)
                    {
                        ParallaxObject obj = starfield.Layers[i].Objects[o];

                        starfield_layers[i].Fill(new Rectangle(new Point(obj.X, obj.Y), new Size(2, 2)),
                                                 Color.White);
                    }
                }
            }

            mapRenderer = new MapRenderer(mpq, scenario, Painter.SCREEN_RES_X, Painter.SCREEN_RES_Y);

            // load the cursors we'll show when scrolling with the mouse
            string[] cursornames = new string[] {
                "cursor\\ScrollUL.grp",
                "cursor\\ScrollU.grp",
                "cursor\\ScrollUR.grp",
                "cursor\\ScrollR.grp",
                "cursor\\ScrollDR.grp",
                "cursor\\ScrollD.grp",
                "cursor\\ScrollDL.grp",
                "cursor\\ScrollL.grp",
            };
            ScrollCursors = new CursorAnimator [cursornames.Length];
            for (int i = 0; i < cursornames.Length; i++)
            {
                ScrollCursors[i] = new CursorAnimator((Grp)mpq.GetResource(cursornames[i]),
                                                      effectpal.Palette);
                ScrollCursors[i].SetHotSpot(60, 60);
            }

            // load the mag cursors
            string[] magcursornames = new string[] {
                "cursor\\MagG.grp",
                "cursor\\MagY.grp",
                "cursor\\MagR.grp"
            };
            MagCursors = new CursorAnimator [magcursornames.Length];
            for (int i = 0; i < magcursornames.Length; i++)
            {
                MagCursors[i] = new CursorAnimator((Grp)mpq.GetResource(magcursornames[i]),
                                                   effectpal.Palette);
                MagCursors[i].SetHotSpot(60, 60);
            }

            // load the targeting cursors
            string[] targetcursornames = new string[] {
                "cursor\\TargG.grp",
                "cursor\\TargY.grp",
                "cursor\\TargR.grp"
            };
            TargetCursors = new CursorAnimator [targetcursornames.Length];
            for (int i = 0; i < targetcursornames.Length; i++)
            {
                TargetCursors[i] = new CursorAnimator((Grp)mpq.GetResource(targetcursornames[i]),
                                                      effectpal.Palette);
                TargetCursors[i].SetHotSpot(60, 60);
            }

            /* the following could be made global to speed up the entry to the game screen.. */
            statTxt = (Tbl)mpq.GetResource("rez\\stat_txt.tbl");

            // load the wireframe image info
            wireframe = (Grp)mpq.GetResource("unit\\wirefram\\wirefram.grp");

            // load the command icons
            cmdicons = (Grp)mpq.GetResource("unit\\cmdbtns\\cmdicons.grp");
            pcx      = new Pcx();
            pcx.ReadFromStream((Stream)mpq.GetResource("unit\\cmdbtns\\ticon.pcx"), 0, 0);
            cmdicon_palette = pcx.Palette;

            // create the wireframe display element
            wireframeElement         = new GrpElement(this, wireframe, cmdicon_palette, 170, 390);
            wireframeElement.Visible = false;
            Elements.Add(wireframeElement);

            labelElements = new LabelElement [(int)HudLabels.Count];

            labelElements[(int)HudLabels.UnitName] = new LabelElement(this, fontpal.Palette,
                                                                      GuiUtil.GetFonts(Mpq)[1],
                                                                      254, 390);
            labelElements[(int)HudLabels.ResourceUsed] = new LabelElement(this, fontpal.Palette,
                                                                          GuiUtil.GetFonts(Mpq)[0],
                                                                          292, 420);
            labelElements[(int)HudLabels.ResourceProvided] = new LabelElement(this, fontpal.Palette,
                                                                              GuiUtil.GetFonts(Mpq)[0],
                                                                              292, 434);
            labelElements[(int)HudLabels.ResourceTotal] = new LabelElement(this, fontpal.Palette,
                                                                           GuiUtil.GetFonts(Mpq)[0],
                                                                           292, 448);
            labelElements[(int)HudLabels.ResourceMax] = new LabelElement(this, fontpal.Palette,
                                                                         GuiUtil.GetFonts(Mpq)[0],
                                                                         292, 462);

            for (int i = 0; i < labelElements.Length; i++)
            {
                Elements.Add(labelElements[i]);
            }

            cmdButtonElements = new GrpButtonElement[9];
            int x = 0;
            int y = 0;

            for (int i = 0; i < cmdButtonElements.Length; i++)
            {
                cmdButtonElements[i] = new GrpButtonElement(this, cmdicons, cmdicon_palette, button_xs[x], button_ys[y]);
                x++;
                if (x == 3)
                {
                    x = 0;
                    y++;
                }
                cmdButtonElements[i].Visible = false;
                Elements.Add(cmdButtonElements[i]);
            }

            PlaceInitialUnits();

            Events.Tick += ScrollTick;
        }