wynnbuilder-forked-for-changes/sq2.js

347 lines
9.5 KiB
JavaScript
Raw Normal View History

2021-10-17 15:53:48 +00:00
let equipment_keys = ['weapon', 'helmet', 'chestplate', 'leggings', 'boots', 'ring1', 'ring2', 'bracelet', 'necklace'];
$(document).ready(function(){
// inits
$("#overall-window").toggle();
$("#search-container").toggle();
$("#boost-container").toggle();
// pot/base damage switch for weap display
/*
$(".damage-size").click(function(){
$(".damage-size").hide();
$(".potency").show();
});
$(".potency").click(function(){
$(".potency").hide();
$(".damage-size").show();
});*/
// windows
$("#overall-window").draggable({
handle: '#overall-window-header',
}).resizable({
alsoResize: "#all-stats",
handles: 'n, e, s ,w'
});
$("#search-container").draggable({
handle: '#search-container-header',
});
$("#boost-container").draggable({
handle: '#boost-container-header',
});
// window priority
2021-10-18 04:51:35 +00:00
$("#overall-window").mousedown(function() {
$(".window-container").css("z-index", 10);
$(this).css("z-index", 11);
});
$("#search-container").mousedown(function() {
$(".window-container").css("z-index", 10);
$(this).css("z-index", 11);
});
$("#boost-container").mousedown(function() {
$(".window-container").css("z-index", 10);
$(this).css("z-index", 11);
});
2021-10-17 15:53:48 +00:00
// update builds
jQuery(document).on("input", '.skp-input', function(event){
updateStatSchedule();
});
jQuery(document).on("input", '.search-field', function(event){
doSearchSchedule();
});
// set listeners/checks
$("#weapon-choice").on('input', function(){
set_input_style('weapon');
calcBuildSchedule();
update_powder_count('weapon');
2021-10-17 15:53:48 +00:00
});
$("#weapon-powder").on('input', function(){
calcBuildSchedule();
2021-10-17 15:53:48 +00:00
});
$("#helmet-choice").on('input', function(){
set_input_style('helmet');
calcBuildSchedule();
update_powder_count('helmet', '|example: t6t6');
2021-10-17 15:53:48 +00:00
});
$("#helmet-powder").on('input', function(){
calcBuildSchedule();
2021-10-17 15:53:48 +00:00
});
$("#chestplate-choice").on('input', function(){
set_input_style('chestplate');
calcBuildSchedule();
update_powder_count('chestplate');
});
$("#chestplate-powder").on('input', function(){
calcBuildSchedule();
2021-10-17 15:53:48 +00:00
});
$("#leggings-choice").on('input', function(){
set_input_style('leggings');
calcBuildSchedule();
update_powder_count('leggings');
});
2021-10-18 00:25:02 +00:00
$("#leggings-powder").on('input', function(){
calcBuildSchedule();
2021-10-17 15:53:48 +00:00
});
$("#boots-choice").on('input', function(){
set_input_style('boots');
calcBuildSchedule();
update_powder_count('boots');
});
$("#boots-powder").on('input', function(){
calcBuildSchedule();
2021-10-17 15:53:48 +00:00
});
$("#ring1-choice").on('input', function(){
set_input_style('ring1');
calcBuildSchedule();
2021-10-17 15:53:48 +00:00
});
$("#ring2-choice").on('input', function(){
set_input_style('ring2');
calcBuildSchedule();
2021-10-17 15:53:48 +00:00
});
$("#bracelet-choice").on('input', function(){
set_input_style('bracelet');
calcBuildSchedule();
2021-10-17 15:53:48 +00:00
});
$("#necklace-choice").on('input', function(){
set_input_style('necklace');
calcBuildSchedule();
2021-10-17 15:53:48 +00:00
});
// control vars
let basic_stats_ctrl = true;
let off_stats_ctrl = false;
let def_stats_ctrl = false;
$("#basic-stats-btn").click(function(){
basic_stats_ctrl = true;
off_stats_ctrl = false;
def_stats_ctrl = false;
$("#minimal-stats").show();
$("#minimal-offensive-stats").hide();
$("#minimal-defensive-stats").hide();
$("#off-stats-btn").css("background-color", "rgb(45, 45, 45)");
$("#def-stats-btn").css("background-color", "rgb(45, 45, 45)");
});
$("#basic-stats-btn").hover(
function(){
$("#basic-stats-btn").css("background-color", "rgb(40, 40, 40)");
},function(){
if (basic_stats_ctrl) {
$("#basic-stats-btn").css("background-color", "rgb(30, 30, 30)");
} else {
$("#basic-stats-btn").css("background-color", "rgb(45, 45, 45)");
}
});
$("#off-stats-btn").click(function(){
basic_stats_ctrl = false;
off_stats_ctrl = true;
def_stats_ctrl = false;
$("#minimal-stats").hide();
$("#minimal-offensive-stats").show();
$("#minimal-defensive-stats").hide();
$("#basic-stats-btn").css("background-color", "rgb(45, 45, 45)");
$("#def-stats-btn").css("background-color", "rgb(45, 45, 45)");
});
$("#off-stats-btn").hover(
function(){
$("#off-stats-btn").css("background-color", "rgb(40, 40, 40)");
},function(){
if (off_stats_ctrl) {
$("#off-stats-btn").css("background-color", "rgb(30, 30, 30)");
} else {
$("#off-stats-btn").css("background-color", "rgb(45, 45, 45)");
}
});
$("#def-stats-btn").click(function(){
basic_stats_ctrl = false;
off_stats_ctrl = false;
def_stats_ctrl = true;
$("#minimal-stats").hide();
$("#minimal-offensive-stats").hide();
$("#minimal-defensive-stats").show();
$("#off-stats-btn").css("background-color", "rgb(45, 45, 45)");
$("#basic-stats-btn").css("background-color", "rgb(45, 45, 45)");
});
$("#def-stats-btn").hover(
function(){
$("#def-stats-btn").css("background-color", "rgb(40, 40, 40)");
},function(){
if (def_stats_ctrl) {
$("#def-stats-btn").css("background-color", "rgb(30, 30, 30)");
} else {
$("#def-stats-btn").css("background-color", "rgb(45, 45, 45)");
}
});
// item tooltip
$("#weapon-img-loc").hover(function(event){
$("#weapon-tooltip").show();
init_tooltip_loc('weapon');
2021-10-17 15:53:48 +00:00
}, function(){
$("#weapon-tooltip").hide();
});
$("#helmet-img-loc").hover(function(event){
$("#helmet-tooltip").show();
init_tooltip_loc('helmet');
2021-10-17 15:53:48 +00:00
}, function(){
$("#helmet-tooltip").hide();
});
$("#chestplate-img-loc").hover(function(event){
$("#chestplate-tooltip").show();
init_tooltip_loc('chestplate');
2021-10-17 15:53:48 +00:00
}, function(){
$("#chestplate-tooltip").hide();
});
$("#leggings-img-loc").hover(function(event){
$("#leggings-tooltip").show();
init_tooltip_loc('leggings');
2021-10-17 15:53:48 +00:00
}, function(){
$("#leggings-tooltip").hide();
});
$("#boots-img-loc").hover(function(event){
$("#boots-tooltip").show();
init_tooltip_loc('boots');
2021-10-17 15:53:48 +00:00
}, function(){
$("#boots-tooltip").hide();
});
$("#ring1-img-loc").hover(function(event){
$("#ring1-tooltip").show();
init_tooltip_loc('ring1');
2021-10-17 15:53:48 +00:00
}, function(){
$("#ring1-tooltip").hide();
});
$("#ring2-img-loc").hover(function(event){
$("#ring2-tooltip").show();
init_tooltip_loc('ring2');
2021-10-17 15:53:48 +00:00
}, function(){
$("#ring2-tooltip").hide();
});
$("#bracelet-img-loc").hover(function(event){
$("#bracelet-tooltip").show();
init_tooltip_loc('bracelet');
2021-10-17 15:53:48 +00:00
}, function(){
$("#bracelet-tooltip").hide();
});
$("#necklace-img-loc").hover(function(event){
$("#necklace-tooltip").show();
init_tooltip_loc('necklace');
2021-10-17 15:53:48 +00:00
}, function(){
$("#necklace-tooltip").hide();
});
2021-10-17 15:53:48 +00:00
});
function set_input_style(type) {
let item = itemMap.get($("#"+type+"-choice").val());
if (item) {
$("#"+type+"-choice").addClass(item.tier);
if (type == 'weapon') {
$("#"+type+"-img").attr('src', 'media/items/new/generic-'+item.type+'.png');
}
} else {
$("#"+type+"-choice").attr('class', 'item-name');
}
}
function init_tooltip_loc(equipment){
let ImgLoc = document.getElementById(equipment+'-img-loc').getBoundingClientRect();
let tooltipRect = document.getElementById(equipment+"-tooltip").getBoundingClientRect();
let windowHeight = $(window).height()
$("#"+equipment+"-tooltip").css('top', Math.min(ImgLoc.top, windowHeight - (tooltipRect.bottom - tooltipRect.top)));
$("#"+equipment+"-tooltip").css('left', ImgLoc.right);
}
2021-10-17 15:53:48 +00:00
function update_powder_count(type, alt="") {
let item = itemMap.get($("#"+type+"-choice").val());
if (item) {
$("#"+type+"-powder").attr("placeholder", item["slots"]+" slots"+alt);
}
}
function init_equipUI() {
for (const i in equipment_keys) {
set_input_style(equipment_keys[i]);
}
update_powder_count('weapon');
update_powder_count('helmet', '|example: t6t6');
update_powder_count('chestplate');
update_powder_count('leggings');
update_powder_count('boots');
}
// phanta method of handling input <3
let calcBuildTask = null;
let updateStatTask = null;
let doSearchTask = null;
function calcBuildSchedule(){
if (calcBuildTask !== null) {
clearTimeout(calcBuildTask);
}
calcBuildTask = setTimeout(function(){
calcBuildTask = null;
calculateBuild();
}, 500);
}
function updateStatSchedule(){
if (updateStatTask !== null) {
clearTimeout(updateStatTask);
}
updateStatTask = setTimeout(function(){
updateStatTask = null;
updateStats();
}, 500);
}
function doSearchSchedule(){
if (doSearchTask !== null) {
clearTimeout(doSearchTask);
}
doSearchTask = setTimeout(function(){
doSearchTask = null;
doItemSearch();
}, 500);
2021-10-17 15:53:48 +00:00
}