diff --git a/src/informatis/SVars.java b/src/informatis/SVars.java index f5be829..536665a 100644 --- a/src/informatis/SVars.java +++ b/src/informatis/SVars.java @@ -6,10 +6,10 @@ import static arc.Core.atlas; public class SVars { - public static TextureRegion - clear = atlas.find("clear"), - error = atlas.find("error"); - public static RangeShader turretRange = new RangeShader(); + public static final TextureRegion + clear = atlas.find("clear"); + public static final TextureRegion error = atlas.find("error"); + public static final RangeShader turretRange = new RangeShader(); public static informatis.core.Pathfinder pathfinder; public static void init() { diff --git a/src/informatis/core/EventEmitter.java b/src/informatis/core/EventEmitter.java index b0ae325..cb104c3 100644 --- a/src/informatis/core/EventEmitter.java +++ b/src/informatis/core/EventEmitter.java @@ -4,7 +4,7 @@ import informatis.SUtils; public class EventEmitter { - ObjectMap> events = new ObjectMap<>(); + final ObjectMap> events = new ObjectMap<>(); public Runnable subscribe(T event, Runnable listener) { ObjectSet listeners = events.get(event); diff --git a/src/informatis/core/Pathfinder.java b/src/informatis/core/Pathfinder.java index a7d1b87..e6c78e8 100644 --- a/src/informatis/core/Pathfinder.java +++ b/src/informatis/core/Pathfinder.java @@ -81,11 +81,11 @@ public class Pathfinder implements Runnable{ /** unordered array of path data for iteration only. DO NOT iterate or access this in the main thread. */ Seq threadList = new Seq<>(), mainList = new Seq<>(); /** handles task scheduling on the update thread. */ - TaskQueue queue = new TaskQueue(); + final TaskQueue queue = new TaskQueue(); /** Current pathfinding thread */ @Nullable Thread thread; - IntSeq tmpArray = new IntSeq(); + final IntSeq tmpArray = new IntSeq(); public Pathfinder(){ clearCache(); @@ -512,7 +512,7 @@ public static abstract class Flowfield{ /** search IDs of each position - the highest, most recent search is prioritized and overwritten */ public int[] searches; /** search frontier, these are Pos objects */ - IntQueue frontier = new IntQueue(); + final IntQueue frontier = new IntQueue(); /** all target positions; these positions have a cost of 0, and must be synchronized on! */ final IntSeq targets = new IntSeq(); /** current search ID */ diff --git a/src/informatis/core/Setting.java b/src/informatis/core/Setting.java index 743e941..997011d 100644 --- a/src/informatis/core/Setting.java +++ b/src/informatis/core/Setting.java @@ -16,6 +16,21 @@ import static arc.Core.*; import static mindustry.Vars.*; +abstract class SharSetting extends SettingsMenuDialog.SettingsTable.Setting { + + public SharSetting(String name) { + super(name); + } + + public SharSetting(String name, Object def) { + this(name); + Core.settings.defaults(name, def); + } + + public void add(Table table) { } + public void add(SettingsMenuDialog.SettingsTable table) { } +} + public class Setting { public static SettingsMenuDialog.SettingsTable sharset; @@ -158,18 +173,4 @@ public static void init(){ settingUi.button(bundle.get("setting.shar-title"), Styles.cleart, dialog::show); }); } -} -abstract class SharSetting extends SettingsMenuDialog.SettingsTable.Setting { - - public SharSetting(String name) { - super(name); - } - - public SharSetting(String name, Object def) { - this(name); - Core.settings.defaults(name, def); - } - - public void add(Table table) { } - public void add(SettingsMenuDialog.SettingsTable table) { } -} +} \ No newline at end of file diff --git a/src/informatis/core/UpdateChecker.java b/src/informatis/core/UpdateChecker.java index 70e97ba..238217d 100644 --- a/src/informatis/core/UpdateChecker.java +++ b/src/informatis/core/UpdateChecker.java @@ -49,7 +49,7 @@ private static void checkUpdate(Boolc done) { updateBuild = version; showUpdateDialog(); done.get(true); - }; + } }); } diff --git a/src/informatis/ui/components/IntervalTableWrapper.java b/src/informatis/ui/components/IntervalTableWrapper.java index 021a512..918e733 100644 --- a/src/informatis/ui/components/IntervalTableWrapper.java +++ b/src/informatis/ui/components/IntervalTableWrapper.java @@ -7,9 +7,9 @@ public class IntervalTableWrapper { - Cons tableCons; - Boolf
condition; - int interval; + final Cons
tableCons; + final Boolf
condition; + final int interval; public IntervalTableWrapper() { this(t -> {}); diff --git a/src/informatis/ui/components/SBar.java b/src/informatis/ui/components/SBar.java index 35791c3..52cca70 100644 --- a/src/informatis/ui/components/SBar.java +++ b/src/informatis/ui/components/SBar.java @@ -21,7 +21,7 @@ public class SBar extends Element { barSprite = SUtils.getDrawable(Core.atlas.find("informatis-barS"), 10, 10, 9, 9), barTopSprite = SUtils.getDrawable(Core.atlas.find("informatis-barS-top"), 10, 10, 9, 9); - public UnitWindow.BarData barData; + public final UnitWindow.BarData barData; float value, lastValue, blink; public SBar(String name, Color color, Floatp fraction){ @@ -66,10 +66,10 @@ private void drawBarSprite(Color color, float width) { } public static class SBarData { - public String name; - public Floatp fraction; - public Color fromColor; - public Color toColor; + public final String name; + public final Floatp fraction; + public final Color fromColor; + public final Color toColor; public SBarData(String name, Color fromColor, Color toColor, Floatp fraction) { this.name = name; diff --git a/src/informatis/ui/components/SIcons.java b/src/informatis/ui/components/SIcons.java index 430c403..9a411d5 100644 --- a/src/informatis/ui/components/SIcons.java +++ b/src/informatis/ui/components/SIcons.java @@ -4,11 +4,11 @@ import arc.graphics.g2d.TextureRegion; public class SIcons { - public static TextureRegion health = Core.atlas.find("informatis-health"); - public static TextureRegion shield = Core.atlas.find("informatis-shield"); - public static TextureRegion item = Core.atlas.find("informatis-item"); - public static TextureRegion liquid = Core.atlas.find("informatis-liquid"); - public static TextureRegion power = Core.atlas.find("informatis-power"); - public static TextureRegion ammo = Core.atlas.find("informatis-ammo"); - public static TextureRegion reload = Core.atlas.find("informatis-reload"); + public static final TextureRegion health = Core.atlas.find("informatis-health"); + public static final TextureRegion shield = Core.atlas.find("informatis-shield"); + public static final TextureRegion item = Core.atlas.find("informatis-item"); + public static final TextureRegion liquid = Core.atlas.find("informatis-liquid"); + public static final TextureRegion power = Core.atlas.find("informatis-power"); + public static final TextureRegion ammo = Core.atlas.find("informatis-ammo"); + public static final TextureRegion reload = Core.atlas.find("informatis-reload"); } diff --git a/src/informatis/ui/components/TabsFragment.java b/src/informatis/ui/components/TabsFragment.java index b1636f3..462c1ab 100644 --- a/src/informatis/ui/components/TabsFragment.java +++ b/src/informatis/ui/components/TabsFragment.java @@ -8,7 +8,7 @@ public class TabsFragment extends Table { public int currentTabIndex = 0; - public EventEmitter eventEmitter = new EventEmitter<>(); + public final EventEmitter eventEmitter = new EventEmitter<>(); public TabsFragment(String... tabs) { super(); diff --git a/src/informatis/ui/fragments/QuickSchemFragment.java b/src/informatis/ui/fragments/QuickSchemFragment.java index 46c02ea..22db644 100644 --- a/src/informatis/ui/fragments/QuickSchemFragment.java +++ b/src/informatis/ui/fragments/QuickSchemFragment.java @@ -267,7 +267,6 @@ void buildTags(Schematic schem, Table t, boolean name){ }).fillX().left().height(42f).scrollY(false); - Seq finalTags1 = tags; t.button(Icon.addSmall, () -> { var dialog = new BaseDialog("@schematic.addtag"); dialog.addCloseButton(); @@ -276,7 +275,7 @@ void buildTags(Schematic schem, Table t, boolean name){ float sum = 0f; Table current = new Table().left(); - for(var tag : finalTags1){ + for(var tag : tags){ if(schem.labels.contains(tag)) continue; var next = Elem.newButton(tag, () -> { diff --git a/src/informatis/ui/fragments/ServerSearchFragment.java b/src/informatis/ui/fragments/ServerSearchFragment.java index f722a47..85f5c3e 100644 --- a/src/informatis/ui/fragments/ServerSearchFragment.java +++ b/src/informatis/ui/fragments/ServerSearchFragment.java @@ -15,8 +15,8 @@ import static mindustry.Vars.*; public class ServerSearchFragment extends Table { - ObjectMap> servers = new ObjectMap<>(); - static String[] modeNames = new String[]{ "Survival", "PvP", "Attack", "Sandbox", "Custom" }; + final ObjectMap> servers = new ObjectMap<>(); + static final String[] modeNames = new String[]{ "Survival", "PvP", "Attack", "Sandbox", "Custom" }; public ServerSearchFragment() { super(); diff --git a/src/informatis/ui/fragments/SidebarSwitcher.java b/src/informatis/ui/fragments/SidebarSwitcher.java index 0b5bac7..908ee70 100644 --- a/src/informatis/ui/fragments/SidebarSwitcher.java +++ b/src/informatis/ui/fragments/SidebarSwitcher.java @@ -14,7 +14,7 @@ public class SidebarSwitcher { private int showIndex = 0; private final Table sidebarTable = new Table(); - private Table[] sidebars; + private final Table[] sidebars; private final ImageButton switchButton = new ImageButton(style) { @Override @@ -25,6 +25,7 @@ public void draw() { } { clicked(() -> { + Table[] sidebars = getSidebars(); Element currentSidebar = sidebars[showIndex]; showIndex = (showIndex + 1) % sidebars.length; Element nextSidebar = sidebars[showIndex]; @@ -97,4 +98,8 @@ public void rebuildSidebarTable() { sidebarTable.row(); sidebarTable.add(switchButton).growX(); } + + private Table[] getSidebars() { + return sidebars; + } } diff --git a/src/informatis/ui/fragments/TileInfoFragment.java b/src/informatis/ui/fragments/TileInfoFragment.java index e438e98..8b43b97 100644 --- a/src/informatis/ui/fragments/TileInfoFragment.java +++ b/src/informatis/ui/fragments/TileInfoFragment.java @@ -15,8 +15,8 @@ public class TileInfoFragment { private boolean waveShown; - Table tileInfoTable = new Table(Tex.buttonEdge4); - Stack tileInfoContainer; + final Table tileInfoTable = new Table(Tex.buttonEdge4); + final Stack tileInfoContainer; public TileInfoFragment() { Table waveTable = (Table) scene.find("waves"); diff --git a/src/informatis/ui/fragments/sidebar/TroopingManager.java b/src/informatis/ui/fragments/sidebar/TroopingManager.java index c8b97fe..bbe55b1 100644 --- a/src/informatis/ui/fragments/sidebar/TroopingManager.java +++ b/src/informatis/ui/fragments/sidebar/TroopingManager.java @@ -8,7 +8,7 @@ import mindustry.gen.Unit; public class TroopingManager { - static Seq troops = new Seq<>(10) {{ + static final Seq troops = new Seq<>(10) {{ SUtils.loop(10, (i) -> { add(new IntSeq()); }); diff --git a/src/informatis/ui/fragments/sidebar/dialogs/ResourcePreviewDialog.java b/src/informatis/ui/fragments/sidebar/dialogs/ResourcePreviewDialog.java index 451d23a..39b52b2 100644 --- a/src/informatis/ui/fragments/sidebar/dialogs/ResourcePreviewDialog.java +++ b/src/informatis/ui/fragments/sidebar/dialogs/ResourcePreviewDialog.java @@ -233,7 +233,7 @@ Table buildColors(Class colorClass) { sum -= getWidth(); t.row(); } - }; + } }, table -> { if(!Objects.equals(cachedId[0], getWidth() + ":" + tabsFragment.currentTabIndex)) { cachedId[0] = getWidth()+":"+tabsFragment.currentTabIndex; diff --git a/src/informatis/ui/fragments/sidebar/windows/CoreWindow.java b/src/informatis/ui/fragments/sidebar/windows/CoreWindow.java index c6209e9..e127ffd 100644 --- a/src/informatis/ui/fragments/sidebar/windows/CoreWindow.java +++ b/src/informatis/ui/fragments/sidebar/windows/CoreWindow.java @@ -25,7 +25,7 @@ public class CoreWindow extends Window { Table window; float heat; - ObjectMap itemData = new ObjectMap<>(); + final ObjectMap itemData = new ObjectMap<>(); public CoreWindow() { super(Icon.list, "core"); @@ -92,13 +92,7 @@ public Table setTable(Team team){ tt.stack( new Table(s -> { s.center(); - Image image = new Image(core.block.uiIcon); - image.clicked(() -> SUtils.moveCamera(core)); - HandCursorListener listener1 = new HandCursorListener(); - image.addListener(listener1); - image.update(() -> { - image.color.lerp(!listener1.isOver() ? Color.lightGray : Color.white, Mathf.clamp(0.4f * Time.delta)); - }); + Image image = getCoreImage(core); Tooltip.Tooltips option = new Tooltip.Tooltips(); option.animations=false; s.add(image).size(iconLarge).get().addListener(new Tooltip(tool -> { @@ -168,9 +162,20 @@ public Table setTable(Team team){ }); } + private static Image getCoreImage(CoreBlock.CoreBuild core) { + Image image = new Image(core.block.uiIcon); + image.clicked(() -> SUtils.moveCamera(core)); + HandCursorListener listener1 = new HandCursorListener(); + image.addListener(listener1); + image.update(() -> { + image.color.lerp(!listener1.isOver() ? Color.lightGray : Color.white, Mathf.clamp(0.4f * Time.delta)); + }); + return image; + } + static class ItemData { - Seq prevItems = new Seq<>(); - Seq updateItems = new Seq<>(); + final Seq prevItems = new Seq<>(); + final Seq updateItems = new Seq<>(); ItemData() { resetItems(); diff --git a/src/informatis/ui/fragments/sidebar/windows/MapEditorWindow.java b/src/informatis/ui/fragments/sidebar/windows/MapEditorWindow.java index 19d2ef7..d805bef 100644 --- a/src/informatis/ui/fragments/sidebar/windows/MapEditorWindow.java +++ b/src/informatis/ui/fragments/sidebar/windows/MapEditorWindow.java @@ -199,7 +199,7 @@ Table rebuildEditor() { return new Table(table-> { table.top(); Seq blocks = Vars.content.blocks().copy(); - if(search.getText().length() > 0){ + if(!search.getText().isEmpty()){ blocks.filter(p -> p.name.toLowerCase().contains(search.getText().toLowerCase())||p.localizedName.toLowerCase().contains(search.getText().toLowerCase())); } table.table(select-> this.buildBlockSelection(null, select, blocks, ()-> drawBlock, block-> drawBlock =block, false)).marginTop(16f).marginBottom(16f).row(); @@ -378,7 +378,7 @@ public void drawBlocks(int x, int y, Boolf tester){ drawBlocks(x, y, false, tester); } - int rotation = 0; + final int rotation = 0; public void drawBlocks(int x, int y, boolean square, Boolf tester){ if(drawBlock.isMultiblock()){ x = Mathf.clamp(x, (drawBlock.size - 1) / 2, world.width() - drawBlock.size / 2 - 1); diff --git a/src/informatis/ui/fragments/sidebar/windows/SettingConfiger.java b/src/informatis/ui/fragments/sidebar/windows/SettingConfiger.java index 3b0c668..18a2927 100644 --- a/src/informatis/ui/fragments/sidebar/windows/SettingConfiger.java +++ b/src/informatis/ui/fragments/sidebar/windows/SettingConfiger.java @@ -4,7 +4,7 @@ import informatis.ui.fragments.sidebar.windows.ToolConfigable; public class SettingConfiger implements ToolConfigable { - public String name; + public final String name; private boolean enabled; public SettingConfiger(String name) { diff --git a/src/informatis/ui/fragments/sidebar/windows/UnitWindow.java b/src/informatis/ui/fragments/sidebar/windows/UnitWindow.java index 1af079d..9243304 100644 --- a/src/informatis/ui/fragments/sidebar/windows/UnitWindow.java +++ b/src/informatis/ui/fragments/sidebar/windows/UnitWindow.java @@ -74,9 +74,9 @@ public boolean isLocked() { } public static class BarData { - public Prov name; - public Floatp fraction; - public Prov color; + public final Prov name; + public final Floatp fraction; + public final Prov color; public final TextureRegion icon; public BarData(String name, Color color, float fraction) { @@ -109,7 +109,7 @@ public BarData(Prov name, Prov color, Floatp fraction, TextureReg static class UnitWindowBody extends Table implements VDOM.IRebuildable { public boolean locked; - private Seq barDataSeq = new Seq<>(); + private final Seq barDataSeq = new Seq<>(); public UnitWindowBody() { super(); @@ -229,7 +229,7 @@ private Table buildContent(Teamc target) { bar.add(barIcon).size(iconMed * 0.75f).padLeft(8f); }).growX(); bars.row(); - }; + } }); }); } @@ -662,7 +662,7 @@ public void draw() { } } private static class BarIconImage extends Image { - public BarData barData; + public final BarData barData; public BarIconImage(BarData barData) { super(barData.icon); diff --git a/src/informatis/ui/fragments/sidebar/windows/Window.java b/src/informatis/ui/fragments/sidebar/windows/Window.java index db0c98b..331b6fc 100644 --- a/src/informatis/ui/fragments/sidebar/windows/Window.java +++ b/src/informatis/ui/fragments/sidebar/windows/Window.java @@ -21,8 +21,10 @@ public class Window extends Table { public final Cons
content; public boolean shown = false, disableRootScroll = false; - public float minWindowWidth = 160, minWindowHeight = 60; - public static float maxWindowWidth = Float.MAX_VALUE, maxWindowHeight = Float.MAX_VALUE; + public float minWindowWidth = 160; + public final float minWindowHeight = 60; + public static final float maxWindowWidth = Float.MAX_VALUE; + public static final float maxWindowHeight = Float.MAX_VALUE; public Window(String name){ this(new TextureRegionDrawable(Core.atlas.find("clear")), name, null); @@ -109,7 +111,7 @@ public void touchDragged(InputEvent event, float dx, float dy, int pointer) { } private static class DragHandleListener extends TouchPosInputListener { - Window targetWindow; + final Window targetWindow; public DragHandleListener(Window targetWindow) { this.targetWindow = targetWindow; } @@ -133,7 +135,7 @@ public void touchDragged(InputEvent event, float dx, float dy, int pointer) { } private static class ScaleInputListener extends TouchPosInputListener { - Window targetWindow; + final Window targetWindow; public ScaleInputListener(Window targetWindow) { this.targetWindow = targetWindow; } diff --git a/src/informatis/ui/fragments/sidebar/windows/WindowManager.java b/src/informatis/ui/fragments/sidebar/windows/WindowManager.java index 2912e0e..7f5e10b 100644 --- a/src/informatis/ui/fragments/sidebar/windows/WindowManager.java +++ b/src/informatis/ui/fragments/sidebar/windows/WindowManager.java @@ -7,7 +7,7 @@ import mindustry.ui.*; public class WindowManager { - public static Seq windows = new Seq<>(); + public static final Seq windows = new Seq<>(); public static UnitWindow unitWindow; public static MapEditorWindow mapEditorWindow; public static Table body; diff --git a/src/informatis/ui/fragments/sidebar/windows/tools/draws/MassLinkDraw.java b/src/informatis/ui/fragments/sidebar/windows/tools/draws/MassLinkDraw.java index 67c671e..d390ff6 100644 --- a/src/informatis/ui/fragments/sidebar/windows/tools/draws/MassLinkDraw.java +++ b/src/informatis/ui/fragments/sidebar/windows/tools/draws/MassLinkDraw.java @@ -18,8 +18,8 @@ import static mindustry.Vars.world; public class MassLinkDraw extends OverDraw { - Seq linkedMasses = new Seq<>(); - Seq linkedPayloadMasses = new Seq<>(); + final Seq linkedMasses = new Seq<>(); + final Seq linkedPayloadMasses = new Seq<>(); public MassLinkDraw() { super("massLink"); diff --git a/src/informatis/ui/fragments/sidebar/windows/tools/draws/OverDrawManager.java b/src/informatis/ui/fragments/sidebar/windows/tools/draws/OverDrawManager.java index ac1af9f..cb8b8e4 100644 --- a/src/informatis/ui/fragments/sidebar/windows/tools/draws/OverDrawManager.java +++ b/src/informatis/ui/fragments/sidebar/windows/tools/draws/OverDrawManager.java @@ -27,7 +27,7 @@ public class OverDrawManager { OverDrawCategory.Util, new OverDraw[] { new MagicCursorDraw(),new SelectArrawDraw(), new SpawnerArrawDraw(), new DistanceLineDraw() } ); public static final Seq overDraws = new Seq<>(); - public static float[] zIndexTeamCache = new float[Team.baseTeams.length]; + public static final float[] zIndexTeamCache = new float[Team.baseTeams.length]; private static final FrameBuffer effectBuffer = new FrameBuffer(); public static void init() { diff --git a/src/informatis/ui/fragments/sidebar/windows/tools/draws/PowerNodeDraw.java b/src/informatis/ui/fragments/sidebar/windows/tools/draws/PowerNodeDraw.java index 74d5771..90835c6 100644 --- a/src/informatis/ui/fragments/sidebar/windows/tools/draws/PowerNodeDraw.java +++ b/src/informatis/ui/fragments/sidebar/windows/tools/draws/PowerNodeDraw.java @@ -14,7 +14,7 @@ import static mindustry.Vars.world; public class PowerNodeDraw extends OverDraw { - Seq linkedNodes = new Seq<>(); + final Seq linkedNodes = new Seq<>(); public PowerNodeDraw() { super("powerNode"); diff --git a/src/informatis/ui/fragments/sidebar/windows/tools/draws/RangeDraw.java b/src/informatis/ui/fragments/sidebar/windows/tools/draws/RangeDraw.java index 17ef556..73648aa 100644 --- a/src/informatis/ui/fragments/sidebar/windows/tools/draws/RangeDraw.java +++ b/src/informatis/ui/fragments/sidebar/windows/tools/draws/RangeDraw.java @@ -33,9 +33,7 @@ private boolean validate(Ranged target) { rangeData.init(target); if(groundRange.isEnabled() && rangeData.canDetectGround()) return true; - if(airRange.isEnabled() && rangeData.canDetectAir()) return true; - - return false; + return airRange.isEnabled() && rangeData.canDetectAir(); } @Override diff --git a/src/informatis/ui/fragments/sidebar/windows/tools/tools/CameraScaler.java b/src/informatis/ui/fragments/sidebar/windows/tools/tools/CameraScaler.java index 0bd135d..575cb22 100644 --- a/src/informatis/ui/fragments/sidebar/windows/tools/tools/CameraScaler.java +++ b/src/informatis/ui/fragments/sidebar/windows/tools/tools/CameraScaler.java @@ -8,7 +8,7 @@ public class CameraScaler extends Tool { private float lastMinZoom = 1.5f; // TODO: set subconfig by slider later - private float targetMinZoom = 0.35f; + private final float targetMinZoom = 0.35f; public CameraScaler() { super("camerascaler"); diff --git a/src/informatis/ui/fragments/sidebar/windows/tools/tools/Tool.java b/src/informatis/ui/fragments/sidebar/windows/tools/tools/Tool.java index 721c9fb..e9aa12c 100644 --- a/src/informatis/ui/fragments/sidebar/windows/tools/tools/Tool.java +++ b/src/informatis/ui/fragments/sidebar/windows/tools/tools/Tool.java @@ -7,5 +7,5 @@ public Tool(String name) { super(name); } - public void onUpdate() {}; + public void onUpdate() {} } diff --git a/src/informatis/ui/fragments/sidebar/windows/tools/tools/ToolManager.java b/src/informatis/ui/fragments/sidebar/windows/tools/tools/ToolManager.java index b6e0ec3..17dcb8e 100644 --- a/src/informatis/ui/fragments/sidebar/windows/tools/tools/ToolManager.java +++ b/src/informatis/ui/fragments/sidebar/windows/tools/tools/ToolManager.java @@ -4,7 +4,7 @@ import mindustry.game.EventType; public class ToolManager { - public static Tool[] tools = new Tool[] { new FogRemover(), new CameraScaler(), new AutoShooter() }; + public static final Tool[] tools = new Tool[] { new FogRemover(), new CameraScaler(), new AutoShooter() }; public static void init() { Events.run(EventType.Trigger.update, () -> {