public CreditsScreen(ScreenManager Manager, SpriteBatch SBatch) : base(Manager, "Credits", SBatch, new Vector2(0, 0), new Vector2(GlobalSettings.Default.ScreenWidth, GlobalSettings.Default.ScreenHeight), GlobalSettings.Default.StartupPath + "\\" + "gamedata\\uiscripts\\credits.uis") { BackgroundImg = (UIImage)m_Walker.Elements["\"BackgroundImage\""]; TSOLogoImage = m_Walker.Controls["\"TSOLogoImage\""].Image; BackButtonIndentImage = m_Walker.Controls["\"BackButtonIndentImage\""].Image; WillImage = (UIImage)m_Walker.Elements["\"WillImage\""]; MaxisButton = (UIButton)m_Walker.Elements["\"MaxisButton\""]; MaxisButton.OnButtonClicked += MaxisButton_OnButtonClicked; m_WillWrightDiag = new WillWrightDiag(WillImage, this, new Vector2(100, 100)); m_WillWrightDiag.IsDrawn = false; m_Walker.Elements.Add("WillWrightDiag", m_WillWrightDiag); m_Credits = FileManager.GetIFF("credits.iff"); m_CreditsArea = (UIControl)m_Walker.Controls["\"CreditsArea\""]; m_CreditsY = m_CreditsArea.Size.Y; foreach(TranslatedString TStr in m_Credits.GetSTR(163).GetStringList(LanguageCodes.EngUS)) { foreach (string Str in TStr.TranslatedStr.Split('\n')) m_CreditsStrings.Add(Str); } m_CreditsTimer = new Timer(300); m_CreditsTimer.Elapsed += M_CreditsTimer_Elapsed; m_CreditsTimer.Start(); }
/// <summary> /// Copy constructor for the UIControl class. /// This constructor will deep copy another UIControl instance. /// </summary> /// <param name="Ctrl">A UIControl instance to copy.</param> /// <param name="Screen">A UIScreen instance that this UIControl belongs to.</param> public UIControl(UIControl Ctrl, UIScreen Screen) : base(Screen) { Image = Ctrl.Image; Position = Ctrl.Position; m_Size = Ctrl.Size; m_LeftArrowImage = Ctrl.m_LeftArrowImage; m_RightArrowImage = Ctrl.m_RightArrowImage; m_ThumbSize = Ctrl.m_ThumbSize; m_ThumbMargins = Ctrl.m_ThumbMargins; m_ThumbImageSize = Ctrl.m_ThumbImageSize; m_ThumbImageOffsets = Ctrl.m_ThumbImageOffsets; m_ThumbButtonImage = Ctrl.m_ThumbButtonImage; }
/// <summary> /// Constructs a new instance of UISkinBrowser. /// </summary> /// <param name="Screen">A UIScreen instance that this UISkinBrowser belongs to.</param> /// <param name="Ctrl">A UIControl instance that this UISkinBrowser should be created from.</param> /// <param name="SkinType">The type of skin initially displayed by this UISkinBrowser. 0 = light, 1 = medium, 2 = dark.</param> public UISkinBrowser(UIScreen Screen, UIControl Ctrl, int SkinType, AvatarSex Sex) : base(Ctrl, Screen) { m_KeyboardInput = false; Position = Position + Screen.Position; m_SelectedSkintype = (SkinType)SkinType; m_Sex = Sex; //DrawOrder = (int)DrawOrderEnum.Game; //Default m_SkinBrowserArrowLeft = new UIButton("SkinBrowserArrowLeft", Position + new Vector2(5, Size.Y - 70), Screen, FileManager.Instance.GetTexture((ulong)FileIDs.UIFileIDs.person_edit_skinbrowserarrowleft)); m_SkinBrowserArrowLeft.DrawOrder = (int)DrawOrderEnum.UI; m_SkinBrowserArrowLeft.OnButtonClicked += M_SkinBrowserArrowLeft_OnButtonClicked; m_SkinBrowserArrowRight = new UIButton("SkinBrowserArrowRight", Position + new Vector2(Size.X - 45, Size.Y - 70), Screen, FileManager.Instance.GetTexture((ulong)FileIDs.UIFileIDs.person_edit_skinbrowserarrowright)); m_SkinBrowserArrowRight.DrawOrder = (int)DrawOrderEnum.UI; m_SkinBrowserArrowRight.OnButtonClicked += M_SkinBrowserArrowRight_OnButtonClicked; }
public UIBodyBrowser(UIScreen Screen, UIControl Ctrl, int SkinType, AvatarSex Sex) : base(Screen, Ctrl, SkinType, Sex) { m_EditBodySkinBtnTex = FileManager.GetTexture((ulong)FileIDs.UIFileIDs.person_edit_bodyskinbtn); m_Collections.Add(FileManager.GetCollection((ulong)FileIDs.CollectionsFileIDs.ea_male)); m_FemaleCollections.Add(FileManager.GetCollection((ulong)FileIDs.CollectionsFileIDs.ea_female)); m_Collections.Add(FileManager.GetCollection((ulong)FileIDs.CollectionsFileIDs.eainternal_unisex)); OutfitContainer OftContainer; m_Map = new int[, ] { { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, }; //Get all the thumbnails. foreach (Collection Col in m_Collections) { foreach (UniqueFileID PO in Col.PurchasableOutfitIDs) { OftContainer = new OutfitContainer(FileManager.GetOutfit( FileManager.GetPurchasableOutfit(PO.UniqueID).OutfitID.UniqueID)); //Load all appearances where available, if the player wishes to switch skin type (see CASScreen.cs) if (OftContainer.LightAppearance != null) { m_LightAppearances.Add(OftContainer); } if (OftContainer.MediumAppearance != null) { m_MediumAppearances.Add(OftContainer); } if (OftContainer.DarkAppearance != null) { m_DarkAppearances.Add(OftContainer); } } } //Get all the thumbnails. foreach (Collection Col in m_FemaleCollections) { foreach (UniqueFileID PO in Col.PurchasableOutfitIDs) { m_NumberOfBodies++; OftContainer = new OutfitContainer(FileManager.GetOutfit( FileManager.GetPurchasableOutfit(PO.UniqueID).OutfitID.UniqueID)); //Load all appearances where available, if the player wishes to switch skin type (see CASScreen.cs) if (OftContainer.LightAppearance != null) { m_LightFemaleAppearances.Add(OftContainer); } if (OftContainer.MediumAppearance != null) { m_MediumFemaleAppearances.Add(OftContainer); } if (OftContainer.DarkAppearance != null) { m_DarkFemaleAppearances.Add(OftContainer); } } } foreach (OutfitContainer Ctr in m_LightAppearances) { SkinBtnContainer Container = new SkinBtnContainer(); Container.BtnTex = m_EditBodySkinBtnTex; Container.SourcePosition = //Initialize to second frame in image. new Vector2((m_EditBodySkinBtnTex.Width / (4)) * 2, 0.0f); m_SkinBtns.Add(Container); } foreach (OutfitContainer Ctr in m_MediumAppearances) { SkinBtnContainer Container = new SkinBtnContainer(); Container.BtnTex = m_EditBodySkinBtnTex; Container.SourcePosition = //Initialize to second frame in image. new Vector2((m_EditBodySkinBtnTex.Width / (4)) * 2, 0.0f); m_SkinBtns.Add(Container); } foreach (OutfitContainer Ctr in m_DarkAppearances) { SkinBtnContainer Container = new SkinBtnContainer(); Container.BtnTex = m_EditBodySkinBtnTex; Container.SourcePosition = //Initialize to second frame in image. new Vector2((m_EditBodySkinBtnTex.Width / (4)) * 2, 0.0f); m_SkinBtns.Add(Container); } }
/// <summary> /// Constructs a new instance of UISkinBrowser. /// </summary> /// <param name="Screen">A UIScreen instance that this UISkinBrowser belongs to.</param> /// <param name="Ctrl">A UIControl instance that this UISkinBrowser should be created from.</param> /// <param name="SkinType">The type of skin initially displayed by this UISkinBrowser. 0 = light, 1 = medium, 2 = dark.</param> public UISkinBrowser(UIScreen Screen, UIControl Ctrl, int SkinType, AvatarSex Sex) : base(Ctrl, Screen) { Position = Position + Screen.Position; m_SelectedSkintype = (Elements.SkinType)SkinType; m_Sex = Sex; m_SkinBrowserArrowLeft = new UIButton("SkinBrowserArrowLeft", FileManager.GetTexture((ulong)FileIDs.UIFileIDs.person_edit_skinbrowserarrowleft), Position + new Vector2(5, Size.Y - 70), Screen); m_SkinBrowserArrowLeft.OnButtonClicked += M_SkinBrowserArrowLeft_OnButtonClicked; m_SkinBrowserArrowRight = new UIButton("SkinBrowserArrowRight", FileManager.GetTexture((ulong)FileIDs.UIFileIDs.person_edit_skinbrowserarrowright), Position + new Vector2(Size.X - 45, Size.Y - 70), Screen); m_SkinBrowserArrowRight.OnButtonClicked += M_SkinBrowserArrowRight_OnButtonClicked; }
public UIHeadBrowser(UIScreen Screen, UIControl Ctrl, int SkinType, AvatarSex Sex) : base(Screen, Ctrl, SkinType, Sex) { m_EditHeadSkinBtnTex = FileManager.GetTexture((ulong)FileIDs.UIFileIDs.person_edit_headskinbtn); m_Collections.Add(FileManager.GetCollection((ulong)FileIDs.CollectionsFileIDs.ea_male_heads)); m_FemaleCollections.Add(FileManager.GetCollection((ulong)FileIDs.CollectionsFileIDs.ea_female_heads)); m_Collections.Add(FileManager.GetCollection((ulong)FileIDs.CollectionsFileIDs.eainternalheads_unisex)); OutfitContainer OftContainer; //Get all the thumbnails. foreach (Collection Col in m_Collections) { foreach (UniqueFileID PO in Col.PurchasableOutfitIDs) { OftContainer = new OutfitContainer(FileManager.GetOutfit( FileManager.GetPurchasableOutfit(PO.UniqueID).OutfitID.UniqueID)); //Load all appearances where available, if the player wishes to switch skin type (see CASScreen.cs) if (OftContainer.LightAppearance != null) m_LightAppearances.Add(OftContainer); if (OftContainer.MediumAppearance != null) m_MediumAppearances.Add(OftContainer); if (OftContainer.DarkAppearance != null) m_DarkAppearances.Add(OftContainer); } } //Get all the thumbnails. foreach (Collection Col in m_FemaleCollections) { foreach (UniqueFileID PO in Col.PurchasableOutfitIDs) { OftContainer = new OutfitContainer(FileManager.GetOutfit( FileManager.GetPurchasableOutfit(PO.UniqueID).OutfitID.UniqueID)); //Load all appearances where available, if the player wishes to switch skin type (see CASScreen.cs) if (OftContainer.LightAppearance != null) m_LightFemaleAppearances.Add(OftContainer); if (OftContainer.MediumAppearance != null) m_MediumFemaleAppearances.Add(OftContainer); if (OftContainer.DarkAppearance != null) m_DarkFemaleAppearances.Add(OftContainer); } } foreach (OutfitContainer Ctr in m_LightAppearances) { SkinBtnContainer Container = new SkinBtnContainer(); Container.BtnTex = m_EditHeadSkinBtnTex; Container.SourcePosition = //Initialize to second frame in image. new Vector2((m_EditHeadSkinBtnTex.Width / (4)) * 2, 0.0f); m_SkinBtns.Add(Container); } foreach (OutfitContainer Ctr in m_MediumAppearances) { SkinBtnContainer Container = new SkinBtnContainer(); Container.BtnTex = m_EditHeadSkinBtnTex; Container.SourcePosition = //Initialize to second frame in image. new Vector2((m_EditHeadSkinBtnTex.Width / (4)) * 2, 0.0f); m_SkinBtns.Add(Container); } foreach (OutfitContainer Ctr in m_DarkAppearances) { SkinBtnContainer Container = new SkinBtnContainer(); Container.BtnTex = m_EditHeadSkinBtnTex; Container.SourcePosition = //Initialize to second frame in image. new Vector2((m_EditHeadSkinBtnTex.Width / (4)) * 2, 0.0f); m_SkinBtns.Add(Container); } }
/// <summary> /// Walks a generated AST (Abstract Syntax Tree) and creates the elements of this UIScreen. /// </summary> /// <param name="State">A ParserState instance.</param> /// <param name="node">The root node of the AST.</param> private void WalkTree(UIParser.ParserState State, AstNode node) { NodeType NType = (NodeType)Enum.Parse(typeof(NodeType), node.ToString(), true); switch (NType) { case NodeType.DefineImage: //Defines an image and loads a texture for it. DefineImageNode ImgNode = (DefineImageNode)UINode.GetNode(node); UIImage Img = new UIImage(ImgNode, m_Screen); Elements.Add(ImgNode.Name, Img); break; case NodeType.DefineString: //Defines a string with a name. DefineStringNode StrNode = (DefineStringNode)UINode.GetNode(node); Strings.Add(StrNode.Name, StringManager.StrTable(State.CurrentStringTable)[StrNode.StrIndex]); break; case NodeType.AddButton: //Defines a button. AddButtonNode ButtonNode = (AddButtonNode)UINode.GetNode(node); UIButton Btn = new UIButton(ButtonNode, State, m_Screen); Elements.Add(ButtonNode.Name, Btn); break; case NodeType.AddText: AddTextNode TextNode = (AddTextNode)UINode.GetNode(node); UILabel Lbl = new UILabel(TextNode, State, m_Screen); Elements.Add(TextNode.Name, Lbl); break; case NodeType.AddTextEdit: AddTextEditNode TextEditNode = (AddTextEditNode)UINode.GetNode(node); UITextEdit Txt = new UITextEdit(TextEditNode, State, m_Screen); Elements.Add(TextEditNode.Name, Txt); break; case NodeType.AddSlider: AddSliderNode SliderNode = (AddSliderNode)UINode.GetNode(node); UISlider Slider = new UISlider(SliderNode, State, m_Screen); Elements.Add(SliderNode.Name, Slider); break; case NodeType.SetSharedProperties: //Assigns a bunch of shared properties to declarations following the statement. State.InSharedPropertiesGroup = true; SetSharedPropsNode SharedPropsNode = (SetSharedPropsNode)UINode.GetNode(node); if (SharedPropsNode.StringTable != null) State.CurrentStringTable = (int)SharedPropsNode.StringTable; if (SharedPropsNode.ControlPosition != null) { State.Position[0] = SharedPropsNode.ControlPosition.Numbers[0]; State.Position[1] = SharedPropsNode.ControlPosition.Numbers[1]; break; } if (SharedPropsNode.Color != null) { State.Color = new Color(); State.Color.R = (byte)SharedPropsNode.Color.Numbers[0]; State.Color.G = (byte)SharedPropsNode.Color.Numbers[1]; State.Color.B = (byte)SharedPropsNode.Color.Numbers[2]; } if (SharedPropsNode.TextColor != null) { State.TextColor = new Color(); State.TextColor.R = (byte)SharedPropsNode.TextColor.Numbers[0]; State.TextColor.G = (byte)SharedPropsNode.TextColor.Numbers[1]; State.TextColor.B = (byte)SharedPropsNode.TextColor.Numbers[2]; } if (SharedPropsNode.TextColorSelected != null) { State.TextColorSelected = new Color(); State.TextColorSelected.R = (byte)SharedPropsNode.TextColorSelected.Numbers[0]; State.TextColorSelected.G = (byte)SharedPropsNode.TextColorSelected.Numbers[1]; State.TextColorSelected.B = (byte)SharedPropsNode.TextColorSelected.Numbers[2]; } if (SharedPropsNode.TextColorHighlighted != null) { State.TextColorHighlighted = new Color(); State.TextColorHighlighted.R = (byte)SharedPropsNode.TextColorHighlighted.Numbers[0]; State.TextColorHighlighted.G = (byte)SharedPropsNode.TextColorHighlighted.Numbers[1]; State.TextColorHighlighted.B = (byte)SharedPropsNode.TextColorHighlighted.Numbers[2]; } if (SharedPropsNode.TextColorDisabled != null) { State.TextColorDisabled = new Color(); State.TextColorDisabled.R = (byte)SharedPropsNode.TextColorDisabled.Numbers[0]; State.TextColorDisabled.G = (byte)SharedPropsNode.TextColorDisabled.Numbers[1]; State.TextColorDisabled.B = (byte)SharedPropsNode.TextColorDisabled.Numbers[2]; } if (SharedPropsNode.BackColor != null) { State.BackColor = new Color(); State.BackColor.R = (byte)SharedPropsNode.BackColor.Numbers[0]; State.BackColor.G = (byte)SharedPropsNode.BackColor.Numbers[1]; State.BackColor.B = (byte)SharedPropsNode.BackColor.Numbers[2]; } if (SharedPropsNode.CursorColor != null) { State.CursorColor = new Color(); State.CursorColor.R = (byte)SharedPropsNode.CursorColor.Numbers[0]; State.CursorColor.G = (byte)SharedPropsNode.CursorColor.Numbers[1]; State.CursorColor.B = (byte)SharedPropsNode.CursorColor.Numbers[2]; } if (SharedPropsNode.TextButton) State.TextButton = true; if (SharedPropsNode.Opaque != null) State.IsOpaque = (SharedPropsNode.Opaque == 1) ? true : false; if (SharedPropsNode.Transparent != null) State.IsTransparent = (SharedPropsNode.Transparent == 1) ? true : false; if (SharedPropsNode.Alignment != null) State.Alignment = (int)SharedPropsNode.Alignment; if (SharedPropsNode.Image != "") State.Image = SharedPropsNode.Image; if (SharedPropsNode.Tooltip != "") State.Tooltip = SharedPropsNode.Tooltip; if (SharedPropsNode.Text != "") State.Caption = SharedPropsNode.Text; if (SharedPropsNode.Size != null) State.Size = new Vector2(SharedPropsNode.Size.Numbers[0], SharedPropsNode.Size.Numbers[1]); if (SharedPropsNode.Orientation != null) State.Orientation = (int)SharedPropsNode.Orientation; if (SharedPropsNode.Font != null) State.Font = (int)SharedPropsNode.Font; if (SharedPropsNode.Opaque != null) State.Opaque = (int)SharedPropsNode.Opaque; break; case NodeType.SetControlProperties: //Sets a bunch of properties to a specified control. SetControlPropsNode ControlPropsNode = (SetControlPropsNode)UINode.GetNode(node); UIControl Ctrl = new UIControl(ControlPropsNode, m_Screen, State); Controls.Add(ControlPropsNode.Control, Ctrl); if (State.InSharedPropertiesGroup) { UIElement Test = new UIElement(m_Screen, null); //Script implicitly created an object... :\ if (!Elements.TryGetValue(ControlPropsNode.Control, out Test)) { Elements.Add(ControlPropsNode.Control, new UIElement(m_Screen, null)); if (Ctrl.Image != null) Elements[ControlPropsNode.Control].Image = new UIImage(Ctrl.Image); Elements[ControlPropsNode.Control].Position = Ctrl.Position; } } break; case NodeType.End: State.InSharedPropertiesGroup = false; State.Image = ""; //Reset State.TextButton = false; //Reset State.Color = new Color(); State.Caption = ""; //TODO: Reset more? break; } foreach (AstNode child in node.ChildNodes) WalkTree(State, child); }