RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[MV] Global Text Codes 1.0.1

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2011 Best Veteran2010 Best RPG Maker User (Scripting)2010 Most Mature Member
Global Text Codes
Version: 1.0.1
Author: modern algebra
Date: 31 October 2015

Version History


  • <Version 1.0.2> 2015-11-21 - Made overwritten functions publicly accessible
  • <Version 1.0.1> 2015-10-31 - Fixed an error that had been introduced by last-minute adjustments
  • <Version 1.0.0> 2015-10-31 - Original Release

Description


Use basic escape codes in any text on any window. Be aware that drawing text with escape codes is slow, so it is possible that some computers will experience lag if this is used too much in any one frame.

Screenshots


Example showing \i[n] codes used for the options, \c[n] codes used on the names, and \{ and \} used for the class names.

Features

  • Can use some escape codes anywhere
  • Using codes will not disrupt alignment
  • Should be compatible with most escape codes added by message scripts

Instructions

Save the script in your plugins folder and import it through the Plugin Manager.

This plugin allows you to use basic escape codes in any text field, so long as you include \* in the text field. By default, the options are limited to \c[n]; \i[n]; \v[x]; \n[x]; \pn[x]; \{; \}; and \G. They may be expanded by other message scripts which add escape codes, but not likely by all such escape codes as some would be necessarily restricted to the message window.

When using codes like \c[n] and others that change the font settings, remember that you should set it back to normal afterwards. In other words, write "\*\c[3]Text\c[0]" and not just "\*\c[3]Text"

Plugin


You can download the .js file from Pastebin: http://pastebin.com/jXGbUgDL

Code: [Select]
//=============================================================================
//  GlobalTextCodes.js
//=============================================================================
//  Version: 1.0.2
//  Date: 21 November 2015
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*:
 * @plugindesc Use basic escape codes in any window for any text
 * @author Modern Algebra (rmrk.net)
 * @help This plugin allows you to use basic escape codes in any text field, so long
 * as you include \* in the text field. By default, the options are limited to
 * \c[n]; \i[n]; \v[x]; \n[x]; \pn[x]; \{; \}; and \G. They may be expanded by
 * other message scripts which add escape codes, but not likely by all such
 * escape codes as some would be necessarily restricted to the message window.
 *
 * When using codes like \c[n] and others that change the font settings,
 * remember that you should set it back to normal afterwards. In other words,
 * write "\*\c[3]Text\c[0]" and not just "\*\c[3]Text"
 */
//=============================================================================

var Imported = Imported || {};
Imported.MA_GlobalTextCodes = true;

var ModernAlgebra = ModernAlgebra || {};
ModernAlgebra.GTC = {};

(function() {
   
// Draw Text - Check for \* and drawTextEx if it is present
ModernAlgebra.GTC.window_Base_drawText =
            Window_Base.prototype.drawText;
Window_Base.prototype.drawText = function() {
var text = arguments[0];
if ((typeof text === 'string' || text instanceof String) && text.match(/\\\*/i)) {
var tx = this.magtcCalculateAlignmentExX.apply(this, arguments);
// Draw Special Text if the \* code is present
this.drawTextEx(text, tx, arguments[2]);
} else {
// Draw Normal Text otherwise
    ModernAlgebra.GTC.window_Base_drawText.apply(this, arguments);
}
};

// Convert Escape Characters - delete \* codes
    ModernAlgebra.GTC.window_Base_convertEscapeCharacters =
            Window_Base.prototype.convertEscapeCharacters;
    Window_Base.prototype.convertEscapeCharacters = function() {
        var text = ModernAlgebra.GTC.window_Base_convertEscapeCharacters.apply(this, arguments)
        text = text.replace(/\x1b\*/, ''); // Remove \* Codes
        return text;
    };

// Calculate Alignment Ex X - Get display X when using different alignment
Window_Base.prototype.magtcCalculateAlignmentExX = function(text, tx, y, mw, align) {
if (align === 'center' || align === 'right') {
// Calculate line length and adjust x based on alignment
var tw = this.magtcMeasureTextEx(text);
var blankSpace = mw - tw;
if (align === 'center') {
blankSpace = blankSpace / 2;
}
tx = tx + blankSpace;
}
return tx
};

// Measure text that has escape codes
Window_Base.prototype.magtcMeasureTextEx = function(text) {
// Create temporary bitmap for testing to accomodate other scripts with unknown codes
this._magtcAlignmentTesting = true;
var realContents = this.contents;
this.contents = new Bitmap(24, 24);
this.resetFontSettings();
// Draw TextEx on the temporary Bitmap
var firstLine = text.match(/^\n?(.+)\n?/)[0] || '';
var tw = this.drawTextEx(firstLine, 0, 0);
// Restore normal contents
this._magtcAlignmentTesting = null;
this.contents = realContents;
return tw
}

})();

Credit


  • modern algebra

Support


Post in this thread if you have any comments or questions. It is perfectly fine to post here even if this topic has not been posted in for a very long time.

Please do not message me privately, as any concerns you have are likely shared by others and they will benefit from our correspondence being public. Additionally, I am often absent, and posting publicly will allow other members to assist you when I am unable to do so quickly.

Terms of Use


You are welcome to use this script in any project of yours, whether it is commercial or non-commercial. There is no need to credit me, and please feel free to modify the plugin in whatever ways suit your project.

Basically, my plugin is your plugin, but please do not re-post this plugin or any modified version of it on another forum or website.
« Last Edit: November 21, 2015, 09:20:05 PM by modern algebra »

*
The Hero of Rhyme
Rep:
Level 83
( ͡° ͜ʖ ͡°)
Project of the Year 20142014 Best RPG Maker User - Story2014 Queen of RMRK2011 Best Newbie2014 Kindest Member2014 Best RPG Maker User - Creativity2013 Queen of RMRKBronze SS AuthorBronze Writing ReviewerSecret Santa 2013 ParticipantFor taking arms in the name of your breakfast.GOOD!For frequently finding and reporting spam and spam bots2012 Best Yuyubabe Smiley2012 Best RPG Maker User (Creativity);o
Definitely one of my favorite scripts to use in the past makers. ;___;

Thanks for writing it, modern! ^_^
Spoiler for My Games and Art:
ℒℴѵℯ❤


My Artwork Thread

The Lhuvia Tales [Current]

Ambassador [Complete]

The Postman [Complete]

The Wyvern [Complete]

Phoenix Wright: Haunted Turnabout [Complete]

Major Arcana [Cancelled]


***
Rep:
Level 77
RMRK Junior
Help text is missing.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2011 Best Veteran2010 Best RPG Maker User (Scripting)2010 Most Mature Member
Do you mean the text that shows up in the Plugin Manager when you press the help button? Or do you mean the text that would show up in a help window in-game (like the description of an item)? Or do you mean something else.

In any case, I have been unable to detect an error when I've tested the script, so please let me know some more details so that I can hopefully find and fix the problem.

*
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Rep:
Level 96
&&&&&&&&&&&&&&&&&&&&&&&&&&&
GIAW 14: 2nd Place (Hard Mode)2013 Zero to Hero2013 Biggest Drama WhoreParticipant - GIAW 11Secret Santa 2013 ParticipantFor taking arms in the name of your breakfast.
Loved the VXA version.
Kicks the UI up another notch.
&&&&&&&&&&&&&&&&

***
Rep:
Level 77
RMRK Junior
The Plugin Manager help text and description is what's blank.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2011 Best Veteran2010 Best RPG Maker User (Scripting)2010 Most Mature Member
OK, it has to do with how Pastebin is naming the file when you download it from there. I will change the name to avoid that problem in the future, but you can just rename the .js file to "GlobalTextCodes.js" and everything should come back.

*
Rep:
Level 85
I am the wood of my broom
2010 Project of the YearProject of the Month winner for January 2009Project of the Month winner for January 2010Project of the Month winner for April 2010
Aaa MA is back! I can't wait for your animated parallax and pictures <3


**
Rep: +0/-0Level 74
RMRK Junior
first of all... thanks for this amazing plugin...
some sugestion though...
can you make this plugin doesn't have to add \*  to activate it...?
i try modifying your plugin
Code: [Select]
ModernAlgebra.GTC.window_Base_drawText =
            Window_Base.prototype.drawText;
Window_Base.prototype.drawText = function() {
               // if it's window message... then call old method
if (this.constructor == Window_Message)
return ModernAlgebra.GTC.window_Base_drawText.apply(this, arguments);
                           
var text = arguments[0];
if ((typeof text === 'string' || text instanceof String)) {
var tx = this.magtcCalculateAlignmentExX.apply(this, arguments);
// Draw Special Text if the \* code is present
this.drawTextEx(text, tx, arguments[2]);
} else {
// Draw Normal Text otherwise
    ModernAlgebra.GTC.window_Base_drawText.apply(this, arguments);
}
};
removing the match inside the if. and it work. can i request you to implement this changes to your script?
or there's a problem about the edit i done which i don't know?
and any particular reason why we should add \* if we want to use escape code

since i have autocolor plugins which will auto convert certain text to \c[x]text\c[0]
so by needing to use \* it will require to modify all my database while if not... this plugin will become plug and play with my plugin :D.

maybe if you still want to use \* at least plugin parameter to switch from requiring \* and not requiring \*
« Last Edit: November 24, 2015, 12:10:24 AM by estriole »

**
Rep: +0/-0Level 74
RMRK Junior
ignore my post above...
apparently it caused lag when using it with yanfly battle engine core's visual selection.
so using \* to only draw what needed to be colored is fine approach.