Sphinx-WB_CSS
Comme tous mes plugins, ce script est publié sous licence CC BY 4.0.
//=============================================================================
// Sphinx-WB_CSS.js
//=============================================================================
/*:
* @plugindesc Extension du système de messages pour y utiliser certaines propriétés CSS
* @author Sphinx - Version : 1.2.0
*
* @help
* //==========================================================================
* // Plugin : Sphinx-WB_CSS
* // Date : 11 janvier 2016
* // Auteur : Sphinx
* //==========================================================================
* Partage de ce script selon les termes de la licence CC BY 3.0 FR
* https://creativecommons.org/licenses/by/3.0/fr/
*
* Ce script a pour objectifde rendre disponible certaines propriétés du CSS
* dans les fenêtres des messages
*
* Toutes les commandes débutent par \#
*
* Liste des commandes du plugin :
* - ENREGISTRER_COULEUR ALIAS COULEUR
* Enregistre une couleur sous un alias qui pourra être utilisé à sa
* place dans des messages textes et défilants.
* ALIAS : nom de la couleur tel qu'il sera utilisé ensuite (ne doit
* contenir QUE des caractères alphanumériques)
* COULEUR : couleurs au format hexadécimal, ou nombre compris
* entre 0 et 31 pour les couleurs du windowskin, ou couleur
* CSS
*
* - ENREGISTRER_POLICE ALIAS CHEMIN_FICHIER
* ALIAS : nom de la police telle qu'elle sera utilisée ensuite
* CHEMIN_FICHIER : nom du fichier (incluant l'extension et
* l'ensemble des sous répertoires éventuels après
* fonts/)
* Les polices DOIVENT se situer dans le dossier fonts/
*
* - COULEUR_PAR_DEFAUT TYPE_MSG COULEUR
* - COULEUR_PAR_DEFAUT TYPE_MSG COULEUR1 COULEUR2
* Change la couleur par défaut des messages
* TYPE_MSG : message -> Change la couleur des messages normaux
* scrolltext -> Change la couleur des textes défilants
* both -> Change la couleur des messages normaux
* et des textes défilants
* COULEUR
* COULEUR1
* COULEUR2 : couleurs au format hexadécimal, ou nombre compris
* entre 0 et 31 pour les couleurs du windowskin, ou un
* alias de couleur, ou couleur CSS
*
* - POLICE_PAR_DEFAUT TYPE_MSG POLICE
* Change la police par défaut des messages
* TYPE_MSG : message -> Change la police des messages normaux
* scrolltext -> Change la police des textes défilants
* both -> Change la police des messages normaux
* et des textes défilants
* POLICE : Police de caractères ou alias de police de caractères
* à utiliser
*
* - ALIGNEMENT_PAR_DEFAUT TYPE_MSG POLICE
* Change la police par défaut des messages
* TYPE_MSG : message -> Change la police des messages normaux
* scrolltext -> Change la police des textes défilants
* both -> Change la police des messages normaux
* et des textes défilants
* ALIGNEMENT : left -> aligne le texte à gauche
* center -> aligne le texte au centre
* right -> aligne le texte à droite
* justify -> justifie le texte
*
* Liste des commandes des messages :
* - \#FF FONT FAMILY
* - \#FF[FONT_NAME]
* Change la police de caractères. Si la police n'est pas précisé,
* revient à la normale
* FONT_NAME : Nom de la police ou un alias enregistré
*
* - \#FS FONT SIZE
* - \#FS[FONT_SIZE]
* Change la taille de la police de caractères. Si la taille n'est
* pas précisée, revient à la normale
* FONT_SIZE : Taille de la police
*
* - \#LG[COULEUR1][COULEUR2] LINEAR GRADIENT
* Colore le texte d'un dégradé allant de la couleur 1 à la couleur 2
* COULEUR1
* COULEUR2 : couleurs au format hexadécimal, ou nombre compris
* entre 0 et 31 pour les couleurs du windowskin, ou un
* alias de couleur, ou couleur CSS
*
* - \#EG END GRADIENT
* Balise de fin du dégradé
*
* - \#TA[ALIGNEMENT] TEXT ALIGN
* Aligne le texte qui suit à gauche, au centre, à droite ou encore
* justifié
* ALIGNEMENT : left -> aligne le texte à gauche
* center -> aligne le texte au centre
* right -> aligne le texte à droite
* justify -> justifie le texte
* NB : l'alignement justifié aligne la dernière ligne à gauche
*
* - \#UC UPPER CASE
* Transforme le texte qui suit en majuscule
*
* - \#LC LOWER CASE
* Transforme le texte qui suit en minuscule
*
* - \#CP CAPITALIZE
* Transforme la première lettre de chaque mot qui suit en majuscule
* et le reste du mot en minuscule
*
* - \#NC NORMAL CASE
* Met fin aux effets de \#UC, \#LC et \#CP
*
* - \#B BOLD
* Met le texte qui suit en gras
*
* - \#EB END BOLD
* Met fin à l'effet de \#B
*
* - \#C COLOR
* - \#C[COULEUR]
* Colore le texte qui suit de la couleur choisie. Si la couleur
* n'est pas spécifiée, c'est la couleur par défaut qui est
* appliquée
* COULEUR : couleurs au format hexadécimal, ou nombre compris
* entre 0 et 31 pour les couleurs du windowskin, ou un
* alias de couleur
*
* - \#I ITALIC
* Met le texte qui suit en italique
*
* - \#EI END ITALIC
* Met fin à l'effet de \#I
*
* - \#U UNDERLINE
* Souligne le texte qui suit
*
* - \#EU END UNDERLINE
* Met fin à l'effet de \#U
*
* Dépendances :
* Aucune
*/
if(!String.prototype.padStart) {
String.prototype.padStart = function padStart(targetLength,padString) {
targetLength = targetLength>>0; //floor ifnumber or convert non-number to 0;
padString = String((typeof padString !== 'undefined' ? padString : ' '));
if(this.length > targetLength) {
return String(this);
}
else {
targetLength = targetLength-this.length;
if(targetLength > padString.length) {
padString += padString.repeat(targetLength/padString.length); //append to original to ensure we are longer than needed
}
return padString.slice(0,targetLength) + String(this);
}
};
};
Game_System.prototype.SphinxCSS_initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function() {
Game_System.prototype.SphinxCSS_initialize.call(this);
this.savedColors = {};
};
Game_System.prototype.saveColor = function(alias, color) {
if(/^\w+$/i.test(alias) && !(/^([0-9A-F]{3}|#?[0-9A-F]{6}|[0-2]?\d|3[0-1])$/i.test(alias))) {
if(/^([0-9A-F]{3}|#?[0-9A-F]{6}|[0-2]?\d|3[0-1])$/i.test(color)) {
this.savedColors[alias.toUpperCase()] = color.toUpperCase();
}
}
};
Game_System.prototype.getColor = function(color) {
if(this.savedColors[color.toUpperCase()]) {
return this.savedColors[color.toUpperCase()];
}
d = document.createElement("div");
d.style.color = color;
document.body.appendChild(d);
color = window.getComputedStyle(d).color;
document.body.removeChild(d);
color = color.replace(/^rgb\((\d+), (\d+), (\d+)\)$/, "$1-$2-$3").split("-");
for(i = 0; i < color.length; ++i) {
color[i] = parseInt(color[i], 10).toString(16);
if(color[i].length == 0) color[i] = "00";
else if(color[i].length == 1) color[i] = "0" + color[i];
}
return color.join("");
};
Game_System.prototype.saveFont = function(alias, font) {
if(/^\w+$/i.test(alias)) {
var font = new FontFace(alias, "url('fonts/" + font + "')");
font.load().then(function(loadedFontFace) {
document.fonts.add(loadedFontFace);
})
}
};
Game_Interpreter.prototype.SphinxCSS_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
switch(command) {
case "ENREGISTRER_COULEUR":
$gameSystem.saveColor(args[0].toUpperCase(), args[1]);
break;
case "ENREGISTRER_POLICE":
$gameSystem.saveFont(args[0], args.slice(1).join(" "));
break;
case "COULEUR_PAR_DEFAUT":
args[0] = args[0].toLowerCase();
if(typeof args[2] == "undefined") {
if(args[0] == "message" || args[0] == "both") {
Window_Message.defaultColor = args[1];
}
if(args[0] == "scrolltext" || args[0] == "both") {
Window_ScrollText.defaultColor = args[1];
}
} else {
if(args[0] == "message" || args[0] == "both") {
Window_Message.defaultColor = { start: args[1], end: args[2] };
}
if(args[0] == "scrolltext" || args[0] == "both") {
Window_ScrollText.defaultColor = { start: args[1], end: args[2] };
}
}
break;
case "POLICE_PAR_DEFAUT":
args[0] = args[0].toLowerCase();
if(args[0] == "message" || args[0] == "both") {
if($gameSystem.isChinese()) {
Window_Message.defaultFont.chinese = args.slice(1).join(", ");
} else if($gameSystem.isKorean()) {
Window_Message.defaultFont.korean = args.slice(1).join(", ");
} else {
Window_Message.defaultFont.latin = args.slice(1).join(", ");
}
}
if(args[0] == "scrolltext" || args[0] == "both") {
if($gameSystem.isChinese()) {
Window_ScrollText.defaultFont.chinese = args.slice(1).join(", ");
} else if($gameSystem.isKorean()) {
Window_ScrollText.defaultFont.korean = args.slice(1).join(", ");
} else {
Window_ScrollText.defaultFont.latin = args.slice(1).join(", ");
}
}
break;
case "ALIGNEMENT_PAR_DEFAUT":
args[0] = args[0].toLowerCase();
if(args[0] == "message" || args[0] == "both") {
Window_Message.defaultAlign = args[1];
}
if(args[0] == "scrolltext" || args[0] == "both") {
Window_ScrollText.defaultAlign = args[1];
}
break;
default:
Game_Interpreter.prototype.SphinxCSS_pluginCommand.call(this, command, args);
break;
}
};
Window_Base.prototype.SphinxCSS_obtainEscapeCode = Window_Base.prototype.obtainEscapeCode;
Window_Base.prototype.obtainEscapeCode = function(textState) {
textState.index++;
var regExp = /^#(FF|FS|LG|EG|TA|UC|LC|CP|NC|B|EB|C|I|EI|U|EU)/i;
var arr = regExp.exec(textState.text.slice(textState.index));
if(arr) {
textState.index += arr[0].length;
return arr[0];
} else {
textState.index--;
return Window_Base.prototype.SphinxCSS_obtainEscapeCode.call(this, textState);
}
};
Window_Base.prototype.obtainEscapeHexaParam = function(textState) {
var arr = /^\[[0-9A-Fa-f]+\]/.exec(textState.text.slice(textState.index));
if(arr) {
textState.index += arr[0].length;
return arr[0].replace("[", "").replace("]", "").toUpperCase();
} else {
return "";
}
};
Window_Base.prototype.obtainEscapeAlphaNumParam = function(textState) {
var arr = /^\[[\w ,]+\]/.exec(textState.text.slice(textState.index));
if(arr) {
textState.index += arr[0].length;
return arr[0].replace("[", "").replace("]", "");
} else {
return "";
}
};
Window_Base.prototype.SphinxCSS_processEscapeCharacter = Window_Base.prototype.processEscapeCharacter;
Window_Base.prototype.processEscapeCharacter = function(code, textState) {
switch(code.toUpperCase()) {
// font family
case "#FF":
var font = this.obtainEscapeAlphaNumParam(textState);
if(font != "") {
this.contents.fontFace = font;
} else {
this.contents.fontFace = "GameFont";
}
break;
// font size
case "#FS":
var size = this.obtainEscapeParam(textState);
if(size != "") {
this.contents.fontSize = size;
} else {
this.contents.fontSize = 28;
}
break;
// linear-gradient
case "#LG":
var start = this.obtainEscapeAlphaNumParam(textState);
var end = this.obtainEscapeAlphaNumParam(textState);
this.initializeGradient(textState, start, end);
break;
// end-gradient
case "#EG":
this.changeTextColor(this.normalColor());
delete textState.gradient;
if(typeof this.constructor.defaultColor == "object" && typeof textState.gradient == "undefined") {
var start = this.constructor.defaultColor.start;
var end = this.constructor.defaultColor.end;
this.initializeGradient(textState, start, end);
}
break;
// text-align
case "#TA":
textState.align = this.obtainEscapeAlphaNumParam(textState);
this.getLeftWithAlign(textState);
break;
// uppercase
case "#UC":
var text = textState.text.slice(textState.index).replace(/^(.*)(\x1b#NC)?/, "$1");
textState.text = textState.text.slice(0, textState.index) + textState.text.slice(textState.index).replace(text, text.toUpperCase());
break;
// lowercase
case "#LC":
var text = textState.text.slice(textState.index).replace(/^(.*)(\x1b#NC)?/, "$1");
textState.text = textState.text.slice(0, textState.index) + textState.text.slice(textState.index).replace(text, text.toLowerCase());
break;
// capitalize
case "#CP":
var text = textState.text.slice(textState.index).replace(/^(.*)(\x1b#NC)?/, "$1");
textState.text = textState.text.slice(0, textState.index) + textState.text.slice(textState.index).replace(text, text.toLowerCase().replace(/(^\w|\b\w)/gi, function(m) { return m.toUpperCase(); }));
break;
// normal case
case "#NC":
break;
// bold
case "#B":
textState.fontBold = true;
break;
// end-bold
case "#EB":
textState.fontBold = false;
break;
// color
case "#C":
var couleur = this.obtainEscapeAlphaNumParam(textState);
if(!(/^([0-2]?\d|3[0-1]|[0-9A-F]{3}|#?[0-9A-F]{6})$/i.test(couleur))) {
couleur = $gameSystem.getColor(couleur);
}
if(/^([0-2]?\d|3[0-1])$/.test(couleur)) {
couleur = this.textColor(couleur).slice(1);
}
if(/^rgb\(/.test(couleur)) {
couleur = couleur.replace(/^rgb\((\d+), (\d+), (\d+)\)$/i, function() {
console.log(arguments);
return "";
});
}
if(couleur != "") {
this.changeTextColor("#" + couleur);
} else {
this.changeTextColor(this.normalColor());
}
break;
// italic
case "#I":
textState.fontItalic = true;
break;
// end-italic
case "#EI":
textState.fontItalic = false;
break;
// underline
case "#U":
this.contents.fillRect(textState.x - 1, textState.y + textState.height - 3, 1, 2, this.contents.outlineColor);
textState.fontUnderline = true;
break;
// end-underline
case "#EU":
this.contents.fillRect(textState.x, textState.y + textState.height - 3, 1, 2, this.contents.outlineColor);
textState.fontUnderline = false;
break;
// exécution des autres commandes
default:
Window_Base.prototype.SphinxCSS_processEscapeCharacter.call(this, code, textState);
break;
}
};
Window_Base.prototype.processNormalCharacter = function(textState) {
if(typeof textState.gradient == "object") {
this.SphinxCSS_calculateGradientColor(textState);
}
this.contents.fontBold = textState.fontBold;
this.contents.fontItalic = textState.fontItalic;
var c = textState.text[textState.index++];
var w = this.textWidth(c);
this.contents.drawText(c, textState.x, textState.y, w * 2, textState.height);
if(textState.fontUnderline) {
if(c == " " && textState.justifyWidth && textState.justifyWidth < 0) {
this.contents.fillRect(textState.x, textState.y + textState.height - 4, w + textState.justifyWidth, 1, this.contents.outlineColor);
this.contents.fillRect(textState.x, textState.y + textState.height - 3, w + textState.justifyWidth, 2, this.contents.textColor);
this.contents.fillRect(textState.x, textState.y + textState.height - 1, w + textState.justifyWidth, 1, this.contents.outlineColor);
} else {
this.contents.fillRect(textState.x, textState.y + textState.height - 4, w, 1, this.contents.outlineColor);
this.contents.fillRect(textState.x, textState.y + textState.height - 3, w, 2, this.contents.textColor);
this.contents.fillRect(textState.x, textState.y + textState.height - 1, w, 1, this.contents.outlineColor);
}
}
textState.x += w;
if(c == " " && textState.justifyWidth) {
if(textState.fontUnderline && textState.justifyWidth > 0) {
this.contents.fillRect(textState.x, textState.y + textState.height - 4, textState.justifyWidth, 1, this.contents.outlineColor);
this.contents.fillRect(textState.x, textState.y + textState.height - 3, textState.justifyWidth, 2, this.contents.textColor);
this.contents.fillRect(textState.x, textState.y + textState.height - 1, textState.justifyWidth, 1, this.contents.outlineColor);
}
textState.x += textState.justifyWidth;
}
if(textState.fontUnderline && textState.text.slice(textState.index) == "") {
this.contents.fillRect(textState.x, textState.y + textState.height - 3, 1, 2, this.contents.outlineColor);
}
};
Window_Base.prototype.newLineX = function() {
return this.standardPadding();
};
Window_Base.prototype.SphinxCSS_processNewLine = Window_Base.prototype.processNewLine;
Window_Base.prototype.processNewLine = function(textState) {
if(textState.fontUnderline) {
this.contents.fillRect(textState.x, textState.y + textState.height - 3, 1, 2, this.contents.outlineColor);
}
Window_Base.prototype.SphinxCSS_processNewLine.call(this, textState);
if(textState.gradient) {
var text = /^.*\n?/.exec(textState.text.slice(textState.index))[0].trim();
if(/#LG|#EG/i.test(text)) {
text = /^(.*)(#LG|#EG)/i.exec(textState.text.slice(textState.index))[1];
}
var length = text.length;
textState.gradient.startIndex = textState.index;
textState.gradient.endIndex = textState.index + length - 1;
}
this.getLeftWithAlign(textState);
if(textState.fontUnderline) {
this.contents.fillRect(textState.x - 1, textState.y + textState.height - 3, 1, 2, this.contents.outlineColor);
}
};
Window_Base.prototype.initializeGradient = function(textState, start, end) {
if(!(/^([0-2]?\d|3[0-1]|[0-9A-F]{3}|#?[0-9A-F]{6})$/i.test(start))) {
start = $gameSystem.getColor(start);
}
if(!(/^([0-2]?\d|3[0-1]|[0-9A-F]{3}|#?[0-9A-F]{6})$/i.test(end))) {
end = $gameSystem.getColor(end);
}
if(/^([0-2]?\d|3[0-1])$/i.test(start)) {
start = this.textColor(start).slice(1);
}
if(/^([0-2]?\d|3[0-1])$/i.test(end)) {
end = this.textColor(end).slice(1);
}
if(start == "") {
start = this.normalColor().replace("#", "");
}
if(end == "") {
end = this.normalColor().replace("#", "");
}
var text = /^.*\n?/.exec(textState.text.slice(textState.index))[0].trim();
if(/#LG|#EG/i.test(text)) {
text = /^(.*)(#LG|#EG)/i.exec(textState.text.slice(textState.index))[1];
}
var length = text.length;
textState.gradient = {
start: [parseInt(start.slice(0, 2), 16), parseInt(start.slice(2, 4), 16), parseInt(start.slice(4, 6), 16)],
end: [parseInt(end.slice(0, 2), 16), parseInt(end.slice(2, 4), 16), parseInt(end.slice(4, 6), 16)],
startIndex: textState.index,
endIndex: textState.index + length - 1
}
};
Window_Base.prototype.SphinxCSS_calculateGradientColor = function(textState) {
var color = [0, 0, 0];
var start = textState.gradient.start;
var end = textState.gradient.end;
for(var i = 0; i < 3; ++i) {
color[i] = Math.round(start[i] + (end[i] - start[i]) / (textState.gradient.endIndex - textState.gradient.startIndex) * (textState.index - textState.gradient.startIndex));
}
this.changeTextColor("#" + color[0].toString(16).padStart(2, "0") + color[1].toString(16).padStart(2, "0") + color[2].toString(16).padStart(2, "0"));
};
Window_Base.prototype.getLeftWithAlign = function(textState) {
if(typeof textState.align == "undefined") {
textState.x = this.newLineX();
return;
}
var italic = /\x1b#I/i.test(text);
var endItalic = /\x1b#EI/i.test(text) && !(/\x1b#EI$/im.test(text));
var text = this.convertEscapeCharacters(textState.text.slice(textState.index));
if(/\x1b([\$\.\|\^!><\{\}\\]+|#?(FF|FS|LG|EG|TA|UC|LC|CP|NC|B|EB|C|I|EI|U|EU))(\[\w+\])*/i.test(text)) {
text = text.replace(/\x1b([\$\.\|\^!><\{\}\\]+|#?(FF|FS|LG|EG|TA|UC|LC|CP|NC|B|EB|C|I|EI|U|EU))(\[\w+\])*/ig, "");
}
var notEndMessage = /\n/.test(text);
text = /^.*\n?/.exec(text)[0].trim();
if(typeof textState.align == "undefined") {
textState.align = this.constructor.defaultAlign;
}
switch(textState.align.toLowerCase()) {
case "center":
textState.x = this.newLineX() + (this.contents.width - (this.standardPadding() * 2) - (endItalic ? 13 : (italic ? 17 : 0)) - this.newLineX() - this.textWidth(text)) / 2;
break;
case "right":
textState.x = this.contents.width - (this.standardPadding() * 2) - (endItalic ? 13 : (italic ? 17 : 0)) - this.textWidth(text);
break;
case "justify":
textState.x = this.newLineX();
if(notEndMessage) {
textState.justifyWidth = Math.floor((this.contents.width - (this.standardPadding() * 2) - (endItalic ? 16 : (italic ? 20 : 3)) - this.newLineX() - this.textWidth(text)) / (text.match(/ /g) || []).length);
} else {
textState.justifyWidth = 0;
}
break;
case "left":
default:
textState.x = this.newLineX();
break;
}
this.contents.fontItalic = textState.fontItalic;
};
Window_Base.prototype.SphinxCSS_processCharacter = Window_Base.prototype.processCharacter;
Window_Base.prototype.processCharacter = function(textState) {
if(typeof this.constructor.defaultColor == "object" && typeof textState.gradient == "undefined") {
var start = this.constructor.defaultColor.start;
var end = this.constructor.defaultColor.end;
this.initializeGradient(textState, start, end);
}
if(typeof textState.align == "undefined") {
textState.align = this.constructor.defaultAlign;
}
if(textState.index == 0) {
this.getLeftWithAlign(textState);
}
Window_Base.prototype.SphinxCSS_processCharacter.call(this, textState);
};
Window_Message.defaultColor = undefined;
Window_Message.defaultAlign = "left";
Window_Message.defaultFont = {
latin: "GameFont",
chinese: "SimHei, Heiti TC, sans-serif",
korean: "Dotum, AppleGothic, sans-serif"
};
Window_Message.prototype.standardFontFace = function() {
if($gameSystem.isChinese()) {
return this.constructor.defaultFont.chinese;
} else if($gameSystem.isKorean()) {
return this.constructor.defaultFont.korean;
} else {
return this.constructor.defaultFont.latin;
}
};
Window_Message.prototype.normalColor = function() {
if(typeof Window_Message.defaultColor == "string") {
var couleur = Window_Message.defaultColor;
if(!(/^([0-2]?\d|3[0-1]|[0-9A-F]{3}|#?[0-9A-F]{6})$/i.test(couleur))) {
couleur = $gameSystem.getColor(couleur);
}
if(/^([0-2]?\d|3[0-1])$/.test(couleur)) {
return this.textColor(couleur);
}
return "#" + couleur;
}
return Window_Base.prototype.normalColor.call(this);
};
Window_ScrollText.defaultColor = undefined;
Window_ScrollText.defaultAlign = "left";
Window_ScrollText.defaultFont = {
latin: "GameFont",
chinese: "SimHei, Heiti TC, sans-serif",
korean: "Dotum, AppleGothic, sans-serif"
};
Window_ScrollText.prototype.standardFontFace = function() {
if($gameSystem.isChinese()) {
return this.constructor.defaultFont.chinese;
} else if($gameSystem.isKorean()) {
return this.constructor.defaultFont.korean;
} else {
return this.constructor.defaultFont.latin;
}
};
Window_ScrollText.prototype.normalColor = function() {
if(typeof Window_ScrollText.defaultColor == "string") {
var couleur = Window_ScrollText.defaultColor;
if(!(/^([0-2]?\d|3[0-1]|[0-9A-F]{3}|#?[0-9A-F]{6})$/i.test(couleur))) {
couleur = $gameSystem.getColor(couleur);
}
if(/^([0-2]?\d|3[0-1])$/.test(couleur)) {
return this.textColor(couleur);
}
} else if(Window_ScrollText.defaultColor == "object" && !reset) {
return Window_ScrollText.defaultColor;
}
return Window_Base.prototype.normalColor.call(this);
};
Bitmap.prototype.SphinxCSS_makeFontNameText = Bitmap.prototype._makeFontNameText;
Bitmap.prototype._makeFontNameText = function() {
if(typeof Yanfly != "undefined" && typeof Yanfly.Message != "undefined" && typeof Yanfly.Message.Bitmap_makeFontNameText != "undefined") {
return Bitmap.prototype.SphinxCSS_makeFontNameText.call(this);
}
return (this.fontBold ? "Bold " : "") + Bitmap.prototype.SphinxCSS_makeFontNameText.call(this);
};
Liste des commandes de plugin
ENREGISTRER_COULEUR ALIAS COULEUR
Où ALIAS est le nom de la couleur tel qu’utilisé ensuite dans les commandes de messages (ne doit contenir que des caractères alphanumériques) ; et COULEUR est la couleur correspondante, soit au format hexadécimal sur 6 chiffres, soit un nombre entre 0 et 31 correspondant à l’une des couleurs du windowskin.
ENREGISTRER_POLICE ALIAS CHEMIN_FICHIER
Où ALIAS est le nom de la police telle qu’elle sera utilisée ensuite ; et CHEMIN_FICHIER est le chemin vers le fichier de la police avec son extension, depuis l’intérieur du dossier fonts/ du jeu.
COULEUR_PAR_DEFAUT TYPE_MSG COULEUR
COULEUR_PAR_DEFAUT TYPE_MSG COULEUR1 COULEUR2
Où TYPE_MSG est soit message, pour modifier la couleur par défaut des messages, soit scrolltext pour modifier la couleur par défaut des textes défilants, soit both pour modifier la couleur par défaut des deux types de messages ; et où COULEUR (couleur unique), COULEUR1 et COULEUR2 (dégradé), est la couleur correspondante, soit au format hexadécimal sur 6 chiffres, soit un nombre entre 0 et 31 correspondant à l’une des couleurs du windowskin.
POLICE_PAR_DEFAUT TYPE_MSG POLICE
Où TYPE_MSG est soit message, pour modifier la couleur par défaut des messages, soit scrolltext pour modifier la couleur par défaut des textes défilants, soit both pour modifier la couleur par défaut des deux types de messages ; et où POLICE est l’alias de la police à utiliser.
ALIGNEMENT_PAR_DEFAUT TYPE_MSG ALIGNEMENT
Où TYPE_MSG est soit message, pour modifier la couleur par défaut des messages, soit scrolltext pour modifier la couleur par défaut des textes défilants, soit both pour modifier la couleur par défaut des deux types de messages ; et où ALIGNEMENT est soit left pour aligner par défaut le texte à gauche , soit center par défaut pour aligner le texte au centre, soit right par défaut pour aligner le texte à droite, soit justify par défaut pour justifier le texte.
Liste des commandes de messages
Ces commandes s’utilisent dans les messages des évènements, dans les textes défilants des évènements, et dans presque toutes les fenêtres héritant de la classe Window_Base.
\#FF
\#FF[FONT_NAME]
Où FONT_NAME est un alias de la police utilisée. Modifie la police de caractères du texte qui suit. Si FONT_NAME n’est pas précisé, restaure la police par défaut.
\#FS
\#FS[FONT_SIZE]
Où FONT_SIZE est la taille de la police. Modifie la taille de la police de caractère du texte qui suit. Si FONT_SIZE est omis, restaure la taille de la police par défaut.
\#LG[COULEUR1][COULEUR2]
Où COULEUR1 et COULEUR2 sont soit des alias de couleurs enregistrés précédemment, soit des couleurs au format hexadécimal, soit des nombres compris entre 0 et 31 correspondant à une des couleurs du windowskin. Colorie le texte en dégradé (une couleur par lettre) de gauche à droite.
\#EG
Termine un dégradé de couleur. Le texte qui suit retrouve la couleur par défaut.
\#TA[ALIGNEMENT]
Où ALIGNEMENT est soit left pour aligner par défaut le texte à gauche , soit center par défaut pour aligner le texte au centre, soit right par défaut pour aligner le texte à droite, soit justify par défaut pour justifier le texte.
\#UC
Transforme le texte qui suit en MAJUSCULE.
\#LC
Transforme le texte qui suit en minuscule.
\#CP
Met la première lettre de chaque mot en MAJUSCULE et le reste en minuscule.
\#NC
Met fin aux effets des commandes \#UC, \#LC et \#CP. Le texte qui suit ne sera plus transformé.
\#B
Met le texte qui suit en gras.
\#EB
Met fin à l’effet de la balise \#B. Le texte qui suit ne sera plus mis en gras.
\#C
\#C[COULEUR]
Où COULEUR est soit un alias de couleurs enregistrés précédemment, soit une couleur au format hexadécimal, soit un nombres compris entre 0 et 31 correspondant à une des couleurs du windowskin. Colorie le texte qui suit avec la couleur COULEUR. Si COULEUR est omis, applique la couleur par défaut.
\#I
Met le texte qui suit en italique.
\#EI
Met fin à l’effet de \#I. Le texte qui suit n’est plus mis en italique.
\#U
Souligne le texte.
\#EU
Met fin à l’effet de \#U. Le texte qui suit n’est plus souligné.
Problème de compatibilité avec le script SRD_ShakingText
Afin de faire fonctionner nos deux scripts ensemble, le script Sphinx-WB_CSS doit être placé avant le script SRD_ShakingText. Ensuite, le script ci-dessous doit être placé après le script SRD_ShakingText.
//=============================================================================
// SRD_ShakingText-Sphinx-WB_CSS.js
//=============================================================================
/*:
* @plugindesc Intégration du plugin Sphinx-WB_CSS dans SRD_ShakingText
* @author SumRndmDde/Sphinx
*
* @help
* //==========================================================================
* // Plugin : SRD_ShakingText-Sphinx-WB_CSS
* // Date : 14 janvier 2016
* // Auteur : SumRndmDde (SRD_ShakingText) / Sphinx (Sphinx-WB_CSS)
* //==========================================================================
*
* Ce plugin dépend et est partagé sous les mêmes conditions que Sphinx-WB_CSS
* c'est à dire sous licence Creative Commons CC BY 3.0
*
* Pour utiliser ce plugin, vous devez également vous conformer aux conditions
* d'utilisation de SumRndmDde (http://sumrndm.site/terms-of-use/)
*
* Ce plugin permet simplement d'adapter le plugin SRD_ShakingText pour
* permettre l'utilisation des deux plugins simultanément.
* Il doit être placé immédiatement après le plugin de SumRndmDde
*
* Il ne définit aucune nouvelle commande.
*
* Dépendances :
* - SRD_ShakingText de SumRndmDde
* - Sphinx-WB_CSS de Sphinx
*/
var SRD = SRD || {};
SRD.ShakingText = SRD.ShakingText || {};
(function(_) {
var _Window_Message_processNormalCharacter = Window_Message.prototype.processNormalCharacter;
Window_Message.prototype.processNormalCharacter = function(textState) {
if(this.isShakingActive() && !this._checkWordWrapMode) {
if(Imported.YEP_MessageCore && this.checkWordWrap(textState)) {
return this.processNewLine(textState);
}
if(typeof textState.gradient == "object") {
this.SphinxCSS_calculateGradientColor(textState);
}
this.contents.fontBold = textState.fontBold;
this.contents.fontItalic = textState.fontItalic;
var c = textState.text[textState.index++];
var w = this.textWidth(c);
var h = textState.height;
this.createShakingCharacter(textState, c, w, h);
if(textState.fontUnderline) {
if(c == " " && textState.justifyWidth && textState.justifyWidth < 0) {
this.contents.fillRect(textState.x, textState.y + textState.height - 4, w + textState.justifyWidth, 1, this.contents.outlineColor);
this.contents.fillRect(textState.x, textState.y + textState.height - 3, w + textState.justifyWidth, 2, this.contents.textColor);
this.contents.fillRect(textState.x, textState.y + textState.height - 1, w + textState.justifyWidth, 1, this.contents.outlineColor);
} else {
this.contents.fillRect(textState.x, textState.y + textState.height - 4, w, 1, this.contents.outlineColor);
this.contents.fillRect(textState.x, textState.y + textState.height - 3, w, 2, this.contents.textColor);
this.contents.fillRect(textState.x, textState.y + textState.height - 1, w, 1, this.contents.outlineColor);
}
}
textState.x += w;
if(c == " " && textState.justifyWidth) {
if(textState.fontUnderline && textState.justifyWidth > 0) {
this.contents.fillRect(textState.x, textState.y + textState.height - 4, textState.justifyWidth, 1, this.contents.outlineColor);
this.contents.fillRect(textState.x, textState.y + textState.height - 3, textState.justifyWidth, 2, this.contents.textColor);
this.contents.fillRect(textState.x, textState.y + textState.height - 1, textState.justifyWidth, 1, this.contents.outlineColor);
}
textState.x += textState.justifyWidth;
}
if(textState.fontUnderline && textState.text.slice(textState.index) == "") {
this.contents.fillRect(textState.x, textState.y + textState.height - 3, 1, 2, this.contents.outlineColor);
}
} else {
_Window_Message_processNormalCharacter.call(this, textState);
}
};
})(SRD.ShakingText);