Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // TheoAllen - Anywhere Texts on Screen
- // Version: 1.0
- // TheoAllen_AnywhereTexts.js
- //=============================================================================
- var Imported = Imported || {};
- Imported.Theo_AnywhereText = true;
- /*:
- * @plugindesc
- * Anywhere Texts on Screen.
- *
- * @author TheoAllen (Ported by Kadafi)
- *
- * @help
- * -----------------------------------------------------------------------------
- * *) Introduction :
- * -----------------------------------------------------------------------------
- * This plugin allow you to have many texts written on screen.
- *
- * -----------------------------------------------------------------------------
- * *) How to use :
- * -----------------------------------------------------------------------------
- * Write this following line to script call to add text on your screen
- *
- * this.text(key,x,y,text,z,show,width,height,color1,color2);
- *
- * Paramaters that must be filled:
- * - key >> Is a hash key. You may fill it with numeric or string. It's used to
- * delete your on screen text later
- * - x >> X coordinate from top-left
- * - y >> Y coordinate from top-left
- * - text >> Is the text you want to display on screen. It's support escape
- * characters such as \N[1] in show text message. But, you have to use
- * double slash to activate. For example \\N[1]
- *
- * Parameters that can be ommited :
- * - z >> Z coordinate on screen. The larger number means the closer to
- * player text will be displayed. If it's ommited, the default value
- * is 0.
- * - show >> show duration in frame. If you want to text stay on screen until
- * you delete it manualy, use -1. The default value is -1
- * - width >> width of a rectangle that will be used to draw a box
- * - height >> height of a rectangle that will be used to draw a box
- * - color1 >> Color of the rectangle. Must be filled by
- * 'rgba(red, green, blue, alpha)'
- * - color2 >> Second Color of the rectangle. The default value is same as
- * color1
- *
- * To delete a certain text. Use this script call
- * this.del_text(key);
- *
- * Key is a hash key. Same as above
- *
- * To clear entire screen, use
- * this.clear_texts();
- *
- * -----------------------------------------------------------------------------
- * *) Terms of use :
- * -----------------------------------------------------------------------------
- * TheoAllen:
- * Credit me, TheoAllen. You are free to edit this script by your own. As long
- * as you don't claim it yours. For commercial purpose, don't forget to give me
- * a free copy of the game.
- *
- * Kadafi:
- * Credit me, Kadafi. (Optional)
- */
- //-----------------------------------------------------------------------------
- // Game_Interpreter
- //-----------------------------------------------------------------------------
- Game_Interpreter.prototype.text = function(key, x, y, text, z, show, width, height, color1, color2) {
- var data = [x || 0, y || 0, text || "", z || 0, show || -1, width || 0, height || 0,
- color1 || 'rgba(0, 0, 0, 0)', color2 || 'rgba(0, 0, 0, 0)'];
- $gameSystem.addAnyText(key, data);
- };
- Game_Interpreter.prototype.del_text = function(key) {
- $gameSystem.delAnyText(key);
- };
- Game_Interpreter.prototype.clear_texts = function() {
- $gameSystem.clearTexts();
- };
- //-----------------------------------------------------------------------------
- // Game_System
- //-----------------------------------------------------------------------------
- var Game_System_initialize = Game_System.prototype.initialize;
- Game_System.prototype.initialize = function() {
- Game_System_initialize.call(this);
- this._anywhereTexts = {};
- };
- Game_System.prototype.addAnyText = function(key, data) {
- if (SceneManager._scene._anywhereTextWindow) {
- this._anywhereTexts[key] = data;
- SceneManager._scene._anywhereTextWindow.refresh();
- }
- };
- Game_System.prototype.delAnyText = function(key) {
- if (SceneManager._scene._anywhereTextWindow) {
- delete this._anywhereTexts[key];
- SceneManager._scene._anywhereTextWindow.refresh();
- }
- };
- Game_System.prototype.clearTexts = function() {
- if (SceneManager._scene._anywhereTextWindow) {
- this._anywhereTexts = {};
- SceneManager._scene._anywhereTextWindow.refresh();
- }
- };
- //-----------------------------------------------------------------------------
- // Scene_Map
- //-----------------------------------------------------------------------------
- var Scene_Map_createMapNameWindow = Scene_Map.prototype.createMapNameWindow;
- Scene_Map.prototype.createMapNameWindow = function() {
- // Anywhere Text Window placed below Map Name Window
- this._anywhereTextWindow = new Window_AnywhereText();
- this.addChild(this._anywhereTextWindow);
- Scene_Map_createMapNameWindow.call(this);
- };
- //-----------------------------------------------------------------------------
- // Window_AnywhereText
- //-----------------------------------------------------------------------------
- function Window_AnywhereText() {
- this.initialize.apply(this, arguments);
- }
- Window_AnywhereText.prototype = Object.create(Window_Base.prototype);
- Window_AnywhereText.prototype.constructor = Window_AnywhereText;
- Window_AnywhereText.prototype.initialize = function() {
- Window_Base.prototype.initialize.call(this, 0, 0, Graphics.boxWidth, Graphics.boxHeight);
- this.opacity = 0;
- this.contentsOpacity = 255;
- this.refresh();
- };
- Window_AnywhereText.prototype.update = function() {
- Window_Base.prototype.update.call(this);
- for (var key in $gameSystem._anywhereTexts) {
- if ($gameSystem._anywhereTexts[key][4] >= 0) {
- $gameSystem._anywhereTexts[key][4]--;
- if ($gameSystem._anywhereTexts[key][4] === 0) {
- $gameSystem.delAnyText(key);
- }
- }
- }
- };
- Window_AnywhereText.prototype.standardPadding = function() {
- return 0;
- };
- Window_AnywhereText.prototype.refresh = function() {
- this.contents.clear();
- var textOrder = [];
- for (var key in $gameSystem._anywhereTexts) {
- textOrder.push([key, $gameSystem._anywhereTexts[key][3]]);
- }
- textOrder.sort(function(a, b) { return a[1] - b[1] });
- for (var i = 0; i < textOrder.length; i++) {
- var data = $gameSystem._anywhereTexts[textOrder[i][0]];
- var x = data[0];
- var y = data[1];
- var text = data[2];
- var width = data[5];
- var height = data[6];
- var color1 = data[7];
- var color2 = data[8];
- this.contents.gradientFillRect(x, y, width, height, color1, color2);
- this.drawTextEx(text, x, y);
- this.resetFontSettings();
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement