From e4dd7bf14b6990b92324baf61a21efc346d8a703 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 8 Feb 2022 01:57:40 -0500 Subject: [PATCH] Reduced texture bindings with chat open --- core/src/mindustry/editor/MapEditorDialog.java | 4 +--- core/src/mindustry/ui/fragments/ChatFragment.java | 9 +++++++-- .../mindustry/ui/fragments/ScriptConsoleFragment.java | 8 ++++++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/core/src/mindustry/editor/MapEditorDialog.java b/core/src/mindustry/editor/MapEditorDialog.java index 2a98804146..3c1b5b9f08 100644 --- a/core/src/mindustry/editor/MapEditorDialog.java +++ b/core/src/mindustry/editor/MapEditorDialog.java @@ -298,7 +298,7 @@ public class MapEditorDialog extends Dialog implements Disposable{ Map map = save(); if(map != null){ - //skip dialog, play with survival or attack when shift clicked + //skip dialog, play immediately when shift clicked if(Core.input.shift()){ hide(); //auto pick best fit @@ -309,8 +309,6 @@ public class MapEditorDialog extends Dialog implements Disposable{ ); }else{ playtestDialog.playListener = this::hide; - //TODO skip dialog? or reuse - //TODO set playtesting map, do not create save. playtestDialog.show(map, true); } } diff --git a/core/src/mindustry/ui/fragments/ChatFragment.java b/core/src/mindustry/ui/fragments/ChatFragment.java index c7d2c174eb..a90e2bb9e7 100644 --- a/core/src/mindustry/ui/fragments/ChatFragment.java +++ b/core/src/mindustry/ui/fragments/ChatFragment.java @@ -120,6 +120,11 @@ public class ChatFragment extends Table{ } } + protected void rect(float x, float y, float w, float h){ + //prevents texture bindings; the string lookup is irrelevant as it is only called <10 times per frame, and maps are very fast anyway + Draw.rect("whiteui", x + w/2f, y + h/2f, w, h); + } + @Override public void draw(){ float opacity = Core.settings.getInt("chatopacity") / 100f; @@ -128,7 +133,7 @@ public class ChatFragment extends Table{ Draw.color(shadowColor); if(shown){ - Fill.crect(offsetx, chatfield.y + scene.marginBottom, chatfield.getWidth() + 15f, chatfield.getHeight() - 1); + rect(offsetx, chatfield.y + scene.marginBottom, chatfield.getWidth() + 15f, chatfield.getHeight() - 1); } super.draw(); @@ -159,7 +164,7 @@ public class ChatFragment extends Table{ font.getCache().setAlphas(opacity); } - Fill.crect(offsetx, theight - layout.height - 2, textWidth + Scl.scl(4f), layout.height + textspacing); + rect(offsetx, theight - layout.height - 2, textWidth + Scl.scl(4f), layout.height + textspacing); Draw.color(shadowColor); Draw.alpha(opacity * shadowColor.a); diff --git a/core/src/mindustry/ui/fragments/ScriptConsoleFragment.java b/core/src/mindustry/ui/fragments/ScriptConsoleFragment.java index e6de3a897c..6380fa21aa 100644 --- a/core/src/mindustry/ui/fragments/ScriptConsoleFragment.java +++ b/core/src/mindustry/ui/fragments/ScriptConsoleFragment.java @@ -104,6 +104,10 @@ public class ScriptConsoleFragment extends Table{ add(chatfield).padBottom(offsety).padLeft(offsetx).growX().padRight(offsetx).height(28); } + protected void rect(float x, float y, float w, float h){ + Draw.rect("whiteui", x + w/2f, y + h/2f, w, h); + } + @Override public void draw(){ float opacity = 1f; @@ -112,7 +116,7 @@ public class ScriptConsoleFragment extends Table{ Draw.color(shadowColor); if(open){ - Fill.crect(offsetx, chatfield.y + scene.marginBottom, chatfield.getWidth() + 15f, chatfield.getHeight() - 1); + rect(offsetx, chatfield.y + scene.marginBottom, chatfield.getWidth() + 15f, chatfield.getHeight() - 1); } super.draw(); @@ -143,7 +147,7 @@ public class ScriptConsoleFragment extends Table{ font.getCache().setAlphas(opacity); } - Fill.crect(offsetx, theight - layout.height - 2, textWidth + Scl.scl(4f), layout.height + textspacing); + rect(offsetx, theight - layout.height - 2, textWidth + Scl.scl(4f), layout.height + textspacing); Draw.color(shadowColor); Draw.alpha(opacity * shadowColor.a);