Add objct for Dialog
This commit is contained in:
parent
7a15bcc0ba
commit
1f875bafc5
23
RdD.geany
23
RdD.geany
@ -27,17 +27,18 @@ long_line_behaviour=1
|
|||||||
long_line_column=72
|
long_line_column=72
|
||||||
|
|
||||||
[files]
|
[files]
|
||||||
current_page=6
|
current_page=10
|
||||||
FILE_NAME_0=8094;JSON;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplate.json;0;2
|
FILE_NAME_0=8019;JSON;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplate.json;0;2
|
||||||
FILE_NAME_1=0;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Factor-sheet.js;0;2
|
FILE_NAME_1=2995;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Factor-sheet.js;0;2
|
||||||
FILE_NAME_2=4774;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Factor-sheet.html;0;2
|
FILE_NAME_2=9441;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Factor-sheet.html;0;2
|
||||||
FILE_NAME_3=13265;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Frdd-utility.js;0;2
|
FILE_NAME_3=6869;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Factor.js;0;2
|
||||||
FILE_NAME_4=985;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Fsimple.js;0;2
|
FILE_NAME_4=6424;CSS;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fstyles%2Fsimple.css;0;2
|
||||||
FILE_NAME_5=6984;CSS;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fstyles%2Fsimple.css;0;2
|
FILE_NAME_5=4430;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Frdd-utility.js;0;2
|
||||||
FILE_NAME_6=8465;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Factor.js;0;2
|
FILE_NAME_6=1134;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2FWFRP-4th-Edition-FoundryVTT_SLADECRAVEN%2Ftemplates%2Factors%2Factor-skills.html;0;2
|
||||||
FILE_NAME_7=1134;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2FWFRP-4th-Edition-FoundryVTT_SLADECRAVEN%2Ftemplates%2Factors%2Factor-skills.html;0;2
|
FILE_NAME_7=7542;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2FWFRP-4th-Edition-FoundryVTT_SLADECRAVEN%2Fscripts%2Factor%2Fsheet%2Fcharacter-sheet.js;0;2
|
||||||
FILE_NAME_8=7542;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2FWFRP-4th-Edition-FoundryVTT_SLADECRAVEN%2Fscripts%2Factor%2Fsheet%2Fcharacter-sheet.js;0;2
|
FILE_NAME_8=705;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Fdialog-competence.html;0;2
|
||||||
FILE_NAME_9=956;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Fdialog-competence.html;0;2
|
FILE_NAME_9=985;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Fsimple.js;0;2
|
||||||
|
FILE_NAME_10=795;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Fitem-arme-sheet.html;0;2
|
||||||
|
|
||||||
[VTE]
|
[VTE]
|
||||||
last_dir=/home/sigmar
|
last_dir=/home/sigmar
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { RdDUtility } from "./rdd-utility.js";
|
import { RdDUtility } from "./rdd-utility.js";
|
||||||
|
import { RdDRollDialog } from "./rdd-roll-dialog.js";
|
||||||
|
|
||||||
export class RdDActor extends Actor {
|
export class RdDActor extends Actor {
|
||||||
|
|
||||||
@ -40,6 +41,7 @@ export class RdDActor extends Actor {
|
|||||||
if (actorData.type === 'personnage') this._prepareCharacterData(actorData);
|
if (actorData.type === 'personnage') this._prepareCharacterData(actorData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
/**
|
/**
|
||||||
* Prepare Character type specific data
|
* Prepare Character type specific data
|
||||||
*/
|
*/
|
||||||
@ -178,97 +180,26 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
rollArme( armeName ) {
|
rollArme( armeName ) {
|
||||||
// TODO : Search the weapon in the items
|
let armeItem = RdDUtility.findCompetence( this.data.items, armeName);
|
||||||
|
this.rollCompetence( armeItem.data.competence, armeItem );
|
||||||
// TODO : Get the associated compentence
|
|
||||||
|
|
||||||
// TODO call rollCompetence with the comp+arme
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async rollCompetence( compName, arme ) {
|
async rollCompetence( compName, armeItem ) {
|
||||||
|
|
||||||
let compItem = RdDUtility.findCompetence( this.data.items, compName);
|
let compItem = RdDUtility.findCompetence( this.data.items, compName);
|
||||||
let rollData = {
|
let rollData = {
|
||||||
"competence": compItem,
|
"competence": compItem,
|
||||||
|
"arme": armeItem,
|
||||||
"carac": this.data.data.carac,
|
"carac": this.data.data.carac,
|
||||||
"bonusmalusTable": CONFIG.RDD.bonusmalus,
|
"bonusmalusTable": CONFIG.RDD.bonusmalus,
|
||||||
"etat": this.data.data.compteurs.etat.value,
|
"etat": this.data.data.compteurs.etat.value,
|
||||||
"bmValue": 0,
|
"bmValue": 0,
|
||||||
"arme": arme,
|
|
||||||
"finalLevel": 0
|
"finalLevel": 0
|
||||||
}
|
}
|
||||||
|
|
||||||
let dlg = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html', rollData);
|
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html', rollData);
|
||||||
let mydialog = new Dialog(
|
new RdDRollDialog("competence", html, rollData, this ).render(true);
|
||||||
{
|
|
||||||
title: "Test de compétence",
|
|
||||||
content: dlg,
|
|
||||||
buttons:
|
|
||||||
{
|
|
||||||
rollButton:
|
|
||||||
{
|
|
||||||
label: "Lancer",
|
|
||||||
callback: html => this.performRoll(html)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
default: "rollButton"
|
|
||||||
}, {
|
|
||||||
classes: ["rdddialog"],
|
|
||||||
width: 600,
|
|
||||||
height: 360
|
|
||||||
} );
|
|
||||||
|
|
||||||
mydialog.data.rollData = rollData;
|
|
||||||
mydialog.data.actor = this;
|
|
||||||
mydialog.activateListeners = function(html) {
|
|
||||||
// Get the rollData stuff
|
|
||||||
var rollData = this.data.rollData;
|
|
||||||
|
|
||||||
function updateRollResult( rollData ) {
|
|
||||||
rollData.finalLevel = parseInt(rollData.competence.data.niveau) + parseInt(rollData.bmValue) + parseInt(rollData.etat);
|
|
||||||
rollData.finalLevelStr = (rollData.finalLevel >= 0 ) ? "+" + rollData.finalLevel : rollData.finalLevel;
|
|
||||||
$("#roll-param").text( rollData.selectedCarac.value + " / " + rollData.finalLevelStr );
|
|
||||||
rollData.rollTarget = game.data.RdDUtility.getResolutionField( rollData.selectedCarac.value, rollData.finalLevel);
|
|
||||||
let niveauStr = (rollData.competence.data.niveau >= 0) ? "+" + rollData.competence.data.niveau : rollData.competence.data.niveau;
|
|
||||||
$("#compdialogTitle").text( rollData.competence.name + " - " + niveauStr + " - " + rollData.selectedCarac.label );
|
|
||||||
$(".table-resolution").remove();
|
|
||||||
game.data.RdDUtility.makeHTMLResolutionTable( $("#resolutionTable"), rollData.selectedCarac.value-2, parseInt(rollData.selectedCarac.value) + 2, -10, 11,
|
|
||||||
rollData.selectedCarac.value, rollData.finalLevel );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup everything onload
|
|
||||||
$(function() {
|
|
||||||
// Set the default carac from the competence item
|
|
||||||
rollData.selectedCarac = rollData.carac[rollData.competence.data.carac_defaut];
|
|
||||||
// Update html, according to data
|
|
||||||
$("#carac").val( rollData.competence.data.carac_defaut );
|
|
||||||
$("#bonusmalus").val( rollData.bmValue );
|
|
||||||
updateRollResult(rollData);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// Replace again the button action, as i overwritten it
|
|
||||||
$('button').click((event) => {
|
|
||||||
mydialog.data.actor.performRoll(rollData);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Update !
|
|
||||||
$('#bonusmalus').click((event) => {
|
|
||||||
rollData.bmValue = event.currentTarget.value; // Update the selected bonus/malus
|
|
||||||
//console.log("BM CLICKED !!!", rollData.bmValue, rollData.competence.data.niveau, parseInt(rollData.competence.data.niveau) + parseInt(rollData.bmValue) );
|
|
||||||
updateRollResult(rollData);
|
|
||||||
});
|
|
||||||
$('#carac').click((event) => {
|
|
||||||
let caracKey = event.currentTarget.value;
|
|
||||||
rollData.selectedCarac = rollData.carac[caracKey]; // Update the selectedCarac
|
|
||||||
//console.log("CARAC CLICKED !!!", rollData.selectedCarac, rollData.competence.data.niveau, rollData.bmValue);
|
|
||||||
updateRollResult(rollData);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
mydialog.render(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
93
module/rdd-roll-dialog.js
Normal file
93
module/rdd-roll-dialog.js
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
/**
|
||||||
|
* Extend the base Dialog entity by defining a custom window to perform roll.
|
||||||
|
* @extends {Dialog}
|
||||||
|
*/
|
||||||
|
|
||||||
|
export class RdDRollDialog extends Dialog {
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
constructor(mode, html, rollData, actor) {
|
||||||
|
|
||||||
|
// Common conf
|
||||||
|
let dialogConf = {
|
||||||
|
content: html,
|
||||||
|
buttons:
|
||||||
|
{
|
||||||
|
rollButton:
|
||||||
|
{
|
||||||
|
label: "Lancer",
|
||||||
|
callback: html => this.performRoll(html)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
default: "rollButton"
|
||||||
|
}
|
||||||
|
let dialogOptions = { classes: [ "rdddialog"] }
|
||||||
|
|
||||||
|
// Select proper roll dialog template and stuff
|
||||||
|
if (mode == "competence" ) {
|
||||||
|
dialogConf.title = "Test de compétence",
|
||||||
|
dialogOptions.width = 600;
|
||||||
|
dialogOptions.height = 360;
|
||||||
|
}
|
||||||
|
super(dialogConf, dialogOptions);
|
||||||
|
|
||||||
|
this.mode = mode;
|
||||||
|
this.rollData = rollData;
|
||||||
|
this.actor = actor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
performRoll (html) {
|
||||||
|
this.actor.performRoll( this.rollData );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
|
||||||
|
activateListeners(html) {
|
||||||
|
super.activateListeners(html);
|
||||||
|
|
||||||
|
// Get the rollData stuff
|
||||||
|
var rollData = this.rollData;
|
||||||
|
|
||||||
|
function updateRollResult( rollData ) {
|
||||||
|
rollData.finalLevel = parseInt(rollData.competence.data.niveau) + parseInt(rollData.bmValue) + parseInt(rollData.etat);
|
||||||
|
rollData.finalLevelStr = (rollData.finalLevel >= 0 ) ? "+" + rollData.finalLevel : rollData.finalLevel;
|
||||||
|
$("#roll-param").text( rollData.selectedCarac.value + " / " + rollData.finalLevelStr );
|
||||||
|
rollData.rollTarget = game.data.RdDUtility.getResolutionField( rollData.selectedCarac.value, rollData.finalLevel);
|
||||||
|
let niveauStr = (rollData.competence.data.niveau >= 0) ? "+" + rollData.competence.data.niveau : rollData.competence.data.niveau;
|
||||||
|
$("#compdialogTitle").text( rollData.competence.name + " - " + niveauStr + " - " + rollData.selectedCarac.label );
|
||||||
|
$(".table-resolution").remove();
|
||||||
|
game.data.RdDUtility.makeHTMLResolutionTable( $("#resolutionTable"), rollData.selectedCarac.value-2, parseInt(rollData.selectedCarac.value) + 2, -10, 11,
|
||||||
|
rollData.selectedCarac.value, rollData.finalLevel );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup everything onload
|
||||||
|
$(function() {
|
||||||
|
// Set the default carac from the competence item
|
||||||
|
rollData.selectedCarac = rollData.carac[rollData.competence.data.carac_defaut];
|
||||||
|
// Update html, according to data
|
||||||
|
$("#carac").val( rollData.competence.data.carac_defaut );
|
||||||
|
$("#bonusmalus").val( rollData.bmValue );
|
||||||
|
updateRollResult(rollData);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Replace again the button action, as i overwritten it
|
||||||
|
//$('button').click((event) => {
|
||||||
|
//mydialog.data.actor.performRoll(rollData);
|
||||||
|
//});
|
||||||
|
|
||||||
|
// Update !
|
||||||
|
$('#bonusmalus').click((event) => {
|
||||||
|
rollData.bmValue = event.currentTarget.value; // Update the selected bonus/malus
|
||||||
|
//console.log("BM CLICKED !!!", rollData.bmValue, rollData.competence.data.niveau, parseInt(rollData.competence.data.niveau) + parseInt(rollData.bmValue) );
|
||||||
|
updateRollResult(rollData);
|
||||||
|
});
|
||||||
|
$('#carac').click((event) => {
|
||||||
|
let caracKey = event.currentTarget.value;
|
||||||
|
rollData.selectedCarac = rollData.carac[caracKey]; // Update the selectedCarac
|
||||||
|
//console.log("CARAC CLICKED !!!", rollData.selectedCarac, rollData.competence.data.niveau, rollData.bmValue);
|
||||||
|
updateRollResult(rollData);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -303,7 +303,7 @@
|
|||||||
"dommages": 0,
|
"dommages": 0,
|
||||||
"force": 0,
|
"force": 0,
|
||||||
"resistance": 0,
|
"resistance": 0,
|
||||||
"famille": "",
|
"competence": "",
|
||||||
"cout": 0
|
"cout": 0
|
||||||
},
|
},
|
||||||
"munition": {
|
"munition": {
|
||||||
|
1
templates/arme-competence.html
Normal file
1
templates/arme-competence.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
49
templates/item-arme-sheet.html
Normal file
49
templates/item-arme-sheet.html
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<form class="{{cssClass}}" autocomplete="off">
|
||||||
|
<header class="sheet-header">
|
||||||
|
<img class="profile-img" src="{{item.img}}" data-edit="img" title="{{item.name}}"/>
|
||||||
|
<div class="header-fields">
|
||||||
|
<h1 class="charname"><input name="name" type="text" value="{{item.name}}" placeholder="Name"/></h1>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
{{!-- Sheet Body --}}
|
||||||
|
<section class="sheet-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="categorie">Compétence</label>
|
||||||
|
<select name="data.competence" id="competence" data-dtype="String">
|
||||||
|
{{#select item.data.competence}}
|
||||||
|
{{each armeCompetence as |competence key|}}
|
||||||
|
<option value={{bmvalue}}>{{competence.name}}</option>
|
||||||
|
{{/each}}
|
||||||
|
{{/select}}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="niveau">Dommmages </label>
|
||||||
|
<input class="attribute-value" type="text" name="data.dommages" value="{{data.dommages}}" data-dtype="Number"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="xp">Résistance </label>
|
||||||
|
<input class="attribute-value" type="text" name="data.resistance" value="{{data.resistance}}" data-dtype="Number"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="xp">Encombrement </label>
|
||||||
|
<input class="attribute-value" type="text" name="data.encombrement" value="{{data.encombrement}}" data-dtype="Number"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="xp">Force min. </label>
|
||||||
|
<input class="attribute-value" type="text" name="data.force" value="{{data.force}}" data-dtype="Number"/>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="xp">Prix (sols) </label>
|
||||||
|
<input class="attribute-value" type="text" name="data.cout" value="{{data.cout}}" data-dtype="Number"/>
|
||||||
|
</div>
|
||||||
|
<header class="header-field">
|
||||||
|
<span>Description : </span>
|
||||||
|
</header>
|
||||||
|
<div class="form-group" style="height:200px">
|
||||||
|
{{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
</form>
|
Loading…
Reference in New Issue
Block a user