Fix issue #65: Item selecting icon
This commit is contained in:
166
frontend/app/components/windows/FoundryIconPickerWindow.vue
Normal file
166
frontend/app/components/windows/FoundryIconPickerWindow.vue
Normal file
@@ -0,0 +1,166 @@
|
||||
<script setup>
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { SetupHandle, SetSize, ResetPosition, ClearWindow, Top, SetResizable, SetMinSize } from '@/services/Windows';
|
||||
import WindowHandle from './partials/WindowHandle.vue';
|
||||
import Server from '~/services/Server';
|
||||
import { emitter } from '~/services/Emitter';
|
||||
|
||||
const props = defineProps(['data']);
|
||||
const id = props.data.id;
|
||||
const itemId = props.data.item?._id;
|
||||
const campaign = props.data.campaign || '';
|
||||
const ICON_ROOT = 'icons';
|
||||
|
||||
const handle = ref(null);
|
||||
const wrapper = ref(null);
|
||||
const loading = ref(false);
|
||||
const error = ref('');
|
||||
const applying = ref('');
|
||||
// What the window is standing on: one folder of Foundry's icon library at a time.
|
||||
const listing = ref({ dir: ICON_ROOT, parent: null, folders: [], files: [], next: null });
|
||||
const { t } = useI18n();
|
||||
|
||||
onMounted(() => {
|
||||
Top(wrapper);
|
||||
SetupHandle(id, handle);
|
||||
SetSize(id, { width: 560, height: 540 });
|
||||
ResetPosition(id, 'center');
|
||||
SetResizable(id, true);
|
||||
SetMinSize(id, { width: 420, height: 340 });
|
||||
Load(ICON_ROOT);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => ClearWindow({ type: 'foundry_icons' }));
|
||||
|
||||
// One request per folder, and the icons inside it a page at a time: that library
|
||||
// runs into the thousands, so the window only ever asks for what it shows.
|
||||
async function Load(dir, offset = 0) {
|
||||
if (loading.value) return;
|
||||
if (!campaign) {
|
||||
error.value = t('foundry.errors.icons-no-world-url');
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const params = new URLSearchParams({ campaign, dir });
|
||||
if (offset) params.set('offset', String(offset));
|
||||
const response = await Server().get(`/foundry/icons?${params.toString()}`);
|
||||
if (response.data.status !== 'ok') {
|
||||
error.value = t(response.data.msg || 'foundry.errors.icons-unavailable');
|
||||
return;
|
||||
}
|
||||
const page = {
|
||||
dir: response.data.dir || dir,
|
||||
parent: response.data.parent ?? null,
|
||||
folders: response.data.folders || [],
|
||||
files: response.data.files || [],
|
||||
next: response.data.next ?? null,
|
||||
};
|
||||
listing.value = offset
|
||||
? { ...page, files: [...listing.value.files, ...page.files] }
|
||||
: page;
|
||||
} catch (requestError) {
|
||||
error.value = t('foundry.errors.icons-unavailable');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const trail = computed(() => {
|
||||
const parts = String(listing.value.dir || ICON_ROOT).split('/').filter(Boolean);
|
||||
return parts.map((name, index) => ({ name, path: parts.slice(0, index + 1).join('/') }));
|
||||
});
|
||||
|
||||
const empty = computed(() => !loading.value && !listing.value.folders.length && !listing.value.files.length);
|
||||
|
||||
function GoUp() {
|
||||
Load(listing.value.parent || ICON_ROOT);
|
||||
}
|
||||
|
||||
// The icon is stored as the url the browser loads it from, the same shape a synced
|
||||
// Foundry item's icon has; the item window follows the event this leaves behind.
|
||||
async function Choose(icon) {
|
||||
if (applying.value) return;
|
||||
applying.value = icon.path;
|
||||
error.value = '';
|
||||
try {
|
||||
const response = await Server().post('/item/update', { id: itemId, image: icon.url });
|
||||
if (response.data.status !== 'ok') {
|
||||
error.value = t('campaigns.item.sheet.save-error');
|
||||
return;
|
||||
}
|
||||
emitter.emit('campaign-entry-updated', { entityType: 'item', entry: response.data.item });
|
||||
ClearWindow({ type: 'foundry_icons' });
|
||||
ClearWindow({ type: 'item_icon_source' });
|
||||
} catch (requestError) {
|
||||
error.value = t('campaigns.item.sheet.save-error');
|
||||
} finally {
|
||||
applying.value = '';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="window-wrapper foundry-icons-window" :id="'window-wrapper-' + id" ref="wrapper">
|
||||
<WindowHandle :window="id" ref="handle" />
|
||||
<div class="icons-body">
|
||||
<nav class="icons-trail" :aria-label="$t('foundry.icons.path')">
|
||||
<button class="trail-up" type="button" :disabled="loading || !listing.parent" :aria-label="$t('foundry.icons.up')" @click="GoUp">
|
||||
<img class="icon" src="/icons/iconoir/regular/arrow-up.svg" alt="" aria-hidden="true">
|
||||
</button>
|
||||
<template v-for="crumb in trail" :key="crumb.path">
|
||||
<span class="trail-separator" aria-hidden="true">/</span>
|
||||
<button class="trail-crumb" type="button" :disabled="loading" @click="Load(crumb.path)">{{ crumb.name }}</button>
|
||||
</template>
|
||||
</nav>
|
||||
|
||||
<div v-if="error" class="icons-error">{{ error }}</div>
|
||||
<p v-if="loading" class="icons-state">{{ $t('foundry.icons.loading') }}</p>
|
||||
<p v-else-if="empty" class="icons-state">{{ $t('foundry.icons.empty') }}</p>
|
||||
|
||||
<div v-if="listing.folders.length" class="icon-tiles">
|
||||
<button v-for="folder in listing.folders" :key="folder.path" class="icon-tile folder" type="button" :disabled="loading" @click="Load(folder.path)">
|
||||
<img class="icon" src="/icons/iconoir/regular/folder.svg" alt="" aria-hidden="true">
|
||||
<span class="tile-name">{{ folder.name }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="listing.files.length" class="icon-tiles">
|
||||
<button v-for="icon in listing.files" :key="icon.path" class="icon-tile" type="button"
|
||||
:disabled="applying !== ''" :title="icon.name" @click="Choose(icon)">
|
||||
<img class="tile-image" :src="icon.url" :alt="icon.name" loading="lazy">
|
||||
<span class="tile-name">{{ icon.name }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<button v-if="listing.next" class="icons-more sheet-button" type="button" :disabled="loading" @click="Load(listing.dir, listing.next)">
|
||||
{{ $t('foundry.icons.load-more') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.foundry-icons-window { min-width: 0; min-height: 0; }
|
||||
.icons-body { width: 100%; min-height: 0; flex: 1; overflow: auto; padding: 12px 14px 16px; box-sizing: border-box; display: flex; flex-direction: column; gap: 10px; }
|
||||
.icons-trail { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; position: sticky; top: 0; padding-bottom: 8px; background: var(--color-window-background); font-size: 12px; }
|
||||
.trail-up, .trail-crumb { display: inline-flex; align-items: center; padding: 4px 7px; border: 1px solid var(--color-border); border-radius: 6px; background: var(--color-background-soft); color: var(--color-text); cursor: pointer; font-size: 12px; }
|
||||
.trail-up:hover, .trail-crumb:hover { background: var(--color-button-hover); }
|
||||
.trail-up:disabled, .trail-crumb:disabled { opacity: .5; cursor: wait; }
|
||||
.trail-separator { opacity: .45; }
|
||||
.icons-error { padding: 7px 10px; border-radius: 6px; color: var(--color-red); background: var(--color-background-soft); font-size: 12px; }
|
||||
.icons-state { margin: 0; font-size: 12px; opacity: .7; }
|
||||
.icon-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
|
||||
.icon-tile { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 8px 6px; border: 1px solid var(--color-border); border-radius: 8px; background: var(--color-background-soft); color: var(--color-text); cursor: pointer; }
|
||||
.icon-tile:hover { background: var(--color-button-hover); border-color: var(--color-link); }
|
||||
.icon-tile:disabled { opacity: .55; cursor: wait; }
|
||||
.icon-tile.folder { justify-content: center; }
|
||||
.icon-tile .icon { width: 22px; height: 22px; }
|
||||
.tile-image { width: 40px; height: 40px; object-fit: contain; }
|
||||
.tile-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; opacity: .75; }
|
||||
.icons-more { align-self: center; border: 1px solid var(--color-border); border-radius: 7px; padding: 7px 12px; background: var(--color-background-soft); color: var(--color-text); cursor: pointer; white-space: nowrap; font-size: 13px; }
|
||||
.icons-more:hover { background: var(--color-button-hover); }
|
||||
.icons-more:disabled { opacity: .55; cursor: wait; }
|
||||
</style>
|
||||
128
frontend/app/components/windows/ItemIconSourceWindow.vue
Normal file
128
frontend/app/components/windows/ItemIconSourceWindow.vue
Normal file
@@ -0,0 +1,128 @@
|
||||
<script setup>
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { SetupHandle, SetSize, ResetPosition, ClearWindow, Top, CreateChildWindow } from '@/services/Windows';
|
||||
import WindowHandle from './partials/WindowHandle.vue';
|
||||
import Server, { getBaseUrl } from '~/services/Server';
|
||||
import { emitter } from '~/services/Emitter';
|
||||
|
||||
const props = defineProps(['data']);
|
||||
const id = props.data.id;
|
||||
const item = props.data.item || {};
|
||||
const itemId = item._id;
|
||||
const campaign = props.data.campaign || '';
|
||||
const handle = ref(null);
|
||||
const wrapper = ref(null);
|
||||
const error = ref('');
|
||||
const uploading = ref(false);
|
||||
const photoInput = ref(null);
|
||||
const image = ref(item.image || '');
|
||||
const { t } = useI18n();
|
||||
|
||||
onMounted(() => {
|
||||
Top(wrapper);
|
||||
SetupHandle(id, handle);
|
||||
SetSize(id, { width: 430, height: 320 });
|
||||
ResetPosition(id, 'center');
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => ClearWindow({ type: 'item_icon_source' }));
|
||||
|
||||
// An uploaded icon is a file of the backend's uploads folder and a Foundry one an
|
||||
// absolute url of the world; both are drawn the way the item window draws them.
|
||||
const imageUrl = computed(() => {
|
||||
if (!image.value) return '';
|
||||
return /^(https?:|data:|\/\/)/i.test(image.value)
|
||||
? image.value
|
||||
: `${getBaseUrl()}/public/${image.value}`;
|
||||
});
|
||||
|
||||
function pickLocalIcon() {
|
||||
photoInput.value?.click();
|
||||
}
|
||||
|
||||
// The icon browser opens on top of this window, as its child: closing the chooser
|
||||
// takes the browser with it, like every other child window here.
|
||||
function openFoundryIcons() {
|
||||
CreateChildWindow(id, 'foundry_icons', { item: { _id: itemId, name: item.name }, campaign });
|
||||
}
|
||||
|
||||
async function onIconSelected(event) {
|
||||
const file = event.target.files?.[0];
|
||||
event.target.value = '';
|
||||
if (!file || uploading.value) return;
|
||||
uploading.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append('image', file);
|
||||
const response = await Server().post(`/item/upload-image?item=${itemId}`, formData, {
|
||||
headers: { "Content-Type": "multipart/form-data" }
|
||||
});
|
||||
if (response.data.status !== 'ok') {
|
||||
error.value = t('campaigns.item.sheet.upload-error');
|
||||
return;
|
||||
}
|
||||
// The item window follows this event and shows the new icon.
|
||||
emitter.emit('campaign-entry-updated', { entityType: 'item', entry: response.data.item });
|
||||
ClearWindow({ id });
|
||||
} catch (requestError) {
|
||||
error.value = t('campaigns.item.sheet.upload-error');
|
||||
} finally {
|
||||
uploading.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="window-wrapper icon-source-window" :id="'window-wrapper-' + id" ref="wrapper">
|
||||
<WindowHandle :window="id" ref="handle" />
|
||||
<div class="source-body">
|
||||
<header class="source-hero">
|
||||
<div class="source-icon" :class="{ empty: !image }">
|
||||
<img v-if="imageUrl" :src="imageUrl" :alt="$t('campaigns.item.sheet.icon')">
|
||||
<span v-else aria-hidden="true">{{ (item.name || '?').slice(0, 1).toUpperCase() }}</span>
|
||||
</div>
|
||||
<p class="source-intro">{{ $t('campaigns.item.icon-picker.intro') }}</p>
|
||||
</header>
|
||||
|
||||
<div v-if="error" class="source-error">{{ error }}</div>
|
||||
|
||||
<div class="source-options">
|
||||
<button class="source-option" type="button" :disabled="uploading" @click="pickLocalIcon">
|
||||
<img class="icon" src="/icons/iconoir/regular/cloud-upload.svg" alt="" aria-hidden="true">
|
||||
<span class="source-option-title">{{ uploading
|
||||
? $t('campaigns.item.sheet.uploading')
|
||||
: $t('campaigns.item.icon-picker.upload') }}</span>
|
||||
<span class="source-option-hint">{{ $t('campaigns.item.icon-picker.upload-hint') }}</span>
|
||||
</button>
|
||||
<button class="source-option" type="button" @click="openFoundryIcons">
|
||||
<img class="icon" src="/icons/iconoir/regular/media-image.svg" alt="" aria-hidden="true">
|
||||
<span class="source-option-title">{{ $t('campaigns.item.icon-picker.foundry') }}</span>
|
||||
<span class="source-option-hint">{{ $t('campaigns.item.icon-picker.foundry-hint') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<input ref="photoInput" class="photo-input" type="file" accept="image/*" @change="onIconSelected">
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.icon-source-window { min-width: 0; min-height: 0; }
|
||||
.source-body { width: 100%; min-height: 0; flex: 1; overflow: auto; padding: 14px 16px 16px; box-sizing: border-box; display: flex; flex-direction: column; gap: 12px; }
|
||||
.source-hero { display: flex; align-items: center; gap: 13px; padding-bottom: 12px; border-bottom: 1px solid var(--color-border); }
|
||||
.source-icon { width: 56px; height: 56px; flex: 0 0 56px; display: grid; place-items: center; overflow: hidden; border-radius: 10px; border: 1px solid var(--color-border); background: var(--color-background-soft); color: var(--color-link); font: 26px MrEavesRemake; }
|
||||
.source-icon.empty { border-style: dashed; }
|
||||
.source-icon img { width: 100%; height: 100%; object-fit: contain; }
|
||||
.source-intro { margin: 0; font-size: 13px; opacity: .85; }
|
||||
.source-error { padding: 7px 10px; border-radius: 6px; color: var(--color-red); background: var(--color-background-soft); font-size: 12px; }
|
||||
.source-options { display: flex; flex-direction: column; gap: 10px; }
|
||||
.source-option { display: grid; grid-template-columns: 26px 1fr; align-items: center; gap: 4px 10px; padding: 12px 14px; text-align: left; border: 1px solid var(--color-border); border-radius: 10px; background: var(--color-background-soft); color: var(--color-text); cursor: pointer; }
|
||||
.source-option:hover { background: var(--color-button-hover); }
|
||||
.source-option:disabled { opacity: .55; cursor: wait; }
|
||||
.source-option .icon { width: 20px; height: 20px; grid-row: span 2; }
|
||||
.source-option-title { font: 15px MrEavesRemake; }
|
||||
.source-option-hint { font-size: 12px; opacity: .7; }
|
||||
.photo-input { display: none; }
|
||||
</style>
|
||||
@@ -1,9 +1,10 @@
|
||||
<script setup>
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { SetupHandle, SetSize, ResetPosition, ClearWindow, Top } from '@/services/Windows';
|
||||
import { SetupHandle, SetSize, ResetPosition, ClearWindow, Top, CreateChildWindow } from '@/services/Windows';
|
||||
import WindowHandle from './partials/WindowHandle.vue';
|
||||
import Server, { getBaseUrl } from '~/services/Server';
|
||||
import { useCampaignService } from '~/services/Campaign.js';
|
||||
import { emitter } from '~/services/Emitter';
|
||||
|
||||
const props = defineProps(['data']);
|
||||
@@ -12,9 +13,10 @@ const itemId = props.data.item?._id;
|
||||
const handle = ref(null);
|
||||
const wrapper = ref(null);
|
||||
const error = ref('');
|
||||
const uploadingIcon = ref(false);
|
||||
const applyingFoundryIcon = ref(false);
|
||||
const photoInput = ref(null);
|
||||
// Set while this window writes the item's icon, so a Foundry sync landing behind
|
||||
// the window does not rewrite the form under the change being made.
|
||||
const applyingIcon = ref(false);
|
||||
const { Campaign } = useCampaignService();
|
||||
const { t } = useI18n();
|
||||
|
||||
function normalizeItem(item) {
|
||||
@@ -43,9 +45,10 @@ onMounted(() => {
|
||||
onBeforeUnmount(() => ClearWindow({ type: 'item_sheet' }));
|
||||
|
||||
// The sidebar keeps this entry fresh (Foundry sync lands in the background);
|
||||
// follow along unless the window is mid-icon-upload.
|
||||
// follow along unless this window is mid-icon-change. The icon windows leave
|
||||
// their result here, on the same event.
|
||||
function handleItemSync({ entityType, entry }) {
|
||||
if (entityType !== 'item' || entry?._id !== itemId || uploadingIcon.value) return;
|
||||
if (entityType !== 'item' || entry?._id !== itemId || applyingIcon.value) return;
|
||||
form.value = normalizeItem(entry);
|
||||
}
|
||||
|
||||
@@ -69,40 +72,22 @@ async function updateItem(payload) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function pickIcon() {
|
||||
photoInput.value?.click();
|
||||
// Choosing an icon is a window of its own: upload one from this device, or browse
|
||||
// the icon library of the linked Foundry world. Both leave their result on the
|
||||
// `campaign-entry-updated` event, which this window follows.
|
||||
function chooseIcon() {
|
||||
CreateChildWindow(id, 'item_icon_source', {
|
||||
item: { _id: itemId, name: form.value.name, image: form.value.image },
|
||||
campaign: Campaign.value?._id || ''
|
||||
});
|
||||
}
|
||||
|
||||
async function onIconSelected(event) {
|
||||
const file = event.target.files?.[0];
|
||||
event.target.value = '';
|
||||
if (!file || uploadingIcon.value) return;
|
||||
uploadingIcon.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append('image', file);
|
||||
const response = await Server().post(`/item/upload-image?item=${itemId}`, formData, {
|
||||
headers: { "Content-Type": "multipart/form-data" }
|
||||
});
|
||||
if (response.data.status !== 'ok') {
|
||||
error.value = t('campaigns.item.sheet.upload-error');
|
||||
return;
|
||||
}
|
||||
form.value = normalizeItem(response.data.item);
|
||||
emitter.emit('campaign-entry-updated', { entityType: 'item', entry: response.data.item });
|
||||
} catch (requestError) {
|
||||
error.value = t('campaigns.item.sheet.upload-error');
|
||||
} finally {
|
||||
uploadingIcon.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// "Fetch from Foundry's icons": the module keeps the world's own icon on the
|
||||
// item, so this just switches back to it.
|
||||
// The world's own icon for this item: the module keeps it on the item, so this
|
||||
// just switches back to it. Picking one of the world's other icons is what the
|
||||
// icon browser is for.
|
||||
async function useFoundryIcon() {
|
||||
if (!canUseFoundryIcon.value || applyingFoundryIcon.value) return;
|
||||
applyingFoundryIcon.value = true;
|
||||
if (!canUseFoundryIcon.value || applyingIcon.value) return;
|
||||
applyingIcon.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const done = await updateItem({ image: form.value.foundryImage });
|
||||
@@ -110,18 +95,21 @@ async function useFoundryIcon() {
|
||||
} catch (requestError) {
|
||||
error.value = t('campaigns.item.sheet.save-error');
|
||||
} finally {
|
||||
applyingFoundryIcon.value = false;
|
||||
applyingIcon.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function removeIcon() {
|
||||
if (!form.value.image) return;
|
||||
if (!form.value.image || applyingIcon.value) return;
|
||||
applyingIcon.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const done = await updateItem({ image: '' });
|
||||
if (!done) error.value = t('campaigns.item.sheet.save-error');
|
||||
} catch (requestError) {
|
||||
error.value = t('campaigns.item.sheet.save-error');
|
||||
} finally {
|
||||
applyingIcon.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -131,10 +119,12 @@ async function removeIcon() {
|
||||
<WindowHandle :window="id" ref="handle" />
|
||||
<div class="item-body">
|
||||
<header class="item-hero">
|
||||
<div class="item-icon" :class="{ empty: !form.image }">
|
||||
<button class="item-icon" :class="{ empty: !form.image }" type="button"
|
||||
:aria-label="$t(form.image ? 'campaigns.item.sheet.change-icon' : 'campaigns.item.sheet.choose-icon')"
|
||||
@click="chooseIcon">
|
||||
<img v-if="form.image" :src="imageUrl" :alt="$t('campaigns.item.sheet.icon')">
|
||||
<span v-else aria-hidden="true">{{ form.name.slice(0, 1).toUpperCase() }}</span>
|
||||
</div>
|
||||
</button>
|
||||
<div class="item-identity">
|
||||
<h1>{{ form.name }}</h1>
|
||||
<div class="item-tags">
|
||||
@@ -148,16 +138,13 @@ async function removeIcon() {
|
||||
<div v-if="error" class="item-error">{{ error }}</div>
|
||||
|
||||
<div class="icon-controls">
|
||||
<button class="sheet-button" type="button" :disabled="uploadingIcon" @click="pickIcon">
|
||||
{{ uploadingIcon
|
||||
? $t('campaigns.item.sheet.uploading')
|
||||
: (form.image ? $t('campaigns.item.sheet.change-icon') : $t('campaigns.item.sheet.choose-icon')) }}
|
||||
<button class="sheet-button" type="button" @click="chooseIcon">
|
||||
{{ form.image ? $t('campaigns.item.sheet.change-icon') : $t('campaigns.item.sheet.choose-icon') }}
|
||||
</button>
|
||||
<button v-if="canUseFoundryIcon" class="sheet-button secondary" type="button" :disabled="applyingFoundryIcon" @click="useFoundryIcon">
|
||||
<button v-if="canUseFoundryIcon" class="sheet-button secondary" type="button" :disabled="applyingIcon" @click="useFoundryIcon">
|
||||
{{ $t('campaigns.item.sheet.foundry-icon') }}
|
||||
</button>
|
||||
<button v-if="form.image" class="sheet-button secondary" type="button" :disabled="uploadingIcon" :aria-label="$t('campaigns.item.sheet.remove-icon')" @click="removeIcon">×</button>
|
||||
<input ref="photoInput" class="photo-input" type="file" accept="image/*" @change="onIconSelected">
|
||||
<button v-if="form.image" class="sheet-button secondary" type="button" :disabled="applyingIcon" :aria-label="$t('campaigns.item.sheet.remove-icon')" @click="removeIcon">×</button>
|
||||
</div>
|
||||
|
||||
<!-- Quantity is the actor inventory's business (Syndria98/dragonroll#63); the item
|
||||
@@ -186,7 +173,8 @@ async function removeIcon() {
|
||||
.item-window { min-width: 0; min-height: 0; }
|
||||
.item-body { width: 100%; min-height: 0; flex: 1; overflow: auto; padding: 14px 16px 16px; box-sizing: border-box; }
|
||||
.item-hero { display: flex; align-items: center; gap: 13px; padding: 2px 2px 13px; margin-bottom: 11px; border-bottom: 1px solid var(--color-border); }
|
||||
.item-icon { width: 64px; height: 64px; flex: 0 0 64px; display: grid; place-items: center; overflow: hidden; border-radius: 10px; border: 1px solid var(--color-border); background: var(--color-background-soft); color: var(--color-link); font: 30px MrEavesRemake; }
|
||||
.item-icon { width: 64px; height: 64px; flex: 0 0 64px; display: grid; place-items: center; overflow: hidden; border-radius: 10px; border: 1px solid var(--color-border); background: var(--color-background-soft); color: var(--color-link); font: 30px MrEavesRemake; padding: 0; cursor: pointer; }
|
||||
.item-icon:hover { border-color: var(--color-link); }
|
||||
.item-icon.empty { border-style: dashed; }
|
||||
.item-icon img { width: 100%; height: 100%; object-fit: contain; }
|
||||
.item-identity { min-width: 0; }
|
||||
@@ -199,7 +187,6 @@ async function removeIcon() {
|
||||
.sheet-button { border: 1px solid var(--color-border); border-radius: 7px; padding: 7px 12px; background: var(--color-background-soft); color: var(--color-text); cursor: pointer; white-space: nowrap; font-size: 13px; }
|
||||
.sheet-button:hover { background: var(--color-button-hover); }
|
||||
.sheet-button:disabled { opacity: .55; cursor: wait; }
|
||||
.photo-input { display: none; }
|
||||
.item-facts { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 13px; }
|
||||
.item-fact { flex: 1 1 120px; min-width: 0; padding: 9px 11px; border: 1px solid var(--color-border); border-radius: 8px; background: var(--color-background-soft); }
|
||||
.item-fact dt { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; opacity: .72; }
|
||||
|
||||
@@ -88,6 +88,21 @@ const defWindows = {
|
||||
close: () => ClearWindow({type: 'item_sheet'}),
|
||||
movable: true
|
||||
},
|
||||
item_icon_source: {
|
||||
title: 'windows.icon-source',
|
||||
component: () => import('~/components/windows/ItemIconSourceWindow.vue'),
|
||||
close: () => ClearWindow({ type: 'item_icon_source' }),
|
||||
movable: true
|
||||
},
|
||||
foundry_icons: {
|
||||
title: 'windows.foundry-icons',
|
||||
component: () => import('~/components/windows/FoundryIconPickerWindow.vue'),
|
||||
// Back closes the icon browser and leaves the chooser it was opened from,
|
||||
// which is still open behind it.
|
||||
back: () => ClearWindow({ type: 'foundry_icons' }),
|
||||
close: () => ClearWindow({ type: 'foundry_icons' }),
|
||||
movable: true
|
||||
},
|
||||
create_map: {
|
||||
title: 'windows.create-map',
|
||||
component: () => import('~/components/windows/CreateMapWindow.vue'),
|
||||
|
||||
@@ -73,6 +73,11 @@
|
||||
"foundry-icon": "Fes servir la icona del Foundry", "remove-icon": "Treu la icona", "save-error": "No s'ha pogut desar aquest objecte.",
|
||||
"no-description": "Sense descripció afegida."
|
||||
},
|
||||
"icon-picker": {
|
||||
"intro": "D'on ha de sortir la icona d'aquest objecte?",
|
||||
"upload": "Pujar una icona", "upload-hint": "Tria una imatge d'aquest dispositiu.",
|
||||
"foundry": "Carregar del Foundry", "foundry-hint": "Recorre les icones que inclou el teu món del Foundry."
|
||||
},
|
||||
"categories": {
|
||||
"weapon": "Arma", "armor": "Armadura", "shield": "Escut", "adventuring-gear": "Equip d'aventura",
|
||||
"magic-item": "Objecte màgic", "consumable": "Consumible", "tool": "Eina", "treasure": "Tresor", "other": "Altre"
|
||||
|
||||
@@ -3,6 +3,15 @@
|
||||
"link-expired": "El codi d'enllaç de Foundry no és vàlid, ha caducat o ja s'ha utilitzat.",
|
||||
"world-already-linked": "Aquest món de Foundry ja està enllaçat amb una altra campanya.",
|
||||
"actor-already-synced": "Un altre actor d'aquesta campanya ja està sincronitzat amb aquell actor del Foundry.",
|
||||
"item-already-synced": "Un altre objecte d'aquesta campanya ja està sincronitzat amb aquell objecte del Foundry."
|
||||
"item-already-synced": "Un altre objecte d'aquesta campanya ja està sincronitzat amb aquell objecte del Foundry.",
|
||||
"icons-unavailable": "Les icones del Foundry no són disponibles: el seu bridge no està configurat o ara mateix no hi arriba.",
|
||||
"icons-no-world-url": "Aquesta campanya no té adreça del món del Foundry. Definiu-la als ajustos de la campanya, a la pestanya d'integracions."
|
||||
},
|
||||
"icons": {
|
||||
"path": "Carpeta d'icones",
|
||||
"up": "Una carpeta amunt",
|
||||
"loading": "Carregant icones...",
|
||||
"empty": "No hi ha icones per triar en aquesta carpeta.",
|
||||
"load-more": "Carregar més icones"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,5 +10,7 @@
|
||||
"create-map": "Crear mapa",
|
||||
"map-viewer": "Mapa",
|
||||
"pinned-note": "Nota fixada",
|
||||
"item-sheet": "Objecte"
|
||||
"item-sheet": "Objecte",
|
||||
"icon-source": "Tria una icona",
|
||||
"foundry-icons": "Icones del Foundry"
|
||||
}
|
||||
|
||||
@@ -77,6 +77,11 @@
|
||||
"foundry-icon": "Use Foundry icon", "remove-icon": "Remove icon", "save-error": "Unable to save this item.",
|
||||
"no-description": "No description added."
|
||||
},
|
||||
"icon-picker": {
|
||||
"intro": "Where should this item's icon come from?",
|
||||
"upload": "Upload icon", "upload-hint": "Choose an image from this device.",
|
||||
"foundry": "Load from Foundry", "foundry-hint": "Browse the icons your Foundry world ships with."
|
||||
},
|
||||
"categories": {
|
||||
"weapon": "Weapon", "armor": "Armor", "shield": "Shield", "adventuring-gear": "Adventuring gear",
|
||||
"magic-item": "Magic item", "consumable": "Consumable", "tool": "Tool", "treasure": "Treasure", "other": "Other"
|
||||
|
||||
@@ -3,6 +3,15 @@
|
||||
"link-expired": "This Foundry pairing code is invalid, expired, or already used.",
|
||||
"world-already-linked": "This Foundry world is already linked to another campaign.",
|
||||
"actor-already-synced": "Another actor in this campaign is already synced with that Foundry actor.",
|
||||
"item-already-synced": "Another item in this campaign is already synced with that Foundry item."
|
||||
"item-already-synced": "Another item in this campaign is already synced with that Foundry item.",
|
||||
"icons-unavailable": "Foundry's icons are not available: its bridge is not set up, or it cannot be reached right now.",
|
||||
"icons-no-world-url": "This campaign has no Foundry world address. Set it under campaign settings, in the Integrations tab."
|
||||
},
|
||||
"icons": {
|
||||
"path": "Icon folder",
|
||||
"up": "One folder up",
|
||||
"loading": "Loading icons...",
|
||||
"empty": "No icons to pick in this folder.",
|
||||
"load-more": "Load more icons"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,5 +10,7 @@
|
||||
"create-map": "Create Map",
|
||||
"map-viewer": "Map",
|
||||
"pinned-note": "Pinned note",
|
||||
"item-sheet": "Item"
|
||||
"item-sheet": "Item",
|
||||
"icon-source": "Choose an icon",
|
||||
"foundry-icons": "Foundry icons"
|
||||
}
|
||||
|
||||
@@ -73,6 +73,11 @@
|
||||
"foundry-icon": "Usar el icono de Foundry", "remove-icon": "Quitar el icono", "save-error": "No se pudo guardar este objeto.",
|
||||
"no-description": "Sin descripción añadida."
|
||||
},
|
||||
"icon-picker": {
|
||||
"intro": "¿De dónde debe salir el icono de este objeto?",
|
||||
"upload": "Subir icono", "upload-hint": "Elige una imagen de este dispositivo.",
|
||||
"foundry": "Cargar desde Foundry", "foundry-hint": "Recorre los iconos que incluye tu mundo de Foundry."
|
||||
},
|
||||
"categories": {
|
||||
"weapon": "Arma", "armor": "Armadura", "shield": "Escudo", "adventuring-gear": "Equipo de aventura",
|
||||
"magic-item": "Objeto mágico", "consumable": "Consumible", "tool": "Herramienta", "treasure": "Tesoro", "other": "Otro"
|
||||
|
||||
@@ -3,6 +3,15 @@
|
||||
"link-expired": "El código de vinculación de Foundry no es válido, ha caducado o ya se ha usado.",
|
||||
"world-already-linked": "Este mundo de Foundry ya está vinculado a otra campaña.",
|
||||
"actor-already-synced": "Otro actor de esta campaña ya está sincronizado con ese actor de Foundry.",
|
||||
"item-already-synced": "Otro objeto de esta campaña ya está sincronizado con ese objeto de Foundry."
|
||||
"item-already-synced": "Otro objeto de esta campaña ya está sincronizado con ese objeto de Foundry.",
|
||||
"icons-unavailable": "Los iconos de Foundry no están disponibles: su bridge no está configurado o no es accesible ahora.",
|
||||
"icons-no-world-url": "Esta campaña no tiene dirección del mundo de Foundry. Defínala en los ajustes de la campaña, en la pestaña de integraciones."
|
||||
},
|
||||
"icons": {
|
||||
"path": "Carpeta de iconos",
|
||||
"up": "Una carpeta arriba",
|
||||
"loading": "Cargando iconos...",
|
||||
"empty": "No hay iconos para elegir en esta carpeta.",
|
||||
"load-more": "Cargar más iconos"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,5 +10,7 @@
|
||||
"create-map": "Crear mapa",
|
||||
"map-viewer": "Mapa",
|
||||
"pinned-note": "Nota fijada",
|
||||
"item-sheet": "Objeto"
|
||||
"item-sheet": "Objeto",
|
||||
"icon-source": "Elegir icono",
|
||||
"foundry-icons": "Iconos de Foundry"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user