Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ============================================================================
- // TimeFantasyScreenSize.js
- // ============================================================================
- // eslint-disable-next-line spaced-comment
- /*:
- * @plugindesc Changes the menu size to allow for TimeFantasy sprites and
- * tilesets whithout clashing too much with menus and other stuff.
- * As an effect the menu will drawn on a smaller surface (with it size defined
- * by this plugin) and rescaled to the actual screen size to make it appear more
- * block/pixelated.
- * Warning: This plugin is not finished! It only works in canvas mode and it
- * does not work with mouse/touch input.
- * <TimeFantasyScreenSize>
- * @author psuessenb
- *
- * @param menuWidth
- * @text Original menu width in pixels
- * @type number
- * @default 816
- *
- * @param menuHeight
- * @text Original menu height in pixels
- * @type number
- * @default 624
- *
- * @help This plugin does not provide plugin commands.
- *
- */
- // eslint-disable-next-line no-var
- var TimeFantasyScreenSize = TimeFantasyScreenSize || {};
- (($) => {
- 'use strict';
- const params = $plugins.filter((p) => {
- return p.description.contains('<TimeFantasyScreenSize>');
- })[0].parameters;
- const menuWidth = params['menuWidth'];
- const menuHeight = params['menuHeight'];
- Scene_Base.prototype.createWindowLayer = function() {
- this._windowLayer = new WindowLayer();
- this._windowLayer.move(0, 0, menuWidth, menuHeight);
- this.addChild(this._windowLayer);
- };
- // Scene_MenuBase
- (($) => {
- let origBoxHeight = 0;
- let origBoxWidth = 0;
- const aliasCreate = $.prototype.create;
- $.prototype.create = function() {
- origBoxHeight = Graphics.boxHeight;
- origBoxWidth = Graphics.boxWidth;
- Graphics.boxHeight = menuHeight;
- Graphics.boxWidth = menuWidth;
- aliasCreate.call(this);
- };
- const aliasTerminate = $.prototype.terminate;
- $.prototype.terminate = function() {
- aliasTerminate.call(this);
- Graphics.boxWidth = origBoxWidth;
- Graphics.boxHeight = origBoxHeight;
- };
- })(Scene_MenuBase);
- // Window_TitleCommand
- (($) => {
- const aliasUpdatePlacement = $.prototype.updatePlacement;
- $.prototype.updatePlacement = function() {
- const origBoxHeight = Graphics.boxHeight;
- const origBoxWidth = Graphics.boxWidth;
- Graphics.boxHeight = menuHeight;
- Graphics.boxWidth = menuWidth;
- aliasUpdatePlacement.call(this);
- Graphics.boxHeight = origBoxHeight;
- Graphics.boxWidth = origBoxWidth;
- };
- })(Window_TitleCommand);
- // WindowLayer
- (($) => {
- let _widthRatio;
- let _heightRatio;
- function calcWidthRatio() {
- return _widthRatio || Graphics.width / menuWidth;
- }
- function calcHeightRatio() {
- return _heightRatio || Graphics.height / menuHeight;
- }
- $.prototype.renderCanvas = function(renderer) {
- if (!this.visible || !this.renderable) {
- return;
- }
- if (!this._tempCanvas) {
- this._tempCanvas = document.createElement('canvas');
- }
- this._tempCanvas.width = menuWidth;
- this._tempCanvas.height = menuHeight;
- const realCanvasContext = renderer.context;
- const context = this._tempCanvas.getContext('2d');
- context.save();
- context.clearRect(0, 0, Graphics.width, Graphics.height);
- context.beginPath();
- context.rect(this.x, this.y, this.width, this.height);
- context.closePath();
- context.clip();
- renderer.context = context;
- for (let i = 0; i < this.children.length; i++) {
- const child = this.children[i];
- if (child._isWindow && child.visible && child.openness > 0) {
- this._canvasClearWindowRect(renderer, child);
- context.save();
- child.renderCanvas(renderer);
- context.restore();
- }
- }
- context.restore();
- renderer.context = realCanvasContext;
- renderer.context.setTransform(calcWidthRatio(), 0, 0, calcHeightRatio(),
- 0, 0);
- renderer.context.globalCompositeOperation = 'source-over';
- renderer.context.globalAlpha = 1;
- renderer.context.drawImage(this._tempCanvas, 0, 0);
- for (let j = 0; j < this.children.length; j++) {
- if (!this.children[j]._isWindow) {
- this.children[j].renderCanvas(renderer);
- }
- }
- };
- })(WindowLayer);
- })(TimeFantasyScreenSize);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement