Ajoute l'assistant IA "Ruby" (Claude + Scenario) et corrige plusieurs bugs de la scène
Intègre un chat IA capable de manipuler la scène via les mêmes fonctions que l'éditeur manuel (objets, variables, déclencheurs, images générées), avec conversations multiples par écran façon Claude. Corrige au passage le rafraîchissement pjax hors-ordre, l'onglet IA/déclencheurs vide après sélection d'un objet, la comparaison de booléens dans les conditions, et le blocage du glisser-déposer hors du cadre caméra après un redimensionnement de fond par l'IA. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
ab6635eee0
commit
b07b231a61
@@ -0,0 +1,67 @@
|
||||
// ---------- Onglet "Variables" — CRUD en AJAX ----------
|
||||
// Demande explicite : modifier/supprimer une variable rechargeait toute
|
||||
// la page (formulaires classiques + navigation pjax) — remplacé par de
|
||||
// vrais appels fetch(), sans jamais recharger ni naviguer.
|
||||
|
||||
// Enregistre automatiquement dès qu'un champ (type/valeur) change — plus
|
||||
// besoin d'un bouton "Enregistrer" séparé (demande explicite : "que la
|
||||
// modification s'enregistre automatiquement").
|
||||
function saveGlobalVariable(varId) {
|
||||
var row = document.querySelector('tr[data-var-row="' + varId + '"]');
|
||||
if (!row) return;
|
||||
var type = row.querySelector('select[name="type"]').value;
|
||||
var value = row.querySelector('input[name="value"]').value;
|
||||
var status = document.getElementById('varSaveStatus' + varId);
|
||||
var body = new FormData();
|
||||
body.append('type', type);
|
||||
body.append('value', value);
|
||||
fetch('/game/' + GAME_SLUG + '/variables/' + varId + '/edit', {
|
||||
method: 'POST', headers: { 'X-Requested-With': 'fetch' }, body: body,
|
||||
})
|
||||
.then(function (r) {
|
||||
if (!r.ok) { window.location.reload(); return; }
|
||||
if (status) {
|
||||
status.textContent = 'Enregistré ✓';
|
||||
setTimeout(function () { status.textContent = ''; }, 2000);
|
||||
}
|
||||
})
|
||||
.catch(function () { window.location.reload(); });
|
||||
}
|
||||
|
||||
function deleteGlobalVariable(varId, name) {
|
||||
if (!confirm('Supprimer la variable « ' + name + ' » ? Toute condition/action qui la référence encore cessera de fonctionner.')) return;
|
||||
var body = new FormData();
|
||||
fetch('/game/' + GAME_SLUG + '/variables/' + varId + '/delete', {
|
||||
method: 'POST', headers: { 'X-Requested-With': 'fetch' }, body: body,
|
||||
})
|
||||
.then(function (r) {
|
||||
if (!r.ok) { window.location.reload(); return; }
|
||||
var row = document.querySelector('tr[data-var-row="' + varId + '"]');
|
||||
if (row) row.remove();
|
||||
var body2 = document.getElementById('globalVariablesBody');
|
||||
var emptyHint = document.getElementById('globalVariablesEmptyHint');
|
||||
if (body2 && emptyHint) emptyHint.style.display = body2.children.length ? 'none' : '';
|
||||
})
|
||||
.catch(function () { window.location.reload(); });
|
||||
}
|
||||
|
||||
function createGlobalVariable(event) {
|
||||
event.preventDefault();
|
||||
var form = event.target;
|
||||
var body = new FormData(form);
|
||||
fetch('/game/' + GAME_SLUG + '/variables/new', {
|
||||
method: 'POST', headers: { 'X-Requested-With': 'fetch' }, body: body,
|
||||
})
|
||||
.then(function (r) { return r.ok ? r.json() : Promise.reject(); })
|
||||
.then(function (json) {
|
||||
if (!json.row_html) { window.location.reload(); return; }
|
||||
var tbody = document.getElementById('globalVariablesBody');
|
||||
tbody.insertAdjacentHTML('beforeend', json.row_html);
|
||||
var emptyHint = document.getElementById('globalVariablesEmptyHint');
|
||||
if (emptyHint) emptyHint.style.display = 'none';
|
||||
form.reset();
|
||||
form.style.display = 'none'; // même comportement que toggleDashCreate() après création
|
||||
})
|
||||
.catch(function () { window.location.reload(); });
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user