void AddMovieElements(int elementIndex, int campaign, int off_x, int off_y) { MovieElement normalElement, onElement, diskElement; ButtonElement button = (ButtonElement)Elements[elementIndex]; RectangleF buttonTextBounds = button.TextBounds; diskElement = new MovieElement(this, button.BinElement, button.Palette, (Game.Instance.PlayingBroodWar ? "glue\\Expcampaign\\disk.smk" : "glue\\campaign\\disk.smk")); diskElement.X1 = (ushort)(button.X1 + (button.Width - diskElement.MovieSize.Width) / 2); diskElement.Y1 = (ushort)(button.Y1 + button.Height - buttonTextBounds.Y - buttonTextBounds.Height - diskElement.MovieSize.Height); normalElement = new MovieElement(this, button.BinElement, button.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)(button.Y1 + button.Height - buttonTextBounds.Y - buttonTextBounds.Height - normalElement.MovieSize.Height + off_y); onElement = new MovieElement(this, button.BinElement, button.Palette, (Game.Instance.PlayingBroodWar ? BroodwarCampaigns : StarcraftCampaigns)[campaign].onMovie); onElement.X1 = (ushort)(Elements[elementIndex].X1 + ((Elements[elementIndex].Width - onElement.MovieSize.Width) / 2)); onElement.Y1 = (ushort)(button.Y1 + button.Height - buttonTextBounds.Y - buttonTextBounds.Height - 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; }; }
public ButtonLayerDelegate (ButtonElement el) { this.el = el; }
public ButtonLayerDelegate(ButtonElement el) { this.el = el; }
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.LayerFromStream((Stream)mpq.GetResource(background_path), background_translucent, background_transparent); background.AnchorPoint = new PointF(0, 0); AddSublayer(background); // FIXME: we should center the background (and scale it?) } 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); } } }
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.LayerFromStream ((Stream)mpq.GetResource (background_path), background_translucent, background_transparent); background.AnchorPoint = new PointF (0, 0); AddSublayer (background); // FIXME: we should center the background (and scale it?) } 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); } } }