Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var COLD = COLD || {};
- (function(){
- COLD.BOOKS = {
- Book_Window : function(){this.initialize.apply(this, arguments);},
- Book_Scene : function(){this.initialize.apply(this, arguments);},
- Books : {
- DragonHistory:{
- title: 'History of Dragons',
- page1: 'This is page 1.',
- page2: 'This is page 2.'
- },
- ElfHistory:{
- title: 'History of Elfs',
- page1: '<wrap> Oh haaai... Latin text Qui '+
- 'id vide molestie, graeco evertitur conceptam at est. Te'+
- 'vis erant convenire, wisividisse expetendis mea ex, eos in dicant graeco.' +
- 'Eum eu novum decore, ei qui mundi labitur inciderint, eam ne partem nullam. Eam '+
- 'mutat aeque fabulas in. Quisconsequat cu est, soluta iriure no cum, ad pro feu'+
- 'giat perpetua. Id mel wisi ridensreprimique, no has adhuc affert.',
- page2: 'This is page 2.'
- }
- },
- PageOptionsText : {
- changePageText : "Change page with Left/Right buttons.",
- pageNumberText : "Page: "
- }
- };
- })();
- (function($){
- ($.prototype = Object.create(Window_Base.prototype)).constructor = $;
- $.prototype.initialize = function(x, y, bookname) {
- var width = this.windowWidth();
- var height = this.windowHeight();
- this._book = COLD.BOOKS.Books[bookname];
- this.page = 1;
- this.lastPage = 0;
- this.maxPages = Object.keys(this._book).length-1;
- Window_Base.prototype.initialize.call(this, x, y, width, height);
- };
- $.prototype.windowWidth = function(){
- return Graphics.width;
- };
- $.prototype.windowHeight = function(){
- return Graphics.height;
- };
- $.prototype.refresh = function() {
- if(this.page != this.lastPage){
- this.contents.clear();
- this.drawBookTitle();
- this.drawPageContents();
- this.drawBookBottom();
- this.lastPage = this.page;
- };
- };
- $.prototype.drawBookTitle = function(){
- this.drawText(this._book.title,0,0,this.windowWidth()-2 * this.standardPadding(),'center');
- this.drawHorzLine(this.lineHeight());
- };
- $.prototype.drawPageContents = function(){
- var page = 'page' + this.page;
- this.drawTextEx(this._book[page],0,this.lineHeight()+2*this.standardPadding())
- };
- $.prototype.drawBookBottom = function(){
- this.makeFontSmaller();
- var pad = 2 * this.standardPadding();
- this.drawText(COLD.BOOKS.PageOptionsText.changePageText,0,this.windowHeight()-this.lineHeight()- pad,this.windowWidth()-pad,'left');
- this.drawText(COLD.BOOKS.PageOptionsText.pageNumberText + this.page +'/'+ this.maxPages,0,this.windowHeight()-this.lineHeight()- pad,this.windowWidth()-pad,'right');
- this.drawHorzLine(this.windowHeight()-3 * this.lineHeight());
- this.makeFontBigger();
- };
- $.prototype.drawHorzLine = function(y) {
- var lineY = y + this.lineHeight() / 2 - 1;
- this.contents.paintOpacity = 48;
- this.contents.fillRect(0, lineY, this.contentsWidth(), 2, this.normalColor());
- this.contents.paintOpacity = 255;
- };
- $.prototype.update = function(){
- if(Input.isTriggered('right') && this.page < this.maxPages){
- this.page += 1;
- };
- if(Input.isTriggered('left') && this.page != 1){
- this.page -= 1;
- };
- this.refresh();
- };
- })(COLD.BOOKS.Book_Window);
- (function($){
- ($.prototype = Object.create(Scene_MenuBase.prototype)).constructor = $;
- $.prototype.initialize = function() {
- Scene_MenuBase.prototype.initialize.call(this);
- };
- $.prototype.create = function() {
- Scene_MenuBase.prototype.create.call(this);
- this.createWindow();
- };
- $.prototype.prepare = function(bookname){
- this._bookName = bookname;
- };
- $.prototype.createWindow = function() {
- this._BookWindow = new COLD.BOOKS.Book_Window(0,0, this._bookName);
- this.addWindow(this._BookWindow);
- };
- })(COLD.BOOKS.Book_Scene);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement