aboutsummaryrefslogtreecommitdiffstats
path: root/src/inventory.cpp
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2016-04-23 21:55:31 -0400
committerdrumsetmonkey <abelleisle@roadrunner.com>2016-04-23 21:55:31 -0400
commitdebb080a17eba2b2957e99ba7f1ce0fa0c4d2e4e (patch)
tree621bcf54c0f97b202e21bb4f21f5107f852cba63 /src/inventory.cpp
parent6e51f9723635de3defce30517fa1043f26e27ee9 (diff)
parente04fae7b72b424e5019429a071ad2de9edf4df1f (diff)
Fixed some bugs
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r--src/inventory.cpp73
1 files changed, 31 insertions, 42 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 224ee12..c6b28d9 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -440,32 +440,22 @@ void Inventory::draw(void) {
a++;
}
C("Done drawing standard inv");
- }else if (invHover) {
+ } else if (invHover) {
static unsigned int highlight = 0;
static unsigned int thing = 0;
- std::cout<<"Inventory2???"<<std::endl;
-
if (!mouseSel) {
+ // setup?
mouseStart.x = ui::mouse.x - offset.x;
- std::cout << "Setting highlight" << std::endl;
highlight = sel;
- std::cout << "Setting thing" << std::endl;
thing = sel;
- std::cout << "Setting mouseSel" << std::endl;
- mouseSel=true;
- std::cout << "Done" << std::endl;
- }else{
- std::cout << "Is mousex greater than the start" << std::endl;
- if ((ui::mouse.x - offset.x) >= mouseStart.x) {
- std::cout << "Thing" << std::endl;
+ mouseSel = true;
+ } else {
+ if((ui::mouse.x - offset.x) >= mouseStart.x){
thing = (ui::mouse.x - offset.x - mouseStart.x)/80;
- std::cout << "Highlight" << std::endl;
highlight=sel+thing;
- std::cout << "Highlight Check" << std::endl;
- if (highlight>numSlot-1)highlight=numSlot-1;
- std::cout << "Left Click" << std::endl;
- if (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT)) {
+ if(highlight>numSlot-1)highlight=numSlot-1;
+ if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT)){
sel = highlight;
mouseSel=false;
invHover=false;
@@ -474,9 +464,11 @@ void Inventory::draw(void) {
}
if ((ui::mouse.x - offset.x) < mouseStart.x) {
thing = (mouseStart.x - (ui::mouse.x - offset.x))/80;
- if ((int)sel-(int)thing<0)highlight=0;
- else highlight=sel-thing;
- if (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT)) {
+ if ((int)sel - (int)thing < 0)
+ highlight = 0;
+ else
+ highlight = sel - thing;
+ if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT)){
sel = highlight;
mouseSel=false;
invHover=false;
@@ -484,17 +476,15 @@ void Inventory::draw(void) {
}
}
}
- std::cout << "Rays" << std::endl;
- for(auto &r : iray) {
- std::cout << "Setting angle" << std::endl;
- angle=180-(angleB*a) - angleB/2.0f;
- std::cout << "Currcourd" << std::endl;
+
+ a = 0;
+ 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);
- std::cout << "Ray.end" << std::endl;
r.end = curCoord[a];
- std::cout << "Draw" << std::endl;
+ // square drawing
glColor4f(0.0f, 0.0f, 0.0f, a == highlight ? 0.5f : 0.1f);
glBegin(GL_QUADS);
glVertex2i(r.end.x-(itemWide/2), r.end.y-(itemWide/2));
@@ -503,18 +493,16 @@ void Inventory::draw(void) {
glVertex2i(r.end.x-(itemWide/2), r.end.y+(itemWide/2));
glEnd();
- std::cout << "Draw items," << a << std::endl;
- if (!items.empty() && a < numSlot && items[a].count) {
- std::cout << "drawing" << std::endl;
+ if (a < items.size() && items[a].count) {
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, itemtex[items[a].id]);
- glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+ glColor4f(1.0f, 1.0f, 1.0f, a == highlight ? 0.8f : 0.2f);
glBegin(GL_QUADS);
- if (itemMap[items[a].id]->height > itemMap[items[a].id]->width) {
- glTexCoord2i(0,1);glVertex2i(r.end.x-((itemWide/2)*((float)itemMap[items[a].id]->width/(float)itemMap[items[a].id]->height)), r.end.y-(itemWide/2));
- glTexCoord2i(1,1);glVertex2i(r.end.x+((itemWide/2)*((float)itemMap[items[a].id]->width/(float)itemMap[items[a].id]->height)), r.end.y-(itemWide/2));
- glTexCoord2i(1,0);glVertex2i(r.end.x+((itemWide/2)*((float)itemMap[items[a].id]->width/(float)itemMap[items[a].id]->height)), r.end.y+(itemWide/2));
- glTexCoord2i(0,0);glVertex2i(r.end.x-((itemWide/2)*((float)itemMap[items[a].id]->width/(float)itemMap[items[a].id]->height)), r.end.y+(itemWide/2));
+ if(itemMap[items[a].id]->height > itemMap[items[a].id]->width){
+ glTexCoord2i(0,1);glVertex2i(r.end.x-((itemWide/2)*((float)itemMap[items[a].id]->width/(float)itemMap[items[a].id]->height)),r.end.y-(itemWide/2));
+ glTexCoord2i(1,1);glVertex2i(r.end.x+((itemWide/2)*((float)itemMap[items[a].id]->width/(float)itemMap[items[a].id]->height)),r.end.y-(itemWide/2));
+ glTexCoord2i(1,0);glVertex2i(r.end.x+((itemWide/2)*((float)itemMap[items[a].id]->width/(float)itemMap[items[a].id]->height)),r.end.y+(itemWide/2));
+ glTexCoord2i(0,0);glVertex2i(r.end.x-((itemWide/2)*((float)itemMap[items[a].id]->width/(float)itemMap[items[a].id]->height)),r.end.y+(itemWide/2));
}else{
glTexCoord2i(0,1);glVertex2i(r.end.x-(itemWide/2),r.end.y-(itemWide/2)*((float)itemMap[items[a].id]->height/(float)itemMap[items[a].id]->width));
glTexCoord2i(1,1);glVertex2i(r.end.x+(itemWide/2),r.end.y-(itemWide/2)*((float)itemMap[items[a].id]->height/(float)itemMap[items[a].id]->width));
@@ -523,15 +511,16 @@ void Inventory::draw(void) {
}
glEnd();
glDisable(GL_TEXTURE_2D);
-
- if (highlight == a) {
- std::cout << "Shitting" << std::endl;
- std::cout << itemMap[items[a].id]->name << std::endl;
- ui::putStringCentered(player->loc.x+player->width/2, player->loc.y + range*.75,itemMap[items[a].id]->name);
- }
}
a++;
}
+
+ if (highlight < items.size()) {
+ ui::putStringCentered(player->loc.x + player->width / 2,
+ player->loc.y + range * 0.75f,
+ itemMap[items[highlight].id]->name.c_str()
+ );
+ }
}
if (!items.empty() && items.size() > sel && items[sel].count)
itemDraw(player,items[sel].id);