290 lines
11 KiB
JavaScript
290 lines
11 KiB
JavaScript
/*:ja
|
||
* @target MZ
|
||
* @author kurogoma knights
|
||
* @plugindesc 上ファイルの修正パッチ フェードアウトでHUD消えてくれない問題の修正と、ズーム補正
|
||
*/
|
||
|
||
(() => {
|
||
'use strict';
|
||
|
||
//-----------------------------------------------------------------------------
|
||
// MOG_ActorHud 拡張:HUDをSpriteset内に再配置し、ズームを打ち消す
|
||
//-----------------------------------------------------------------------------
|
||
const _Scene_Base_createHudField = Scene_Base.prototype.createHudField;
|
||
Scene_Base.prototype.createHudField = function() {
|
||
// 元の処理を実行(HUD生成)
|
||
_Scene_Base_createHudField.call(this);
|
||
|
||
// 既にHUDフィールドが存在していれば再配置
|
||
if (this._hudField && this._spriteset && this._hudContainer) {
|
||
const index = this._spriteset.children.indexOf(this._hudContainer);
|
||
if (index >= 0) {
|
||
// いったん削除して指定位置に再追加
|
||
this._spriteset.removeChild(this._hudField);
|
||
this._spriteset.addChildAt(this._hudField, index + 1);
|
||
} else {
|
||
// 万が一見つからなければ末尾に追加
|
||
this._spriteset.addChild(this._hudField);
|
||
}
|
||
}
|
||
|
||
// --- ズーム打ち消し処理を付与 ---
|
||
const field = this._hudField;
|
||
if (field) {
|
||
const applyZoomFix = () => {
|
||
const zoom = $gameScreen.zoomScale();
|
||
field.scale.set(1 / zoom, 1 / zoom);
|
||
field._lastZoom = zoom;
|
||
};
|
||
|
||
// 初期化時に即適用(ちらつき防止)
|
||
applyZoomFix();
|
||
|
||
// 毎フレーム追従
|
||
const _update = field.update;
|
||
field.update = function() {
|
||
if (_update) _update.call(this);
|
||
const z = $gameScreen.zoomScale();
|
||
if (this._lastZoom !== z) {
|
||
this.scale.set(1 / z, 1 / z);
|
||
this._lastZoom = z;
|
||
}
|
||
};
|
||
}
|
||
};
|
||
|
||
// 既にフック済みなら何もしない
|
||
if (Actor_Hud.prototype._ahud_fix_sp_installed) return;
|
||
Actor_Hud.prototype._ahud_fix_sp_installed = true;
|
||
|
||
// 数字設定
|
||
//
|
||
Moghunter.ahud_sp_number_visible = true;
|
||
Moghunter.ahud_atk_number_visible = true;
|
||
Moghunter.ahud_def_number_visible = true;
|
||
Moghunter.ahud_agi_number_visible = true;
|
||
Moghunter.ahud_mhp_number_visible = true;
|
||
Moghunter.ahud_mmp_number_visible = true;
|
||
//
|
||
Moghunter.ahud_sp_number_pos_x = Number(Moghunter.ahud_level_number_pos_x) + 10;
|
||
Moghunter.ahud_sp_number_pos_y = Number(Moghunter.ahud_level_number_pos_y) - 30;
|
||
//
|
||
Moghunter.ahud_atk_number_pos_x = 100;
|
||
Moghunter.ahud_atk_number_pos_y = 20;
|
||
Moghunter.ahud_def_number_pos_x = Moghunter.ahud_atk_number_pos_x - 10;
|
||
Moghunter.ahud_def_number_pos_y = Moghunter.ahud_atk_number_pos_y + 30;
|
||
Moghunter.ahud_agi_number_pos_x = Moghunter.ahud_def_number_pos_x - 10;
|
||
Moghunter.ahud_agi_number_pos_y = Moghunter.ahud_def_number_pos_y + 30;
|
||
//
|
||
Moghunter.ahud_mhp_number_pos_x = 0;
|
||
Moghunter.ahud_mhp_number_pos_y = 0;
|
||
Moghunter.ahud_mmp_number_pos_x = 0;
|
||
Moghunter.ahud_mmp_number_pos_y = 0;
|
||
|
||
// create_sprites をフックして SP を生成
|
||
const _AH_create_sprites = Actor_Hud.prototype.create_sprites;
|
||
Actor_Hud.prototype.create_sprites = function() {
|
||
_AH_create_sprites.call(this);
|
||
this.create_bar();
|
||
this.create_sp_number();
|
||
this.create_atk_number();
|
||
this.create_def_number();
|
||
this.create_agi_number();
|
||
};
|
||
|
||
// フックして更新
|
||
const _AH_update_sprites = Actor_Hud.prototype.update_sprites;
|
||
Actor_Hud.prototype.update_sprites = function() {
|
||
_AH_update_sprites.call(this);
|
||
this.update_sp_number();
|
||
this.update_atk_number();
|
||
this.update_def_number();
|
||
this.update_agi_number();
|
||
};
|
||
|
||
// フックしてロード
|
||
const _AH_load_img = Actor_Hud.prototype.load_img;
|
||
Actor_Hud.prototype.load_img = function() {
|
||
_AH_load_img.call(this);
|
||
this._sp_number_img = ImageManager.loadAHud("SP_Number");
|
||
this._layout_bar_img = ImageManager.loadAHud("Layout_Bar");
|
||
// sp_numberを流用してる
|
||
this._atk_number_img = this._sp_number_img;
|
||
this._def_number_img = this._sp_number_img;
|
||
this._agi_number_img = this._sp_number_img;
|
||
}
|
||
|
||
// バー表示
|
||
Actor_Hud.prototype.create_bar = function() {
|
||
if (this._layout_bar) {
|
||
this.removeChild(this._layout_bar);
|
||
this._layout_bar.destroy();
|
||
this._layout_bar = null;
|
||
}
|
||
if (!this._battler) { return };
|
||
this._layout_bar = new Sprite(this._layout_bar_img);
|
||
this._layout_bar.x = this._pos_x;
|
||
this._layout_bar.y = this._pos_y;
|
||
let insertIndex = this.children.length;
|
||
if (this._hp_number && this._hp_number.length) {
|
||
let hpIndex = -1;
|
||
for (const sprite of this._hp_number) {
|
||
if (!sprite) continue;
|
||
const index = this.children.indexOf(sprite);
|
||
if (index >= 0 && index > hpIndex) {
|
||
hpIndex = index;
|
||
}
|
||
}
|
||
if (hpIndex >= 0) insertIndex = Math.min(hpIndex + 1, this.children.length);
|
||
}
|
||
this.addChildAt(this._layout_bar, insertIndex);
|
||
};
|
||
|
||
// create_sp_number 実装
|
||
Actor_Hud.prototype.create_sp_number = function() {
|
||
if (String(Moghunter.ahud_sp_number_visible) !== 'true') return;
|
||
if (this._sp_number) { for (let i = 0; i < this._sp_number.length; i++) { this.removeChild(this._sp_number[i]); } }
|
||
if (!this._battler) return;
|
||
|
||
this._sp_number = [];
|
||
this._sp_number.align = 1; // 中央
|
||
this._sp_img_data = [
|
||
this._sp_number_img.width,
|
||
this._sp_number_img.height,
|
||
this._sp_number_img.width / 10,
|
||
this._sp_number_img.height / 2,
|
||
this._pos_x + Number(Moghunter.ahud_sp_number_pos_x),
|
||
this._pos_y + Number(Moghunter.ahud_sp_number_pos_y)
|
||
];
|
||
|
||
for (let i = 0; i < 3; i++) {
|
||
this._sp_number[i] = new Sprite(this._sp_number_img);
|
||
this._sp_number[i].visible = false;
|
||
this._sp_number[i].x = this._sp_img_data[4];
|
||
this._sp_number[i].y = this._sp_img_data[5];
|
||
this.addChild(this._sp_number[i]);
|
||
}
|
||
|
||
const spv = Number($gameVariables.value(Kurogoma.VariableConst.UnassignedPoints) || 0);
|
||
this._sp_number_old = spv;
|
||
this.refresh_number(this._sp_number, this._sp_number_old, this._sp_img_data, this._sp_img_data[4], 1);
|
||
};
|
||
|
||
// create_atk_number: reuse SP_Number graphics
|
||
Actor_Hud.prototype.create_atk_number = function() {
|
||
if (!this._battler) return;
|
||
if (this._atk_number) { for (let i = 0; i < this._atk_number.length; i++) { this.removeChild(this._atk_number[i]); } }
|
||
this._atk_number = [];
|
||
this._atk_number.align = 1; // center
|
||
this._atk_img_data = [
|
||
this._atk_number_img.width,
|
||
this._atk_number_img.height,
|
||
this._atk_number_img.width / 10,
|
||
this._atk_number_img.height / 2,
|
||
this._pos_x + Number(Moghunter.ahud_atk_number_pos_x),
|
||
this._pos_y + Number(Moghunter.ahud_atk_number_pos_y)
|
||
];
|
||
for (let i = 0; i < 3; i++) {
|
||
this._atk_number[i] = new Sprite(this._atk_number_img);
|
||
this._atk_number[i].visible = false;
|
||
this._atk_number[i].x = this._atk_img_data[4];
|
||
this._atk_number[i].y = this._atk_img_data[5];
|
||
this.addChild(this._atk_number[i]);
|
||
}
|
||
this._atk_number_old = this._battler.atk;
|
||
this.refresh_number(this._atk_number, this._atk_number_old, this._atk_img_data, this._atk_img_data[4], 1);
|
||
};
|
||
|
||
Actor_Hud.prototype.create_def_number = function() {
|
||
if (!this._battler) return;
|
||
if (this._def_number) { for (let i = 0; i < this._def_number.length; i++) { this.removeChild(this._def_number[i]); } }
|
||
this._def_number = [];
|
||
this._def_number.align = 1;
|
||
this._def_img_data = [
|
||
this._def_number_img.width,
|
||
this._def_number_img.height,
|
||
this._def_number_img.width / 10,
|
||
this._def_number_img.height / 2,
|
||
this._pos_x + Number(Moghunter.ahud_def_number_pos_x),
|
||
this._pos_y + Number(Moghunter.ahud_def_number_pos_y)
|
||
];
|
||
for (let i = 0; i < 3; i++) {
|
||
this._def_number[i] = new Sprite(this._def_number_img);
|
||
this._def_number[i].visible = false;
|
||
this._def_number[i].x = this._def_img_data[4];
|
||
this._def_number[i].y = this._def_img_data[5];
|
||
this.addChild(this._def_number[i]);
|
||
}
|
||
this._def_number_old = this._battler.def;
|
||
this.refresh_number(this._def_number, this._def_number_old, this._def_img_data, this._def_img_data[4], 1);
|
||
};
|
||
|
||
Actor_Hud.prototype.create_agi_number = function() {
|
||
if (!this._battler) return;
|
||
if (this._agi_number) { for (let i = 0; i < this._agi_number.length; i++) { this.removeChild(this._agi_number[i]); } }
|
||
this._agi_number = [];
|
||
this._agi_number.align = 1;
|
||
this._agi_img_data = [
|
||
this._agi_number_img.width,
|
||
this._agi_number_img.height,
|
||
this._agi_number_img.width / 10,
|
||
this._agi_number_img.height / 2,
|
||
this._pos_x + Number(Moghunter.ahud_agi_number_pos_x),
|
||
this._pos_y + Number(Moghunter.ahud_agi_number_pos_y)
|
||
];
|
||
for (let i = 0; i < 3; i++) {
|
||
this._agi_number[i] = new Sprite(this._agi_number_img);
|
||
this._agi_number[i].visible = false;
|
||
this._agi_number[i].x = this._agi_img_data[4];
|
||
this._agi_number[i].y = this._agi_img_data[5];
|
||
this.addChild(this._agi_number[i]);
|
||
}
|
||
this._agi_number_old = this._battler.agi;
|
||
this.refresh_number(this._agi_number, this._agi_number_old, this._agi_img_data, this._agi_img_data[4], 1);
|
||
};
|
||
|
||
// update_sp_number 実装
|
||
Actor_Hud.prototype.update_sp_number = function() {
|
||
if (!this._sp_number) return;
|
||
const spv = Number($gameVariables.value(Kurogoma.VariableConst.UnassignedPoints) || 0);
|
||
const dif_number = this.update_dif(this._sp_number_old, spv, 30);
|
||
if (this._sp_number_old != dif_number) {
|
||
this._sp_number_old = dif_number;
|
||
this.refresh_number(this._sp_number, this._sp_number_old, this._sp_img_data, this._sp_img_data[4], 1);
|
||
}
|
||
};
|
||
|
||
// update_atk_number
|
||
Actor_Hud.prototype.update_atk_number = function() {
|
||
if (!this._atk_number) return;
|
||
const val = Number(this._battler.atk);
|
||
const dif_number = this.update_dif(this._atk_number_old, val, 30);
|
||
if (this._atk_number_old != dif_number) {
|
||
this._atk_number_old = dif_number;
|
||
this.refresh_number(this._atk_number, this._atk_number_old, this._atk_img_data, this._atk_img_data[4], 1);
|
||
}
|
||
};
|
||
|
||
// update_def_number
|
||
Actor_Hud.prototype.update_def_number = function() {
|
||
if (!this._def_number) return;
|
||
const val = Number(this._battler.def);
|
||
const dif_number = this.update_dif(this._def_number_old, val, 30);
|
||
if (this._def_number_old != dif_number) {
|
||
this._def_number_old = dif_number;
|
||
this.refresh_number(this._def_number, this._def_number_old, this._def_img_data, this._def_img_data[4], 1);
|
||
}
|
||
};
|
||
|
||
// update_agi_number
|
||
Actor_Hud.prototype.update_agi_number = function() {
|
||
if (!this._agi_number) return;
|
||
const val = Number(this._battler.agi);
|
||
const dif_number = this.update_dif(this._agi_number_old, val, 30);
|
||
if (this._agi_number_old != dif_number) {
|
||
this._agi_number_old = dif_number;
|
||
this.refresh_number(this._agi_number, this._agi_number_old, this._agi_img_data, this._agi_img_data[4], 1);
|
||
}
|
||
};
|
||
|
||
})();
|