Skip to content

Commit

Permalink
Fixed vps view
Browse files Browse the repository at this point in the history
  • Loading branch information
syd711 committed Nov 15, 2024
1 parent 4f0b666 commit e729c67
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 54 deletions.
2 changes: 1 addition & 1 deletion resources/vpsdb.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
@Override
public void onViewActivated(NavigationOptions options) {
// first time activation
if (models == null) {
if (models == null || models.isEmpty()) {
this.doReload(false);
}
VpsTableModel selection = tableView.getSelectionModel().getSelectedItem();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ public class VpsTablesFilterController extends BaseFilterController<VpsTable, Vp
@FXML
private CheckBox withTutorial;

@FXML
private CheckBox withPov;

//------------------------------------------------------

private VpsTablesPredicateFactory predicateFactory = new VpsTablesPredicateFactory();
Expand Down Expand Up @@ -135,6 +138,7 @@ protected void resetFilters() {
withAltSound.setSelected(false);
withAltColor.setSelected(false);
withTutorial.setSelected(false);
withPov.setSelected(false);
}

protected boolean hasFilter() {
Expand Down Expand Up @@ -251,6 +255,11 @@ public void updateItem(LocalDate date, boolean empty) {
predicateFactory.setWithTutorial(newValue);
applyFilters();
});
withPov.setSelected(predicateFactory.isWithPov());
withPov.selectedProperty().addListener((observable, oldValue, newValue) -> {
predicateFactory.setWithPov(newValue);
applyFilters();
});

// create Checkboxes for features
featureCheckboxes = new LinkedHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import de.mephisto.vpin.connectors.vps.model.VpsTableVersion;
import de.mephisto.vpin.ui.vps.VpsTablesController.VpsTableModel;

class VpsTablesPredicateFactory {
class VpsTablesPredicateFactory {

private String[] tableFormats;

Expand All @@ -39,6 +39,7 @@ class VpsTablesPredicateFactory {
private boolean withAltSound;
private boolean withAltColor;
private boolean withTutorial;
private boolean withPov;

private LinkedHashMap<String, Boolean> features = new LinkedHashMap<>();

Expand All @@ -49,48 +50,55 @@ public void setTableFormats(String[] tableFormats) {
public boolean isInstalledOnly() {
return installedOnly;
}

public void setInstalledOnly(boolean installedOnly) {
this.installedOnly = installedOnly;
}

public boolean isNotInstalledOnly() {
return notInstalledOnly;
}

public void setNotInstalledOnly(boolean notInstalledOnly) {
this.notInstalledOnly = notInstalledOnly;
}

public LocalDate getLastUpdateDate() {
return lastUpdateDate;
}

public void setLastUpdateDate(LocalDate lastUpdateDate) {
this.lastUpdateDate = lastUpdateDate;
}

public String getAuthor() {
return StringUtils.join(authors, ", ");
}

public void setAuthor(String author) {
this.authors = splitAndTrim(author, ",;");
}

public boolean isSearchAuthorInOtherAssetsToo() {
return searchAuthorInOtherAssetsToo;
}

public void setSearchAuthorInOtherAssetsToo(boolean searchAuthorInOtherAssetsToo) {
this.searchAuthorInOtherAssetsToo = searchAuthorInOtherAssetsToo;
}

public String getManufacturer() {
return StringUtils.join(manufacturers, ", ");
}

public void setManufacturer(String manufacturer) {
this.manufacturers = splitAndTrim(manufacturer, ",;");
this.manufacturers = splitAndTrim(manufacturer, ",;");
}

public String getTheme() {
return theme;
}

public void setTheme(String theme) {
this.theme = theme;
}
Expand All @@ -99,72 +107,91 @@ public void setTheme(String theme) {
public boolean isWithTutorial() {
return withTutorial;
}

public void setWithTutorial(boolean withRes) {
this.withTutorial = withRes;
}

public boolean isWithPov() {
return withPov;
}

public void setWithPov(boolean withPov) {
this.withPov = withPov;
}

public boolean isWithRom() {
return withRom;
}

public void setWithRom(boolean withPov) {
this.withRom = withPov;
}

public boolean isWithTopper() {
return withTopper;
}

public void setWithTopper(boolean withIni) {
this.withTopper = withIni;
}

public boolean isWithBackglass() {
return withBackglass;
}

public void setWithBackglass(boolean withBackglass) {
this.withBackglass = withBackglass;
}

public boolean isWithPupPack() {
return withPupPack;
}

public void setWithPupPack(boolean withPupPack) {
this.withPupPack = withPupPack;
}

public boolean isWithAltSound() {
return withAltSound;
}

public void setWithAltSound(boolean withAltSound) {
this.withAltSound = withAltSound;
}

public boolean isWithAltColor() {
return withAltColor;
}

public void setWithAltColor(boolean withAltColor) {
this.withAltColor = withAltColor;
}

public boolean isWithWheel() {
return withWheel;
}

public void setWithWheel(boolean withWheel) {
this.withWheel = withWheel;
}

public boolean isVpsUpdates() {
return vpsUpdates;
}

public void setVpsUpdates(boolean vpsUpdates) {
this.vpsUpdates = vpsUpdates;
}

public void registerFeature(String feature) {
features.put(feature, Boolean.FALSE);
}

public boolean isSelectedFeature(String feature) {
return features.containsKey(feature) && features.get(feature);
}

public boolean toggleFeature(String feature) {
if (features.containsKey(feature)) {
boolean newstate = !features.get(feature);
Expand All @@ -176,21 +203,21 @@ public boolean toggleFeature(String feature) {

public boolean isResetted() {
return isFeaturesFilterEmpty()
&& lastUpdateDate == null
&& (authors == null || authors.length == 0)
&& (manufacturers == null || manufacturers.length == 0)
&& StringUtils.isEmpty(theme)
&& !this.vpsUpdates
&& !installedOnly
&& !notInstalledOnly
&& !this.withAltColor
&& !this.withAltSound
&& !this.withBackglass
&& !this.withTopper
&& !this.withWheel
&& !this.withRom
&& !this.withTutorial
&& !this.withPupPack;
&& lastUpdateDate == null
&& (authors == null || authors.length == 0)
&& (manufacturers == null || manufacturers.length == 0)
&& StringUtils.isEmpty(theme)
&& !this.vpsUpdates
&& !installedOnly
&& !notInstalledOnly
&& !this.withAltColor
&& !this.withAltSound
&& !this.withBackglass
&& !this.withTopper
&& !this.withWheel
&& !this.withRom
&& !this.withTutorial
&& !this.withPupPack;
}

public boolean isFeaturesFilterEmpty() {
Expand Down Expand Up @@ -223,16 +250,16 @@ public boolean test(VpsTableModel model) {

if (lastUpdateDate != null) {
LocalDate updated = Instant.ofEpochMilli(table.getUpdatedAt())
.atZone(ZoneId.systemDefault()).toLocalDate();
.atZone(ZoneId.systemDefault()).toLocalDate();
if (lastUpdateDate.compareTo(updated) > 0) {
return false;
}
}

if (StringUtils.isNotEmpty(searchTerm)
&& !StringUtils.containsIgnoreCase(table.getName(), searchTerm)
//&& !StringUtils.containsIgnoreCase(table.getRom(), filterValue)
) {
//&& !StringUtils.containsIgnoreCase(table.getRom(), filterValue)
) {
return false;
}

Expand Down Expand Up @@ -286,21 +313,26 @@ public boolean test(VpsTableModel model) {
if (isWithTutorial() && !VpsUtil.isDataAvailable(table.getTutorialFiles())) {
return false;
}
if (isWithPov() && !VpsUtil.isDataAvailable(table.getPovFiles())) {
return false;
}

// As this filter is a bit heavy, keep it last
if (searchAuthorInOtherAssetsToo) {
if (!containsAnyAuthor(table.getTableFiles(), authors)
&& !containsAnyAuthor(table.getB2sFiles(), authors)
&& !containsAnyAuthor(table.getPupPackFiles(), authors)
&& !containsAnyAuthor(table.getTopperFiles(), authors)
&& !containsAnyAuthor(table.getWheelArtFiles(), authors)
&& !containsAnyAuthor(table.getAltColorFiles(), authors)
&& !containsAnyAuthor(table.getAltSoundFiles(), authors)
&& !containsAnyAuthor(table.getTutorialFiles(), authors)
&& !containsAnyAuthor(table.getB2sFiles(), authors)
&& !containsAnyAuthor(table.getPupPackFiles(), authors)
&& !containsAnyAuthor(table.getTopperFiles(), authors)
&& !containsAnyAuthor(table.getWheelArtFiles(), authors)
&& !containsAnyAuthor(table.getAltColorFiles(), authors)
&& !containsAnyAuthor(table.getAltSoundFiles(), authors)
&& !containsAnyAuthor(table.getTutorialFiles(), authors)
&& !containsAnyAuthor(table.getPovFiles(), authors)
) {
return false;
}
} else {
}
else {
if (!containsAnyAuthor(table.getTableFiles(), authors)) {
return false;
}
Expand All @@ -316,7 +348,7 @@ public Predicate<VpsTableVersion> buildTableVersionPredicate() {
return new Predicate<VpsTableVersion>() {
@Override
public boolean test(VpsTableVersion version) {

if (tableFormats != null && !containsIgnoreCase(tableFormats, version.getTableFormat())) {
return false;
}
Expand All @@ -331,7 +363,7 @@ public boolean test(VpsTableVersion version) {

if (lastUpdateDate != null) {
LocalDate updated = Instant.ofEpochMilli(version.getUpdatedAt())
.atZone(ZoneId.systemDefault()).toLocalDate();
.atZone(ZoneId.systemDefault()).toLocalDate();
if (lastUpdateDate.compareTo(updated) > 0) {
return false;
}
Expand All @@ -350,7 +382,7 @@ public Predicate<VpsAuthoredUrls> buildAuthoredUrlsPredicate() {
return new Predicate<VpsAuthoredUrls>() {
@Override
public boolean test(VpsAuthoredUrls url) {

if (searchAuthorInOtherAssetsToo && !containsAnyAuthor(url, authors)) {
return false;
}
Expand Down Expand Up @@ -430,26 +462,27 @@ protected boolean containsAnyAuthor(List<? extends VpsAuthoredUrls> urls, String
}
}
return false;
}
protected boolean containsAnyAuthor(VpsAuthoredUrls url, String[] _authors) {
if (_authors == null || _authors.length == 0) {
return true;
}
if (url != null) {
if (url.getAuthors() != null) {
for (String author : url.getAuthors()) {
if (containsAnyIgnoreCase(author, _authors)) {
return true;
}

protected boolean containsAnyAuthor(VpsAuthoredUrls url, String[] _authors) {
if (_authors == null || _authors.length == 0) {
return true;
}
if (url != null) {
if (url.getAuthors() != null) {
for (String author : url.getAuthors()) {
if (containsAnyIgnoreCase(author, _authors)) {
return true;
}
}
}
}
return false;
}
return false;
}


protected String[] splitAndTrim(String input, String separators) {
if(input != null) {
if (input != null) {
String[] splitted = StringUtils.split(input, separators);
for (int i = 0; i < splitted.length; i++) {
splitted[i] = splitted[i].trim();
Expand Down
Loading

0 comments on commit e729c67

Please sign in to comment.