Пример #1
0
        public ChatMenu()
        {
            screenSize = GUCView.GetScreenSize();
            chatHeigth = screenSize.Y / 5;
            chatWidth  = screenSize.X - 350;

            chatBackground = new GUCVisual(0, 0, chatWidth, chatHeigth + 5);
            chatBackground.SetBackTexture("Dlg_Conversation.tga");

            const int space = 20;
            int       lines = chatHeigth / space;

            for (int i = 0; i < lines; i++)
            {
                chatBackground.CreateText("" + i, 20, 5 + i * space);
                chatBackground.Texts[i].Text = "";
            }

            textBox = new GUCTextBox(70, chatHeigth + 5, chatWidth - 90, false);
            prefix  = new GUCVisual(15, chatHeigth + 5, chatWidth, 20);
            prefix.CreateText("", 0, 0);

            chatInactivityTimer = new GUCTimer();
            chatInactivityTimer.SetCallback(() => { if (!textBox.Enabled)
                                                    {
                                                        chatBackground.Hide();
                                                    }
                                                    chatInactivityTimer.Stop(); });
            chatInactivityTimer.SetInterval(6 * TimeSpan.TicksPerSecond);
        }
Пример #2
0
        public MainMenu()
        {
            //Increase the size so we can fit the character model into the menu
            var screenSize = GUCView.GetScreenSize();
            int width      = 900;
            int height     = 600;

            int posX = (screenSize.X - width) / 2;
            int posY = (screenSize.Y - height) / 2;


            Back.SetPos(posX, posY);
            Back.SetSize(width, height);

            AddButton("Welt betreten", "Die Spielwelt mit dem gewählten Character betreten.", 50, () => JoinGameSelected?.Invoke(this));
            AddButton("Charakter wählen", "Wähle deinen Spielcharakter.", 100, () => CharacterSelectionSelected?.Invoke(this));
            AddButton("Charakter erstellen", "Erstelle einen Spielcharakter", 150, () => CharacterCreationSelected?.Invoke(this));
            AddButton("Logout", "Zurück zum Login Menü", 200, () => BackToLoginSelected?.Invoke(this));
            AddButton("Spiel verlassen", "Das Spiel schließen.", 250, () => ExitGameSelected?.Invoke(this));


            _Character = AddCharacter("", 400, 0, 533, 400);
            _Character.SetVisual("HUMANS.MDS");
            _Character.SetAdditionalVisuals(HumBodyMeshs.HUM_BODY_BABE0.ToString(), (int)HumBodyTexs.G1Hero, HumHeadMeshs.HUM_HEAD_BABE.ToString(), (int)HumHeadTexs.FaceBabe_B_RedLocks);
            _Character.Enabled = false;
            _Character.Hide();

            _CharacterNameText = Back.CreateText("PlayerName", 650, 475);
            _CharacterNameText.Hide();
        }
Пример #3
0
        public CharacterSelectionMenu()
        {
            Back.CreateTextCenterX("Charakterauswahl", 10);

            _CharacterButtons = new MainMenuButton[5];
            for (int i = 0; i < _CharacterButtons.Length; i++)
            {
                _CharacterButtons[i]         = AddButton("...", "", _DistanceBetweenButtons * (i + 1), OnActivate);
                _CharacterButtons[i].Enabled = false;
            }

            //Increase the size so we can fit the character model into the menu
            var screenSize = GUCView.GetScreenSize();
            int width      = 900;
            int height     = 600;

            int posX = (screenSize.X - width) / 2;
            int posY = (screenSize.Y - height) / 2;


            Back.SetPos(posX, posY);
            Back.SetSize(width, height);


            _CharacterDisplay = AddCharacter("", 400, 0, 533, 400);
            _CharacterDisplay.SetVisual("HUMANS.MDS");
            _CharacterDisplay.SetAdditionalVisuals(HumBodyMeshs.HUM_BODY_BABE0.ToString(), (int)HumBodyTexs.G1Hero, HumHeadMeshs.HUM_HEAD_BABE.ToString(), (int)HumHeadTexs.FaceBabe_B_RedLocks);
            _CharacterDisplay.Enabled = false;
            _CharacterDisplay.Hide();

            _CharacterNameText = Back.CreateText("PlayerName", 650, 475);
            _CharacterNameText.Hide();

            CursorChanged += OnCursorChanged;
        }
Пример #4
0
        protected static void DoVictoryStuff(bool win, string winText = "SIEG!", string lossText = "NIEDERLAGE!")
        {
            if (VictoryVis == null)
            {
                const int boxWidth  = 260;
                const int boxHeight = 45;
                const int boxOffset = 100;
                var       ssize     = GUCView.GetScreenSize();
                var       vis       = new GUCVisual((ssize.X - boxWidth) / 2, boxOffset, boxWidth, boxHeight);
                vis.Font = GUCView.Fonts.Menu;
                vis.SetBackTexture("menu_choice_back.tga");
                var txt = vis.CreateTextCenterX("", 7);
                txt.Show();
                VictoryVis = vis;
            }

            if (win)
            {
                VictoryVis.Texts[0].Text = winText;
                SoundHandler.PlaySound(VictoryWin);
            }
            else
            {
                VictoryVis.Texts[0].Text = lossText;
                SoundHandler.PlaySound(VictoryLoss);
            }
            VictoryVis.Show();
        }
Пример #5
0
        public ChatMenu(Chat chat)
        {
            _Chat = chat ?? throw new ArgumentNullException(nameof(chat));
            _Chat.ChatMessageReceived += (sender, args) => ReceiveServerMessage(args.Mode, args.Message);


            screenSize = GUCView.GetScreenSize();
            chatHeigth = screenSize.Y / 5;
            chatWidth  = screenSize.X - 350;

            chatBackground = new GUCVisual(0, 0, chatWidth, chatHeigth + 5);
            chatBackground.SetBackTexture("Dlg_Conversation.tga");

            const int space = 20;
            int       lines = chatHeigth / space;

            for (int i = 0; i < lines; i++)
            {
                chatBackground.CreateText("" + i, 20, 5 + i * space);
                chatBackground.Texts[i].Text = "";
            }

            textBox = new GUCTextBox(70, chatHeigth + 5, chatWidth - 90, false);
            prefix  = new GUCVisual(15, chatHeigth + 5, chatWidth, 20);
            prefix.CreateText("", 0, 0);

            chatInactivityTimer = new GUCTimer();
            chatInactivityTimer.SetCallback(() => { if (!textBox.Enabled)
                                                    {
                                                        chatBackground.Hide();
                                                    }
                                                    chatInactivityTimer.Stop(); });
            chatInactivityTimer.SetInterval(6 * TimeSpan.TicksPerSecond);
        }
Пример #6
0
        static GameClient()
        {
            Client = ScriptManager.Interface.CreateClient();

            // Init RakNet objects
            clientInterface = RakPeerInterface.GetInstance();
            clientInterface.SetOccasionalPing(true);

            socketDescriptor      = new SocketDescriptor();
            socketDescriptor.port = 0;

            if (clientInterface.Startup(1, socketDescriptor, 1) != StartupResult.RAKNET_STARTED)
            {
                Logger.LogError("RakNet failed to start!");
            }

            // Init debug info on screen
            var screenSize = GUCView.GetScreenSize();

            abortInfo = new GUCVisual((screenSize.Y - 300) / 2, 150, 300, 40);
            abortInfo.SetBackTexture("Menu_Choice_Back.tga");
            GUCVisualText visText = abortInfo.CreateText("Verbindung unterbrochen!");

            visText.SetColor(ColorRGBA.Red);

            devInfo = new GUCVisual();
            for (int pos = 0; pos < 0x2000; pos += devInfo.zView.FontY() + 5)
            {
                var t = devInfo.CreateText("", 0x2000, pos, true);
                t.Format = GUCVisualText.TextFormat.Right;
            }
            devInfo.Show();
        }
Пример #7
0
        protected MenuWithViewBlocker()
        {
            var screenSize = GUCView.GetScreenSize();

            _BackgroundTexture = new GUCVisual(0, 0, screenSize.X, screenSize.Y);
            _BackgroundTexture.SetBackTexture("StartScreen.tga");
            _BackgroundTexture.Font = GUCVisual.Fonts.Menu;
        }
Пример #8
0
        static MissionScreen()
        {
            countdown = new GUCVisual();
            countdown.CreateTextCenterX("", 200).Font = GUCView.Fonts.Menu;

            const int missionHeight = 300;
            const int missionWidth  = 300;

            mission = new GUCVisual(20, GUCView.GetScreenSize().Y - missionHeight - 50, missionWidth, missionHeight);
            mission.CreateText("", 25, 25).Font = GUCView.Fonts.Book;
            mission.SetBackTexture("Letters.tga");
        }
Пример #9
0
        public PlayerInventory()
        {
            // Create the player inventory relative to the screen size
            int x, y, cols, rows;
            var screenSize = GUCView.GetScreenSize();

            cols = 5;
            x    = screenSize.X - (GUCInventory.SlotSize * cols + screenSize.X / 25);
            y    = screenSize.Y / 7 + 15;
            rows = (screenSize.Y - GUCInventory.DescriptionBoxHeight - y) / GUCInventory.SlotSize;

            inv = new GUCInventory(x, y, cols, rows);
        }
Пример #10
0
        static TOInfoScreen()
        {
            vis      = new GUCVisual();
            vis.Font = GUCView.Fonts.Menu;

            const int yOffset = 60;
            var       text    = vis.CreateText("Team Objective", GUCView.GetScreenSize().X, yOffset);

            text.Format = GUCVisualText.TextFormat.Right;

            //toName = vis.CreateText("TO_NAME", GUCView.GetScreenSize().Width, yOffset + GUCView.FontsizeMenu);
            //toName.Format = GUCVisualText.TextFormat.Right;

            toTime        = vis.CreateText("TIME LEFT", GUCView.GetScreenSize().X, yOffset + 1 * GUCView.FontsizeMenu);
            toTime.Format = GUCVisualText.TextFormat.Right;
        }
Пример #11
0
        public static void AddText(string text, GUCView.Fonts font, ColorRGBA color, long duration = TextDuration)
        {
            if (string.IsNullOrWhiteSpace(text))
            {
                return;
            }

            if (vis.Texts.Count == 0)
            {
                vis.CreateTextCenterX("", 0);
            }

            int vFontSize = GUCView.PixelToVirtualY(GUCView.GetFontSize(font));

            // push up active texts
            for (int i = endTimes.Count - 1; i >= 0; i--)
            {
                if (i == vis.Texts.Count - 1)
                {
                    vis.CreateTextCenterX("", 0);
                }

                var newText = vis.Texts[i + 1];
                var curText = vis.Texts[i];

                newText.Font = curText.Font;
                newText.SetColor(curText.GetColor());
                newText.Text = curText.Text;
                newText.SetPosY(curText.VPos.Y - vFontSize, true);
            }

            // add new text
            var visText = vis.Texts[0];

            visText.Font = font;
            visText.SetColor(color);
            visText.Text = text;
            visText.SetPosY(0xB00 - vFontSize, true);

            endTimes.Insert(0, GameTime.Ticks + duration);

            if (endTimes.Count == 1)
            {
                vis.Show();
                GUCScripts.OnUpdate += Update;
            }
        }
Пример #12
0
        /// <summary>
        /// Shifts chat rows to create space for the new message and controls message length
        /// </summary>
        /// <param name="message"></param>
        public void AddMessage(ChatMode chatmode, string message)
        {
            Log.Logger.Log(chatmode);
            if (!this.textBox.Enabled)
            {
                chatBackground.Show();
                StartInactivityTimer();
            }

            // resort chat rows if necessary
            int maxScreenSize = chatWidth - 30;

            if (chatBackground.Texts[chatBackground.Texts.Count - 1].Text.Length > 0)
            {
                for (int i = 0; i < chatBackground.Texts.Count - 1; i++)
                {
                    chatBackground.Texts[i].Text = chatBackground.Texts[i + 1].Text;
                    chatBackground.Texts[i].SetColor(chatBackground.Texts[i + 1].GetColor());
                }
            }

            // split messages to multiple rows
            if (GUCView.StringPixelWidth(message) > maxScreenSize)
            {
                int    charCounter = 0;
                string newMessage  = "";
                foreach (char c in message)
                {
                    newMessage += c;
                    charCounter++;
                    if (!(GUCView.StringPixelWidth(newMessage) < maxScreenSize))
                    {
                        InsertMessage(openChatMode, newMessage);
                        // remains of the message
                        if (message.Length > charCounter)
                        {
                            AddMessage(chatmode, message.Substring(charCounter));
                        }
                        return;
                    }
                }
            }

            // set message in the correct place
            InsertMessage(chatmode, message);
        }
Пример #13
0
 public void UpdateSelectedTeam()
 {
     if (GameMode.IsActive && GameMode.ActiveMode is TDMMode)
     {
         int index = (int)PlayerInfo.HeroInfo.TeamID;
         if (index >= 0)
         {
             if (Cast.Try(items[index], out MainMenuButton button))
             {
                 arrow.SetPosY(button.VPos.Y + GUCView.PixelToVirtualY(5), true);
                 arrow.SetPosX(button.VPos.X - GUCView.PixelToVirtualX(25), true);
                 arrow.Show();
                 return;
             }
         }
     }
     arrow.Hide();
 }
Пример #14
0
        void UpdateBoardPositions()
        {
            var screenSize = GUCView.GetScreenSize();

            for (int i = 0; i < boardCount; i++)
            {
                ScoreBoard board;
                if (i >= boards.Count)
                {
                    board = new ScoreBoard();
                    boards.Add(board);
                }
                else
                {
                    board = boards[i];
                }
                board.SetPos((screenSize.X - ScoreBoard.Width * boardCount) / 2 + i * ScoreBoard.Width, ScoreBoard.YDistance);
            }
        }
Пример #15
0
        public GUCMainMenu()
        {
            var screenSize = GUCView.GetScreenSize();

            pos  = new int[] { (screenSize.X - 640) / 2, (screenSize.Y - 480) / 2 };
            Back = new GUCVisual(pos[0], pos[1], 640, 480);
            Back.SetBackTexture("Menu_Ingame.tga");
            Back.Font = GUCVisual.Fonts.Menu;

            helpVis            = GUCVisualText.Create("", 0, pos[1] + 455);
            helpText.CenteredX = true;

            scrollHelper = new KeyHoldHelper()
            {
                { () => MoveCursor(true), VirtualKeys.Up },
                { () => MoveCursor(false), VirtualKeys.Down },
                { () => MoveCursor(false), VirtualKeys.Tab },
            };
        }
Пример #16
0
 public void UpdateSelectedTeam()
 {
     if (TeamMode.ActiveTODef != null)
     {
         var team  = TeamMode.TeamDef;
         int index = TeamMode.ActiveTODef.Teams.IndexOf(team);
         if (team != null && index >= 0)
         {
             if (Cast.Try(items[index], out MainMenuButton button))
             {
                 arrow.SetPosY(button.VPos.Y + GUCView.PixelToVirtualY(5), true);
                 arrow.SetPosX(button.VPos.X - GUCView.PixelToVirtualX(25), true);
                 arrow.Show();
                 return;
             }
         }
     }
     arrow.Hide();
 }
Пример #17
0
        static PlayerList()
        {
            var screen = GUCView.GetScreenSize();

            int x = (screen.X - Width) / 2;
            int y = (screen.Y - Height) / 2;

            vis      = new GUCVisual(x, y - GUCView.FontsizeMenu, Width, Height + GUCView.FontsizeMenu);
            vis.Font = GUCView.Fonts.Menu;
            vis.CreateTextCenterX("Spielerliste", 0);

            listVis = new GUCVisual(x, y, Width, Height);
            vis.AddChild(listVis);

            listVis.SetBackTexture(BackTex);
            for (int offset = 20; offset < Height - GUCView.FontsizeDefault - 5; offset += GUCView.FontsizeDefault + 1)
            {
                listVis.CreateText("", 17, offset);
            }
        }
Пример #18
0
        public DropItemMenu()
        {
            const int backWidth  = 120;
            const int backHeight = 64;

            back = new GUCVisual((GUCView.GetScreenSize().X - backWidth) / 2, (GUCView.GetScreenSize().Y - backHeight) / 2, backWidth, backHeight);
            back.SetBackTexture("Inv_Back.tga");

            const int borderWidth  = 80;
            const int borderHeight = 24;

            border = (GUCVisual)back.AddChild(new GUCVisual((GUCView.GetScreenSize().X - borderWidth) / 2, (GUCView.GetScreenSize().Y - borderHeight) / 2, borderWidth, borderHeight));
            border.SetBackTexture("Inv_Titel.tga");

            const int tbWidth = borderWidth - 20;

            tb             = (GUCTextBox)border.AddChild(new GUCTextBox((GUCView.GetScreenSize().X - tbWidth) / 2, (GUCView.GetScreenSize().Y - GUCView.FontsizeDefault) / 2, tbWidth, true));
            tb.OnlyNumbers = true;

            player = ScriptClient.Client.Character;
        }
Пример #19
0
        static bool ShowConnectionAttempts()
        {
            if (GameClient.IsDisconnected)
            {
                return(true);
            }

            if (!GameClient.IsConnected)
            {
                if (!GameClient.IsConnecting)
                {
                    GameClient.Connect();
                }

                if (connectionVis == null)
                {
                    connectionVis = new GUCVisual();
                    connectionVis.SetBackTexture("MENU_CHOICE_BACK.TGA");
                    var text = connectionVis.CreateText("");
                }
                var screenSize = GUCView.GetScreenSize();
                connectionVis.SetPosX(screenSize.X / 2 - 200);
                connectionVis.SetPosY(200);
                connectionVis.SetHeight(40);
                connectionVis.SetWidth(400);
                connectionVis.Texts[0].Text = string.Format("Connecting to '{0}:{1}' ... ({2})", Program.ServerIP, Program.ServerPort, GameClient.ConnectionAttempts);
                connectionVis.Show();
                return(true);
            }

            if (connectionVis != null)
            {
                connectionVis.Hide();
            }
            return(!GameClient.IsConnected);
        }
Пример #20
0
        protected override void OnCreate()
        {
            base.OnCreate();
            var screenSize = GUCView.GetScreenSize();

            Back.SetPos((screenSize.X - 900) / 2, (screenSize.Y - 480) / 2);
            Back.SetSize(900, 480);

            Back.CreateTextCenterX("Login", 100);

            _TbName = AddTextBox("Accountname:", "Name deines Accounts eingeben.", 200, 200, OnActivate);


            _TbPw = AddTextBox("Passwort:", "Passwort deines Accounts eingeben.", 250, 200, OnActivate, true);

            _TbPw2 = AddTextBox("Passwort wdh.:", "Passwort deines Accounts wiederholen.", 300, 200, OnActivate, true);

            AddButton("erstellen", "Die Erstellung des Accounts ausführen", 350, OnActivate);

            AddButton("Zurück", "Die Erstellung des Accounts abbrechen", 400, () => ChancelSelected?.Invoke(this));

            _LbErrorText = Back.CreateTextCenterX("", 400);
            _LbErrorText.SetColor(ColorRGBA.Red);
        }
Пример #21
0
 static RespawnNote()
 {
     textVis      = new GUCVisual().CreateTextCenterX("Warte auf Respawn...", GUCView.GetScreenSize().Y - 100);
     textVis.Font = GUCView.Fonts.Menu;
 }