Add anatomical character customization at initial creation
This commit is contained in:
+9
-10
@@ -1,7 +1,5 @@
|
||||
import './style.css';
|
||||
import { showCharacterCreator } from './appearance-editor';
|
||||
import type { Appearance } from './generated';
|
||||
let draftAppearance: Appearance | undefined;
|
||||
import { createAppearanceEditor } from './appearance-editor';
|
||||
import {createItemActions} from './item-actions';
|
||||
import { showTravel } from './travel';
|
||||
import { createHousingPanel } from './housing-panel';
|
||||
@@ -357,15 +355,16 @@ async function boot() {
|
||||
}
|
||||
if(config.kind==='hub'){visible('join-form',false);$('arrival-error').textContent='Enter a hub through travel from your current character. Open your account to continue.';}
|
||||
}
|
||||
const customize = document.createElement('button'); customize.type = 'button'; customize.textContent = 'Create your look';
|
||||
customize.onclick = () => showCharacterCreator(draftAppearance, async appearance => { draftAppearance = appearance; customize.textContent = 'Edit your look'; });
|
||||
$('join-form').insertBefore(customize, $('join'));
|
||||
const restyle = document.createElement('button'); restyle.type = 'button'; restyle.textContent = 'Character appearance';
|
||||
restyle.onclick = () => showCharacterCreator(snapshot?.self.entity.appearance, async appearance => { await api('/api/appearance', appearance); notice('Appearance saved.'); });
|
||||
$('settings').append(restyle);
|
||||
let characterEditor: ReturnType<typeof createAppearanceEditor> | undefined;
|
||||
if (me && !me.character && !me.active && config.kind !== 'hub') {
|
||||
characterEditor = createAppearanceEditor(['human'], undefined, [], true);
|
||||
$('arrival').classList.add('arrival-creator');
|
||||
$('arrival-status').textContent = 'Choose your name and appearance. This is who you will be in this life.';
|
||||
$('join-form').insertBefore(characterEditor.node, $('join'));
|
||||
}
|
||||
$<HTMLFormElement>('join-form').onsubmit = async event => {
|
||||
event.preventDefault(); const button = $<HTMLButtonElement>('join'); button.disabled = true;
|
||||
try { await api('/api/join', { name: $<HTMLInputElement>('name').value, passage: '', appearance: draftAppearance }); $<HTMLDialogElement>('arrival').close(); connect(); }
|
||||
try { await api('/api/join', { name: $<HTMLInputElement>('name').value, passage: '', appearance: characterEditor?.read() }); $<HTMLDialogElement>('arrival').close(); characterEditor?.dispose(); connect(); }
|
||||
catch (e) { $('arrival-error').textContent = (e as Error).message; }
|
||||
finally { button.disabled = false; }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user