Skip to content

Commit

Permalink
make library optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ardittristan committed Aug 25, 2020
1 parent d43604f commit cd1b4d5
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ jobs:
shell: bash
id: get-version
run: echo "::set-output name=version::$(node ./.github/workflows/get-version.js)"
- run: zip -r ./personal-markers.zip module.json marker.js assets/ lang/ # Add folders/files here
- run: zip -r ./personal-markers.zip module.json marker.js assets/ lang/ lib/ # Add folders/files here
- name: Create Release # Create an additional release for this version
id: create_versioned_release
uses: ncipollo/release-action@v1
with:
allowUpdates: true # set to false if you do not want to allow updates on existing releases
allowUpdates: false # set to false if you do not want to allow updates on existing releases
name: Release ${{ steps.get-version.outputs.version }} # Use the version in the name
draft: false
prerelease: false
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Patch Notes

## Version 1.0.3

Make colorsettings lib optional.

## Version 1.0.2

If middle mouse button is on it now eats the input so it doesn't trigger the fast scroll.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![GitHub All Releases](https://img.shields.io/badge/dynamic/json?color=green&label=downloads&query=*&url=http%3A%2F%2Faws.ardittristan.xyz%3A9756%2FdownloadCount%2FVttPersonalMarkers)
![GitHub All Releases](https://img.shields.io/github/downloads/ardittristan/VttPersonalMarkers/total)

# Personal Markers

Expand Down
45 changes: 45 additions & 0 deletions lib/colorSettingStub.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Hooks.once('init', function () {
game.settings.register("colorsettings", "showWarning", {
config: true,
type: Boolean,
default: true,
name: "Show Error",
hint: "Enable or disable error if main module missing."
});
if (window?.Ardittristan?.initialColorSettingRun === undefined) {
if (game.modules.has("colorsettings")) {
if (game.modules.get("colorsettings").active) {
return;
} else {
game.settings.register("colorsettings", "autoEnable", {
config: false,
type: Boolean,
default: true
});
Hooks.once("canvasReady", () => {
if (game.user.isGM && game.settings.get("colorsettings", "autoEnable")) {
Dialog.confirm({
title: "Enable Color Settings module?",
content: "<p>You seem to have Color Settings installed already, do you want to enable it?</p>",
yes: () => game.settings.set("core", ModuleManagement.CONFIG_SETTING, {
...game.settings.get("core", ModuleManagement.CONFIG_SETTING),
...{ colorsettings: true }
}),
no: () => game.settings.set("colorsettings", "autoEnable", false),
defaultYes: false
});

}
});
}
}

Hooks.once('ready', function () {
if (game.settings.get("colorsettings", "showWarning")) {
ui.notifications.notify("A module is missing the color picker library. For best results, please install and enable the Lib-Color Settings module.", "warning");
}
});
console.log("ColorSettings | initializing fallback mode");

}
});
35 changes: 20 additions & 15 deletions marker.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
Hooks.once('ready', () => {
try{window.Ardittristan.ColorSetting.tester} catch {
ui.notifications.notify('Please make sure you have the "lib - ColorSettings" module installed', "error", {permanent: true});
}
});

Hooks.once('init', async function () {
// Init settings
game.settings.register("personalmarkers", "markerJSON", {
Expand Down Expand Up @@ -45,13 +39,24 @@ Hooks.once('init', async function () {
config: true
});

new window.Ardittristan.ColorSetting("personalmarkers", "markerIconColor", {
name: game.i18n.localize("PersonalMarkers.markerIconColor.name"),
label: game.i18n.localize("PersonalMarkers.markerIconColor.label"),
defaultColor: "#000000ff",
scope: "client",
onChange: () => window.location.reload()
});
if (typeof window?.Ardittristan?.ColorSetting === "function") {
new window.Ardittristan.ColorSetting("personalmarkers", "markerIconColor", {
name: game.i18n.localize("PersonalMarkers.markerIconColor.name"),
label: game.i18n.localize("PersonalMarkers.markerIconColor.label"),
defaultColor: "#000000ff",
scope: "client",
onChange: () => window.location.reload()
});
} else {
game.settings.register("personalmarkers", "markerIconColor", {
name: "PersonalMarkers.markerIconColor.name",
restricted: false,
default: "#000000ff",
type: String,
scope: "client",
config: true
});
}
});

/**
Expand Down Expand Up @@ -136,8 +141,8 @@ class MarkersLayer extends CanvasLayer {
*/
_onMidMouseDown(e) {
if (!this._mouseOnCanvas || e.button != 1 || !game.settings.get("personalmarkers", "useMiddleMouse")) return;
e.preventDefault()
e.stopPropagation()
e.preventDefault();
e.stopPropagation();
const id = Math.random().toString(36).substring(7);
this._triggerPing(id);
}
Expand Down
3 changes: 2 additions & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
"name": "personalmarkers",
"title": "Personal Markers",
"description": "Add personal markers that only you can see.",
"version": "1.0.2",
"version": "1.0.3",
"author": "ardittristan#0001",
"esmodules": ["marker.js"],
"scripts": ["./lib/colorSettingStub.js"],
"socket": true,
"languages": [
{
Expand Down

0 comments on commit cd1b4d5

Please sign in to comment.