gh-pages
peshomir 2024-02-21 19:58:40 +00:00
parent 4a2a6f3b02
commit e0e6645d2a
4 changed files with 92 additions and 3 deletions

View File

@ -1,5 +1,5 @@
const fx_version = '0.6.0.3'; // FX Client Version
const fx_update = 'Feb 15'; // FX Client Last Updated
const fx_version = '0.6.1'; // FX Client Version
const fx_update = 'Feb 21'; // FX Client Last Updated
if (localStorage.getItem("fx_winCount") == undefined || localStorage.getItem("fx_winCount") == null) {
@ -9,12 +9,79 @@ if (localStorage.getItem("fx_winCount") == undefined || localStorage.getItem("fx
var wins_counter = localStorage.getItem("fx_winCount");
}
function KeybindsInput(containerElement) {
this.container = containerElement;
this.keys = [ "key", "type", "value" ];
this.objectArray = [];
this.addObject = function () {
this.objectArray.push({ key: "", type: "absolute", value: 1 });
this.displayObjects();
};
document.getElementById("keybindAddButton").addEventListener("click", this.addObject.bind(this));
this.displayObjects = function () {
// Clear the content of the container
this.container.innerHTML = "";
if (this.objectArray.length === 0) return this.container.innerText = "No custom keybinds added";
// Loop through the array and display input fields for each object
for (var i = 0; i < this.objectArray.length; i++) {
var objectDiv = document.createElement("div");
// Create input fields for each key
this.keys.forEach(function (key) {
if (key === "type") {
var selectMenu = document.createElement("select");
selectMenu.innerHTML = '<option value="absolute">Absolute</option><option value="relative">Relative</option>';
selectMenu.value = this.objectArray[i][key];
selectMenu.addEventListener("change", this.updateObject.bind(this, i, key));
objectDiv.appendChild(selectMenu);
return;
}
var inputField = document.createElement("input");
inputField.type = key === "value" ? "number" : "text";
if (key === "value") inputField.setAttribute("step", "0.1");
if (key === "key") inputField.setAttribute("readonly", "");
inputField.value = this.objectArray[i][key];
if (key === "key") inputField.addEventListener("click", this.startKeyInput.bind(this, i, key));
else inputField.addEventListener("input", this.updateObject.bind(this, i, key));
// Append input field to the object div
objectDiv.appendChild(inputField);
}, this);
// Button to delete the object
var deleteButton = document.createElement("button");
deleteButton.textContent = "Delete";
deleteButton.addEventListener("click", this.deleteObject.bind(this, i));
// Append delete button to the object div
objectDiv.appendChild(deleteButton);
// Append the object div to the container
this.container.appendChild(objectDiv);
}
};
this.startKeyInput = function (index, property, event) {
event.target.value = "Press any key";
document.addEventListener('keydown', this.updateObject.bind(this, index, property), { once: true });
};
this.updateObject = function (index, property, event) {
if (index >= this.objectArray.length) return;
// Update the corresponding property of the object in the array
const value = property === "value" ? parseFloat(event.target.value) : property === "key" ? event.key : event.target.value;
this.objectArray[index][property] = value;
if (property === "key") this.displayObjects();
};
this.deleteObject = function (index) {
// Remove the object from the array
this.objectArray.splice(index, 1);
// Display the updated input fields for objects
this.displayObjects();
};
return this;
}
var settings = {
"fontName": "Trebuchet MS",
"showBotDonations": false,
"hideAllLinks": false,
"realisticNames": false,
//"customMapFileBtn": true
"attackPercentageKeybinds": [],
};
var settingsManager = new (function() {
var inputFields = {
@ -35,9 +102,12 @@ var settingsManager = new (function() {
// should probably firgure out a way to do this without reloading - // You can't do it, localstorages REQUIRE you to reload
window.location.reload();
};
let keybindsInput = new KeybindsInput(document.getElementById("keybinds"));
this.syncFields = function() {
Object.keys(inputFields).forEach(function(key) { inputFields[key].value = settings[key]; });
Object.keys(checkboxFields).forEach(function(key) { checkboxFields[key].checked = settings[key]; });
keybindsInput.objectArray = settings.attackPercentageKeybinds;
keybindsInput.displayObjects();
};
this.resetAll = function() {
if (!confirm("Are you Really SURE you want to RESET ALL SETTINGS back to the default?")) return;
@ -138,6 +208,15 @@ var utils = new (function() {
};
});
const keybindFunctions = { setAbsolute: () => {}, setRelative: () => {} };
const keybindHandler = key => {
const keybindData = settings.attackPercentageKeybinds.find(keybind => keybind.key === key);
if (keybindData === undefined) return false;
if (keybindData.type === "absolute") keybindFunctions.setAbsolute(keybindData.value);
else keybindFunctions.setRelative(keybindData.value);
return true;
};
if (localStorage.getItem("fx_settings") !== null) {
settings = {...settings, ...JSON.parse(localStorage.getItem("fx_settings"))};
}

View File

@ -529,6 +529,7 @@ function f0() {
}
function fH(cE) {
if (keybindHandler(cE.key)) return;
fJ() || ("ArrowLeft" === cE.key || "a" === cE.key ? fs.g1(3) : "ArrowUp" === cE.key || "w" === cE.key ? fs.g1(0) : "ArrowRight" === cE.key || "d" === cE.key ? fs.g1(1) : "ArrowDown" === cE.key || "s" === cE.key ? fs.g1(2) : "1" === cE.key ?
ck.g2(.75) : "2" === cE.key ? ck.g2(7 / 8) : "3" === cE.key ? ck.g2(.9375) : "4" === cE.key ? ck.g2(31 / 32) : "5" === cE.key ? ck.g2(32 / 31) : "6" === cE.key ? ck.g2(16 / 15) : "7" === cE.key ? ck.g2(8 / 7) : "8" === cE.key ? ck.g2(
4 / 3) : "+" === cE.key ? 0 !== aY && cY.eF(Math.floor(eG / 2), Math.floor(eH / 2), -200) : "-" === cE.key ? 0 !== aY && cY.eF(Math.floor(eG / 2), Math.floor(eH / 2), 200) : "c" === cE.key && 0 !== aY && cs.g3())
@ -5414,6 +5415,11 @@ function a85() {
2), ck.aC - 2 * a8C, a8B), aK.fillRect(Math.floor(aQ - 1.25 * ck.aC) + a8C, Math.floor((ck.aC - a8B) / 2), ck.aC - 2 * a8C - a8C % 2, a8B), aK.fillRect(Math.floor(aQ - 1.25 * ck.aC) + Math.floor((ck.aC - a8B) / 2), a8C, a8B, ck.aC -
2 * a8C - a8C % 2), a87 = bG.kI.a2n(kY, ck.pc()), aK.fillText(bG.hZ.ha(a87) + " (" + bG.hZ.i5(100 * sr, 0) + ")", Math.floor(.5 * aQ), rG)
}
this.setAbsolutePercentage = function(newPercentage) {
sr = newPercentage;
};
keybindFunctions.setAbsolute = this.setAbsolutePercentage;
keybindFunctions.setRelative = (arg1) => ck.g2(arg1);
function a8G(ee) {
return !(1 < ee && 1 === sr || (1 < ee && ee * sr - sr < 1 / 1024 ? ee = (sr + 1 / 1024) / sr : ee < 1 && sr - ee * sr < 1 / 1024 && (ee = (sr - 1 / 1024) / sr), sr = yP.hr(sr * ee, 1 / 1024, 1), a89(), 0))

View File

@ -76,6 +76,9 @@
Bring back the custom map file button after the creator removed it in 1.83.0
<input type="checkbox" id="settings_custommapfileinput"><span class="checkmark"></span>
</label>-->
<p>Keybinds</p>
<div id="keybinds" class="arrayinput"></div>
<button id="keybindAddButton">Add</button>
</div>
<hr>
<footer>

View File

@ -36,7 +36,8 @@ hr {
}
.window button,
.window input {
.window input,
.window select {
background-color: rgba(0, 0, 0, 0.7);
color : white;
font-size : 20px;