diff options
author | drumsetmonkey <abelleisle@roadrunner.com> | 2016-03-01 08:43:11 -0500 |
---|---|---|
committer | drumsetmonkey <abelleisle@roadrunner.com> | 2016-03-01 08:43:11 -0500 |
commit | 20948cfe47f1fbeeed04e890c457d83cc826d74d (patch) | |
tree | 575a2630767d9496f9581ef1b1947d436f5201d8 | |
parent | 883b348abac73d6c2b1d4ea8b65caccf0767e5a8 (diff) |
Work on merchants and yer mum
-rw-r--r-- | include/inventory.h | 1 | ||||
-rw-r--r-- | src/entities.cpp | 6 | ||||
-rw-r--r-- | src/inventory.cpp | 8 | ||||
-rw-r--r-- | src/ui.cpp | 30 |
4 files changed, 31 insertions, 14 deletions
diff --git a/include/inventory.h b/include/inventory.h index 8225ab2..cf6e480 100644 --- a/include/inventory.h +++ b/include/inventory.h @@ -62,6 +62,7 @@ void initInventorySprites(void); void destroyInventory(void); const char *getItemTexturePath(std::string name); +Texturec *getItemTexture(std::string name); float getItemWidth(std::string name); float getItemHeight(std::string name); diff --git a/src/entities.cpp b/src/entities.cpp index 5e8d51c..b0013d2 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -459,8 +459,12 @@ void NPC::interact(){ //have the npc's interact back to the player void Merchant::interact(){ ui::merchantBox(name, &bsinv, ":Accept:Good-Bye", false, "Welcome to Smithy\'s. Buy your sausages here you freaking meme lording screw-face"); - //ui::merchantBox(); ui::waitForDialog(); + if(ui::dialogOptChosen == 1){ + std::cout << "Gimme ye' munny" << std::endl; + }else{ + std::cout << "See ye!" << std::endl; + } } void Object::interact(void){ diff --git a/src/inventory.cpp b/src/inventory.cpp index b32b56f..92cce75 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -142,6 +142,14 @@ const char *getItemTexturePath(std::string name){ return NULL; } +Texturec *getItemTexture(std::string name){ + for(auto &i : itemMap){ + if(i->name == name) + return i->tex; + } + return NULL; +} + float getItemWidth(std::string name){ for(auto &i : itemMap){ if(i->name == name) @@ -773,6 +773,8 @@ namespace ui { setFontSize(16); } }else if(dialogMerchant){ + static int dispItem; + x=offset.x-SCREEN_WIDTH/6; y=(offset.y+SCREEN_HEIGHT/2)-HLINE*8; @@ -792,30 +794,32 @@ namespace ui { // draw typeOut'd text putString(x + HLINE, y - fontSize - HLINE, (rtext = typeOut(dialogBoxText))); 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][0] = offset.x + (SCREEN_WIDTH / 6.5); + merchAOptLoc[0][1] = offset.y + (SCREEN_HEIGHT *.25); merchAOptLoc[1][1] = offset.y + (SCREEN_HEIGHT *.25); - merchAOptLoc[2][0] = offset.x - (SCREEN_WIDTH / 6.5); - merchAOptLoc[2][1] = offset.x + (SCREEN_WIDTH / 6.5) + 16; + merchAOptLoc[0][2] = offset.x - (SCREEN_WIDTH / 6.5); + merchAOptLoc[1][2] = 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); + if(mouse.x > merchAOptLoc[i][0] && mouse.x < merchAOptLoc[i][2] && + mouse.y > merchAOptLoc[i][1] - 8 && mouse.y < merchAOptLoc[i][1] + 8){ + dispItem++; + glColor3ub(255,255, 0); }else{ glColor3ub(255,255,255); } } glBegin(GL_TRIANGLES); - 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[0][0],merchAOptLoc[0][1]); + glVertex2f(merchAOptLoc[0][2],merchAOptLoc[0][1]-8); + glVertex2f(merchAOptLoc[0][2],merchAOptLoc[0][1]+8); - glVertex2f(merchAOptLoc[2][1],merchAOptLoc[1][1]); - glVertex2f(merchAOptLoc[0][1],merchAOptLoc[1][1]-8); - glVertex2f(merchAOptLoc[0][1],merchAOptLoc[1][1]+8); + glVertex2f(merchAOptLoc[1][2],merchAOptLoc[1][1]); + glVertex2f(merchAOptLoc[1][0],merchAOptLoc[1][1]-8); + glVertex2f(merchAOptLoc[1][0],merchAOptLoc[1][1]+8); glEnd(); + // draw / handle dialog options if they exist for(i = 0; i < dialogOptCount; i++){ |