public RenameMenu(TeleportMenu parentMenu, string title, MiniObelisk obelisk)
        {
            this.obelisk    = obelisk;
            this.parentMenu = parentMenu;

            base.xPositionOnScreen = 0;
            base.yPositionOnScreen = 0;
            base.width             = Game1.uiViewport.Width;
            base.height            = Game1.uiViewport.Height;
            this.title             = title;

            this.textBox        = new TextBox(null, null, Game1.dialogueFont, Game1.textColor);
            this.textBox.X      = Game1.uiViewport.Width / 2 - ((Game1.uiViewport.Width / 6) / 2);
            this.textBox.Y      = Game1.uiViewport.Height / 2;
            this.textBox.Width  = Game1.uiViewport.Width / 6;
            this.textBox.Height = 192;
            this.e = textBoxEnter;
            this.textBox.OnEnterPressed        += this.e;
            Game1.keyboardDispatcher.Subscriber = this.textBox;
            this.textBox.Text     = obelisk.CustomName;
            this.textBox.Selected = true;

            this.doneNamingButton = new ClickableTextureComponent(new Rectangle(this.textBox.X + this.textBox.Width + 32 + 4, Game1.uiViewport.Height / 2 - 8, 64, 64), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46), 1f)
            {
                myID            = 102,
                rightNeighborID = 103,
                leftNeighborID  = 104
            };
            this.textBoxCC = new ClickableComponent(new Rectangle(this.textBox.X, this.textBox.Y, textBox.Width, textBox.Height), "")
            {
                myID            = 104,
                rightNeighborID = 102
            };
            if (Game1.options.SnappyMenus)
            {
                base.populateClickableComponentList();
                this.snapToDefaultClickableComponent();
            }
        }
 private async Task RegisterUserAsync()
 {
     if (Nid == null || Nid.Equals(""))
     {
         UserTittle = "Ingrese Nid";
         _textBoxNid.Focus(FocusState.Programmatic);
     }
     else
     {
         if (Name == null || Name.Equals(""))
         {
             UserTittle = "Ingrese el nombre";
             _textBoxName.Focus(FocusState.Programmatic);
         }
         else
         {
             if (LastName == null || LastName.Equals(""))
             {
                 UserTittle = "Ingrese el apellido";
                 _textBoxLastName.Focus(FocusState.Programmatic);
             }
             else
             {
                 if (Telephone == null || Telephone.Equals(""))
                 {
                     UserTittle = "Ingrese el Numero de telefono";
                     _textBoxTelephone.Focus(FocusState.Programmatic);
                 }
                 else
                 {
                     if (Email == null || Email.Equals(""))
                     {
                         UserTittle = "Ingrese el email";
                         _textBoxEmail.Focus(FocusState.Programmatic);
                     }
                     else
                     {
                         if (TextBoxEvent.IsValidEmail(Email))
                         {
                             if (Password == null || Password.Equals(""))
                             {
                                 UserTittle = "Ingrese la contrseña";
                                 _textBoxPass.Focus(FocusState.Programmatic);
                             }
                             else
                             {
                                 if (User == null || User.Equals(""))
                                 {
                                     UserTittle = "Ingrese el usuario";
                                     _textBoxUser.Focus(FocusState.Programmatic);
                                 }
                                 else
                                 {
                                     if (SelectedRole == null || SelectedRole.Equals(""))
                                     {
                                         UserTittle = "Seleccione un rol";
                                     }
                                     else
                                     {
                                         await SaveDataAsync();
                                     }
                                 }
                             }
                         }
                         else
                         {
                             UserTittle = "el Email no es valido";
                             _textBoxEmail.Focus(FocusState.Programmatic);
                         }
                     }
                 }
             }
         }
     }
 }
        protected override void LoadContent()
        {
            // Load textures, map and sounds
            Tileset ts = new Tileset();

            try
            {
                ts.LoadFromStream(typeof(Map).Assembly.GetManifestResourceStream("GameClassLibrary.game.tileset"));

                FXCollection.Textures = new List <Texture2D>();
                for (int i = 0; i < ts.Images.Images.Count; i++)
                {
                    using (MemoryStream ms = new MemoryStream())
                    {
                        ts.Images.Images[i].Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                        FXCollection.Textures.Add(Texture2D.FromStream(GraphicsDevice, ms));
                    }
                }

                // Load sounds
                FXCollection.Songs        = new List <LoopedSoundPlayer>();
                FXCollection.SoundEffects = new List <SoundEffectInstance>();
                FXCollection.Songs[Songs.PreGame = FXCollection.Load <SoundEffect>("Audio\\Music\\titleSong")].Overlap       = new TimeSpan(0, 0, 0, 0, 1500);
                FXCollection.Songs[Songs.InGame = FXCollection.Load <SoundEffect>("Audio\\Music\\inGameBackground")].Overlap = new TimeSpan(0, 0, 0, 0, 2500);
                SoundEffects.Select  = FXCollection.Load <SoundEffectInstance>("Audio\\SoundEffects\\pop");
                SoundEffects.Collect = FXCollection.Load <SoundEffectInstance>("Audio\\SoundEffects\\boop");
                SoundEffects.Blip    = FXCollection.Load <SoundEffectInstance>("Audio\\SoundEffects\\blip");
            }
            catch
            {
                throw new Exception("There was a problem loading a resource!");
            }

            // Create audio zones for enemies
            for (int i = 1; i < World.Players.Count; i++)
            {
                Player e = World.Players[i];

                if (e is Enemy)
                {
                    // Temporary - just use the color red for enemies, rather than an actual texture
                    Texture2D texture = new Texture2D(GraphicsDevice, 1, 1);
                    texture.SetData(new[] { Color.Red });
                    FXCollection.Textures.Add(texture);

                    World.Players[i].CurrentGraphicIndex = FXCollection.Textures.Count - 1;
                    audioManager.AddZone(new EnemyAudioZone(e as Enemy, FXCollection.Load <SoundEffectInstance>("Audio\\Music\\tone"), 200));
                }
            }

            World.LightsFX = new LightsFX(
                Content.Load <Effect>("Effects\\resolveShadowsEffect"),
                Content.Load <Effect>("Effects\\reductionEffect"),
                Content.Load <Effect>("Effects\\2xMultiBlend"));

            // Eventually, the lower four lines graphics will be pulled from the tileset
            World.MainPlayer.BackGraphicIndex  = FXCollection.Load <Texture2D>("back_sprite");
            World.MainPlayer.FrontGraphicIndex = FXCollection.Load <Texture2D>("front_sprite");
            World.MainPlayer.LeftGraphicIndex  = FXCollection.Load <Texture2D>("left_sprite");
            World.MainPlayer.RightGraphicIndex = FXCollection.Load <Texture2D>("right_sprite");

            World.MainPlayer.CurrentGraphicIndex = World.MainPlayer.FrontGraphicIndex;

            KeyboardDispatcher = new KeyboardDispatcher(Window);

            inGamePanel      = new XNAComponentPanel(this);
            loginPanel       = new XNAComponentPanel(this);
            registerPanel    = new XNAComponentPanel(this);
            preGameMenuPanel = new XNAComponentPanel(this);
            howToPlayPanel   = new XNAComponentPanel(this);
            backgroundPanel  = new XNAComponentPanel(this);

            int screenWidth  = GraphicsDevice.Viewport.Width;
            int screenHeight = GraphicsDevice.Viewport.Height;

            Texture2D[] textboxTextures = new Texture2D[4]
            {
                Content.Load <Texture2D>("textboxBack"),
                Content.Load <Texture2D>("textboxLeft"),
                Content.Load <Texture2D>("textboxRight"),
                Content.Load <Texture2D>("textboxCaret")
            };

            // Background image with ripple effect
            background = new Background(this, Content.Load <Texture2D>("titleBackground"));
            RippleEffect rippleEffect = new RippleEffect(backgroundPanel);

            loginPanel.Components.Add(rippleEffect);
            registerPanel.Components.Add(rippleEffect);
            preGameMenuPanel.Components.Add(rippleEffect);
            howToPlayPanel.Components.Add(rippleEffect);

            PreGameMenu = new XNAMenu(this, new Rectangle(screenWidth / 2 - 150, screenHeight / 2 - 100, 300, 200))
            {
                ForeColor      = SD.Color.FromArgb(25, 50, 150),
                HighlightColor = SD.Color.FromArgb(4, 4, 99),
                Font           = new SD.Font("Calibri", 36),
                RenderingHint  = SD.Text.TextRenderingHint.SingleBitPerPixelGridFit,
                ItemHeight     = 60
            };
            PreGameMenu.SelectionChanged += (o, e) => { FXCollection.SoundEffects[SoundEffects.Blip].Play(); };
            PreGameMenu.AddMenuItem("Log In", (o, e) =>
            {
                FXCollection.SoundEffects[SoundEffects.Select].Play();
                World.GameState = GameState.Login;
            });
            PreGameMenu.AddMenuItem("Create Account", (o, e) =>
            {
                FXCollection.SoundEffects[SoundEffects.Select].Play();
                World.GameState = GameState.Register;
            });
            PreGameMenu.AddMenuItem("How to Play", (o, e) =>
            {
                FXCollection.SoundEffects[SoundEffects.Select].Play();

                World.GameState = GameState.HowToPlay;
            });
            PreGameMenu.AddMenuItem("Quit Game", (o, e) =>
            {
                FXCollection.SoundEffects[SoundEffects.Select].Play();
                System.Threading.Tasks.Task.Factory.StartNew(() =>
                {
                    System.Threading.Thread.Sleep(300);                     // Make sure the select sound plays
                    Exit();
                });
            });

            XNAPictureBox titlePicture = new XNAPictureBox(this, new Rectangle(100, screenHeight / 2 - 50, screenWidth - 200, 200))
            {
                StretchMode = StretchMode.CenterInFrame,
                Texture     = Content.Load <Texture2D>("logo")
            };

            loginPanel.Components.Add(titlePicture);
            registerPanel.Components.Add(titlePicture);
            preGameMenuPanel.Components.Add(titlePicture);
            howToPlayPanel.Components.Add(titlePicture);

            //temporary action objects that are used to construct the member TextBoxEvent variables
            Action <object, EventArgs> loginEvent;
            Action <object, EventArgs> registerEvent;

            // Login event
            loginEvent = (o, e) =>
            {
                FXCollection.SoundEffects[SoundEffects.Select].Play();

                World.GameState = GameState.LoggingIn;

                World.MainPlayer.SendToServer(ServerAction.ClientLogin,
                                              new LoginData(usernameTextbox.Text, passwordTextbox.Text));
            };

            loginTBEvent = new TextBoxEvent(loginEvent);

            // Register event
            registerEvent = (o, e) =>
            {
                if (passwordTextbox.Text == confirmPasswordTextbox.Text)
                {
                    FXCollection.SoundEffects[SoundEffects.Select].Play();

                    World.GameState = GameState.Registering;

                    World.MainPlayer.SendToServer(ServerAction.ClientCreateAcc,
                                                  new LoginData(usernameTextbox.Text, passwordTextbox.Text));
                }
                else
                {
                    FXCollection.SoundEffects[SoundEffects.Select].Play();

                    XNADialog errDlg = new XNADialog(this, "Passwords do not match.", "Error creating account!");
                    errDlg.CloseAction = (param) => { FXCollection.SoundEffects[SoundEffects.Select].Play(); };
                }
            };

            XNALabel howToPlayText = new XNALabel(this, new Rectangle(screenWidth / 4, screenHeight / 2 - 80, screenWidth / 2, 300));

            howToPlayText.Text = Resources.HowToPlayText;
            howToPlayText.Font = new SD.Font("Calibri", 16);
            howToPlayPanel.Components.Add(howToPlayText);

            XNAHyperLink backHyperlink = new XNAHyperLink(
                this,
                new Rectangle(3 * screenWidth / 4 - 50, screenHeight / 2 + 75, 50, 30),
                "Arial", 12.0f,
                SD.FontStyle.Bold,
                SD.Text.TextRenderingHint.SingleBitPerPixelGridFit);

            backHyperlink.DrawOrder      = (int)RenderOrder.UILayer;
            backHyperlink.ForeColor      = SD.Color.FromArgb(139, 95, 71);
            backHyperlink.HighlightColor = SD.Color.FromArgb(150, 139, 95, 71);
            backHyperlink.Text           = "Back";
            backHyperlink.TextAlign      = System.Drawing.ContentAlignment.MiddleRight;
            backHyperlink.OnClick       += (o, e) =>
            {
                FXCollection.SoundEffects[SoundEffects.Select].Play();
                World.GameState = GameState.PregameMenu;
            };
            howToPlayPanel.Components.Add(backHyperlink);

            registerTBEvent = new TextBoxEvent(registerEvent);

            subscribeToUsernameBox = (object sender, EventArgs e) => { usernameTextbox.Selected = true; KeyboardDispatcher.Subscriber = usernameTextbox; };
            subscribeToPasswordBox = (object sender, EventArgs e) => { passwordTextbox.Selected = true; KeyboardDispatcher.Subscriber = passwordTextbox; };
            subscribeToConfirmBox  = (object sender, EventArgs e) => { confirmPasswordTextbox.Selected = true; KeyboardDispatcher.Subscriber = confirmPasswordTextbox; };

            // Update error message event
            World.MainPlayer.UpdateErrorMessage += (o, e) =>
            {
                //close any open dialog
                XNADialog errMsg = new XNADialog(this, e.Message, e.Caption);
                if (!(o as ConnectedPlayer).Connected)
                {
                    errMsg.CloseAction += (bool success) =>
                    {
                        FXCollection.SoundEffects[SoundEffects.Select].Play();
                        this.Exit();
                    }
                }
                ;
            };

            World.MainPlayer.BacteriaCollect += (o, e) =>
            {
                FXCollection.SoundEffects[SoundEffects.Collect].Play();

                overlayRenderer.RenderBacteriaCount();
            };

            // Username field
            usernameTextbox             = new XNATextBox(this, new Rectangle(screenWidth / 2 - 100, screenHeight / 2 - 70, 200, 30), textboxTextures, "Arial", 12.0f);
            usernameTextbox.DrawOrder   = (int)RenderOrder.UILayer;
            usernameTextbox.MaxChars    = 30;
            usernameTextbox.DefaultText = "Username";
            usernameTextbox.Clicked    += subscribeToUsernameBox;
            subscribeToUsernameBox(usernameTextbox);
            usernameTextbox.OnTabPressed += subscribeToPasswordBox;
            loginPanel.Components.Add(usernameTextbox);
            registerPanel.Components.Add(usernameTextbox);

            // Password field
            passwordTextbox             = new XNATextBox(this, new Rectangle(screenWidth / 2 - 100, screenHeight / 2 - 20, 200, 30), textboxTextures, "Arial", 12.0f);
            passwordTextbox.DrawOrder   = (int)RenderOrder.UILayer;
            passwordTextbox.MaxChars    = 30;
            passwordTextbox.DefaultText = "Password";
            passwordTextbox.PasswordBox = true;
            passwordTextbox.Clicked    += subscribeToPasswordBox;
            loginPanel.Components.Add(passwordTextbox);
            registerPanel.Components.Add(passwordTextbox);

            // Confirm password field
            confirmPasswordTextbox                 = new XNATextBox(this, new Rectangle(screenWidth / 2 - 100, screenHeight / 2 + 30, 200, 30), textboxTextures, "Arial", 12.0f);
            confirmPasswordTextbox.DrawOrder       = (int)RenderOrder.UILayer;
            confirmPasswordTextbox.MaxChars        = 30;
            confirmPasswordTextbox.DefaultText     = "Confirm Password";
            confirmPasswordTextbox.PasswordBox     = true;
            confirmPasswordTextbox.Clicked        += subscribeToConfirmBox;
            confirmPasswordTextbox.OnTabPressed   += subscribeToUsernameBox;
            confirmPasswordTextbox.OnEnterPressed += new TextBoxEvent(registerEvent);
            registerPanel.Components.Add(confirmPasswordTextbox);

            Texture2D[] loginButtonTextures = new Texture2D[2]
            {
                Content.Load <Texture2D>("button"),
                Content.Load <Texture2D>("buttonHover")
            };

            XNAButton loginButton = new XNAButton(this, new Vector2(screenWidth / 2 + 20, screenHeight / 2 + 30), "Login");

            loginButton.DrawOrder = (int)RenderOrder.UILayer;
            loginButton.OnClick  += new XNAButton.ButtonClickEvent(loginEvent);
            loginPanel.Components.Add(loginButton);

            XNAButton registerButton = new XNAButton(this, new Vector2(screenWidth / 2 + 20, screenHeight / 2 + 80), "Register");

            registerButton.DrawOrder = (int)RenderOrder.UILayer;
            registerButton.OnClick  += new XNAButton.ButtonClickEvent(registerEvent);
            registerPanel.Components.Add(registerButton);

            cancelHyperlink = new XNAHyperLink(
                this,
                new Rectangle(screenWidth / 2 - 95, screenHeight / 2 + 80, 100, 30),
                "Arial", 12.0f,
                SD.FontStyle.Bold,
                SD.Text.TextRenderingHint.SingleBitPerPixelGridFit);
            cancelHyperlink.DrawOrder      = (int)RenderOrder.UILayer;
            cancelHyperlink.ForeColor      = SD.Color.FromArgb(139, 95, 71);
            cancelHyperlink.HighlightColor = SD.Color.FromArgb(150, 139, 95, 71);
            cancelHyperlink.Text           = "Cancel";
            cancelHyperlink.TextAlign      = System.Drawing.ContentAlignment.MiddleLeft;
            cancelHyperlink.OnClick       += (o, e) =>
            {
                FXCollection.SoundEffects[SoundEffects.Select].Play();
                World.GameState = GameState.PregameMenu;
            };
            registerPanel.Components.Add(cancelHyperlink);
            loginPanel.Components.Add(cancelHyperlink);

            // Map renderer
            MapRenderer mapRenderer = new MapRenderer(this, World.CurrentMap);

            inGamePanel.Components.Add(mapRenderer);

            // NPC rendering engine
            GraphicEngine npcEngine = new GraphicEngine(this, RenderOrder.NPCLayer);

            GraphicsEngineComponent.CreateAndAdd <MinorPlayerRenderer>(npcEngine);
            inGamePanel.Components.Add(npcEngine);

            // Overlay rendering engine
            GraphicEngine overlayEngine = new GraphicEngine(this, RenderOrder.OverlayLayer);

            overlayRenderer = GraphicsEngineComponent.CreateAndAdd <OverlayRenderer>(overlayEngine);
            inGamePanel.Components.Add(overlayEngine);

            // Audio manager
            inGamePanel.Components.Add(audioManager = new AudioManager(this));

            // Input handler
            InputHandler = new InputHandler(this);
            inGamePanel.Components.Add(InputHandler);
            InputHandler.ChatBoxClosing += (o, e) =>
            {
                if (ShowChatPrompt && chatRenderer.MessageBox.Text != "")
                {
                    World.MainPlayer.SendToServer(ServerAction.ClientSay, new TalkData(chatRenderer.MessageBox.Text));
                    chatRenderer.MessageBox.Text = "";
                }
            };
            InputHandler.RemoveTilde += () =>
            {
                chatRenderer.MessageBox.Text = chatRenderer.MessageBox.Text.TrimEnd('`');
            };

            // Main Player
            inGamePanel.Components.Add(MainPlayer = new PlayerComponent(this, World.MainPlayer));

            // Pause menu
            GraphicEngine pauseMenuEngine = new GraphicEngine(this, RenderOrder.PauseMenuLayer);

            GraphicsEngineComponent.CreateAndAdd <PauseMenuRenderer>(pauseMenuEngine);
            inGamePanel.Components.Add(pauseMenuEngine);

            // Chat
            GraphicEngine chatEngine = new GraphicEngine(this, RenderOrder.ChatLayer);

            chatRenderer = GraphicsEngineComponent.CreateAndAdd <ChatRenderer>(chatEngine);
            inGamePanel.Components.Add(chatEngine);

            World.GameState = GameState.PregameMenu;
        }
        public CustomNamingMenu(doneNamingBehavior b, string titleMaleIn, string titleFemaleIn, string defaultName = null)
        {
            doneNaming        = b;
            xPositionOnScreen = 0;
            yPositionOnScreen = 0;
            width             = Game1.viewport.Width;
            height            = Game1.viewport.Height;
            titleMale         = titleMaleIn;
            titleFemale       = titleFemaleIn;
            gender            = "Male";
            //randomButton = new ClickableTextureComponent(new Rectangle(xPositionOnScreen + width + 51 + 64, Game1.viewport.Height / 2, 64, 64), Game1.mouseCursors, new Rectangle(381, 361, 10, 10), 4f, false);
            textBox        = new TextBox(null, null, Game1.dialogueFont, Game1.textColor);
            textBox.X      = Game1.viewport.Width / 2 - 192;
            textBox.Y      = Game1.viewport.Height / 2;
            textBox.Width  = 256;
            textBox.Height = 192;
            e = new TextBoxEvent(this.textBoxEnter);
            textBox.OnEnterPressed += this.e;
            Game1.keyboardDispatcher.Subscriber = textBox;
            textBox.Text     = defaultName != null ? defaultName : Dialogue.randomName();
            textBox.Selected = true;

            ClickableTextureComponent textureComponent1 = new ClickableTextureComponent(new Rectangle(textBox.X + textBox.Width + 64 + 48 - 8, Game1.viewport.Height / 2 + 4, 64, 64), Game1.mouseCursors, new Rectangle(381, 361, 10, 10), 4f, false);

            textureComponent1.myID            = 103;
            textureComponent1.leftNeighborID  = 102;
            textureComponent1.rightNeighborID = region_male;
            randomButton = textureComponent1;

            ClickableTextureComponent textureComponent2 = new ClickableTextureComponent(new Rectangle(textBox.X + textBox.Width + 32 + 4, Game1.viewport.Height / 2 - 8, 64, 64), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false);

            textureComponent2.myID            = 102;
            textureComponent2.rightNeighborID = 103;
            textureComponent2.leftNeighborID  = 104;
            doneNamingButton = textureComponent2;

            ClickableTextureComponent textureComponent3 = new ClickableTextureComponent("Male", new Rectangle(textBox.X + textBox.Width + 64 + 48 + 32 + 8, Game1.viewport.Height / 2 + 4, 64, 64), null, "Male", Game1.mouseCursors, new Rectangle(128, 192, 16, 16), 4f, false);

            textureComponent3.myID            = region_male;
            textureComponent3.rightNeighborID = region_female;
            textureComponent3.leftNeighborID  = region_randomButton;
            maleButton = textureComponent3;

            ClickableTextureComponent textureComponent4 = new ClickableTextureComponent("Female", new Rectangle(textBox.X + textBox.Width + 64 + 48 + 32 + 8 + 64, Game1.viewport.Height / 2 + 4, 64, 64), null, "Female", Game1.mouseCursors, new Rectangle(144, 192, 16, 16), 4f, false);

            textureComponent4.myID           = region_female;
            textureComponent4.leftNeighborID = region_male;
            femaleButton = textureComponent4;

            textBoxCC = new ClickableComponent(new Rectangle(textBox.X, textBox.Y, 192, 48), "")
            {
                myID            = 104,
                rightNeighborID = 102
            };
            if (!Game1.options.SnappyMenus)
            {
                return;
            }
            populateClickableComponentList();
            snapToDefaultClickableComponent();
        }
Exemple #5
0
 public PurchaseAnimalsMenu(List <Object> stock)
     : base(Game1.viewport.Width / 2 - menuWidth / 2 - IClickableMenu.borderWidth * 2, (Game1.viewport.Height - menuHeight - IClickableMenu.borderWidth * 2) / 4, menuWidth + IClickableMenu.borderWidth * 2, menuHeight + IClickableMenu.borderWidth)
 {
     height += 64;
     for (int i = 0; i < stock.Count; i++)
     {
         animalsToPurchase.Add(new ClickableTextureComponent(string.Concat(stock[i].salePrice()), new Microsoft.Xna.Framework.Rectangle(xPositionOnScreen + IClickableMenu.borderWidth + i % 3 * 64 * 2, yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth / 2 + i / 3 * 85, 128, 64), null, stock[i].Name, Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(i % 3 * 16 * 2, 448 + i / 3 * 16, 32, 16), 4f, stock[i].Type == null)
         {
             item            = stock[i],
             myID            = i,
             rightNeighborID = ((i % 3 == 2) ? (-1) : (i + 1)),
             leftNeighborID  = ((i % 3 == 0) ? (-1) : (i - 1)),
             downNeighborID  = i + 3,
             upNeighborID    = i - 3
         });
     }
     okButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(xPositionOnScreen + width + 4, yPositionOnScreen + height - 64 - IClickableMenu.borderWidth, 64, 64), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 47), 1f)
     {
         myID           = 101,
         upNeighborID   = 103,
         leftNeighborID = 103
     };
     randomButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(xPositionOnScreen + width + 51 + 64, Game1.viewport.Height / 2, 64, 64), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(381, 361, 10, 10), 4f)
     {
         myID            = 103,
         downNeighborID  = 101,
         rightNeighborID = 101
     };
     menuHeight     = 320;
     menuWidth      = 448;
     textBox        = new TextBox(null, null, Game1.dialogueFont, Game1.textColor);
     textBox.X      = Game1.viewport.Width / 2 - 192;
     textBox.Y      = Game1.viewport.Height / 2;
     textBox.Width  = 256;
     textBox.Height = 192;
     e         = textBoxEnter;
     textBoxCC = new ClickableComponent(new Microsoft.Xna.Framework.Rectangle(textBox.X, textBox.Y, 192, 48), "")
     {
         myID            = 104,
         rightNeighborID = 102,
         downNeighborID  = 101
     };
     randomButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(textBox.X + textBox.Width + 64 + 48 - 8, Game1.viewport.Height / 2 + 4, 64, 64), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(381, 361, 10, 10), 4f)
     {
         myID            = 103,
         leftNeighborID  = 102,
         downNeighborID  = 101,
         rightNeighborID = 101
     };
     doneNamingButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(textBox.X + textBox.Width + 32 + 4, Game1.viewport.Height / 2 - 8, 64, 64), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46), 1f)
     {
         myID            = 102,
         rightNeighborID = 103,
         leftNeighborID  = 104,
         downNeighborID  = 101
     };
     if (Game1.options.SnappyMenus)
     {
         populateClickableComponentList();
         snapToDefaultClickableComponent();
     }
 }
 private void Telephone_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
 {
     TextBoxEvent.numberPreviewKeyDown(e);
 }
 private void LastName_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
 {
     TextBoxEvent.textPreviewKeyDown(e);
 }
Exemple #8
0
 public TextBox(Game g)
     : base(g)
 {
     OnSubTextShowDone = new TextBoxEvent(OnSubTextShowDoneCode);
 }
Exemple #9
0
 public TextBox(Game g)
     : base(g)
 {
     OnSubTextShowDone = new TextBoxEvent(OnSubTextShowDoneCode);
 }
Exemple #10
0
 public PurchaseAnimalsMenu(List <StardewValley.Object> stock) : base(Game1.viewport.Width / 2 - PurchaseAnimalsMenu.menuWidth / 2 - IClickableMenu.borderWidth * 2, Game1.viewport.Height / 2 - PurchaseAnimalsMenu.menuHeight - IClickableMenu.borderWidth * 2, PurchaseAnimalsMenu.menuWidth + IClickableMenu.borderWidth * 2, PurchaseAnimalsMenu.menuHeight + IClickableMenu.borderWidth, false)
 {
     this.height += Game1.tileSize;
     for (int i = 0; i < stock.Count; i++)
     {
         this.animalsToPurchase.Add(new ClickableTextureComponent(string.Concat(stock[i].salePrice()), new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + IClickableMenu.borderWidth + i % 3 * Game1.tileSize * 2, this.yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth / 2 + i / 3 * (Game1.tileSize + Game1.tileSize / 3), Game1.tileSize * 2, Game1.tileSize), null, stock[i].Name, Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(i % 3 * 16 * 2, 448 + i / 3 * 16, 32, 16), 4f, stock[i].type == null)
         {
             item            = stock[i],
             myID            = i,
             rightNeighborID = ((i % 3 == 2) ? -1 : (i + 1)),
             leftNeighborID  = ((i % 3 == 0) ? -1 : (i - 1)),
             downNeighborID  = i + 3,
             upNeighborID    = i - 3
         });
     }
     this.okButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + this.width + 4, this.yPositionOnScreen + this.height - Game1.tileSize - IClickableMenu.borderWidth, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 47, -1, -1), 1f, false)
     {
         myID           = 101,
         upNeighborID   = 103,
         leftNeighborID = 103
     };
     this.randomButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + this.width + Game1.tileSize * 4 / 5 + Game1.tileSize, Game1.viewport.Height / 2, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(381, 361, 10, 10), (float)Game1.pixelZoom, false)
     {
         myID            = 103,
         downNeighborID  = 101,
         rightNeighborID = 101
     };
     PurchaseAnimalsMenu.menuHeight = Game1.tileSize * 5;
     PurchaseAnimalsMenu.menuWidth  = Game1.tileSize * 7;
     this.textBox        = new TextBox(null, null, Game1.dialogueFont, Game1.textColor);
     this.textBox.X      = Game1.viewport.Width / 2 - Game1.tileSize * 3;
     this.textBox.Y      = Game1.viewport.Height / 2;
     this.textBox.Width  = Game1.tileSize * 4;
     this.textBox.Height = Game1.tileSize * 3;
     this.e         = new TextBoxEvent(this.textBoxEnter);
     this.textBoxCC = new ClickableComponent(new Microsoft.Xna.Framework.Rectangle(this.textBox.X, this.textBox.Y, 192, 48), "")
     {
         myID            = 104,
         rightNeighborID = 102,
         downNeighborID  = 101
     };
     this.randomButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.textBox.X + this.textBox.Width + Game1.tileSize + Game1.tileSize * 3 / 4 - Game1.pixelZoom * 2, Game1.viewport.Height / 2 + Game1.pixelZoom, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(381, 361, 10, 10), (float)Game1.pixelZoom, false)
     {
         myID            = 103,
         leftNeighborID  = 102,
         downNeighborID  = 101,
         rightNeighborID = 101
     };
     this.doneNamingButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.textBox.X + this.textBox.Width + Game1.tileSize / 2 + Game1.pixelZoom, Game1.viewport.Height / 2 - Game1.pixelZoom * 2, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false)
     {
         myID            = 102,
         rightNeighborID = 103,
         leftNeighborID  = 104,
         downNeighborID  = 101
     };
     if (Game1.options.SnappyMenus)
     {
         base.populateClickableComponentList();
         this.snapToDefaultClickableComponent();
     }
 }
Exemple #11
0
        public PurchaseAnimalsMenu(List <StardewValley.Object> stock)
            : base(Game1.viewport.Width / 2 - PurchaseAnimalsMenu.menuWidth / 2 - IClickableMenu.borderWidth * 2, Game1.viewport.Height / 2 - PurchaseAnimalsMenu.menuHeight - IClickableMenu.borderWidth * 2, PurchaseAnimalsMenu.menuWidth + IClickableMenu.borderWidth * 2, PurchaseAnimalsMenu.menuHeight + IClickableMenu.borderWidth, false)
        {
            this.height = this.height + Game1.tileSize;
            for (int index = 0; index < stock.Count; ++index)
            {
                List <ClickableTextureComponent> animalsToPurchase = this.animalsToPurchase;
                ClickableTextureComponent        textureComponent  = new ClickableTextureComponent(string.Concat((object)stock[index].salePrice()), new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + IClickableMenu.borderWidth + index % 3 * Game1.tileSize * 2, this.yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth / 2 + index / 3 * (Game1.tileSize + Game1.tileSize / 3), Game1.tileSize * 2, Game1.tileSize), (string)null, stock[index].Name, Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(index % 3 * 16 * 2, 448 + index / 3 * 16, 32, 16), 4f, stock[index].type == null);
                StardewValley.Object             @object           = stock[index];
                textureComponent.item = (Item)@object;
                int num1 = index;
                textureComponent.myID = num1;
                int num2 = index % 3 == 2 ? -1 : index + 1;
                textureComponent.rightNeighborID = num2;
                int num3 = index % 3 == 0 ? -1 : index - 1;
                textureComponent.leftNeighborID = num3;
                int num4 = index + 3;
                textureComponent.downNeighborID = num4;
                int num5 = index - 3;
                textureComponent.upNeighborID = num5;
                animalsToPurchase.Add(textureComponent);
            }
            ClickableTextureComponent textureComponent1 = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + this.width + 4, this.yPositionOnScreen + this.height - Game1.tileSize - IClickableMenu.borderWidth, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 47, -1, -1), 1f, false);
            int num6 = 101;

            textureComponent1.myID = num6;
            int num7 = 103;

            textureComponent1.upNeighborID = num7;
            int num8 = 103;

            textureComponent1.leftNeighborID = num8;
            this.okButton = textureComponent1;
            ClickableTextureComponent textureComponent2 = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + this.width + Game1.tileSize * 4 / 5 + Game1.tileSize, Game1.viewport.Height / 2, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(381, 361, 10, 10), (float)Game1.pixelZoom, false);
            int num9 = 103;

            textureComponent2.myID = num9;
            int num10 = 101;

            textureComponent2.downNeighborID = num10;
            int num11 = 101;

            textureComponent2.rightNeighborID = num11;
            this.randomButton = textureComponent2;
            PurchaseAnimalsMenu.menuHeight = Game1.tileSize * 5;
            PurchaseAnimalsMenu.menuWidth  = Game1.tileSize * 7;
            this.textBox        = new TextBox((Texture2D)null, (Texture2D)null, Game1.dialogueFont, Game1.textColor);
            this.textBox.X      = Game1.viewport.Width / 2 - Game1.tileSize * 3;
            this.textBox.Y      = Game1.viewport.Height / 2;
            this.textBox.Width  = Game1.tileSize * 4;
            this.textBox.Height = Game1.tileSize * 3;
            this.e         = new TextBoxEvent(this.textBoxEnter);
            this.textBoxCC = new ClickableComponent(new Microsoft.Xna.Framework.Rectangle(this.textBox.X, this.textBox.Y, 192, 48), "")
            {
                myID            = 104,
                rightNeighborID = 102,
                downNeighborID  = 101
            };
            ClickableTextureComponent textureComponent3 = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.textBox.X + this.textBox.Width + Game1.tileSize + Game1.tileSize * 3 / 4 - Game1.pixelZoom * 2, Game1.viewport.Height / 2 + Game1.pixelZoom, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(381, 361, 10, 10), (float)Game1.pixelZoom, false);
            int num12 = 103;

            textureComponent3.myID = num12;
            int num13 = 102;

            textureComponent3.leftNeighborID = num13;
            int num14 = 101;

            textureComponent3.downNeighborID = num14;
            int num15 = 101;

            textureComponent3.rightNeighborID = num15;
            this.randomButton = textureComponent3;
            ClickableTextureComponent textureComponent4 = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.textBox.X + this.textBox.Width + Game1.tileSize / 2 + Game1.pixelZoom, Game1.viewport.Height / 2 - Game1.pixelZoom * 2, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false);
            int num16 = 102;

            textureComponent4.myID = num16;
            int num17 = 103;

            textureComponent4.rightNeighborID = num17;
            int num18 = 104;

            textureComponent4.leftNeighborID = num18;
            int num19 = 101;

            textureComponent4.downNeighborID = num19;
            this.doneNamingButton            = textureComponent4;
            if (!Game1.options.SnappyMenus)
            {
                return;
            }
            this.populateClickableComponentList();
            this.snapToDefaultClickableComponent();
        }
        //Check for codes in the Text and apply specific actions.
        void CheckCodeAction()
        {
            //Check for action code in the text.
            switch (_CurrentWord.Trim())
            {
                //New Line.
                case ("/n"):
                    {
                        //Add a new line.
                        _TextBoxEvent = TextBoxEvent.NewLine;
                        //Find the next word.
                        FindNextWord();

                        break;
                    }
                //Clear the Box.
                case ("/c"):
                    {
                        //Update the Delay Multiplier.
                        _TextBoxEvent = TextBoxEvent.ClearTextBox;
                        //Find the next word.
                        FindNextWord();

                        break;
                    }
                //Faster Text.
                case ("/f"):
                    {
                        //Update the Delay Multiplier.
                        _TextBoxEvent = TextBoxEvent.DelayMultiplierChange;
                        //Decrease the delay.
                        _UpdateDelayMultiplier -= .25f;
                        //Keep it within limits.
                        _UpdateDelayMultiplier = (float)Math.Max(_UpdateDelayMultiplier, .25);
                        //Find the next word.
                        FindNextWord();

                        break;
                    }
                //Slower Text.
                case ("/s"):
                    {
                        //Update the Delay Multiplier.
                        _TextBoxEvent = TextBoxEvent.DelayMultiplierChange;
                        //Decrease the delay.
                        _UpdateDelayMultiplier += .25f;
                        //Keep it within limits.
                        _UpdateDelayMultiplier = (float)Math.Min(_UpdateDelayMultiplier, 10);
                        //Find the next word.
                        FindNextWord();

                        break;
                    }
            }
        }
        //Decide if if it's time to add another row or begin scrolling them.
        void AddRowOrScrollTextBox()
        {
            //Create the char array, containing spaces.
            char[] space = { ' ' };
            //Trim the Current word so that the leading white-space is removed.
            _CurrentWord = _CurrentWord.TrimStart(space);

            //Check if there is room for another row.
            if (_CurrentRow < (((int)Math.Round((_TextBox.Height / _RowSeperation), 0)) - 1))
            {
                //Add a row.
                AddRow();
                //Reset the TextBoxEvent.
                _TextBoxEvent = TextBoxEvent.None;
            }
            else
            {
                //Wait for user Input.
                _WaitForInput = true;
                //Reset the Text Box.
                _TextBoxEvent = TextBoxEvent.ScrollRowsDown;
            }
        }
        //Update the Text.
        public void UpdateText()
        {
            //Check if the letter is completely printed.
            if (_TextList[_CurrentRow].EndsWith(_CurrentWord))
            {
                //Check if there are more words.
                if ((_TextClone.IndexOf(_CurrentWord) + _CurrentWord.Length) < _TextClone.Length)
                {
                    //Find the next word.
                    NextWord();

                    //Check what type of action is ordered.
                    switch (_TextBoxEvent)
                    {
                        //If no action is ordered.
                        case (TextBoxEvent.None):
                            {
                                //Check if the new word doesn't fit.
                                if (!WillWordFit(_CurrentWord, _CurrentRow))
                                {
                                    //Add a row or scrool the rows.
                                    AddRowOrScrollTextBox();
                                }
                                else
                                {
                                    //Add the white-space.
                                    AddLetter();
                                    //Increment the Index counter.
                                    _Index++;
                                }
                                //End.
                                break;
                            }
                        //If a new line action is ordered.
                        case (TextBoxEvent.NewLine):
                            {
                                //Add a row or Reset the whole Text Box.
                                AddRowOrScrollTextBox();
                                //End.
                                break;
                            }
                        //If a clear box action is ordered.
                        case (TextBoxEvent.ClearTextBox):
                            {
                                //Wait for user input.
                                _WaitForInput = true;
                                //End.
                                break;
                            }
                        //If a delay multiplier change action is ordered.
                        case (TextBoxEvent.DelayMultiplierChange):
                            {
                                //Goto the default action.
                                goto case (TextBoxEvent.None);
                            }
                    }
                }
                //If there's no more words in the Text.
                else
                {
                    //Wait for user Input.
                    _WaitForInput = true;
                    //End the Text Box.
                    _TextBoxEvent = TextBoxEvent.EndTextBox;
                }
            }
        }
        //Handle all Input.
        public void HandleInput(InputState input)
        {
            //Check if it is waiting for user Input.
            if (_WaitForInput)
            {
                //Check for Input.
                if (input.MainSelect)
                {
                    //Check for what event should be happening.
                    switch (_TextBoxEvent)
                    {
                        case (TextBoxEvent.ClearTextBox):
                            {
                                //Clear the Text Box.
                                ClearTextBox();
                                //Exit.
                                break;
                            }
                        case (TextBoxEvent.ScrollRowsDown):
                            {
                                //Scroll the rows one step.
                                ScrollRows();
                                //Exit.
                                break;
                            }
                        case (TextBoxEvent.EndTextBox):
                            {
                                //Exit.
                                _Exit = true;
                                //Call the TextPrinted Event.
                                TextPrinted(this);

                                //Exit.
                                break;
                            }
                    }
                    //Disable the WaitForInput.
                    _WaitForInput = false;
                    //Reset the TextBoxEvent.
                    _TextBoxEvent = TextBoxEvent.None;
                }
            }
        }