44import com .faforever .client .domain .api .MapPoolAssignment ;
55import com .faforever .client .domain .api .MapVersion ;
66import com .faforever .client .fx .ImageViewHelper ;
7+ import com .faforever .client .fx .NodeController ;
78import com .faforever .client .i18n .I18n ;
89import com .faforever .client .map .MapService ;
9- import com .faforever .client .fx .NodeController ;
1010import com .faforever .client .map .MapService .PreviewSize ;
1111import com .faforever .client .map .generator .MapGeneratorService ;
1212import com .faforever .client .preferences .MatchmakerPrefs ;
2525import javafx .scene .image .ImageView ;
2626import javafx .scene .layout .HBox ;
2727import javafx .scene .layout .Pane ;
28- import javafx .scene .layout .VBox ;
2928import javafx .scene .layout .Region ;
29+ import javafx .scene .layout .VBox ;
3030import lombok .RequiredArgsConstructor ;
3131import lombok .Setter ;
3232import org .springframework .beans .factory .config .ConfigurableBeanFactory ;
3333import org .springframework .context .annotation .Scope ;
3434import org .springframework .stereotype .Component ;
35+
3536import java .util .function .Consumer ;
3637
3738/**
@@ -101,9 +102,10 @@ void setVetoModeEnabled(BooleanProperty vetoModeEnabled) {
101102 public void bindVetoModeDependentProperties () {
102103 vetoesBox .mouseTransparentProperty ().bind (vetoModeEnabled .not ());
103104 vetoesBox .visibleProperty ().bind (vetoModeEnabled .or (tokenCount .greaterThan (0 )));
104- root .cursorProperty ().bind (Bindings .when (
105- Bindings .createBooleanBinding (() -> isGeneratedMap .getValue () || vetoModeEnabled .get (), isGeneratedMap , vetoModeEnabled )
106- ).then (Cursor .DEFAULT ).otherwise (Cursor .HAND ));
105+ root .cursorProperty ()
106+ .bind (Bindings .when (
107+ Bindings .createBooleanBinding (() -> isGeneratedMap .getValue () || vetoModeEnabled .get (), isGeneratedMap ,
108+ vetoModeEnabled )).then (Cursor .DEFAULT ).otherwise (Cursor .HAND ));
107109 }
108110
109111 @ Override
@@ -112,9 +114,9 @@ protected void onInitialize() {
112114 isGeneratedMap = mapObservable .map (map -> mapGeneratorService .isGeneratedMap (map .displayName ())).orElse (false );
113115
114116 thumbnailImageView .imageProperty ()
115- .bind (assignment
116- . map ( assignmentBean -> mapService .loadPreview (assignmentBean .mapVersion (), PreviewSize .SMALL ))
117- .flatMap (imageViewHelper ::createPlaceholderImageOnErrorObservable ));
117+ .bind (assignment . map (
118+ assignmentBean -> mapService .loadPreview (assignmentBean .mapVersion (), PreviewSize .SMALL ))
119+ .flatMap (imageViewHelper ::createPlaceholderImageOnErrorObservable ));
118120
119121 nameLabel .textProperty ().bind (mapObservable .map (map -> {
120122 if (isGeneratedMap .getValue ()) {
@@ -123,9 +125,7 @@ protected void onInitialize() {
123125 return map .displayName ();
124126 }));
125127
126- authorBox .visibleProperty ()
127- .bind (mapObservable .map (
128- map -> (map .author () != null ) || isGeneratedMap .getValue ()));
128+ authorBox .visibleProperty ().bind (mapObservable .map (map -> (map .author () != null ) || isGeneratedMap .getValue ()));
129129 authorBox .managedProperty ().bind (authorBox .visibleProperty ());
130130
131131 authorLabel .textProperty ().bind (mapObservable .map (map -> {
@@ -165,27 +165,26 @@ protected void onInitialize() {
165165 });
166166
167167 vetoButton .setOnAction (event -> {
168- if (assignment .getValue () == null ) {
168+ MapPoolAssignment value = assignment .getValue ();
169+ if (value == null ) {
169170 return ;
170171 }
171172 int currentTokenCount = tokenCount .get ();
172173 int currentMaxPerMap = maxPerMap .get ();
173174 if ((isMaxPerMapDynamic .get () || currentTokenCount < currentMaxPerMap ) && currentTokenCount < vetoTokensMax .get () && vetoTokensLeft .getValue () > 0 ) {
174- teamMatchmakingService .setTokensForMap (
175- new VetoKey (assignment .getValue ().mapPool ().mapPool ().id (), assignment .getValue ().id ()),
176- currentTokenCount + 1 );
175+ teamMatchmakingService .setTokensForMap (VetoKey .of (value ), currentTokenCount + 1 );
177176 }
178177 event .consume ();
179178 });
180179
181180 minusButton .setOnAction (event -> {
182- if (assignment .getValue () == null ) {
181+ MapPoolAssignment value = assignment .getValue ();
182+ if (value == null ) {
183183 return ;
184184 }
185185 int current = tokenCount .get ();
186186 if (current > 0 ) {
187- teamMatchmakingService .setTokensForMap (
188- new VetoKey (assignment .getValue ().mapPool ().mapPool ().id (), assignment .getValue ().id ()), current - 1 );
187+ teamMatchmakingService .setTokensForMap (VetoKey .of (value ), current - 1 );
189188 }
190189 event .consume ();
191190 });
@@ -213,11 +212,12 @@ private void updateBannedState() {
213212 }
214213
215214 private void updateVetoes () {
216- if (assignment .getValue () == null ) {
215+ MapPoolAssignment value = assignment .getValue ();
216+ if (value == null ) {
217217 tokenCount .set (0 );
218218 return ;
219219 }
220- VetoKey key = new VetoKey ( assignment . getValue (). mapPool (). mapPool (). id (), assignment . getValue (). id () );
220+ VetoKey key = VetoKey . of ( value );
221221 int usedTokens = matchmakerPrefs .getAppliedVetoes ().getOrDefault (key , 0 );
222222 tokenCount .set (usedTokens );
223223 }
0 commit comments