Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //====================================================
- //@filename K89_MessageBallon.js
- //====================================================
- /*>>
- */
- /*:
- *@plugindesc Messaggio in balloon
- *
- *
- *@author Killvern89
- *
- *
- *@help
- *V:0.2 - D:2020/02/23
- * =============================
- * Target
- * =============================
- *
- * Per identificare la posizione del messaggio è necessario inserire
- * il codice: \T[n]
- * n = ID dell'evento target del messaggio
- * Per n = 0 il target del messaggio è il party leader
- *
- *
- * Il codice \T[n] verrà sostituito con il nome del leader del
- * party (n = 0) o il nome dell'evento (n = ID evento)
- *
- *
- * Non è possibile utilizzare il balloon senza identificare un target.
- *
- *
- * Per modificare il nome del party leader durante i dialoghi,
- * si può usare questo script:
- * >> $gameParty.leader()._name = '';
- *
- *
- * Per cambare il nome dell'evento durante i messaggi, si può usare
- * lo script:
- * >> $gameMap._events[n].event().name = '';
- *
- * Si consiglia di inserire nell'evento il nome definitivo.
- *
- *
- * =============================
- * Font size
- * =============================
- *
- * La dimensione del testo nel balloon può essere diversa
- * da quella dei testi standard (28).
- * La dimensione del balloon si adatta dinamamicamente.
- *
- * È possibile modificare la dimensione del font tramite
- * script in questo modo:
- * >> K89.MB.FontSize = n;
- *
- * =============================
- * Face
- * =============================
- *
- * Nel balloon può essere mostrata l'immagine face come nei messaggi standard.
- * Il ballon si adatta dinamicamente in altezza ed in larghezza secodno la
- * dimensione base del face impostate in Window_Base.
- *
- * Tramite il valore 'Face full height' = false, si inidica allo switch di non
- * considerare l'altezza del face nella creazione della finestra di messaggio.
- *
- * È possibile modificare questa ipostazione tramite script:
- * >> K89.MB.FullFace = true/false;
- *
- *
- * =============================
- * Offset
- * =============================
- *
- * Possibilità di inserire compesazione per posizione X e Y del messaggio
- *
- * Possibile modificare in game con script:
- * >> K89.MB.OffSetX = n;
- * >> K89.MB.OffSetY = n;
- *
- * =============================
- * Log
- * =============================
- * V:0.1 - D:2020/02/23
- *
- * V:0.2 - D:2020/02/23
- * - Add y positionig based on chara size
- * - Add offsett x & y
- *
- * =============================
- *
- * @param Font size
- * @desc Text font size fore message ballon
- * @default 20
- *
- * @param Face full height
- * @desc Full face in message balloon
- * @default true
- *
- * @param Offset X
- * @desc Standard offset X
- * @default 0
- *
- * @param Offset Y
- * @desc Standard offset Y
- * @default 0
- */
- var K89 = K89 || {};
- K89.MB = {};
- K89.MB.Par = PluginManager.parameters('K89_MessageBallon');
- //----------------------------------------------
- //Set Parameters
- //----------------------------------------------
- K89.MB.FontSize = Number(K89.MB.Par['Font size']);
- K89.MB.FullFace = Boolean(K89.MB.Par['Face full height']);
- K89.MB.OffSetX = Number(K89.MB.Par['Offset X']);
- K89.MB.OffSetY = Number(K89.MB.Par['Offset Y']);
- console.log('OffSet X' + K89.MB.OffSetX);
- console.log('OffSet Y' + K89.MB.OffSetY);
- // Modifico funzione posizionamento finestra messaggio
- Window_Message.prototype.updatePlacement = function() {
- this._positionType = $gameMessage.positionType();
- this.contents.fontSize = K89.MB.FontSize;
- this.padding = 10;
- if (this._textTarget != undefined) {
- this.width = this.eval_Width(this.textlenght)
- this.height = this.eval_Height(this.textlenght)
- if ($gameMessage._faceName != '') {
- this.width += Window_Base._faceWidth + this.padding*2;
- if (K89.MB.FullFace) {
- this.height = (Window_Base._faceHeight + this.padding*2);
- }
- }
- this.y = this.eval_Y();
- this.x = this.eval_X();
- } else {
- this.x = 0;
- this.padding = 18;
- this.width = this.windowWidth();
- this.contents.fontSize = Window_Base.prototype.standardFontSize();
- this.height = 180;
- this._positionType = $gameMessage.positionType();
- this.y = this._positionType * (Graphics.boxHeight - this.height) / 2;
- this._goldWindow.y = this.y > 0 ? 0 : Graphics.boxHeight - this._goldWindow.height;
- }
- this._goldWindow.y = this.y > 0 ? 0 : Graphics.boxHeight - this._goldWindow.height;
- };
- // TODO: Verificare che la finestra non esca dallo schermo e definire posizionamento alternativo
- // Valutare se necessario
- //Valutazione X balloon
- Window_Message.prototype.eval_X = function () {
- if (this._textTarget == '0') {
- caller_X = $gamePlayer.screenX();
- } else {
- caller_X = $gameMap._events[this._textTarget].screenX();
- }
- caller_X = caller_X - this.width/2 + K89.MB.OffSetX;
- return caller_X
- }
- //Valutazione Y balloon, basata su altezza sprite target
- Window_Message.prototype.eval_Y = function () {
- caller_height = 48;
- if (this._textTarget == '0') {
- caller_Y = $gamePlayer.screenY();
- spritesetLenght = SceneManager._scene._spriteset._characterSprites.length;
- caller_height = SceneManager._scene._spriteset._characterSprites[spritesetLenght-1].height;
- } else {
- caller_Y = $gameMap._events[this._textTarget].screenY();
- caller_height = SceneManager._scene._spriteset._characterSprites[this._textTarget-1].height;
- }
- caller_Y = caller_Y - (this.height + caller_height) + K89.MB.OffSetY;
- return caller_Y
- }
- //Valutazione larghezza balloon
- Window_Message.prototype.eval_Width = function (text) {
- let width = 1;
- let letter = 0;
- for (let i = 0; i < text.length; i++) {
- letter = text[i].toString().length;
- if (letter > width) {
- width = letter;
- };
- };
- width *= (K89.MB.FontSize*0.58);
- if (letter <= 14) {
- width += (K89.MB.FontSize/1.5);
- }
- return width
- }
- //Valutazione altezza balloon
- Window_Message.prototype.eval_Height = function (text) {
- let height = text.length;
- height *= (K89.MB.FontSize*1.5);
- height += 30;
- return height
- }
- // Modifico funzione conversione escape character per leggere target messaggio, definire posizione finestra e inserire nome target
- Window_Base.prototype.convertEscapeCharacters = function(text) {
- text = text.replace(/\\/g, '\x1b');
- text = text.replace(/\x1b\x1b/g, '\\');
- text = text.replace(/\x1bV\[(\d+)\]/gi, function() {
- return $gameVariables.value(parseInt(arguments[1]));
- }.bind(this));
- text = text.replace(/\x1bV\[(\d+)\]/gi, function() {
- return $gameVariables.value(parseInt(arguments[1]));
- }.bind(this));
- text = text.replace(/\x1bN\[(\d+)\]/gi, function() {
- return this.actorName(parseInt(arguments[1]));
- }.bind(this));
- text = text.replace(/\x1bP\[(\d+)\]/gi, function() {
- return this.partyMemberName(parseInt(arguments[1]));
- }.bind(this));
- text = text.replace(/\x1bG/gi, TextManager.currencyUnit);
- //> Kill : Gestione target messaggio
- // console.log('text:' + text);
- this._textTarget = text.match(/\x1bT\[(\d+)\]/gi);
- if (this._textTarget != null) {
- this._textTarget = this._textTarget.toString().match(/\d+/g);
- speacker = this.getSpeakerName(this._textTarget)
- text = text.replace(/\x1bT\[(\d+)\]/gi, speacker);
- this.textlenght = text.split('\n')
- };
- return text;
- };
- //Calcolo nome attore/evento da inserire nel messaggio al posto di /t[x]
- Window_Message.prototype.getSpeakerName = function (index) {
- if (index == '0') {
- name = $gameParty.leader()._name;
- } else {
- name = $gameMap.events()[index-1].event().name;
- }
- return name
- }
- //Inizializazione messaggio, per gestire primi valori, potrebbe non servire...
- Window_Message.prototype.initialize = function() {
- var width = this.windowWidth();
- var height = this.windowHeight();
- var x = 0;
- var y = 0;
- Window_Base.prototype.initialize.call(this, x, y, width, height);
- this.openness = 0;
- this.initMembers();
- this.createSubWindows();
- this.updatePlacement();
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement