Skip to content

Commit

Permalink
Added region support
Browse files Browse the repository at this point in the history
  • Loading branch information
Haxxer committed Jul 14, 2024
1 parent ffbf43e commit 06724ae
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 11 deletions.
62 changes: 60 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
release:
types: [published]

env:
package_name: Tagger
package_id: tagger

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -39,8 +43,6 @@ jobs:
manifest: https://raw.githubusercontent.com/${{github.repository}}/next/module.json
download: https://github.com/${{github.repository}}/releases/download/${{github.event.release.tag_name}}/module.zip



# Create a zip file with all files required by the module to add to the release
- run: zip -r ./module.zip module.json LICENSE style.css scripts/

Expand All @@ -59,6 +61,62 @@ jobs:
tag: ${{ github.event.release.tag_name }}
body: ${{ github.event.release.body }}

- name: Get Compatibility
if: "!github.event.release.prerelease"
run: |
echo 'COMPATIBILITY<<EOF' >> $GITHUB_ENV
cat module.json | jq .compatibility >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Send package to foundry
if: "!github.event.release.prerelease"
run: |
HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X POST 'https://api.foundryvtt.com/_api/packages/release_version/' \
--header 'Authorization: ${{ secrets.PACKAGE_TOKEN }}' \
--header 'Content-Type: application/json' \
--data '{
"id": "${{env.package_id}}",
"release": {
"version": "${{ github.event.release.tag_name }}",
"manifest": "https://github.com/${{github.repository}}/releases/download/${{github.event.release.tag_name}}/module.json",
"notes": "https://github.com/${{github.repository}}/releases/tag/${{github.event.release.tag_name}}",
"compatibility": ${{ env.COMPATIBILITY }}
}
}')
# extract the body
HTTP_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g')
# extract the status
HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
# print the body
echo "$HTTP_BODY"
# example using the status
if [ ! $HTTP_STATUS -eq 200 ]; then
echo "Error [HTTP status: $HTTP_STATUS]"
exit 1
fi
- name: FC Discord notification
if: "!github.event.release.prerelease"
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
DISCORD_USERNAME: ${{env.package_name}} Version ${{github.event.release.tag_name}}
uses: Ilshidur/action-discord@master
with:
args: "${{github.event.release.body}}"

- name: JB2A Discord notification
if: "!github.event.release.prerelease"
env:
DISCORD_WEBHOOK: ${{ secrets.JB2A_WEBHOOK_URL }}
DISCORD_USERNAME: ${{env.package_name}} Version ${{github.event.release.tag_name}}
uses: Ilshidur/action-discord@master
with:
args: "${{github.event.release.body}}"

# OR create a pre-release for this specific version
- name: Update Release with Files
if: "github.event.release.prerelease"
Expand Down
5 changes: 1 addition & 4 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
"styles": [
"./style.css"
],
"socket": false,
"protected": false,
"coreTranslation": false,
"library": "false",
"library": true,
"url": "https://github.com/fantasycalendar/FoundryVTT-Tagger",
"manifest": "https://github.com/fantasycalendar/FoundryVTT-Tagger/releases/latest/download/module.json",
"download": "https://github.com/fantasycalendar/FoundryVTT-Tagger/releases/latest/download/module.zip",
Expand Down
12 changes: 10 additions & 2 deletions scripts/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ export default class Tagger {
...Array.from(scene.walls),
...Array.from(scene.drawings),
...Array.from(scene.notes),
...Array.from(scene.regions),
].deepFlatten().filter(Boolean)
}

Expand Down Expand Up @@ -415,6 +416,12 @@ class TaggerConfig {
this._applyHtml(app, elem, true);
}

static _handleRegionConfig(app, html) {
const jqueryHtml = $(html);
const elem = jqueryHtml.find(`section[data-tab="identity"]`);
this._applyHtml(app, elem);
}

static _handleGenericConfig(app, html) {
const jqueryHtml = $(html);
let button = jqueryHtml.find(`button[name="submit"]`);
Expand Down Expand Up @@ -810,10 +817,11 @@ const configHandlers = {
"TileConfig": "_handleTileConfig",
"DrawingConfig": "_handleDrawingConfig",
"AmbientLightConfig": "_handleAmbientLightConfig", // v12
"RegionConfig": "_handleRegionConfig",
"WallConfig": "_handleGenericConfig",
"AmbientSoundConfig": "_handleGenericConfig",
"MeasuredTemplateConfig": "_handleGenericConfig",
"NoteConfig": "_handleGenericConfig"
"NoteConfig": "_handleGenericConfig",
}

for (const [configName, configHandler] of Object.entries(configHandlers)) {
Expand All @@ -822,7 +830,7 @@ for (const [configName, configHandler] of Object.entries(configHandlers)) {
});
}

for (const obj of ["Actor", "Token", "Tile", "Drawing", "Wall", "Light", "AmbientLight", "AmbientSound", "MeasuredTemplate", "Note"]) {
for (const obj of ["Actor", "Token", "Tile", "Drawing", "Wall", "AmbientLight", "AmbientSound", "MeasuredTemplate", "Note", "Region"]) {
Hooks.on(`preUpdate${obj}`, (...args) => TaggerHandler.applyUpdateTags(...args));
Hooks.on(`preCreate${obj}`, (...args) => TaggerHandler.preCreateApplyTags(...args));
}
Expand Down
5 changes: 3 additions & 2 deletions style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion style.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions style.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
fieldset.tagger {
margin: 5px 0;
flex: auto;

.tag-container {

Expand Down

0 comments on commit 06724ae

Please sign in to comment.