コード例 #1
0
 public void ToggleBackground()
 {
     if (chatBackground.Shown)
     {
         chatBackground.Hide();
     }
     else
     {
         chatBackground.Show();
     }
 }
コード例 #2
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();
        }
コード例 #3
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();
        }
コード例 #4
0
        public override void Open()
        {
            CloseActiveMenus(); //main menus never overlap

            if (!init)
            {   //create items on first opening, otherwise pointers to 'Open()-Methods' of other menus, which are yet not constructed, will be used => crash
                //could also be solved with static Open()-Methods
                OnCreate();
                init = true;
            }

            base.Open();
            Back.Show();
            helpVis.Show();
            for (int i = 0; i < items.Count; i++)
            {
                items[i].Show();
            }

            cursor      = preferredCursorItem;
            CurrentItem = items[cursor];

            if (!CurrentItem.Enabled)
            {
                sndEnabled = false; //sound would be played on opening
                MoveCursor();
                sndEnabled = true;
            }
            CurrentItem.Select();
            UpdateHelpText();

            isOpen = true;
        }
コード例 #5
0
        void SelectSlot()
        {
            slots[cursor.X, cursor.Y].IsSelected = true;

            ItemInst selItem = GetSelectedItem();

            if (selItem == null)
            {
                descrBack.Hide();
                descrVis.Hide();
            }
            else
            {
                List <GUCVisualText> texts = descrBack.Texts;
                var def = selItem.Definition;

                //set description name
                texts[0].Text = def.Name;

                if (def.Damage != 0)
                {
                    texts[3].Text = "Schaden";
                    texts[4].Text = def.Damage.ToString();
                }
                else
                {
                    texts[3].Text = texts[4].Text = "";
                }

                if (def.Range != 0)
                {
                    texts[5].Text = "Reichweite";
                    texts[6].Text = def.Range.ToString();
                }
                else
                {
                    texts[5].Text = texts[6].Text = "";
                }

                if (def.Protection != 0)
                {
                    texts[7].Text = "Schutz vor Waffen";
                    texts[8].Text = def.Protection.ToString();
                }
                else
                {
                    texts[7].Text = texts[8].Text = "";
                }

                //visual vob
                descrVis.SetVisual(selItem.ModelDef.Visual);

                //show description
                def.PositionInVobVisual(descrVis);

                descrBack.Show();
                descrVis.Show();
            }
        }
コード例 #6
0
 public override void Open()
 {
     back.Show();
     border.Show();
     tb.Show();
     tb.Enabled = true;
     base.Open();
 }
コード例 #7
0
 public override void Show()
 {
     back.Show();
     if (item != null)
     {
         vis.Show();
         UpdateSlotAmount();
     }
     shown = true;
 }
コード例 #8
0
 public override void Open()
 {
     textBox.Enabled = true;
     textBox.Show();
     prefix.Show();
     if (!chatBackground.Shown)
     {
         chatBackground.Show();
     }
     base.Open();
 }
コード例 #9
0
 public static void TogglePlayerList()
 {
     if (vis.Shown)
     {
         vis.Hide();
         PlayerInfo.OnPlayerListChange -= UpdateList;
     }
     else
     {
         vis.Show();
         UpdateList();
         PlayerInfo.OnPlayerListChange += UpdateList;
     }
 }
コード例 #10
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;
            }
        }
コード例 #11
0
        static void Update(long now)
        {
            if (TeamMode.ActiveTODef == null)
            {
                vis.Hide();
                return;
            }

            if (!vis.Shown)
            {
                vis.Show();
            }

            long timeLeft = TeamMode.PhaseEndTime - now;

            if (timeLeft < 0)
            {
                timeLeft = 0;
            }
            long mins = timeLeft / TimeSpan.TicksPerMinute;
            long secs = timeLeft % TimeSpan.TicksPerMinute / TimeSpan.TicksPerSecond;

            string phase;

            switch (TeamMode.Phase)
            {
            case TOPhases.Battle:
                phase = "Kampf läuft.";
                break;

            case TOPhases.Warmup:
                phase = "Startet in";
                break;

            case TOPhases.Finish:
                phase = "Ende";
                break;

            default:
                phase = TeamMode.Phase.ToString();
                break;
            }

            toTime.Text = string.Format("{0} {1}:{2:00}", phase, mins, secs);
        }
コード例 #12
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();
 }
コード例 #13
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();
 }
コード例 #14
0
        public static void Show(string missionText = null)
        {
            if (shown)
            {
                return;
            }
            shown = true;

            Update(GameTime.Ticks);
            GUCScripts.OnUpdate += Update;


            countdown.Show();
            if (!string.IsNullOrWhiteSpace(missionText))
            {
                mission.Texts[0].Text = missionText;
                mission.Show();
            }
        }
コード例 #15
0
        public override void Show()
        {
            foreach (Slot slot in slots)
            {
                slot.Show();
            }

            if (RightInfoBox != null && RightInfoBox.Length > 0)
            {
                rightBack.Show();
                rightVis.Show();
            }

            if (LeftInfoBox != null && LeftInfoBox.Length > 0)
            {
                leftBack.Show();
                leftVis.Show();
            }
        }
コード例 #16
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);
        }
コード例 #17
0
 public override void Open()
 {
     _BackgroundTexture?.Show();
     base.Open();
 }
コード例 #18
0
 public override void Select()
 {
     leftArrow.Show();
     rightArrow.Show();
     _ZoomText.Show();
 }
コード例 #19
0
        internal static void Update()
        {
            int            counter = 0;
            ServerMessages msgType;
            Packet         packet;

            // Receive packets
            while ((packet = clientInterface.Receive()) != null)
            {
                try
                {
                    receivedBytes += packet.length;

                    packetReader.Load(packet.data, (int)packet.length);
                    msgType = (ServerMessages)packetReader.ReadByte();
                    ReadMessage(msgType, packetReader);

                    counter++;
                    if (counter >= 1000)
                    {
                        counter = 0;
                        Logger.Log("1000 Pakete hintereinander");
                    }
                }
                catch (Exception e)
                {
                    if (packet.length >= 1)
                    {
                        Logger.LogError("{0}: {1}: {2}\n{3}", (ServerMessages)packet.data[0], e.Source, e.Message, e.StackTrace);
                    }
                    else
                    {
                        Logger.LogError("{0}: {1}\n{2}", e.Source, e.Message, e.StackTrace);
                    }
                }
                finally
                {
                    clientInterface.DeallocatePacket(packet);
                }
            }

            #region Debug Info

            // update only every second
            if (infoTimer.IsReady)
            {
                int ping = clientInterface.GetLastPing(clientInterface.GetSystemAddressFromIndex(0));

                if (isDisconnected)
                {
                    abortInfo.Texts[0].Text = "Verbindung geschlossen!";
                    abortInfo.Show();
                }
                else if (isConnected)
                {
                    if (ping > 300 || ping < 0)
                    {
                        abortInfo.Show();
                    }
                    else
                    {
                        abortInfo.Hide();
                    }
                }

                // update ping text on screen
                int           devIndex = 0;
                GUCVisualText pingText = devInfo.Texts[devIndex++];
                pingText.Text = string.Format("Ping: {0}ms", ping);
                ColorRGBA color;
                if (ping <= 120)
                {
                    color = new ColorRGBA((byte)(40 + 180 * ping / 120), 220, 40);
                }
                else if (ping <= 220)
                {
                    color = new ColorRGBA(220, (byte)(220 - 180 * (ping - 100) / 120), 40);
                }
                else
                {
                    color = new ColorRGBA(220, 40, 40);
                }
                pingText.SetColor(color);

                long          fps     = Hooks.hGame.LastElapsedTicks > 0 ? TimeSpan.TicksPerSecond / Hooks.hGame.LastElapsedTicks : 999;
                GUCVisualText fpsText = devInfo.Texts[devIndex++];
                fpsText.Text = "FPS: " + fps;
                if (fps < 10)
                {
                    color = new ColorRGBA(220, 40, 40);
                }
                else if (fps < 40)
                {
                    color = new ColorRGBA(220, (byte)(40 + 180 * (fps - 10) / 30), 40);
                }
                else if (fps < 90)
                {
                    color = new ColorRGBA((byte)(220 - 180 * (fps - 40) / 50), 220, 40);
                }
                else
                {
                    color = new ColorRGBA(40, 220, 40);
                }
                fpsText.SetColor(color);

                devInfo.Texts[devIndex++].Text = "Spike: " + Hooks.hGame.SpikeLongest / TimeSpan.TicksPerMillisecond + "ms";

                // update kB/s text on screen
                int kbs = (int)(receivedBytes);
                devInfo.Texts[devIndex++].Text = ("Net received: " + kbs + "B/s");
                kbs = (int)(sentBytes);
                devInfo.Texts[devIndex++].Text = ("Net Sent: " + kbs + "B/s");
                receivedBytes = 0;
                sentBytes     = 0;

                if (World.Current != null)
                {
                    devIndex = 8;
                    devInfo.Texts[devIndex++].Text = World.Current.VobCount + " Vobs";
                    devInfo.Texts[devIndex++].Text = Client.guidedIDs.Count + " guided";

                    devInfo.Texts[devIndex++].Text = "Weather: " + World.Current.WeatherCtrl.CurrentWeight + " " + World.Current.Clock.Time.ToString(false);
                    devInfo.Texts[devIndex++].Text = "Barrier: " + World.Current.BarrierCtrl.CurrentWeight + " " + World.Current.BarrierCtrl.EndWeight;

                    devInfo.Texts[devIndex++].Text = "VobSounds: " + SoundHandler.VobSoundCount;
                    devInfo.Texts[devIndex++].Text = "PosSounds: " + SoundHandler.PosSoundCount;

                    //if (NPC.Hero != null)
                    //    devInfo.Texts[devIndex++].Text =  NPC.Hero.Movement.ToString();
                }
            }

            #endregion
        }
コード例 #20
0
 public override void Show()
 {
     vis.Show();
 }
コード例 #21
0
 void StartCountdown()
 {
     GUCScripts.OnUpdate += UpdateCountdown;
     countdown.Show();
 }
コード例 #22
0
 public override void Show()
 {
     titleVis.Show();
 }