108 lines
2.6 KiB
TypeScript
108 lines
2.6 KiB
TypeScript
import { CharacterManagerClient } from "../proto/character.client";
|
|
import { GetCharacterRequest } from '../proto/character'
|
|
import { GrpcWebFetchTransport } from '@protobuf-ts/grpcweb-transport'
|
|
|
|
// import { ModuleData } from "@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/packages.mjs";
|
|
import { id as moduleId } from "../module.json";
|
|
// import DogBrowser from "./apps/NewCharacter";
|
|
|
|
import { initializeSettings } from "./settings";
|
|
import { CharacterArchiver } from "./apps/CharacterArchiver"
|
|
|
|
import "../styles/CharacterArchiver.scss"
|
|
// interface MyModule extends Game.ModuleData<ModuleData> {
|
|
// dogBrowser: DogBrowser;
|
|
// }
|
|
|
|
// let module: MyModule;
|
|
|
|
Hooks.once("init", async () => {
|
|
|
|
|
|
initializeSettings();
|
|
|
|
console.log("hello world!");
|
|
|
|
|
|
const client = new CharacterManagerClient(
|
|
new GrpcWebFetchTransport({
|
|
baseUrl: 'http://localhost/api',
|
|
format: 'binary',
|
|
}),
|
|
);
|
|
|
|
console.log("Potato");
|
|
let request = GetCharacterRequest.fromJson({
|
|
})
|
|
console.log("Potato");
|
|
let a = await client.getCharacter(request).then((res) => {
|
|
console.log(res)
|
|
return res
|
|
})
|
|
|
|
console.log(a.response)
|
|
|
|
console.log("Potato");
|
|
|
|
console.log(`Initializing ${moduleId}`);
|
|
});
|
|
|
|
// 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 as Game).actors!.get(target.data("documentId"));
|
|
};
|
|
|
|
// console.log("char--^^")
|
|
// console.log(getActorData(html))
|
|
// console.log(html[0])
|
|
// console.log(options)
|
|
// console.log("char^^--")
|
|
|
|
options.splice(
|
|
3,
|
|
0,
|
|
{
|
|
name: "Archive",
|
|
icon: '<i class="fas fa-save"></i>',
|
|
callback: (target: any) => {
|
|
console.log("char-->")
|
|
console.log(getActorData(target))
|
|
console.log("char--<")
|
|
console.log(target)
|
|
console.log(target[0].dataset.documentId)
|
|
new CharacterArchiver(target[0].dataset.documentId).render(true);
|
|
},
|
|
},
|
|
);
|
|
|
|
});
|