Skip to content

Commit

Permalink
Adding button to the book
Browse files Browse the repository at this point in the history
  • Loading branch information
bobvoorneveld committed Feb 7, 2022
1 parent 44c2372 commit 3cb3b57
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion js/koi/gui/cards/cardBook.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ const CardBook = function(width, height, cards, audio, onUnlock) {

this.element.appendChild(this.buttonPageLeft.element);
this.element.appendChild(this.buttonPageRight.element);

if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.loadImage) {
this.element.appendChild(this.createLoadImageElement(audio));
}
this.fit();
this.setButtonLockedStatus();
};
Expand All @@ -43,6 +45,7 @@ CardBook.prototype.PADDING_PAGE = .02;
CardBook.prototype.PADDING_CARD = .035;
CardBook.prototype.HEIGHT = .65;
CardBook.prototype.PAGE_COUNT = CardRequirements.length;
CodeViewer.prototype.LANG_SAVE = "LOAD_IMAGE"; // TODO, what loading text?

/**
* A page flip action
Expand Down Expand Up @@ -488,3 +491,25 @@ CardBook.prototype.resize = function(width, height) {

this.fit();
};

/**
* Creates the load Koi Code image button
* @param {AudioBank} audio Game audio
* @returns {HTMLButtonElement} The download button
*
* TODO: needs styling and positioning.
*/
CardBook.prototype.createLoadImageElement = function(audio) {
const button = document.createElement("button");

button.appendChild(document.createTextNode(language.get(this.LANG_LOAD)));
button.onclick = () => {
audio.effectClick.play();

if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.loadImage) {
window.webkit.messageHandlers.loadImage.postMessage(null);
}
this.hide();
};
return button;
};

0 comments on commit 3cb3b57

Please sign in to comment.