void DrawHUD() { int i; int color; if(hud.subwindow) { if(hud.windowdraw != NULL) { hud.windowdraw(); } } else { if(Player != NULL) { if(strlen(ThePlayerStats.name) > 0) { DrawWindow(1,30,-60); DrawTextCentered(ThePlayerStats.name,screen,120,18,IndexColor(DarkGrey),F_Large); if((ThePlayerStats.good - ThePlayerStats.evil) > ((ThePlayerStats.good + ThePlayerStats.evil)/2)) DrawTextCentered(ThePlayerStats.name,screen,119,17,IndexColor(LightYellow),F_Large); if((ThePlayerStats.evil - ThePlayerStats.good) > ((ThePlayerStats.good + ThePlayerStats.evil)/2)) DrawTextCentered(ThePlayerStats.name,screen,119,17,IndexColor(Violet),F_Large); else DrawTextCentered(ThePlayerStats.name,screen,119,17,IndexColor(LightGreen),F_Large); } else DrawWindow(1,30,-70); DrawStatusBarHoriz(ThePlayerStats.health, ThePlayerStats.healthmax, LightRed, Red, 40, 2, 160, 4); DrawStatusBarHoriz(ThePlayerStats.stamina, ThePlayerStats.staminamax, Cyan, Blue, 40, 6, 160, 4); if(ThePlayerStats.fatigue < 1000) DrawStatusBarHoriz(ThePlayerStats.fatigue, 2000, LightGreen, DarkGreen, 40, 10, 160, 4); else DrawStatusBarHoriz(ThePlayerStats.fatigue, 2000, Green, DarkGreen, 40, 10, 160, 4); if(ThePlayerStats.stage > 0) { if(ThePlayerStats.fullness > (ThePlayerStats.stage * 25)) DrawStatusBarHoriz(100, 100, Yellow, DarkBlue, 40, 14, 160, 4); else DrawStatusBarHoriz(ThePlayerStats.fullness, (ThePlayerStats.stage * 25), LightViolet, Violet, 40, 14, 160, 4); } } } for(i = 0;i < hud.numbuttons;i++) { if(hud.buttons[i].shown) { DrawSprite(hud.buttons[i].button,screen,hud.buttons[i].box.x,hud.buttons[i].box.y - hud.buttons[i].state, hud.buttons[i].frame); if(strlen(hud.buttons[i].text) > 0) { if(hud.buttonfocus == i)color = LightGreen; else color = Green; DrawTextCentered(hud.buttons[i].text,screen,1 + hud.buttons[i].box.x + (hud.buttons[i].box.w >> 1),hud.buttons[i].box.y + (hud.buttons[i].box.h >> 1) - 10 + 1,IndexColor(DarkGrey),F_Large); DrawTextCentered(hud.buttons[i].text,screen,hud.buttons[i].box.x + (hud.buttons[i].box.w >> 1),hud.buttons[i].box.y + (hud.buttons[i].box.h >> 1) - 10,IndexColor(color),F_Large); } } }
void DrawInfoWin() { int height; DrawSprite(windowsprite,screen,30,20,0); DrawTextCentered(hud.windowheader,screen,120,32,IndexColor(DarkGrey),F_Large); DrawTextCentered(hud.windowheader,screen,119,31,IndexColor(Green),F_Large); if(hud.image == NULL)height = 50; else { DrawSprite(hud.image,screen,120 - (hud.image->w /2), 50,hud.subwindowinfo); height = 60 + hud.image->h; } DrawTextBlock(hud.description,screen,38, height,IndexColor(LightBlue),F_Small,172); }
void DrawButton(Button *button) { if(button->usesprite) { if(!button->State)DrawSprite(button->sprite,screen,button->rect.x,button->rect.y,0); else DrawSprite(button->sprite,screen,button->rect.x,button->rect.y,1); } else { DrawFilledRect(button->rect.x,button->rect.y, button->rect.w, button->rect.h, IndexColor(button->bg), screen); if(!button->State) { DrawFilledRect(button->rect.x,button->rect.y, 1, button->rect.h, IndexColor(Black), screen); DrawFilledRect(button->rect.x,button->rect.y, button->rect.w, 1, IndexColor(White), screen); DrawFilledRect(button->rect.x + button->rect.w,button->rect.y, 1, button->rect.h, IndexColor(White), screen); DrawFilledRect(button->rect.x,button->rect.y + button->rect.h, button->rect.w, 1, IndexColor(Black), screen); } else { DrawFilledRect(button->rect.x,button->rect.y, 1, button->rect.h, IndexColor(White), screen); DrawFilledRect(button->rect.x,button->rect.y, button->rect.w, 1, IndexColor(Black), screen); DrawFilledRect(button->rect.x + button->rect.w,button->rect.y, 1, button->rect.h, IndexColor(Black), screen); DrawFilledRect(button->rect.x,button->rect.y + button->rect.h, button->rect.w, 1, IndexColor(White), screen); } } if(button->text != NULL) { DrawTextCentered(button->text,screen,button->rect.x + (button->rect.w/2),button->rect.y + 2,IndexColor(button->fg),F_Small); } }
void DrawScore() { static int flag1=0; static float pulse1 =0.5f; char temp[80]; if(inMenu == 0) { if(flag1 == 0) { if(pulse1 < 1) { pulse1 += 0.08f; }else flag1 = 1; } if(flag1 == 1) { if(pulse1 > 0.5f) { pulse1 -= 0.08f; }else flag1 = 0; } sprintf(temp,"%08i",score); glColor4f(pulse1,0,1-pulse1,0.62f); DrawTextCentered(temp,videobuffer,videobuffer->w*0.5f,videobuffer->h-30,White_,F_Large); glColor4f(1,1,1,1); } }
void DrawTextWindow() { char message[80]; DrawSprite(mediumwindowsprite,screen,30,200,0); DrawSprite(windowsprite,screen,30,20,0); DrawTextCentered(hud.windowheader,screen,120,32,IndexColor(DarkGrey),F_Large); DrawTextCentered(hud.windowheader,screen,119,31,IndexColor(Green),F_Large); if(hud.editstring[0] == '\0') { DrawText("_",screen,50,228,IndexColor(DarkGrey),F_Large); DrawText("_",screen,49,227,IndexColor(LightGreen),F_Large); } else { sprintf(message,"%s_",hud.editstring); DrawText(message,screen,50,228,IndexColor(DarkGrey),F_Large); DrawText(message,screen,49,227,IndexColor(LightGreen),F_Large); } }
void DrawWindowGeneric(Window *self) { int i; if(self->sprite != NULL) { DrawSprite(self->sprite,screen,self->rect.x,self->rect.y,0); } else { DrawFilledRect(self->rect.x,self->rect.y, self->rect.w, self->rect.h, IndexColor(self->fg), screen); DrawFilledRect(self->rect.x,self->rect.y, 1, self->rect.h, IndexColor(self->fg), screen); DrawFilledRect(self->rect.x,self->rect.y, self->rect.w, 1, IndexColor(self->fg), screen); DrawFilledRect(self->rect.x + self->rect.w,self->rect.y, 1, self->rect.h, IndexColor(self->fg), screen); DrawFilledRect(self->rect.x,self->rect.y + self->rect.h, self->rect.w, 1, IndexColor(self->fg), screen); } DrawTextCentered(self->title,screen,self->rect.x + (self->rect.w /2),self->rect.y + 2,IndexColor(self->bg),F_Small); for(i = 0; i < self->buttoncount;i++) { DrawButton(self->buttonlist[i]); } }
void DrawElementWindow() { int i; int percent; char message[80]; DrawSprite(windowsprite,screen,30,30,0); switch(hud.subwindowinfo) { case 0: DrawTextCentered("Condition",screen,120,38,IndexColor(DarkGrey),F_Large); DrawTextCentered("Condition",screen,119,37,IndexColor(LightGreen),F_Large); DrawTextCentered(ThePlayerStats.stagename,screen,120,60,IndexColor(DarkGrey),F_Large); DrawTextCentered(ThePlayerStats.stagename,screen,119,59,IndexColor(Green),F_Large); sprintf(message,"Age: %i",PlayerStats[Player->playernum].Age ); DrawText(message,screen,61,80,IndexColor(DarkGrey),F_Medium); DrawText(message,screen,60,79,IndexColor(Green),F_Medium); DrawSprite(attributes,screen,60,96,6); sprintf(message,"%i / %i",(int)PlayerStats[Player->playernum].health,PlayerStats[Player->playernum].healthmax ); DrawText(message,screen,79,97,IndexColor(DarkGrey),F_Medium); DrawText(message,screen,78,96,IndexColor(Green),F_Medium); DrawSprite(attributes,screen,60,97 + 24,7); sprintf(message,"%i / %i",(int)PlayerStats[Player->playernum].stamina,PlayerStats[Player->playernum].staminamax ); DrawText(message,screen,79,97 + 24,IndexColor(DarkGrey),F_Medium); DrawText(message,screen,78,96 + 24,IndexColor(Green),F_Medium); DrawSprite(attributes,screen,60,96 + 48,8); sprintf(message,"%i / %i",(int)PlayerStats[Player->playernum].fullness,PlayerStats[Player->playernum].stage * 25 ); DrawText(message,screen,79,97 + 48,IndexColor(DarkGrey),F_Medium); DrawText(message,screen,78,96 + 48,IndexColor(Green),F_Medium); sprintf(message,"Food: %i",PlayerStats[Player->playernum].foodsupply ); DrawText(message,screen,61,96 + 48 + 20,IndexColor(DarkGrey),F_Medium); DrawText(message,screen,60,97 + 48 + 20,IndexColor(Green),F_Medium); break; case 1: DrawTextCentered("Attributes",screen,120,38,IndexColor(DarkGrey),F_Large); DrawTextCentered("Attributes",screen,119,37,IndexColor(Green),F_Large); for(i = 0;i < 6;i++) { DrawSprite(attributes,screen,60,66 + (24 * i),i); sprintf(message,"%i",PlayerStats[Player->playernum].attributes[i]); DrawText(message,screen,79,67 + (24 * i),IndexColor(DarkGrey),F_Medium); if(PlayerStats[Player->playernum].attributetrains[i] <= 0) DrawText(message,screen,78,66 + (24 * i),IndexColor(DarkGreen),F_Medium); else if(PlayerStats[Player->playernum].attributetrains[i] < 10) DrawText(message,screen,78,66 + (24 * i),IndexColor(Green),F_Medium); else DrawText(message,screen,78,66 + (24 * i),IndexColor(LightGreen),F_Medium); } break; case 2: DrawTextCentered("Elements",screen,120,38,IndexColor(DarkGrey),F_Large); DrawTextCentered("Elements",screen,119,37,IndexColor(Green),F_Large); for(i = 0;i < 5;i++) { DrawSprite(elements,screen,60,56 + (33 * i),i); sprintf(message,"%i",(int)PlayerStats[Player->playernum].Element[i]); DrawText(message,screen,79,57 + (33 * i),IndexColor(DarkGrey),F_Medium); DrawText(message,screen,78,56 + (33 * i),IndexColor(Green),F_Medium); DrawSprite(elements,screen,75,56 + (33 * i) + 16,i + 5); } DrawSprite(elements,screen,120,74,12);/*good*/ if(ThePlayerStats.good) { percent = (ThePlayerStats.good * 0.001)*100; if(percent <= 0)percent = 1; DrawFilledRect(140,130 - (percent), 16, percent, IndexColor(LightYellow),screen); } DrawSprite(elements,screen,120,122,11);/*balance*/ DrawSprite(elements,screen,120,170,10);/*evil*/ if(ThePlayerStats.evil) { percent = (ThePlayerStats.evil * 0.001)*100; if(percent <= 0)percent = 1; DrawFilledRect(140,130, 16, percent, IndexColor(LightViolet),screen); } break; case 3: DrawTextCentered("Attacks",screen,120,38,IndexColor(DarkGrey),F_Large); DrawTextCentered("Attacks",screen,119,37,IndexColor(Green),F_Large); for(i = 0;i < PlayerStats[Player->playernum].numattacks;i++) { sprintf(message,"%s",PlayerStats[Player->playernum].attacks[i]); DrawText(message,screen,79,57 + (20 * i),IndexColor(DarkGrey),F_Medium); DrawText(message,screen,78,56 + (20 * i),IndexColor(Green),F_Medium); } break; case 4: DrawTextCentered("Other Skills",screen,120,38,IndexColor(DarkGrey),F_Large); DrawTextCentered("Other Skills",screen,119,37,IndexColor(Green),F_Large); for(i = 0;i < PlayerStats[Player->playernum].numdefenses;i++) { sprintf(message,"%s",PlayerStats[Player->playernum].defenses[i]); DrawText(message,screen,79,57 + (20 * i),IndexColor(DarkGrey),F_Medium); DrawText(message,screen,78,56 + (20 * i),IndexColor(Green),F_Medium); } break; } }
void DrawYesNoWindow() { DrawSprite(mediumwindowsprite,screen,30,60,0); DrawTextCentered(hud.windowheader,screen,120,68,IndexColor(DarkGrey),F_Large); DrawTextCentered(hud.windowheader,screen,119,67,IndexColor(Green),F_Large); }
int updateMainMenu() { BBox boxtemp; BBox CursorBox; static float pulse=0.5f; static int delay=190; static int flag=0; static float fadein =0.1f; CursorBox.x=Mouse.x; CursorBox.y=Mouse.y; CursorBox.w=1; CursorBox.h=1; if(delay > 0) delay--; if(fadein < 1) fadein += 0.01f; if(flag == 0) { if(pulse < 1) { pulse += 0.04f; }else flag = 1; } if(flag == 1) { if(pulse > 0.7f) { pulse -= 0.04f; }else flag = 0; } glColor4f(fadein,fadein,fadein,fadein); glEnable(GL_BLEND); /*draw the intro text*/ DrawTextCentered("Invasion",(S_Data.xres *0.5f),(S_Data.yres *0.2f),White_,F_Medium); glDisable(GL_BLEND); if(fadein >= 0.6f) { /*draw the text, returns the collision box of the text*/ boxtemp=DrawTxt("New Game",(S_Data.xres *0.4f),(S_Data.yres *0.65f),White_,F_Small); /*tests if the cursor is colliding with the text, if so then the text pulses*/ if(BoxCollide2(boxtemp,CursorBox)==1) { glColor4f(pulse,pulse,pulse,1); DrawTxt("New Game",(S_Data.xres *0.4f),(S_Data.yres *0.65f),White_,F_Small); glColor4f(1,1,1,1); /*if the mouse is over the box and the mouse button is clicked then it calls what it needs to be called*/ if(SDL_GetMouseState(NULL,NULL)) { fadein =1.0f; buttondelay=15; return 1; } } /*draw the text, returns the collision box of the text*/ boxtemp=DrawTxt("Quit",(S_Data.xres *0.45f),(S_Data.yres *0.75f),White_,F_Small); /*tests if the cursor is colliding with the text, if so then the text pulses*/ if(BoxCollide2(boxtemp,CursorBox)==1) { glColor4f(pulse,pulse,pulse,1); DrawTxt("Quit",(S_Data.xres *0.45f),(S_Data.yres *0.75f),White_,F_Small); glColor4f(1,1,1,1); /*if the mouse is over the box and the mouse button is clicked then it calls what it needs to be called*/ if(SDL_GetMouseState(NULL,NULL)) { exit(1); return 0; } } } return 0; }