#include <common.h>
#include <string.h>
+#include <boost/range/adaptor/reversed.hpp>
#define DEBUG
int maxStackSize;
char* textureLoc;
Texturec *tex;
+ GLuint text;
int count;
Item(ITEM_ID i, char* n, ITEM_TYPE t, float w, float h, int m, char* tl):
id(i), type(t), width(w), height(h), maxStackSize(m){
count = 0;
- name = (char*)calloc(strlen(n ),sizeof(char));
- textureLoc = (char*)calloc(strlen(tl),sizeof(char));
+ name = (char*)calloc(strlen(n )+1,sizeof(char));
+ textureLoc = (char*)calloc(strlen(tl)+1,sizeof(char));
strcpy(name,n);
strcpy(textureLoc,tl);
tex= new Texturec(1,textureLoc);
+ text = Texture::loadTexture(textureLoc);
}
GLuint rtex(){
return tex->image[0];
}
};
+static Item item[5]= {
+ #include "../config/items.h"
+};
+
struct item_t{
int count;
ITEM_ID id;
extern Player *player;
extern GLuint invUI;
-static Item item[5]= {
- #include "../config/items.h"
-};
-
void itemDraw(Player *p,ITEM_ID id);
Inventory::Inventory(unsigned int s){
void Inventory::draw(void){
ui::putText(offset.x-SCREEN_WIDTH/2,480,"%d",sel);
unsigned int i=0;
+ static unsigned int lop = 0;
float y,xoff;
//dfp[a] = 0;
a++;
}a=0;
- if(invOpening){
+ if(invOpening && lop % 1 == 0){
end = 0;
for(auto &d : dfp){
if(a != 0){
a++;
}a=0;
if(end < numSlot)invOpen=true;
- }else if(!invOpening){
- for(auto &d : dfp){
+ }else if(!invOpening && lop % 1 == 0){
+ for(auto &d : boost::adaptors::reverse(dfp)){
if(d > 0){
- if(a != 0){
- //d-=25;
- if(dfp[a-1]+25<d || dfp[a-1]<=0)d-=25;
- }else{
- d-=25;
- }
+ d-=25;
}else end++;
- a++;
- }a=0;
+ }
if(end >= numSlot)invOpen=false;
}
if(invOpen){
curCoord[a].y += float((dfp[a]) * sin(angle*PI/180));
r.end = curCoord[a];
- item[inv[i].id].tex->bind(0);
- glColor4f(1.0f, 1.0f, 1.0f, (float)dfp[a]/(float)range);
+ glColor4f(0.0f, 0.0f, 0.0f, ((float)dfp[a]/(float)range));
glBegin(GL_QUADS);
- glTexCoord2i(0,1);glVertex2i(r.end.x, r.end.y);
- glTexCoord2i(1,1);glVertex2i(r.end.x+45, r.end.y);
- glTexCoord2i(1,0);glVertex2i(r.end.x+45, r.end.y+45);
- glTexCoord2i(0,0);glVertex2i(r.end.x, r.end.y+45);
+ glVertex2i(r.end.x, r.end.y);
+ glVertex2i(r.end.x+45, r.end.y);
+ glVertex2i(r.end.x+45, r.end.y+45);
+ glVertex2i(r.end.x, r.end.y+45);
glEnd();
+
+ if(inv[a].count > 0){
+ glBindTexture(GL_TEXTURE_2D, item[inv[a].id].text);
+ glColor4f(1.0f, 1.0f, 1.0f, (float)dfp[a]/(float)range);
+ glBegin(GL_QUADS);
+ glTexCoord2i(0,1);glVertex2i(r.end.x, r.end.y);
+ glTexCoord2i(1,1);glVertex2i(r.end.x+45, r.end.y);
+ glTexCoord2i(1,0);glVertex2i(r.end.x+45, r.end.y+45);
+ glTexCoord2i(0,0);glVertex2i(r.end.x, r.end.y+45);
+ glEnd();
+ }
a++;
}
}
}
}*/
if(inv[sel].count)itemDraw(player,inv[sel].id);
+ lop++;
}
static vec2 item_coord = {0,0};