-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/setting veto system fields #229
base: develop
Are you sure you want to change the base?
Changes from 5 commits
a19649c
8683962
69e977b
1b0ba79
33926a1
7824241
28e83e8
010b6db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -4,26 +4,41 @@ | |||||||||||||
import com.faforever.moderatorclient.ui.caches.SmallThumbnailCache; | ||||||||||||||
import com.faforever.moderatorclient.ui.data_cells.ListViewMapCell; | ||||||||||||||
import com.faforever.moderatorclient.ui.domain.MapPoolAssignmentFX; | ||||||||||||||
import com.faforever.moderatorclient.ui.domain.MapVersionFX; | ||||||||||||||
import com.faforever.moderatorclient.ui.domain.MatchmakerQueueMapPoolFX; | ||||||||||||||
import javafx.beans.binding.Bindings; | ||||||||||||||
import javafx.beans.property.FloatProperty; | ||||||||||||||
import javafx.beans.property.IntegerProperty; | ||||||||||||||
import javafx.beans.value.ChangeListener; | ||||||||||||||
import javafx.collections.ObservableList; | ||||||||||||||
import javafx.fxml.FXML; | ||||||||||||||
import javafx.scene.control.CheckBox; | ||||||||||||||
import javafx.scene.control.ListView; | ||||||||||||||
import javafx.scene.control.Spinner; | ||||||||||||||
import javafx.scene.control.SpinnerValueFactory; | ||||||||||||||
import javafx.scene.layout.HBox; | ||||||||||||||
import javafx.scene.layout.VBox; | ||||||||||||||
import javafx.util.converter.NumberStringConverter; | ||||||||||||||
import lombok.RequiredArgsConstructor; | ||||||||||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory; | ||||||||||||||
import org.springframework.context.annotation.Scope; | ||||||||||||||
import org.springframework.stereotype.Component; | ||||||||||||||
|
||||||||||||||
import java.util.Comparator; | ||||||||||||||
import lombok.extern.slf4j.Slf4j; | ||||||||||||||
|
||||||||||||||
@Component | ||||||||||||||
@RequiredArgsConstructor | ||||||||||||||
@Slf4j | ||||||||||||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) | ||||||||||||||
public class BracketListViewController implements Controller<VBox> { | ||||||||||||||
|
||||||||||||||
@FXML VBox root; | ||||||||||||||
@FXML ListView<MapPoolAssignmentFX> mapListView; | ||||||||||||||
public Spinner<Integer> vetoTokensPerPlayerSpinner; | ||||||||||||||
public Spinner<Integer> maxTokensPerMapSpinner; | ||||||||||||||
public Spinner<Double> minimumMapsAfterVetoSpinner; | ||||||||||||||
public CheckBox dynamicMaxTokensPerMapCheckBox; | ||||||||||||||
public HBox maxTokensPerMapHBox; | ||||||||||||||
@FXML | ||||||||||||||
VBox root; | ||||||||||||||
@FXML | ||||||||||||||
ListView<MapPoolAssignmentFX> mapListView; | ||||||||||||||
|
||||||||||||||
private final SmallThumbnailCache smallThumbnailCache; | ||||||||||||||
|
||||||||||||||
|
@@ -35,11 +50,38 @@ public VBox getRoot() { | |||||||||||||
@FXML | ||||||||||||||
public void initialize() { | ||||||||||||||
mapListView.setCellFactory(mapListView -> new ListViewMapCell(smallThumbnailCache)); | ||||||||||||||
vetoTokensPerPlayerSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 255, 0, 1)); | ||||||||||||||
maxTokensPerMapSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1,255,1,1)); | ||||||||||||||
minimumMapsAfterVetoSpinner.setValueFactory(new SpinnerValueFactory.DoubleSpinnerValueFactory(0.001, 255, 1, 0.5)); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
public void setMaps(ObservableList<MapPoolAssignmentFX> maps) { | ||||||||||||||
mapListView.prefHeightProperty().bind(Bindings.size(maps).multiply(70)); | ||||||||||||||
mapListView.setItems(maps); | ||||||||||||||
// mapListView.setItems(maps.sorted(Comparator.comparing(MapPoolAssignmentFX::getId))); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
public void bindVetoParams(MatchmakerQueueMapPoolFX bracket) { | ||||||||||||||
dynamicMaxTokensPerMapCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> { | ||||||||||||||
if (newValue){ | ||||||||||||||
log.debug(String.valueOf(bracket.maxTokensPerMapProperty().get())); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This log statement isn't needed anymore |
||||||||||||||
maxTokensPerMapSpinner.setDisable(true); | ||||||||||||||
bracket.maxTokensPerMapProperty().set(0); | ||||||||||||||
} else { | ||||||||||||||
bracket.maxTokensPerMapProperty().set(1); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
maxTokensPerMapSpinner.setDisable(false); | ||||||||||||||
} | ||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
dynamicMaxTokensPerMapCheckBox.setSelected(bracket.maxTokensPerMapProperty().get() == 0); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
|
||||||||||||||
maxTokensPerMapSpinner.getValueFactory().setValue(bracket.maxTokensPerMapProperty().get()); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
maxTokensPerMapSpinner.valueProperty().addListener((observable, oldValue, newValue) -> bracket.maxTokensPerMapProperty().set(newValue)); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
|
||||||||||||||
vetoTokensPerPlayerSpinner.getValueFactory().setValue(bracket.vetoTokensPerPlayerProperty().get()); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
vetoTokensPerPlayerSpinner.valueProperty().addListener((observable, oldValue, newValue) -> bracket.vetoTokensPerPlayerProperty().set(newValue)); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
|
||||||||||||||
minimumMapsAfterVetoSpinner.getValueFactory().setValue(bracket.minimumMapsAfterVetoProperty().get()); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
minimumMapsAfterVetoSpinner.valueProperty().addListener((observable, oldValue, newValue) -> bracket.minimumMapsAfterVetoProperty().set(newValue)); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
} | ||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,9 @@ | |
import com.faforever.commons.api.dto.MatchmakerQueue; | ||
import com.faforever.commons.api.dto.MatchmakerQueueMapPool; | ||
import com.faforever.commons.api.dto.NeroxisGeneratorParams; | ||
import com.faforever.commons.api.elide.ElideNavigator; | ||
import com.faforever.commons.api.elide.ElideNavigatorOnId; | ||
import com.faforever.moderatorclient.api.FafApiCommunicationService; | ||
import com.faforever.moderatorclient.api.domain.MapService; | ||
import com.faforever.moderatorclient.mapstruct.MapPoolAssignmentMapper; | ||
import com.faforever.moderatorclient.mapstruct.MatchmakerQueueMapPoolMapper; | ||
|
@@ -64,6 +67,7 @@ public class LadderMapPoolController implements Controller<SplitPane> { | |
public static final double MIN_MAP_SIZE_STEP = 1.25; | ||
private final MapService mapService; | ||
private final UiService uiService; | ||
private final FafApiCommunicationService apiService; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should only need mapService |
||
private final MatchmakerQueueMapPoolMapper matchmakerQueueMapPoolMapper; | ||
private final MapPoolAssignmentMapper mapPoolAssignmentMapper; | ||
private final LargeThumbnailCache largeThumbnailCache; | ||
|
@@ -174,6 +178,7 @@ private void loadMatchMakerQueue(MatchmakerQueue matchmakerQueue) { | |
|
||
// create the bracket list views | ||
BracketListViewController listViewController = uiService.loadFxml("ui/main_window/bracketListView.fxml"); | ||
listViewController.bindVetoParams(bracketFX); | ||
listViewController.setMaps(bracketAssignments); | ||
listViewController.mapListView.prefWidthProperty().bind((bracketsScrollPane.widthProperty().divide(bracketsFX.size())).subtract(16 / bracketsFX.size())); | ||
bracketListContainer.getChildren().add(listViewController.getRoot()); | ||
|
@@ -187,6 +192,19 @@ private void loadMatchMakerQueue(MatchmakerQueue matchmakerQueue) { | |
bindSelectedMapPropertyToAddRemoveButtons(bracketAssignments, addBracketController, bracketFX.getMapPool()); | ||
} | ||
uploadToDatabaseButton.setOnAction(event -> { | ||
for (MatchmakerQueueMapPoolFX bracketFX : bracketsFX) { | ||
ElideNavigatorOnId<MatchmakerQueueMapPool> navigator = ElideNavigator.of(MatchmakerQueueMapPool.class) | ||
.id(bracketFX.getId()); | ||
MatchmakerQueueMapPool dto = matchmakerQueueMapPoolMapper.mapToDto(bracketFX); | ||
dto.setMapPool(null); | ||
dto.setCreateTime(null); | ||
dto.setMinRating(null); | ||
dto.setMaxRating(null); | ||
dto.setMatchmakerQueue(null); | ||
dto.setUpdateTime(null); | ||
apiService.patch(navigator, dto); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a method inside mapService There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. like the changes to mappoolassignments below |
||
} | ||
|
||
List<MapPoolAssignment> oldMapPoolAssignments = mapService.getListOfMapsInBrackets(brackets); | ||
List<MapPoolAssignmentFX> oldMapPoolAssignmentsFX = mapPoolAssignmentMapper.mapToFX(oldMapPoolAssignments); | ||
List<MapPoolAssignmentFX> bracketMapPoolAssignments = bracketLists.stream() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would follow convention and make these not public and use @FXML