aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/entities.cpp6
-rw-r--r--src/inventory.cpp8
-rw-r--r--src/ui.cpp30
-rw-r--r--src/world.cpp16
4 files changed, 42 insertions, 18 deletions
diff --git a/src/entities.cpp b/src/entities.cpp
index 1c364a4..b97767d 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 203e707..cd8bb71 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)
diff --git a/src/ui.cpp b/src/ui.cpp
index c755a59..2c9a230 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -665,6 +665,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;
@@ -684,30 +686,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++){
diff --git a/src/world.cpp b/src/world.cpp
index 80ddc5a..32a3153 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -1446,6 +1446,7 @@ World *loadWorldFromXMLNoSave(const char *path){
while(vil){
name = vil->Name();
randx = 0;
+ //static BuySell bs;
/**
* READS DATA ABOUT STRUCTURE CONTAINED IN VILLAGE
@@ -1469,10 +1470,17 @@ World *loadWorldFromXMLNoSave(const char *path){
(char*)vil->Attribute("texture"),
ptr);
tmp->addMerchant(0,100);
- if(!strcmp(name,"buy")){
- std::cout << "Buying";
- }else if(!strcmp(name,"sell")){
- std::cout << "Selling";
+ if(vil->FirstChildElement("buy")){
+ std::cout << "Buy" << std::endl;
+ /*bs.member = 0;
+ bs.cost.type = 0;
+ bs.cost.item = vil->FirstChildElement("buy")->Attribute("item");
+ bs.cost.price =vil->FirstChildElement("buy")->IntAttribute("cost");*/
+ tmp->merchant.back()->bsinv.push_back({0,"Dank MayMay",420});
+ }if(vil->FirstChildElement("sell")){
+ std::cout << "Sell" << std::endl;
+ }if(vil->FirstChildElement("trade")){
+ std::cout << "Trade" << std::endl;
}
strcpy(tmp->merchant.back()->name,"meme");