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 22cf256
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 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 @@ -638,7 +640,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 22cf256

Please sign in to comment.