예제 #1
0
        private void onLevelRender(On.Celeste.Level.orig_Render orig, Level self)
        {
            if (Input.Aim == null || Input.GliderMoveY == null || Input.MoveY == null)
            {
                orig(self);
                return;
            }

            // the upside down variant is the only way to have vertical controls inverted.
            Input.Aim.InvertedY = false;

            // there may be another mod (or the Upside Down variant :p) here. if so, it will mess with Input.Aim.InvertedY
            orig(self);

            // at this point, Input.Aim.InvertedY is either the vanilla value, or what some other mod wants.
            // either way, we should keep it or invert it based on our settings.

            bool expectedValue = Input.Aim.InvertedY;

            if (Settings.InvertVerticalControls)
            {
                expectedValue = !expectedValue;
            }

            Input.Aim.InvertedY        = expectedValue;
            Input.MoveY.Inverted       = expectedValue;
            Input.GliderMoveY.Inverted = expectedValue;
        }
        private static void LevelOnRender(On.Celeste.Level.orig_Render orig, Level self)
        {
            orig(self);

            DrawInfo(self);
            InfoMouse.ToggleAndDrag();
        }
예제 #3
0
        private static void LevelOnRender(On.Celeste.Level.orig_Render orig, Level self)
        {
            orig(self);

            if (FrameStep)
            {
                Audio.CurrentAmbienceEventInstance?.setVolume(0);

                if (LoopAudioInstances.Count > 0)
                {
                    WeakReference <EventInstance>[] copy = LoopAudioInstances.Keys.ToArray();
                    foreach (WeakReference <EventInstance> loopAudioInstance in copy)
                    {
                        if (loopAudioInstance.TryGetTarget(out EventInstance eventInstance))
                        {
                            if (LoopAudioInstances[loopAudioInstance] <= 0)
                            {
                                eventInstance.setVolume(0);
                                LoopAudioInstances.Remove(loopAudioInstance);
                            }
                            else
                            {
                                LoopAudioInstances[loopAudioInstance]--;
                            }
                        }
                        else
                        {
                            LoopAudioInstances.Remove(loopAudioInstance);
                        }
                    }
                }
            }
        }
예제 #4
0
        private static void LevelOnRender(On.Celeste.Level.orig_Render orig, Level self)
        {
            orig(self);
            if (!Settings.Enabled)
            {
                return;
            }

            Draw.SpriteBatch.Begin();

            int viewWidth  = Engine.ViewWidth;
            int viewHeight = Engine.ViewHeight;

            string  text = Variable.Parse(DisplayContent);
            Vector2 size = ActiveFont.Measure(text) * Settings.FontSize;

            float x;
            float y;

            switch (Settings.Position)
            {
            case Position.TopLeft:
                x = Settings.Margin;
                y = Settings.Margin;
                break;

            case Position.TopRight:
                x = viewWidth - size.X - Settings.Margin - Settings.Padding * 2;
                y = Settings.Margin;
                break;

            case Position.BottomLeft:
                x = Settings.Margin;
                y = viewHeight - size.Y - Settings.Margin - Settings.Padding * 2;
                break;

            case Position.BottomRight:
                x = viewWidth - size.X - Settings.Margin - Settings.Padding * 2;
                y = viewHeight - size.Y - Settings.Margin - Settings.Padding * 2;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            Vector2 rectPosition = new Vector2(x, y);

            Draw.Rect(rectPosition, size.X + Settings.Padding * 2, size.Y + Settings.Padding * 2, Color.Black * Settings.BackgroundAlpha);

            Vector2 textPosition = new Vector2(x + Settings.Padding, y + Settings.Padding);
            Vector2 scale        = new Vector2(Settings.FontSize);

            ActiveFont.Draw(text, textPosition, Vector2.Zero, scale, Color.White * Settings.FontAlpha);

            Draw.SpriteBatch.End();
        }
예제 #5
0
 private static void LevelOnRender(On.Celeste.Level.orig_Render orig, Level self)
 {
     CenterTheCamera(() => orig(self));
 }
예제 #6
0
        private static void LevelOnRender(On.Celeste.Level.orig_Render orig, Level self)
        {
            orig(self);

            if (!ModSettings.Enabled || ModSettings.InfoHud == InfoPositions.Off)
            {
                return;
            }

            int viewWidth  = Engine.ViewWidth;
            int viewHeight = Engine.ViewHeight;

            float pixelScale = viewWidth / 320f;
            float margin     = 2 * pixelScale;
            float padding    = 2 * pixelScale;
            float fontSize   = 0.15f * pixelScale;
            float alpha      = 1f;

            StringBuilder     stringBuilder = new StringBuilder();
            InputController   controller    = Manager.Controller;
            List <InputFrame> inputs        = controller.Inputs;

            if (Manager.Running && controller.CurrentFrame >= 0 && controller.CurrentFrame < inputs.Count)
            {
                InputFrame previous = null;
                InputFrame next     = null;

                InputFrame current = controller.Current;
                if (controller.CurrentFrame >= 1 && current != controller.Previous)
                {
                    current = controller.Previous;
                }

                int currentIndex = inputs.IndexOf(current);
                if (currentIndex >= 1)
                {
                    previous = inputs[currentIndex - 1];
                }

                currentIndex = inputs.LastIndexOf(current);
                if (currentIndex < inputs.Count - 1)
                {
                    next = inputs[currentIndex + 1];
                }

                int maxLine     = Math.Max(current.Line, Math.Max(previous?.Line ?? 0, next?.Line ?? 0)) + 1;
                int linePadLeft = maxLine.ToString().Length;

                int maxFrames     = Math.Max(current.Frames, Math.Max(previous?.Frames ?? 0, next?.Frames ?? 0));
                int framesPadLeft = maxFrames.ToString().Length;

                if (previous != null)
                {
                    stringBuilder.Append(
                        $"{(previous.Line + 1).ToString().PadLeft(linePadLeft)}: {string.Empty.PadLeft(framesPadLeft - previous.Frames.ToString().Length)}{previous}\n");
                }

                string currentStr =
                    $"{(current.Line + 1).ToString().PadLeft(linePadLeft)}: {string.Empty.PadLeft(framesPadLeft - current.Frames.ToString().Length)}{current}";
                int maxWidth = currentStr.ToString().Length + controller.StudioFrameCount.ToString().Length + 1;
                maxWidth = Manager.PlayerStatus.Split('\n').Select(s => s.Length).Concat(new[] { maxWidth }).Max();
                stringBuilder.Append(
                    $"{currentStr.PadRight(maxWidth - controller.StudioFrameCount.ToString().Length - 1)}{controller.StudioFrameCount}\n");
                if (next != null)
                {
                    stringBuilder.Append(
                        $"{(next.Line + 1).ToString().PadLeft(linePadLeft)}: {string.Empty.PadLeft(framesPadLeft - next.Frames.ToString().Length)}{next}\n");
                }

                stringBuilder.AppendLine();
            }

            stringBuilder.Append(Manager.PlayerStatus);

            string text = stringBuilder.ToString();

            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            Vector2 size = JetBrainsMono.Measure(text) * fontSize;

            float x;
            float y;

            switch (ModSettings.InfoHud)
            {
            case InfoPositions.TopLeft:
                x = margin;
                y = margin;
                if (Settings.Instance.SpeedrunClock == SpeedrunType.Chapter)
                {
                    y += 16 * pixelScale;
                }
                else if (Settings.Instance.SpeedrunClock == SpeedrunType.File)
                {
                    y += 20 * pixelScale;
                }

                break;

            case InfoPositions.TopRight:
                x = viewWidth - size.X - margin - padding * 2;
                y = margin;
                break;

            case InfoPositions.BottomLeft:
                x = margin;
                y = viewHeight - size.Y - margin - padding * 2;
                break;

            case InfoPositions.BottomRight:
                x = viewWidth - size.X - margin - padding * 2;
                y = viewHeight - size.Y - margin - padding * 2;
                break;

            case InfoPositions.Off:
                throw new ArgumentException();

            default:
                throw new ArgumentOutOfRangeException();
            }

            Rectangle bgRect = new Rectangle((int)x, (int)y, (int)(size.X + padding * 2), (int)(size.Y + padding * 2));

            if (self.Entities.FindFirst <Player>() is Player player)
            {
                Vector2   playerPosition = self.Camera.CameraToScreen(player.TopLeft) * pixelScale;
                Rectangle playerRect     = new Rectangle((int)playerPosition.X, (int)playerPosition.Y, (int)(8 * pixelScale), (int)(11 * pixelScale));
                Rectangle mirrorBgRect   = bgRect;
                if (SaveData.Instance?.Assists.MirrorMode == true)
                {
                    mirrorBgRect.X = (int)Math.Abs(x - viewWidth + size.X + padding * 2);
                }

                if (self.Paused || playerRect.Intersects(mirrorBgRect))
                {
                    alpha = 0.5f;
                }
            }

            Draw.SpriteBatch.Begin();

            Draw.Rect(bgRect, Color.Black * 0.8f * alpha);

            Vector2 textPosition = new Vector2(x + padding, y + padding);
            Vector2 scale        = new Vector2(fontSize);

            JetBrainsMono.Draw(text, textPosition, Vector2.Zero, scale, Color.White * alpha);

            Draw.SpriteBatch.End();
        }
예제 #7
0
        private void LevelOnRender(On.Celeste.Level.orig_Render orig, Level self)
        {
            orig(self);

            if (ModuleSettings.Mode == GhostModuleMode.Play && ModuleSettings.ShowCompareTime)
            {
                int viewWidth  = Engine.ViewWidth;
                int viewHeight = Engine.ViewHeight;

                float pixelScale = viewWidth / 320f;
                float margin     = 2 * pixelScale;
                float padding    = 2 * pixelScale;
                float fontSize   = 0.3f * pixelScale;
                float alpha      = 1f;

                if (ghostTime == 0)
                {
                    return;
                }

                long   diffRoomTime     = currentTime - ghostTime - lastCurrentTime + lastGhostTime;
                long   diffTotalTime    = currentTime - ghostTime;
                string diffRoomTimeStr  = (diffRoomTime > 0 ? "+" : string.Empty) + (diffRoomTime / 10000000D).ToString("0.000");
                string diffTotalTimeStr = (diffTotalTime > 0 ? "+" : string.Empty) + (diffTotalTime / 10000000D).ToString("0.000");
                string timeStr          = $"last room: {diffRoomTimeStr}\ntotal    : {diffTotalTimeStr}";

                if (string.IsNullOrEmpty(timeStr))
                {
                    return;
                }

                Vector2 size = Draw.DefaultFont.MeasureString(timeStr) * fontSize;

                float x;
                float y;

                x = margin;
                y = margin;

                if (Settings.Instance.SpeedrunClock == SpeedrunType.Chapter)
                {
                    y += 16 * pixelScale;
                }
                else if (Settings.Instance.SpeedrunClock == SpeedrunType.File)
                {
                    y += 20 * pixelScale;
                }

                Rectangle bgRect = new Rectangle((int)x, (int)y, (int)(size.X + padding * 2), (int)(size.Y + padding * 2));

                if (self.Entities.FindFirst <Player>() is Player player)
                {
                    Vector2   playerPosition = self.Camera.CameraToScreen(player.TopLeft) * pixelScale;
                    Rectangle playerRect     = new Rectangle((int)playerPosition.X, (int)playerPosition.Y, (int)(8 * pixelScale), (int)(11 * pixelScale));
                    Rectangle mirrorBgRect   = bgRect;
                    if (SaveData.Instance?.Assists.MirrorMode == true)
                    {
                        mirrorBgRect.X = (int)Math.Abs(x - viewWidth + size.X + padding * 2);
                    }

                    if (self.Paused || playerRect.Intersects(mirrorBgRect))
                    {
                        alpha = 0.5f;
                    }
                }

                Draw.SpriteBatch.Begin();

                Draw.Rect(bgRect, Color.Black * 0.8f * alpha);

                Vector2 textPosition = new Vector2(x + padding, y + padding);
                Vector2 scale        = new Vector2(fontSize);

                Draw.Text(Draw.DefaultFont, timeStr, textPosition, Color.White * alpha, Vector2.Zero, scale, 0f);

                Draw.SpriteBatch.End();
            }
        }