Exemplo n.º 1
0
        static void DrawSkippingWindow()
        {
            if (Multiplayer.Client == null || TickPatch.skipTo < 0)
            {
                return;
            }

            string text        = $"{"MpSimulating".Translate()}{MpUtil.FixedEllipsis()}";
            float  textWidth   = Text.CalcSize(text).x;
            float  windowWidth = Math.Max(240f, textWidth + 40f);
            Rect   rect        = new Rect(0, 0, windowWidth, 75f).CenterOn(new Rect(0, 0, UI.screenWidth, UI.screenHeight));

            if (Multiplayer.IsReplay && !TickPatch.disableSkipCancel && Event.current.type == EventType.KeyUp && Event.current.keyCode == KeyCode.Escape)
            {
                TickPatch.ClearSkipping();
                Event.current.Use();
            }

            Find.WindowStack.ImmediateWindow(SkippingWindowId, rect, WindowLayer.Super, () =>
            {
                Text.Anchor = TextAnchor.MiddleCenter;
                Text.Font   = GameFont.Small;
                Widgets.Label(rect.AtZero(), text);
                Text.Anchor = TextAnchor.UpperLeft;
            }, absorbInputAroundWindow: true);
        }
Exemplo n.º 2
0
        public override void DoWindowContents(Rect inRect)
        {
            string label = IsConnecting ? (ConnectingString + MpUtil.FixedEllipsis()) : result;

            if (Multiplayer.Client?.StateObj is ClientJoiningState joining && joining.state == JoiningState.Downloading)
            {
                label = $"MpDownloading".Translate(Multiplayer.Client.FragmentProgress);
            }

            const float buttonHeight = 40f;
            const float buttonWidth  = 120f;

            Rect textRect = inRect;

            textRect.yMax -= (buttonHeight + 10f);
            Text.Anchor    = TextAnchor.MiddleCenter;

            Widgets.Label(textRect, label);
            Text.Anchor = TextAnchor.UpperLeft;

            Rect buttonRect = new Rect((inRect.width - buttonWidth) / 2f, inRect.height - buttonHeight - 10f, buttonWidth, buttonHeight);

            if (Widgets.ButtonText(buttonRect, "CancelButton".Translate(), true, false, true))
            {
                Close();
            }
        }
        static void DrawSkippingWindow()
        {
            if (Multiplayer.Client == null || !TickPatch.Skipping)
            {
                return;
            }

            string text         = $"{TickPatch.skippingTextKey.Translate()}{MpUtil.FixedEllipsis()}";
            float  textWidth    = Text.CalcSize(text).x;
            float  windowWidth  = Math.Max(240f, textWidth + 40f);
            float  windowHeight = TickPatch.cancelSkip != null ? 100f : 75f;
            Rect   rect         = new Rect(0, 0, windowWidth, windowHeight).CenterOn(new Rect(0, 0, UI.screenWidth, UI.screenHeight));

            if (TickPatch.canESCSkip && Event.current.type == EventType.KeyUp && Event.current.keyCode == KeyCode.Escape)
            {
                TickPatch.ClearSkipping();
                Event.current.Use();
            }

            Find.WindowStack.ImmediateWindow(SkippingWindowId, rect, WindowLayer.Super, () =>
            {
                var textRect = rect.AtZero();
                if (TickPatch.cancelSkip != null)
                {
                    textRect.yMin   += 5f;
                    textRect.height -= 50f;
                }

                Text.Anchor = TextAnchor.MiddleCenter;
                Text.Font   = GameFont.Small;
                Widgets.Label(textRect, text);
                Text.Anchor = TextAnchor.UpperLeft;

                if (TickPatch.cancelSkip != null && Widgets.ButtonText(new Rect(0, textRect.yMax, 100f, 35f).CenteredOnXIn(textRect), TickPatch.skipCancelButtonKey.Translate()))
                {
                    TickPatch.cancelSkip();
                }
            }, absorbInputAroundWindow: true);
        }
Exemplo n.º 4
0
        public override void DoWindowContents(Rect inRect)
        {
            string label = Ellipsis ? (ConnectingString + MpUtil.FixedEllipsis()) : result;

            const float buttonHeight = 40f;
            const float buttonWidth  = 120f;

            Rect textRect = inRect;

            textRect.yMax -= (buttonHeight + 10f);
            float textWidth = Text.CalcSize(label).x;

            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(textRect, label);
            Text.Anchor = TextAnchor.UpperLeft;

            Rect buttonRect = new Rect((inRect.width - buttonWidth) / 2f, inRect.height - buttonHeight - 10f, buttonWidth, buttonHeight);

            if (Widgets.ButtonText(buttonRect, "CancelButton".Translate(), true, false, true))
            {
                Close();
            }
        }
Exemplo n.º 5
0
        private void DrawLan(Rect inRect)
        {
            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(new Rect(inRect.x, 8f, inRect.width, 40), "MpLanSearching".Translate() + MpUtil.FixedEllipsis());
            Text.Anchor  = TextAnchor.UpperLeft;
            inRect.yMin += 40f;

            float margin  = 100;
            Rect  outRect = new Rect(margin, inRect.yMin + 10, inRect.width - 2 * margin, inRect.height - 20);

            float height   = servers.Count * 40;
            Rect  viewRect = new Rect(0, 0, outRect.width - 16f, height);

            Widgets.BeginScrollView(outRect, ref lanScroll, viewRect, true);

            float y = 0;
            int   i = 0;

            foreach (LanServer server in servers)
            {
                Rect entryRect = new Rect(0, y, viewRect.width, 40);
                if (i % 2 == 0)
                {
                    Widgets.DrawAltRect(entryRect);
                }

                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(entryRect.Right(5), "" + server.endpoint);

                Text.Anchor = TextAnchor.MiddleCenter;
                Rect playButton = new Rect(entryRect.xMax - 75, entryRect.y + 5, 70, 40 - 10);
                if (Widgets.ButtonText(playButton, ">>"))
                {
                    Close(false);
                    Log.Message("Connecting to lan server");
                    Find.WindowStack.Add(new ConnectingWindow(server.endpoint.Address, server.endpoint.Port)
                    {
                        returnToServerBrowser = true
                    });
                }

                Text.Anchor = TextAnchor.UpperLeft;

                y += entryRect.height;
                i++;
            }

            Widgets.EndScrollView();
        }