Made console a setting

This commit is contained in:
Anuken
2022-06-08 10:35:00 -04:00
parent 62c2d9d606
commit 13ac6e0331
10 changed files with 23 additions and 18 deletions

View File

@@ -970,6 +970,7 @@ setting.borderlesswindow.name = Borderless Window
setting.borderlesswindow.name.windows = Borderless Fullscreen setting.borderlesswindow.name.windows = Borderless Fullscreen
setting.borderlesswindow.description = Restart may be required to apply changes. setting.borderlesswindow.description = Restart may be required to apply changes.
setting.fps.name = Show FPS & Ping setting.fps.name = Show FPS & Ping
setting.console.name = Enable Console
setting.smoothcamera.name = Smooth Camera setting.smoothcamera.name = Smooth Camera
setting.vsync.name = VSync setting.vsync.name = VSync
setting.pixelate.name = Pixelate setting.pixelate.name = Pixelate

View File

@@ -170,8 +170,6 @@ public class Vars implements Loadable{
public static boolean headless; public static boolean headless;
/** whether steam is enabled for this game */ /** whether steam is enabled for this game */
public static boolean steam; public static boolean steam;
/** whether typing into the console is enabled - developers only TODO change */
public static boolean enableConsole = true;
/** whether to clear sector saves when landing */ /** whether to clear sector saves when landing */
public static boolean clearSectors = false; public static boolean clearSectors = false;
/** whether any light rendering is enabled */ /** whether any light rendering is enabled */
@@ -369,7 +367,7 @@ public class Vars implements Loadable{
result = tags[level.ordinal()] + " " + result; result = tags[level.ordinal()] + " " + result;
if(!headless && (ui == null || ui.scriptfrag == null)){ if(!headless && (ui == null || ui.consolefrag == null)){
logBuffer.add(result); logBuffer.add(result);
}else if(!headless){ }else if(!headless){
if(!OS.isWindows){ if(!OS.isWindows){
@@ -378,12 +376,12 @@ public class Vars implements Loadable{
} }
} }
ui.scriptfrag.addMessage(Log.removeColors(result)); ui.consolefrag.addMessage(Log.removeColors(result));
} }
} }
}; };
Events.on(ClientLoadEvent.class, e -> logBuffer.each(ui.scriptfrag::addMessage)); Events.on(ClientLoadEvent.class, e -> logBuffer.each(ui.consolefrag::addMessage));
loadedLogger = true; loadedLogger = true;
} }

View File

@@ -40,7 +40,7 @@ public class UI implements ApplicationListener, Loadable{
public MenuFragment menufrag; public MenuFragment menufrag;
public HudFragment hudfrag; public HudFragment hudfrag;
public ChatFragment chatfrag; public ChatFragment chatfrag;
public ScriptConsoleFragment scriptfrag; public ConsoleFragment consolefrag;
public MinimapFragment minimapfrag; public MinimapFragment minimapfrag;
public PlayerListFragment listfrag; public PlayerListFragment listfrag;
public LoadingFragment loadfrag; public LoadingFragment loadfrag;
@@ -172,7 +172,7 @@ public class UI implements ApplicationListener, Loadable{
minimapfrag = new MinimapFragment(); minimapfrag = new MinimapFragment();
listfrag = new PlayerListFragment(); listfrag = new PlayerListFragment();
loadfrag = new LoadingFragment(); loadfrag = new LoadingFragment();
scriptfrag = new ScriptConsoleFragment(); consolefrag = new ConsoleFragment();
picker = new ColorPicker(); picker = new ColorPicker();
editor = new MapEditorDialog(); editor = new MapEditorDialog();
@@ -217,7 +217,7 @@ public class UI implements ApplicationListener, Loadable{
chatfrag.build(hudGroup); chatfrag.build(hudGroup);
minimapfrag.build(hudGroup); minimapfrag.build(hudGroup);
listfrag.build(hudGroup); listfrag.build(hudGroup);
scriptfrag.build(hudGroup); consolefrag.build(hudGroup);
loadfrag.build(group); loadfrag.build(group);
new FadeInFragment().build(group); new FadeInFragment().build(group);
} }

View File

@@ -292,7 +292,7 @@ public class DesktopInput extends InputHandler{
if(state.isMenu() || Core.scene.hasDialog()) return; if(state.isMenu() || Core.scene.hasDialog()) return;
//zoom camera //zoom camera
if((!Core.scene.hasScroll() || Core.input.keyDown(Binding.diagonal_placement)) && !ui.chatfrag.shown() && Math.abs(Core.input.axisTap(Binding.zoom)) > 0 if((!Core.scene.hasScroll() || Core.input.keyDown(Binding.diagonal_placement)) && !ui.chatfrag.shown() && !ui.consolefrag.shown() && Math.abs(Core.input.axisTap(Binding.zoom)) > 0
&& !Core.input.keyDown(Binding.rotateplaced) && (Core.input.keyDown(Binding.diagonal_placement) || && !Core.input.keyDown(Binding.rotateplaced) && (Core.input.keyDown(Binding.diagonal_placement) ||
!keybinds.get(Binding.zoom).equals(keybinds.get(Binding.rotate)) || ((!player.isBuilder() || !isPlacing() || !block.rotate) && selectPlans.isEmpty()))){ !keybinds.get(Binding.zoom).equals(keybinds.get(Binding.rotate)) || ((!player.isBuilder() || !isPlacing() || !block.rotate) && selectPlans.isEmpty()))){
renderer.scaleCamera(Core.input.axisTap(Binding.zoom)); renderer.scaleCamera(Core.input.axisTap(Binding.zoom));

View File

@@ -10,6 +10,7 @@ import mindustry.gen.*;
import mindustry.graphics.*; import mindustry.graphics.*;
import mindustry.world.meta.*; import mindustry.world.meta.*;
import static arc.Core.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
public class ContentInfoDialog extends BaseDialog{ public class ContentInfoDialog extends BaseDialog{
@@ -31,7 +32,7 @@ public class ContentInfoDialog extends BaseDialog{
table.table(title1 -> { table.table(title1 -> {
title1.image(content.uiIcon).size(iconXLarge).scaling(Scaling.fit); title1.image(content.uiIcon).size(iconXLarge).scaling(Scaling.fit);
title1.add("[accent]" + content.localizedName + (enableConsole ? "\n[gray]" + content.name : "")).padLeft(5); title1.add("[accent]" + content.localizedName + (settings.getBool("console") ? "\n[gray]" + content.name : "")).padLeft(5);
}); });
table.row(); table.row();

View File

@@ -17,6 +17,7 @@ import mindustry.type.*;
import mindustry.ui.*; import mindustry.ui.*;
import mindustry.world.*; import mindustry.world.*;
import static arc.Core.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
public class DatabaseDialog extends BaseDialog{ public class DatabaseDialog extends BaseDialog{
@@ -98,7 +99,7 @@ public class DatabaseDialog extends BaseDialog{
ui.content.show(unlock); ui.content.show(unlock);
} }
}); });
image.addListener(new Tooltip(t -> t.background(Tex.button).add(unlock.localizedName + (enableConsole ? "\n[gray]" + unlock.name : "")))); image.addListener(new Tooltip(t -> t.background(Tex.button).add(unlock.localizedName + (settings.getBool("console") ? "\n[gray]" + unlock.name : ""))));
} }
if((++count) % cols == 0){ if((++count) % cols == 0){

View File

@@ -358,6 +358,10 @@ public class SettingsMenuDialog extends BaseDialog{
} }
} }
if(!mobile){
game.checkPref("console", false);
}
int[] lastUiScale = {settings.getInt("uiscale", 100)}; int[] lastUiScale = {settings.getInt("uiscale", 100)};
graphics.sliderPref("uiscale", 100, 25, 300, 25, s -> { graphics.sliderPref("uiscale", 100, 25, 300, 25, s -> {

View File

@@ -58,7 +58,7 @@ public class ChatFragment extends Table{
update(() -> { update(() -> {
if(net.active() && input.keyTap(Binding.chat) && (scene.getKeyboardFocus() == chatfield || scene.getKeyboardFocus() == null || ui.minimapfrag.shown()) && !ui.scriptfrag.shown()){ if(net.active() && input.keyTap(Binding.chat) && (scene.getKeyboardFocus() == chatfield || scene.getKeyboardFocus() == null || ui.minimapfrag.shown()) && !ui.consolefrag.shown()){
toggle(); toggle();
} }

View File

@@ -18,7 +18,7 @@ import mindustry.ui.*;
import static arc.Core.*; import static arc.Core.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
public class ScriptConsoleFragment extends Table{ public class ConsoleFragment extends Table{
private static final int messagesShown = 30; private static final int messagesShown = 30;
private Seq<String> messages = new Seq<>(); private Seq<String> messages = new Seq<>();
private boolean open = false, shown; private boolean open = false, shown;
@@ -33,14 +33,14 @@ public class ScriptConsoleFragment extends Table{
private int historyPos = 0; private int historyPos = 0;
private int scrollPos = 0; private int scrollPos = 0;
public ScriptConsoleFragment(){ public ConsoleFragment(){
setFillParent(true); setFillParent(true);
font = Fonts.def; font = Fonts.def;
visible(() -> { visible(() -> {
if(input.keyTap(Binding.console) && (scene.getKeyboardFocus() == chatfield || scene.getKeyboardFocus() == null) && !ui.chatfrag.shown()){ if(input.keyTap(Binding.console) && settings.getBool("console") && (scene.getKeyboardFocus() == chatfield || scene.getKeyboardFocus() == null) && !ui.chatfrag.shown()){
shown = !shown; shown = !shown;
if(shown && !open && enableConsole){ if(shown && !open && settings.getBool("console")){
toggle(); toggle();
} }
if(shown){ if(shown){
@@ -53,7 +53,7 @@ public class ScriptConsoleFragment extends Table{
}); });
update(() -> { update(() -> {
if(input.keyTap(Binding.chat) && enableConsole && (scene.getKeyboardFocus() == chatfield || scene.getKeyboardFocus() == null)){ if(input.keyTap(Binding.chat) && settings.getBool("console") && (scene.getKeyboardFocus() == chatfield || scene.getKeyboardFocus() == null)){
toggle(); toggle();
} }

View File

@@ -144,7 +144,7 @@ public class PlacementFragment{
} }
} }
if(ui.chatfrag.shown() || Core.scene.hasKeyboard()) return false; if(ui.chatfrag.shown() || ui.consolefrag.shown() || Core.scene.hasKeyboard()) return false;
for(int i = 0; i < blockSelect.length; i++){ for(int i = 0; i < blockSelect.length; i++){
if(Core.input.keyTap(blockSelect[i])){ if(Core.input.keyTap(blockSelect[i])){