Skip to content

Commit

Permalink
refactor: favourite key
Browse files Browse the repository at this point in the history
  • Loading branch information
litwak913 committed Nov 15, 2024
1 parent 7042699 commit 758afd1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions desktop/src/cn/harryh/arkpets/controllers/ModelsModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -392,15 +392,17 @@ private void initModelFavourite() {
modelFavourite.setGraphic(favIcon);
modelFavourite.setRipplerFill(Color.GRAY);
modelFavourite.setOnAction(e -> {
String key = (String) modelFavourite.getUserData();
String key = selectedModelCell.getItem().key;
if (app.config.character_favorites.containsKey(key)) {
app.config.character_favorites.remove(key);
selectedModelCell.getStyleClass().remove("Search-models-item-favourite");
modelFavourite.setGraphic(favIcon);
Logger.debug("ModelManager", "Remove favourite model " + key);
} else {
app.config.character_favorites.put(key, new ArkConfig.AssetPrefab());
selectedModelCell.getStyleClass().add("Search-models-item-favourite");
modelFavourite.setGraphic(favFillIcon);
Logger.debug("ModelManager", "Add favourite model " + key);
}
app.config.save();
});
Expand Down Expand Up @@ -575,6 +577,7 @@ private JFXListCell<AssetItem> getMenuItem(AssetItem assetItem, JFXListView<JFXL
SVGPath fav = GuiPrefabs.Icons.getIcon(GuiPrefabs.Icons.ICON_STAR_FILL,GuiPrefabs.Colors.COLOR_WARNING);
fav.getStyleClass().add("Search-models-star");
fav.setLayoutX(0);
fav.setLayoutY(3);
fav.setScaleX(0.75);
fav.setScaleY(0.75);
item.setPrefSize(width, height);
Expand Down Expand Up @@ -638,7 +641,6 @@ private void selectModel(AssetItem asset, JFXListCell<AssetItem> item) {
} else {
modelFavourite.setGraphic(favIcon);
}
modelFavourite.setUserData(asset.key);
// Apply to app.config, but not to save
app.config.character_asset = asset.getLocation();
app.config.character_files = asset.assetList;
Expand Down

0 comments on commit 758afd1

Please sign in to comment.