]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
XML'd pages
authorClyne Sullivan <tullivan99@gmail.com>
Wed, 9 Mar 2016 13:40:58 +0000 (08:40 -0500)
committerClyne Sullivan <tullivan99@gmail.com>
Wed, 9 Mar 2016 13:40:58 +0000 (08:40 -0500)
.gitattributes
Changelog
assets/pages/gootaGoFast.png
config/items.h [deleted file]
config/quest_list.txt [deleted file]
include/Texture.h
include/ui.h
src/gameplay.cpp
src/ui.cpp
src/world.cpp
xml/playerSpawnHill1.xml

index b98fd9b7d4593a8d329113d42346a1978ac77263..7bb24181c464a6e1b69d4798bcb6587797968d75 100644 (file)
@@ -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
index bac3a6425767ffd6a689334e46d1932c08a5bd48..795aa0d00c9395a77b8e842cdc5cd883acb10b25 100644 (file)
--- a/Changelog
+++ b/Changelog
 
        - fixed world draw shadings
        - improved merchant menu
+
+3/9/2016:
+=========
+
+       - pages are XMLable and can be drawn
+       - dialogs are cool with threads
+       - better lighting
index a113f5d940cb5b89c7b75ef7883564e469681eac..639c0f0f2a98b8c56b03caeced9e1c4470036e46 100644 (file)
Binary files a/assets/pages/gootaGoFast.png and b/assets/pages/gootaGoFast.png differ
diff --git a/config/items.h b/config/items.h
deleted file mode 100644 (file)
index ee1024c..0000000
+++ /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 (file)
index 484a2cc..0000000
+++ /dev/null
@@ -1 +0,0 @@
-TITLE "Test" DESC "A test quest" REWARD 1 x SWORD_WOOD END
index 7201a4c250da6749a93294baf33931a51f2770a0..816a8bfd8250cab764430ebf0b06b1fa7e07658f 100644 (file)
@@ -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
index ed9fb944e6fff4ee1b36da23d304fe24078ebb3d..9523269b4ec15541c3cb814bace53f03edb745fb 100644 (file)
@@ -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.
        */
index 06240679174de1eb10f60f6ffe0b950b90b1f9c3..71556787fca3f389c48d0acd0a67de0752035af5 100644 (file)
@@ -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;
index eb25e2e7e47125ca5cf69467875c0e6cd7e7c131..50ae9de33289732d8d807f25a23b3bd57c7847f0 100644 (file)
@@ -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 )
index 5ce0b2db073f1bc66546829a2c6e595eca375ab0..af28ac5919a1ec3ead995f6632aecb03c792d10f 100644 (file)
@@ -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,
index 2e8b2aadfd82af8df842b04383abcbc911a14190..c79b93f9cef67ed240428508a729e33ef3ea462d 100644 (file)
@@ -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"/>