Hi,
I'm using both of Yanfly's Item Core and Item Synthesis plugins.
I just want to replace the status window here in red with the status window here in yellow.
Any way I can do that?
---
I'm not good with JS at all, but here's what I tried doing so far:
In the Item Synthesis plugin, I tried to put in //comments the entirety of Window_SynthesisStatus, and then copy over Window_ItemStatus from the Item Core plugin by renaming it to "Window_SynthesisStatus" and every mention of ItemStatus to SynthesisStatus.
It sort of worked (I didn't get any error messages), except the window itself shows no information in-game when selecting/highlighting items to craft in the Synthesis menu.
So then I looked and noticed mentions of Window_Base in the "new" Window_SynthesisStatus, so I copied over Window_Base from the Item Core plugin into the Item Synthesis plugin, but that gave me an error on startup:
RangeError: Maximum call stack size exceeded
I'm not too bright, so I tried renaming all instances of Window_Base to something else, but instead of getting an error message on startup, I get one when opening the Synthesis menu in-game that reads:
TypeError: Cannot read property 'bind' of undefined
Does anyone have any tips or pointers as to how to make it work?
Any help is greatly appreciated. Thank you for your time.
I'm using both of Yanfly's Item Core and Item Synthesis plugins.
I just want to replace the status window here in red with the status window here in yellow.
Any way I can do that?
---
I'm not good with JS at all, but here's what I tried doing so far:
In the Item Synthesis plugin, I tried to put in //comments the entirety of Window_SynthesisStatus, and then copy over Window_ItemStatus from the Item Core plugin by renaming it to "Window_SynthesisStatus" and every mention of ItemStatus to SynthesisStatus.
It sort of worked (I didn't get any error messages), except the window itself shows no information in-game when selecting/highlighting items to craft in the Synthesis menu.
JavaScript:
//=============================================================================
// Window_SynthesisStatus
//=============================================================================
function Window_SynthesisStatus() {
this.initialize.apply(this, arguments);
}
Window_SynthesisStatus.prototype = Object.create(Window_Base.prototype);
Window_SynthesisStatus.prototype.constructor = Window_SynthesisStatus;
Window_SynthesisStatus.prototype.initialize = function(x, y, width, height) {
Window_Base.prototype.initialize.call(this, x, y, width, height);
this._item = null;
this.deactivate();
this.refresh();
};
Window_SynthesisStatus.prototype.setItem = function(item) {
if (this._item === item) return;
this._item = item;
this.refresh();
};
Window_SynthesisStatus.prototype.refresh = function() {
this.contents.clear();
this.drawDarkRectEntries();
if (!this._item) return;
this.contents.fontSize = Yanfly.Param.ItemFontSize;
this.drawItemEntry();
};
Window_SynthesisStatus.prototype.drawDarkRectEntries = function() {
var rect = new Rectangle();
if (Yanfly.Param.ItemShowIcon) {
rect.width = Window_Base._faceWidth;
rect.height = Window_Base._faceHeight;
this.drawDarkRect(rect.x, rect.y, rect.width, rect.height);
rect.width = (this.contents.width - Window_Base._faceWidth) / 2;
} else {
rect.width = this.contents.width / 2;
}
rect.height = this.lineHeight();
for (var i = 0; i < 8; ++i) {
rect = this.getRectPosition(rect, i);
this.drawDarkRect(rect.x, rect.y, rect.width, rect.height);
}
};
Window_SynthesisStatus.prototype.drawDarkRect = function(dx, dy, dw, dh) {
var color = this.gaugeBackColor();
this.changePaintOpacity(false);
this.contents.fillRect(dx + 1, dy + 1, dw - 2, dh - 2, color);
this.changePaintOpacity(true);
};
Window_SynthesisStatus.prototype.getRectPosition = function(rect, i) {
if (i % 2 === 0) {
if (Yanfly.Param.ItemShowIcon) {
rect.x = Window_Base._faceWidth;
} else {
rect.x = 0;
}
rect.y = i / 2 * this.lineHeight();
} else {
if (Yanfly.Param.ItemShowIcon) {
rect.x = Window_Base._faceWidth + rect.width;
} else {
rect.x = rect.width;
}
}
return rect;
};
Window_SynthesisStatus.prototype.drawItemEntry = function() {
var item = this._item;
if (Yanfly.Param.ItemShowIcon) this.drawItemIcon(item);
if (DataManager.isItem(item)) this.drawItemInfo(item);
if (DataManager.isWeapon(item)) this.drawEquipInfo(item);
if (DataManager.isArmor(item)) this.drawEquipInfo(item);
};
Window_SynthesisStatus.prototype.drawItemIcon = function() {
this.drawLargeIcon();
};
Window_SynthesisStatus.prototype.drawLargeIcon = function() {
var iconIndex = this._item.iconIndex;
var bitmap = ImageManager.loadSystem('IconSet');
var pw = Window_Base._iconWidth;
var ph = Window_Base._iconHeight;
var sx = iconIndex % 16 * pw;
var sy = Math.floor(iconIndex / 16) * ph;
var dw = Yanfly.Param.ItemIconSize;
var dh = Yanfly.Param.ItemIconSize;
var dx = (Window_Base._faceWidth - dw) / 2;
var dy = (Window_Base._faceHeight - dh) / 2;
this.contents._context.imageSmoothingEnabled = false;
this.contents.blt(bitmap, sx, sy, pw, ph, dx, dy, dw, dh);
this.contents._context.imageSmoothingEnabled = true;
};
Window_SynthesisStatus.prototype.drawEquipInfo = function(item) {
var rect = new Rectangle();
if (eval(Yanfly.Param.ItemShowIcon)) {
rect.width = (this.contents.width - Window_Base._faceWidth) / 2;
} else {
rect.width = this.contents.width / 2;
}
var order = [0, 1, 3, 5, 2, 6, 4, 7]; //new param order
for (var i = 0; i < 8; ++i) {
rect = this.getRectPosition(rect, i);
var dx = rect.x + this.textPadding();
var dw = rect.width - this.textPadding() * 2;
this.changeTextColor(this.systemColor());
this.drawText(TextManager.param(order[i]), dx, rect.y, dw);
this.changeTextColor(this.paramchangeTextColor(item.params[order[i]]));
var text = Yanfly.Util.toGroup(item.params[order[i]]);
if (item.params[order[i]] >= 0) text = '+' + text;
if (text === '+0') this.changePaintOpacity(false);
this.drawText(text, dx, rect.y, dw, 'right');
this.changePaintOpacity(true);
}
};
Window_SynthesisStatus.prototype.drawItemInfo = function(item) {
var rect = new Rectangle();
if (eval(Yanfly.Param.ItemShowIcon)) {
rect.width = (this.contents.width - Window_Base._faceWidth) / 2;
} else {
rect.width = this.contents.width / 2;
}
for (var i = 0; i < 8; ++i) {
rect = this.getRectPosition(rect, i);
var dx = rect.x + this.textPadding();
var dw = rect.width - this.textPadding() * 2;
this.changeTextColor(this.systemColor());
var text = this.getItemInfoCategory(i);
this.drawText(text, dx, rect.y, dw);
this.drawItemData(i, dx, rect.y, dw);
}
};
Window_SynthesisStatus.prototype.getItemInfoCategory = function(i) {
var fmt = Yanfly.Param.ItemRecoverFmt;
if (i === 0) return fmt.format(TextManager.param(0));
if (i === 1) return fmt.format(TextManager.hp);
if (i === 2) return fmt.format(TextManager.param(1));
if (i === 3) return fmt.format(TextManager.mp);
if (i === 4) return Yanfly.Param.ItemAddState;
if (i === 5) return Yanfly.Param.ItemRemoveState;
if (i === 6) return Yanfly.Param.ItemAddBuff;
if (i === 7) return Yanfly.Param.ItemRemoveBuff;
return '';
};
Window_SynthesisStatus.prototype.drawItemData = function(i, dx, dy, dw) {
if (!this._item) return;
var effect;
var value = '---';
var pre = '';
var text = '';
var icons = [];
if (i === 0) {
effect = this.getEffect(Game_Action.EFFECT_RECOVER_HP);
value = (effect) ? effect.value1 : '---';
if (value === 0) value = '---';
if (value !== '---' && value !== 0) value *= 100;
}
if (i === 1) {
effect = this.getEffect(Game_Action.EFFECT_RECOVER_HP);
value = (effect) ? effect.value2 : '---';
if (value === 0) value = '---';
}
if (i === 2) {
effect = this.getEffect(Game_Action.EFFECT_RECOVER_MP);
value = (effect) ? effect.value1 : '---';
if (value === 0) value = '---';
if (value !== '---' && value !== 0) value *= 100;
}
if (i === 3) {
effect = this.getEffect(Game_Action.EFFECT_RECOVER_MP);
value = (effect) ? effect.value2 : '---';
if (value === 0) value = '---';
}
if (i >= 4) {
icons = this.getItemIcons(i, icons);
}
this.changeTextColor(this.normalColor());
if (value === '---') {
this.changePaintOpacity(false);
} else if (i < 4) {
if (value > 0) pre = '+';
value = Yanfly.Util.toGroup(parseInt(value));
if ([0, 2].contains(i)) text = '%';
}
if (icons.length > 0) {
this.changePaintOpacity(true);
dx = dx + dw - icons.length * Window_Base._iconWidth;
dx += this.textPadding() - 2;
for (var j = 0; j < icons.length; ++j) {
var icon = icons[j];
this.drawIcon(icon, dx, dy + 2);
dx += Window_Base._iconWidth;
}
} else {
text = pre + value + text;
this.drawText(text, dx, dy, dw, 'right');
this.changePaintOpacity(true);
}
};
Window_SynthesisStatus.prototype.getEffect = function(code) {
var targetEffect;
this._item.effects.forEach(function(effect) {
if (effect.code === code) targetEffect = effect;
}, this);
return targetEffect;
};
Window_SynthesisStatus.prototype.getItemIcons = function(i, array) {
this._item.effects.forEach(function(effect) {
if (i === 4 && effect.code === Game_Action.EFFECT_ADD_STATE) {
var state = $dataStates[effect.dataId];
if (state && state.iconIndex !== 0) array.push(state.iconIndex);
}
if (i === 5 && effect.code === Game_Action.EFFECT_REMOVE_STATE) {
var state = $dataStates[effect.dataId];
if (state && state.iconIndex !== 0) array.push(state.iconIndex);
}
if (i === 6 && effect.code === Game_Action.EFFECT_ADD_BUFF) {
var icon = Game_BattlerBase.ICON_BUFF_START + effect.dataId;
array.push(icon);
}
if (i === 6 && effect.code === Game_Action.EFFECT_ADD_DEBUFF) {
var icon = Game_BattlerBase.ICON_DEBUFF_START + effect.dataId;
array.push(icon);
}
if (i === 7 && effect.code === Game_Action.EFFECT_REMOVE_BUFF) {
var icon = Game_BattlerBase.ICON_BUFF_START + effect.dataId;
array.push(icon);
}
if (i === 7 && effect.code === Game_Action.EFFECT_REMOVE_DEBUFF) {
var icon = Game_BattlerBase.ICON_DEBUFF_START + effect.dataId;
array.push(icon);
}
}, this);
array = array.slice(0, Yanfly.Param.ItemMaxIcons);
return array;
};
So then I looked and noticed mentions of Window_Base in the "new" Window_SynthesisStatus, so I copied over Window_Base from the Item Core plugin into the Item Synthesis plugin, but that gave me an error on startup:
RangeError: Maximum call stack size exceeded
JavaScript:
//=============================================================================
// Window_Base
//=============================================================================
Yanfly.Item.Window_Base_drawItemName = Window_Base.prototype.drawItemName;
Window_Base.prototype.drawItemName = function(item, wx, wy, ww) {
ww = ww || 312;
this.setItemTextColor(item);
Yanfly.Item.Window_Base_drawItemName.call(this, item, wx, wy, ww);
this._resetTextColor = undefined;
this.resetTextColor();
};
Window_Base.prototype.setItemTextColor = function(item) {
if (!item) return;
if (item.textColor === undefined) return;
this._resetTextColor = item.textColor;
};
Yanfly.Item.Window_Base_normalColor = Window_Base.prototype.normalColor;
Window_Base.prototype.normalColor = function() {
if (this._resetTextColor !== undefined) {
return this.textColor(this._resetTextColor);
}
return Yanfly.Item.Window_Base_normalColor.call(this);
};
I'm not too bright, so I tried renaming all instances of Window_Base to something else, but instead of getting an error message on startup, I get one when opening the Synthesis menu in-game that reads:
TypeError: Cannot read property 'bind' of undefined
Does anyone have any tips or pointers as to how to make it work?
Any help is greatly appreciated. Thank you for your time.