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

@@ -170,8 +170,6 @@ public class Vars implements Loadable{
public static boolean headless;
/** whether steam is enabled for this game */
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 */
public static boolean clearSectors = false;
/** whether any light rendering is enabled */
@@ -369,7 +367,7 @@ public class Vars implements Loadable{
result = tags[level.ordinal()] + " " + result;
if(!headless && (ui == null || ui.scriptfrag == null)){
if(!headless && (ui == null || ui.consolefrag == null)){
logBuffer.add(result);
}else if(!headless){
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;
}

View File

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

View File

@@ -292,7 +292,7 @@ public class DesktopInput extends InputHandler{
if(state.isMenu() || Core.scene.hasDialog()) return;
//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) ||
!keybinds.get(Binding.zoom).equals(keybinds.get(Binding.rotate)) || ((!player.isBuilder() || !isPlacing() || !block.rotate) && selectPlans.isEmpty()))){
renderer.scaleCamera(Core.input.axisTap(Binding.zoom));

View File

@@ -10,6 +10,7 @@ import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.world.meta.*;
import static arc.Core.*;
import static mindustry.Vars.*;
public class ContentInfoDialog extends BaseDialog{
@@ -31,7 +32,7 @@ public class ContentInfoDialog extends BaseDialog{
table.table(title1 -> {
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();

View File

@@ -17,6 +17,7 @@ import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.*;
import static arc.Core.*;
import static mindustry.Vars.*;
public class DatabaseDialog extends BaseDialog{
@@ -98,7 +99,7 @@ public class DatabaseDialog extends BaseDialog{
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){

View File

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

View File

@@ -58,7 +58,7 @@ public class ChatFragment extends Table{
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();
}

View File

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

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++){
if(Core.input.keyTap(blockSelect[i])){