actor picker 1

This commit is contained in:
François-Xavier Guillois
2023-09-01 19:59:44 +02:00
parent 918b7c0b0c
commit e11525564a
13 changed files with 136 additions and 20 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 336 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 362 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 335 KiB

-1
View File
@@ -253,7 +253,6 @@ export class VermineActorSheet extends ActorSheet {
weapons.push(i);
}
else if (i.type === 'ability') {
console.log('ability', i);
if (i.system.type == 'totem'){
totem_abilities.push(i);
} else {
+18 -1
View File
@@ -1,6 +1,6 @@
import {onManageActiveEffect, prepareActiveEffectCategories} from "../system/effects.mjs";
import { VermineActorSheet } from "./actor-sheet.mjs";
import { TotemPicker } from "../system/applications.mjs";
import { TotemPicker, ActorPicker } from "../system/applications.mjs";
/**
* Extend the basic ActorSheet with some very simple modifications
@@ -147,6 +147,9 @@ export class VermineGroupSheet extends VermineActorSheet {
// Choose Totem
html.find('.chooseTotem').click(this._onTotemButton.bind(this));
// Choose Members / Encounters
html.find('.chooseActor').click(this._onRoadButton.bind(this));
if (this.actor.isOwner) {
let handler = ev => this._onDragStart(ev);
html.find('li.item').each((i, li) => {
@@ -230,4 +233,18 @@ export class VermineGroupSheet extends VermineActorSheet {
totemPicker.render(true);
}
/**
* Handle actor pick
* @param {Event} event The originating click event
* @private
*/
_onRoadButton(event) {
event.preventDefault();
const el = event.currentTarget;
// const dataset = el.dataset;
const actorPicker = new ActorPicker(el, this.actor);
actorPicker.render(true);
}
}
+77 -1
View File
@@ -22,7 +22,6 @@ export class TotemPicker extends Application {
getData() {
// Send data to the template
return {
config: CONFIG.VERMINE,
/*anarchy: this.gmAnarchy.getAnarchy(),
@@ -49,3 +48,80 @@ export class TotemPicker extends Application {
// console.log(formData.exampleInput);
}*/
}
export class ActorPicker extends Application {
constructor(linkEl, actor) {
super();
this.linkEl = linkEl;
this.actor = actor;
}
/* -------------------------------------------- */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
id:"ACTOR_PICKER",
title:game.i18n.localize("VERMINE.actor_picker"),
template:'systems/vermine2047/templates/applications/choose-actor.hbs',
popOut:true,
resizable:true,
height:"600",
width:"600"
});
}
getData() {
// Send data to the template
const npcs = game.actors.filter(a => a.type == "npc");
const characters = game.actors.filter(a => a.type == "character");
const encounters = game.actors.filter(a => a.type == "npc" || a.type == 'character');
const type = $(this.linkEl).data('type');
let actorsList = [];
if (type == 'members'){
actorsList = characters;
} else if (type == 'relations'){
actorsList = npc;
} else {
actorsList = encounters;
}
return {
config: CONFIG.VERMINE,
actorsList: actorsList
}
}
activateListeners(html) {
super.activateListeners(html);
html.find('.actor').click(event => {
const actorId = $(event.target).parent('div').data('id');
let actorsList = [];
const type = $(this.linkEl).data('type');
if (type == 'members'){
actorsList = this.actor.system.members;
} else if (type == 'encounters'){
actorsList = this.actor.system.encounters;
}
if (!Array.isArray(actorsList)){
actorsList = [];
}
console.log(actorsList, type, this.actor.system.encounters, this.actor.system.members);
actorsList.push(actorId);
if (type == 'members'){
actorsList = this.actor.system.members;
this.actor.update({ 'system.members': actorsList });
} else if (type == 'encounters'){
this.actor.update({ 'system.encounters': actorsList });
}
console.log(actorsList);
});
}
}
+2 -1
View File
@@ -379,7 +379,8 @@
"min": 1,
"max": 7
},
"members": []
"members": [],
"encounters": []
},
"creature": {
"templates": ["base"],
+16 -4
View File
@@ -1,6 +1,9 @@
<div class="grid grid-2col">
<div>
<h4 class="align-center">{{ localize 'VERMINE.group_members'}}</h4>
<h4 class="align-center">
<span>{{ localize 'VERMINE.group_members'}}</span>
<a class="item-control chooseActor" title="Add member" data-type="members"><i class="fas fa-plus"></i></a>
</h4>
<ol class="list-item">
{{#each specialties as |item id|}}
<li class="item flexrow" data-item-id="{{item._id}}">
@@ -16,7 +19,10 @@
</ol>
</div>
<div>
<h4 class="align-center">{{ localize 'VERMINE.encounters'}}</h4>
<h4 class="align-center">
<span>{{ localize 'VERMINE.encounters'}}</span>
<a class="item-control chooseActor" title="Add member" data-type="encounters"><i class="fas fa-plus"></i></a>
</h4>
<ol class="list-item">
{{#each backgrounds as |item id|}}
<li class="item flexrow" data-item-id="{{item._id}}">
@@ -32,7 +38,10 @@
</ol>
</div>
<div>
<h4 class="align-center">{{ localize 'VERMINE.boost'}}</h4>
<h4 class="align-center">
<span>{{ localize 'VERMINE.boost'}}</span>
<a class="item-control chooseActor" title="Add encounter" data-type="npc"><i class="fas fa-plus"></i></a>
</h4>
<ol class="list-item">
{{#each abilities as |item id|}}
<li class="item flexrow" data-item-id="{{item._id}}">
@@ -48,7 +57,10 @@
</ol>
</div>
<div>
<h4 class="align-center">{{ localize 'VERMINE.totem_abilities'}}</h4>
<h4 class="align-center">
<span>{{ localize 'VERMINE.totem_abilities'}}</span>
<a class="item-control item-create" title="Create item" data-type="ability"><i class="fas fa-plus"></i></a>
</h4>
<ol class="list-item">
{{#each totem_abilities as |item id|}}
<li class="item flexrow" data-item-id="{{item._id}}">
+8
View File
@@ -0,0 +1,8 @@
<div class="actor choose flexrow row">
{{#each actorsList as | actor akey|}}
<div class="actor rounded-full" data-totem="{{ tk }}" data-id="{{ actor.id }}" style="position:relative; width:100px;height:100px;">
<span class="flexrow w-full flex-group-center flex-align-center" style="position:absolute;z-index:10;height:100%;">{{ actor.name }}</span>
<img src="{{ actor.img }}" alt="{{ actor.name }}" width="100" height="100" style="position:relative;" />
</div>
{{/each}}
</div>
+15 -12
View File
@@ -6,21 +6,24 @@
</div>
</header>
{{!-- Sheet Tab Navigation --}}
<nav class="sheet-tabs tabs" data-group="primary">
<a class="item active" data-tab="description">Description</a>
<a class="item active" data-tab="description">{{ VERMINE.stats }}</a>
</nav>
{{!-- Sheet Body --}}
<section class="sheet-body">
{{!-- Description Tab --}}
<div class="tab" data-group="primary" data-tab="description">
{{editor system.description target="system.description" rollData=rollData button=true owner=owner editable=editable}}
<div class="tab flexrow" data-group="primary" data-tab="description">
<aside style="flex:1">
<div class="resource">
<label class="resource-label">{{ localize "VERMINE.level"}}</label>
<input type="number" name="system.level" value="{{system.level}}" data-dtype="Number"/>
</div>
<div class="resource">
<label class="resource-label">{{ localize "VERMINE.type"}}</label>
<input type="number" name="system.type" value="{{system.type}}" data-dtype="Number"/>
</div>
</aside>
<main class="editor-wrapper" style="flex:10">
{{editor system.description target="system.description" rollData=rollData button=true owner=owner editable=editable}}
</main>
</div>
</section>
</form>