v1.5.2_pre

This commit is contained in:
Cristian Deenen
2023-10-05 23:17:56 +02:00
parent 2cfa8c3ac9
commit 9242cf4978
13 changed files with 269 additions and 299 deletions

View File

@@ -916,8 +916,10 @@ export class ExternalModules{
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
updateMonksActiveTiles(settings,context,device) {
const id = settings.monksActiveTilesId;
if (id == undefined || id == '') return;
let tile = canvas.tiles.placeables.find(t => t.id == id);
if (tile == undefined) return;
const tileData = tile.document.flags?.['monks-active-tiles'];
if (tileData == undefined) return;
@@ -929,7 +931,7 @@ export class ExternalModules{
ring = 2;
ringColor = '#00ff00'
}
let src = tile.document.texture.sr;
let src = tile.document.texture.src;
streamDeck.setTitle('',context);
if (settings.iconOverride != '' && settings.iconOverride != undefined) src = settings.iconOverride;
@@ -946,6 +948,7 @@ export class ExternalModules{
if (tileData == undefined) return;
if (mode == 'toggle') tile.document.setFlag('monks-active-tiles','active',!tileData.active);
else tile.document.setFlag('monks-active-tiles','active',mode == 'enable');
}
}

View File

@@ -1,4 +1,4 @@
import { sdVersion, msVersion, moduleName, getPermission, enableModule, streamDeck, macroControl,soundboard,playlistControl, minimumMSversion, minimumSDversion } from "../MaterialDeck.js";
import { moduleName, getPermission, enableModule, macroControl, soundboard, playlistControl, releaseURLs, versions } from "../MaterialDeck.js";
export function compareVersions(checkedVersion, requiredVersion) {
requiredVersion = requiredVersion.split(".");
@@ -1041,21 +1041,7 @@ export class importConfigForm extends FormApplication {
export class downloadUtility extends FormApplication {
constructor(data, options) {
super(data, options);
this.localSDversion = sdVersion;
this.masterSDversion;
this.localMSversion = msVersion;
this.masterMSversion;
this.masterModuleVersion;
this.releaseAssets = [];
this.profiles = [];
let parent = this;
setTimeout(function(){
parent.checkForUpdate('SD');
parent.checkForUpdate('MS');
parent.checkForUpdate('Module');
parent.getReleaseData();
},100)
this.releases = {}
}
/**
@@ -1074,33 +1060,20 @@ export class downloadUtility extends FormApplication {
/**
* Provide data to the template
*/
getData() {
async getData() {
let dlDisabled = true;
this.profiles = [];
let iteration = 0;
for (let asset of this.releaseAssets) {
let split = asset.name.split('.');
if (split[split.length-1] == 'streamDeckProfile') {
this.profiles.push({id: iteration, label:split[0], url:asset.browser_download_url});
iteration++;
dlDisabled = false;
}
this.releases = {
module: await this.checkForUpdate('module'),
plugin: await this.checkForUpdate('plugin'),
materialCompanion: await this.checkForUpdate('materialCompanion')
}
if (this.localMSversion == undefined) this.localMSversion = 'unknown';
return {
minimumSdVersion: minimumSDversion,
localSdVersion: this.localSDversion,
masterSdVersion: this.masterSDversion,
sdDlDisable: this.masterSDversion == undefined,
minimumMsVersion: minimumMSversion,
localMsVersion: this.localMSversion,
masterMsVersion: this.masterMSversion,
msDlDisable: this.masterMSversion == undefined,
localModuleVersion: game.modules.get('MaterialDeck').version,
masterModuleVersion: this.masterModuleVersion,
profiles: this.profiles,
releases: this.releases,
versions,
sdDlDisable: this.releases.plugin == undefined,
msDlDisable: this.releases.materialCompanion == undefined,
profileDlDisable: dlDisabled
}
}
@@ -1118,38 +1091,22 @@ export class downloadUtility extends FormApplication {
super.activateListeners(html);
const downloadSd = html.find("button[id='materialDeck_dlUtil_downloadSd']");
const downloadMs = html.find("button[id='materialDeck_dlUtil_downloadMs']");
const downloadMc = html.find("button[id='materialDeck_dlUtil_downloadMc']");
const downloadProfile = html.find("button[name='downloadProfile']")
const refresh = html.find("button[id='materialDeck_dlUtil_refresh']");
//releaseURLs
downloadSd.on('click', () => {
const version = document.getElementById('materialDeck_dlUtil_masterSdVersion').innerHTML;
if (version == '' || version == undefined || version == 'Error') return;
const url = `https://github.com/CDeenen/MaterialDeck_SD/releases/download/v${version}/com.cdeenen.materialdeck.streamDeckPlugin`;
this.downloadURI(url,'com.cdeenen.materialdeck.streamDeckPlugin')
this.downloadURI(this.releases.plugin.url)
})
downloadMs.on('click', () => {
const version = document.getElementById('materialDeck_dlUtil_masterMsVersion').innerHTML;
downloadMc.on('click', () => {
const os = document.getElementById('materialDeck_dlUtil_os').value;
if (version == '' || version == undefined || version == 'Error') return;
let name = `MaterialServer-${os}.zip`;
let url;
if (os == 'source') url = `https://github.com/CDeenen/MaterialServer/archive/refs/tags/v${version}.zip`;
else url = `https://github.com/CDeenen/MaterialServer/releases/download/v${version}/${name}`;
this.downloadURI(url,name)
this.downloadURI(this.releases.materialCompanion.variants.find(v => v.name.includes(os)).url)
})
downloadProfile.on('click',(event) => {
let id = event.currentTarget.id.replace('materialDeck_dlUtil_dlProfile-','');
this.downloadURI(this.profiles[id].url,`${this.profiles[id].label}.streamDeckProfile`);
})
refresh.on('click', () => {
document.getElementById('materialDeck_dlUtil_masterSdVersion').value = 'Getting data';
this.checkForUpdate('SD');
document.getElementById('materialDeck_dlUtil_masterMsVersion').value = 'Getting data';
this.checkForUpdate('MS');
document.getElementById('materialDeck_dlUtil_masterModuleVersion').value = 'Getting data';
this.checkForUpdate('Module');
this.getReleaseData();
let name = event.currentTarget.id.replace('materialDeck_dlUtil_dlProfile-','');
this.downloadURI(this.releases.plugin.profiles.find(p => p.name.includes(name)).url);
})
}
@@ -1181,8 +1138,53 @@ export class downloadUtility extends FormApplication {
}
checkForUpdate(reqType) {
let parent = this;
let url;
return new Promise((resolve) => {
const url = releaseURLs?.[reqType].api;
if (url == undefined) return;
$.getJSON(url).done(function(releases) {
const release = releases[0];
if (reqType == 'plugin') {
const url = release.assets.find(a => a.name.includes('streamDeckPlugin'))?.browser_download_url;
let profiles = [];
for (let profile of release.assets.filter(a => a.name.includes('streamDeckProfile'))) {
profiles.push({
name: profile.name.replace('.streamDeckProfile', ''),
url: profile.browser_download_url
})
}
resolve({
release: releases[0],
version: release.tag_name,
url,
profiles
});
}
else if (reqType == 'materialCompanion') {
let variants = [];
for (let variant of release.assets) {
variants.push({
name: variant.name,
url: variant.browser_download_url
})
}
resolve({
release: releases[0],
version: release.tag_name,
url,
variants
});
}
else if (reqType == 'module') {
resolve({
release: releases[0],
version: release.tag_name
});
}
});
});
/*
let elementId;
if (reqType == 'SD') {
elementId = 'materialDeck_dlUtil_masterSdVersion';
@@ -1194,7 +1196,7 @@ export class downloadUtility extends FormApplication {
}
else if (reqType == 'Module') {
elementId = 'materialDeck_dlUtil_masterModuleVersion';
url = 'https://raw.githubusercontent.com/CDeenen/MaterialDeck/Master/module.json';
url = game.modules.get('MaterialDeck').manifest;
}
var request = new XMLHttpRequest();
@@ -1215,92 +1217,6 @@ export class downloadUtility extends FormApplication {
request.onerror = function () {
document.getElementById(elementId).innerHTML = 'Error';
}
*/
}
}
export class deviceConfig extends FormApplication {
constructor(data, options) {
super(data, options);
this.devices = [];
}
/**
* Default Options for this FormApplication
*/
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
id: "materialDeck_deviceConfig",
title: "Material Deck: " + game.i18n.localize("MaterialDeck.DeviceConfig.Title"),
template: "./modules/MaterialDeck/templates/deviceConfig.html",
width: 500,
height: "auto"
});
}
/**
* Provide data to the template
*/
getData() {
this.devices = [];
let dConfig = game.settings.get(moduleName, 'devices');
if (Object.prototype.toString.call(game.settings.get('MaterialDeck', 'devices')) === "[object String]") {
dConfig = {};
game.settings.set(moduleName, 'devices', dConfig);
}
for (let d of streamDeck.buttonContext) {
if (d == undefined) continue;
let type;
if (d.type == 0) type = 'Stream Deck';
else if (d.type == 1) type = 'Stream Deck Mini';
else if (d.type == 2) type = 'Stream Deck XL';
else if (d.type == 3) type = 'Stream Deck Mobile';
else if (d.type == 4) type = 'Corsair G Keys';
const name = d.name;
const id = d.device;
let enable;
if (dConfig?.[id] == undefined) enable = true;
else enable = dConfig?.[id].enable;
const device = {
id,
name,
type,
en: enable
}
this.devices.push(device);
}
return {
devices: this.devices
}
}
/**
* Update on form submit
* @param {*} event
* @param {*} formData
*/
async _updateObject(event, formData) {
}
activateListeners(html) {
super.activateListeners(html);
html.find("input[name='enable']").on('change', (event) => {
const id = event.currentTarget.id.replace('materialDeck_devConf_','');;
for (let d of this.devices) {
if (d.id == id) {
let dConfig = game.settings.get(moduleName, 'devices');
delete dConfig[id];
dConfig[id] = {enable: event.currentTarget.checked}
game.settings.set(moduleName, 'devices', dConfig);
}
}
})
}
}

View File

@@ -1,5 +1,5 @@
import { moduleName, isEmpty } from "../MaterialDeck.js";
import { playlistConfigForm, macroConfigForm, soundboardConfigForm, downloadUtility, deviceConfig } from "./misc.js";
import { playlistConfigForm, macroConfigForm, soundboardConfigForm, downloadUtility } from "./misc.js";
let userPermissions = {};
const defaultEnable = [true,true,true,true];
@@ -173,21 +173,6 @@ export const registerSettings = async function() {
restricted: false
});
game.settings.registerMenu(moduleName, 'deviceConfig',{
name: "MaterialDeck.DeviceConfig.Title",
label: "MaterialDeck.DeviceConfig.Title",
type: deviceConfig,
restricted: false
});
game.settings.register(moduleName, 'devices', {
name: "devices",
scope: "client",
type: Object,
config: false,
default: {}
});
game.settings.registerMenu(moduleName, 'permissionConfig',{
name: "MaterialDeck.Sett.Permission",
label: "MaterialDeck.Sett.Permission",

View File

@@ -205,16 +205,20 @@ export class StreamDeck{
setTitle(txt,context){
if (txt == null || txt == undefined) txt = '';
txt = this.formatTitle(txt);
let thisDevice;
for (let device of this.buttonContext) {
if (device == undefined) continue;
const btn = device.buttons.find(b => b?.context == context);
if (btn == undefined) continue;
btn.txt = txt;
thisDevice = device;
}
let msg = {
target: "SD",
target: "MaterialDeck_Device",
source: "MaterialDeck_Foundry",
userId: game.userId,
device: thisDevice,
event: 'setTitle',
context: context,
payload: {
@@ -226,8 +230,16 @@ export class StreamDeck{
}
setColor(context,color = '#000000'){
let thisDevice;
for (let device of this.buttonContext) {
if (device == undefined) continue;
thisDevice = device.buttons.find(b => b?.context == context);
}
let msg = {
target: "SD",
target: "MaterialDeck_Device",
source: "MaterialDeck_Foundry",
userId: game.userId,
device: thisDevice,
event: 'setIcon',
context: context,
url: '',
@@ -239,7 +251,9 @@ export class StreamDeck{
setImage(image,context,device,nr,id){
var json = {
target: "SD",
target: "MaterialDeck_Device",
source: "MaterialDeck_Foundry",
userId: game.userId,
event: "setImage",
context: context,
device: device,
@@ -255,7 +269,9 @@ export class StreamDeck{
setBufferImage(context,device,nr,id){
var json = {
target: "SD",
target: "MaterialDeck_Device",
source: "MaterialDeck_Foundry",
userId: game.userId,
event: "setBufferImage",
context: context,
device: device,
@@ -322,7 +338,9 @@ export class StreamDeck{
let split2 = split[0].split('-');
if (split2[0] == 'fa') format = 'icon';
let msg = {
target: "SD",
target: "MaterialDeck_Device",
source: "MaterialDeck_Foundry",
userId: game.userId,
event: 'setIcon',
context: context,
device: device,
@@ -339,9 +357,17 @@ export class StreamDeck{
}
setState(state,context,action){
let thisDevice;
for (let device of this.buttonContext) {
if (device == undefined) continue;
thisDevice = device.buttons.find(b => b?.context == context);
}
let msg = {
target: "SD",
target: "MaterialDeck_Device",
source: "MaterialDeck_Foundry",
userId: game.userId,
event: 'setStateCustom',
device: thisDevice,
context: context,
action: action,
state: state
@@ -354,8 +380,9 @@ export class StreamDeck{
if (action == 'playlistcontrol')
profile = 'MaterialDeck-Playlist'
var json = {
target: "SD",
source: 1,
target: "MaterialDeck_Device",
source: "MaterialDeck_Foundry",
userId: game.userId,
event: "switchToProfile",
context: this.pluginId,
device: device,

View File

@@ -239,7 +239,7 @@ export class pf2e{
getConditionIcon(condition) {
if (condition == undefined) condition = 'removeAll';
if (condition == 'removeAll') return window.CONFIG.controlIcons.effects;
else return `${CONFIG.PF2E.statusEffects.effectsIconFolder}${condition}.webp`;
else return `${CONFIG.PF2E.statusEffects.iconDir}${condition}.webp`;
}
getConditionActive(token,condition) {
@@ -281,6 +281,7 @@ export class pf2e{
}
async toggleCondition(token,condition) {
console.log(token,condition)
if (condition == undefined) condition = 'removeAll';
if (condition == 'removeAll'){
for( let effect of token.actor.items.filter(i => i.type == 'condition'))
@@ -288,6 +289,7 @@ export class pf2e{
}
else {
const effect = this.getCondition(token,condition);
console.log('eff',effect)
if (effect == undefined) {
const newEffect = game.pf2e.ConditionManager.conditions.get(condition).toObject();
await token.actor?.createEmbeddedDocuments("Item", [newEffect]);