-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWindow_Options.js
145 lines (123 loc) · 4.27 KB
/
Window_Options.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
//-----------------------------------------------------------------------------
// Window_Options
//
// The window for changing various settings on the options screen.
function Window_Options() {
this.initialize.apply(this, arguments);
}
Window_Options.prototype = Object.create(Window_Command.prototype);
Window_Options.prototype.constructor = Window_Options;
Window_Options.prototype.initialize = function() {
Window_Command.prototype.initialize.call(this, 0, 0);
this.updatePlacement();
};
Window_Options.prototype.windowWidth = function() {
return 400;
};
Window_Options.prototype.windowHeight = function() {
return this.fittingHeight(Math.min(this.numVisibleRows(), 12));
};
Window_Options.prototype.updatePlacement = function() {
this.x = (Graphics.boxWidth - this.width) / 2;
this.y = (Graphics.boxHeight - this.height) / 2;
};
Window_Options.prototype.makeCommandList = function() {
this.addGeneralOptions();
this.addVolumeOptions();
};
Window_Options.prototype.addGeneralOptions = function() {
this.addCommand(TextManager.alwaysDash, 'alwaysDash');
this.addCommand(TextManager.commandRemember, 'commandRemember');
};
Window_Options.prototype.addVolumeOptions = function() {
this.addCommand(TextManager.bgmVolume, 'bgmVolume');
this.addCommand(TextManager.bgsVolume, 'bgsVolume');
this.addCommand(TextManager.meVolume, 'meVolume');
this.addCommand(TextManager.seVolume, 'seVolume');
};
Window_Options.prototype.drawItem = function(index) {
var rect = this.itemRectForText(index);
var statusWidth = this.statusWidth();
var titleWidth = rect.width - statusWidth;
this.resetTextColor();
this.changePaintOpacity(this.isCommandEnabled(index));
this.drawText(this.commandName(index), rect.x, rect.y, titleWidth, 'left');
this.drawText(this.statusText(index), rect.x+titleWidth, rect.y, statusWidth, 'right');
};
Window_Options.prototype.statusWidth = function() {
return 120;
};
Window_Options.prototype.statusText = function(index) {
var symbol = this.commandSymbol(index);
var value = this.getConfigValue(symbol);
if (this.isVolumeSymbol(symbol)) {
return this.volumeStatusText(value);
} else {
return this.booleanStatusText(value);
}
};
Window_Options.prototype.isVolumeSymbol = function(symbol) {
return symbol.contains('Volume');
};
Window_Options.prototype.booleanStatusText = function(value) {
return value ? 'ON' : 'OFF';
};
Window_Options.prototype.volumeStatusText = function(value) {
return value + '%';
};
Window_Options.prototype.processOk = function() {
var index = this.index();
var symbol = this.commandSymbol(index);
var value = this.getConfigValue(symbol);
if (this.isVolumeSymbol(symbol)) {
value += this.volumeOffset();
if (value > 100) {
value = 0;
}
value = value.clamp(0, 100);
this.changeValue(symbol, value);
} else {
this.changeValue(symbol, !value);
}
};
Window_Options.prototype.cursorRight = function(wrap) {
var index = this.index();
var symbol = this.commandSymbol(index);
var value = this.getConfigValue(symbol);
if (this.isVolumeSymbol(symbol)) {
value += this.volumeOffset();
value = value.clamp(0, 100);
this.changeValue(symbol, value);
} else {
this.changeValue(symbol, true);
}
};
Window_Options.prototype.cursorLeft = function(wrap) {
var index = this.index();
var symbol = this.commandSymbol(index);
var value = this.getConfigValue(symbol);
if (this.isVolumeSymbol(symbol)) {
value -= this.volumeOffset();
value = value.clamp(0, 100);
this.changeValue(symbol, value);
} else {
this.changeValue(symbol, false);
}
};
Window_Options.prototype.volumeOffset = function() {
return 20;
};
Window_Options.prototype.changeValue = function(symbol, value) {
var lastValue = this.getConfigValue(symbol);
if (lastValue !== value) {
this.setConfigValue(symbol, value);
this.redrawItem(this.findSymbol(symbol));
SoundManager.playCursor();
}
};
Window_Options.prototype.getConfigValue = function(symbol) {
return ConfigManager[symbol];
};
Window_Options.prototype.setConfigValue = function(symbol, volume) {
ConfigManager[symbol] = volume;
};