Adaptive Music v0.8.0 release candidate
Validate and generate manual release / package (push) Waiting to run
Validate and generate manual release / package (push) Waiting to run
This commit is contained in:
1 parent
8c07a468a4
commit
95b0427aa1
48 files changed
+3631
-313
No files matched your search
@@ -4,14 +4,28 @@
|
||||
<section id="adaptive-music-setup"><main id="app" class="window-content"></main></section>
|
||||
<script type="module">
|
||||
import {createSetupClass,createListenerClass} from '/src/foundry/setup.mjs';
|
||||
import {startConfigurationInterfaces} from '/src/foundry/configuration.mjs';
|
||||
let flag={},catalog=[];const settings={ownedPlaylistIds:'native',musicDefaults:{},enabled:false,advancedDevelopment:false};
|
||||
const collection=items=>{const map=new Map(items.map(x=>[x.id,x]));map[Symbol.iterator]=function*(){yield*map.values()};return map};
|
||||
const scene={id:'scene',name:'Moonlit forest',active:true,getFlag:()=>flag,setFlag:async(ns,k,v)=>{flag=v;window.saved=flag}};
|
||||
const scene={id:'scene',name:'Moonlit forest',documentName:'Scene',active:true,getFlag:()=>flag,setFlag:async(ns,k,v)=>{flag=v;window.saved=flag}};
|
||||
const game={user:{isGM:true},settings:{get:(ns,k)=>settings[k],set:async(ns,k,v)=>{settings[k]=v}},playlists:collection([{id:'native',name:'Foundry fallback'}]),scenes:collection([scene]),combats:[]};
|
||||
let trackState='playing',position=12;window.controlActions=[];
|
||||
const connection={status:{state:'disconnected',catalog:0,audioContext:'closed'},open:async p=>{if(p.token!=='fixture-token')throw {code:'denied'};catalog=[{provider:'ma',id:'ambient',kind:'playlist',name:'Forest at night'},{provider:'ma',id:'combat',kind:'playlist',name:'Battle drums'}];connection.status={state:'connected',catalog:2,audioContext:'running',hasPrivateDraft:true,peers:2}},refresh:async()=>{},resume:async()=>{},disconnect:async()=>{},playback:async()=>({source:'Music Assistant',state:trackState,title:'Forest at night',position,duration:90}),
|
||||
control:async(action,value)=>{window.controlActions.push(action);if(action==='seek')position=value;else trackState={pause:'paused',resume:'playing',stop:'idle'}[action];},setVolume:value=>{connection.status.volume=value;}};
|
||||
let trackState='playing',position=12,repeat='off';window.controlActions=[];
|
||||
const connection={status:{state:'disconnected',catalog:0,audioContext:'closed'},open:async p=>{if(p.token!=='fixture-token')throw {code:'denied'};catalog=[{provider:'ma',id:'ambient',kind:'playlist',name:'Forest at night'},{provider:'ma',id:'combat',kind:'playlist',name:'Battle drums'}];connection.status={state:'connected',catalog:2,audioContext:'running',hasPrivateDraft:true,peers:2}},refresh:async()=>{},resume:async()=>{},disconnect:async()=>{},playback:async()=>({source:'Music Assistant',state:trackState,title:'Forest at night',position,duration:90,repeat}),
|
||||
control:async(action,value)=>{window.controlActions.push(action);if(action==='seek')position=value;else if(action==='repeat')repeat=value;else trackState={pause:'paused',resume:'playing',stop:'idle'}[action];},setVolume:value=>{connection.status.volume=value;}};
|
||||
const Setup=createSetupClass({game,connection,getChoices:async()=>[{provider:'native',id:'native',name:'Foundry fallback'},...catalog],start(){},stop(){},setOverrides(){},onError(){},Base:class{}});
|
||||
document.querySelector('#app').append(await new Setup()._renderHTML());window.ready=true;
|
||||
window.nativeConfiguration=async()=>{
|
||||
const callbacks=new Map();
|
||||
const Hooks={on:(event,callback)=>callbacks.set(event,callback),off:event=>callbacks.delete(event)};
|
||||
const directory=document.createElement('aside'),sheet=document.createElement('section');
|
||||
directory.id='fixture-playlists';sheet.id='fixture-scene';document.body.append(directory,sheet);
|
||||
const interfaces=startConfigurationInterfaces({game,Hooks,getChoices:()=>catalog,onError(error){throw error;}});
|
||||
await callbacks.get('renderPlaylistDirectory')({},directory);
|
||||
window.refreshNativeConfiguration=async()=>{
|
||||
await interfaces.refreshDirectory({element:directory});
|
||||
await callbacks.get('renderSceneConfig')({document:scene},sheet);
|
||||
};
|
||||
window.closeNativeConfiguration=()=>{interfaces.dispose();directory.remove();sheet.remove();};
|
||||
};
|
||||
window.listener=async()=>{const Listener=createListenerClass({game,audio:{stop(){}},resumeListener:()=>{window.activated=true},Base:class{}});document.querySelector('#app').replaceChildren(await new Listener()._renderHTML())};
|
||||
</script>
|
||||
Reference in new issue
Block a user