aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gameplay.cpp18
-rw-r--r--src/ui.cpp42
-rw-r--r--src/world.cpp27
3 files changed, 65 insertions, 22 deletions
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;
diff --git a/src/ui.cpp b/src/ui.cpp
index eb25e2e..50ae9de 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -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,