-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWindow_DebugRange.js
95 lines (80 loc) · 2.81 KB
/
Window_DebugRange.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
//-----------------------------------------------------------------------------
// Window_DebugRange
//
// The window for selecting a block of switches/variables on the debug screen.
function Window_DebugRange() {
this.initialize.apply(this, arguments);
}
Window_DebugRange.prototype = Object.create(Window_Selectable.prototype);
Window_DebugRange.prototype.constructor = Window_DebugRange;
Window_DebugRange.lastTopRow = 0;
Window_DebugRange.lastIndex = 0;
Window_DebugRange.prototype.initialize = function(x, y) {
this._maxSwitches = Math.ceil(($dataSystem.switches.length - 1) / 10);
this._maxVariables = Math.ceil(($dataSystem.variables.length - 1) / 10);
var width = this.windowWidth();
var height = this.windowHeight();
Window_Selectable.prototype.initialize.call(this, x, y, width, height);
this.refresh();
this.setTopRow(Window_DebugRange.lastTopRow);
this.select(Window_DebugRange.lastIndex);
this.activate();
};
Window_DebugRange.prototype.windowWidth = function() {
return 246;
};
Window_DebugRange.prototype.windowHeight = function() {
return Graphics.boxHeight;
};
Window_DebugRange.prototype.maxItems = function() {
return this._maxSwitches + this._maxVariables;
};
Window_DebugRange.prototype.update = function() {
Window_Selectable.prototype.update.call(this);
if (this._editWindow) {
this._editWindow.setMode(this.mode());
this._editWindow.setTopId(this.topId());
}
};
Window_DebugRange.prototype.mode = function() {
return this.index() < this._maxSwitches ? 'switch' : 'variable';
};
Window_DebugRange.prototype.topId = function() {
var index = this.index();
if (index < this._maxSwitches) {
return index * 10 + 1;
} else {
return (index - this._maxSwitches) * 10 + 1;
}
};
Window_DebugRange.prototype.refresh = function() {
this.createContents();
this.drawAllItems();
};
Window_DebugRange.prototype.drawItem = function(index) {
var rect = this.itemRectForText(index);
var start;
var text;
if (index < this._maxSwitches) {
start = index * 10 + 1;
text = 'S';
} else {
start = (index - this._maxSwitches) * 10 + 1;
text = 'V';
}
var end = start + 9;
text += ' [' + start.padZero(4) + '-' + end.padZero(4) + ']';
this.drawText(text, rect.x, rect.y, rect.width);
};
Window_DebugRange.prototype.isCancelTriggered = function() {
return (Window_Selectable.prototype.isCancelTriggered() ||
Input.isTriggered('debug'));
};
Window_DebugRange.prototype.processCancel = function() {
Window_Selectable.prototype.processCancel.call(this);
Window_DebugRange.lastTopRow = this.topRow();
Window_DebugRange.lastIndex = this.index();
};
Window_DebugRange.prototype.setEditWindow = function(editWindow) {
this._editWindow = editWindow;
};