Skip to content

Commit eb0845c

Browse files
committed
Added Removal Check/Dialog.
- also fixed wrong assignment of new/edited group name/s
1 parent 3590322 commit eb0845c

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

src/net/fexcraft/app/fmt/ui/editor/GroupEditor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public void updateTextField(){
3838
TurboList list = null;
3939
if(FMTB.MODEL.getDirectlySelectedGroupsAmount() == 1){
4040
if(FMTB.MODEL.getCompound().isEmpty()) return;
41-
list = FMTB.MODEL.getCompound().values().toArray(new TurboList[0])[0];
42-
FMTB.MODEL.getCompound().remove(list.id);
41+
list = FMTB.MODEL.getFirstSelectedGroup();
42+
list = FMTB.MODEL.getCompound().remove(list.id);
4343
list.id = this.getTextValue().replace(" ", "_").replace("-", "_").replace(".", "");
4444
while(FMTB.MODEL.getCompound().containsKey(list.id)){ list.id += "_"; }
4545
FMTB.MODEL.getCompound().put(list.id, list);

src/net/fexcraft/app/fmt/ui/tree/ModelTree.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import net.fexcraft.app.fmt.FMTB;
88
import net.fexcraft.app.fmt.ui.editor.Editor;
9+
import net.fexcraft.app.fmt.ui.generic.DialogBox;
910
import net.fexcraft.app.fmt.utils.GGR;
1011
import net.fexcraft.app.fmt.utils.TextureManager;
1112
import net.fexcraft.app.fmt.wrappers.PolygonWrapper;
@@ -77,13 +78,16 @@ else if(mx >= x + width - 48 && mx < x + width - 28){
7778
trlist[j].visible = !trlist[j].visible; return true;
7879
}
7980
else if(mx >= x + width - 26 && mx < x + width - 6){
80-
FMTB.MODEL.getCompound().remove(trlist[j].id); return true;
81+
String id = trlist[j].id;
82+
FMTB.showDialogbox("Remove this group?", id, "Yes", "No!", () -> {
83+
FMTB.MODEL.getCompound().remove(id);
84+
}, DialogBox.NOTHING);
85+
return true;
8186
}
8287
else{
8388
boolean bool = trlist[j].selected;
8489
if(!GGR.isShiftDown()){ FMTB.MODEL.clearSelection(); }
85-
trlist[j].selected = !bool;
86-
FMTB.MODEL.updateFields();
90+
trlist[j].selected = !bool; FMTB.MODEL.updateFields();
8791
}
8892
return false;
8993
}
@@ -97,13 +101,16 @@ else if(mx >= x + width - 52 && mx < x + width - 32){
97101
trlist[j].get(l).visible = !trlist[j].get(l).visible; return true;
98102
}
99103
else if(mx >= x + width - 30 && mx < x + width - 10){
100-
trlist[j].remove(l); return true;
104+
String id = trlist[j].id; PolygonWrapper poly = trlist[j].get(l);
105+
FMTB.showDialogbox("Remove this polygon?", id + ":" + poly.name(), "Yes", "No!", () -> {
106+
FMTB.MODEL.getCompound().get(id).remove(poly);
107+
}, DialogBox.NOTHING);
108+
return true;
101109
}
102110
else{
103111
boolean bool = trlist[j].get(l).selected;
104112
if(!GGR.isShiftDown()){ FMTB.MODEL.clearSelection(); }
105-
trlist[j].get(l).selected = !bool;
106-
FMTB.MODEL.updateFields();
113+
trlist[j].get(l).selected = !bool; FMTB.MODEL.updateFields();
107114
}
108115
return false;
109116
}

0 commit comments

Comments
 (0)