Skip to content

Commit

Permalink
0.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
averrin committed Dec 4, 2022
1 parent 659e8a5 commit 58d557b
Show file tree
Hide file tree
Showing 20 changed files with 1,003 additions and 648 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
All notable changes to this project will be documented in this file. Dates are displayed in UTC.

## [Unreleased]
## [0.5.1 - 0.5.2](https://github.com/averrin/alpha-suit/compare/0.5.1...0.5.2)
Added:
* Expanding dropped folders for grid
* [Director integration] support saved effects for grid
* Support dropped compendiums for grid [Compendium Folders required]
* [Premium, Experimental] Grid tab in the sidebar
* [Premium, Experimental] Grid tab in Alpha Tree
* Folders are now grid-droppable in Alpha Tree
* [Experimental] Checkbox to search files within the current folder

Known Issues:
* Grid can lost some data. Resizing and auto-placing can act weirdly, especially with experimental features enabled.

## [0.5.0 - 0.5.1](https://github.com/averrin/alpha-suit/compare/0.5.0...0.5.1)
Added:
* Titles for grid buttons
Expand Down
8 changes: 4 additions & 4 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"readme": "https://github.com/averrin/alpha-suit/blob/master/README.md",
"bugs": "https://github.com/averrin/alpha-suit/issues",
"changelog": "https://github.com/averrin/alpha-suit/releases/latest/",
"version": "0.5.0-dev",
"minimumCoreVersion": "0.8.6",
"compatibleCoreVersion": "9",
"version": "0.6.0-dev",
"minimumCoreVersion": "9",
"compatibleCoreVersion": "10",
"esmodules": [
"index.js"
],
Expand All @@ -35,7 +35,7 @@
"relationships": {},
"socket": false,
"manifest": "https://github.com/averrin/alpha-suit/releases/latest/download/module.json",
"download": "https://github.com/averrin/alpha-suit/releases/download/0.5.0-dev/module.zip",
"download": "https://github.com/averrin/alpha-suit/releases/download/0.6.0-dev/module.zip",
"protected": false,
"coreTranslation": false,
"library": false,
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

1 change: 0 additions & 1 deletion src/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export function createApps() {
const app = new (CreateApplication(spec, props))();
apps[spec.app_id] = app;
}
logger.info(apps)
return apps;
}

Expand Down
38 changes: 36 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "iconify-icon";

import { moduleId, SETTINGS, infoColor } from "./modules/constants.js";

import {get} from "svelte/store"
import { get } from "svelte/store"
import initHelpers, { logger, moduleId as mid } from "crew-components/helpers";
import { initStores as helperStores } from "crew-components/stores";

Expand All @@ -18,9 +18,11 @@ import { initSettingsTopics } from "./modules/settings_content";
import { createApps, getApp, startGMApps, startUserApps } from "./apps";
import { getTool, initTools } from "./tools";
import "./systems.js";
import {createAPI} from "./api.js";
import { createAPI } from "./api.js";
import GridUI_inline from "./view/GridUI_inline.svelte"

import NotificationsApp from "./view/Notifications.js"
import CreateApplication from "crew-components/AlphaApplication";

initHelpers(moduleId, infoColor, SETTINGS);
createApps();
Expand All @@ -47,11 +49,43 @@ Hooks.on('renderSceneControls', _ => {
initTools();
});

function addSidebarTab(id, appSpec) {
const tabs = document.getElementById("sidebar-tabs");
const tab = document.createElement("a")
tab.classList.add("item")
tab.dataset.tab = id
const icon = document.createElement("i")
icon.classList.add("fas")
icon.classList.add("fa-icons")
tab.appendChild(icon)
tabs.prepend(tab)

const sidebar = document.getElementById("sidebar");
const section = document.createElement("section")
section.classList.add("sidebar-tab")
section.classList.add("tab")
section.id = id
section.dataset.tab = id
sidebar.appendChild(section);

//TODO: rework resizing
document.querySelector(':root').style.setProperty("--sidebar-width", "360px");

const igApp = new (CreateApplication(appSpec))();
igApp.start();
igApp.show()
}

Hooks.once('ready', () => {
helperStores()
initStores();
startUserApps()

if (game.settings.get(moduleId, SETTINGS.GRID_IN_SIDEBAR)) {
const inlineGrid = { moduleId: "alpha-suit", isTemp: true, app_id: "grid", target: "#grid", title: "Alpha Grid [ALPHA]", component: GridUI_inline }
addSidebarTab("grid", inlineGrid)
}

if (game.user.isGM) {
startGMApps()

Expand Down
2 changes: 2 additions & 0 deletions src/modules/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export const FLAGS = {
}

export const SETTINGS = {
GRID_IN_SIDEBAR: "grid-in-sidebar",
GRID_IN_TREE: "grid-in-tree",
GRID_FOR_PLAYERS: "grid-for-players",
DEBUG: "debug",
FILES_WHITE_LIST: "files-white-list",
Expand Down
18 changes: 18 additions & 0 deletions src/modules/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,4 +396,22 @@ export function initSettings() {
type: Boolean,
default: true,
});

game.settings.register(moduleId, SETTINGS.GRID_IN_SIDEBAR, {
name: "Show grid tab in sidebar",
hint: "[EXPERIMENTAL] Add grid tab to the sidebar",
scope: "client",
config: false,
type: Boolean,
default: false,
});

game.settings.register(moduleId, SETTINGS.GRID_IN_TREE, {
name: "Show grid tab in Alpha Tree",
hint: "[EXPERIMENTAL] Add grid tab in Alpha Tree",
scope: "client",
config: false,
type: Boolean,
default: false,
});
}
4 changes: 4 additions & 0 deletions src/modules/stores.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export const helpTopic = writable(null);
export const helpTree = writable({});
export const settingsTopic = writable(null);
export const settingsTree = writable({});
export const gridSizes = writable({});
export const lastEditGrid = writable(null);

export const tagsStore = writable([]);
export const systems = writable({});
Expand All @@ -39,6 +41,8 @@ export const directorActionsStore = writable([]);
export const charactersStore = writable([]);
export const targetsStore = writable([]);

export const editingWidget = writable(null)

function getTree() {
let collection = get(currentCollection);
return collection.directory.tree;
Expand Down
53 changes: 39 additions & 14 deletions src/view/EditWidgetDialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<script>
import { v4 as uuidv4 } from "uuid";
import AlphaShell from "crew-components/AlphaShell";
import { onDestroy, tick } from "svelte";
import { onDestroy, tick, createEventDispatcher } from "svelte";
import InlineButton from "crew-components/InlineButton";
import { isPremium } from "crew-components/premium";
Expand All @@ -13,15 +13,38 @@
import { TJSProseMirror } from "@typhonjs-fvtt/svelte-standard/component";
import ArgInput from "crew-components/ArgInput";
import InspectButton from "./components/InspectButton.svelte";
import { editingWidget } from "../modules/stores.js";
export let elementRoot;
export let id;
let content = "HP: {{system.attributes.hp.value}} / {{system.attributes.hp.max}}";
let widget = $editingWidget;
if (!widget) {
widget = {
1: {
h: 1,
w: 4,
x: 0,
y: 0,
},
type: "Text",
widgetId: uuidv4(),
persist: {
target: undefined,
template: content,
},
};
}
logger.info(widget)
let result = "";
let source;
let target;
function save() {
$editingWidget.set(widget);
}
function getTarget() {
target = calculateValue(source, "token");
logger.info(target);
Expand All @@ -30,8 +53,8 @@
function process() {
try {
getTarget();
result = Handlebars.compile(content)(target.actor);
logger.info(result);
result = Handlebars.compile(widget.persist.template)(target.actor);
logger.info(widget.persist.template, result);
} catch (e) {
result = e;
}
Expand All @@ -41,29 +64,31 @@
$: process();
</script>

<AlphaShell bind:elementRoot {id} fullHeight={true} temp={true}>
<AlphaShell bind:elementRoot {id} fullHeight={true} isTemp={true}>
<div class="ui-flex ui-flex-col ui-gap-2 ui-h-full ui-items-stretch">
<div class="ui-flex ui-flex-row ui-gap-2 ui-items-center ui-p-1"
style:background-color="hsl(var(--b2))"
>
<ArgInput type="token" label="Source token" bind:value={source} on:change={process} />
<InspectButton item={target?.actor} size="md" />
</div>
<div class="ui-flex ui-flex-row ui-gap-2 ui-items-center ui-p-1" style:background-color="hsl(var(--b2))">
<ArgInput type="token" label="Source token" bind:value={source} on:change={process} />
<InspectButton item={target?.actor} size="md" />
</div>

<div class="ui-flex ui-flex-col ui-h-1/2 ui-p-1">
<h3>Template</h3>
<TJSProseMirror
on:editor:save={(e) => {
logger.info("editor:save", e);
process()
process();
}}
bind:content
bind:content={widget.persist.template}
options={{ editable: true }}
/>
</div>
<div class="ui-flex ui-flex-col ui-h-1/2 ui-p-1">
<h3>Preview</h3>
<button on:click={process}>update</button>
<TJSProseMirror content={result} options={{ editable: false }} />
</div>
<div class="ui-flex ui-flex-row ui-w-full ui-content-between ui-p-2 ui-gap-2">
<button class="ui-btn ui-btn-md" style:width="49%" on:click={process}>Update</button>
<button class="ui-btn ui-btn-md ui-btn-primary" style:width="49%" on:click={save}>Save</button>
</div>
</div>
</AlphaShell>
29 changes: 27 additions & 2 deletions src/view/FilesUI.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -443,15 +443,25 @@
const ff = foundry.utils.debounce(filterFiles, 5);
const searchLimit = setting(SETTINGS.FILES_SEARCH_LIMIT);
const fuzzy = setting(SETTINGS.FILES_FUZZY) && isPremium();
let searchInFolder = false;
let folderForSearch;
function searchFile() {
if (search.length >= 3) {
if (topic.id != "Search") {
folderForSearch = topic.id;
}
selectedFiles.set([]);
searchStatus = "Searching...";
files = [];
topic = { id: "Search", source: { files } };
filterFiles();
let index = $fileIndex;
if (searchInFolder && folderForSearch) {
index = index.filter((p) => p.startsWith(folderForSearch));
}
if (!fuzzy) {
$fileIndex.forEach((f) => {
index.forEach((f) => {
const name = f.split("/")[f.split("/").length - 1];
const store = f.split("/")[0];
f = f.replace(store + "/", "");
Expand All @@ -464,7 +474,7 @@
} else {
const result = fuzzyFindInList(
search,
$fileIndex.map((f) => {
index.map((f) => {
const name = f.split("/")[f.split("/").length - 1];
const store = f.split("/")[0];
f = f.replace(store + "/", "");
Expand Down Expand Up @@ -530,6 +540,21 @@
clearable={true}
>
<svelte:fragment slot="right">
<span
class="ui-p-1"
style="background-color: hsl(var(--n) / var(--tw-bg-opacity));"
title="Search within the current folder"
>
<ArgInput
type="check"
size="xs"
bind:value={searchInFolder}
on:change={(e) => {
searchInFolder = e.detail;
searchFile();
}}
/>
</span>
{#if $fileIndex.length == 0}
<IconButton icon="mdi:database" on:click={rebuildIndex} type="primary" title="Start indexing" />
{/if}
Expand Down
Loading

0 comments on commit 58d557b

Please sign in to comment.