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