diff --git a/src/module.json b/src/module.json index dafaab9..d582502 100644 --- a/src/module.json +++ b/src/module.json @@ -1,17 +1,16 @@ { - "id": "testmodule", - "title": "Foundry TS", - "description": "A simple module using Typescript", - "authors": [ - { - "name": "Josh Matthews", - "email": "josh@bringingfire.com" - } - ], - "version": "1.0.0", - "compatibility": { - "minimum": "9", - "verified": "10" - }, - "esmodules": ["scripts/module.js"] + "id": "rush-character-archive-foundry-module", + "title": "Rush Character Archive", + "description": "A module for sharing character files across foundry instances.", + "version": "0.0.0", + "authors": [ + { + "name": "badgers" + } + ], + "compatibility": { + "minimum": "11", + "verified": "11" + }, + "esmodules": ["scripts/module.js"] } diff --git a/scripts/apps/CharacterArchiver.js b/src/scripts/apps/CharacterArchiver.js similarity index 100% rename from scripts/apps/CharacterArchiver.js rename to src/scripts/apps/CharacterArchiver.js diff --git a/scripts/apps/CharacterCatalog.js b/src/scripts/apps/CharacterCatalog.js similarity index 100% rename from scripts/apps/CharacterCatalog.js rename to src/scripts/apps/CharacterCatalog.js diff --git a/scripts/common.js b/src/scripts/common.js similarity index 100% rename from scripts/common.js rename to src/scripts/common.js diff --git a/scripts/index.js b/src/scripts/index.js similarity index 100% rename from scripts/index.js rename to src/scripts/index.js diff --git a/scripts/settings.js b/src/scripts/settings.js similarity index 100% rename from scripts/settings.js rename to src/scripts/settings.js diff --git a/templates/CharacterArchiver.hbs b/src/templates/CharacterArchiver.hbs similarity index 100% rename from templates/CharacterArchiver.hbs rename to src/templates/CharacterArchiver.hbs diff --git a/src/ts/apps/CharacterArchiver.ts b/src/ts/apps/CharacterArchiver.ts new file mode 100644 index 0000000..4498f27 --- /dev/null +++ b/src/ts/apps/CharacterArchiver.ts @@ -0,0 +1,14 @@ + +export class CharacterArchiver extends Application { + + static override get defaultOptions() { + const options = super.defaultOptions; + options.id = "character-archiver"; + options.template = "modules/rush-character-archive-foundry-module/templates/CharacterArchiver.hbs"; + options.width = 500; + options.height = 270; + options.tabs = [{ navSelector: ".tabs", contentSelector: ".theatre-config-contents", initial: "main" }]; + return options; + } + +} \ No newline at end of file diff --git a/src/ts/apps/CharacterCatalog.js b/src/ts/apps/CharacterCatalog.js new file mode 100644 index 0000000..e69de29 diff --git a/src/ts/common.ts b/src/ts/common.ts new file mode 100644 index 0000000..266d1e0 --- /dev/null +++ b/src/ts/common.ts @@ -0,0 +1,5 @@ + +export const MODULE_ID = "rush-character-archive-foundry-module"; + +export const URI_SETTING_NAME = "uri_setting"; +export const API_KEY_NAME = "api_key"; \ No newline at end of file diff --git a/src/ts/module.ts b/src/ts/module.ts index 7a79aa7..ada4d68 100644 --- a/src/ts/module.ts +++ b/src/ts/module.ts @@ -6,6 +6,9 @@ import { ModuleData } from "@league-of-foundry-developers/foundry-vtt-types/src/ import { id as moduleId } from "../module.json"; import DogBrowser from "./apps/NewCharacter"; +import { initializeSettings } from "./settings"; +import { CharacterArchiver } from "./apps/CharacterArchiver" + interface MyModule extends Game.ModuleData { dogBrowser: DogBrowser; @@ -14,6 +17,10 @@ interface MyModule extends Game.ModuleData { let module: MyModule; Hooks.once("init", async () => { + + + initializeSettings(); + console.log("hello world!"); @@ -43,3 +50,51 @@ Hooks.once("init", async () => { module.dogBrowser = new DogBrowser(); module.dogBrowser.render(true); }); + +// Add to the character sheet header bar. +Hooks.on("getActorSheetHeaderButtons", (app: any, buttons: any) => { + + console.log(app); + + let theatreButtons = []; + + theatreButtons.push({ + label: "Archive", + class: "send-to-archive", + icon: "fas fa-save", + onclick: (ev: any) => { + console.log(ev) + new CharacterArchiver().render(true); + + console.log("ARCHIVE ME!"); + } + }); + + buttons.unshift(...theatreButtons); +}); + +// Add to the character context menu. +Hooks.on("getActorDirectoryEntryContext", async (html: any, options: any) => { + + console.log(html) + + const getActorData = (target: any) => { + console.log(target) + return game.actors.get(target.data("documentId")); + }; + + console.log(getActorData) + + options.splice( + 3, + 0, + { + name: "Archive", + icon: '', + callback: (target) => { + + new CharacterArchiver().render(true); + }, + }, + ); +}); \ No newline at end of file diff --git a/src/ts/settings.ts b/src/ts/settings.ts new file mode 100644 index 0000000..aa09e1d --- /dev/null +++ b/src/ts/settings.ts @@ -0,0 +1,23 @@ +import {MODULE_ID, URI_SETTING_NAME, API_KEY_NAME} from "./common.js" + +export function initializeSettings() { + game.settings.register(MODULE_ID, URI_SETTING_NAME, { + name: "Archive Server URI", + hint: "Address of the character archive server.", + scope: "world", + config: true, + restricted: true, + default: "https://chararchive.cyberpunkrush.com", + type: String, + }); + + game.settings.register(MODULE_ID, API_KEY_NAME, { + name: "API Key", + hint: "API key to use when communicating with the archive server.", + scope: "world", + config: true, + restricted: true, + default: "", + type: String, + }); +}