]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Work on merchants and yer mum
authordrumsetmonkey <abelleisle@roadrunner.com>
Tue, 1 Mar 2016 13:21:12 +0000 (08:21 -0500)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Tue, 1 Mar 2016 13:21:12 +0000 (08:21 -0500)
1  2 
include/common.h
include/world.h
src/gameplay.cpp
src/ui.cpp

Simple merge
diff --cc include/world.h
index 228defa5b9f2d29e326c5b4cb3da78c32f4dccff,c0668655eb103f073960b80397579f0bf572e741..733daaef1214c9c4842a6f8358bb39eb364e39d9
@@@ -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.
   */
Simple merge
diff --cc src/ui.cpp
index 00c0864c96751bfc999b09d142e101fbf5de433b,d66c1706c9a6c306a13803afdb435e6b7c04c6c1..89e4805a7f7eb4d10ec4e7d9aa28eb7745b3b058
@@@ -240,69 -323,15 +326,17 @@@ namespace ui 
         */
        
        void setFontSize(unsigned int size){
-               unsigned int i,j;
-               
-               std::unique_ptr<uint8_t[]> 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<<" ("<<i<<")."<<std::endl;
-                               abort();
-                       }
-                       
-                       /*
-                        * Set up the OpenGL texture thing.
-                        */
-               
-                       glBindTexture(GL_TEXTURE_2D, ftmap[i-33].tex);
-                       
-                       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S                , GL_CLAMP_TO_EDGE);
-                       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T                , GL_CLAMP_TO_EDGE);
-                       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER    , GL_LINEAR              );
-                       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER    , GL_LINEAR              );
-                       
-                       glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-               
-                       /*
-                        * Convert the bitmap font given to us from FreeType into an RGBA
-                        * format, for ease of drawing.
-                        */
-               
-                       rgbaBuf.reset(new uint8_t [(rgbaBufSize = ftf->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();
 +              mtx.lock();
+               switch((fontSize = size)){
+               case 24:
+                       ftmapptr = ftmap24;
+                       break;
+               default:
+               case 16:
+                       ftmapptr = ftmap16;
+                       break;
                }
 +              mtx.unlock();
        }
        
        /**
                                        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);