Mudanças entre as edições de "Widget:Character.WeaponToggle"
Ir para navegação
Ir para pesquisar
m |
m |
||
| Linha 2: | Linha 2: | ||
<script> | <script> | ||
(() => { | (() => { | ||
let toggleContainer = null; | |||
const applyWeaponState = (enabled) => { | const applyWeaponState = (enabled) => { | ||
// Atualizar flag global | |||
if (typeof window.__setGlobalWeaponEnabled === 'function') { | if (typeof window.__setGlobalWeaponEnabled === 'function') { | ||
window.__setGlobalWeaponEnabled(enabled); | window.__setGlobalWeaponEnabled(enabled); | ||
} | } | ||
// Atualizar visual do botão | |||
document.querySelectorAll('.char-weapon-btn').forEach(b => { | document.querySelectorAll('.char-weapon-btn').forEach(b => { | ||
b.classList.toggle('active', enabled); | b.classList.toggle('active', enabled); | ||
}); | }); | ||
// Salvar preferência | |||
try { | try { | ||
localStorage.setItem('glaWeaponEnabled', enabled ? '1' : '0'); | localStorage.setItem('glaWeaponEnabled', enabled ? '1' : '0'); | ||
} catch (x) { } | } catch (x) { } | ||
// IMPORTANTE: Limpar TODOS os ícones weapon-equipped quando desativa | |||
if (!enabled) { | |||
document.querySelectorAll('.skill-icon.weapon-equipped').forEach(el => { | |||
el.classList.remove('weapon-equipped'); | |||
el.style.removeProperty('--weapon-badge-url'); | |||
}); | |||
} | |||
// Reatualizar o ícone ativo para aplicar/remover efeitos | |||
const lastIcon = window.__lastActiveSkillIcon; | const lastIcon = window.__lastActiveSkillIcon; | ||
if (lastIcon && typeof lastIcon.click === 'function') { | if (lastIcon && typeof lastIcon.click === 'function') { | ||
| Linha 31: | Linha 47: | ||
const m = document.getElementById('weapon-info-modal'); | const m = document.getElementById('weapon-info-modal'); | ||
if (m) m.classList.remove('show'); | if (m) m.classList.remove('show'); | ||
}; | |||
const updateToggleVisibility = () => { | |||
if (!toggleContainer) return; | |||
const skillsTab = document.getElementById('skills'); | |||
const isSkillsActive = skillsTab && skillsTab.classList.contains('active'); | |||
toggleContainer.style.display = isSkillsActive ? 'flex' : 'none'; | |||
}; | }; | ||
| Linha 36: | Linha 59: | ||
// Verificar se existe alguma skill com arma | // Verificar se existe alguma skill com arma | ||
const hasAnyWeapon = document.querySelectorAll('.skill-icon[data-weapon]').length > 0; | const hasAnyWeapon = document.querySelectorAll('.skill-icon[data-weapon]').length > 0; | ||
if (!hasAnyWeapon) return; | if (!hasAnyWeapon) return; | ||
// Encontrar posição: após . | // Encontrar posição: logo após .character-tabs | ||
const | const characterTabs = document.querySelector('.character-tabs'); | ||
if (! | if (!characterTabs) return; | ||
// Criar | // Criar container do toggle | ||
toggleContainer = document.createElement('div'); | |||
toggleContainer.className = 'char-weapon-toggle'; | |||
toggleContainer.innerHTML = ` | |||
<button class="char-weapon-btn" title="Visualizar com Arma"> | <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"> | <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"> | ||
| Linha 54: | Linha 77: | ||
</button> | </button> | ||
`; | `; | ||
characterTabs.parentElement.insertBefore(toggleContainer, characterTabs.nextSibling); | |||
// Criar modal informativo | // Criar modal informativo | ||
| Linha 82: | Linha 105: | ||
document.body.appendChild(m); | document.body.appendChild(m); | ||
// Event listeners | // Event listeners para o toggle | ||
document.addEventListener('click', (ev) => { | document.addEventListener('click', (ev) => { | ||
const btn = ev.target.closest('.char-weapon-btn'); | const btn = ev.target.closest('.char-weapon-btn'); | ||
| Linha 109: | Linha 132: | ||
}); | }); | ||
// Estado inicial | // Observar mudanças de aba para mostrar/ocultar toggle | ||
const tabBtns = document.querySelectorAll('.tab-btn'); | |||
tabBtns.forEach(btn => { | |||
btn.addEventListener('click', () => { | |||
setTimeout(updateToggleVisibility, 50); | |||
}); | |||
}); | |||
// Visibilidade inicial | |||
updateToggleVisibility(); | |||
// Estado inicial do toggle | |||
let init = false; | let init = false; | ||
try { | try { | ||
| Linha 125: | Linha 159: | ||
</script> | </script> | ||
<style> | <style> | ||
/* Toggle | /* Toggle posicionado abaixo das abas, alinhado com elas */ | ||
.char-weapon-toggle { | .char-weapon-toggle { | ||
display: flex; | display: flex; | ||
justify-content: center; | justify-content: flex-start; | ||
margin: 8px | align-items: center; | ||
margin: 0 0 6px 8px; | |||
z-index: 10; | z-index: 10; | ||
} | } | ||
/* Botão | /* Botão limpo e simples */ | ||
.char-weapon-btn { | .char-weapon-btn { | ||
display: flex; | display: flex; | ||
align-items: center; | align-items: center; | ||
gap: 6px; | gap: 6px; | ||
padding: | padding: 5px 12px; | ||
border-radius: 6px; | border-radius: 6px; | ||
border: none; | border: none; | ||
background: rgba(74, 158, 255, 0. | background: rgba(74, 158, 255, 0.12); | ||
cursor: pointer; | cursor: pointer; | ||
transition: | transition: background .2s, color .2s, box-shadow .2s; | ||
color: rgba(255, 255, 255, . | color: rgba(255, 255, 255, .7); | ||
font-size: 12px; | font-size: 12px; | ||
font-weight: 600; | font-weight: 600; | ||
} | } | ||
.char-weapon-btn svg { | .char-weapon-btn svg { | ||
flex-shrink: 0; | flex-shrink: 0; | ||
opacity: 0. | opacity: 0.8; | ||
transition: opacity .2s; | |||
} | } | ||
.char-weapon-btn:hover { | .char-weapon-btn:hover { | ||
background: rgba(74, 158, 255, 0. | background: rgba(74, 158, 255, 0.2); | ||
color: # | color: #6BB3FF; | ||
} | } | ||
| Linha 165: | Linha 200: | ||
.char-weapon-btn.active { | .char-weapon-btn.active { | ||
background: rgba(74, 158, 255, 0. | background: rgba(74, 158, 255, 0.25); | ||
color: # | color: #6BB3FF; | ||
box-shadow: 0 0 | box-shadow: 0 0 8px rgba(74, 158, 255, 0.25); | ||
} | } | ||
| Linha 174: | Linha 209: | ||
} | } | ||
/* Modal | /* Modal com cores neutras */ | ||
.weapon-modal { | .weapon-modal { | ||
position: fixed; | position: fixed; | ||
| Linha 275: | Linha 310: | ||
.weapon-modal-body strong { | .weapon-modal-body strong { | ||
color: # | color: #6BB3FF; | ||
} | } | ||
| Linha 319: | Linha 354: | ||
@media (max-width: 600px) { | @media (max-width: 600px) { | ||
.char-weapon-toggle { | .char-weapon-toggle { | ||
margin: 6px | margin: 0 0 4px 6px; | ||
} | } | ||
| Linha 327: | Linha 362: | ||
.char-weapon-btn { | .char-weapon-btn { | ||
padding: | padding: 5px 8px; | ||
} | } | ||
Edição das 11h04min de 28 de novembro de 2025
<script>
(() => {
let toggleContainer = null;
const applyWeaponState = (enabled) => {
// Atualizar flag global
if (typeof window.__setGlobalWeaponEnabled === 'function') {
window.__setGlobalWeaponEnabled(enabled);
}
// Atualizar visual do botão
document.querySelectorAll('.char-weapon-btn').forEach(b => {
b.classList.toggle('active', enabled);
});
// Salvar preferência
try {
localStorage.setItem('glaWeaponEnabled', enabled ? '1' : '0');
} catch (x) { }
// IMPORTANTE: Limpar TODOS os ícones weapon-equipped quando desativa
if (!enabled) {
document.querySelectorAll('.skill-icon.weapon-equipped').forEach(el => {
el.classList.remove('weapon-equipped');
el.style.removeProperty('--weapon-badge-url');
});
}
// Reatualizar o ícone ativo para aplicar/remover efeitos
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 updateToggleVisibility = () => {
if (!toggleContainer) return;
const skillsTab = document.getElementById('skills');
const isSkillsActive = skillsTab && skillsTab.classList.contains('active');
toggleContainer.style.display = isSkillsActive ? 'flex' : 'none';
};
const boot = () => {
// Verificar se existe alguma skill com arma
const hasAnyWeapon = document.querySelectorAll('.skill-icon[data-weapon]').length > 0;
if (!hasAnyWeapon) return;
// Encontrar posição: logo após .character-tabs
const characterTabs = document.querySelector('.character-tabs');
if (!characterTabs) return;
// Criar container do toggle
toggleContainer = document.createElement('div');
toggleContainer.className = 'char-weapon-toggle';
toggleContainer.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>
`;
characterTabs.parentElement.insertBefore(toggleContainer, characterTabs.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 para o toggle
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();
}
});
// Observar mudanças de aba para mostrar/ocultar toggle
const tabBtns = document.querySelectorAll('.tab-btn');
tabBtns.forEach(btn => {
btn.addEventListener('click', () => {
setTimeout(updateToggleVisibility, 50);
});
});
// Visibilidade inicial
updateToggleVisibility();
// Estado inicial do toggle
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 posicionado abaixo das abas, alinhado com elas */
.char-weapon-toggle {
display: flex;
justify-content: flex-start;
align-items: center;
margin: 0 0 6px 8px;
z-index: 10;
}
/* Botão limpo e simples */
.char-weapon-btn {
display: flex;
align-items: center;
gap: 6px;
padding: 5px 12px;
border-radius: 6px;
border: none;
background: rgba(74, 158, 255, 0.12);
cursor: pointer;
transition: background .2s, color .2s, box-shadow .2s;
color: rgba(255, 255, 255, .7);
font-size: 12px;
font-weight: 600;
}
.char-weapon-btn svg {
flex-shrink: 0;
opacity: 0.8;
transition: opacity .2s;
}
.char-weapon-btn:hover {
background: rgba(74, 158, 255, 0.2);
color: #6BB3FF;
}
.char-weapon-btn:hover svg {
opacity: 1;
}
.char-weapon-btn.active {
background: rgba(74, 158, 255, 0.25);
color: #6BB3FF;
box-shadow: 0 0 8px rgba(74, 158, 255, 0.25);
}
.char-weapon-btn.active svg {
opacity: 1;
}
/* Modal com 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: #6BB3FF;
}
.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: 0 0 4px 6px;
}
.weapon-label {
display: none;
}
.char-weapon-btn {
padding: 5px 8px;
}
.weapon-modal-content {
width: 95%;
}
.weapon-modal-header,
.weapon-modal-body,
.weapon-modal-footer {
padding: 12px 16px;
}
.weapon-modal-footer {
flex-direction: column;
}
}
</style>