Наследование: UIElement
Пример #1
0
        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();
        }
Пример #2
0
        /// <summary>
        /// Constructs a new UIDialog instance.
        /// </summary>
        /// <param name="Screen">A UIScreen instance.</param>
        /// <param name="Pos">A Vector2 instance specifying the position of this dialog.</param>
        /// <param name="IsTall">Will this dialog use a tall background template?</param>
        /// <param name="IsDraggable">Is this dialog draggable?</param>
        /// <param name="HasExitButton">Does this dialog have an exit button?</param>
        public UIDialog(UIScreen Screen, Vector2 Pos, bool IsTall, bool IsDraggable, bool HasExitButton)
            : base(Screen)
        {
            Position = Pos;
            m_IsDraggable = IsDraggable;
            m_HasExitBtn = HasExitButton;

            //TODO: Find a way to NOT hardcode these references.
            Texture2D Tex = (IsTall != false) ?
                FileManager.GetTexture((ulong)FileIDs.UIFileIDs.dialog_backgroundtemplatetall, true) :
                FileManager.GetTexture((ulong)FileIDs.UIFileIDs.dialog_backgroundtemplate, true);

            Texture2D CloseBtnBackground = (IsTall != false) ?
                FileManager.GetTexture((ulong)FileIDs.UIFileIDs.dialog_closebtnbackgroundtall) :
                FileManager.GetTexture((ulong)FileIDs.UIFileIDs.dialog_closebtnbackground);

            Image = new UIImage(Tex, Screen, null);

            if (IsTall != false)
                Image.Slicer = new NineSlicer(new Vector2(0, 0), Tex.Width, Tex.Height, 41, 41, 66, 40);
            else
                Image.Slicer = new NineSlicer(new Vector2(0, 0), Tex.Width, Tex.Height, 41, 41, 60, 40);

            Image.Position = new Vector2(Pos.X, Pos.Y);

            m_CloseBtnBack = new UIImage(CloseBtnBackground, Screen, null);
            m_CloseBtnBack.Position = Position + new Vector2(Image.Slicer.Width - m_CloseBtnBack.Texture.Width, 0);

            Texture2D CloseButtonTex = FileManager.GetTexture((ulong)FileIDs.UIFileIDs.dialog_closebtn);
            m_CloseButton = new UIButton("CloseBtn", CloseButtonTex,
                Position + new Vector2(Image.Slicer.Width - (CloseButtonTex.Width / 2.5f), 9f), Screen, null);
            m_CloseButton.OnButtonClicked += CloseButton_OnButtonClicked;
        }
Пример #3
0
 public WillWrightDiag(UIImage Img, UIScreen Screen, Vector2 Position)
     : base(Screen, Position, true, true, true)
 {
     m_WillWrightImg = Img;
     m_WillWrightImg.Position = Position;
     Image.SetSize(m_WillWrightImg.Texture.Width + 50, m_WillWrightImg.Texture.Height + 55);
     CenterAround(m_WillWrightImg, -22, -42);
 }
Пример #4
0
        public CASScreen(ScreenManager Manager, SpriteBatch SBatch)
            : base(Manager, "CAS", SBatch, 
            new Vector2(0, 0), 
            new Vector2(GlobalSettings.Default.ScreenWidth, GlobalSettings.Default.ScreenHeight),
            GlobalSettings.Default.StartupPath + "\\" + "gamedata\\uiscripts\\personselectionedit.uis")
        {
            m_BackgroundImg = (UIImage)m_Walker.Elements["\"BackgroundImage\""];

            m_CancelBtn = (UIButton)m_Walker.Elements["\"CancelButton\""];
            m_AcceptBtn = (UIButton)m_Walker.Elements["\"AcceptButton\""];
            m_DescriptionScrollUpBtn = (UIButton)m_Walker.Elements["\"DescriptionScrollUpButton\""];
            m_DescriptionScrollDownBtn = (UIButton)m_Walker.Elements["\"DescriptionScrollDownButton\""];

            m_ExitBtn = (UIButton)m_Walker.Elements["\"ExitButton\""];
            m_ExitBtn.OnButtonClicked += M_ExitBtn_OnButtonClicked;

            m_FemaleBtn = (UIButton)m_Walker.Elements["\"FemaleButton\""];
            m_FemaleBtn.OnButtonClicked += M_FemaleBtn_OnButtonClicked;

            m_MaleBtn = (UIButton)m_Walker.Elements["\"MaleButton\""];
            m_MaleBtn.OnButtonClicked += M_MaleBtn_OnButtonClicked;

            m_SkinLightBtn = (UIButton)m_Walker.Elements["\"SkinLightButton\""];
            m_SkinLightBtn.OnButtonClicked += M_SkinLightBtn_OnButtonClicked;

            m_SkinMediumBtn = (UIButton)m_Walker.Elements["\"SkinMediumButton\""];
            m_SkinMediumBtn.OnButtonClicked += M_SkinMediumBtn_OnButtonClicked;

            m_SkinDarkBtn = (UIButton)m_Walker.Elements["\"SkinDarkButton\""];
            m_SkinDarkBtn.OnButtonClicked += M_SkinDarkBtn_OnButtonClicked;

            m_HeadSkinBrowser = new UIHeadBrowser(this, m_Walker.Controls["\"HeadSkinBrowser\""], 1, AvatarSex.Female);
            m_HeadSkinBrowser.OnButtonClicked += M_HeadSkinBrowser_OnButtonClicked;
            m_BodySkinBrowser = new UIBodyBrowser(this, m_Walker.Controls["\"BodySkinBrowser\""], 1, AvatarSex.Female);
            m_BodySkinBrowser.OnButtonClicked += M_BodySkinBrowser_OnButtonClicked;

            AdultAvatar Avatar = new AdultAvatar(Manager.Device);
            Avatar.ChangeOutfit(FileManager.GetOutfit((ulong)FileIDs.OutfitsFileIDs.fab001_sl__pjs4), Vitaboy.SkinType.Medium);
            Avatar.SetHead(FileManager.GetOutfit((ulong)FileIDs.OutfitsFileIDs.fah002_mom), (Vitaboy.SkinType)m_CurrentSkinType);
            Avatar.ShouldRotate = true;

            m_Avatar = new Sim(Manager.Device, Avatar);
            m_Avatar.Camera.Origin = new Vector2(175, 100);
            m_Avatar.Camera.Zoom = 0.7f;

            m_VitaboyScreen = new VitaboyScreen(Manager, new Vector2(0, 0),
                new Vector2(GlobalSettings.Default.ScreenWidth, GlobalSettings.Default.ScreenHeight));
            m_VitaboyScreen.AddSim(m_Avatar);

            m_ExitDialog = new ExitDialog(this, new Vector2(250, 250), m_Walker,
                GlobalSettings.Default.StartupPath + "\\" + "gamedata\\uiscripts\\exitdialog.uis");
            m_ExitDialog.Visible = false;

            Manager.AddScreen(m_VitaboyScreen);
        }
Пример #5
0
        private float m_XScale = 1.0f; //Used to scale buttons to fit text.

        #endregion Fields

        #region Constructors

        public UIButton(AddButtonNode Node, ParserState State, UIScreen Screen)
            : base(Screen)
        {
            Name = Node.Name;
            m_ID = Node.ID;
            m_Screen = Screen;

            if (!State.InSharedPropertiesGroup)
            {
                if (Node.Image != null)
                {
                    Image = m_Screen.GetImage(Node.Image, false);
                    //Initialize to second frame in the image.
                    m_SourcePosition = new Vector2((Image.Texture.Width / (4)) * 2, 0.0f);

                    m_Size = new Vector2();
                    m_Size.X = (Image.Texture.Width) / (4);
                    m_Size.Y = Image.Texture.Height;

                    Position = new Vector2(Node.ButtonPosition.Numbers[0], Node.ButtonPosition.Numbers[1]) + m_Screen.Position;
                }
                else
                {
                    Image = new UIImage(FileManager.GetTexture((ulong)FileIDs.UIFileIDs.buttontiledialog), m_Screen);
                    //Initialize to second frame in the image.
                    m_SourcePosition = new Vector2((Image.Texture.Width / 4) * 2, 0.0f);

                    m_Size = new Vector2();
                    m_Size.X = (Image.Texture.Width) / (4);
                    m_Size.Y = Image.Texture.Height;

                    Position = new Vector2(Node.ButtonPosition.Numbers[0], Node.ButtonPosition.Numbers[1]) + m_Screen.Position;
                }
            }
            else
            {
                if (State.Image != "")
                {
                    Image = m_Screen.GetImage(State.Image, true);
                    //Initialize to second frame in the image.
                    m_SourcePosition = new Vector2((Image.Texture.Width / 4) * 2, 0.0f);

                    m_Size = new Vector2();
                    m_Size.X = Image.Texture.Width / 4;
                    m_Size.Y = Image.Texture.Height;

                    Position = new Vector2(Node.ButtonPosition.Numbers[0], Node.ButtonPosition.Numbers[1]) + m_Screen.Position;
                }
                else
                {
                    if (State.TextButton)
                    {
                        m_Text = State.Caption;
                        //Text buttons always use this image.
                        Image = new UIImage(FileManager.GetTexture((ulong)FileIDs.UIFileIDs.buttontiledialog), m_Screen);
                        //Initialize to second frame in the image.
                        m_SourcePosition = new Vector2((Image.Texture.Width / 4) * 2, 0.0f);

                        m_Size = new Vector2();
                        m_Size.X = Image.Texture.Width / 4;
                        m_Size.Y = Image.Texture.Height;
                    }
                    else
                    {
                        Image = m_Screen.GetImage(Node.Image, false);
                        //Initialize to second frame in the image.
                        m_SourcePosition = new Vector2((Image.Texture.Width / (4)) * 2, 0.0f);

                        m_Size = new Vector2();
                        m_Size.X = (Image.Texture.Width) / (4);
                        m_Size.Y = Image.Texture.Height;

                        Position = new Vector2(Node.ButtonPosition.Numbers[0], Node.ButtonPosition.Numbers[1]) + m_Screen.Position;
                    }

                    Position = new Vector2(Node.ButtonPosition.Numbers[0], Node.ButtonPosition.Numbers[1]) + m_Screen.Position;
                }

                if (State.Tooltip != "")
                    Tooltip = m_Screen.GetString(State.Tooltip);
            }

            if (Node.TextHighlighted != null)
                m_IsTextHighlighted = (Node.TextHighlighted == 1) ? true : false;

            if (Node.Font != null)
            {
                int FontSize = (int)Node.Font;

                switch (FontSize)
                {
                    case 9:
                        m_Font = Screen.Font9px;
                        break;
                    case 10:
                        m_Font = Screen.Font10px;
                        break;
                    case 12:
                        m_Font = Screen.Font12px;
                        break;
                    case 14:
                        m_Font = Screen.Font14px;
                        break;
                    case 16:
                        m_Font = Screen.Font16px;
                        break;
                }
            }
            else if(State.Font != 0)
            {
                switch (State.Font)
                {
                    case 9:
                        m_Font = Screen.Font9px;
                        break;
                    case 10:
                        m_Font = Screen.Font10px;
                        break;
                    case 12:
                        m_Font = Screen.Font12px;
                        break;
                    case 14:
                        m_Font = Screen.Font14px;
                        break;
                    case 16:
                        m_Font = Screen.Font16px;
                        break;
                    default:
                        m_Font = Screen.Font12px;
                        break;
                }
            }

            if (Node.TextColor != null)
            {
                TextColor = new Color();
                TextColor.A = 255;
                TextColor.R = (byte)Node.TextColor.Numbers[0];
                TextColor.G = (byte)Node.TextColor.Numbers[1];
                TextColor.B = (byte)Node.TextColor.Numbers[2];
            }
            else
            {
                TextColor = State.TextColor;
                TextColor.A = 255;
            }

            if (Node.TextColorSelected != null)
            {
                TextColorSelected = new Color();
                TextColorSelected.A = 255;
                TextColorSelected.R = (byte)Node.TextColorSelected.Numbers[0];
                TextColorSelected.G = (byte)Node.TextColorSelected.Numbers[1];
                TextColorSelected.B = (byte)Node.TextColorSelected.Numbers[2];
            }
            else
            {
                TextColorSelected = State.TextColorSelected;
                TextColorSelected.A = 255;
            }

            if (Node.TextColorHighlighted != null)
            {
                TextColorHighlighted = new Color();
                TextColorHighlighted.A = 255;
                TextColorHighlighted.R = (byte)Node.TextColorHighlighted.Numbers[0];
                TextColorHighlighted.G = (byte)Node.TextColorHighlighted.Numbers[1];
                TextColorHighlighted.B = (byte)Node.TextColorHighlighted.Numbers[2];
            }
            else
            {
                TextColorHighlighted = State.TextColorHighlighted;
                TextColorHighlighted.A = 255;
            }

            if (Node.TextColorDisabled != null)
            {
                TextColorDisabled = new Color();
                TextColorDisabled.A = 255;
                TextColorDisabled.R = (byte)Node.TextColorDisabled.Numbers[0];
                TextColorDisabled.G = (byte)Node.TextColorDisabled.Numbers[1];
                TextColorDisabled.B = (byte)Node.TextColorDisabled.Numbers[2];
            }
            else
            {
                TextColorDisabled = State.TextColorDisabled;
                TextColorDisabled.A = 255;
            }

            if (Node.TextButton != null)
                m_IsTextButton = (Node.TextButton == 1) ? true : false;
            else
                m_IsTextButton = m_IsTextButton = State.TextButton;

            if (m_IsTextButton)
            {
                if (Node.Text != string.Empty)
                    m_Text = m_Screen.GetString(Node.Text);
                else
                    m_Text = m_Screen.GetString(State.Caption);

                m_TextPosition = Position;

                if (m_Size.X != 0)
                    ScaleToText();
            }

            if (Node.Tooltip != "")
                Tooltip = m_Screen.GetString(Node.Tooltip);

            if (Node.Tracking != null)
                Tracking = (int)Node.Tracking;
        }
Пример #6
0
        /// <summary>
        /// Adds an image to this button, because (you guessed it) sometimes
        /// buttons will be defined without images...
        /// </summary>
        /// <param name="Img">The image to add.</param>
        public void AddImage(UIImage Img)
        {
            Image = Img;
            Image.Position = Position;

            m_Size = new Vector2();
            m_Size.X = Image.Texture.Width / 4;
            m_Size.Y = Image.Texture.Height;

            //Initialize to second frame in the image.
            m_SourcePosition = new Vector2((Image.Texture.Width / 4) * 2, 0.0f);

            if (m_Text != null)
                ScaleToText();
        }
Пример #7
0
        /// <summary>
        /// Constructs a new UIButton instance.
        /// </summary>
        /// <param name="Name">Name of button.</param>
        /// <param name="Tex">Texture used to display this button.</param>
        /// <param name="Position">Button's position.</param>
        /// <param name="Screen">This button's screen.</param>
        public UIButton(string Name, Texture2D Tex, Vector2 Pos, UIScreen Screen, UIElement Parent = null)
            : base(Screen, Parent)
        {
            base.Name = Name;
            Position = Pos;

            Image = new UIImage(Tex, Screen, null);
            Image.Position = new Vector2(Pos.X, Pos.Y);
            //Initialize to second frame in the image.
            m_SourcePosition = new Vector2((Tex.Width / 4) * 2, 0.0f);

            m_Size = new Vector2();
            m_Size.X = Tex.Width / 4;
            m_Size.Y = Tex.Height;
        }
Пример #8
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="Image">A UIImage instance to copy.</param>
 public UIImage(UIImage Image)
     : base(Image.m_Screen)
 {
     Name = Image.Name;
     Texture = Image.Texture;
     Position = Image.Position;
     m_Loaded = true;
 }
Пример #9
0
        public SASScreen(ScreenManager Manager, SpriteBatch SBatch)
            : base(Manager, "SAS", SBatch,
            new Vector2(0, 0), new Vector2(GlobalSettings.Default.ScreenWidth, GlobalSettings.Default.ScreenHeight),
            GlobalSettings.Default.StartupPath + "\\" + "gamedata\\uiscripts\\personselection.uis")
        {
            BackgroundImg = (UIImage)m_Walker.Elements["\"BackgroundImage\""];

            AdultAvatar Avatar = new AdultAvatar(Manager.Device);
            Avatar.ChangeOutfit(FileManager.GetOutfit((ulong)FileIDs.OutfitsFileIDs.fab001_sl__pjs4), Vitaboy.SkinType.Medium);
            Avatar.SetHead(FileManager.GetOutfit((ulong)FileIDs.OutfitsFileIDs.fah002_mom), Vitaboy.SkinType.Medium);
            AddAvatar(Avatar, 1);

            VitaboyScreen VScreen = new VitaboyScreen(Manager, new Vector2(0, 0),
                new Vector2(GlobalSettings.Default.ScreenWidth, GlobalSettings.Default.ScreenHeight));
            VScreen.AddSim(m_Avatars[0]);

            Manager.AddScreen(VScreen);

            TabBackgroundImg1 = m_Walker.Elements["\"TabBackgroundImage1\""].Image;
            TabBackgroundImg2 = m_Walker.Elements["\"TabBackgroundImage2\""].Image;
            TabBackgroundImg3 = m_Walker.Elements["\"TabBackgroundImage3\""].Image;

            DescriptionTabBackgroundImg1 = m_Walker.Elements["\"DescriptionTabBackgroundImage1\""].Image;
            DescriptionTabBackgroundImg1.Visible = m_Avatars.Count >= 1 ? true : false;
            DescriptionTabBackgroundImg2 = m_Walker.Elements["\"DescriptionTabBackgroundImage2\""].Image;
            DescriptionTabBackgroundImg2.Visible = m_Avatars.Count >= 2 ? true : false;
            DescriptionTabBackgroundImg3 = m_Walker.Elements["\"DescriptionTabBackgroundImage3\""].Image;
            DescriptionTabBackgroundImg3.Visible = m_Avatars.Count == 3 ? true : false;

            DescriptionTabImage1 = m_Walker.Elements["\"DescriptionTabImage1\""].Image;
            DescriptionTabImage1.Visible = m_Avatars.Count >= 1 ? true : false;
            DescriptionTabImage2 = m_Walker.Elements["\"DescriptionTabImage2\""].Image;
            DescriptionTabImage2.Visible = m_Avatars.Count >= 2 ? true : false;
            DescriptionTabImage3 = m_Walker.Elements["\"DescriptionTabImage3\""].Image;
            DescriptionTabImage3.Visible = m_Avatars.Count == 3 ? true : false;

            EnterTabImage1 = m_Walker.Elements["\"EnterTabImage1\""].Image;
            EnterTabImage1.Visible = false;
            EnterTabImage2 = m_Walker.Elements["\"EnterTabImage2\""].Image;
            EnterTabImage2.Visible = false;
            EnterTabImage3 = m_Walker.Elements["\"EnterTabImage3\""].Image;
            EnterTabImage3.Visible = false;

            EnterTabBackgroundImage1 = m_Walker.Elements["\"EnterTabBackgroundImage1\""].Image;
            EnterTabBackgroundImage1.Visible = false;
            EnterTabBackgroundImage2 = m_Walker.Elements["\"EnterTabBackgroundImage2\""].Image;
            EnterTabBackgroundImage2.Visible = false;
            EnterTabBackgroundImage3 = m_Walker.Elements["\"EnterTabBackgroundImage3\""].Image;
            EnterTabBackgroundImage3.Visible = false;

            //DefaultHouseImg = (UIImage)m_Elements["\"DefaultHouseImage\""].Image; //Not used??

            CreditsBackgroundImg = m_Walker.Controls["\"CreditsButtonBackgroundImage\""].Image;
            //CityThumbnailBusyImg = m_Controls["\"CityThumbnailBusyImage\""].Image; //Not used??

            CityButtonTemplateImage = (UIImage)m_Walker.Elements["\"CityButtonTemplateImage\""];

            m_ExitButton = (UIButton)m_Walker.Elements["\"ExitButton\""];

            m_EnterTabBtn1 = (UIButton)m_Walker.Elements["\"EnterTabButton1\""];
            m_EnterTabBtn1.OnButtonClicked += EnterTabBtn1_OnButtonClicked;
            m_EnterTabBtn1.Enabled = m_Avatars.Count >= 1 ? true : false;
            m_EnterTabBtn2 = (UIButton)m_Walker.Elements["\"EnterTabButton2\""];
            m_EnterTabBtn2.OnButtonClicked += EnterTabBtn2_OnButtonClicked;
            m_EnterTabBtn2.Enabled = m_Avatars.Count >= 2 ? true : false;
            m_EnterTabBtn3 = (UIButton)m_Walker.Elements["\"EnterTabButton3\""];
            m_EnterTabBtn3.OnButtonClicked += EnterTabBtn3_OnButtonClicked;
            m_EnterTabBtn3.Enabled = m_Avatars.Count == 3 ? true : false;

            m_DescriptionTabBtn1 = (UIButton)m_Walker.Elements["\"DescriptionTabButton1\""];
            m_DescriptionTabBtn1.OnButtonClicked += DescriptionTabBtn1_OnButtonClicked;
            m_DescriptionTabBtn1.Enabled = m_Avatars.Count >= 1 ? true : false;
            m_DescriptionTabBtn2 = (UIButton)m_Walker.Elements["\"DescriptionTabButton2\""];
            m_DescriptionTabBtn2.OnButtonClicked += DescriptionTabBtn2_OnButtonClicked;
            m_DescriptionTabBtn2.Enabled = m_Avatars.Count >= 2 ? true : false;
            m_DescriptionTabBtn3 = (UIButton)m_Walker.Elements["\"DescriptionTabButton3\""];
            m_DescriptionTabBtn3.OnButtonClicked += DescriptionTabBtn3_OnButtonClicked;
            m_DescriptionTabBtn3.Enabled = m_Avatars.Count == 3 ? true : false;

            m_AvatarButton1 = (UIButton)m_Walker.Elements["\"AvatarButton1\""];
            m_AvatarButton2 = (UIButton)m_Walker.Elements["\"AvatarButton2\""];
            m_AvatarButton3 = (UIButton)m_Walker.Elements["\"AvatarButton3\""];

            m_CityButton1 = (UIButton)m_Walker.Elements["\"CityButton1\""];
            m_CityButton1.AddImage(GetImage("\"CityButtonTemplateImage\"", true));
            m_CityButton1.Visible = false;
            m_CityButton2 = (UIButton)m_Walker.Elements["\"CityButton2\""];
            m_CityButton2.AddImage(GetImage("\"CityButtonTemplateImage\"", true));
            m_CityButton2.Visible = false;
            m_CityButton3 = (UIButton)m_Walker.Elements["\"CityButton3\""];
            m_CityButton3.AddImage(GetImage("\"CityButtonTemplateImage\"", true));
            m_CityButton3.Visible = false;

            m_HouseButton1 = (UIButton)m_Walker.Elements["\"HouseButton1\""];
            m_HouseButton1.AddImage(GetImage("\"HouseButtonTemplateImage\"", true));
            m_HouseButton1.Visible = false;
            m_HouseButton2 = (UIButton)m_Walker.Elements["\"HouseButton2\""];
            m_HouseButton2.AddImage(GetImage("\"HouseButtonTemplateImage\"", true));
            m_HouseButton2.Visible = false;
            m_HouseButton3 = (UIButton)m_Walker.Elements["\"HouseButton3\""];
            m_HouseButton3.AddImage(GetImage("\"HouseButtonTemplateImage\"", true));
            m_HouseButton3.Visible = false;

            m_NewAvatarButton1 = (UIButton)m_Walker.Elements["\"NewAvatarButton1\""];
            m_NewAvatarButton1.Visible = m_Avatars.Count >= 1 ? false : true;
            m_NewAvatarButton2 = (UIButton)m_Walker.Elements["\"NewAvatarButton2\""];
            m_NewAvatarButton2.Visible = m_Avatars.Count >= 2 ? false : true;
            m_NewAvatarButton3 = (UIButton)m_Walker.Elements["\"NewAvatarButton3\""];
            m_NewAvatarButton3.Visible = m_Avatars.Count == 3 ? false : true;

            m_DeleteAvatarButton1 = (UIButton)m_Walker.Elements["\"DeleteAvatarButton1\""];
            m_DeleteAvatarButton1.Visible = m_Avatars.Count >= 1 ? true : false;
            m_DeleteAvatarButton2 = (UIButton)m_Walker.Elements["\"DeleteAvatarButton2\""];
            m_DeleteAvatarButton2.Visible = m_Avatars.Count >= 2 ? true : false;
            m_DeleteAvatarButton3 = (UIButton)m_Walker.Elements["\"DeleteAvatarButton3\""];
            m_DeleteAvatarButton3.Visible = m_Avatars.Count == 3 ? true : false;

            m_PersonDescriptionText1 = (UITextEdit)m_Walker.Elements["\"PersonDescriptionText1\""];
            m_PersonDescriptionText1.Visible = m_Avatars.Count >= 1 ? true : false;
            m_PersonDescriptionText2 = (UITextEdit)m_Walker.Elements["\"PersonDescriptionText2\""];
            m_PersonDescriptionText2.Visible = m_Avatars.Count >= 2 ? true : false;
            m_PersonDescriptionText3 = (UITextEdit)m_Walker.Elements["\"PersonDescriptionText3\""];
            m_PersonDescriptionText3.Visible = m_Avatars.Count == 3 ? true : false;

            m_PersonDescriptionScrollUpBtn1 = (UIButton)m_Walker.Elements["\"PersonDescriptionScrollUpButton1\""];
            m_PersonDescriptionScrollUpBtn1.Visible = m_PersonDescriptionText1.Visible ? true : false;
            m_PersonDescriptionScrollUpBtn2 = (UIButton)m_Walker.Elements["\"PersonDescriptionScrollUpButton2\""];
            m_PersonDescriptionScrollUpBtn2.Visible = m_PersonDescriptionText2.Visible ? true : false;
            m_PersonDescriptionScrollUpBtn3 = (UIButton)m_Walker.Elements["\"PersonDescriptionScrollUpButton3\""];
            m_PersonDescriptionScrollUpBtn3.Visible = m_PersonDescriptionText3.Visible ? true : false;

            m_PersonDescriptionScrollDownBtn1 = (UIButton)m_Walker.Elements["\"PersonDescriptionScrollDownButton1\""];
            m_PersonDescriptionScrollDownBtn1.Visible = m_PersonDescriptionText1.Visible ? true : false;
            m_PersonDescriptionScrollDownBtn2 = (UIButton)m_Walker.Elements["\"PersonDescriptionScrollDownButton2\""];
            m_PersonDescriptionScrollDownBtn2.Visible = m_PersonDescriptionText2.Visible ? true : false;
            m_PersonDescriptionScrollDownBtn3 = (UIButton)m_Walker.Elements["\"PersonDescriptionScrollDownButton3\""];
            m_PersonDescriptionScrollDownBtn3.Visible = m_PersonDescriptionText3.Visible ? true : false;

            m_CityNameText1 = (UILabel)m_Walker.Elements["\"CityNameText1\""];
            m_CityNameText1.Visible = false;
            m_CityNameText2 = (UILabel)m_Walker.Elements["\"CityNameText2\""];
            m_CityNameText2.Visible = false;
            m_CityNameText3 = (UILabel)m_Walker.Elements["\"CityNameText3\""];
            m_CityNameText3.Visible = false;

            //TODO: Assign captions to these if a sim has a house...
            m_HouseNameText1 = (UILabel)m_Walker.Elements["\"HouseNameText1\""];
            m_HouseNameText2 = (UILabel)m_Walker.Elements["\"HouseNameText2\""];
            m_HouseNameText3 = (UILabel)m_Walker.Elements["\"HouseNameText3\""];

            m_CreditsButton = (UIButton)m_Walker.Elements["\"CreditsButton\""];
        }
Пример #10
0
        /// <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);
        }
Пример #11
0
 /// <summary>
 /// Gets a UIImage instance.
 /// </summary>
 /// <param name="Name">Name of the UIImage instance to get.</param>
 /// <param name="Copy">Should this element be deep copied?</param>
 /// <returns>A shallow or deep copy of the specified UIImage instance.</returns>
 public UIImage GetImage(string Name, bool Copy = false)
 {
     if (Copy)
     {
         UIImage Value = new UIImage((UIImage)m_Walker.Elements[Name]);
         return Value;
     }
     else
     {
         UIImage Value = (UIImage)m_Walker.Elements[Name];
         return Value;
     }
 }