Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta Fix - send to game log not appearing if just the content is changing #1561

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions CharactersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,14 @@ function observe_character_sheet_changes(documentToObserve) {

if (mutationTarget.closest(".ct-game-log-pane").length == 0 && mutationTarget.find(".ct-sidebar__header").length > 0 && mutationTarget.find(".ddbc-html-content").length > 0 && mutationTarget.find("#castbutton").length == 0) {
// we explicitly don't want this to happen in `.ct-game-log-pane` because otherwise it will happen to the injected gamelog messages that we're trying to send here
if(is_abovevtt_page() || window.sendToTab != undefined)
inject_sidebar_send_to_gamelog_button(mutationTarget.find('.ct-sidebar__pane-content>div:last-of-type'));
if(is_abovevtt_page() || window.sendToTab != undefined){
if(mutationTarget.hasClass('ct-sidebar__pane-content')){
inject_sidebar_send_to_gamelog_button(mutationTarget.children('div:last-of-type'));
}else{
inject_sidebar_send_to_gamelog_button(mutationTarget.find('.ct-sidebar__pane-content>div:last-of-type'));
}

}
}


Expand Down
91 changes: 0 additions & 91 deletions Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2033,98 +2033,7 @@ function monitor_character_sidebar_changes() {
});
}

//
/**
* Add inject button into sidebar.
*
* When the user clicks on an item in a character sheet, the details are shown in a sidebar.
* This will inject a "send to gamelog" button and properly send the pertinent sidebar content to the gamelog.
* @param {DOMObject} sidebarPaneContent
*/
function inject_sidebar_send_to_gamelog_button(sidebarPaneContent) {
// we explicitly don't want this to happen in `.ct-game-log-pane` because otherwise it will happen to the injected gamelog messages that we're trying to send here
console.log("inject_sidebar_send_to_gamelog_button")
let button = $(`<button id='castbutton'">SEND TO GAMELOG</button>`);
// button.css({
// "margin": "10px 0px",
// "border": "1px solid #bfccd6",
// "border-radius": "4px",
// "background-color": "transparent",
// "color": "#394b59"
// });
button.css({
"display": "flex",
"flex-wrap": "wrap",
"font-family": "Roboto Condensed,Roboto,Helvetica,sans-serif",
"cursor": "pointer",
"color": "#838383",
"line-height": "1",
"font-weight":" 700",
"font-size": "12px",
"text-transform": "uppercase",
"background-color": "#f2f2f2",
"margin": "3px 2px",
"border-radius": "3px",
"padding": "5px 7px",
"white-space": "nowrap"
})
$(button).hover(
function () {
button.css({
"background-color": "#5d5d5d",
"color": "#f2f2f2"
})
},
function () {
button.css({
"background-color": "#f2f2f2",
"color": "#5d5d5d"
})
}
);

sidebarPaneContent.prepend(button);
button.click(function() {
// make sure the button grabs dynamically. Don't hold HTML in the button click block because clicking on items back to back will fuck that up

let sidebar = sidebarPaneContent.closest(".ct-sidebar__portal");
let toInject = $(`<div></div>`);
toInject.attr("class", sidebarPaneContent.attr("class")); // set the class on our new element
// required
toInject.append(sidebar.find(".ct-sidebar__header").clone());

// these are optional, but if they're here, grab them
toInject.append(sidebarPaneContent.find(".ddbc-property-list").clone());
toInject.append(sidebarPaneContent.find(".ct-spell-detail__level-school").clone());
toInject.append(sidebarPaneContent.find(".ct-speed-manage-pane__speeds").clone());
toInject.append(sidebarPaneContent.find(".ct-armor-manage-pane__items").clone());

if (sidebarPaneContent.find(".ct-creature-pane__block").length > 0) {
// extras tab creatures need a little extra love
toInject.append(sidebarPaneContent.find(".ct-creature-pane__block").clone());
toInject.append(sidebarPaneContent.find(".ct-creature-pane__full-image").clone());
toInject.find(".ct-sidebar__header").css({
"margin-left": "20px",
"margin-right": "20px"
});
} else {
// required... unless it's an extras tab creature
toInject.append(sidebar.find(".ddbc-html-content").clone());
}

// now clean up any edit elements
toInject.find(".ct-container-pane__pencil").remove();

let html = window.MB.encode_message_text(toInject[0].outerHTML);
data = {
player: window.PLAYER_NAME,
img: window.PLAYER_IMG,
text: html
};
window.MB.inject_chat(data);
notify_gamelog();
});
}

/**
* Add Dice buttons into sidebar.
Expand Down