-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop raving same data to config if no changes. detected
- Loading branch information
nani
committed
Oct 9, 2022
1 parent
638574a
commit ccb7182
Showing
1 changed file
with
34 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,42 @@ | ||
PlayerList = new Proxy(PlayerList, { | ||
construct: function (target, args) | ||
{ | ||
const autociv_playersBox_preferences = new ConfigJSON("playersBox", true, false); | ||
const playersBox = Engine.GetGUIObjectByName("playersBox"); | ||
construct: function (target, args) { | ||
const autociv_playersBox_preferences = new ConfigJSON( | ||
"playersBox", | ||
true, | ||
false | ||
); | ||
const playersBox = Engine.GetGUIObjectByName("playersBox"); | ||
|
||
for (let id of autociv_playersBox_preferences.getIds()) | ||
playersBox[id] = autociv_playersBox_preferences.getValue(id); | ||
for (let id of autociv_playersBox_preferences.getIds()) | ||
playersBox[id] = autociv_playersBox_preferences.getValue(id); | ||
|
||
let instance = new target(...args); | ||
instance.autociv_playersBox_preferences = autociv_playersBox_preferences | ||
return instance; | ||
} | ||
let instance = new target(...args); | ||
instance.autociv_playersBox_preferences = autociv_playersBox_preferences; | ||
warn("1"); | ||
return instance; | ||
}, | ||
}); | ||
|
||
autociv_patchApplyN(PlayerList.prototype, "onPlayerListSelection", function (target, that, args) | ||
{ | ||
if (that.autociv_playersBox_preferences) | ||
{ | ||
for (let id of ["selected_column", "selected_column_order"]) | ||
that.autociv_playersBox_preferences.setValue(id, that.playersBox[id]) | ||
that.autociv_playersBox_preferences.save() | ||
autociv_patchApplyN( | ||
PlayerList.prototype, | ||
"onPlayerListSelection", | ||
function (target, that, args) { | ||
if (that.autociv_playersBox_preferences) { | ||
warn("2"); | ||
const needsSave = ["selected_column", "selected_column_order"] | ||
.map((id) => { | ||
let old = that.autociv_playersBox_preferences.getValue(id); | ||
if (old == that.playersBox[id]) return false; | ||
that.autociv_playersBox_preferences.setValue(id, that.playersBox[id]); | ||
return true; | ||
}) | ||
.some((v) => v); | ||
|
||
if (needsSave) { | ||
that.autociv_playersBox_preferences.save(); | ||
} | ||
} | ||
|
||
return target.apply(that, args); | ||
}) | ||
} | ||
); |