Modify Winow_BattleStatus

修改 WIndow_BattleStatus 来符合需求。
main
xian18 2 years ago
parent d356f5527c
commit 788c68df4f
Signed by: SaltedFish
GPG Key ID: B0C26448E9EF40CA

@ -20,6 +20,32 @@ var SF_Plugins = SF_Plugins || {};
SF_Windows.version = 1.0;
//=============================================================================
// Window_Base
//=============================================================================
Window_Base.prototype.drawGaugeVertical = function (dx, dy, dh, rate, color1, color2, color3) {
dx = Math.floor(dx);
dy = Math.floor(dy);
dh = Math.floor(dh);
var color3 = this.gaugeBackColor();
var fillH = Math.floor(dh * rate).clamp(0, dh);
var gaugeW = this.gaugeHeight();
var gaugeX = dx + this.lineHeight() - gaugeW - 2;
if (Yanfly && Yanfly.Param && Yanfly.Param.GaugeOutline) {
color3 = this.translucentOpacity();
this.contents.fillRect(gaugeX - 1, dy, gaugeW, dh, color3);
fillH = Math.max(fillH - 2, 0);
gaugeW -= 2;
dy -= 1;
} else {
var fillH = Math.floor(dh * rate);
var gaugeX = dx + this.lineHeight() - gaugeW - 2;
this.contents.fillRect(gaugeX, dy, gaugeW, dh, color3);
}
this.contents.gradientFillRect(gaugeX, dy + dh - fillH, gaugeW, fillH, color1, color2);
};
//=============================================================================
// Window_SFBase
//=============================================================================
@ -40,34 +66,33 @@ var SF_Plugins = SF_Plugins || {};
var width = this.windowWidth();
var height = this.windowHeight();
Window_Base.prototype.initialize.call(this, x, y, width, height);
}
};
Window_SFBase.prototype.windowWidth = function () {
return Graphics.boxWidth;// overwrite this
}
return Graphics.boxWidth; // overwrite this
};
Window_SFBase.prototype.windowHeight = function () {
return Graphics.boxHeight;// overwrite this
}
return Graphics.boxHeight; // overwrite this
};
Window_SFBase.prototype.windowX = function () {
return 0;// overwrite this
}
return 0; // overwrite this
};
Window_SFBase.prototype.windowY = function () {
return 0;// overwrite this
}
return 0; // overwrite this
};
Window_SFBase.prototype.canUpdate = function () {
return this.active && this.visible && this.worldVisible;
}
};
Window_SFBase.prototype.containsPoint = function (point) {
var x = this.canvasToLocalX(point.x);
var y = this.canvasToLocalY(point.y);
return x >= 0 && y >= 0 && x < this.width && y < this.height;
}
};
//=============================================================================
// Window_PagingBase
@ -96,59 +121,59 @@ var SF_Plugins = SF_Plugins || {};
this.createPageNumber();
this.setItemList(this.makeItemList());
this._state = 'pointer-out';// pointer-out, pointer-over, pointer-down
this._state = "pointer-out"; // pointer-out, pointer-over, pointer-down
this._pointerIndex = -1;
}
};
Window_PagingBase.prototype.standardPadding = function () {
return 0;
}
};
Window_PagingBase.prototype.itemWidth = function () {
// overwrite this
return 0;
}
};
Window_PagingBase.prototype.itemHeight = function () {
// overwrite this
return 0;
}
};
Window_PagingBase.prototype.maxCols = function () {
// overwrite this
return 1;
}
};
Window_PagingBase.prototype.maxRows = function () {
// overwrite this
return 1;
}
};
Window_PagingBase.prototype.maxPageItems = function () {
return this.maxCols() * this.maxRows();
}
};
Window_PagingBase.prototype.maxItems = function () {
return this._itemList.length;
}
};
Window_PagingBase.prototype.itemPadding = function () {
// overwrite this
return new Point(0, 0);
}
};
Window_PagingBase.prototype.itemStartPosition = function () {
// overwrite this
return new Point(0, 0);
}
};
Window_PagingBase.prototype.itemPaddingWidth = function () {
return this.itemPadding().x;
}
};
Window_PagingBase.prototype.itemPaddingHeight = function () {
return this.itemPadding().y;
}
};
Window_PagingBase.prototype.itemRect = function (index) {
var maxPageItems = this.maxPageItems();
@ -162,56 +187,56 @@ var SF_Plugins = SF_Plugins || {};
var startPosition = this.itemStartPosition();
rect.width = itemWidth;
rect.height = itemHeight;
rect.x = index % maxCols * (itemWidth + itemPaddingWidth) + startPosition.x;
rect.x = (index % maxCols) * (itemWidth + itemPaddingWidth) + startPosition.x;
rect.y = Math.floor(index / maxCols) * (itemHeight + itemPaddingHeight) + startPosition.y;
return rect;
}
};
Window_PagingBase.prototype.pageUpPosition = function () {
// overwrite this
return new Point(0, 0);
}
};
Window_PagingBase.prototype.pageUpBitmap = function () {
// overwrite this
var bitmap = new Bitmap(32, 32);
bitmap.fillAll('white');
return { "cold": bitmap, "hot": bitmap };
}
bitmap.fillAll("white");
return { cold: bitmap, hot: bitmap };
};
Window_PagingBase.prototype.pageDownPosition = function () {
// overwrite this
return new Point(0, 0);
}
};
Window_PagingBase.prototype.pageDownBitmap = function () {
// overwrite this
var bitmap = new Bitmap(32, 32);
bitmap.fillAll('white');
return { "cold": bitmap, "hot": bitmap };
}
bitmap.fillAll("white");
return { cold: bitmap, hot: bitmap };
};
Window_PagingBase.prototype.isShowPageButton = function () {
return true;
}
};
Window_PagingBase.prototype.isShowPageNumber = function () {
return true;
}
};
Window_PagingBase.prototype.pageNumberPosition = function () {
// overwrite this
return new Point(0, 0);
}
};
Window_PagingBase.prototype.pageNumberStyle = function () {
return new PIXI.TextStyle();
}
};
Window_PagingBase.prototype.updatePageNumber = function (text, pageIndex, pageCount) {
// overwrite this
text.text = `${pageIndex + 1}/${pageCount}`;
}
};
Window_PagingBase.prototype.createPageButtons = function () {
var bitmaps = null;
@ -239,46 +264,46 @@ var SF_Plugins = SF_Plugins || {};
this.addChild(this._pageUpButton);
this.addChild(this._pageDownButton);
}
};
Window_PagingBase.prototype.createPageNumber = function () {
var style = this.pageNumberStyle();
var position = this.pageNumberPosition();
this._pageIndexText = new PIXI.Text('', style);
this._pageIndexText = new PIXI.Text("", style);
this._pageIndexText.anchor.set(0.5, 0.5);
this._pageIndexText.position.set(position.x, position.y);
this._pageIndexText.visible = false;
this.addChild(this._pageIndexText);
}
};
Window_PagingBase.prototype.makeItemList = function () {
// overwrite this
return [];
}
};
Window_PagingBase.prototype.setItemList = function (itemList) {
this._itemList = itemList;
this._pageMax = Math.ceil(this._itemList.length / this.maxPageItems());
this._pageIndex = 0;
// this.refresh();
}
};
Window_PagingBase.prototype.setPageIndex = function (pageIndex) {
this._pageIndex = pageIndex.clamp(0, this._pageMax);
this.refresh();
}
};
Window_PagingBase.prototype.refresh = function () {
this.refreshItem();
this.refreshPageNumber();
this.refreshPageButton();
this.setStateToItem(-1, 'pointer-out');
}
this.setStateToItem(-1, "pointer-out");
};
Window_PagingBase.prototype.refreshItem = function () {
this.contents.clear();
this.drawAllItems();
}
};
Window_PagingBase.prototype.refreshPageNumber = function () {
if (!this.isShowPageNumber()) return;
@ -286,7 +311,7 @@ var SF_Plugins = SF_Plugins || {};
var pageIndex = this._pageIndex;
var pageCount = this._pageMax;
this.updatePageNumber(text, pageIndex, pageCount);
}
};
Window_PagingBase.prototype.refreshPageButton = function () {
if (!this.isShowPageButton()) return;
@ -299,16 +324,15 @@ var SF_Plugins = SF_Plugins || {};
if (!pageUpButton.visible) pageUpButton.releasePointer();
if (!pageDownButton.visible) pageDownButton.releasePointer();
}
};
Window_PagingBase.prototype.onPageUpButtonClick = function () {
this.setPageIndex(this._pageIndex - 1);
}
};
Window_PagingBase.prototype.onPageDownButtonClick = function () {
this.setPageIndex(this._pageIndex + 1);
}
};
Window_PagingBase.prototype.drawAllItems = function () {
var index = this._pageIndex * this.maxPageItems();
@ -316,25 +340,25 @@ var SF_Plugins = SF_Plugins || {};
for (var i = 0; i < maxItems; i++) {
this.drawItem(index + i);
}
}
};
Window_PagingBase.prototype.getItem = function (index) {
return this._itemList[index];
}
};
Window_PagingBase.prototype.drawItem = function (index) {
// overwrite this
}
};
Window_PagingBase.prototype.update = function () {
if (this.canUpdate()) {
Window_Base.prototype.update.call(this);
if (this._state !== 'pointer-out') {
if (this._state !== "pointer-out") {
this.onItemPointerOver(this._pointerIndex);
}
this.updatePointer();
}
}
};
Window_PagingBase.prototype.updatePointer = function () {
var pointer = this.getPointer();
@ -359,13 +383,12 @@ var SF_Plugins = SF_Plugins || {};
} else {
pointer.setUser(this);
}
}
}
};
Window_PagingBase.prototype.setPointerIndex = function (index, pointer) {
if (this._pointerIndex !== index) {
this.setStateToItem(index, 'pointer-over');
this.setStateToItem(index, "pointer-over");
}
if (index === -1) {
return;
@ -373,27 +396,26 @@ var SF_Plugins = SF_Plugins || {};
var events = pointer.getEvents();
for (var i = 0; i < events.length; i++) {
var event = events[i];
if (event === 'pointer-down') {
this.setStateToItem(index, 'pointer-down');
} else if (event === 'pointer-up') {
this.setStateToItem(index, 'pointer-over');
} else if (event === 'pointer-cancel') {
this.setStateToItem(index, 'pointer-out');
}
if (event === "pointer-down") {
this.setStateToItem(index, "pointer-down");
} else if (event === "pointer-up") {
this.setStateToItem(index, "pointer-over");
} else if (event === "pointer-cancel") {
this.setStateToItem(index, "pointer-out");
}
}
};
Window_PagingBase.prototype.setStateToItem = function (index, state) {
if (index !== this._pointerIndex && this._pointerIndex !== -1) {
if (this._state === 'pointer-down') {
this._state = 'pointer-over';
if (this._state === "pointer-down") {
this._state = "pointer-over";
this.onItemPointerUp(this._pointerIndex);
}
if (this._state === 'pointer-over') {
this._state = 'pointer-out';
if (this._state === "pointer-over") {
this._state = "pointer-out";
this.onItemPointerLeave(this._pointerIndex);
}
}
this._pointerIndex = index;
@ -401,69 +423,67 @@ var SF_Plugins = SF_Plugins || {};
return;
}
if (state === 'pointer-out') {
if (this._state === 'pointer-down') {
this._state = 'pointer-over';
if (state === "pointer-out") {
if (this._state === "pointer-down") {
this._state = "pointer-over";
this.onItemPointerUp(this._pointerIndex);
}
if (this._state === 'pointer-over') {
this._state = 'pointer-out';
if (this._state === "pointer-over") {
this._state = "pointer-out";
this.onItemPointerLeave(this._pointerIndex);
}
} else if (state === 'pointer-down') {
if (this._state === 'pointer-out') {
this._state = 'pointer-over';
} else if (state === "pointer-down") {
if (this._state === "pointer-out") {
this._state = "pointer-over";
this.onItemPointerEnter(this._pointerIndex);
}
if (this._state === 'pointer-over') {
this._state = 'pointer-down';
if (this._state === "pointer-over") {
this._state = "pointer-down";
this.onItemPointerDown(this._pointerIndex);
}
} else if (state === 'pointer-over') {
if (this._state === 'pointer-out') {
this._state = 'pointer-over';
} else if (state === "pointer-over") {
if (this._state === "pointer-out") {
this._state = "pointer-over";
this.onItemPointerEnter(this._pointerIndex);
}
if (this._state === 'pointer-down') {
this._state = 'pointer-over';
if (this._state === "pointer-down") {
this._state = "pointer-over";
this.onItemPointerUp(this._pointerIndex);
this.onItemClick(this._pointerIndex);
}
}
}
};
Window_PagingBase.prototype.onItemPointerDown = function (index) {
// overwrite this
}
};
Window_PagingBase.prototype.onItemPointerUp = function (index) {
// overwrite this
}
};
Window_PagingBase.prototype.onItemPointerMove = function (index) {
// overwrite this
}
};
Window_PagingBase.prototype.onItemPointerOver = function (index) {
// overwrite this
}
};
Window_PagingBase.prototype.onItemPointerEnter = function (index) {
// overwrite this
}
};
Window_PagingBase.prototype.onItemPointerLeave = function (index) {
// overwrite this
}
};
Window_PagingBase.prototype.onItemClick = function (index) {
// overwrite this
}
};
Window_PagingBase.prototype.releasePointer = function () {
Window_SFBase.prototype.releasePointer.call(this);
this.setStateToItem(-1, 'pointer-out');
}
this.setStateToItem(-1, "pointer-out");
};
})();

@ -464,6 +464,17 @@ Window_ActorCommand.prototype.processCancel = function () {
//=============================================================================
// Window_BattleStatus
//=============================================================================
Yanfly.BSW.Window_BattleStatus_initialize = Window_BattleStatus.prototype.initialize;
Window_BattleStatus.prototype.initialize = function () {
this._guageHeight = Imported.YEP_CoreEngine ? this.gaugeHeight() : 6;
this._guageHeight = Math.max(16, this._guageHeight);
this._actorsStateIcon = []; // [index] = [nextRenderStartIndex ,icons]
this._actorsStateIconMaxTick = 90;
this._actorsStateIconCurrentTick = 0;
this._actorsStateIconNum = 4;
Yanfly.BSW.Window_BattleStatus_initialize.call(this);
};
Window_BattleStatus.prototype.windowWidth = function () {
return Graphics.boxWidth;
};
@ -528,49 +539,90 @@ Window_BattleStatus.prototype.itemHeight = function () {
Window_BattleStatus.prototype.drawItem = function (index) {
var actor = $gameParty.battleMembers()[index];
this.drawBasicArea(this.basicAreaRect(index), actor);
this.drawGaugeArea(this.gaugeAreaRect(index), actor);
this.drawStateArea(this.basicAreaRect(index), actor);
};
var rect = this.itemRectForText(index);
Window_BattleStatus.prototype.drawBasicArea = function (rect, actor) {
if (Imported.YEP_X_BattleSysATB && Yanfly.Param.ATBGaugeStyle) {
if (BattleManager.isATB()) {
var atb_rect = this.gaugeAreaRect(0);
this.drawActorAtbGauge(actor, rect.x, atb_rect.y + atb_rect.height - this.lineHeight(), rect.width);
}
}
var iw = Window_Base._iconWidth;
this.drawActorActionIcon(actor, rect.x, rect.y);
this.resetFontSettings();
this.contents.fontSize = Yanfly.Param.BSWNameFontSize;
this.drawActorName(actor, rect.x + iw + 4, rect.y, rect.width);
};
this.drawGuages(index, actor);
// this.drawActorActionIcon(actor, rect.x + rect.width - Window_Base._iconWidth, rect.y);
Window_BattleStatus.prototype.basicAreaRect = function (index) {
var rect = this.itemRectForText(index);
rect.height = this.lineHeight() * 2;
return rect;
this._actorsStateIcon[index] = [0, actor.allIcons()];
this.drawActorIcons(index);
};
Window_BattleStatus.prototype.drawGaugeArea = function (rect, actor) {
Window_BattleStatus.prototype.drawGuages = function (index, actor) {
this.contents.fontSize = Yanfly.Param.BSWParamFontSize;
this._enableYBuffer = true;
var wy = rect.y + rect.height - this.lineHeight();
var wymod = Imported.YEP_CoreEngine ? Yanfly.Param.GaugeHeight : 6;
var wymod = Math.max(16, wymod);
this.drawActorHp(actor, rect.x, wy - wymod * 2, rect.width);
var tpRect = this.tpGaugeRect(index, actor);
var hpRect = this.hpGaugeRect(index, actor);
var mpRect = this.mpGaugeRect(index, actor);
var atbRect = this.atbGaugeRect(index, actor);
this.drawActorHp(actor, hpRect.x, hpRect.y, hpRect.width);
if (this.getGaugesDrawn(actor) <= 2) {
this.drawActorMp(actor, rect.x, wy, rect.width);
this.drawActorMp(actor, mpRect.x, mpRect.y, mpRect.width);
} else {
var ww = Math.floor(rect.width / 2);
var pad = rect.width - ww * 2;
this.drawActorMp(actor, rect.x, wy - wymod, ww);
this.drawActorTp(actor, rect.x + ww + pad, wy - wymod, ww);
this.drawActorMp(actor, mpRect.x, mpRect.y, mpRect.width);
this.drawActorTp(actor, tpRect.x, tpRect.y, tpRect.width);
}
this.drawActorAtbGaugeVertical(actor, atbRect.x, atbRect.y, atbRect.height);
this._enableYBuffer = false;
};
Window_BattleStatus.prototype.tpGaugeRect = function (index) {
var rect = this.itemRectForText(index);
rect.width -= Window_Base._iconWidth;
rect.height = this._guageHeight;
return rect;
};
Window_BattleStatus.prototype.hpGaugeRect = function (index) {
var rect = this.itemRectForText(index);
rect.y = rect.height - this.lineHeight() - this._guageHeight * 2 - (this.lineHeight() - this._guageHeight);
rect.height = this._guageHeight;
rect.width = rect.width - this.lineHeight();
return rect;
};
Window_BattleStatus.prototype.mpGaugeRect = function (index) {
var rect = this.itemRectForText(index);
rect.y = rect.height - this.lineHeight() - this._guageHeight * 1 - (this.lineHeight() - this._guageHeight);
rect.height = this._guageHeight;
rect.width = rect.width - this.lineHeight();
return rect;
};
Window_BattleStatus.prototype.atbGaugeRect = function (index) {
var rect = this.itemRectForText(index);
rect.x = rect.x + rect.width - this.lineHeight();
rect.y = this.lineHeight();
rect.width = this._guageHeight;
rect.height = rect.height - this.lineHeight();
return rect;
};
Window_BattleStatus.prototype.stateAreaRect = function (index) {
var rect = this.itemRectForText(index);
rect.y = rect.height - this.lineHeight();
rect.height = Window_Base._iconHeight;
rect.width = rect.width - this.lineHeight();
return rect;
};
Window_BattleStatus.prototype.drawBasicArea = function (rect, actor) {
if (Imported.YEP_X_BattleSysATB && Yanfly.Param.ATBGaugeStyle && BattleManager.isATB()) {
this.drawActorAtbGaugeVertical(actor, rect.x, rect.y, rect.height);
}
};
Window_BattleStatus.prototype.basicAreaRect = function (index) {
if (Imported.YEP_X_BattleSysATB && Yanfly.Param.ATBGaugeStyle && BattleManager.isATB()) {
return this.atbGaugeRect(index);
}
};
Window_BattleStatus.prototype.drawStateArea = function (rect, actor) {
var row = Yanfly.Param.BSWStateIconRow;
if (row === undefined) row = 1;
@ -584,13 +636,6 @@ Window_BattleStatus.prototype.getGaugesDrawn = function (actor) {
return value;
};
Window_BattleStatus.prototype.gaugeAreaRect = function (index) {
var rect = this.itemRectForText(index);
rect.height = this.contents.height - this.lineHeight() * 3;
rect.y = this.contents.height - rect.height;
return rect;
};
Window_BattleStatus.prototype.drawStatusFace = function (index) {
var actor = $gameParty.battleMembers()[index];
var rect = this.itemRect(index);
@ -685,6 +730,79 @@ Window_BattleStatus.prototype._refreshCursor = function () {
bitmap.fillAll("rgba(250, 250, 240, 0.6)");
};
Yanfly.BSW.Window_BattleStatus_update = Window_BattleStatus.prototype.update;
Window_BattleStatus.prototype.update = function () {
Yanfly.BSW.Window_BattleStatus_update.call(this);
this.updateStateIcons();
};
Window_BattleStatus.prototype.updateStateIcons = function () {
this._actorsStateIconCurrentTick++;
if (this._actorsStateIconCurrentTick < this._actorsStateIconMaxTick) return;
this._actorsStateIconCurrentTick = 0;
for (var index = 0; index < $gameParty.battleMembers().length; index++) {
this.drawActorIcons(index);
}
};
Window_BattleStatus.prototype.drawActorIcons = function (index) {
var startIcons = this._actorsStateIcon[index][0];
var icons = this._actorsStateIcon[index][1];
var rect = this.stateAreaRect(index);
this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);
if (icons.length <= 0) {
return;
}
var iconWidth = Window_Base._iconWidth;
var x = rect.x + 2;
var y = rect.y;
for (var i = 0; i < this._actorsStateIconNum; i++) {
if (icons[i + startIcons] === undefined) continue;
var icon = icons[i + startIcons];
this.drawIcon(icon, x, y);
x += iconWidth;
}
this._actorsStateIcon[index][0] += this._actorsStateIconNum;
if (this._actorsStateIcon[index][0] >= icons.length) {
this._actorsStateIcon[index][0] = 0;
}
};
Window_BattleStatus.prototype.drawActorTp = function (actor, x, y, width) {
this.changeTextColor(this.systemColor());
this.drawText(TextManager.tpA, x, y, 44);
this.changeTextColor(this.tpColor(actor));
this.drawText(actor.tp, x + 50, y, 64, "left");
};
Window_BattleStatus.prototype.drawActorAtbGaugeVertical = function (actor, wx, wy, wh) {
wh = wh || 96;
if (!actor) return;
var color1 = this.atbGaugeColor1(actor);
var color2 = this.atbGaugeColor2(actor);
if (actor.atbRate() < 1) {
var rate = actor.atbRate();
} else if (actor.atbRate() >= 1 && actor.atbChargeRate() >= 0) {
var rate = 1;
} else {
var rate = 0;
}
this.drawGaugeVertical(wx, wy, wh, rate, color1, color2);
if (actor.atbChargeRate() > 0) this.drawAtbChargeGaugeVertical(actor, wx, wy, wh);
};
Window_BattleStatus.prototype.drawAtbChargeGaugeVertical = function (actor, wx, wy, wh) {
var color1 = this.textColor(Yanfly.Param.ATBColorChar1);
var color2 = this.textColor(Yanfly.Param.ATBColorChar2);
var rate = actor.atbChargeRate();
this.drawGaugeVertical(wx, wy, wh * rate, 1, color1, color2);
};
//=============================================================================
// Scene_Battle
//=============================================================================

Loading…
Cancel
Save