Skip to content

Commit

Permalink
Merge pull request #2893 from Hoppyhob/3.0.x_2869
Browse files Browse the repository at this point in the history
[#2869] Added Limited Sheets, Partial sheets, and Modified logic in character sheet 2 if permission is limited
  • Loading branch information
arbron authored Feb 13, 2024
2 parents af52d27 + 9f1d1b6 commit fadc6b7
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 17 deletions.
69 changes: 56 additions & 13 deletions less/v2/character.less
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@
}
}

/* Name */
.document-name {
color: var(--color-text-light-0);
font-size: var(--font-size-46);
text-shadow: 2px 2px 2px var(--color-shadow-dark);
font-family: var(--dnd5e-font-modesto);
font-weight: bold;
letter-spacing: 2px;
padding: 0;
margin: 0;
transition: font-size 250ms ease;
}

/* Name & Class */
> .left {
Expand All @@ -119,19 +131,6 @@
.document-name { font-size: var(--font-size-36); }
}

/* Name */
.document-name {
color: var(--color-text-light-0);
font-size: var(--font-size-46);
text-shadow: 2px 2px 2px var(--color-shadow-dark);
font-family: var(--dnd5e-font-modesto);
font-weight: bold;
letter-spacing: 2px;
padding: 0;
margin: 0;
transition: font-size 250ms ease;
}

input.document-name {
padding: .3125rem .75rem;
border-radius: 6px;
Expand Down Expand Up @@ -1566,6 +1565,50 @@
.ability-scores { left: 0; }
}

/* ---------------------------------- */
/* Limited Sheets */
/* ---------------------------------- */

&.limited {
min-width: 600px;
min-height: 600px;

.sheet-header {
display: flex;
gap: 1.5rem;
padding: 1rem 1.5rem;

> * { flex: unset; }

.portrait {
width: 128px;
height: 128px;
border-radius: 100%;
border: 4px solid var(--dnd5e-color-gold);
box-shadow: 0 0 6px var(--dnd5e-color-black);
overflow: hidden;

> img {
border: none;
width: 100%;
height: 100%;
object-fit: cover;
object-position: top;
background-color: var(--dnd5e-color-light-gray);
margin: 0;
}
}
}

.tab.biography > .bottom {
padding: .5rem .5rem 1.5rem;
.editor { min-height: unset; }
}

.main-content { display: unset; }
.sheet-body .tab-body .tab:not(.details) { padding: 0; }
}

/* ---------------------------------- */
/* Edit Mode */
/* ---------------------------------- */
Expand Down
16 changes: 12 additions & 4 deletions module/applications/actor/character-sheet-2.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import ActorSheet5eCharacter from "./character-sheet.mjs";
*/
export default class ActorSheet5eCharacter2 extends ActorSheet5eCharacter {
constructor(object, options={}) {
const { width, height } = game.user.getFlag("dnd5e", "sheetPrefs.character") ?? {};
const key = `character${object.limited ? ":limited" : ""}`;
const { width, height } = game.user.getFlag("dnd5e", `sheetPrefs.${key}`) ?? {};
if ( width && !("width" in options) ) options.width = width;
if ( height && !("height" in options) ) options.height = height;
super(object, options);
Expand Down Expand Up @@ -95,6 +96,7 @@ export default class ActorSheet5eCharacter2 extends ActorSheet5eCharacter {

/** @override */
get template() {
if ( !game.user.isGM && this.actor.limited ) return "systems/dnd5e/templates/actors/limited-sheet-2.hbs";
return "systems/dnd5e/templates/actors/character-sheet-2.hbs";
}

Expand Down Expand Up @@ -131,6 +133,11 @@ export default class ActorSheet5eCharacter2 extends ActorSheet5eCharacter {
firstButton?.insertAdjacentElement("beforebegin", idLink);
}

if ( !game.user.isGM && this.actor.limited ) {
html[0].classList.add("limited");
return html;
}

// Render tabs.
const nav = document.createElement("nav");
nav.classList.add("tabs");
Expand All @@ -149,7 +156,7 @@ export default class ActorSheet5eCharacter2 extends ActorSheet5eCharacter {
html[0].insertAdjacentElement("afterbegin", nav);
this._tabs = this.options.tabs.map(t => {
t.callback = this._onChangeTab.bind(this);
if (this._tabs?.[0]?.active !== t.initial) t.initial = this._tabs?.[0]?.active ?? t.initial;
if ( this._tabs?.[0]?.active !== t.initial ) t.initial = this._tabs?.[0]?.active ?? t.initial;
return new Tabs5e(t);
});

Expand All @@ -176,7 +183,7 @@ export default class ActorSheet5eCharacter2 extends ActorSheet5eCharacter {
const context = await super.getData(options);
context.editable = this.isEditable && (this._mode === this.constructor.MODES.EDIT);
context.cssClass = context.editable ? "editable" : this.isEditable ? "interactable" : "locked";
const activeTab = this._tabs?.[0]?.active ?? "details";
const activeTab = (game.user.isGM || !this.actor.limited) ? this._tabs?.[0]?.active ?? "details" : "biography";
context.cssClass += ` tab-${activeTab}`;
const sidebarCollapsed = game.user.getFlag("dnd5e", `sheetPrefs.character.tabs.${activeTab}.collapseSidebar`);
if ( sidebarCollapsed ) {
Expand Down Expand Up @@ -1003,7 +1010,8 @@ export default class ActorSheet5eCharacter2 extends ActorSheet5eCharacter {
_onResize(event) {
super._onResize(event);
const { width, height } = this.position;
game.user.setFlag("dnd5e", "sheetPrefs.character", { width, height });
const key = `character${this.actor.limited ? ":limited": ""}`;
game.user.setFlag("dnd5e", `sheetPrefs.${key}`, { width, height });
}

/* -------------------------------------------- */
Expand Down
48 changes: 48 additions & 0 deletions templates/actors/limited-sheet-2.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<form class="{{ cssClass }} flexcol" autocomplete="off">

{{!-- Header --}}
<header class="sheet-header">

{{!-- Portrait --}}
<div class="portrait {{#if portrait.token}}token{{/if}}">
<img src="{{ portrait.src }}" alt="{{ actor.name }}">
</div>

{{!-- Name --}}
<div class="document-name">{{ actor.name }}</div>

</header>

{{!-- Body --}}
<section class="sheet-body">

{{!-- Main Content --}}
<div class="main-content">

{{!-- Tabbed Content --}}
<section class="tab-body">

{{!-- Biography --}}
<div class="tab biography active" data-group="primary" data-tab="biography">

{{!-- Biography --}}
<div class="bottom">
<h3 class="icon">
<i class="fas fa-feather"></i>
<dnd5e-icon src="systems/dnd5e/icons/svg/ink-pot.svg"></dnd5e-icon>
<span class="roboto-upper">{{ localize "DND5E.Biography" }}</span>
</h3>
{{ editor biographyHTML target="system.details.biography.value" button=false
editable=@root.editable engine="prosemirror" collaborate=false }}
engine="prosemirror" collaborate=false }}
</div>

</div>

</section>

</div>

</section>

</form>

0 comments on commit fadc6b7

Please sign in to comment.