Skip to content

Commit

Permalink
cleanup before push
Browse files Browse the repository at this point in the history
  • Loading branch information
Norc committed Jul 30, 2020
1 parent 38a6d54 commit dde4866
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
4 changes: 2 additions & 2 deletions css/card-hotbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@
border-radius: px;
max-width: 100%;
}
/*

#card-hotbar .macro.inactive {
display: none;
}
*/

#card-hotbar .macro:hover {
box-shadow: 0 0 10px #ff6400 inset;
}
Expand Down
56 changes: 34 additions & 22 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,33 @@ async function cardHotbarInit() {
Hooks.callAll("cardHotbarReady");
}

async function classifyCards () {
//mark the first inactive macro as "next" for CSS styling and button changing
let cardHand = ui.cardHotbar.macros;
console.debug("Card Hotbar | cardHand defined?");
console.debug(cardHand);
for (var i = 0; i < cardHand.length; ++i) {
console.debug(i);
/*not functional yet
//Math.min(i+1,cardHand.length) && cardHand[i+1].cssClass.includes("inactive") )
if( cardHand[i].cssClass.includes("active") ) {
if( cardHand[i].cssClass.includes("next") ) {
console.log("Card Hotbar | Cleaning up recently filled card slot...");
//change button
cardHand[1].cssClass.replace("next", "");
}
}
*/
if( cardHand[i].cssClass.includes("inactive") ) {
//change button
console.log("Card Hotbar | Marking first inactive card slot as next...");
cardHand[i].cssClass = cardHand[i].cssClass.replace("inactive","") + " next";
console.debug(cardHand[i].cssClass);
return;
}
}
}

Hooks.on("init", async () => {
CONFIG.ui.hotbar = class extends Hotbar {
_onDragStart(...arg) {
Expand Down Expand Up @@ -140,30 +167,15 @@ Hooks.on('ready', () => {

Hooks.on('cardHotbarReady', async () => {
console.debug("Card Hotbar | Card Hotbar ready, performing final cleanup...");
//mark the first inactive macro as "next" for CSS styling and button changing
let cardHand = ui.cardHotbar.macros;
console.debug("Card Hotbar | cardHand defined?");
console.debug(cardHand);
for (var i = 0; i < cardHand.length; ++i) {
console.debug(i);
//Math.min(i+1,cardHand.length) && cardHand[i+1].cssClass.includes("inactive") )
if( cardHand[i].cssClass.includes("active") ) {
if( cardHand[i].cssClass.includes("next") ) {
console.log("Card Hotbar | Cleaning up recently filled card slot...");
//change button
cardHand[1].cssClass.replace("next", "");
}
}
if( cardHand[i].cssClass.includes("inactive") ) {
//change button
console.log("Card Hotbar | Marking first inactive card slot as next...");
cardHand[i].cssClass = cardHand[i].cssClass.replace("inactive","") + " next";
return;
}
}

classifyCards();
});

Hooks.on('rendercardHotbar', async () => {
console.debug("Card Hotbar | Reclassifying Card Hotbar macros...");
//overwritten by normal logic still
//squash a few random undefined errors
classifyCards();
});


Hooks.on("renderSettingsConfig", async () => {
Expand Down

0 comments on commit dde4866

Please sign in to comment.