Skip to content

Commit 80dea41

Browse files
authored
Merge pull request #38 from JiroCab/Development
slightly more better filters
2 parents a5f26a9 + 8850185 commit 80dea41

File tree

8 files changed

+113
-24
lines changed

8 files changed

+113
-24
lines changed

assets/bundles/bundle.properties

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ setting.cui-playerTrackedAlpha.description =Default: 100%
2323
setting.cui-playerIconSize.name =Player's Unit icon size:
2424
setting.cui-playerIconSize.description =Default: 35\nApplies next map change / Ui rebuilt
2525
setting.cui-playerHoldTrackMouse =Hold Track player mouse
26+
setting.cui-useCycleFilter.name =Hide Cursor of ignored players
27+
setting.cui-useCycleFilter.description =Same as`Filter Teams (Cycle player)`
28+
setting.cui-cyclePlayersIgnoreNoCore.name =Cycle Players ignores players w/o cores
29+
setting.cui-cyclePlayersIgnoreNoCore.description =Useful for cases where a team losses their core
2630

2731
setting.cui-counter-category.name =Counters options
2832
setting.cui-ShowPlayerList.name =Mini Player Table
@@ -176,7 +180,8 @@ cui-hiddenInfo =Units to show/hide in Unit table
176180
cui-hiddenCoreUnits =Hidden Core units
177181
cui-hiddenCoreInfo =Units to ignore for `Hide Core units`
178182
cui-unbind =Unbind
179-
cui-filterTeams =Filter Teams
183+
cui-filterTeams =Filter Teams\n({0})
184+
cui-filterTeamsShort =Filter Teams ({0})
180185
cui-teamblacklister =Filter Teams
181186

182187
settings.cui-preset =Presets
@@ -289,9 +294,10 @@ cui-unitshealtbar-style3 =left bar
289294
cui-unitshealtbar-style4 =no bg + centered bar
290295
cui-unitshealtbar-style5 =no bg + left bar
291296
cui-unitshealtbar-style6 =no bg + right bar
292-
cui-unitshealtbar-style7 =boarder + centered bar
293-
cui-unitshealtbar-style8 =boarder + left bar
294-
cui-unitshealtbar-style9 =boarder + right bar
297+
cui-unitshealtbar-style7 =Border + centered bar
298+
cui-unitshealtbar-style8 =Border + left bar
299+
cui-unitshealtbar-style9 =Border + right bar
300+
cui-unitshealtbar-style10 = Hud Diamond
295301

296302
cui-unittext-style1 =%
297303
cui-unittext-style2 =raw hp
@@ -305,3 +311,8 @@ cui-preset4 =bottom` centric
305311
cui-cmd-limits1 =Mouse
306312
cui-cmd-limits2 =On screen
307313
cui-cmd-limits3 =ALL units
314+
315+
cui-filter0 =Domination
316+
cui-filter1 =Units
317+
cui-filter2 =Core Items
318+
cui-filter3 =Cycle players

mod.hjson

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ name: "caster-ui-java"
22
displayName: "Caster User interface"
33
description: "Aming to make the client a bit better for casting! with ease of use, simplicity and elegance in mind \n \n Java rewrite of 'JiroCab/Caster-Ui' which was based off 'Ferlern/extended-UI' \nconflicts with 'Ferlern/extended-UI' \n\nPLEASE DON'T THIS FOR AN ADVANTAGE IN PVP THANKS"
44
author: "RushieWashie, WMF Industries"
5-
subtitle: "v4.8 Helping you cast games~"
6-
version: 4.8
5+
subtitle: "v4.9 Helping you cast games~"
6+
version: 4.9
77

88
minGameVersion: 140.4
99
hidden: true

src/casterui/CuiVars.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public class CuiVars {
5252
countersSeparateTeams = false, countersCoreUnits = false, countersCoreFlagged = false, countersTotals = false,
5353
dominationVertical = false, dominationColoured = false, dominationIcons = false,
5454
showTeamItems = false, showDomination = false;
55-
public static boolean[] hiddenTeamsDomination = new boolean[Team.all.length], hiddenTeamsUnits = new boolean[Team.all.length], hiddenTeamsItems = new boolean[Team.all.length];
56-
public static boolean[][] hiddenTeamList = {hiddenTeamsDomination, hiddenTeamsUnits, hiddenTeamsItems};
55+
public static boolean[] hiddenTeamsDomination = new boolean[Team.all.length], hiddenTeamsUnits = new boolean[Team.all.length], hiddenTeamsItems = new boolean[Team.all.length], hiddenCycleTeam = new boolean[Team.all.length];
56+
public static boolean[][] hiddenTeamList = {hiddenTeamsDomination, hiddenTeamsUnits, hiddenTeamsItems, hiddenCycleTeam};
5757
public static Table updateCheckTable = new Table();
5858

5959
public static void init(){

src/casterui/io/CuiBinding.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ public enum CuiBinding implements KeyBinds.KeyBind {
1414
spectate_previous_player(KeyCode.apostrophe),
1515
spectate_next_core(KeyCode.unknown),
1616
spectate_previous_core(KeyCode.unknown),
17+
spectate_ignore_coreless(KeyCode.unknown),
1718

1819
toggle_units_player_table_controls(KeyCode.unknown, "cui-counter"),
1920
toggle_table_core_units(KeyCode.unknown),
2021
toggle_table_summarize_players(KeyCode.unknown),
2122

2223
toggle_player_cursor(KeyCode.unknown, "cui-trackers"),
24+
filter_player_cursor(KeyCode.unknown),
2325
toggle_track_logic(KeyCode.unknown),
2426
toggle_unit_cmd(KeyCode.unknown),
2527
toggle_unit_Cmd_type(KeyCode.unknown),

src/casterui/io/CuiInputs.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ public void update(){
7878
if(cuiKeyTap(toggle_cui_kill_switch)) settings.put("cui-killswitch", !settings.getBool("cui-killswitch")); //haha this will be one way but lulz
7979
if(cuiKeyTap(toggle_unit_Cmd_type)) settings.put("cui-unitCmdNonMv", !settings.getBool("cui-unitCmdNonMv"));
8080
if(cuiKeyTap(toggle_domination)) settings.put("cui-domination-toggle", !settings.getBool("cui-domination-toggle"));
81+
if(cuiKeyTap(spectate_ignore_coreless)) settings.put("cui-cyclePlayersIgnoreNoCore", !settings.getBool("cui-cyclePlayersIgnoreNoCore"));
82+
if(cuiKeyTap(filter_player_cursor)) settings.put("cui-useCycleFilter", !settings.getBool("cui-useCycleFilter"));
8183

8284

8385

@@ -194,6 +196,9 @@ void cyclePlayers(boolean increment){
194196
if (p != player) ply.add(p);
195197
}
196198
ply.remove(player);
199+
ply.removeAll(p -> CuiVars.hiddenCycleTeam[p.team().id]);
200+
if(settings.getBool("cui-cyclePlayersIgnoreNoCore")) ply.removeAll(p->p.team().cores().size == 0);
201+
197202

198203
if (ply.size < 1) return;
199204
int number = playerNumber;

src/casterui/io/ui/CuiWorldRenderer.java

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import mindustry.world.blocks.storage.CoreBlock;
2727
import mindustry.world.blocks.units.UnitFactory;
2828

29-
import static arc.graphics.g2d.Draw.draw;
29+
import static arc.graphics.g2d.Draw.*;
3030
import static mindustry.Vars.*;
3131

3232

@@ -42,6 +42,7 @@ public void worldRenderer(){
4242
if (!CuiVars.globalShow) return;
4343
boolean unitBars = Core.settings.getInt("cui-showUnitBarStyle") > 0;
4444
boolean trackPlayerCursor = Core.settings.getBool("cui-TrackPlayerCursor");
45+
boolean filterPlayerCursor = Core.settings.getBool("cui-useCycleFilter"), filterNoCores = Core.settings.getBool("cui-cyclePlayersIgnoreNoCore");
4546
boolean trackLogicControl = Core.settings.getInt("cui-logicLineAlpha") > 0;
4647
boolean unitCmds = Core.settings.getInt("cui-unitscommands") > 0;
4748

@@ -63,6 +64,7 @@ public void worldRenderer(){
6364
}));
6465
if(unitCmds) drawUnitPointer();
6566
if(trackPlayerCursor) Groups.player.each(ply ->{
67+
if(filterPlayerCursor && (CuiVars.hiddenCycleTeam[ply.team().id] || (filterNoCores && ply.team().cores().size == 0))) return;
6668
if(ply.unit() != null){drawPlayerCursor(ply);}
6769
});
6870
}
@@ -119,28 +121,39 @@ public void drawUnitBars(Unit unit, int style, float alpha, float stroke){
119121
Color shclr = new Color().set(unit.team.color).lerp(Color.black, 0.25f).a(alpha);
120122

121123
Draw.alpha(alpha);
122-
Draw.draw(Layer.flyingUnit +2, () ->{
124+
Draw.draw(Layer.flyingUnit +2, () -> {
123125
if(Core.settings.getInt("cui-showUnitTextStyle") > 0){
124126
int tstyle = Core.settings.getInt("cui-showUnitTextStyle");
125127
String txt = "[red]";
126128
if(tstyle == 1){
127-
txt += Mathf.round(hp * 100) + "%[]";
129+
txt += Mathf.round(hp * 100) + "%[]";
128130
if(shield > 0) txt += "\n" + CuiVars.decFor.format(unit.shield);
129131
}else if(style == 2){
130-
txt += CuiVars.decFor.format(unit.health) + "[]";
132+
txt += CuiVars.decFor.format(unit.health) + "[]";
131133
if(shield > 0) txt += "\n" + CuiVars.decFor.format(unit.shield);
132-
} else {
133-
txt += (CuiVars.decFor.format(unit.health) + "[][white]/[][pink]"+ Math.round(unit.maxHealth) +"[]");
134+
}else{
135+
txt += (CuiVars.decFor.format(unit.health) + "[][white]/[][pink]" + Math.round(unit.maxHealth) + "[]");
134136
if(shield > 0) txt += "\n" + CuiVars.decFor.format(unit.shield);
135137
}
136138

137139
drawLabel(unit.x, unit.y, txt, colour);
138140

139141
}
140-
if(stroke == 0) return;
142+
});
143+
if(stroke == 0) return;
144+
Draw.draw(Layer.flyingUnit +1.99f, () ->{
141145
float yShield = y - offset + stroke, yShieldAlt = yShield + (stroke /2.5f);
142146
float yOff = y - offset;
147+
143148
switch (style) {
149+
case 10 -> { //diamonds, (don't remember which mod that used to do this so ughh yes)
150+
drawInner(Pal.darkishGray, 1f, false, x - (offset /1.5f), y - (offset /2), (width / 2f), unit.hitSize, 1);
151+
drawInner(colour, hp ,false, x - (offset /1.5f), y - (offset /2), (width / 2f), unit.hitSize, 1);
152+
if(shield > 0){
153+
drawInner(Pal.darkishGray, 1f, true, x + (offset /1.5f), y - (offset /2), (width / 2f), unit.hitSize, 1);
154+
drawInner(colour, shield ,true, x + (offset /1.5f), y - (offset /2), (width / 2f), unit.hitSize, 1);
155+
}
156+
}
144157
case 9 -> {//boarder - right
145158
if(shield > 0)drawBoardedLine(colour, x + width, yShield, x - (width), yShield,x + offset + ((width * 2) * shield), yShield, x + offset, yShield, stroke, bg);
146159
drawBoardedLine(colour, x + width, yOff, x - (width), yOff,x + offset + ((width * 2) * hp), yOff, x + offset, yOff, stroke, bg);
@@ -356,6 +369,48 @@ public void drawPointer(Color color, float x, float y, Position unit, int style)
356369
Draw.reset();
357370
}
358371

372+
public void drawInner(Color color, float fract, boolean flip, float x, float y, float width, float height, float parentAlpha){
373+
if(fract < 0) return;
374+
375+
fract = Mathf.clamp(fract);
376+
if(flip){
377+
x += width;
378+
width = -width;
379+
}
380+
381+
float stroke = width * 0.35f;
382+
float bh = height/2f;
383+
Draw.color(color, parentAlpha);
384+
385+
float f1 = Math.min(fract * 2f, 1f), f2 = (fract - 0.5f) * 2f;
386+
387+
float bo = -(1f - f1) * (width - stroke);
388+
389+
Fill.quad(
390+
x, y,
391+
x + stroke, y,
392+
x + width + bo, y + bh * f1,
393+
x + width - stroke + bo, y + bh * f1
394+
);
395+
396+
if(f2 > 0){
397+
float bx = x + (width - stroke) * (1f - f2);
398+
Fill.quad(
399+
x + width, y + bh,
400+
x + width - stroke, y + bh,
401+
bx, y + height * fract,
402+
bx + stroke, y + height * fract
403+
);
404+
}
405+
406+
Draw.reset();
407+
408+
if(flip){
409+
width = -width;
410+
x -= width;
411+
}
412+
}
413+
359414
public static void drawBoardedLine(Color color, float x, float y, float x2, float y2, float x3, float y3, float stoke, Color bg){
360415
drawBoardedLine(color, x, y, x2, y2, x3, y3, x, y, stoke, bg);
361416
}

src/casterui/io/ui/dialog/CuiSettingsDialog.java

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public void add(SettingsMenuDialog.SettingsTable table) {
6565
case 8 -> unitsCategory(table);
6666
case 9 -> dominationSubCategory(table);
6767
case 10 -> updateHeader(table);
68+
case 11 -> cyclePlayerSubCategory(table);
6869
default -> advanceCategory(table);
6970
}
7071
}
@@ -83,9 +84,15 @@ public void trackingCategory(SettingsMenuDialog.SettingsTable table){
8384
subTable.sliderPref("cui-playerTrackAlpha", 7, 0, 10, s -> s > 0 ? s != 10 ? s + "0%" : "100%" : "@off");
8485
subTable.sliderPref("cui-playerTrackedAlpha", 10, 0, 10, s -> s > 0 ? s != 10 ? s + "0%" : "100%" : "@off");
8586
subTable.sliderPref("cui-playerIconSize", 35, 1, 100, String::valueOf);
87+
subTable.checkPref("cui-useCycleFilter", true);
88+
89+
subTable.pref(new CollapserSetting("cui-offset-div", 6));
90+
subTable.pref(new CollapserSetting("cui-playerCycle-more", 11));
91+
subTable.checkPref("cui-cyclePlayersIgnoreNoCore", true);
8692

87-
allCuiOptions.add(subTable);
8893
t.add(subTable);
94+
allCuiOptions.addAll(subTable);
95+
8996
}, CuiVars.animateCats , () ->tracking[0]).growX().row();
9097
}
9198

@@ -95,12 +102,12 @@ public void counterCategory(SettingsMenuDialog.SettingsTable table) {
95102
table.collapser( t -> {
96103
SettingsMenuDialog.SettingsTable subTable = new SettingsMenuDialog.SettingsTable();
97104
//TODO: SAVE THESE AND LOAD THEM
98-
t.button(bundle.get("cui-hiddenUnits"), Icon.eyeOffSmall,() -> showBanned(bundle.get("cui-hiddenUnits"), hiddenUnits)).tooltip(bundle.get("cui-hiddenInfo")).center().width(400f).top().row();
99-
t.button(bundle.get("cui-hiddenCoreUnits"), Icon.cancel,() -> showBanned(bundle.get("cui-hiddenCoreUnits"), coreUnitsTypes, true)).tooltip(bundle.get("cui-hiddenCoreInfo")).center().width(400f).top().row();
100-
t.button(bundle.get("cui-filterTeams"), Icon.eraserSmall,() ->{
105+
t.button(bundle.get("cui-hiddenUnits"), Icon.eyeOffSmall,() -> showBanned(bundle.get("cui-hiddenUnits"), hiddenUnits)).tooltip(bundle.get("cui-hiddenInfo")).center().width(400f).height(40).top().row();
106+
t.button(bundle.get("cui-hiddenCoreUnits"), Icon.cancel, () -> showBanned(bundle.get("cui-hiddenCoreUnits"), coreUnitsTypes, true)).tooltip(bundle.get("cui-hiddenCoreInfo")).center().width(400f).height(40).top().row();
107+
t.button(bundle.format("cui-filterTeamsShort", bundle.get("cui-filter1")), Icon.eraserSmall, () ->{
101108
TeamBlackListerDialog teamBlackListerDialog = new TeamBlackListerDialog();
102109
teamBlackListerDialog.show(1);
103-
}).marginLeft(14f).width(400f).scaling(Scaling.bounded).row();
110+
}).height(40).marginLeft(14f).width(400f).scaling(Scaling.bounded).row();
104111

105112
//Counter table
106113
subTable.checkPref("cui-ShowUnitTable", true);
@@ -135,7 +142,7 @@ public void unitsCategory(SettingsMenuDialog.SettingsTable table) {
135142
table.collapser( t -> {
136143
SettingsMenuDialog.SettingsTable subTable = new SettingsMenuDialog.SettingsTable();
137144
//hp bars
138-
subTable.sliderPref("cui-showUnitBarStyle", 7, 0, 9, s -> s == 0 ? "@off" :bundle.get("cui-unitshealtbar-style" + s));
145+
subTable.sliderPref("cui-showUnitBarStyle", 7, 0, 10, s -> s == 0 ? "@off" :bundle.get("cui-unitshealtbar-style" + s));
139146
subTable.sliderPref("cui-showUnitBarSize", 4, 0, 100, s -> s == 0 ? "@off" : decFor.format(s * 0.25f));
140147
subTable.sliderPref("cui-showUnitBarAlpha", 10, 1, 10, s -> s + "0%");
141148
subTable.sliderPref("cui-showUnitTextStyle", 1, 0, 3, s -> s == 0 ? "@off" :bundle.get("cui-unittext-style" + s));
@@ -237,7 +244,7 @@ public void teamsCategory(SettingsMenuDialog.SettingsTable table){
237244
subTable.sliderPref("cui-domination-x", 0, -offsetMinMax , offsetMinMax, String::valueOf);
238245
subTable.sliderPref("cui-domination-y", 0, -offsetMinMax , offsetMinMax, String::valueOf);
239246

240-
t.button(bundle.get("cui-filterTeams"), Icon.eraserSmall,() ->{
247+
t.button(bundle.format("cui-filterTeams", bundle.get("cui-filter2")), Icon.eraser,() ->{
241248
TeamBlackListerDialog teamBlackListerDialog = new TeamBlackListerDialog();
242249
teamBlackListerDialog.show(2);
243250
}).marginLeft(14f).width(400f).scaling(Scaling.bounded).row();
@@ -307,7 +314,7 @@ public void advanceCategory(SettingsMenuDialog.SettingsTable table){
307314

308315
public void dominationSubCategory(SettingsMenuDialog.SettingsTable table){
309316
boolean[] dominactionShown = {false};
310-
table.button(bundle.get("cui-filterTeams"), Icon.eraserSmall,() ->{
317+
table.button(bundle.format("cui-filterTeams", bundle.get("cui-filter0")), Icon.eraser,() ->{
311318
TeamBlackListerDialog teamBlackListerDialog = new TeamBlackListerDialog();
312319
teamBlackListerDialog.show(0);
313320
}).marginLeft(14f).width(400f).scaling(Scaling.bounded).row();
@@ -340,6 +347,13 @@ public void dominationSubCategory(SettingsMenuDialog.SettingsTable table){
340347
public void updateHeader(SettingsMenuDialog.SettingsTable table){
341348
table.add(CuiVars.updateCheckTable).growX().center().row();
342349
}
350+
351+
public void cyclePlayerSubCategory(SettingsMenuDialog.SettingsTable table){
352+
table.button(bundle.format("cui-filterTeams", bundle.get("cui-filter3")), Icon.eraser,() ->{
353+
TeamBlackListerDialog teamBlackListerDialog = new TeamBlackListerDialog();
354+
teamBlackListerDialog.show(3);
355+
}).marginLeft(14f).width(400f).scaling(Scaling.bounded).row();
356+
};
343357
}
344358

345359

src/casterui/io/ui/dialog/TeamBlackListerDialog.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.io.*;
2424
import java.util.*;
2525

26+
import static arc.Core.bundle;
2627
import static casterui.CuiVars.*;
2728
import static mindustry.Vars.*;
2829

@@ -33,7 +34,7 @@ public class TeamBlackListerDialog extends BaseDialog{
3334
public int sort = 0;
3435
public String sortTxt = "";
3536
private int write;
36-
public static String headerSub[] = {"teams", "counter", "team"};
37+
public static String headerSub[] = {"teams", "counter", "team", "cycle"};
3738

3839

3940
public TeamBlackListerDialog(){
@@ -60,6 +61,7 @@ public TeamBlackListerDialog(){
6061

6162
public void show(int write){
6263
this.write = write;
64+
this.title.setText(Core.bundle.get("cui-teamblacklister") + " - " + bundle.get("cui-filter" + write));
6365
show();
6466
}
6567

0 commit comments

Comments
 (0)