-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvorple-status-line.h
More file actions
162 lines (136 loc) · 5.03 KB
/
vorple-status-line.h
File metadata and controls
162 lines (136 loc) · 5.03 KB
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
#Ifndef VORPLE_STATUS_LINE;
System_file;
Constant VORPLE_STATUS_LINE;
Include "vorple.h";
Include "vorple-element-manipulation.h";
! Comment this out to not get a status line with full width
!Constant VORPLE_STATUS_LINE_FULL_WIDTH;
! Don't change this number directly - internal use only
Global VorpleStatusLineSize = 0;
!===============================
! Construct the Vorple status line with a given number of columns
! Default is something on the left and something on the right
! Change this if you want more or less
Global VorpleStatusLineColumns = 2;
Object VorpleStatusLineConstructionRule "" VorpleInterfaceSetup
with description [;
VorpleConstructStatusLine(VorpleStatusLineColumns);
];
[ VorpleConstructStatusLine cols ;
if (cols > 3 || cols < 0) {
VorpleThrowRuntimeError("Vorple Status Line: status line must have exactly 1, 2 or 3 columns.");
return false;
}
VorpleStatusLineSize = cols;
VorpleStatusLineRemove();
VorplePlaceElementAtTopLevel("status-line-container");
#IfDef VORPLE_STATUS_LINE_FULL_WIDTH;
VorpleExecuteJavaScriptCommand("$('.status-line-container').prependTo('main#vorple')");
#Ifnot;
VorpleExecuteJavaScriptCommand("$('.status-line-container').prependTo('#output')");
#Endif;
VorpleSetOutputFocus("status-line-container");
if (cols > 1) {
VorplePlaceBlockLevelElement("status-line-left col-xs lg-only");
}
if (cols ~=2) {
VorplePlaceBlockLevelElement("status-line-middle col-xs lg-only");
}
if (cols > 1) {
VorplePlaceBlockLevelElement("status-line-right col-xs lg-only");
}
VorplePlaceBlockLevelElement("status-line-mobile col-xs sm-only");
VorpleSetOutputFocusMainWindow();
];
!===============================
! Drawing the usual status line
Constant LEN_STATUS 200;
Array VorpleStatusLineLeftHand buffer LEN_STATUS;
Array VorpleStatusLineMiddleHand buffer LEN_STATUS;
Array VorpleStatusLineRightHand buffer LEN_STATUS;
Array VorpleStatusLineMobile buffer LEN_STATUS;
! Put this variable at 0 if you don't want those to be updated with the usual location/score text
Constant VORPLE_USUAL_STATUS_LINE = 1;
Object VorpleDrawStatusLine "" VorpleInterfaceUpdate
with description [ r ;
if (VORPLE_USUAL_STATUS_LINE == 1) {
! update the columns text using the usual DrawStatusLine
VorpleStatusLineUsualInfo();
}
if (child(StatusLineRulebook) == nothing) {
VorpleDefaultStatusLine.description();
} else {
objectloop(r in StatusLineRulebook) { r.description(); }
}
return true;
];
Object StatusLineRulebook "status line rulebook";
Object VorpleDefaultStatusLine
with description [;
if (VorpleStatusLineSize > 1) {
VorplePutContentInAllElements("status-line-left", VorpleStatusLineLeftHand);
}
if (VorpleStatusLineSize ~= 2) {
VorplePutContentInAllElements("status-line-middle", VorpleStatusLineMiddleHand);
}
if (VorpleStatusLineSize > 1) {
VorplePutContentInAllElements("status-line-right", VorpleStatusLineRightHand);
}
VorplePutContentInAllElements("status-line-mobile", VorpleStatusLineMobile);
return ;
];
! Update the columns text using the usual DrawStatusLine code
[ VorpleStatusLineUsualInfo width;
width = ScreenWidth();
bp_output_stream(3, VorpleStatusLineLeftHand, LEN_STATUS);
! TODO: bug: out of bounds memory access??
!if (location == thedark) {
! print (name) location;
!} else {
! FindVisibilityLevels();
! if (visibility_ceiling == location)
! print (name) location;
! else
! print (The) visibility_ceiling;
!}
print (name) location;
bp_output_stream(-3);
bp_output_stream(3, VorpleStatusLineMobile, LEN_STATUS);
PrintStringOrArray(VorpleStatusLineLeftHand);
bp_output_stream(-3);
bp_output_stream(3, VorpleStatusLineRightHand, LEN_STATUS);
if (sys_statusline_flag && width > 53) {
print (string) TIME__TX;
LanguageTimeOfDay(sline1, sline2);
} else {
if (width > 66) {
#Ifndef NO_SCORE;
print (string) SCORE__TX, sline1;
#Endif;
print " ";
print (string) MOVES__TX, sline2;
}
#Ifndef NO_SCORE;
if (width > 53 && width <= 66) {
print sline1, "/", sline2;
}
#Endif;
}
bp_output_stream(-3);
];
!===============================
! Refresh, remove, clear
[ VorpleStatusLineRefresh ;
if (isVorpleSupported() && VorpleStatusLineSize > 0) {
! save the internal state of line breaks
VorpleDrawStatusLine.description();
! restore the internal state of line breaks
}
];
[ VorpleStatusLineRemove ;
VorpleRemoveElement("status-line-container");
];
[ VorpleStatusLineClear ;
VorpleExecuteJavaScriptCommand("$('.status-line-container').children().empty()");
];
#Endif;