forked from akanyan/mu3-mods
fix(TestMenuConfig): proper handling of audiomode
This commit is contained in:
@ -34,10 +34,11 @@ class TestModePageModConfig: TestModePage {
|
||||
using IniFile iniFile = new("mu3.ini");
|
||||
var previous = iniFile.getValue(sectionName, fieldName, values.ElementAt(indexDefault).Value);
|
||||
var found = this.values.FindIndex(i => i.Value == previous);
|
||||
if(found == -1) {
|
||||
if(found < 0) {
|
||||
itemDefine.isSelectable = false;
|
||||
selection = indexDefault;
|
||||
} else {
|
||||
selection = found == -1 ? indexDefault : found;
|
||||
selection = found;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -152,7 +153,7 @@ class TestModePageModConfig: TestModePage {
|
||||
"AUDIO MODE*",
|
||||
"WasapiExclusive",
|
||||
d,
|
||||
0,
|
||||
1,
|
||||
true,
|
||||
"Sound"
|
||||
));
|
||||
@ -221,7 +222,7 @@ class TestModePageModConfig: TestModePage {
|
||||
}
|
||||
|
||||
protected override void onInitializeItem(Item item, int index) {
|
||||
item.setState(item.isSelectable ? Item.State.Selectable : Item.State.UnselectableTemp);
|
||||
item.setState(item.define.isSelectable ? Item.State.Selectable : Item.State.UnselectableTemp);
|
||||
|
||||
if(!item.define.hasValueField) {
|
||||
return;
|
||||
@ -269,8 +270,24 @@ class TestModePageModConfig: TestModePage {
|
||||
|
||||
_writeToFile.Invoke(iniFile, [sw]);
|
||||
}
|
||||
|
||||
protected override void onUpdateItem(Item item, int index) {
|
||||
if(!item.define.hasValueField || !item.define.isSelectable) {
|
||||
return;
|
||||
}
|
||||
|
||||
var op = _options[index];
|
||||
if(op.fieldName == "WasapiExclusive") {
|
||||
var next = _itemList[index + 1];
|
||||
if(next != null) {
|
||||
var enabled = op.selection != 0;
|
||||
next.define.isSelectable = enabled;
|
||||
next.setState(enabled ? Item.State.Selectable : Item.State.UnselectableTemp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void rewriteOption(IniFile ini, string sectionName, string fieldName, string defaultValue) {
|
||||
;
|
||||
ini.setValue(sectionName, fieldName, ini.getValue(sectionName, fieldName, defaultValue));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user