From 2e98abc86e66eda24d13564ab6b0bf35c5dd9300 Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Sat, 1 Oct 2022 14:42:57 -0700 Subject: [PATCH 1/2] Player-only weapons (#6010) Co-authored-by: Anuken --- core/src/mindustry/entities/units/AIController.java | 5 +++++ core/src/mindustry/type/Weapon.java | 2 ++ 2 files changed, 7 insertions(+) diff --git a/core/src/mindustry/entities/units/AIController.java b/core/src/mindustry/entities/units/AIController.java index bbdd2870b1..3ef7851a96 100644 --- a/core/src/mindustry/entities/units/AIController.java +++ b/core/src/mindustry/entities/units/AIController.java @@ -147,6 +147,11 @@ public class AIController implements UnitController{ //let uncontrollable weapons do their own thing if(!weapon.controllable || weapon.noAttack) continue; + if(!weapon.aiControllable){ + mount.rotate = false; + continue; + } + float mountX = unit.x + Angles.trnsx(rotation, weapon.x, weapon.y), mountY = unit.y + Angles.trnsy(rotation, weapon.x, weapon.y); diff --git a/core/src/mindustry/type/Weapon.java b/core/src/mindustry/type/Weapon.java index 6870046bd9..16ceee125d 100644 --- a/core/src/mindustry/type/Weapon.java +++ b/core/src/mindustry/type/Weapon.java @@ -53,6 +53,8 @@ public class Weapon implements Cloneable{ public boolean alwaysContinuous; /** whether this weapon can be aimed manually by players */ public boolean controllable = true; + /** whether this weapon can be automatically aimed by the unit */ + public boolean aiControllable = true; /** whether this weapon is always shooting, regardless of targets ore cone */ public boolean alwaysShooting = false; /** whether to automatically target relevant units in update(); only works when controllable = false. */ From 5863f2f3532944863c03514cee50fb780f646b27 Mon Sep 17 00:00:00 2001 From: Zelaux <58040045+Zelaux@users.noreply.github.com> Date: Sun, 2 Oct 2022 00:48:33 +0300 Subject: [PATCH 2/2] Added scroll pane for server menu (#6451) * Added scroll pane for server menu * Fixed title problems in menus * Removed useless import --- core/src/mindustry/core/UI.java | 48 ++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/core/src/mindustry/core/UI.java b/core/src/mindustry/core/UI.java index 6c90c9f6b3..9488cce27a 100644 --- a/core/src/mindustry/core/UI.java +++ b/core/src/mindustry/core/UI.java @@ -562,31 +562,37 @@ public class UI implements ApplicationListener, Loadable{ /** Shows a menu that fires a callback when an option is selected. If nothing is selected, -1 is returned. */ public void showMenu(String title, String message, String[][] options, Intc callback){ new Dialog(title){{ - cont.row(); - cont.image().width(400f).pad(2).colspan(2).height(4f).color(Pal.accent); - cont.row(); - cont.add(message).width(400f).wrap().get().setAlignment(Align.center); - cont.row(); + setFillParent(true); + removeChild(titleTable); + cont.add(titleTable).width(400f); - int option = 0; - for(var optionsRow : options){ - Table buttonRow = buttons.row().table().get().row(); - int fullWidth = 400 - (optionsRow.length - 1) * 8; // adjust to count padding as well - int width = fullWidth / optionsRow.length; - int lastWidth = fullWidth - width * (optionsRow.length - 1); // take the rest of space for uneven table + cont.row(); + cont.image().width(400f).pad(2).colspan(2).height(4f).color(Pal.accent).bottom(); + cont.row(); + cont.pane(table -> { + table.add(message).width(400f).wrap().get().setAlignment(Align.center); + table.row(); - for(int i = 0; i < optionsRow.length; i++){ - if(optionsRow[i] == null) continue; + int option = 0; + for(var optionsRow : options){ + Table buttonRow = table.row().table().get().row(); + int fullWidth = 400 - (optionsRow.length - 1) * 8; // adjust to count padding as well + int width = fullWidth / optionsRow.length; + int lastWidth = fullWidth - width * (optionsRow.length - 1); // take the rest of space for uneven table - String optionName = optionsRow[i]; - int finalOption = option; - buttonRow.button(optionName, () -> { - callback.get(finalOption); - hide(); - }).size(i == optionsRow.length - 1 ? lastWidth : width, 50).pad(4); - option++; + for(int i = 0; i < optionsRow.length; i++){ + if(optionsRow[i] == null) continue; + + String optionName = optionsRow[i]; + int finalOption = option; + buttonRow.button(optionName, () -> { + callback.get(finalOption); + hide(); + }).size(i == optionsRow.length - 1 ? lastWidth : width, 50).pad(4); + option++; + } } - } + }).growX(); closeOnBack(() -> callback.get(-1)); }}.show(); }