-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathLeTBS_EntityHud.js
150 lines (128 loc) · 4.88 KB
/
LeTBS_EntityHud.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
#=============================================================================
# LeTBS: Entity Hud
# LeTBS_EntityHud.js
# By Lecode
# Version 1.0
#-----------------------------------------------------------------------------
# TERMS OF USE
#-----------------------------------------------------------------------------
# https://github.com/LecodeMV/leTBS/blob/master/LICENSE.txt
#-----------------------------------------------------------------------------
# Version History
#-----------------------------------------------------------------------------
# - 1.0 : Initial release
#=============================================================================
*/
var Lecode = Lecode || {};
Lecode.S_TBS.EntityHud = {};
/*:
* @plugindesc Draw a mini hud for each entity
* @author Lecode
* @version 1.0
*
* @help
* ...
*/
//#=============================================================================
/*-------------------------------------------------------------------------
* Get Parameters
-------------------------------------------------------------------------*/
var parameters = PluginManager.parameters('LeTBS_EntityHud');
/*-------------------------------------------------------------------------
* TBSEntity
-------------------------------------------------------------------------*/
Lecode.S_TBS.EntityHud.oldTBSEntity_createComponents = TBSEntity.prototype.createComponents;
TBSEntity.prototype.createComponents = function () {
Lecode.S_TBS.EntityHud.oldTBSEntity_createComponents.call(this);
this._miniHud = new Window_TBSEntityHud(this);
BattleManagerTBS.getLayer("movableInfo").addChild(this._miniHud);
};
Lecode.S_TBS.EntityHud.oldTBSEntity_update = TBSEntity.prototype.update;
TBSEntity.prototype.update = function() {
Lecode.S_TBS.EntityHud.oldTBSEntity_update.call(this);
this._miniHud.updatePosition();
};
Lecode.S_TBS.EntityHud.oldTBSEntity_onMouseOver = TBSEntity.prototype.onMouseOver;
TBSEntity.prototype.onMouseOver = function () {
Lecode.S_TBS.EntityHud.oldTBSEntity_onMouseOver.call(this);
this.showMiniHud();
};
Lecode.S_TBS.EntityHud.oldTBSEntity_onMouseOut = TBSEntity.prototype.onMouseOut;
TBSEntity.prototype.onMouseOut = function () {
Lecode.S_TBS.EntityHud.oldTBSEntity_onMouseOut.call(this);
this.hideMiniHud();
};
Lecode.S_TBS.EntityHud.oldTBSEntity_onTurnEnd = TBSEntity.prototype.onTurnEnd;
TBSEntity.prototype.onTurnEnd = function () {
Lecode.S_TBS.EntityHud.oldTBSEntity_onTurnEnd.call(this);
this._miniHud.refresh();
};
Lecode.S_TBS.EntityHud.oldTBSEntity_onDamage = TBSEvent.prototype.onDamage;
TBSEvent.prototype.onDamage = function () {
Lecode.S_TBS.EntityHud.oldTBSEntity_onDamage.call(this);
this._miniHud.refresh();
};
TBSEntity.prototype.showMiniHud = function () {
this._miniHud.contentsOpacity = 255;
this._miniHud.refresh();
};
TBSEntity.prototype.hideMiniHud = function () {
this._miniHud.contentsOpacity = 0;
};
/*-------------------------------------------------------------------------
* Window_TBSEntityHud
-------------------------------------------------------------------------*/
function Window_TBSEntityHud() {
this.initialize.apply(this, arguments);
}
Window_TBSEntityHud.prototype = Object.create(Window_Base.prototype);
Window_TBSEntityHud.prototype.constructor = Window_TBSEntityHud;
Window_TBSEntityHud.prototype.initialize = function (entity) {
this._entity = entity;
var width = this.windowWidth();
var height = this.windowHeight();
Window_Base.prototype.initialize.call(this, 0, 0, width, height);
this.opacity = 0;
this.contentsOpacity = 0;
this.refresh();
this.updatePosition();
};
Window_TBSEntityHud.prototype.minWindowWidth = function () {
return 300;
};
Window_TBSEntityHud.prototype.minWindowHeight = function () {
return 200;
};
Window_TBSEntityHud.prototype.windowWidth = function () {
return 300;
};
Window_TBSEntityHud.prototype.windowHeight = function () {
return 200;
};
Window_TBSEntityHud.prototype.updatePosition = function () {
var x = this._entity._posX - this.windowWidth() / 2;
var y = this._entity._posY;
this.x = x + this._entity.width() / 2;
this.y = y;
};
Window_TBSEntityHud.prototype.refresh = function () {
this.contents.clear();
this.resetFontSettings();
var battler = this._entity.battler();
//- Name
var x = 0;
var y = 0;
var w = 46;
this.contents.fontSize -= 4;
this.changeTextColor(this.systemColor());
this.leU_drawText(battler.name(), "center", y);
//y += this.contents.fontSize;
x = this.contentsWidth() / 2 - w / 2;
var color1 = this.hpGaugeColor1();
var color2 = this.hpGaugeColor2();
this.drawGauge(x, y, w, battler.hpRate(), color1, color2);
};
Window_TBSEntityHud.prototype.gaugeHeight = function() {
return 5;
};