This commit is contained in:
Jesse James Isler 2022-06-03 09:26:25 +02:00
parent bce998b934
commit 0081b43a9e
6 changed files with 200 additions and 0 deletions

9
COPYRIGHT.md Normal file
View File

@ -0,0 +1,9 @@
## Credits
The next list is the icons used inside each theme or timer.
| light-meter\sword.svg | |
|---|---|
|Original name|Sword |
|Author|[franc11s](https://thenounproject.com/franc11s/)|
|Source|https://thenounproject.com/term/sword/3376430 |
|License|[Creative Commons - Attribution 3.0 United States](https://creativecommons.org/licenses/by/3.0/us/legalcode)|

35
combatreadythemes.ts Normal file
View File

@ -0,0 +1,35 @@
import { registerLightMeter } from "./themes/light-meter/lightMeter";
export function getCanvas(): Canvas {
if (!(canvas instanceof Canvas) || !canvas.ready) {
throw new Error('Canvas Is Not Initialized');
}
return canvas;
}
export function getGame(): Game {
if (!(game instanceof Game)) {
throw new Error('Game Is Not Initialized');
}
return game;
}
export function getCombats(): CombatEncounters {
if (!(getGame().combats instanceof CombatEncounters)) {
throw new Error('CombatEncounters Is Not Initialized');
}
return <CombatEncounters>getGame().combats;
}
/**
* Ready hook
*/
Hooks.on("ready", function () {
//@ts-ignore
if (!(game.modules.get("combatready")?.active ?? false)) {
ui?.notifications?.notify('Please make sure you have the "Combat Ready!" module installed and enabled.', "error");
}
});
Hooks.on("combatready.ready", (CombatReadyAnimationTheme, CombatReadyTimer) => {
registerLightMeter(CombatReadyTimer);
});

43
module.json Normal file
View File

@ -0,0 +1,43 @@
{
"name": "combatreadythemes",
"title": "Combat Ready! Themes Pack",
"description": "A pack of basic themes for the Combat Ready! module",
"version": "1.1.0",
"author": "Teshynil",
"authors": [
{
"name": "Teshynil",
"url": "https://github.com/Teshynil/",
"email": "",
"discord": "Teshynil#8564",
"ko-fi": "",
"patreon": "",
"reddit": "u/Teshynil",
"twitter": "@Teshynil"
}
],
"manifestPlusVersion": "1.2.0",
"socket": true,
"languages": [],
"esmodules": [
"combatreadythemes.js"
],
"styles": [
"themes/light-meter/light-meter.css"
],
"dependencies": [
{
"name": "combatready",
"manifest": "https://raw.githubusercontent.com/Teshynil/combatready/master/src/module.json"
}
],
"packs": [],
"minimumCoreVersion": "0.8.6",
"compatibleCoreVersion": "9",
"url": "https://github.com/Teshynil/combatreadythemes",
"download": "https://github.com/Teshynil/combatreadythemes/releases/download/1.1.0/combatreadythemes-v1.1.0.zip",
"manifest": "https://raw.githubusercontent.com/Teshynil/combatreadythemes/master/src/module.json",
"license": "https://github.com/Teshynil/combatreadythemes/blob/1.1.0/LICENSE",
"readme": "https://github.com/Teshynil/combatreadythemes/blob/1.1.0/README.md",
"changelog": "https://github.com/Teshynil/combatreadythemes/blob/1.1.0/CHANGELOG.md"
}

View File

@ -0,0 +1,31 @@
.combatready-theme-dd-timebar {
display: flex;
justify-content: center;
position: fixed;
left: 0;
top: 25px;
width: 100%;
height: 10px;
transition: width 500ms linear;
}
.combatready-theme-dd-timebar-fill {
display: flex;
flex-direction: row-reverse;
position: absolute;
height: 100%;
width: 100%;
background-color: transparent;
background-image: linear-gradient(90deg, transparent, rgba(100, 0, 0, 1) 2%, rgba(252, 120, 0, 1), rgba(100, 0, 0, 1) 98%, transparent);
transition: width 1000ms linear;
}
.combatready-theme-dd-timebar-icon {
height: 60px;
width: 60px;
background-size: contain;
background-repeat: no-repeat;
z-index: 1;
margin-top: -25px;
background-image: url("swords.svg");
}

View File

@ -0,0 +1,81 @@
import { getGame } from "../../combatreadythemes";
export function registerLightMeter(CombatReadyTimer) {
class LightMeter extends CombatReadyTimer {
name = "LightMeter";
public TIMEBAR: HTMLDivElement;
public TIMEFILL: HTMLDivElement;
public ICON: HTMLDivElement;
public initialize() {
let body = document.getElementsByTagName("body")[0] as HTMLElement;
let sidebar = document.getElementById("sidebar") as HTMLElement;
let timebar = document.createElement("div");
let timefill = document.createElement("div");
let icon = document.createElement("div");
timebar.id = "combatready-theme-dd-timebar";
$(timebar).addClass("combatready-theme-dd-timebar");
$(timefill).addClass("combatready-theme-dd-timebar-fill");
$(icon).addClass("combatready-theme-dd-timebar-icon");
timebar.appendChild(icon);
timebar.appendChild(timefill);
body.appendChild(timebar);
// Ajust due to DOM elements
timebar.style.width = `100%`;
this.TIMEBAR = timebar;
this.TIMEFILL = timefill;
this.ICON = icon;
this.adjustWidth();
this.tick();//Do a tick to redraw in case is a reload;
this.ready = true;
}
public destroy() {
this.TIMEBAR?.remove();
this.TIMEFILL?.remove();
this.ICON?.remove();
this.ready = false;
}
public start() {
if (!this.ready) return;
this.TIMEBAR.style.display = "flex";
this.TIMEFILL.style.width = "100%";
this.TIMEFILL.style.transition = "none";
}
public stop() {
if (!this.ready) return;
this.TIMEBAR.style.display = "none";
this.TIMEFILL.style.width = "100%";
this.TIMEFILL.style.transition = "none";
}
public pause() {
if (!this.ready) return;
this.TIMEBAR.style.display = "flex";
}
public resume() {
if (!this.ready) return;
this.TIMEBAR.style.display = "flex";
}
public tick() {
if (!this.ready) return;
this.TIMEBAR.style.display = "flex";
//@ts-ignore
let width = 100 - ((getGame().modules.get("combatready")?.api?.getCurrentTime() / getGame().modules.get("combatready")?.api?.getMaxTime()) * 100);
this.TIMEFILL.style.transition = "";
this.TIMEFILL.style.width = `${width}%`;
}
public adjustWidth() {
let sidebar = document.getElementById("sidebar") as HTMLElement;
let width = sidebar.offsetWidth;
if ($(document.body).hasClass("mobile-improvements")) width = 0;
this.TIMEBAR.style.width = `calc(100vw - ${width}px)`;
}
get settings() {
return [
]
}
}
//@ts-ignore
getGame().modules.get("combatready")?.api?.setupTimer(new LightMeter("CombatReadyLightMeter"));
}

View File

@ -0,0 +1 @@
<svg height='300px' width='300px' fill="#000000" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve"><path d="M27.667,76.333l-4-4L12.314,83.686H5V95h11.314v-7.314L27.667,76.333z M8.771,91.229l0-3.771l3.771-0.001v3.771H8.771z M41,79l-6,2L19,65l2-6L41,79z M38.334,73.666L93.667,25L95,5L75,6.333L26.333,61.667L38.334,73.666z M77,21.667L78.334,23l-38,38 L39,59.666L77,21.667z"></path><g><polygon points="34.282,49.581 40.817,42.151 21.666,23 23,21.667 42.065,40.731 48.659,33.234 25,6.333 5,5 6.333,25 "></polygon><polygon points="61,59.666 59.666,61 57.85,59.184 51.524,64.746 61.666,73.666 73.666,61.667 65.536,52.423 59.269,57.935 "></polygon><path d="M76.333,72.333l-4,4l11.353,11.353V95H95V83.686h-7.314L76.333,72.333z M91.229,91.229h-3.771v-3.771l3.771,0.001 L91.229,91.229z"></path><polygon points="78.999,59 59,79 65,81 81,65 "></polygon></g></svg>

After

Width:  |  Height:  |  Size: 996 B