Skip to content

Commit fb2915d

Browse files
committed
chore: added buttons next to clock, refactor, inc/dec buttons
1 parent 09832ba commit fb2915d

File tree

5 files changed

+88
-57
lines changed

5 files changed

+88
-57
lines changed

module/sheets/actor-standard-sheet.mjs

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,6 @@ export class FUStandardActorSheet extends ActorSheet {
775775
// console.log('All equipped items have been set to unequip.');
776776
} else {
777777
// Checkbox is checked
778-
// console.log('Checkbox is checked');
779778
}
780779
}
781780

@@ -802,7 +801,7 @@ export class FUStandardActorSheet extends ActorSheet {
802801
const duplicatedItemData = foundry.utils.duplicate(item);
803802

804803
// Modify the duplicated item's name
805-
duplicatedItemData.name = `Copy of ${item.name}`;
804+
duplicatedItemData.name = `${item.name}`;
806805
duplicatedItemData.system.isEquipped = {
807806
value: false,
808807
slot: 'default',
@@ -1085,43 +1084,19 @@ export class FUStandardActorSheet extends ActorSheet {
10851084
if (item) {
10861085
switch (dataType) {
10871086
case 'levelCounter':
1088-
// Increment or decrement the level value
1089-
const newLevel = item.system.level.value + increment;
1090-
// Update the item with the new level value
1091-
await item.update({ 'system.level.value': newLevel });
1087+
await this._updateLevel(item, increment);
10921088
break;
10931089

10941090
case 'resourceCounter':
1095-
// Increment or decrement the rp progress current value
1096-
const stepMultiplier = item.system.rp.step || 1;
1097-
const maxProgress = item.system.rp.max;
1098-
let newProgress = item.system.rp.current + increment * stepMultiplier;
1099-
1100-
// Check if newProgress exceeds rp.max unless rp.max is 0
1101-
if (maxProgress !== 0) {
1102-
newProgress = Math.min(newProgress, maxProgress);
1103-
}
1104-
1105-
// Update the item with the new rp progress value
1106-
await item.update({ 'system.rp.current': newProgress });
1091+
await this._updateResourceProgress(item, increment);
11071092
break;
11081093

11091094
case 'clockCounter':
1095+
await this._updateClockProgress(item, increment);
11101096
break;
11111097

11121098
case 'projectCounter':
1113-
// Increment or decrement the rp progress current value
1114-
const progressPerDay = item.system.progressPerDay.value || 1;
1115-
const maxProjectProgress = item.system.progress.max;
1116-
let currentProgress = item.system.progress.current + increment * progressPerDay;
1117-
1118-
// Check if currentProgress exceeds progress.max unless progress.max is 0
1119-
if (maxProjectProgress !== 0) {
1120-
currentProgress = Math.min(currentProgress, maxProjectProgress);
1121-
}
1122-
1123-
// Update the item with the new progress value
1124-
await item.update({ 'system.progress.current': currentProgress });
1099+
await this._updateProjectProgress(item, increment);
11251100
break;
11261101

11271102
default:
@@ -1137,6 +1112,47 @@ export class FUStandardActorSheet extends ActorSheet {
11371112
}
11381113
}
11391114

1115+
async _updateLevel(item, increment) {
1116+
const newLevel = item.system.level.value + increment;
1117+
await item.update({ 'system.level.value': newLevel });
1118+
}
1119+
1120+
async _updateResourceProgress(item, increment) {
1121+
const stepMultiplier = item.system.rp.step || 1;
1122+
const maxProgress = item.system.rp.max;
1123+
let newProgress = item.system.rp.current + increment * stepMultiplier;
1124+
1125+
if (maxProgress !== 0) {
1126+
newProgress = Math.min(newProgress, maxProgress);
1127+
}
1128+
1129+
await item.update({ 'system.rp.current': newProgress });
1130+
}
1131+
1132+
async _updateClockProgress(item, increment) {
1133+
const stepMultiplier = item.system.progress.step || 1;
1134+
const maxProgress = item.system.progress.max;
1135+
let newProgress = item.system.progress.current + increment * stepMultiplier;
1136+
1137+
if (maxProgress !== 0) {
1138+
newProgress = Math.min(newProgress, maxProgress);
1139+
}
1140+
1141+
await item.update({ 'system.progress.current': newProgress });
1142+
}
1143+
1144+
async _updateProjectProgress(item, increment) {
1145+
const progressPerDay = item.system.progressPerDay.value || 1;
1146+
const maxProjectProgress = item.system.progress.max;
1147+
let currentProgress = item.system.progress.current + increment * progressPerDay;
1148+
1149+
if (maxProjectProgress !== 0) {
1150+
currentProgress = Math.min(currentProgress, maxProjectProgress);
1151+
}
1152+
1153+
await item.update({ 'system.progress.current': currentProgress });
1154+
}
1155+
11401156
/**
11411157
* Handles increment button click events for both level and resource progress.
11421158
* @param {Event} ev - The button click event.

styles/css/projectfu.css

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

styles/scss/components/_buttons.scss

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@
9797
background-color: transparent;
9898
color: $color-white;
9999
}
100+
101+
&#behavior-action {
102+
padding: 5px;
103+
font-size: 17px;
104+
}
100105
}
101106

102107
.zenit-style,
@@ -109,7 +114,8 @@
109114
transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
110115
background-image: linear-gradient($color-tabStyle-gradient);
111116

112-
input,select,
117+
input,
118+
select,
113119
.zenit-text,
114120
.study-text {
115121
font-size: 16px;
@@ -162,7 +168,7 @@
162168
border-radius: 8px;
163169
box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
164170
transform: translateY(1px);
165-
}
171+
}
166172

167173
&:hover {
168174
transform: translateY(-1px);

templates/actor/partials/actor-actions.hbs

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,72 +6,71 @@
66
{{#if (eq actor.type "character")}}
77
<div class="action-container grid grid-2col gap-5">
88

9-
<span class="action-button left-hand rollable" id="guardAction" data-action="guardAction"
10-
data-roll-type="action-type" data-tooltip="{{localize 'FU.GuardRule'}}">
9+
<span class="action-button rollable" id="guardAction" data-action="guardAction" data-roll-type="action-type"
10+
data-tooltip="{{localize 'FU.GuardRule'}}">
1111
<span class="icon-letter">{{localize 'FU.ActionAbbr'}}</span>{{localize "FU.Guard"}}
1212
</span>
1313

14-
<span class="action-button left-hand rollable " id="equipmentAction" data-action="equipmentAction"
14+
<span class="action-button rollable " id="equipmentAction" data-action="equipmentAction"
1515
data-roll-type="action-type" data-tooltip="{{localize 'FU.EquipmentRule'}}">
1616
<span class="icon-letter">{{localize 'FU.ActionAbbr'}}</span>{{localize "FU.Equipment"}}
1717
</span>
1818

19-
<span class="action-button left-hand rollable " id="hinderAction" data-action="hinderAction"
20-
data-roll-type="action-type" data-tooltip="{{localize 'FU.HinderRule'}}">
19+
<span class="action-button rollable " id="hinderAction" data-action="hinderAction" data-roll-type="action-type"
20+
data-tooltip="{{localize 'FU.HinderRule'}}">
2121
<span class="icon-letter">{{localize 'FU.ActionAbbr'}}</span>{{localize "FU.Hinder"}}
2222
</span>
2323

24-
<span class="action-button left-hand rollable" id="inventoryAction" data-action="inventoryAction"
24+
<span class="action-button rollable" id="inventoryAction" data-action="inventoryAction"
2525
data-roll-type="action-type" data-tooltip="{{localize 'FU.InventoryRule'}}">
2626
<span class="icon-letter">{{localize 'FU.ActionAbbr'}}</span>{{localize "FU.Inventory"}}
2727
</span>
2828

29-
<span class="action-button left-hand rollable " id="objectiveAction" data-action="objectiveAction"
29+
<span class="action-button rollable " id="objectiveAction" data-action="objectiveAction"
3030
data-roll-type="action-type" data-tooltip="{{localize 'FU.ObjectiveRule'}}">
3131
<span class="icon-letter">{{localize 'FU.ActionAbbr'}}</span>{{localize "FU.Objective"}}
3232
</span>
3333

34-
<span class="action-button left-hand rollable" id="spellAction" data-action="spellAction"
35-
data-roll-type="action-type" data-tooltip="{{localize 'FU.SpellRule'}}">
34+
<span class="action-button rollable" id="spellAction" data-action="spellAction" data-roll-type="action-type"
35+
data-tooltip="{{localize 'FU.SpellRule'}}">
3636
<span class="icon-letter">{{localize 'FU.ActionAbbr'}}</span>{{localize "FU.Spell"}}
3737
</span>
3838

39-
<span class="action-button left-hand rollable " id="studyAction" data-action="studyAction"
40-
data-roll-type="action-type" data-tooltip="{{localize 'FU.StudyRule'}}">
39+
<span class="action-button rollable " id="studyAction" data-action="studyAction" data-roll-type="action-type"
40+
data-tooltip="{{localize 'FU.StudyRule'}}">
4141
<span class="icon-letter">{{localize 'FU.ActionAbbr'}}</span>{{localize "FU.Study"}}
4242
</span>
4343

44-
<span class="action-button left-hand rollable" id="skillAction" data-action="skillAction"
45-
data-roll-type="action-type" data-tooltip="{{localize 'FU.SkillRule'}}">
44+
<span class="action-button rollable" id="skillAction" data-action="skillAction" data-roll-type="action-type"
45+
data-tooltip="{{localize 'FU.SkillRule'}}">
4646
<span class="icon-letter">{{localize 'FU.ActionAbbr'}}</span>{{localize "FU.Skill"}}
4747
</span>
4848
</div>
4949
{{/if}}
5050
<div class="action-container grid grid-2col gap-5">
5151
{{#if (eq @root.actor.type "npc")}}
52-
<span class="action-button left-hand rollable" id="guardAction" data-action="guardAction"
53-
data-roll-type="action-type" data-tooltip="{{localize 'FU.GuardRule'}}">
52+
<span class="action-button rollable" id="guardAction" data-action="guardAction" data-roll-type="action-type"
53+
data-tooltip="{{localize 'FU.GuardRule'}}">
5454
<span class="icon-letter">{{localize 'FU.ActionAbbr'}}</span>{{localize "FU.Guard"}}
5555
</span>
5656

57-
<span class="action-button left-hand rollable " id="hinderAction" data-action="hinderAction"
58-
data-roll-type="action-type" data-tooltip="{{localize 'FU.HinderRule'}}">
57+
<span class="action-button rollable " id="hinderAction" data-action="hinderAction" data-roll-type="action-type"
58+
data-tooltip="{{localize 'FU.HinderRule'}}">
5959
<span class="icon-letter">{{localize 'FU.ActionAbbr'}}</span>{{localize "FU.Hinder"}}
6060
</span>
6161

62-
<span class="action-button left-hand rollable " id="objectiveAction" data-action="objectiveAction"
62+
<span class="action-button rollable " id="objectiveAction" data-action="objectiveAction"
6363
data-roll-type="action-type" data-tooltip="{{localize 'FU.ObjectiveRule'}}">
6464
<span class="icon-letter">{{localize 'FU.ActionAbbr'}}</span>{{localize "FU.Objective"}}
6565
</span>
6666

67-
<span class="action-button left-hand rollable" id="skillAction" data-action="skillAction"
68-
data-roll-type="action-type" data-tooltip="{{localize 'FU.SkillRule'}}">
67+
<span class="action-button rollable" id="skillAction" data-action="skillAction" data-roll-type="action-type"
68+
data-tooltip="{{localize 'FU.SkillRule'}}">
6969
<span class="icon-letter">{{localize 'FU.ActionAbbr'}}</span>{{localize "FU.Skill"}}
7070
</span>
7171

7272
{{#if (eq (getGameSetting 'optionBehaviorRoll') true)}}
73-
<span class="action-button spin2win left-hand rollable grid-span-2" data-roll-type="behavior"
74-
style="padding: 5px; font-size: 17px;">
73+
<span id="behavior-action" class="action-button spin2win rollable grid-span-2" data-roll-type="behavior">
7574
<i class="fas fa-dice-d20 ra-1x icon"></i>
7675
<label class="items-label">{{ localize "FU.Behavior" }}</label>
7776
</span>

templates/actor/partials/actor-clocks.hbs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,17 @@
1515
{{ item.name }}
1616
</span>
1717
</h4>
18-
<div class="item-sm" style="text-align: initial;">
18+
<div class="item-sm buttons-inc gap-2" style="text-align: initial;">
19+
<a class="decrement-button align-center" data-type="clockCounter" data-item-id="{{ item._id }}"> <i
20+
class="fa-solid fa-minus"></i></a>
1921
<div class="progress-container">
22+
2023
{{> "systems/projectfu/templates/actor/partials/actor-progress-clock-xl.hbs"
2124
arr=item.progressArr
2225
data=item.system.progress}}
2326
</div>
27+
<a class="increment-button align-center" data-type="clockCounter" data-item-id="{{ item._id }}">
28+
<i class="fa-solid fa-plus"></i></a>
2429
</div>
2530
</li>
2631
{{/if}}

0 commit comments

Comments
 (0)