Skip to content

Commit 161b559

Browse files
committed
fix bug in none dnd5e systems
1 parent a1d6932 commit 161b559

File tree

5 files changed

+42
-42
lines changed

5 files changed

+42
-42
lines changed

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# 1.0.1
2+
- fix bug in non dnd5e systems.
13
# 1.0.0
24
- module is no longer for dnd5e only. but still has a dnd5e slim sheet.
35
- you can add a virtual gamepad to control a token (you need a gamepad module e.g. [beavers-gamepad](https://github.com/AngryBeaver/beavers-gamepad))

module.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"title": "Beaver's Mobile Enhancements",
33
"description": "A Module to enhance playing locally with sheets on tablets and map screen.#Local Coop",
44
"id": "beavers-mobile",
5-
"version": "1.0.0",
5+
"version": "1.0.1",
66
"authors": [
77
{
88
"name": "angryBeaver",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "beavers-mobile",
33
"title": "Beaver's Mobile",
4-
"version": "1.0.0",
4+
"version": "1.0.1",
55
"description": "A Module to enhance playing locally with sheets on tablets and map screen.#Local Coop",
66
"devDir": "C:\\Users\\Riess\\AppData\\Local\\FoundryVTT\\Data\\modules",
77
"main": "src/main.js",

src/Mobile5eSheet.ts

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
21
// @ts-ignore
32
export class Mobile5eSheet extends dnd5e.applications.actor.ActorSheet5eCharacter {
43

5-
actor:Actor;
4+
actor: Actor;
65
canvas;
7-
touchStart?:Touch
8-
touchNow?:Touch
9-
interval?:number
10-
tokenMovement:any
6+
touchStart?: Touch
7+
touchNow?: Touch
8+
interval?: number
9+
tokenMovement: any
1110

1211

1312
static get defaultOptions() {
1413
return mergeObject(super.defaultOptions, {
15-
classes: ["beavers-mobile","dnd5e", "sheet", "actor", "character"],
14+
classes: ["beavers-mobile", "dnd5e", "sheet", "actor", "character"],
1615
width: 500,
1716
height: 1040
1817
});
@@ -25,33 +24,33 @@ export class Mobile5eSheet extends dnd5e.applications.actor.ActorSheet5eCharacte
2524
return context;
2625
}
2726

28-
activateListeners(html){
27+
activateListeners(html) {
2928
super.activateListeners(html);
3029
this._rerender(html);
3130
this._addMovementListener(html);
3231
}
3332

34-
_rerender(html){
33+
_rerender(html) {
3534
this._moveRest(html);
3635
this._moveCurrency(html);
3736
this._addMovement(html);
3837
}
3938

40-
_moveRest(html){
39+
_moveRest(html) {
4140
const rest = $(html).find(".hit-dice .attribute-footer");
4241
$(html).find(".attributes .movement .attribute-footer").remove();
4342
$(html).find(".attributes .movement ").append(rest);
4443
}
4544

46-
_moveCurrency(html){
45+
_moveCurrency(html) {
4746
$(html).find(".currency .pp").text("pp");
4847
$(html).find(".currency .gp").text("gp");
4948
$(html).find(".currency .ep").text("ep");
5049
$(html).find(".currency .sp").text("sp");
5150
$(html).find(".currency .cp").text("cp");
5251
}
5352

54-
_addMovement(html){
53+
_addMovement(html) {
5554
const upLeft = "<a class='moving up left'><i class='fa-light fa-up-left'></i></a>";
5655
const up = "<a class='moving up'><i class='fa-light fa-up'></i></a>";
5756
const upRight = "<a class='moving up right'><i class='fa-light fa-up-right'></i></a>";
@@ -74,71 +73,68 @@ export class Mobile5eSheet extends dnd5e.applications.actor.ActorSheet5eCharacte
7473
image.append(upLeft);
7574
}
7675

77-
_addMovementListener(html){
78-
$(html).find(".sheet-header .image").on("touchstart",(e: Event)=>{
76+
_addMovementListener(html) {
77+
$(html).find(".sheet-header .image").on("touchstart", (e: Event) => {
7978
this.touchStart = this._getTouchFrom(e);
80-
this.interval = window.setInterval(()=>{
81-
if(this.touchNow && this.touchStart){
79+
this.interval = window.setInterval(() => {
80+
if (this.touchNow && this.touchStart) {
8281

83-
const diffX = this.touchNow.clientX-this.touchStart.clientX;
84-
const diffY = this.touchNow.clientY-this.touchStart.clientY;
82+
const diffX = this.touchNow.clientX - this.touchStart.clientX;
83+
const diffY = this.touchNow.clientY - this.touchStart.clientY;
8584
let x = 0;
8685
let y = 0;
87-
if(Math.abs(diffX) > 30){
86+
if (Math.abs(diffX) > 30) {
8887
x = Math.sign(diffX);
8988
}
90-
if(Math.abs(diffY) > 30){
89+
if (Math.abs(diffY) > 30) {
9190
y = Math.sign(diffY);
9291
}
93-
this.tokenMovement.move(x,y);
92+
this.tokenMovement.move(x, y);
9493
}
95-
},500)
94+
}, 500)
9695
});
9796

98-
$(html).find(".sheet-header .image").on("touchmove",(e:Event)=>{
97+
$(html).find(".sheet-header .image").on("touchmove", (e: Event) => {
9998
this.touchNow = this._getTouchFrom(e);
10099

101100
});
102101

103-
$(html).find(".sheet-header .image").on("touchend",(e:Event)=>{
102+
$(html).find(".sheet-header .image").on("touchend", (e: Event) => {
104103
window.clearInterval(this.interval);
105104
this.touchStart = undefined;
106105
this.touchNow = undefined;
107106
});
108107

109-
$(html).find(".sheet-header .image .fa-up-left").on("click",(e)=>{
108+
$(html).find(".sheet-header .image .fa-up-left").on("click", (e) => {
110109
this.tokenMovement.move(-1, -1)
111110
});
112-
$(html).find(".sheet-header .image .fa-up").on("click",(e)=>{
111+
$(html).find(".sheet-header .image .fa-up").on("click", (e) => {
113112
this.tokenMovement.move(0, -1)
114113
});
115-
$(html).find(".sheet-header .image .fa-up-right").on("click",(e)=>{
114+
$(html).find(".sheet-header .image .fa-up-right").on("click", (e) => {
116115
this.tokenMovement.move(1, -1)
117116
});
118-
$(html).find(".sheet-header .image .fa-left").on("click",(e)=>{
117+
$(html).find(".sheet-header .image .fa-left").on("click", (e) => {
119118
this.tokenMovement.move(-1, 0)
120119
});
121-
$(html).find(".sheet-header .image .fa-right").on("click",(e)=>{
120+
$(html).find(".sheet-header .image .fa-right").on("click", (e) => {
122121
this.tokenMovement.move(1, 0)
123122
});
124-
$(html).find(".sheet-header .image .fa-down-left").on("click",(e)=>{
123+
$(html).find(".sheet-header .image .fa-down-left").on("click", (e) => {
125124
this.tokenMovement.move(-1, 1)
126125
});
127-
$(html).find(".sheet-header .image .fa-down").on("click",(e)=>{
126+
$(html).find(".sheet-header .image .fa-down").on("click", (e) => {
128127
this.tokenMovement.move(0, 1)
129128
});
130-
$(html).find(".sheet-header .image .fa-down-right").on("click",(e)=>{
129+
$(html).find(".sheet-header .image .fa-down-right").on("click", (e) => {
131130
this.tokenMovement.move(1, 1)
132131
});
133132
}
134133

135-
_getTouchFrom(e: Event):Touch{
134+
_getTouchFrom(e: Event): Touch {
136135
// @ts-ignore
137136
const te: TouchEvent = e.originalEvent;
138137
return te.touches[0];
139138
}
140-
141-
142139
}
143140

144-

src/main.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {Settings} from "./Settings.js";
22
import {CombatTrackerEnhancements} from "./CombatTrackerEnhancements.js";
3-
import {Mobile5eSheet} from "./Mobile5eSheet.js";
43
import {VirtualGamepad} from "./VirtualGamepad.js";
54
import {VirtualGamepadApp} from "./VirtualGamepadApp.js";
65
import {GamepadSimulator} from "./GamepadSimulator.js";
@@ -14,9 +13,12 @@ navigator.getGamepads = function(){
1413

1514
Hooks.on("ready", async function(){
1615
if(game.system.id === "dnd5e"){
17-
Actors.registerSheet("dnd5e", Mobile5eSheet, {
18-
types: ["character"],
19-
makeDefault: false,
16+
import('./Mobile5eSheet.js').then(({Mobile5eSheet})=>
17+
{
18+
Actors.registerSheet("dnd5e", Mobile5eSheet, {
19+
types: ["character"],
20+
makeDefault: false,
21+
});
2022
});
2123
}
2224
game[NAMESPACE].Settings.ready();

0 commit comments

Comments
 (0)