Skip to content

Commit

Permalink
Merge pull request #1 from ortegamarcel/develop
Browse files Browse the repository at this point in the history
Updated Project Structure
  • Loading branch information
ortegamarcel authored May 5, 2023
2 parents 1da3164 + f8c294e commit 71bd5df
Show file tree
Hide file tree
Showing 13 changed files with 345 additions and 215 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.detectIndentation": false
}
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
# Token Action HUD TheWitcherTRPG
Token Action HUD is a repositionable HUD of actions for a selected token.

<!-- TODO: Include gif of actions hud -->

# Features
- Make rolls directly from the HUD instead of opening your character sheet.
- Use items from the HUD or right-click an item to open its sheet.
- Move the HUD and choose to expand the menus up or down.
- Unlock the HUD to customise categories and subcategories per user, and actions per actor.
- Add your own macros and Journal Entry and Roll Table compendiums.

# Installation

<!-- ## Method 1
1. On Foundry VTT's **Configuration and Setup** screen, go to **Add-on Modules**
2. Click **Install Module**
3. Search for **Token Action HUD D&D 5e**
4. Click **Install** next to the module listing -->

## Method 1
1. On Foundry VTT's **Configuration and Setup** screen, go to **Add-on Modules**
2. Click **Install Module**
3. In the Manifest URL field, paste: `https://github.com/ortegamarcel/fvtt-token-action-hud-TheWitcherTRPG/releases/latest/download/module.json`
4. Click **Install** next to the pasted Manifest URL

## Required Modules

**IMPORTANT** - Token Action HUD D&D 5e requires the [Token Action HUD D&D Core](https://foundryvtt.com/packages/token-action-hud-core) module to be installed.

## Recommended Modules
Token Action HUD uses either the [Color Picker](https://foundryvtt.com/packages/color-picker), [libThemer](https://foundryvtt.com/packages/lib-themer) or [VTTColorSettings](https://foundryvtt.com/packages/colorsettings) library modules for its color picker settings. Only one is required.

# Support

For questions, feature requests or bug reports, please open an issue [here](https://github.com/Larkinabout/fvtt-token-action-hud-core/issues).

Pull requests are welcome. Please include a reason for the request or create an issue before starting one.
4 changes: 3 additions & 1 deletion languages/de.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"TAH_WITCHER": {
"combat": "Kampf"
"combat": "Kampf",
"weapons": "Waffen",
"magic": "Magie"
}
}
8 changes: 5 additions & 3 deletions languages/en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"TAH_WITCHER": {
"combat": "Combat"
}
"TAH_WITCHER": {
"combat": "Combat",
"weapons": "Weapons",
"magic": "Magic"
}
}
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"version": "AUTOMATICALLY REPLACED BY GITHUB WORKFLOW ACTION",
"esmodules": [
"scripts/module.js"
"scripts/init.js"
],
"relationships": {
"systems": [{
Expand Down
100 changes: 100 additions & 0 deletions scripts/action-handler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import { ACTION_TYPE, GROUP } from "./constants.js";
import { Utils } from "./utils.js";

export let ActionHandler = null;

Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
ActionHandler = class ActionHandler extends coreModule.api.ActionHandler {

/** @override */
async buildSystemActions(subcategoryIds) {
// We don't support MULTIPLE tokens being selected at the same time.
//this.actors = (!this.actor) ? this._getActors() : [this.actor]
//this.tokens = (!this.token) ? this._getTokens() : [this.token]
//this.actorType = this.actor?.type

const token = this.token;
const actor = this.actor;
if (!token || !actor) {
return;
}

this._getCombat(actor, token.id, { id: GROUP.weapons.id, type: 'system' });


//if (settings.get("showHudTitle")) result.hudTitle = token.name;
}

_getCombat(actor, tokenId, parent) {
// just one long list of actions for the combat category
const actions = actor.items
.filter(item => item.type === 'weapon' && item.system.equiped)
.map(item => ({
id: item.id,
name: item.name,
encodedValue: [ACTION_TYPE.attack, actor.id, tokenId, item.id].join(this.delimiter),
img: Utils.getImage(item)
}));
console.log('actions :>> ', actions);
this.addActions(actions, parent);
}

// createList(parent, actor, tokenId, itemtype, checksort, sorting, label, selectedfunc=undefined) {
// // create one sublist
// const actions = actor.items.filter( item => item.type === itemtype &&
// (!checksort || item.system.settings.general.sorting === sorting) &&
// (!actor.system.settings.general.hideArchive || !item.system.archived))
// .map(item => {
// return {
// id: item.id,
// name: item.name,
// encodedValue: [itemtype, actor.id, tokenId, item.id].join(this.delimiter),
// cssClass: item.system.archived ? 'disabled' : selectedfunc ? (selectedfunc(item) ? 'toggle active' : 'toggle') : '',
// img: Utils.getImage(item)
// }
// })
// if (actions.length) {
// const subcat = { id: sorting, name: Utils.i18n(label), type: 'system-derived'};
// this.addGroup(subcat, parent);
// this.addActions(actions, subcat);
// }
// }

// _getSkills(actor, tokenId, parent) {
// // up to four groups of skills
// const table = {
// Skill: actor.system.settings.skills.labelCategory1 || 'CYPHERSYSTEM.Skills',
// SkillTwo: actor.system.settings.skills.labelCategory2 || 'CYPHERSYSTEM.SkillCategoryTwo',
// SkillThree: actor.system.settings.skills.labelCategory3 || 'CYPHERSYSTEM.SkillCategoryThree',
// SkillFour: actor.system.settings.skills.labelCategory4 || 'CYPHERSYSTEM.SkillCategoryFour',
// }
// for (const [ sorting, label ] of Object.entries(table)) {
// this.createList(parent, actor, tokenId, ACTION_SKILL, true, sorting, label)
// }
// }

// _getAbilities(actor, tokenId, parent) {
// // up to four groups of abilities
// const table = {
// Ability: actor.system.settings.abilities.labelCategory1 || 'CYPHERSYSTEM.Abilities',
// AbilityTwo: actor.system.settings.abilities.labelCategory2 || 'CYPHERSYSTEM.AbilityCategoryTwo',
// AbilityThree: actor.system.settings.abilities.labelCategory3 || 'CYPHERSYSTEM.AbilityCategoryThree',
// AbilityFour: actor.system.settings.abilities.labelCategory4 || 'CYPHERSYSTEM.AbilityCategoryFour',
// Spell: 'CYPHERSYSTEM.Spells'
// }
// for (const [ sorting, label ] of Object.entries(table)) {
// this.createList(parent, actor, tokenId, ACTION_ABILITY, true, sorting, label);
// }
// }

// _getTags(actor, tokenId, parent) {
// // current recursion is from actor.getFlag("cyphersystem", "recursion"), but the stored string is @<lowercasenanme>
// const recursion = actor.getFlag("cyphersystem", "recursion")?.slice(1); // strip leading '@'
// const recursionname = actor.items.find(item => item.name.toLowerCase() === recursion)?.name;
// this.createList(parent, actor, tokenId, ACTION_RECURSION, false, 'recursion', 'CYPHERSYSTEM.Recursions',
// (item) => item.name == recursionname );
// this.createList(parent, actor, tokenId, ACTION_TAG, false, 'tag', 'CYPHERSYSTEM.Tags',
// (item) => item.system.active );
// }
}
});
29 changes: 29 additions & 0 deletions scripts/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Module-based constants
*/
export const MODULE = {
ID: 'fvtt-token-action-hud-TheWitcherTRPG'
};

/**
* Core module
*/
export const CORE_MODULE = {
ID: 'token-action-hud-core'
};

/**
* Core module version required by the system module
*/
export const REQUIRED_CORE_MODULE_VERSION = '1.4';

/**
* Action type
*/
export const ACTION_TYPE = {
attack: 'attack'
};

export const GROUP = {
weapons: { id: 'weapons', name: 'TAH_WITCHER.weapons', type: 'system' }
};
42 changes: 42 additions & 0 deletions scripts/defaults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { GROUP } from './constants.js'

/**
* Default categories and groups
*/
export let DEFAULTS = null;

Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
const groups = GROUP
Object.values(groups).forEach(group => {
group.name = coreModule.api.Utils.i18n(group.name)
group.listName = `Group: ${coreModule.api.Utils.i18n(group.name)}`
})
const groupsArray = Object.values(groups)
DEFAULTS = {
layout: [
{
nestId: 'combat',
id: 'combat',
name: coreModule.api.Utils.i18n('TAH_WITCHER.combat'),
groups: [
{ ...groups.weapons, nestId: 'combat_weapons' }
]
},
{
nestId: 'skills',
id: 'skills',
name: coreModule.api.Utils.i18n('WITCHER.Monster.SkillTab'),
groups: [
]
},
{
nestId: 'magic',
id: 'magic',
name: coreModule.api.Utils.i18n('TAH_WITCHER.magic'),
groups: [
]
}
],
groups: groupsArray
}
});
11 changes: 11 additions & 0 deletions scripts/init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { SystemManager } from './system-manager.js'
import { MODULE, REQUIRED_CORE_MODULE_VERSION } from './constants.js'

Hooks.on('tokenActionHudCoreApiReady', async () => {
const module = game.modules.get(MODULE.ID)
module.api = {
requiredCoreModuleVersion: REQUIRED_CORE_MODULE_VERSION,
SystemManager
}
Hooks.call('tokenActionHudSystemReady', module)
});
Loading

0 comments on commit 71bd5df

Please sign in to comment.