Widget:Character.WeaponToggle
Ir para navegação
Ir para pesquisar
<script>
(() => {
const applyWeaponState = (enabled) => {
if (typeof window.__setGlobalWeaponEnabled === 'function') {
window.__setGlobalWeaponEnabled(enabled);
}
document.querySelectorAll('.char-weapon-btn').forEach(b => {
b.classList.toggle('active', enabled);
});
try {
localStorage.setItem('glaWeaponEnabled', enabled ? '1' : '0');
} catch (x) { }
const lastIcon = window.__lastActiveSkillIcon;
if (lastIcon && typeof lastIcon.click === 'function') {
document.body.dataset.suppressSkillPlay = '1';
setTimeout(() => {
lastIcon.click();
setTimeout(() => delete document.body.dataset.suppressSkillPlay, 100);
}, 10);
}
};
const showPopup = () => {
const m = document.getElementById('weapon-info-modal');
if (m) m.classList.add('show');
};
const hidePopup = () => {
const m = document.getElementById('weapon-info-modal');
if (m) m.classList.remove('show');
};
const boot = () => {
// Verificar se existe alguma skill com arma
const hasAnyWeapon = document.querySelectorAll('.skill-icon[data-weapon]').length > 0;
if (!hasAnyWeapon) return; // Não criar toggle se não houver armas
// Encontrar posição: após .top-rail.skills
const skillsRail = document.querySelector('.top-rail.skills');
if (!skillsRail) return;
// Criar botão de toggle
const w = document.createElement('div');
w.className = 'char-weapon-toggle';
w.innerHTML = `
<button class="char-weapon-btn" title="Visualizar com Arma">
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<rect x="3" y="11" width="18" height="11" rx="2"/>
<path d="M7 11V7a5 5 0 0 1 10 0v4"/>
</svg>
Arma
</button>
`;
skillsRail.parentElement.insertBefore(w, skillsRail.nextSibling);
// Criar modal informativo
const m = document.createElement('div');
m.id = 'weapon-info-modal';
m.className = 'weapon-modal';
m.innerHTML = `
`;
document.body.appendChild(m);
// Event listeners
document.addEventListener('click', (ev) => {
const btn = ev.target.closest('.char-weapon-btn');
if (btn) {
ev.preventDefault();
const cur = btn.classList.contains('active');
applyWeaponState(!cur);
if (!cur) {
try {
if (localStorage.getItem('glaWeaponPopupDismissed') !== '1') showPopup();
} catch (x) { showPopup(); }
}
return;
}
if (ev.target.closest('.weapon-modal-close') || ev.target.closest('.weapon-modal-btn')) {
const c = document.getElementById('weapon-dont-show');
if (c && c.checked) {
try { localStorage.setItem('glaWeaponPopupDismissed', '1'); } catch (x) { }
}
hidePopup();
return;
}
if (ev.target.classList.contains('weapon-modal-overlay')) {
hidePopup();
}
});
// Estado inicial
let init = false;
try {
if (localStorage.getItem('glaWeaponEnabled') === '1') init = true;
} catch (x) { }
setTimeout(() => applyWeaponState(init), 100);
};
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', boot);
} else {
boot();
}
})();
</script> <style>
/* Toggle container - design simplificado sem bordas duplas */
.char-weapon-toggle {
display: flex;
justify-content: center;
margin: 8px 0 4px;
z-index: 10;
}
/* Botão único, sem caixa externa */
.char-weapon-btn {
display: flex;
align-items: center;
gap: 6px;
padding: 6px 14px;
border-radius: 6px;
border: none;
background: rgba(74, 158, 255, 0.15);
cursor: pointer;
transition: all .2s ease;
color: rgba(255, 255, 255, .8);
font-size: 12px;
font-weight: 600;
letter-spacing: 0.3px;
}
.char-weapon-btn svg {
flex-shrink: 0;
opacity: 0.85;
}
.char-weapon-btn:hover {
background: rgba(74, 158, 255, 0.25);
color: #4A9EFF;
}
.char-weapon-btn:hover svg {
opacity: 1;
}
.char-weapon-btn.active {
background: rgba(74, 158, 255, 0.3);
color: #4A9EFF;
box-shadow: 0 0 12px rgba(74, 158, 255, 0.3);
}
.char-weapon-btn.active svg {
opacity: 1;
}
/* Modal - cores neutras */
.weapon-modal {
position: fixed;
inset: 0;
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
opacity: 0;
pointer-events: none;
transition: opacity .3s;
}
.weapon-modal.show {
opacity: 1;
pointer-events: all;
}
.weapon-modal-overlay {
position: absolute;
inset: 0;
background: rgba(0, 0, 0, .75);
-webkit-backdrop-filter: blur(4px);
backdrop-filter: blur(4px);
}
.weapon-modal-content {
position: relative;
background: linear-gradient(135deg, #1f1f1f, #2a2a2a);
border: 1px solid rgba(255, 255, 255, .12);
border-radius: 12px;
max-width: 420px;
width: 90%;
box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
animation: modalIn .3s;
}
@keyframes modalIn {
from {
transform: translateY(-20px);
opacity: 0;
}
to {
transform: translateY(0);
opacity: 1;
}
}
.weapon-modal-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16px 20px;
border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.weapon-modal-header h3 {
margin: 0;
font-size: 16px;
font-weight: 600;
color: #fff;
}
.weapon-modal-close {
background: transparent;
border: none;
color: rgba(255, 255, 255, .5);
font-size: 24px;
cursor: pointer;
padding: 0;
width: 28px;
height: 28px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 4px;
transition: all .15s;
}
.weapon-modal-close:hover {
background: rgba(255, 255, 255, .1);
color: #fff;
}
.weapon-modal-body {
padding: 20px;
color: rgba(255, 255, 255, .8);
line-height: 1.6;
font-size: 14px;
}
.weapon-modal-body p {
margin: 0 0 12px;
}
.weapon-modal-body p:last-child {
margin: 0;
}
.weapon-modal-body strong {
color: #4A9EFF;
}
.weapon-modal-footer {
display: flex;
align-items: center;
justify-content: space-between;
padding: 14px 20px;
border-top: 1px solid rgba(255, 255, 255, .08);
gap: 12px;
}
.weapon-modal-checkbox {
display: flex;
align-items: center;
gap: 8px;
font-size: 12px;
color: rgba(255, 255, 255, .6);
cursor: pointer;
}
.weapon-modal-checkbox input[type="checkbox"] {
accent-color: #4A9EFF;
}
.weapon-modal-btn {
background: #4A9EFF;
border: none;
color: #fff;
padding: 10px 24px;
border-radius: 6px;
font-weight: 600;
font-size: 13px;
cursor: pointer;
transition: all .2s;
}
.weapon-modal-btn:hover {
background: #2D7DD2;
transform: translateY(-1px);
}
@media (max-width: 600px) {
.char-weapon-toggle {
margin: 6px 0 2px;
}
.weapon-label {
display: none;
}
.char-weapon-btn {
padding: 6px 10px;
}
.weapon-modal-content {
width: 95%;
}
.weapon-modal-header,
.weapon-modal-body,
.weapon-modal-footer {
padding: 12px 16px;
}
.weapon-modal-footer {
flex-direction: column;
}
}
</style>