diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2016-03-09 08:40:58 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2016-03-09 08:40:58 -0500 |
commit | c8c09860cb732006e161d26f25ff46e508770218 (patch) | |
tree | e6af9cbebcbdb664bc222c147e3cc6d12e46db8f | |
parent | 98e08cb7c2ae6c61192bac73a1fc7254224452be (diff) |
XML'd pages
-rw-r--r-- | .gitattributes | 2 | ||||
-rw-r--r-- | Changelog | 7 | ||||
-rw-r--r-- | assets/pages/gootaGoFast.png | bin | 20663 -> 20631 bytes | |||
-rw-r--r-- | config/items.h | 45 | ||||
-rw-r--r-- | config/quest_list.txt | 1 | ||||
-rw-r--r-- | include/Texture.h | 2 | ||||
-rw-r--r-- | include/ui.h | 2 | ||||
-rw-r--r-- | src/gameplay.cpp | 18 | ||||
-rw-r--r-- | src/ui.cpp | 42 | ||||
-rw-r--r-- | src/world.cpp | 27 | ||||
-rw-r--r-- | xml/playerSpawnHill1.xml | 3 |
11 files changed, 79 insertions, 70 deletions
diff --git a/.gitattributes b/.gitattributes index b98fd9b..7bb2418 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,6 @@ +include/tinyxml2.h linguist-vendored src/tinyxml2.cpp linguist-vendored src/threadpool.cpp linguist-vendored -include/tinyxml2.h linguist-vendored include/threadpool.h linguist-vendored include/SDL2/* linguist-vendored include/freetype/* linguist-vendored @@ -749,3 +749,10 @@ - fixed world draw shadings - improved merchant menu + +3/9/2016: +========= + + - pages are XMLable and can be drawn + - dialogs are cool with threads + - better lighting diff --git a/assets/pages/gootaGoFast.png b/assets/pages/gootaGoFast.png Binary files differindex a113f5d..639c0f0 100644 --- a/assets/pages/gootaGoFast.png +++ b/assets/pages/gootaGoFast.png diff --git a/config/items.h b/config/items.h deleted file mode 100644 index ee1024c..0000000 --- a/config/items.h +++ /dev/null @@ -1,45 +0,0 @@ - -ID DEBUG_ITEM - NAME "Debug" - TYPE TOOL - WIDTH 1 - HEIGHT 1 - STACKSIZE 1 - TEX "assets/items/ITEM_TEST.png" - ENI - -ID TEST_ITEM - NAME "Dank MayMay" - TYPE TOOL - WIDTH HLINE*10 - HEIGHT HLINE*10 - STACKSIZE 420 - TEX "assets/items/ITEM_TEST.png" - ENI - -ID PLAYER_BAG - NAME "Your Bag" - TYPE EQUIP - WIDTH HLINE*5 - HEIGHT HLINE*5 - STACKSIZE 1 - TEX "assets/items/ITEM_TEST.png" - ENI - -ID FLASHLIGHT - NAME "Flashlight" - TYPE TOOL - WIDTH HLINE*4 - HEIGHT HLINE*8 - STACKSIZE 1 - TEX "assets/items/flashlight_off.png" - ENI - -ID SWORD_WOOD - NAME "Wood Sword" - TYPE SWORD - WIDTH HLINE*4 - HEIGHT HLINE*10 - STACKSIZE 1 - TEX "assets/items/SWORD_WOOD.png" - STOP diff --git a/config/quest_list.txt b/config/quest_list.txt deleted file mode 100644 index 484a2cc..0000000 --- a/config/quest_list.txt +++ /dev/null @@ -1 +0,0 @@ -TITLE "Test" DESC "A test quest" REWARD 1 x SWORD_WOOD END diff --git a/include/Texture.h b/include/Texture.h index 7201a4c..816a8bf 100644 --- a/include/Texture.h +++ b/include/Texture.h @@ -20,7 +20,7 @@ * Texture functions are given a namespace for better organization. */ -namespace Texture{ +namespace Texture { /** * Loads a texture from the given file name, returning the GLuint used for diff --git a/include/ui.h b/include/ui.h index ed9fb94..9523269 100644 --- a/include/ui.h +++ b/include/ui.h @@ -150,6 +150,8 @@ namespace ui { void merchantBox(); void waitForDialog(void); + void drawPage( std::string path ); + /* * Draws a larger string in the center of the screen. Drawing is done inside this function. */ diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 0624067..7155678 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -9,7 +9,6 @@ using namespace tinyxml2; extern Player *player; // main.cpp extern World *currentWorld; // main.cpp -extern float shit; extern Menu *currentMenu; extern Menu pauseMenu; extern Menu optionsMenu; @@ -23,7 +22,7 @@ std::vector<XMLElement *> dopt; void destroyEverything(void); -void segFault(){ +inline void segFault() { (*((int *)NULL))++; } @@ -210,6 +209,21 @@ CONT: return 0; } +void commonPageFunc( Mob *callee ) +{ + static bool lock = false; + + if ( !lock ) { + lock = true; + + ui::drawPage( callee->heyid ); + ui::waitForDialog(); + + callee->alive = false; + lock = false; + } +} + void commonTriggerFunc(Mob *callee){ static bool lock = false; XMLDocument xml; @@ -82,6 +82,8 @@ Mix_Chunk *battleStart; Mix_Chunk *sanic; +static GLuint pageTex = 0; + void Menu::gotoParent(){ if(parent == NULL){ currentMenu = NULL; @@ -655,12 +657,28 @@ namespace ui { } + void drawPage( std::string path ) { + pageTex = Texture::loadTexture( path ); + } + void draw(void){ unsigned char i; float x,y,tmp; char *rtext; - if(dialogBoxExists){ + if ( pageTex ) { + + glEnable( GL_TEXTURE_2D); + glBindTexture( GL_TEXTURE_2D, pageTex ); + glBegin( GL_QUADS ); + glTexCoord2i( 0, 0 ); glVertex2i( offset.x - 300, SCREEN_HEIGHT - 100 ); + glTexCoord2i( 1, 0 ); glVertex2i( offset.x + 300, SCREEN_HEIGHT - 100 ); + glTexCoord2i( 1, 1 ); glVertex2i( offset.x + 300, SCREEN_HEIGHT - 600 ); + glTexCoord2i( 0, 1 ); glVertex2i( offset.x - 300, SCREEN_HEIGHT - 600 ); + glEnd(); + glDisable( GL_TEXTURE_2D); + + } else if (dialogBoxExists){ rtext=typeOut(dialogBoxText); @@ -692,7 +710,7 @@ namespace ui { 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); + glVertex2f(x - 1,y+1); glEnd(); glColor3ub(0,0,0); @@ -787,11 +805,11 @@ namespace ui { glColor3ub(255, 255, 255); glBegin(GL_LINE_STRIP); - glVertex2f(x-1 ,y+1); - glVertex2f(x+1+SCREEN_WIDTH-HLINE*16,y+1); - glVertex2f(x+1+SCREEN_WIDTH-HLINE*16,y-1-SCREEN_HEIGHT/4); - glVertex2f(x-1 ,y-1-SCREEN_HEIGHT/4); - glVertex2f(x ,y+1); + glVertex2i(x-1 ,y+1); + glVertex2i(x+1 +SCREEN_WIDTH-HLINE*16,y+1); + glVertex2i(x+1+SCREEN_WIDTH-HLINE*16,y-1-SCREEN_HEIGHT/4); + glVertex2i(x-1 ,y-1-SCREEN_HEIGHT/4); + glVertex2i( x - 1, y + 1 ); glEnd(); glColor3ub(0,0,0); @@ -1199,6 +1217,13 @@ namespace ui { void dialogAdvance(void){ unsigned char i; + + if ( pageTex ) { + glDeleteTextures( 1, &pageTex ); + pageTex = 0; + return; + } + if(!typeOutDone){ typeOutDone = true; return; @@ -1214,7 +1239,6 @@ namespace ui { } } DONE: - // handle important text if(dialogImportant){ @@ -1254,7 +1278,7 @@ DONE: // mouse clicks case SDL_MOUSEBUTTONDOWN: // right click advances dialog - if ( ( e.button.button & SDL_BUTTON_RIGHT ) && dialogBoxExists ) + if ( ( e.button.button & SDL_BUTTON_RIGHT ) && (dialogBoxExists | pageTex) ) dialogAdvance(); // left click uses item if ( ( e.button.button & SDL_BUTTON_LEFT ) && !dialogBoxExists ) diff --git a/src/world.cpp b/src/world.cpp index 5ce0b2d..af28ac5 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -23,7 +23,8 @@ using namespace tinyxml2; extern Player *player; // main.cpp? extern World *currentWorld; // main.cpp extern int commonAIFunc(NPC *); // entities.cpp -extern void commonTriggerFunc(Mob *); // entities.cpp +extern void commonTriggerFunc(Mob *); // gameplay.cpp +extern void commonPageFunc(Mob *); // gameplay.cpp extern bool inBattle; extern unsigned int tickCount; // main.cpp @@ -1342,7 +1343,8 @@ loadWorldFromXMLNoSave( std::string path ) { float spawnx, randx; bool dialog,Indoor; - const char *ptr,*name; + const char *ptr; + std::string name; currentXML = (std::string)"xml/" + path; @@ -1364,18 +1366,18 @@ loadWorldFromXMLNoSave( std::string path ) { while(wxml){ name = wxml->Name(); - if(!strcmp(name,"link")){ + if ( name == "link" ) { if((ptr = wxml->Attribute("left"))) tmp->setToLeft(ptr); else if((ptr = wxml->Attribute("right"))) tmp->setToRight(ptr); else abort(); - }else if(!strcmp(name,"style")){ + } else if ( name == "style" ) { tmp->setStyle(wxml->StrAttribute("folder")); tmp->setBackground((WorldBGType)wxml->UnsignedAttribute("background")); tmp->setBGM(wxml->StrAttribute("bgm")); - }else if(!strcmp(name,"generation")){ + } else if ( name == "generation" ) { if(!strcmp(wxml->Attribute("type"),"Random")){ if(Indoor) ((IndoorWorld *)tmp)->generate(wxml->UnsignedAttribute("width")); @@ -1385,7 +1387,7 @@ loadWorldFromXMLNoSave( std::string path ) { } }else if(Indoor) abort(); - }else if(!strcmp(name,"mob")){ + } else if ( name == "mob" ) { unsigned int type; type = wxml->UnsignedAttribute("type"); if(wxml->QueryFloatAttribute("x",&spawnx) != XML_NO_ERROR) @@ -1395,7 +1397,7 @@ loadWorldFromXMLNoSave( std::string path ) { if(wxml->QueryBoolAttribute("aggressive",&dialog) == XML_NO_ERROR) tmp->mob.back()->aggressive = dialog; - }else if(!strcmp(name,"npc")){ + } else if ( name == "npc" ) { const char *npcname; if(wxml->QueryFloatAttribute("x",&spawnx) != XML_NO_ERROR) @@ -1415,7 +1417,7 @@ loadWorldFromXMLNoSave( std::string path ) { tmp->npc.back()->addAIFunc(commonAIFunc,false); else tmp->npc.back()->dialogIndex = 9999; - }else if(!strcmp(name,"structure")){ + } else if ( name == "structure" ) { tmp->addStructure((BUILD_SUB)wxml->UnsignedAttribute("type"), wxml->QueryFloatAttribute("x",&spawnx) != XML_NO_ERROR ? getRand() % tmp->getTheWidth() / 2.0f : @@ -1423,9 +1425,12 @@ loadWorldFromXMLNoSave( std::string path ) { 100, wxml->StrAttribute("texture"), wxml->StrAttribute("inside")); - }else if(!strcmp(name,"trigger")){ + } else if ( name == "trigger" ) { tmp->addMob(MS_TRIGGER,wxml->FloatAttribute("x"),0,commonTriggerFunc); tmp->mob.back()->heyid = wxml->Attribute("id"); + } else if ( name == "page" ) { + tmp->addMob( MS_PAGE, wxml->FloatAttribute("x"), 0, commonPageFunc ); + tmp->mob.back()->heyid = wxml->Attribute("id"); } wxml = wxml->NextSiblingElement(); @@ -1449,13 +1454,13 @@ loadWorldFromXMLNoSave( std::string path ) { * READS DATA ABOUT STRUCTURE CONTAINED IN VILLAGE */ - if(!strcmp(name,"structure")){ + if ( name == "structure" ) { tmp->addStructure((BUILD_SUB)vil->UnsignedAttribute("type"), vil->QueryFloatAttribute("x", &spawnx) != XML_NO_ERROR ? randx : spawnx, 100, vil->StrAttribute("texture"), vil->StrAttribute("inside")); - }else if(!strcmp(name, "stall")){ + }else if ( name == "stall" ) { if(!strcmp(vil->Attribute("type"),"market")){ std::cout << "Market" << std::endl; tmp->addStructure((BUILD_SUB)70, diff --git a/xml/playerSpawnHill1.xml b/xml/playerSpawnHill1.xml index 2e8b2aa..c79b93f 100644 --- a/xml/playerSpawnHill1.xml +++ b/xml/playerSpawnHill1.xml @@ -10,6 +10,9 @@ <npc name="Ralph" hasDialog="true" /> <npc name="Johnny" hasDialog="false" /> + + <page x="-200" id="assets/pages/gootaGoFast.png" /> + <village name="the Cranmore Tubing Park"> <structure type="0" x="-300" inside="playerSpawnHill1_Building1.xml"/> <structure type="5" x="-500" inside="playerSpawnHill1_Building1.xml"/> |