From: drumsetmonkey Date: Tue, 1 Mar 2016 13:21:12 +0000 (-0500) Subject: Work on merchants and yer mum X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=883b348abac73d6c2b1d4ea8b65caccf0767e5a8;p=clyne%2Fgamedev.git Work on merchants and yer mum --- 883b348abac73d6c2b1d4ea8b65caccf0767e5a8 diff --cc include/world.h index 228defa,c066865..733daae --- a/include/world.h +++ b/include/world.h @@@ -129,10 -129,14 +129,16 @@@ public */ Village(const char *meme, World *w); + + /** + * Destructor... + */ + + ~Village(void){} }; +extern Player *player; + /** * The world class. This class does everything a world should do. */ diff --cc src/ui.cpp index 00c0864,d66c170..89e4805 --- a/src/ui.cpp +++ b/src/ui.cpp @@@ -240,69 -323,15 +326,17 @@@ namespace ui */ void setFontSize(unsigned int size){ + mtx.lock(); - unsigned int i,j; - - std::unique_ptr rgbaBuf; - size_t rgbaBufSize = 0; - - FT_Set_Pixel_Sizes(ftf,0,(fontSize = size)); - - // delete old characters, make space for new ones - for(i=0; i < FT_CHAR_COUNT; i++){ - glDeleteTextures(1, &ftmap[i].tex); - glGenTextures(1, &ftmap[i].tex); - } - - // Load all characters we expect to use - for(i=33;i<126;i++){ - - // Load the bitmap for the current character. - if(FT_Load_Char(ftf,i,FT_LOAD_RENDER)){ - std::cout<<"Error! Unsupported character "<<(char)i<<" ("<glyph->bitmap.width * ftf->glyph->bitmap.rows * 4)]); - rgbaBufSize /= 4; - - // populate the buffer - for(j=0; j < rgbaBufSize; j++){ - rgbaBuf[j * 4 ] = - rgbaBuf[j * 4 + 1] = - rgbaBuf[j * 4 + 2] = 255; - rgbaBuf[j * 4 + 3] = ftf->glyph->bitmap.buffer[j] ? 255 : 0; - } - - // save important character information - ftmap[i-33].wh = { (int)ftf->glyph->bitmap.width, (int)ftf->glyph->bitmap.rows }; - ftmap[i-33].bl = { ftf->glyph->bitmap_left, ftf->glyph->bitmap_top }; - ftmap[i-33].ad = { ftf->glyph->advance.x >> 6, ftf->glyph->advance.y >> 6 }; - - // do the thing - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ftf->glyph->bitmap.width, ftf->glyph->bitmap.rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbaBuf.get()); - - rgbaBuf.release(); + switch((fontSize = size)){ + case 24: + ftmapptr = ftmap24; + break; + default: + case 16: + ftmapptr = ftmap16; + break; } + mtx.unlock(); } /** @@@ -738,65 -697,10 +772,77 @@@ putStringCentered(offset.x, offset.y, rtext); setFontSize(16); } - }else{ // normal dialog box - x = offset.x - SCREEN_WIDTH / 2 + HLINE * 8; - y = (offset.y + SCREEN_HEIGHT / 2) - HLINE * 8; + }else if(dialogMerchant){ + x=offset.x-SCREEN_WIDTH/6; + y=(offset.y+SCREEN_HEIGHT/2)-HLINE*8; + + + glColor3ub(255,255,255); + glBegin(GL_LINE_STRIP); + glVertex2f(x-1 ,y+1); + glVertex2f(x+1+(SCREEN_WIDTH/3),y+1); + glVertex2f(x+1+(SCREEN_WIDTH/3),y-1-SCREEN_HEIGHT*.6); + glVertex2f(x-1,y-1-SCREEN_HEIGHT*.6); + glVertex2f(x,y+1); + glEnd(); + + glColor3ub(0,0,0); + glRectf(x,y,x+SCREEN_WIDTH/3,y-SCREEN_HEIGHT*.6); + + // draw typeOut'd text + putString(x + HLINE, y - fontSize - HLINE, (rtext = typeOut(dialogBoxText))); - merchAOptLoc[0][0] = offset.x - (SCREEN_WIDTH / 5.5); - merchAOptLoc[0][1] = offset.x + (SCREEN_WIDTH / 5.5); ++ merchAOptLoc[0][0] = offset.x - (SCREEN_WIDTH / 6.5) - 16; ++ merchAOptLoc[0][1] = offset.x + (SCREEN_WIDTH / 6.5); + merchAOptLoc[1][0] = offset.y + (SCREEN_HEIGHT *.25); + merchAOptLoc[1][1] = offset.y + (SCREEN_HEIGHT *.25); - merchAOptLoc[2][0] = offset.x - (SCREEN_WIDTH / 5.5) - 16; - merchAOptLoc[2][1] = offset.x + (SCREEN_WIDTH / 5.5) + 16; ++ merchAOptLoc[2][0] = offset.x - (SCREEN_WIDTH / 6.5); ++ merchAOptLoc[2][1] = offset.x + (SCREEN_WIDTH / 6.5) + 16; ++ ++ for(i = 0; i < 2; i++){ ++ if(mouse.x > merchAOptLoc[0][i] && mouse.x < merchAOptLoc[2][i] && ++ mouse.y > merchAOptLoc[1][i] - 8 && mouse.y < merchAOptLoc[1][i] + 8){ ++ glColor3ub(255, 255, 0); ++ }else{ ++ glColor3ub(255,255,255); ++ } ++ } + - glColor3ub(255,255,255); + glBegin(GL_TRIANGLES); - glVertex2f(merchAOptLoc[2][0],merchAOptLoc[1][0]); - glVertex2f(merchAOptLoc[0][0],merchAOptLoc[1][0]-8); - glVertex2f(merchAOptLoc[0][0],merchAOptLoc[1][0]+8); ++ glVertex2f(merchAOptLoc[0][0],merchAOptLoc[1][0]); ++ glVertex2f(merchAOptLoc[2][0],merchAOptLoc[1][0]-8); ++ glVertex2f(merchAOptLoc[2][0],merchAOptLoc[1][0]+8); ++ ++ glVertex2f(merchAOptLoc[2][1],merchAOptLoc[1][1]); ++ glVertex2f(merchAOptLoc[0][1],merchAOptLoc[1][1]-8); ++ glVertex2f(merchAOptLoc[0][1],merchAOptLoc[1][1]+8); + glEnd(); + + // draw / handle dialog options if they exist + for(i = 0; i < dialogOptCount; i++){ + setFontColor(255, 255, 255); + + // draw option + tmp = putStringCentered(offset.x, dialogOptLoc[i][1], dialogOptText[i]); + + // get coordinate information on option + dialogOptLoc[i][2] = offset.x + tmp; + dialogOptLoc[i][0] = offset.x - tmp; + dialogOptLoc[i][1] = y - SCREEN_HEIGHT / 2 - (fontSize + HLINE) * (i + 1); + + // make text yellow if the mouse hovers over the text + if(mouse.x > dialogOptLoc[i][0] && mouse.x < dialogOptLoc[i][2] && + mouse.y > dialogOptLoc[i][1] && mouse.y < dialogOptLoc[i][1] + 16 ){ + setFontColor(255, 255, 0); + putStringCentered(offset.x, dialogOptLoc[i][1], dialogOptText[i]); + } + } + + setFontColor(255, 255, 255); + }else{ //normal dialog box + x=offset.x-SCREEN_WIDTH/2+HLINE*8; + y=(offset.y+SCREEN_HEIGHT/2)-HLINE*8; + // draw white border glColor3ub(255, 255, 255); glBegin(GL_LINE_STRIP);