Darkmode not carried checkbox

This commit is contained in:
James Fleming
2022-07-27 09:00:09 -04:00
parent f12da8537f
commit bf8db20f88
2 changed files with 95 additions and 15 deletions
+54 -1
View File
@@ -94,13 +94,14 @@ body.sheet-darkmode .charsheet {
content: "y"
}
/* the weapon and spell selection button */
.sheet-select-button
{
font-family: "Pictos";
display: inline-block;
border-style: solid;
height: 1rem;
width: 0rem;
width: .1rem;
border-radius: .75rem;
border-width: 1px;
/*font-weight: bold;*/
@@ -108,6 +109,23 @@ body.sheet-darkmode .charsheet {
text-align: center;
}
/* our custom checkboxes */
.sheet-checkbox-button
{
font-family: "Pictos";
display: inline-block;
border-style: solid;
height: 1rem;
width: .03rem;
border-radius: .35rem;
border-width: 1px;
margin-left: .2rem;
align-self: center;
text-align: center;
font-size: smaller;
}
.sheet-attack-button {
display: inline-block;
border-style: solid;
@@ -147,15 +165,31 @@ body.sheet-darkmode .charsheet {
.sheet-expand-button,
.sheet-describe-button,
.sheet-select-button,
.sheet-checkbox-button,
.sheet-attack-button,
.sheet-dice-button {
background-color: #F9F9F9;
border-color: #BBBBBB;
}
/* A bit darker because checkboxes, not real buttons. */
.sheet-checkbox-button {
border-color: #767676;
}
/* a white check */
.sheet-checkbox-checkbox:checked + button::after {
color: white;
}
body.sheet-darkmode .sheet-checkbox-checkbox:checked + button::after {
color: black;
}
body.sheet-darkmode .sheet-expand-button,
body.sheet-darkmode .sheet-describe-button,
body.sheet-darkmode .sheet-select-button,
body.sheet-darkmode .sheet-checkbox-button,
body.sheet-darkmode .sheet-attack-button,
body.sheet-darkmode .sheet-dice-button {
background-color: #202020;
@@ -166,6 +200,7 @@ body.sheet-darkmode .sheet-dice-button {
.sheet-expand-button:hover,
.sheet-describe-button:hover,
.sheet-select-button:hover,
.sheet-checkbox-button:hover,
.sheet-attack-button:hover,
.sheet-dice-button:hover {
background-color: #EBEBEB;
@@ -174,6 +209,7 @@ body.sheet-darkmode .sheet-dice-button {
.sheet-expand-button:active,
.sheet-describe-button:active,
.sheet-select-button:active,
.sheet-checkbox-button:active,
.sheet-attack-button:active,
.sheet-dice-button:active {
background-color: #E1E1E1;
@@ -687,10 +723,27 @@ body.sheet-darkmode .charsheet .sheet-selected-tab {
background-color: #272730;
}
/* Make the button after the checked radio button be blue */
/* See we actually hide the checkbox, but make a button after it */
.charsheet .sheet-select-radio:checked + button {
background-color: blue;
}
.charsheet .sheet-checkbox-checkbox:checked + button {
background-color: #0060ff;
}
.charsheet .sheet-checkbox-checkbox:checked + button:hover {
background-color: blue;
}
.charsheet .sheet-checkbox-checkbox:checked + button::after {
/*content: "3"; 3 is check*/
content: "*"; /* x */
position: relative;
right: .4rem;
bottom: .4rem;
}
.charsheet .sheet-nowrap {
white-space : nowrap;
}
+41 -14
View File
@@ -267,7 +267,7 @@
<span style='width: 4rem;' title="Weapon or projectile weight per item.">Lbs</span>
<span style='position: relative;' title="Not carried, won't count as weight.">
<span style='position: absolute;'>NC</span>
<input type="checkbox" class=sheet-flex-checkbox style='visibility:hidden;'>
<button type="action" class=sheet-checkbox-button name="act_none" style='visibility:hidden;'>
</span>
&nbsp;
<button class=sheet-describe-button style='visibility:hidden' type="action"/>
@@ -283,7 +283,8 @@
<input type=text name=attr_weaponnotes class=sheet-flex>
<input type=number name=attr_count value="1" style='width: 5rem;'>
<input type=text name=attr_weight style='width: 4rem;'>
<input type="checkbox" name="attr_notcarried" value="1" class=sheet-flex-checkbox>
<input type="checkbox" name="attr_notcarried" class=sheet-checkbox-checkbox hidden>
<button type="action" class=sheet-checkbox-button name="act_check_notcarried" />
&nbsp;
<button class=sheet-describe-button title="Describe the weapon." type="action" name="act_describe"/>
<button class=sheet-expand-button title="Expand and edit more fields in the selected weapon." type="action" name="act_expand"/>
@@ -373,7 +374,7 @@
</span>
<span style='position: relative;' title="Not carried, won't count towards Weight, Hits Blocked, Minus to Hit, or DX penalty.">
<span style='position: absolute;'>NC</span>
<input type="checkbox" class=sheet-flex-checkbox style='visibility:hidden;'>
<button type="action" class=sheet-checkbox-button name="act_none" style='visibility:hidden;'>
</span>
&nbsp;
<button class=sheet-describe-button style='visibility:hidden' type="action"/>
@@ -388,7 +389,8 @@
<input type=text name=attr_defensenotes class=sheet-flex>
<input type=text name=attr_weight value="" style='width: 4rem;'>
<input type="checkbox" name="attr_nonflanking" value="1" class=sheet-flex-checkbox>
<input type="checkbox" name="attr_notcarried" value="1" class=sheet-flex-checkbox>
<input type="checkbox" name="attr_notcarried" class=sheet-checkbox-checkbox hidden>
<button type="action" class=sheet-checkbox-button name="act_check_notcarried" />
&nbsp;
<button class=sheet-describe-button title="Describe the Armor/Shield." type="action" name="act_describe"/>
<button class=sheet-expand-button title="Expand and edit more fields." type="action" name="act_expand"/>
@@ -408,7 +410,7 @@
<span style='width: 4rem;' title="Weight per item.">Lbs</span>
<span style='position: relative;' title="Not carried, won't count as weight.">
<span style='position: absolute;'>NC</span>
<input type="checkbox" class=sheet-flex-checkbox style='visibility:hidden;'>
<button type="action" class=sheet-checkbox-button name="act_none" style='visibility:hidden;'>
</span>
&nbsp;
<button class=sheet-describe-button style='visibility:hidden' type="action"/>
@@ -420,7 +422,8 @@
<input type=number name=attr_count value="1" style='width: 8rem;'>
<input type=text name=attr_notes class=sheet-flex>
<input type=text name=attr_weight value="" style='width: 4rem;'>
<input type=checkbox name=attr_notcarried value="1" class=sheet-flex-checkbox>
<input type="checkbox" name="attr_notcarried" class=sheet-checkbox-checkbox hidden>
<button type="action" class=sheet-checkbox-button name="act_check_notcarried" />
&nbsp;
<button class=sheet-describe-button title="Describe the Equipment." type="action" name="act_describe"/>
<button class=sheet-expand-button title="Expand and edit more fields." type="action" name="act_expand"/>
@@ -856,6 +859,10 @@
// Safe method to get a repeating property.
const getFloatProperty = function(v, repName, id, itemName) {
let property = repeatingPropertyName(repName, id, itemName);
if (v[property] == 'on')
{
return 1
}
let val = parseFloat(v[property]);
return isNaN(val) ? 0 : val;
}
@@ -1008,6 +1015,20 @@
});
}
// toggle this not carried. id starts with repeating_[weapon][spell] or any of them, really.
const toggleNotCarried = function(id) {
let selected = (id + "_notcarried").toLowerCase();
getAttrs([selected], function(values) {
let oldValue = values[selected];
let newValue = (oldValue == 'on' ? 0 : 'on');
let valueMap = {};
// toggle this one, turn off the rest.
valueMap[selected] = newValue;
// Can't be silent, has to tell them.
setAttrs(valueMap);
});
}
// select this weapon or spell, id starts with repeating_[weapon][spell]
const selectWeaponOrSpell = function(id) {
// get them all, and de check any not me...
@@ -1018,7 +1039,7 @@
let oldValue = values[selected];
let newValue = (oldValue == 'on' ? 0 : 'on');
let valueMap = {};
// toggle this one, turn off the rest.
// toggle this one, turn off the rest
valueMap[selected] = newValue;
// Radio button the rest.
@@ -1533,14 +1554,17 @@
});
});
// Weapons Select/Expand/Describe
// Weapons Select/Expand/Describe/NC
on('clicked:repeating_weapons', (info) => {
let name = info.htmlAttributes.name;
let id = info.sourceAttribute;
if (name == 'act_select') {
selectWeaponOrSpell(id);
}
if (name == 'act_describe') {
else if (name == 'act_check_notcarried') {
toggleNotCarried(id);
}
else if (name == 'act_describe') {
describeItem(id + '_weaponname', id + '_description',
['To Hit', id + '_tohit'
, 'Damage', id + '_weapondamage'
@@ -1588,11 +1612,13 @@
});
/* Armor Handlers */
// Expand or describe a talent.
// Armor expand/describe/notcarried
on('clicked:repeating_armor', (info) => {
let id = info.sourceAttribute;
let name = info.htmlAttributes.name;
if (name == 'act_describe') {
if (name == 'act_check_notcarried') {
toggleNotCarried(id);
} else if (name == 'act_describe') {
describeItem(id + '_defensename', id + '_description',
['Hits Blocked', id + '_hitsblocked',
'Minus to Hit', id + '_minustohit',
@@ -1607,11 +1633,13 @@
});
/* Equipment Handlers */
// Expand or describe a talent.
// Expand/Describe/NotCarried a talent.
on('clicked:repeating_equipment', (info) => {
let id = info.sourceAttribute;
let name = info.htmlAttributes.name;
if (name == 'act_describe') {
if (name == 'act_check_notcarried') {
toggleNotCarried(id);
} else if (name == 'act_describe') {
describeItem(id + '_name', id + '_description',
['Count', id + '_count',
'Weight', id + '_weight',
@@ -1680,7 +1708,6 @@
getSectionIDs("armor", function(v) {grabIds(v, 'armor', 'minustohit', '', 'notcarried', 'nonflanking', idCallback);});
});
on('sheet:opened change:st change:hits change:fatigue', function() {
getAttrs(['st', 'hits', 'fatigue'], function(v) {
let hitpoints = v.st - v.hits - v.fatigue;