Rework of IK override

This commit is contained in:
SDraw 2022-09-14 00:09:09 +03:00
parent 4e3d5dd6d4
commit 49b72a0711
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
5 changed files with 158 additions and 30 deletions

View file

@ -123,6 +123,54 @@ function inp_slider_mod_amt(_obj, _callbackName) {
}
}
// Modified from original `inp` types, because I have no js knowledge to hook stuff
function inp_toggle_mod_amt(_obj, _callbackName) {
this.obj = _obj;
this.callbackName = _callbackName;
this.value = _obj.getAttribute('data-current');
this.name = _obj.id;
this.type = _obj.getAttribute('data-type');
var self = this;
this.mouseDown = function (_e) {
self.value = self.value == "True" ? "False" : "True";
self.updateState();
}
this.updateState = function () {
self.obj.classList.remove("checked");
if (self.value == "True") {
self.obj.classList.add("checked");
}
engine.call(self.callbackName, self.name, self.value);
}
_obj.addEventListener('mousedown', this.mouseDown);
this.getValue = function () {
return self.value;
}
this.updateValue = function (value) {
self.value = value;
self.obj.classList.remove("checked");
if (self.value == "True") {
self.obj.classList.add("checked");
}
}
this.updateValue(this.value);
return {
name: this.name,
value: this.getValue,
updateValue: this.updateValue
}
}
// Add own menu
{
let l_block = document.createElement('div');
@ -132,6 +180,13 @@ function inp_slider_mod_amt(_obj, _callbackName) {
<div class ="subcategory-description"></div>
</div>
<div class ="row-wrapper">
<div class ="option-caption">IK override: </div>
<div class ="option-input">
<div id="IKOverride" class ="inp_toggle no-scroll" data-current="true"></div>
</div>
</div>
<div class ="row-wrapper">
<div class ="option-caption">Legs locomotion upright limit: </div>
<div class ="option-input">
@ -146,4 +201,10 @@ function inp_slider_mod_amt(_obj, _callbackName) {
for (var i = 0; i < l_sliders.length; i++) {
g_modSettingsAMT[g_modSettingsAMT.length] = new inp_slider_mod_amt(l_sliders[i], 'MelonMod_AMT_Call_InpSlider');
}
// Update toggles in new menu block
let l_toggles = l_block.querySelectorAll('.inp_toggle');
for (var i = 0; i < l_toggles.length; i++) {
g_modSettingsAMT[g_modSettingsAMT.length] = new inp_toggle_mod_amt(l_toggles[i], 'MelonMod_AMT_Call_InpToggle');
}
}