赞 | 1 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 0 |
最后登录 | 2025-5-13 |
在线时间 | 7 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 66
- 在线时间
- 7 小时
- 注册时间
- 2025-4-29
- 帖子
- 8
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
做了一个这个插件,感觉对对话类游戏非常有用。
支持不同角色名字的对话框/ 名字框自定义颜色;还支持非角色的对话框的自定义颜色,非常好用,直接在编辑器里写名字即可。
代码有点长,在这里:
https://sekishiyo.itch.io/
https://github.com/SekiShiyo/RMMZ/tree/main/DialogueTint
/*:
* @target MZ
* @plugindesc Speaker-based message and name window background color v1.6 (no flash, preserves skin) by SekiShiyo
* @author SekiShiyo
*
* @param SpeakerColors
* @text Speaker Color Config
* @type struct<ColorConfig>[]
* @desc Set background colors for specific speakers
*
* @param DefaultColor
* @text Default Background Color
* @type string
* @default rgba(0,0,0,0.3)
* @desc Used when no speaker name matches; supports transparency
*
* @help
* ✅ Keeps default window skin and border
* ✅ Prevents white flash on name window open/close
* ✅ Auto-hides background if no speaker name is shown
*/
/*~struct~ColorConfig:
* @param name
* @text Speaker Name
* @type string
*
* @param color
* @text Background Color (RGBA)
* @type string
* @default rgba(0,0,0,180)
*/
(() => {
const pluginName = "SpeakerWindowColor";
const params = PluginManager.parameters(pluginName);
const colorConfigs = JSON.parse(params["SpeakerColors"] || "[]").map(str => {
const obj = JSON.parse(str);
return { name: obj.name, color: obj.color };
});
const defaultColor = params["DefaultColor"] || "rgba(0,0,0,0.3)";
function parseCssColor(text) {
const vals = text.replace(/\s+/g, "").replace(/^rgba?\(/i, "").replace(/\)$/, "").split(",");
if (vals.length >= 3) {
const r = parseInt(vals[0]);
const g = parseInt(vals[1]);
const b = parseInt(vals[2]);
let a = parseFloat(vals[3] ?? "255");
if (a > 1) a = a / 255;
return `rgba(${r},${g},${b},${a.toFixed(3)})`;
}
return text;
}
// ✅ Message window background
const _Window_Message_startMessage = Window_Message.prototype.startMessage;
Window_Message.prototype.startMessage = function () {
const name = $gameMessage.speakerName();
const match = colorConfigs.find(cfg => cfg.name === name);
const color = match ? parseCssColor(match.color) : parseCssColor(defaultColor);
if (!this._customBgSprite) {
this._customBgSprite = new Sprite(new Bitmap(this.width, this.height));
this._customBgSprite.z = -1;
this.addChildToBack(this._customBgSprite);
}
const bmp = this._customBgSprite.bitmap;
bmp.resize(this.width, this.height);
bmp.clear();
bmp.fillRect(0, 0, this.width, this.height, color);
_Window_Message_startMessage.call(this);
};
// ✅ Name box with no flash and window skin
const _Window_NameBox_start = Window_NameBox.prototype.start;
Window_NameBox.prototype.start = function () {
const name = $gameMessage.speakerName();
const showBg = name && name.trim();
this._lastSpeakerName = name;
if (this._customNameBg) {
this.removeChild(this._customNameBg);
this._customNameBg.destroy();
this._customNameBg = null;
}
_Window_NameBox_start.call(this); // ← run system layout first
if (showBg && this.width > 0 && this.height > 0) {
const match = colorConfigs.find(cfg => cfg.name === name);
const color = match ? parseCssColor(match.color) : parseCssColor(defaultColor);
const bmp = new Bitmap(this.width, this.height);
bmp.fillRect(0, 0, this.width, this.height, color);
this._customNameBg = new Sprite(bmp);
this._customNameBg.z = -2;
this.addChildToBack(this._customNameBg);
}
if (this.contentsBack) {
this.contentsBack.clear(); // |
评分
-
查看全部评分
|