Example #1
0
 public MuGuiManager()
 {
     LastMbMessage = string.Empty;
     zModalWindows = new List<Window>();
     zDoGetWindows = true;
     zWindows = new List<Window>();
     zLastCursorOwner = null;
     zWindowCursorOwner = null;
     LastMessageBoxReturn = MessageBoxReturn.Nothing;
 }
Example #2
0
 private void MouseEnterLeave()
 {
     if (zLastCursorOwner != zWindowCursorOwner)
     {
         if (zLastCursorOwner != null)
             zLastCursorOwner.MouseLeave();
         if (zWindowCursorOwner != null)
             zWindowCursorOwner.MouseEnter();
     }
     zLastCursorOwner = zWindowCursorOwner;
 }
Example #3
0
 public void Activity()
 {
     //for modal window, run this routine only for the last one
     if (zModalWindows.Count > 0)
     {
         List<Window> list = new List<Window>(1);
         list.Add(zModalWindows.Last());
         RecursiveGetWindowUnderCur(list);
     }
     else if (zDoGetWindows)
         RecursiveGetWindowUnderCur(zWindows);
     MouseEnterLeave();
     if (zWindowCursorOwner != null)
     {                
         zWindowCursorOwner.ExecuteMouseRoutine();
         zWindowCursorOwner = null;
     }
 }
Example #4
0
 public Chat() : base()
 {
     InitProps(new Vector2(-22,-11),new Vector2(10,1), new Color(0.3f, 0.3f, 0.3f, 0.75f), "", Color.White);
     zMaxCount = 100;
     zShowCount = 7;
     zTexts = new List<Window>();
     for (int i = 0; i < zShowCount; i++)
     {
         Window w = new Window(this);
         w.InitProps(Position + new Vector2(0, i * 1.5f +2), 
             new Vector2(15, 1), new Color(0.1f, 0.1f, 0.1f, 1), "", Color.White);
         w.Visible = false;
         zTexts.Add(w);
     }
     zMessages = new Queue<ChatMessage>();
     zStartIndex = -1;
     InitEvents();
     zMessageTextBox = new TextBox(this);
     zMessageTextBox.MaxLength = 35;            
     zMessageTextBox.InitProps(Position + new Vector2(3, 0), new Vector2(10, 1), new Color(0.1f, 0.1f, 0.1f, 1), "", Color.White);
     zMessageTextBox.AutoScale = true;
     zMessageTextBox.Visible = false;
     zMessageTextBox.OnEnter = delegate ()
     {
         ProcessInput(zMessageTextBox.Text);
         zMessageTextBox.Text = string.Empty;
         zMessageTextBox.Visible = false;
     };
     //hide if not typing
     Globals.EventManager.AddEvent(delegate ()
     {
         if (Collect)
             return 0;
         if (!zMessageTextBox.IsTyping())
             zMessageTextBox.Visible = false;
         return 1;
     }, "hideifnotyping");
 }
Example #5
0
 private void SetMessageToWindow(Window w, ChatMessage chatMessage)
 {
     float barHeight = 1;
     w.Text = chatMessage.text;
     w.Color = chatMessage.background;
     w.TextColor = chatMessage.foreground;
     w.Visible = true;
     w.Size = new Vector2(w.zText.Width + 0.4f, barHeight);
 }
Example #6
0
        /// <summary>
        /// Decides  wheter currently detected window under cursor should
        /// me executing clicking routines
        /// </summary>
        /// <param name="w"></param>
        private void ShouldReceiveClick(Window w)
        {
            if (zWindowCursorOwner == null)
                zWindowCursorOwner = w;
            else if (w.zParent == zWindowCursorOwner)
                zWindowCursorOwner = w;
            else if (w.IsHigherThan(zWindowCursorOwner))
                zWindowCursorOwner = w;

        }
Example #7
0
 public void RemoveWindow(Window w)
 {
     zWindows.Remove(w);
 }
Example #8
0
 public void AddWindow(Window w)
 {
     zWindows.Add(w);
 }
Example #9
0
 public void RemoveModalWindow(Window w)
 {
     zModalWindows.Remove(w);
 }
Example #10
0
 public void AddModalWindow(Window w)
 {
     zModalWindows.Add(w);
 }
Example #11
0
            public NewCharacterWindow():base(null,true)
            {
                zHeroClass = HeroClass.Invalid;
                InitProps(new Vector2(-11, 5), new Vector2(22, 15), new Color(0.3f, 0.3f, 0.3f, 0.75f), "", Color.White);
                CloseWithEscape = true;

                zNametextbox = new TextBox(this);
                zNametextbox.InitProps(Position + new Vector2(1, -7), new Vector2(14, 1.5f), new Color(0.1f, 0.1f, 0.1f, 1), "", Color.White);
                zNametextbox.MaxLength = 18;

                Window elfbutton = new Button(this);
                elfbutton.InitProps(Position + new Vector2(1, -1), new Vector2(4, 2), new Color(0.1f, 0.1f, 0.1f, 1), "Elf", Color.White);
                elfbutton.OnClick = delegate ()
                {
                    DisplayCharSprite(HeroClass.Elf);
                };

                Window knightbutton = new Button(this);
                knightbutton.InitProps(elfbutton.Position + new Vector2(5, 0), new Vector2(4, 2), new Color(0.1f, 0.1f, 0.1f, 1), "Knight", Color.White);
                knightbutton.OnClick = delegate ()
                {
                    DisplayCharSprite(HeroClass.Knight);
                };

                Window wizardbutton = new Button(this);
                wizardbutton.InitProps(knightbutton.Position + new Vector2(5, -0), new Vector2(4, 2), new Color(0.1f, 0.1f, 0.1f, 1), "Wizard", Color.White);
                wizardbutton.OnClick = delegate ()
                {
                    DisplayCharSprite(HeroClass.Wizard);
                };

                Window createbutton = new Button(this);
                createbutton.InitProps(Position + new Vector2(16.5f, -7), new Vector2(4, 2), new Color(0.1f, 0.1f, 0.1f, 1), "Create", Color.White);
                createbutton.OnClick = CreateNewCharacter;

                Window backbutton = new Button(this);
                backbutton.InitProps(createbutton.Position + new Vector2(0, -3), new Vector2(4, 2), new Color(0.1f, 0.1f, 0.1f, 1), "Back", Color.White);
                backbutton.OnClick = Destroy;

                zCharSprite = new Window(this);
                zCharSprite.InitProps(Position + new Vector2(15, -1), new Vector2(4, 4), Color.White, "", Color.White);
                zCharSprite.Visible = false;
            }
Example #12
0
            public PlayWindow() : base(null, true)
            {
                InitProps(new Vector2(-11, 5), new Vector2(22, 10), new Color(0.3f, 0.3f, 0.3f, 0.75f), "", Color.White);
                CloseWithEscape = true;

                var zServerLabel = new Window(this);
                zServerLabel.InitProps(Position + new Vector2(1, -1), new Vector2(4, 2), new Color(0.1f, 0.1f, 0.1f, 0), "Server", Color.White);

                zServer = new TextBox(this);
                zServer.InitProps(zServerLabel.Position + new Vector2(5, 0), new Vector2(15, 1.5f), new Color(0.1f, 0.1f, 0.1f, 1), Ini.Server, Color.White);
                zServer.MaxLength = 30;

                var portlabel = new Window(this);
                portlabel.InitProps(Position + new Vector2(1, -4), new Vector2(3, 2), new Color(0.1f, 0.1f, 0.1f, 0), "Port", Color.White);


                zPort = new TextBox(this);
                zPort.InitProps(portlabel.Position + new Vector2(5, 0), new Vector2(15, 1.5f), new Color(0.1f, 0.1f, 0.1f, 1), Ini.Port, Color.White);
                zPort.MaxLength = 5;

                Window startbutton = new Button(this);
                startbutton.InitProps(Position + new Vector2(1, -7), new Vector2(4, 2), new Color(0.1f, 0.1f, 0.1f, 1), "Start", Color.White);
                startbutton.OnClick = delegate ()
                {
                    Globals.Ip = "127.0.0.1";
                    MainMenu m = (MainMenu)ScreenManager.CurrentScreen;
                    if (TryPort())
                        m.Start();
                    else
                        new MessageBox("Invalid port");
                };

                Window joinbutton = new Button(this);
                joinbutton.InitProps(Position + new Vector2(6, -7), new Vector2(4, 2), new Color(0.1f, 0.1f, 0.1f, 1), "Join", Color.White);
                joinbutton.OnClick = delegate()
                {
                    Globals.Ip = zServer.Text == string.Empty ? "localhost" : zServer.Text;
                    MainMenu m = (MainMenu)ScreenManager.CurrentScreen;
                    if (TryPort())
                        m.Join();
                    else
                        new MessageBox("Invalid port");
                };

                Window closebutton = new Button(this);
                closebutton.InitProps(Position + new Vector2(11, -7), new Vector2(4, 2), new Color(0.1f, 0.1f, 0.1f, 1), "Back", Color.White);
                closebutton.OnClick = delegate ()
                {
                    Destroy();
                };
            }