aboutsummaryrefslogtreecommitdiffstats
path: root/src/inventory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r--src/inventory.cpp65
1 files changed, 62 insertions, 3 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 0eac3b2..40f2153 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -106,6 +106,7 @@ void Inventory::draw(void){
float angle = float(angleB/2.0f);
unsigned int a = 0;
unsigned int end = 0;
+ static vec2 mouseStart = {0,0};
for(auto &r : iray){
r.start.x = player->loc.x + (player->width/2);
r.start.y = player->loc.y + (player->height/2);
@@ -134,14 +135,14 @@ void Inventory::draw(void){
}
if(end >= numSlot)invOpen=false;
}
- if(invOpen || invHover){
+ if(invOpen){
for(auto &r : iray){
angle=180-(angleB*a) - angleB/2.0f;
curCoord[a].x += float((dfp[a]) * cos(angle*PI/180));
curCoord[a].y += float((dfp[a]) * sin(angle*PI/180));
r.end = curCoord[a];
- glColor4f(0.0f, 0.0f, 0.0f, ((float)dfp[a]/(float)range)*invHover ? 0.2f : 0.5f);
+ glColor4f(0.0f, 0.0f, 0.0f, ((float)dfp[a]/(float)range)*0.4f);
glBegin(GL_QUADS);
glVertex2i(r.end.x-(itemWide/2), r.end.y-(itemWide/2));
glVertex2i(r.end.x-(itemWide/2)+itemWide, r.end.y-(itemWide/2));
@@ -152,7 +153,65 @@ void Inventory::draw(void){
if(inv[a].count > 0){
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, itemtex[inv[a].id]);
- glColor4f(1.0f, 1.0f, 1.0f, ((float)dfp[a]/(float)range)*invHover ? 0.5f : 1.0f);
+ glColor4f(1.0f, 1.0f, 1.0f, ((float)dfp[a]/(float)range)*0.8f);
+ glBegin(GL_QUADS);
+ glTexCoord2i(0,1);glVertex2i(r.end.x-(itemWide/2), r.end.y-(itemWide/2));
+ glTexCoord2i(1,1);glVertex2i(r.end.x-(itemWide/2)+itemWide, r.end.y-(itemWide/2));
+ glTexCoord2i(1,0);glVertex2i(r.end.x-(itemWide/2)+itemWide, r.end.y-(itemWide/2)+itemWide);
+ glTexCoord2i(0,0);glVertex2i(r.end.x-(itemWide/2), r.end.y-(itemWide/2)+itemWide);
+ glEnd();
+ glDisable(GL_TEXTURE_2D);
+ ui::putText(r.end.x-(itemWide/2)+(itemWide*.85),r.end.y-(itemWide/1.75),"%d",inv[a].count);
+ }
+ a++;
+ }
+ }else if(invHover){
+ static int highlight = 0;
+ std::cout << ui::mouse.x << "," << mouseStart.x << "," << mouseSel << std::endl;
+ if(!mouseSel){
+ mouseStart.x = ui::mouse.x;
+ highlight = sel;
+ mouseSel=true;
+ }else{
+ if(ui::mouse.x >= mouseStart.x){
+ highlight = (ui::mouse.x - mouseStart.x)/45;
+ if(highlight>numSlot)highlight=numSlot;
+ if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT)){
+ sel = highlight;
+ mouseSel=false;
+ invHover=false;
+ selected = true;
+ }
+ }
+ if(ui::mouse.x < mouseStart.x){
+ highlight = (mouseStart.x - ui::mouse.x)/45;
+ if(highlight<0)highlight=0;
+ if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT)){
+ sel = highlight;
+ mouseSel=false;
+ invHover=false;
+ selected = true;
+ }
+ }
+ }
+ for(auto &r : iray){
+ angle=180-(angleB*a) - angleB/2.0f;
+ curCoord[a].x += float(range) * cos(angle*PI/180);
+ curCoord[a].y += float(range) * sin(angle*PI/180);
+ r.end = curCoord[a];
+
+ glColor4f(0.0f, 0.0f, 0.0f, 0.1f);
+ glBegin(GL_QUADS);
+ glVertex2i(r.end.x-(itemWide/2), r.end.y-(itemWide/2));
+ glVertex2i(r.end.x-(itemWide/2)+itemWide, r.end.y-(itemWide/2));
+ glVertex2i(r.end.x-(itemWide/2)+itemWide, r.end.y-(itemWide/2)+itemWide);
+ glVertex2i(r.end.x-(itemWide/2), r.end.y-(itemWide/2)+itemWide);
+ glEnd();
+
+ if(inv[a].count > 0){
+ glEnable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, itemtex[inv[a].id]);
+ glColor4f(1.0f, 1.0f, 1.0f, a == highlight ? 0.4f : 0.2f);
glBegin(GL_QUADS);
glTexCoord2i(0,1);glVertex2i(r.end.x-(itemWide/2), r.end.y-(itemWide/2));
glTexCoord2i(1,1);glVertex2i(r.end.x-(itemWide/2)+itemWide, r.end.y-(itemWide/2));