From 22cf25615cc742da851db0a1bbef22910c200359 Mon Sep 17 00:00:00 2001 From: litwak913 Date: Fri, 15 Nov 2024 23:19:25 +0800 Subject: [PATCH] refactor: favourite key --- desktop/src/cn/harryh/arkpets/controllers/ModelsModule.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/desktop/src/cn/harryh/arkpets/controllers/ModelsModule.java b/desktop/src/cn/harryh/arkpets/controllers/ModelsModule.java index 15ff000..5a376b5 100644 --- a/desktop/src/cn/harryh/arkpets/controllers/ModelsModule.java +++ b/desktop/src/cn/harryh/arkpets/controllers/ModelsModule.java @@ -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(); }); @@ -638,7 +640,6 @@ private void selectModel(AssetItem asset, JFXListCell 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;