Skip to content
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

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

Spikey84
Copy link

Makes many improvements to the matchmaker tab of the client. Tested on linux, should work on windows too.

  • Made map vault search async
  • Removed the need for * to search for wildcards. Now u can search ‘wonder’ and see any map with that string in the title.
  • Added a map favoriting system. This can probably be further optimized in the future.You can leave the search bar empty and checkbox checked to get all favorited maps, but this is super slow since it is loading all maps then filtering out unfavorited ones.
  • Fixed mapgen info to be visible. I need to make the size number human readable next.
  • Added a button to remove all maps in a bracket. This should speed up making new pools without losing too much control.
  • Added a zoom in button for maps. This makes sure that you can see the map thumbnail better.

@Spikey84 Spikey84 changed the title Matchmaker overhaul Matchmaker Overhaul Oct 19, 2023
});
writer.close();
} catch (IOException e) {
e.printStackTrace();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logging as above

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines +65 to +67
public MapTableItemAdapter getThis() {
return this;
}
Copy link
Member

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.

Copy link
Author

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

Copy link
Author

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]```

Copy link
Member

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

Copy link
Member

@Sheikah45 Sheikah45 Oct 28, 2023

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()

Copy link
Member

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

public void addFavorite(MapTableItemAdapter mapTableItemAdapter) {
System.out.println(mapTableItemAdapter.getId());
System.out.println(mapTableItemAdapter.getMap().getId());
if (favoritesCache.contains(Integer.parseInt(mapTableItemAdapter.getId()))) return;
Copy link
Member

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.

@Spikey84
Copy link
Author

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));
Copy link
Member

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

Copy link
Author

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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullability of addFavorite

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member

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

Copy link
Member

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.*;
Copy link
Member

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member

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());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bracketAssignments.clear() is easier

Copy link
Author

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();
Copy link
Member

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

Comment on lines +418 to +423
File pwd = new File("").getAbsoluteFile();
File file = new File(pwd.getAbsoluteFile() + File.separator + "favoriteMaps.txt");

if (!file.exists()) {
file.createNewFile();
}
Copy link
Member

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.

@Spikey84
Copy link
Author

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;
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants