From 33d48a76b3266a4f8ff4b06b9278bfc57e5b4afb Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Thu, 26 Oct 2023 12:32:09 +0200 Subject: [PATCH] crossbow:: crossbow icon works --- control.cpp | 11 ++++++++--- graph.cpp | 5 +++++ hud.cpp | 14 +++++++++++++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/control.cpp b/control.cpp index 806ae8d5..c2187163 100644 --- a/control.cpp +++ b/control.cpp @@ -548,15 +548,17 @@ EX void handleKeyNormal(int sym, int uni) { if(sym == '.' || sym == 's') movepcto(-1, 1); if((sym == SDLK_DELETE || sym == SDLK_KP_PERIOD || sym == 'g') && uni != 'G' && uni != 'G'-64) movepcto(MD_DROP, 1); - if(sym == 't' && uni != 'T' && uni != 'T'-64 && canmove) { + if(sym == 't' && uni != 'T' && uni != 'T'-64 && canmove) { cell *target = GDIM == 3 ? mouseover : centerover; if(playermoved && items[itStrongWind]) { cell *c = whirlwind::jumpDestination(cwt.at); if(c) target = c; } - targetRangedOrb(target, roKeyboard); + if(bow::fire_mode) bow::add_fire(target); + else targetRangedOrb(target, roKeyboard); sym = 0; uni = 0; } + if(sym == 'f') bow::switch_fire_mode(); } if(sym == SDLK_KP5 && DEFAULTCONTROL && !game_keys_scroll) movepcto(-1, 1); @@ -613,7 +615,10 @@ EX void handleKeyNormal(int sym, int uni) { actonrelease = false; multi::cpid = 0; - if(mouseover && + if(bow::fire_mode) { + if(mouseover) bow::add_fire(mouseover); + } + else if(mouseover && targetclick && (shmup::on ? numplayers() == 1 && !shmup::pc[0]->dead : true) && targetRangedOrb(mouseover, forcetarget ? roMouseForce : roMouse)) { } else if(forcetarget) diff --git a/graph.cpp b/graph.cpp index 9374df0f..8a0dc0d0 100644 --- a/graph.cpp +++ b/graph.cpp @@ -933,6 +933,11 @@ EX bool drawItemType(eItem it, cell *c, const shiftmatrix& V, color_t icol, int queuepoly(Vit * spinptick(750, 0), cgi.shTriangle, darkena(icol, 0, 255)); } + else if(it == itCrossbow) { + queuepoly(Vit, cgi.shCrossbowIcon, getcs().bowcolor); + queuepoly(Vit, cgi.shCrossbowstringIcon, getcs().bowcolor2); + } + else if(it == itBabyTortoise) { int bits = c ? tortoise::babymap[c] : tortoise::last; int over = c && c->monst == moTortoise; diff --git a/hud.cpp b/hud.cpp index f66af51b..f1fecd80 100644 --- a/hud.cpp +++ b/hud.cpp @@ -46,6 +46,7 @@ EX int subclass(int i) { #define GLYPH_TARGET 512 #define GLYPH_INSQUARE 1024 #define GLYPH_INLANDSCAPE 2048 +#define GLYPH_ACTIVE 4096 #if HDR enum eGlyphsortorder { @@ -68,6 +69,7 @@ int& ikmerge(int i) { bool ikappear(int i) { if(i == itInventory && inv::on) return true; + if(i == itCrossbow && bow::crossbow_mode()) return true; return ikmerge(i); } @@ -142,7 +144,11 @@ int glyphflags(int gid) { int f = 0; if(gid < ittypes) { eItem i = eItem(gid); - if(itemclass(i) == IC_NAI && i != itFatigue) f |= GLYPH_NONUMBER; + if(itemclass(i) == IC_NAI && i != itFatigue && i != itCrossbow) f |= GLYPH_NONUMBER; + if(i == itCrossbow && items[i] == 0) { + if(bow::fire_mode) f |= GLYPH_ACTIVE; + f |= GLYPH_NONUMBER; + } if(isElementalShard(i)) { f |= GLYPH_LOCAL | GLYPH_INSQUARE; if(i == localshardof(cwt.at->land)) f |= GLYPH_LOCAL2; @@ -229,6 +235,7 @@ bool displayglyph(int cx, int cy, int buttonsize, char glyph, color_t color, int if(glyph == ']') bsize = bsize*1.5; if(glyph == 'x') bsize = bsize*1.5; if(it == itWarning) bsize *= 2; + if(it == itCrossbow) bsize *= 2; if(it == itBombEgg || it == itTrollEgg || it == itDodeca) bsize = bsize*3/2; int icol = color; icol -= (color & 0xFCFCFC) >> 2; @@ -266,6 +273,7 @@ bool displayglyph(int cx, int cy, int buttonsize, char glyph, color_t color, int if(flags & GLYPH_LOCAL2) fl += "+"; else if(flags & GLYPH_LOCAL) fl += "-"; if(flags & GLYPH_DEMON) fl += "X"; + if(flags & GLYPH_ACTIVE) fl += "A"; if(flags & GLYPH_MARKOVER) str += "!"; if(fl != "") @@ -326,6 +334,10 @@ void displayglyph2(int cx, int cy, int buttonsize, int i) { mouseovers += XLAT(" (click to use)"); getcstat = 'i'; } + if(it == itCrossbow) { + mouseovers += XLAT(" (click to use)"); + getcstat = 'f'; + } if(imp & GLYPH_LOCAL) mouseovers += XLAT(" (local treasure)"); help = generateHelpForItem(it); }