fix dropdown value in option menu not updating when value is changed externally
This commit is contained in:
parent
4aebbf2cae
commit
a29b70c32c
|
@ -19,6 +19,8 @@ package yugecin.opsudance.options;
|
|||
|
||||
public abstract class ListOption extends Option {
|
||||
|
||||
public Runnable observer;
|
||||
|
||||
public ListOption(String name, String configurationName, String description) {
|
||||
super(name, configurationName, description);
|
||||
}
|
||||
|
@ -30,4 +32,8 @@ public abstract class ListOption extends Option {
|
|||
public abstract Object[] getListItems();
|
||||
public abstract void clickListItem(int index);
|
||||
|
||||
protected final void onChange() {
|
||||
observer.run();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -166,6 +166,7 @@ public class Options {
|
|||
public void clickListItem(int index){
|
||||
idx = index;
|
||||
displayContainer.updateDisplayMode(resolutions[idx]);
|
||||
this.onChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -201,6 +202,7 @@ public class Options {
|
|||
public void clickListItem(int index){
|
||||
skinservice.usedSkinName = skinservice.availableSkinDirectories[index];
|
||||
skinservice.reloadSkin();
|
||||
this.onChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -283,6 +285,7 @@ public class Options {
|
|||
}
|
||||
}
|
||||
}
|
||||
this.onChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -344,6 +347,7 @@ public class Options {
|
|||
@Override
|
||||
public void clickListItem(int index){
|
||||
this.index = index;
|
||||
this.onChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -638,6 +642,7 @@ public class Options {
|
|||
return;
|
||||
}
|
||||
Dancer.instance.setMoverFactoryIndex(index);
|
||||
this.onChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -727,6 +732,7 @@ public class Options {
|
|||
@Override
|
||||
public void clickListItem(int index){
|
||||
Dancer.moverDirection = MoverDirection.values()[index];
|
||||
this.onChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -757,6 +763,7 @@ public class Options {
|
|||
public void clickListItem(int index){
|
||||
val = index;
|
||||
Dancer.sliderMoverController = Dancer.sliderMovers[index];
|
||||
this.onChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -779,6 +786,7 @@ public class Options {
|
|||
@Override
|
||||
public void clickListItem(int index){
|
||||
Dancer.instance.setSpinnerIndex(index);
|
||||
this.onChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -823,6 +831,7 @@ public class Options {
|
|||
@Override
|
||||
public void clickListItem(int index){
|
||||
Dancer.colorOverride = ObjectColorOverrides.values()[index];
|
||||
this.onChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -850,6 +859,7 @@ public class Options {
|
|||
@Override
|
||||
public void clickListItem(int index){
|
||||
Dancer.colorMirrorOverride = ObjectColorOverrides.values()[index];
|
||||
this.onChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -884,6 +894,7 @@ public class Options {
|
|||
@Override
|
||||
public void clickListItem(int index){
|
||||
Dancer.cursorColorOverride = CursorColorOverrides.values()[index];
|
||||
this.onChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -911,6 +922,7 @@ public class Options {
|
|||
@Override
|
||||
public void clickListItem(int index){
|
||||
Dancer.cursorColorMirrorOverride = CursorColorOverrides.values()[index];
|
||||
this.onChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -269,16 +269,20 @@ public class OptionsOverlay implements ResolutionChangedListener, SkinChangedLis
|
|||
openDropdownMenu = null;
|
||||
}
|
||||
};
|
||||
// not the best way to determine the selected option AT ALL, but seems like it's the only one right now...
|
||||
String selectedValue = option.getValueString();
|
||||
int idx = 0;
|
||||
for (Object item : items) {
|
||||
if (item.toString().equals(selectedValue)) {
|
||||
break;
|
||||
final Runnable observer = () -> {
|
||||
// not the best way to determine the selected option AT ALL, but seems like it's the only one right now...
|
||||
String selectedValue = option.getValueString();
|
||||
int idx = 0;
|
||||
for (Object item : items) {
|
||||
if (item.toString().equals(selectedValue)) {
|
||||
break;
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
menu.setSelectedIndex(idx);
|
||||
menu.setSelectedIndex(idx);
|
||||
};
|
||||
observer.run();
|
||||
listOption.observer = observer;
|
||||
menu.setBackgroundColor(COL_BG);
|
||||
menu.setBorderColor(Color.transparent);
|
||||
menu.setChevronDownColor(COL_WHITE);
|
||||
|
|
Loading…
Reference in New Issue
Block a user