forked from biud436/MV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRS_EmbossingButtonStyleEx.js
184 lines (169 loc) · 5.72 KB
/
RS_EmbossingButtonStyleEx.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*:ko
* @plugindesc 버튼 스타일을 엠보싱 스타일로 변경합니다 <RS_EmbossingButtonStyleEx>
* @author biud436
*
* @param backColor1
* @text 배경 색상 1
* @desc Specify the background color
* @default rgb(156, 161, 160)
*
* @param backColor2
* @text 배경 색상 2
* @desc Specify the background color
* @default rgb(108, 124, 124)
*
* @param borderColor1
* @text 테두리 색상 1
* @desc Specify the border color
* @default rgb(232, 231, 226)
*
* @param borderColor2
* @text 테두리 색상 2
* @desc Specify the border color
* @default rgb(30, 33, 32)
*
* @param lineWidth
* @type number
* @text 테두리 굵기
* @desc Specify the line width
* @default 2
*
* @help
* =============================================================================
* 플러그인 동작 환경
* =============================================================================
* Windows 10, RMMV 1.6.0
*/
/*:
* @plugindesc Embossing Button & Cursor Style <RS_EmbossingButtonStyleEx>
* @author biud436
*
* @param backColor1
* @text Background Color1
* @desc Specify the background color
* @default rgb(156, 161, 160)
*
* @param backColor2
* @text Background Color2
* @desc Specify the background color
* @default rgb(108, 124, 124)
*
* @param borderColor1
* @text Border Color1
* @desc Specify the border color
* @default rgb(232, 231, 226)
*
* @param borderColor2
* @text Border Color2
* @desc Specify the border color
* @default rgb(30, 33, 32)
*
* @param lineWidth
* @type number
* @text Line Width
* @desc Specify the line width
* @default 2
*
* @help
*
*/
var Imported = Imported || {};
Imported.RS_EmbossingButtonStyleEx = true;
(function () {
var parameters = $plugins.filter(function (i) {
return i.description.contains('<RS_EmbossingButtonStyleEx>');
});
parameters = (parameters.length > 0) && parameters[0].parameters;
var param = {
backColor1 : parameters['backColor1'] || 'rgb(156, 161, 160)',
backColor2 : parameters['backColor2'] || 'rgb(108, 124, 124)',
borderColor1: parameters['borderColor1'] || "rgb(232, 231, 226)",
borderColor2: parameters['borderColor2'] || "rgb(30, 33, 32)",
lineWidth: parseInt(parameters['lineWidth']) || 2
};
//============================================================================
// Bitmap
//============================================================================
Bitmap.prototype.gradientButtonFillRect = function(x, y, width, height, color1,
color2, vertical) {
var context = this._context;
var grad, border;
var lineWidth = param.lineWidth;
if (vertical) {
grad = context.createLinearGradient(x, y, x, y + height);
border = context.createLinearGradient(x, y, x, y + height);
} else {
grad = context.createLinearGradient(x, y, x + width, y);
border = context.createLinearGradient(x, y, x + width, y);
}
grad.addColorStop(0, color1);
grad.addColorStop(1, color2);
border.addColorStop(0, param.borderColor1);
border.addColorStop(1, param.borderColor2);
context.save();
context.lineJoin = "round";
context.lineWidth = lineWidth;
context.fillStyle = grad;
context.strokeStyle = border;
context.strokeRect(x + lineWidth/2, y + lineWidth/2, width - lineWidth, height - lineWidth);
context.fillRect(x + lineWidth/2, y + lineWidth/2, width - lineWidth, height - lineWidth);
context.restore();
this._setDirty();
};
//============================================================================
// Window_Selectable
//============================================================================
Window_Selectable.prototype._refreshCursor = function() {
var pad = this._padding;
var x = this._cursorRect.x + pad - this.origin.x;
var y = this._cursorRect.y + pad - this.origin.y;
var w = this._cursorRect.width;
var h = this._cursorRect.height;
var m = 4;
var x2 = Math.max(x, pad);
var y2 = Math.max(y, pad);
var ox = x - x2;
var oy = y - y2;
var w2 = Math.min(w, this._width - pad - x2);
var h2 = Math.min(h, this._height - pad - y2);
var bitmap = new Bitmap(w2, h2);
var color1 = param.backColor1;
var color2 = param.backColor2;
var textPadding = Math.floor(this.textPadding() / 2);
this._windowCursorSprite.bitmap = bitmap;
this._windowCursorSprite.setFrame(0, 0, w2, h2);
this._windowCursorSprite.move(x2, y2);
if (w > 0 && h > 0 && this._windowskin) {
var skin = this._windowskin;
var p = 96;
var q = 48;
bitmap.gradientButtonFillRect(ox, oy, w2, h2 - textPadding, color1, color2, true);
}
};
Window_Selectable.prototype.drawItemDefaultBackground = function(index) {
var rect = this.itemRect(index);
var color1 = param.backColor1;
var color2 = param.backColor2;
var textPadding = Math.floor(this.textPadding() / 2);
this.changePaintOpacity(false);
this.contents.gradientButtonFillRect(rect.x, rect.y, rect.width, rect.height - textPadding, color1, color2, true);
this.changePaintOpacity(true);
};
Window_Selectable.prototype.drawAllItems = function() {
var topIndex = this.topIndex();
for (var i = 0; i < this.maxPageItems(); i++) {
var index = topIndex + i;
if (index < this.maxItems()) {
this.drawItemDefaultBackground(index);
this.drawItem(index);
}
}
};
Window_Selectable.prototype.redrawItem = function(index) {
if (index >= 0) {
this.clearItem(index);
this.drawItemDefaultBackground(index);
this.drawItem(index);
}
};
})();