mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-11-26 17:13:52 +01:00
fix(showcase): harden Smirk checkout and multiplayer presentation
This commit is contained in:
@@ -149,6 +149,7 @@
|
||||
return false;
|
||||
}
|
||||
if (visual.kind === 'skin') {
|
||||
if (RK.skinSheetFailed && RK.skinSheetFailed(visual.appearance.avatar)) return false;
|
||||
if (RK.skinSheet && RK.skinSheet(visual.appearance.avatar)) return true;
|
||||
if (!RK.loadSkin) return false;
|
||||
rememberLoad('skin:' + visual.appearance.avatar, function (done) {
|
||||
@@ -294,9 +295,18 @@
|
||||
function drawTopdownWorld(ctx, visual, entity, viewport, opts) {
|
||||
opts = opts || {};
|
||||
visual = visual && visual.appearance ? visual : resolve(visual, opts);
|
||||
if (!ctx || !entity || !viewport || !visual.allowed || !ensureCanvasReady(visual, opts.onReady)) return false;
|
||||
if (visual.kind === 'char') return drawTopdownChar(ctx, visual, entity, viewport, opts);
|
||||
if (visual.kind === 'skin') return drawTopdownSkin(ctx, visual, entity, viewport, opts);
|
||||
if (!ctx || !entity || !viewport || !visual.allowed) return false;
|
||||
if (visual.kind === 'char') {
|
||||
if (!ensureCanvasReady(visual, opts.onReady)) return false;
|
||||
return drawTopdownChar(ctx, visual, entity, viewport, opts);
|
||||
}
|
||||
if (visual.kind === 'skin') {
|
||||
if (ensureCanvasReady(visual, opts.onReady)) return drawTopdownSkin(ctx, visual, entity, viewport, opts);
|
||||
if (RK.skinSheetFailed && RK.skinSheetFailed(visual.appearance.avatar)) {
|
||||
var fallback = resolve({ avatar: 'char-villager' }, { projection: 'topdown', context: visual.context, entity: entity });
|
||||
if (ensureCanvasReady(fallback, opts.onReady)) return drawTopdownChar(ctx, fallback, entity, viewport, opts);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+13
-4
@@ -41,18 +41,27 @@
|
||||
var s = RK.SKINS[id];
|
||||
if (!s) return null;
|
||||
if (sheets[id]) return sheets[id];
|
||||
var rec = sheets[id] = { ready: false, cbs: [] };
|
||||
var rec = sheets[id] = { ready: false, failed: false, cbs: [] };
|
||||
var img = new Image();
|
||||
img.onload = function () {
|
||||
rec.ready = true; rec.img = img;
|
||||
rec.cbs.forEach(function (cb) { try { cb(rec); } catch (_) {} });
|
||||
rec.cbs = [];
|
||||
settle(rec);
|
||||
};
|
||||
img.onerror = function () {
|
||||
rec.failed = true;
|
||||
if (root.console) console.warn('skin sheet failed:', s.sheet);
|
||||
settle(rec);
|
||||
};
|
||||
img.onerror = function () { if (root.console) console.warn('skin sheet failed:', s.sheet); };
|
||||
img.src = s.sheet;
|
||||
return rec;
|
||||
};
|
||||
function settle(rec) {
|
||||
var callbacks = rec.cbs.slice();
|
||||
rec.cbs.length = 0;
|
||||
callbacks.forEach(function (cb) { try { cb(rec); } catch (_) {} });
|
||||
}
|
||||
RK.skinSheet = function (id) { return (sheets[id] && sheets[id].ready) ? sheets[id] : null; };
|
||||
RK.skinSheetFailed = function (id) { return !!(sheets[id] && sheets[id].failed); };
|
||||
|
||||
// --- Movement-aware frame selection ------------------------------------------------------
|
||||
var last = {}; // entity id -> { x, y, t }
|
||||
|
||||
Reference in New Issue
Block a user