we don't really need simpledisplay's glfinish flag, as we do no rendering in window...
[dd2d.git] / editor.d
blob9261dd3ea1251e87a771e2a7b0798b7873b86d73
1 /* DooM2D: Midnight on the Firing Line
2 * coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
3 * Understanding is not required. Only obedience.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 // ////////////////////////////////////////////////////////////////////////// //
19 // cursor (hi, Death Track!)
20 public enum curWidth = 17;
21 public enum curHeight = 23;
22 static immutable ubyte[curWidth*curHeight] curImg = [
23 0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
24 0,0,3,2,0,0,0,0,0,0,0,0,0,0,0,0,0,
25 1,0,3,2,2,0,0,0,0,0,0,0,0,0,0,0,0,
26 1,1,3,3,2,2,0,0,0,0,0,0,0,0,0,0,0,
27 1,1,3,3,4,2,2,0,0,0,0,0,0,0,0,0,0,
28 1,1,3,3,4,4,2,2,0,0,0,0,0,0,0,0,0,
29 1,1,3,3,4,4,4,2,2,0,0,0,0,0,0,0,0,
30 1,1,3,3,4,4,4,4,2,2,0,0,0,0,0,0,0,
31 1,1,3,3,4,4,4,5,6,2,2,0,0,0,0,0,0,
32 1,1,3,3,4,4,5,6,7,5,2,2,0,0,0,0,0,
33 1,1,3,3,4,5,6,7,5,4,5,2,2,0,0,0,0,
34 1,1,3,3,5,6,7,5,4,5,6,7,2,2,0,0,0,
35 1,1,3,3,6,7,5,4,5,6,7,7,7,2,2,0,0,
36 1,1,3,3,7,5,4,5,6,7,7,7,7,7,2,2,0,
37 1,1,3,3,5,4,5,6,8,8,8,8,8,8,8,8,2,
38 1,1,3,3,4,5,6,3,8,8,8,8,8,8,8,8,8,
39 1,1,3,3,5,6,3,3,1,1,1,1,1,1,1,0,0,
40 1,1,3,3,6,3,3,1,1,1,1,1,1,1,1,0,0,
41 1,1,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,
42 1,1,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,
43 1,1,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,
44 1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
45 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
47 static immutable Color[9] curPal = [
48 Color( 0, 0, 0, 0),
49 Color( 0, 0, 0,163),
50 Color( 85,255,255,255),
51 Color( 85, 85,255,255),
52 Color(255, 85, 85,255),
53 Color(170, 0,170,255),
54 Color( 85, 85, 85,255),
55 Color( 0, 0, 0,255),
56 Color( 0, 0,170,255),
60 // ////////////////////////////////////////////////////////////////////////// //
61 __gshared int edtMX, edtMY;
64 void editorDrawCursor (int x, int y) {
65 x -= 2;
66 auto ci = curImg.ptr;
67 foreach (int dy; 0..curHeight) {
68 foreach (int dx; 0..curWidth) {
69 if (*ci) editorPutPixel(x+dx, y, curPal.ptr[*ci]);
70 ++ci;
72 ++y;
77 // ////////////////////////////////////////////////////////////////////////// //
78 void editorPutPixel (int x, int y, Color clr) {
79 pragma(inline, true);
80 if (x >= 0 && y >= 0 && x < editorImg.width && y < editorImg.height) {
81 editorImg.imageData.colors.ptr[y*editorImg.width+x] = clr;
86 // ////////////////////////////////////////////////////////////////////////// //
87 void editorUpdateImage () {
88 editorImg.imageData.colors[] = Color(0, 0, 0, 0);
89 editorDrawCursor(edtMX, edtMY);
93 // ////////////////////////////////////////////////////////////////////////// //
94 void editorKeyEvent (TMsgKeyEvent evt) {
95 if (evt.pressed && evt.key == Key.Escape) {
96 //import core.atomic;
97 //atomicSet(editMode, false);
98 //postToggleOption("EditMode", showMessage:true);
99 return;
101 if (evt.pressed) {
102 if (evt.key == '1') concmd("r_scale 1");
103 if (evt.key == '2') concmd("r_scale 2");
104 if (evt.key == 'l') concmd("r_lighting toggle");
105 if (evt.key == 'q') concmd("ed_exit");
110 // ////////////////////////////////////////////////////////////////////////// //
111 void editorMouseEvent (TMsgMouseEvent evt) {
112 edtMX = evt.x;
113 edtMY = evt.y;