diff --git a/src/poe/level/fx/GemEntry_Controller.java b/src/poe/level/fx/GemEntry_Controller.java index 46221ab..5a90d60 100644 --- a/src/poe/level/fx/GemEntry_Controller.java +++ b/src/poe/level/fx/GemEntry_Controller.java @@ -385,7 +385,7 @@ public void setId(int id){ } public AnchorPane getRoot(){ - return root; + return outerRoot; } public Gem getGem(){ diff --git a/src/poe/level/fx/GemsPanel_Controller.java b/src/poe/level/fx/GemsPanel_Controller.java index 2cc92cb..5abeedf 100644 --- a/src/poe/level/fx/GemsPanel_Controller.java +++ b/src/poe/level/fx/GemsPanel_Controller.java @@ -35,6 +35,7 @@ import javafx.util.StringConverter; import poe.level.data.*; import poe.level.fx.SocketGroupsPanel_Controller.SocketGroupLinker; +import sun.plugin.javascript.navig.Anchor; /** * FXML Controller class @@ -52,6 +53,7 @@ public class GemsPanelLinker{ int popup_id; SocketGroup sg; GemLinker currentMain; + public int panel_mapper; public int hook(GemsPanel_Controller root, SocketGroup sg){ this.root = root; @@ -337,8 +339,8 @@ public void update(SocketGroupLinker sgl){ try { FXMLLoader loader = new FXMLLoader(getClass().getResource("gemEntry.fxml")); - - gemContainer.getChildren().add(loader.load()); + AnchorPane gemEntry = loader.load(); + gemContainer.getChildren().add(gemEntry); sgl.gpl.loadGemPanel(gl.id); gl.hookController(loader.getController()); @@ -361,7 +363,8 @@ public void update(SocketGroupLinker sgl){ for(int gem_id : sgl.gpl.ids){ FXMLLoader loader = new FXMLLoader(getClass().getResource("gemEntry.fxml")); try { - gemContainer.getChildren().add(loader.load()); + AnchorPane gemEntry = loader.load(); + gemContainer.getChildren().add(gemEntry); } catch (IOException ex) { Logger.getLogger(GemsPanel_Controller.class.getName()).log(Level.SEVERE, null, ex); } @@ -436,7 +439,8 @@ private void addGemPanel(){ current_sgl.gpl.gl_map.put(gl.hook(current_sgl.gpl), gl); gl.gem = GemHolder.getInstance().tossDummie(); try { - gemContainer.getChildren().add(loader.load()); + AnchorPane gemEntry = loader.load(); + gemContainer.getChildren().add(gemEntry); current_sgl.gpl.loadGemPanel(gl.id); } catch (IOException ex) { Logger.getLogger(GemsPanel_Controller.class.getName()).log(Level.SEVERE, null, ex); @@ -449,7 +453,14 @@ private void addGemPanel(){ private void removeGemPanel(){ GemLinker get = current_sgl.gpl.gl_map.get(current_sgl.gpl.active_gemLinker); current_sgl.gpl.removeGemPanel(current_sgl.gpl.active_gemLinker); + /* + int active_gemLinker = current_sgl.gpl.active_gemLinker; + GemLinker gemLinker = current_sgl.gpl.gl_map.get(active_gemLinker); + Gem gem = gemLinker.gem;*/ + GemEntry_Controller thisiswrong = get.controller; + + removeGem(get.gem); //remove gem from socketGroup class current_sgl.gpl.gl_map.remove(current_sgl.gpl.active_gemLinker);//let go of the GemLinker reference @@ -457,6 +468,9 @@ private void removeGemPanel(){ if(thisiswrong!=null){ gemContainer.getChildren().remove(thisiswrong.getRoot()); } + if(gemContainer.getChildren().isEmpty()){ + current_sgl.triggerDelete(); + } removeGemPanel_button.setDisable(true); } @@ -532,8 +546,10 @@ private void mainGemValueChanged(){ } } current_sgl.changeLabel(); - groupSliderChange(current_sgl.sg.getActiveGem().getLevelAdded(),0); - fromLevel.getValueFactory().setValue(current_sgl.sg.getActiveGem().getLevelAdded()); + if(current_sgl.sg.getActiveGem()!=null){ + groupSliderChange(current_sgl.sg.getActiveGem().getLevelAdded(),0); + fromLevel.getValueFactory().setValue(current_sgl.sg.getActiveGem().getLevelAdded()); + } if(current_sgl.sg.replaceGroup()){ groupSliderChange(current_sgl.sg.getGroupReplaced().getFromGroupLevel(),1); untilLevel.getValueFactory().setValue(current_sgl.sg.getGroupReplaced().getFromGroupLevel()); @@ -615,7 +631,7 @@ public void gemUpdate(Gem gem, int id){ public void removeGem(Gem gem){ - + Gem replacement = null; if(current_sgl.sg.getActiveGem()!=null){ if(current_sgl.sg.getActiveGem().equals(gem)){ @@ -625,6 +641,20 @@ public void removeGem(Gem gem){ a.sg.setReplaceGroup(false); } } + for(Gem g : current_sgl.sg.getGems()){ + if(g.isActive && g != gem) { + replacement = g; + break; + } + } + if(replacement== null){ + for(Gem g : current_sgl.sg.getGems()){ + if(g != gem) { + replacement = g; + break; + } + } + } } } @@ -644,6 +674,11 @@ public void removeGem(Gem gem){ }*/ + if(replacement!=null){ + System.out.println("Replacement" + replacement.getGemName()); + activeSkillGroup.setValue(replacement); + } + for(Gem g : current_sgl.sg.getGems()){ if(g.replaced){ if(g.replacedWith.equals(gem)){ diff --git a/src/poe/level/fx/SocketGroupsPanel_Controller.java b/src/poe/level/fx/SocketGroupsPanel_Controller.java index 8370f70..c896a90 100644 --- a/src/poe/level/fx/SocketGroupsPanel_Controller.java +++ b/src/poe/level/fx/SocketGroupsPanel_Controller.java @@ -35,14 +35,24 @@ public class SocketGroupLinker{ Label sgLabel; SocketGroup sg; GemsPanelLinker gpl; + SocketGroupsPanel_Controller sgpc; public SocketGroupLinker(SocketGroup sgroup){ sg = sgroup; generateLabel(); } - + + public void hookSGPC(SocketGroupsPanel_Controller sgpc){ + this.sgpc = sgpc; + } + + public void triggerDelete(){ + sgpc.removeSocketGroupIfEmpty(this); + } + public SocketGroupLinker dupe(HashSet s_id, HashSet g_id){ SocketGroupLinker sgl = new SocketGroupLinker(sg.dupe(s_id,g_id)); + sgl.hookSGPC(sgpc); return sgl; } @@ -165,6 +175,7 @@ public void update(ArrayList sgl_list){ ObservableList