2
2
3
3
import bot_parameters .account .RunescapeAccount ;
4
4
import bot_parameters .configuration .Configuration ;
5
+ import bot_parameters .configuration .World ;
5
6
import bot_parameters .configuration .WorldType ;
6
7
import bot_parameters .proxy .Proxy ;
7
8
import bot_parameters .script .Script ;
9
+ import gui .dialogues .world_selector_dialog .WorldSelectorDialog ;
8
10
import javafx .application .Platform ;
9
11
import javafx .collections .FXCollections ;
12
+ import javafx .collections .ListChangeListener ;
10
13
import javafx .collections .ObservableList ;
14
+ import javafx .event .ActionEvent ;
15
+ import javafx .event .EventHandler ;
11
16
import javafx .scene .control .*;
12
17
import javafx .scene .input .KeyCode ;
13
18
import javafx .scene .layout .FlowPane ;
14
19
20
+ import java .util .ArrayList ;
15
21
import java .util .List ;
22
+ import java .util .Map ;
16
23
17
24
public final class ConfigurationDialog extends InputDialog <Configuration > {
18
25
@@ -30,9 +37,8 @@ public final class ConfigurationDialog extends InputDialog<Configuration> {
30
37
private final CheckBox noRandoms ;
31
38
private final CheckBox noInterface ;
32
39
private final CheckBox noRender ;
33
- private final ChoiceBox <WorldType > worldTypeSelector ;
34
- private final CheckBox randomizeWorld ;
35
- private final ChoiceBox <Integer > worldSelector ;
40
+
41
+ private final WorldSelectorDialog worldSelectorDialog ;
36
42
37
43
public ConfigurationDialog (ObservableList <RunescapeAccount > accountList , ObservableList <Script > scriptList , ObservableList <Proxy > proxyList ) {
38
44
@@ -71,16 +77,12 @@ public ConfigurationDialog(ObservableList<RunescapeAccount> accountList, Observa
71
77
proxySelector = new ChoiceBox <>(proxyList );
72
78
contentBox .getChildren ().add (new FlowPane (10 , 10 , new Label ("Proxy:" ), proxySelector ));
73
79
74
- worldTypeSelector = new ChoiceBox <>(FXCollections .observableArrayList (WorldType .values ()));
75
- worldSelector = new ChoiceBox <>(FXCollections .observableArrayList (WorldType .F2P .worlds ));
76
- worldSelector .getSelectionModel ().select (0 );
77
- worldTypeSelector .getSelectionModel ().selectedIndexProperty ().addListener ((observable , oldValue , newValue ) -> {
78
- worldSelector .getItems ().setAll (worldTypeSelector .getItems ().get ((Integer ) newValue ).worlds );
79
- worldSelector .getSelectionModel ().select (0 );
80
+ final Button worldSelectorButton = new Button ("World selector" );
81
+ worldSelectorDialog = new WorldSelectorDialog ();
82
+ worldSelectorButton .setOnAction (event -> {
83
+ worldSelectorDialog .showAndWait ();
80
84
});
81
- randomizeWorld = new CheckBox ("Randomize" );
82
- contentBox .getChildren ().add (new FlowPane (10 , 10 , new Label ("World Type: " ), worldTypeSelector , randomizeWorld , new Label ("World: " ), worldSelector ));
83
-
85
+ contentBox .getChildren ().add (new FlowPane (10 , 10 , worldSelectorButton ));
84
86
85
87
memoryAllocation = new TextField ();
86
88
memoryAllocation .setPromptText ("(Optional) Memory Allocation" );
@@ -131,6 +133,10 @@ public ConfigurationDialog(ObservableList<RunescapeAccount> accountList, Observa
131
133
selectedScripts .getItems ().size () == 0 );
132
134
});
133
135
136
+ worldSelectorDialog .getSelectedWorlds ().addListener ((ListChangeListener <World >) c -> {
137
+ okButton .setDisable (worldSelectorDialog .getSelectedWorlds ().isEmpty ());
138
+ });
139
+
134
140
Platform .runLater (accountSelector ::requestFocus );
135
141
}
136
142
@@ -148,9 +154,7 @@ public void setValues(final Configuration existingItem) {
148
154
lowCpuMode .setSelected (false );
149
155
enableReflection .setSelected (false );
150
156
noRandoms .setSelected (false );
151
- worldTypeSelector .getSelectionModel ().select (WorldType .F2P );
152
- worldSelector .getSelectionModel ().select (0 );
153
- randomizeWorld .setSelected (false );
157
+ worldSelectorDialog .clearSelectedWorlds ();
154
158
noInterface .setSelected (false );
155
159
noRender .setSelected (false );
156
160
return ;
@@ -166,9 +170,7 @@ public void setValues(final Configuration existingItem) {
166
170
lowCpuMode .setSelected (existingItem .isLowCpuMode ());
167
171
enableReflection .setSelected (existingItem .isReflection ());
168
172
noRandoms .setSelected (existingItem .isNoRandoms ());
169
- worldTypeSelector .getSelectionModel ().select (existingItem .getWorldType ());
170
- worldSelector .getSelectionModel ().select (existingItem .getWorld ());
171
- randomizeWorld .setSelected (existingItem .isRandomizeWorld ());
173
+ worldSelectorDialog .setSelectedWorlds (existingItem .getWorlds ());
172
174
noInterface .setSelected (existingItem .isNoInterface ());
173
175
noRender .setSelected (existingItem .isNoRender ());
174
176
okButton .setDisable (accountSelector .getSelectionModel ().getSelectedItem () == null || selectedScripts .getItems ().size () == 0 );
@@ -192,9 +194,7 @@ protected final Configuration onAdd() {
192
194
configuration .setLowResourceMode (lowResourceMode .isSelected ());
193
195
configuration .setReflection (enableReflection .isSelected ());
194
196
configuration .setNoRandoms (noRandoms .isSelected ());
195
- configuration .setWorldType (worldTypeSelector .getValue ());
196
- configuration .setWorld (worldSelector .getValue ());
197
- configuration .setRandomizeWorld (randomizeWorld .isSelected ());
197
+ configuration .setWorlds (new ArrayList <>(worldSelectorDialog .getSelectedWorlds ()));
198
198
configuration .setNoInterface (noInterface .isSelected ());
199
199
configuration .setNoRender (noRender .isSelected ());
200
200
@@ -223,9 +223,7 @@ protected Configuration onEdit(final Configuration existingItem) {
223
223
existingItem .setLowResourceMode (lowResourceMode .isSelected ());
224
224
existingItem .setReflection (enableReflection .isSelected ());
225
225
existingItem .setNoRandoms (noRandoms .isSelected ());
226
- existingItem .setWorldType (worldTypeSelector .getValue ());
227
- existingItem .setWorld (worldSelector .getValue ());
228
- existingItem .setRandomizeWorld (randomizeWorld .isSelected ());
226
+ existingItem .setWorlds (new ArrayList <>(worldSelectorDialog .getSelectedWorlds ()));
229
227
existingItem .setNoInterface (noInterface .isSelected ());
230
228
existingItem .setNoRender (noRender .isSelected ());
231
229
return existingItem ;
0 commit comments