Skip to content

Commit

Permalink
Use viewport instead of window size when rendering console lines
Browse files Browse the repository at this point in the history
  • Loading branch information
WEGFan committed Oct 16, 2021
1 parent fa53631 commit 596dda4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Celeste.Mod.mm/Patches/Monocle/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ internal void Render() {
}

if (drawCommands.Count > 0) {
int drawCount = Math.Min((Engine.Instance.Window.ClientBounds.Height - 100) / 30, drawCommands.Count - firstLineIndexToDraw);
int drawCount = Math.Min((viewHeight - 100) / 30, drawCommands.Count - firstLineIndexToDraw);
float height = 10f + 30f * drawCount;
Draw.Rect(10f, viewHeight - height - 60f, viewWidth - 20f, height, Color.Black * 0.8f);
for (int i = 0; i < drawCount && firstLineIndexToDraw + i < drawCommands.Count; i++) {
Expand Down Expand Up @@ -417,7 +417,7 @@ public void ReloadCommandsList() {
}
return;
}
int width = Engine.Instance.Window.ClientBounds.Width - 40;
int width = Engine.ViewWidth - 40;
while (Draw.DefaultFont.MeasureString(text).X > width) {
int index = -1;
for (int i = 0; i < text.Length; i++) {
Expand All @@ -435,7 +435,7 @@ public void ReloadCommandsList() {
text = text.Substring(index + 1);
}
drawCommands.Insert(0, new patch_Line(text, color));
int maxCommandLines = Math.Max(CoreModule.Settings.ExtraCommandHistoryLines + (Engine.Instance.Window.ClientBounds.Height - 100) / 30, 0);
int maxCommandLines = Math.Max(CoreModule.Settings.ExtraCommandHistoryLines + (Engine.ViewHeight - 100) / 30, 0);
firstLineIndexToDraw = Calc.Clamp(firstLineIndexToDraw, 0, Math.Max(drawCommands.Count - 1, 0));
while (drawCommands.Count > maxCommandLines) {
drawCommands.RemoveAt(drawCommands.Count - 1);
Expand Down

0 comments on commit 596dda4

Please sign in to comment.