hud: keys are on top now
[dd2d.git] / data / scripts / d2dhud.dacs
blob2078d8b4a06d411d6f749cefcba45c1b9bf0e444
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.
4  *
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.
9  *
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.
14  *
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/>.
17  */
18 module d2dhud is "engine" "hud";
20 import apiActor;
21 import apiMap;
22 import apiMove;
23 import apiHud;
24 import stdlib;
26 import d2dplayer; // for some actor fields
29 const KeyFrameBase = 0;
32 // precache sprites
34 public void initializeAnim () {
35   animClearFrames("engine", "hud", "sleep");
36   // keys
37   animAddFrame("engine", "hud", "sleep", ACTOR_DIR_LEFT, "sprites/items/keyra0.vga");
38   animAddFrame("engine", "hud", "sleep", ACTOR_DIR_LEFT, "sprites/items/keyga0.vga");
39   animAddFrame("engine", "hud", "sleep", ACTOR_DIR_LEFT, "sprites/items/keyba0.vga");
44 public void drawHud () {
45   auto pl = getPlayerActor(1);
46   //writeln("pl.classname: ", pl.classname);
47   if (pl.dead || !pl.isPlayer) return;
48   // draw keys
49   // WARNING: keep in sync with INV_ITEM_KEY_xxx
50   //writeln("HUD");
51   int vw = viewportWidth;
52   int vh = viewportHeight;
53   auto inv = pl.invitems;
54   for (int kn = 0; kn < 3; ++kn) {
55     if (inv&(1<<kn)) {
56       string spn;
57       switch (kn) {
58         case 0: spn = "sprites/items/keyra0.vga"; break;
59         case 1: spn = "sprites/items/keyga0.vga"; break;
60         case 2: spn = "sprites/items/keyba0.vga"; break;
61         default: continue; // just in case
62       }
63       //drawSpriteAtNoOfs(spn, 4+kn*(spriteWidth(spn)+1), vh/*-spriteHeight(spn)*/-4);
64       drawSpriteAtNoOfs(spn, 10+kn*(spriteWidth(spn)+1), 20+spriteHeight(spn));
65     }
66   }
67   /*
68   {
69     string spn = "sprites/items/keyra0.vga";
70     drawSpriteAt(spn, 4, viewportHeight-4);
71   }
72   */