예제 #1
0
        private void Render(On.Celeste.SpeedrunTimerDisplay.orig_Render orig, SpeedrunTimerDisplay self)
        {
            SpeedrunToolSettings settings = SpeedrunToolModule.Settings;

            if (!settings.Enabled || settings.RoomTimerType == RoomTimerType.Off || self.DrawLerp <= 0f)
            {
                orig(self);
                return;
            }

            RoomTimerType roomTimeType  = SpeedrunToolModule.Settings.RoomTimerType;
            RoomTimerData roomTimerData = roomTimeType == RoomTimerType.NextRoom ? nextRoomTimerData : currentRoomTimerData;

            string roomTimeString = roomTimerData.TimeString;
            string pbTimeString   = roomTimerData.PbTimeString;

            pbTimeString = "PB " + pbTimeString;

            const float topBlackBarWidth = 32f;
            const float topTimeHeight    = 38f;
            const float pbWidth          = 100;
            const float timeMarginLeft   = 32f;
            const float pbScale          = 0.6f;

            MTexture bg = GFX.Gui["strawberryCountBG"];
            float    x  = -300f * Ease.CubeIn(1f - self.DrawLerp);

            Draw.Rect(x, self.Y, topBlackBarWidth + 2, topTimeHeight, Color.Black);
            bg.Draw(new Vector2(x + topBlackBarWidth, self.Y));

            float roomTimeScale = 1f;

            if (roomTimerData.IsCompleted)
            {
                Wiggler wiggler = (Wiggler)self.GetFieldValue("wiggler");
                if (wiggler != null)
                {
                    roomTimeScale = 1f + wiggler.Value * 0.15f;
                }
            }

            SpeedrunTimerDisplay.DrawTime(new Vector2(x + timeMarginLeft, self.Y + 44f), roomTimeString, roomTimeScale,
                                          true,
                                          roomTimerData.IsCompleted, roomTimerData.BeatBestTime);

            if (roomTimerData.IsCompleted)
            {
                string comparePbString = ComparePb(roomTimerData.Time, roomTimerData.LastPbTime);
                DrawTime(
                    new Vector2(x + timeMarginLeft + SpeedrunTimerDisplay.GetTimeWidth(roomTimeString) + 10,
                                self.Y + 36f),
                    comparePbString, 0.5f,
                    roomTimerData.IsCompleted, roomTimerData.BeatBestTime);
            }

            // 遮住上下两块的间隙,游戏原本的问题
            Draw.Rect(x, self.Y + topTimeHeight - 1, pbWidth + bg.Width * pbScale, 1f, Color.Black);

            Draw.Rect(x, self.Y + topTimeHeight, pbWidth + 2, bg.Height * pbScale + 1f, Color.Black);
            bg.Draw(new Vector2(x + pbWidth, self.Y + topTimeHeight), Vector2.Zero, Color.White, pbScale);
            DrawTime(new Vector2(x + timeMarginLeft, (float)(self.Y + 66.4)), pbTimeString, pbScale, false, false, 0.6f);
        }