-
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
Matchmaker Overhaul #190
base: develop
Are you sure you want to change the base?
Matchmaker Overhaul #190
Conversation
src/main/java/com/faforever/moderatorclient/ui/main_window/LadderMapPoolController.java
Outdated
Show resolved
Hide resolved
src/main/java/com/faforever/moderatorclient/ui/main_window/LadderMapPoolController.java
Outdated
Show resolved
Hide resolved
src/main/java/com/faforever/moderatorclient/ui/main_window/LadderMapPoolController.java
Outdated
Show resolved
Hide resolved
src/main/java/com/faforever/moderatorclient/ui/main_window/LadderMapPoolController.java
Outdated
Show resolved
Hide resolved
src/main/java/com/faforever/moderatorclient/ui/main_window/LadderMapPoolController.java
Outdated
Show resolved
Hide resolved
}); | ||
writer.close(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); |
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.
logging as above
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.
Done.
public MapTableItemAdapter getThis() { | ||
return this; | ||
} |
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.
Makes no sense, please remove.
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.
This is dumb, i wonder why i did this lol
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.
When I remove this the favorite button breaks. I have no idea why, the getThis method is never called.
at com.sun.javafx.property.PropertyReference.getProperty(PropertyReference.java:191) ~[javafx-base-21-ea+24-linux.jar:na]
at javafx.scene.control.cell.TreeItemPropertyValueFactory.getCellDataReflectively(TreeItemPropertyValueFactory.java:184) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.cell.TreeItemPropertyValueFactory.call(TreeItemPropertyValueFactory.java:157) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.cell.TreeItemPropertyValueFactory.call(TreeItemPropertyValueFactory.java:135) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.TreeTableColumn.getCellObservableValue(TreeTableColumn.java:578) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.TreeTableColumn.getCellObservableValue(TreeTableColumn.java:563) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.TreeTableCell.updateItem(TreeTableCell.java:676) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.TreeTableCell.indexChanged(TreeTableCell.java:482) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.IndexedCell$1.invalidated(IndexedCell.java:85) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.beans.property.IntegerPropertyBase.markInvalid(IntegerPropertyBase.java:113) ~[javafx-base-21-ea+24-linux.jar:na]
at javafx.beans.property.IntegerPropertyBase.set(IntegerPropertyBase.java:148) ~[javafx-base-21-ea+24-linux.jar:na]
at javafx.scene.control.IndexedCell.updateIndex(IndexedCell.java:130) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.skin.TableRowSkinBase.updateCells(TableRowSkinBase.java:525) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.skin.TreeTableRowSkin.updateCells(TreeTableRowSkin.java:280) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.skin.TableRowSkinBase.<init>(TableRowSkinBase.java:155) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.skin.TreeTableRowSkin.<init>(TreeTableRowSkin.java:90) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.TreeTableRow.createDefaultSkin(TreeTableRow.java:536) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.Control.doProcessCSS(Control.java:910) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.Control$1.doProcessCSS(Control.java:88) ~[javafx-controls-21-ea+24-linux.jar:na]
at com.sun.javafx.scene.control.ControlHelper.processCSSImpl(ControlHelper.java:68) ~[javafx-controls-21-ea+24-linux.jar:na]
at com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:147) ~[javafx-graphics-21-ea+24-linux.jar:na]
at javafx.scene.Node.processCSS(Node.java:9555) ~[javafx-graphics-21-ea+24-linux.jar:na]
at javafx.scene.Node.applyCss(Node.java:9642) ~[javafx-graphics-21-ea+24-linux.jar:na]
at javafx.scene.control.skin.VirtualFlow.setCellIndex(VirtualFlow.java:1819) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.skin.VirtualFlow.getCell(VirtualFlow.java:1796) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.skin.VirtualFlow.getOrCreateCellSize(VirtualFlow.java:3068) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.skin.VirtualFlow.getOrCreateCellSize(VirtualFlow.java:3040) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.skin.VirtualFlow.recalculateAndImproveEstimatedSize(VirtualFlow.java:3144) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.skin.VirtualFlow$5.invalidated(VirtualFlow.java:865) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.beans.property.IntegerPropertyBase.markInvalid(IntegerPropertyBase.java:113) ~[javafx-base-21-ea+24-linux.jar:na]
at javafx.beans.property.IntegerPropertyBase.set(IntegerPropertyBase.java:148) ~[javafx-base-21-ea+24-linux.jar:na]
at javafx.scene.control.skin.VirtualFlow.setCellCount(VirtualFlow.java:911) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.skin.TreeTableViewSkin.updateItemCount(TreeTableViewSkin.java:354) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.skin.VirtualContainerBase.checkState(VirtualContainerBase.java:183) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.skin.VirtualContainerBase.layoutChildren(VirtualContainerBase.java:158) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.skin.TableViewSkinBase.layoutChildren(TableViewSkinBase.java:432) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.Control.layoutChildren(Control.java:612) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.control.TreeTableView.layoutChildren(TreeTableView.java:1681) ~[javafx-controls-21-ea+24-linux.jar:na]
at javafx.scene.Parent.layout(Parent.java:1208) ~[javafx-graphics-21-ea+24-linux.jar:na]
at javafx.scene.Parent.layout(Parent.java:1215) ~[javafx-graphics-21-ea+24-linux.jar:na]
at javafx.scene.Parent.layout(Parent.java:1215) ~[javafx-graphics-21-ea+24-linux.jar:na]
at javafx.scene.Parent.layout(Parent.java:1215) ~[javafx-graphics-21-ea+24-linux.jar:na]
at javafx.scene.Parent.layout(Parent.java:1215) ~[javafx-graphics-21-ea+24-linux.jar:na]
at javafx.scene.Parent.layout(Parent.java:1215) ~[javafx-graphics-21-ea+24-linux.jar:na]
at javafx.scene.Parent.layout(Parent.java:1215) ~[javafx-graphics-21-ea+24-linux.jar:na]
at javafx.scene.Parent.layout(Parent.java:1215) ~[javafx-graphics-21-ea+24-linux.jar:na]
at javafx.scene.Parent.layout(Parent.java:1215) ~[javafx-graphics-21-ea+24-linux.jar:na]
at javafx.scene.Scene.doLayoutPass(Scene.java:594) ~[javafx-graphics-21-ea+24-linux.jar:na]
at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2600) ~[javafx-graphics-21-ea+24-linux.jar:na]
at com.sun.javafx.tk.Toolkit.lambda$runPulse$2(Toolkit.java:401) ~[javafx-graphics-21-ea+24-linux.jar:na]
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) ~[na:na]
at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:400) ~[javafx-graphics-21-ea+24-linux.jar:na]
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:430) ~[javafx-graphics-21-ea+24-linux.jar:na]
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:592) ~[javafx-graphics-21-ea+24-linux.jar:na]
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:572) ~[javafx-graphics-21-ea+24-linux.jar:na]
at com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:565) ~[javafx-graphics-21-ea+24-linux.jar:na]
at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$11(QuantumToolkit.java:352) ~[javafx-graphics-21-ea+24-linux.jar:na]
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) ~[javafx-graphics-21-ea+24-linux.jar:na]
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method) ~[javafx-graphics-21-ea+24-linux.jar:na]
at com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$10(GtkApplication.java:263) ~[javafx-graphics-21-ea+24-linux.jar:na]```
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.
Maybe @Sheikah45 can help here
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.
It is because of line 1009 in the ViewHelper, you are creating a TreeItemPropertyValueFactory where you specify the property as this. So it is going to look for a getThis method to retrieve the property.
It would be better to change that cell factory to a lambda that provides the value like item -> item.getValue().valueProperty()
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.
Generally for all of those I would use a lambda function rather than relying on the string name of the property to expect a getter. It is better for refactor and type safety
src/main/java/com/faforever/moderatorclient/FafModeratorClientApplication.java
Outdated
Show resolved
Hide resolved
src/main/java/com/faforever/moderatorclient/ui/main_window/LadderMapPoolController.java
Outdated
Show resolved
Hide resolved
public void addFavorite(MapTableItemAdapter mapTableItemAdapter) { | ||
System.out.println(mapTableItemAdapter.getId()); | ||
System.out.println(mapTableItemAdapter.getMap().getId()); | ||
if (favoritesCache.contains(Integer.parseInt(mapTableItemAdapter.getId()))) return; |
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.
This whole integer parsing is EVERYWHERE. It seems much simpler to just use string everywhere.
Will take care of all this tonight. Thanks for the review. |
if (!empty && item != null && !item.isMapVersion()) { | ||
if (ladderMapPoolController.isMapFavorite(Integer.parseInt(item.getId()))) { | ||
Button button = new Button("Unfavorite"); | ||
button.setOnMouseClicked(event -> removeFavorite.accept(item)); |
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.
You have removeFavorite marked as nullable but no null check here
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.
Done.
return; | ||
} else { | ||
Button button = new Button("Favorite"); | ||
button.setOnMouseClicked(event -> addFavorite.accept(item)); |
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.
nullability of addFavorite
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.
Done.
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.
What was changed here? I don't even know what @Sheikah45 refers to O.o
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.
addFavorite is marked as nullable in the method parameters But there is no check to see if it is nonNull before calling accept on it. @Spikey84 I meant checking for null on addFavorite and removeFavorite not the item
import org.apache.maven.artifact.versioning.ComparableVersion; | ||
import org.springframework.core.io.ClassPathResource; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.io.IOException; | ||
import java.io.*; |
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.
Personally I prefer not to use star imports to reduce name collisions
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.
Done.
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.
There are still some on import com.faforever.commons.api.dto.*;
This is a setting you can do in your IDE. Many IDEs like to summarize them to wildcard imports :(
@@ -182,10 +216,16 @@ private void loadMatchMakerQueue(MatchmakerQueue matchmakerQueue) { | |||
AddBracketController addBracketController = uiService.loadFxml("ui/main_window/addBracketLabelAndButton.fxml"); | |||
addBracketController.setRatingLabelText(getBracketRatingString(bracketFX)); | |||
addButtonsContainer.getChildren().add(addBracketController.getRoot()); | |||
Button button = new Button("--"); | |||
button.setOnAction((event -> { | |||
bracketAssignments.removeAll(bracketAssignments.stream().toList()); |
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.
bracketAssignments.clear() is easier
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.
Done.
} | ||
}; | ||
|
||
new Thread(task).start(); |
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.
Rather than just creating threads and starting them it would be better to set up an executor service to execute them. Since this is spring boot one should even be pre configured that you just need to autowire into the class
File pwd = new File("").getAbsoluteFile(); | ||
File file = new File(pwd.getAbsoluteFile() + File.separator + "favoriteMaps.txt"); | ||
|
||
if (!file.exists()) { | ||
file.createNewFile(); | ||
} |
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.
Meh even, I would probably suggest just using an ObjectMapper and saving the preferences as json file similar to how we do in the client.
It escapes the custom encoding and makes it easy to add to later.
src/main/java/com/faforever/moderatorclient/ui/main_window/LadderMapPoolController.java
Outdated
Show resolved
Hide resolved
Im going to wait for another time to redo the cache system and figure out the threadpool thing. |
@@ -2,6 +2,7 @@ | |||
|
|||
import com.faforever.moderatorclient.ui.Controller; | |||
import javafx.fxml.FXML; | |||
import javafx.scene.control.Button; |
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.
You gotta optimize the imports. Since there is no other change to this file it must be unused.
Makes many improvements to the matchmaker tab of the client. Tested on linux, should work on windows too.