55import com .lootfilters .model .FontType ;
66import com .lootfilters .model .TextAccent ;
77import lombok .AllArgsConstructor ;
8- import lombok .Builder ;
98import lombok .EqualsAndHashCode ;
109import lombok .Getter ;
1110import lombok .ToString ;
1716import java .util .List ;
1817
1918@ Getter
20- @ Builder (toBuilder = true )
2119@ AllArgsConstructor
2220@ EqualsAndHashCode
2321@ ToString
2422public class DisplayConfig {
23+ public static Builder builder () {
24+ return new Builder ();
25+ }
26+
2527 public static final Color DEFAULT_MENU_TEXT_COLOR = Color .decode ("#ff9040" );
2628
2729 private final Color textColor ;
@@ -30,7 +32,7 @@ public class DisplayConfig {
3032 private final Boolean hidden ;
3133 private final Boolean showLootbeam ;
3234 private final Boolean showValue ;
33- private final Boolean compact ;
35+ private final Boolean compact ; // compact is currently a config-only setting and not supported in rs2f
3436 private final Boolean showDespawn ;
3537 private final Boolean notify ;
3638 private final TextAccent textAccent ;
@@ -48,32 +50,31 @@ public class DisplayConfig {
4850 private final Integer menuSort ;
4951 private final BufferedImageProvider icon ;
5052
51- // ideally this would be in EvalDisplayConfig which extends DisplayConfig but that's just more code tbh
5253 private final List <Integer > evalTrace ;
5354
54- public DisplayConfig (Color textColor ) {
55- this . textColor = textColor ;
56- backgroundColor = null ;
57- borderColor = null ;
58- hidden = false ;
59- showLootbeam = false ;
60- showValue = false ;
61- compact = false ; // compact is currently a config-only setting and not supported in rs2f
62- showDespawn = false ;
63- notify = false ;
64- textAccent = null ;
65- textAccentColor = null ;
66- lootbeamColor = null ;
67- fontType = null ;
68- menuTextColor = null ;
69- highlightTile = null ;
70- tileStrokeColor = null ;
71- tileFillColor = null ;
72- hideOverlay = null ;
73- sound = null ;
74- menuSort = null ;
75- icon = null ;
76- evalTrace = new ArrayList <>() ;
55+ private DisplayConfig (Builder builder , List < Integer > evalTrace ) {
56+ compact = Box . unwrap ( builder . compact ) ;
57+ hidden = Box . unwrap ( builder . hidden ) ;
58+ hideOverlay = Box . unwrap ( builder . hideOverlay ) ;
59+ highlightTile = Box . unwrap ( builder . highlightTile ) ;
60+ notify = Box . unwrap ( builder . notify ) ;
61+ showDespawn = Box . unwrap ( builder . showDespawn ) ;
62+ showLootbeam = Box . unwrap ( builder . showLootbeam );
63+ showValue = Box . unwrap ( builder . showValue ) ;
64+ icon = Box . unwrap ( builder . icon ) ;
65+ backgroundColor = Box . unwrap ( builder . backgroundColor ) ;
66+ borderColor = Box . unwrap ( builder . borderColor ) ;
67+ lootbeamColor = Box . unwrap ( builder . lootbeamColor ) ;
68+ menuTextColor = Box . unwrap ( builder . menuTextColor ) ;
69+ textAccentColor = Box . unwrap ( builder . textAccentColor ) ;
70+ textColor = Box . unwrap ( builder . textColor ) ;
71+ tileFillColor = Box . unwrap ( builder . tileFillColor ) ;
72+ tileStrokeColor = Box . unwrap ( builder . tileStrokeColor ) ;
73+ fontType = Box . unwrap ( builder . fontType ) ;
74+ menuSort = Box . unwrap ( builder . menuSort ) ;
75+ sound = Box . unwrap ( builder . sound ) ;
76+ textAccent = Box . unwrap ( builder . textAccent ) ;
77+ this . evalTrace = evalTrace ;
7778 }
7879
7980 public SoundProvider getSound () {
@@ -120,41 +121,250 @@ public Color getTileStrokeColor() {
120121 return tileStrokeColor != null ? tileStrokeColor : textColor ;
121122 }
122123
123- public boolean isHidden () { return hidden != null && hidden ; }
124- public boolean isShowLootbeam () { return !isHidden () && showLootbeam != null && showLootbeam ; }
125- public boolean isShowValue () { return showValue != null && showValue ; }
126- public boolean isShowDespawn () { return showDespawn != null && showDespawn ; }
127- public boolean isNotify () { return !isHidden () && notify != null && notify ; }
128- public boolean isHighlightTile () { return !isHidden () && highlightTile != null && highlightTile ; }
129- public boolean isHideOverlay () { return isHidden () || (hideOverlay != null && hideOverlay ); }
124+ public boolean isHidden () {
125+ return hidden != null && hidden ;
126+ }
127+
128+ public boolean isShowLootbeam () {
129+ return !isHidden () && showLootbeam != null && showLootbeam ;
130+ }
131+
132+ public boolean isShowValue () {
133+ return showValue != null && showValue ;
134+ }
135+
136+ public boolean isShowDespawn () {
137+ return showDespawn != null && showDespawn ;
138+ }
139+
140+ public boolean isNotify () {
141+ return !isHidden () && notify != null && notify ;
142+ }
143+
144+ public boolean isHighlightTile () {
145+ return !isHidden () && highlightTile != null && highlightTile ;
146+ }
147+
148+ public boolean isHideOverlay () {
149+ return isHidden () || (hideOverlay != null && hideOverlay );
150+ }
130151
131152 public boolean isCompact () {
132153 return compact != null && compact ;
133154 }
134155
135- public DisplayConfig merge (DisplayConfig other ) {
136- var b = toBuilder ();
137- if (other .textColor != null ) { b .textColor (other .textColor ); }
138- if (other .backgroundColor != null ) { b .backgroundColor (other .backgroundColor ); }
139- if (other .borderColor != null ) { b .borderColor (other .borderColor ); }
140- if (other .hidden != null ) { b .hidden (other .hidden ); }
141- if (other .showLootbeam != null ) { b .showLootbeam (other .showLootbeam ); }
142- if (other .showValue != null ) { b .showValue (other .showValue ); }
143- if (other .compact != null ) { b .compact (other .compact ); }
144- if (other .showDespawn != null ) { b .showDespawn (other .showDespawn ); }
145- if (other .notify != null ) { b .notify (other .notify ); }
146- if (other .textAccent != null ) { b .textAccent (other .textAccent ); }
147- if (other .textAccentColor != null ) { b .textAccentColor (other .textAccentColor ); }
148- if (other .lootbeamColor != null ) { b .lootbeamColor (other .lootbeamColor ); }
149- if (other .fontType != null ) { b .fontType (other .fontType ); }
150- if (other .menuTextColor != null ) { b .menuTextColor (other .menuTextColor ); }
151- if (other .highlightTile != null ) { b .highlightTile (other .highlightTile ); }
152- if (other .tileStrokeColor != null ) { b .tileStrokeColor (other .tileStrokeColor ); }
153- if (other .tileFillColor != null ) { b .tileFillColor (other .tileFillColor ); }
154- if (other .hideOverlay != null ) { b .hideOverlay (other .hideOverlay ); }
155- if (other .sound != null ) { b .sound (other .sound ); }
156- if (other .menuSort != null ) { b .menuSort (other .menuSort ); }
157- if (other .icon != null ) { b .icon (other .icon ); }
158- return b .build ();
156+ public static class Builder {
157+ private Box <Boolean > compact ;
158+ private Box <Boolean > hidden ;
159+ private Box <Boolean > hideOverlay ;
160+ private Box <Boolean > highlightTile ;
161+ private Box <Boolean > notify ;
162+ private Box <Boolean > showDespawn ;
163+ private Box <Boolean > showLootbeam ;
164+ private Box <Boolean > showValue ;
165+ private Box <BufferedImageProvider > icon ;
166+ private Box <Color > backgroundColor ;
167+ private Box <Color > borderColor ;
168+ private Box <Color > lootbeamColor ;
169+ private Box <Color > menuTextColor ;
170+ private Box <Color > textAccentColor ;
171+ private Box <Color > textColor ;
172+ private Box <Color > tileFillColor ;
173+ private Box <Color > tileStrokeColor ;
174+ private Box <FontType > fontType ;
175+ private Box <Integer > menuSort ;
176+ private Box <SoundProvider > sound ;
177+ private Box <TextAccent > textAccent ;
178+
179+ private Builder () {
180+ }
181+
182+ public Builder compact (Boolean v ) {
183+ compact = Box .wrap (v );
184+ return this ;
185+ }
186+
187+ public Builder hidden (Boolean v ) {
188+ hidden = Box .wrap (v );
189+ return this ;
190+ }
191+
192+ public Builder hideOverlay (Boolean v ) {
193+ hideOverlay = Box .wrap (v );
194+ return this ;
195+ }
196+
197+ public Builder highlightTile (Boolean v ) {
198+ highlightTile = Box .wrap (v );
199+ return this ;
200+ }
201+
202+ public Builder notify (Boolean v ) {
203+ notify = Box .wrap (v );
204+ return this ;
205+ }
206+
207+ public Builder showDespawn (Boolean v ) {
208+ showDespawn = Box .wrap (v );
209+ return this ;
210+ }
211+
212+ public Builder showLootbeam (Boolean v ) {
213+ showLootbeam = Box .wrap (v );
214+ return this ;
215+ }
216+
217+ public Builder showValue (Boolean v ) {
218+ showValue = Box .wrap (v );
219+ return this ;
220+ }
221+
222+ public Builder icon (BufferedImageProvider v ) {
223+ icon = Box .wrap (v );
224+ return this ;
225+ }
226+
227+ public Builder backgroundColor (Color v ) {
228+ backgroundColor = Box .wrap (v );
229+ return this ;
230+ }
231+
232+ public Builder borderColor (Color v ) {
233+ borderColor = Box .wrap (v );
234+ return this ;
235+ }
236+
237+ public Builder lootbeamColor (Color v ) {
238+ lootbeamColor = Box .wrap (v );
239+ return this ;
240+ }
241+
242+ public Builder menuTextColor (Color v ) {
243+ menuTextColor = Box .wrap (v );
244+ return this ;
245+ }
246+
247+ public Builder textAccentColor (Color v ) {
248+ textAccentColor = Box .wrap (v );
249+ return this ;
250+ }
251+
252+ public Builder textColor (Color v ) {
253+ textColor = Box .wrap (v );
254+ return this ;
255+ }
256+
257+ public Builder tileFillColor (Color v ) {
258+ tileFillColor = Box .wrap (v );
259+ return this ;
260+ }
261+
262+ public Builder tileStrokeColor (Color v ) {
263+ tileStrokeColor = Box .wrap (v );
264+ return this ;
265+ }
266+
267+ public Builder fontType (FontType v ) {
268+ fontType = Box .wrap (v );
269+ return this ;
270+ }
271+
272+ public Builder menuSort (Integer v ) {
273+ menuSort = Box .wrap (v );
274+ return this ;
275+ }
276+
277+ public Builder sound (SoundProvider v ) {
278+ sound = Box .wrap (v );
279+ return this ;
280+ }
281+
282+ public Builder textAccent (TextAccent v ) {
283+ textAccent = Box .wrap (v );
284+ return this ;
285+ }
286+
287+ public void apply (Builder other ) {
288+ if (other .compact != null ) {
289+ compact = other .compact ;
290+ }
291+ if (other .hidden != null ) {
292+ hidden = other .hidden ;
293+ }
294+ if (other .hideOverlay != null ) {
295+ hideOverlay = other .hideOverlay ;
296+ }
297+ if (other .highlightTile != null ) {
298+ highlightTile = other .highlightTile ;
299+ }
300+ if (other .notify != null ) {
301+ notify = other .notify ;
302+ }
303+ if (other .showDespawn != null ) {
304+ showDespawn = other .showDespawn ;
305+ }
306+ if (other .showLootbeam != null ) {
307+ showLootbeam = other .showLootbeam ;
308+ }
309+ if (other .showValue != null ) {
310+ showValue = other .showValue ;
311+ }
312+ if (other .icon != null ) {
313+ icon = other .icon ;
314+ }
315+ if (other .backgroundColor != null ) {
316+ backgroundColor = other .backgroundColor ;
317+ }
318+ if (other .borderColor != null ) {
319+ borderColor = other .borderColor ;
320+ }
321+ if (other .lootbeamColor != null ) {
322+ lootbeamColor = other .lootbeamColor ;
323+ }
324+ if (other .menuTextColor != null ) {
325+ menuTextColor = other .menuTextColor ;
326+ }
327+ if (other .textAccentColor != null ) {
328+ textAccentColor = other .textAccentColor ;
329+ }
330+ if (other .textColor != null ) {
331+ textColor = other .textColor ;
332+ }
333+ if (other .tileFillColor != null ) {
334+ tileFillColor = other .tileFillColor ;
335+ }
336+ if (other .tileStrokeColor != null ) {
337+ tileStrokeColor = other .tileStrokeColor ;
338+ }
339+ if (other .fontType != null ) {
340+ fontType = other .fontType ;
341+ }
342+ if (other .menuSort != null ) {
343+ menuSort = other .menuSort ;
344+ }
345+ if (other .sound != null ) {
346+ sound = other .sound ;
347+ }
348+ if (other .textAccent != null ) {
349+ textAccent = other .textAccent ;
350+ }
351+ }
352+
353+ public DisplayConfig build (List <Integer > evalTrace ) {
354+ return new DisplayConfig (this , evalTrace );
355+ }
356+ }
357+
358+ @ AllArgsConstructor
359+ private static class Box <T > {
360+ public static <V > Box <V > wrap (V v ) {
361+ return new Box <>(v );
362+ }
363+
364+ public static <V > V unwrap (Box <V > b ) {
365+ return b != null ? b .value : null ;
366+ }
367+
368+ private final T value ;
159369 }
160370}
0 commit comments