From 5351512258182e69786d3be915eab524919a1309 Mon Sep 17 00:00:00 2001 From: "chirs241097@gmail.com" Date: Tue, 8 Apr 2014 13:41:35 +0000 Subject: Port player preference menu, pause menu and return to title menu to the new menu code base. Add shake effect to player preference menu. Make effects faster... Press esc in a menu will select back/exit now. Add several background transfers. Fix possible memory leaks in HangUpText. Remove some commented statements. --- CHANGELOG.TXT | 10 + VERSION.TXT | 2 +- global.h | 2 +- levels.h | 9 +- libcghEx.cpp | 8 +- main.cpp | 65 ++++-- menus.h | 655 +++++++++++++++++++++++++++++++++++++++++++++++++--------- 7 files changed, 630 insertions(+), 121 deletions(-) diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 0b786bf..6e08ceb 100755 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -8,6 +8,16 @@ Random segmentation fault in "Hyper-threading".(seen only once, can not reproduce now...) Pre-Released versions: +0.9.1-0_PR (r84) +Port player preference menu, pause menu and return to title menu +to the new menu code base. +Add shake effect to player preference menu. +Make effects faster... +Press esc in a menu will select back/exit now. +Add several background transfers. +Fix possible memory leaks in HangUpText. +Remove some commented statements. + 0.9.1-0_PR (r83) Now you can change the game resolution. Some resources are not re-made so they may look blurred... diff --git a/VERSION.TXT b/VERSION.TXT index 6adfed4..e0e926c 100755 --- a/VERSION.TXT +++ b/VERSION.TXT @@ -1 +1 @@ -0.9.1-0_PR (r83) \ No newline at end of file +0.9.1-0_PR (r84) \ No newline at end of file diff --git a/global.h b/global.h index f77dbbe..63f28da 100644 --- a/global.h +++ b/global.h @@ -331,7 +331,7 @@ static const char* archive[]={ }; #endif //static const char* GLOBAL_H_FN="global.h"; -static const char* BLRVERSION="0.9.1-0_PR (r83)"; +static const char* BLRVERSION="0.9.1-0_PR (r84)"; static const char* BuiltDate=__DATE__; void Throw(char *Filename,char *Info) diff --git a/levels.h b/levels.h index af4a65c..1c04cb5 100644 --- a/levels.h +++ b/levels.h @@ -48,6 +48,12 @@ bool sout,tendone;bool dmt[16]; void Level1Part0(){++part;} void Level1Part1() { + if(DBGColor!=0xFF888820) + { + for(int i=0;i<3;++i) + DBGColor=ColorTransfer(DBGColor,0xFF888820); + return; + } CreateTower1(400,300,857,2); frameleft=AMinute*2; tcnt=1;sout=false;dscroll=-0.025f;memset(dmt,true,sizeof(dmt)); @@ -3530,7 +3536,8 @@ Good luck and go for the highest score!\ } if (Current_Position==1) { - if((DBGColor=ColorTransfer(DBGColor,0xFF1B2065))!=0xFF1B2065)frameleft=10; + if((DBGColor=ColorTransfer(DBGColor,0xFF1B2065))!=0xFF1B2065) + DBGColor=ColorTransfer(DBGColor,0xFF1B2065),frameleft=10; else{++part;IfShowTip=true;bulcnt=0;return;} } } diff --git a/libcghEx.cpp b/libcghEx.cpp index 860b322..78aeb02 100644 --- a/libcghEx.cpp +++ b/libcghEx.cpp @@ -80,6 +80,7 @@ bool HangUpText::Active(){return TFont&&!done;} void HangUpText::Init(const char *Font,const char *_Text,double _tlim,double _alim,double _dlim,DWORD _color) { TFont=new hgeFont(Font); + TFont->SetScale(0.8); strcpy(Text,_Text); Limit=_tlim;alim=_alim;dlim=_dlim;TFont->SetColor(_color); Progresser.Init(0,dlim,Limit);Progalpha.Init(0,255,Limit/2); @@ -99,8 +100,13 @@ void HangUpText::Process(double DT) Progalpha.Init(255,0,Limit/2); Progalpha.Launch(); } - if (Progalpha.GetA()>Progalpha.GetB()&&Progresser.GetElapsed()>=Limit)return (void)(done=true); + if (Progalpha.GetA()>Progalpha.GetB()&&Progresser.GetElapsed()>=Limit) + { + delete TFont;TFont=0; + return (void)(done=true); + } Progalpha.Update(DT); + if(!TFont)return; TFont->SetColor(SETA(TFont->GetColor(),Progalpha.GetValue())); TFont->printf(Position.x,Position.y,HGETEXT_CENTER,Text); } diff --git a/main.cpp b/main.cpp index 2f8aeaa..f5b34b9 100644 --- a/main.cpp +++ b/main.cpp @@ -623,11 +623,14 @@ bool FrameFunc() float dt=hge->Timer_GetDelta(); static float t=0.0f; float tx,ty; - if (Current_Position==1&&hge->Input_GetKeyState(HGEK_ESCAPE))PauseGUI_Init(); - int MMR=-1,SMR=-1,OMR=-1; + if (Current_Position==1&&hge->Input_GetKeyState(HGEK_ESCAPE))pauseMenu.Init(-200);//PauseGUI_Init(); + int MMR=-1,SMR=-1,OMR=-1,PPMR=-1,PMR=-1,RTTMR=-1; if (mainMenu.isActive())MMR=mainMenu.Update(); if (startMenu.isActive())SMR=startMenu.Update(); if (optionMenu.isActive())OMR=optionMenu.Update(); + if (playerPreferenceMenu.isActive())PPMR=playerPreferenceMenu.Update(); + if (pauseMenu.isActive())PMR=pauseMenu.Update(); + if (returnToTitleMenu.isActive())RTTMR=returnToTitleMenu.Update(); if (Current_Position==0) { if(!mainMenu.isActive())return true; @@ -731,13 +734,34 @@ bool FrameFunc() if (Current_Position==8)HighScoreGUI_FrameFnk(); if (Current_Position==9)HSViewGUI_FrameFnk(); if (Current_Position==10)HSDetGUI_FrameFnk(); - if (Current_Position==11)PauseGUI_FrameFnk(); - if (Current_Position==12)BkTTitleGUI_FrameFnk(); + if (Current_Position==11) + { + if(~PMR) + { + pauseMenu.Leave(); + if(PMR==2)returnToTitleMenu.Init(-200),Current_Position=12; + return false; + } + } + if (Current_Position==12) + { + if(~RTTMR) + { + returnToTitleMenu.Leave(); + if(RTTMR==1)pauseMenu.Init(-200); + if(RTTMR==2)mainMenu.Init(-200),Current_Position=0; + } + } if (Current_Position==13) { if(~OMR) { if(OMR==4||OMR==5)optionMenu.Leave(); + if(OMR==4) + { + playerPreferenceMenu.Init(-200); + Current_Position=14; + } if(OMR==5) { Options_Writeback(); @@ -747,8 +771,21 @@ bool FrameFunc() return false; } } - if (Current_Position==14)PlayerProfGUI_FrameFnk(); - // Here we update our background animation + if (Current_Position==14) + { + if(~PPMR) + { + if(PPMR==5) + { + if(AP_Update(plrspd,plrslospd,clrbns)<=10000) + optionMenu.Init(850), + Current_Position=13, + playerPreferenceMenu.Leave(); + else playerPreferenceMenu.Shake(); + } + return false; + } + } t+=dt; tx=50*cosf(t/60); ty=50*sinf(t/60); @@ -772,12 +809,12 @@ bool FrameFunc() if(mainMenu.isActive())mainMenu.Render(); if(startMenu.isActive())startMenu.Render(); if(optionMenu.isActive())optionMenu.Render(); + if(playerPreferenceMenu.isActive())playerPreferenceMenu.Render(); + if(pauseMenu.isActive())pauseMenu.Render(); + if(returnToTitleMenu.isActive())returnToTitleMenu.Render(); if (Current_Position==0||Current_Position==3||Current_Position==8|| Current_Position==9||Current_Position==10||Current_Position==13||Current_Position==14) { - //titlespr->Render(160,0); - //if (Current_Position==0)gui->Render(); - //mainMenu.Render(); titlespr->Render(160,0); } if (Current_Position==1||Current_Position==2||Current_Position==5||Current_Position==11||Current_Position==12) @@ -854,10 +891,6 @@ bool FrameFunc() if (Current_Position==8)HighScoreGUI->Render(); if (Current_Position==9)HSViewGUI->Render(); if (Current_Position==10)HSDetailGUI->Render(); - if (Current_Position==11)PauseGUI->Render(); - if (Current_Position==12)BkTTitleGUI->Render(); - //if (Current_Position==13)OptionsGUI->Render(); - if (Current_Position==14)PlayerProfGUI->Render(); fnt->SetColor(0xFFFFFFFF); rbPanelFont.UpdateString(L" FPS: %.2f",hge->Timer_GetFPSf()); rbPanelFont.Render(785,595,0xFFFFFFFF,1); @@ -1137,7 +1170,7 @@ int main(int argc,char *argv[]) if(!quad.tex||!SprSheet||!TexTitle||!TexCredits) Error("Error Loading Resources!",true); quad.blend=BLEND_ALPHABLEND | BLEND_COLORMUL | BLEND_NOZWRITE; - DBGColor=0xFF888820; + DBGColor=0xFFFFFFFF; for(int i=0;i<4;i++) { quad.v[i].z=0.5f; @@ -1179,6 +1212,8 @@ int main(int argc,char *argv[]) } mainMenu.Init_Once();if(!startLvl)mainMenu.Init(-200); startMenu.Init_Once();optionMenu.Init_Once(); + pauseMenu.Init_Once();returnToTitleMenu.Init_Once(); + playerPreferenceMenu.Init_Once(); gui=new hgeGUI(); gui->AddCtrl(new hgeGUIMenuItem(1,fnt,snd,400,200,0.0f,"Start")); gui->AddCtrl(new hgeGUIMenuItem(2,fnt,snd,400,240,0.1f,"Highscores && Records")); @@ -1188,7 +1223,7 @@ int main(int argc,char *argv[]) gui->SetNavMode(HGEGUI_UPDOWN | HGEGUI_CYCLED); gui->SetCursor(spr); gui->SetFocus(1); - gui->Enter(); + //gui->Enter(); if(LOWFPS)hge->System_Log("%s: Low FPS Mode Enabled.",MAIN_SRC_FN); if(fNoSound)hge->System_Log("%s: Sound is disabled.",MAIN_SRC_FN); if(startLvl) diff --git a/menus.h b/menus.h index e9b285c..8c26fdc 100644 --- a/menus.h +++ b/menus.h @@ -17,30 +17,83 @@ void ConfigureQuad(hgeQuad *quad,double x,double y,double w,double h) quad->v[2].x=x+w;quad->v[2].y=y+h; quad->v[3].x=x;quad->v[3].y=y+h; } +int AP_Update(int plrspd,int plrslospd,int clrbns) +{ + int res=0; + if (plrspd<=4)res+=plrspd*1200;else res+=5000; + switch (plrslospd) + { + case 1:res+=4000;break; + case 2:res+=3200;break; + case 3:res+=2000;break; + case 4:res+=1500;break; + case 5:res+=700;break; + } + switch (clrbns) + { + case 0:break; + case 1:res+=1500;break; + case 2:res+=2700;break; + case 3:res+=4000;break; + case 4:res+=5500;break; + } + return res; +} +void Options_Writeback() +{ + freopen("blr.cfg","w",stdout); + printf(";CBL"); + printf("%c",fpslvl==2?1:0); + printf("%c",tfs?1:0); + printf("%c",VidMode); + printf("%c",diffkey?1:0); + printf("%c%c%c%c",plrspd,plrslospd,clrbns,clrmode); + fclose(stdout); +} static const char* MMStr[]={ -"Start", -"Highscore", -"Options", -"About", -"Exit" + "Start", + "Highscore", + "Options", + "About", + "Exit" }; static const char* OMStr[]={ -"Fullscreen", -"VSync", -"Clear Range Key", -"Resolution", -"Player Preference", -"Save and Exit", -"On", -"Off", -"X", -"Z", -"800x600", -"640x480", -"960x720", -"1024x768", -"1280x960", -"?" + "Fullscreen", + "VSync", + "Clear Range Key", + "Resolution", + "Player Preference", + "Save and Exit", + "On", + "Off", + "X", + "Z", + "800x600", + "640x480", + "960x720", + "1024x768", + "1280x960", + "?" +}; +static const char *PPMStr[]={ + "Moving Speed", + "Precise Moving Speed", + "Clear Range Bonus", + "Clear Range Mode", + "Ability Point", + "Back", + "Expand", + "Rotate" +}; +static const char *PMStr[]={ + "Paused...", + "Return to Game", + "Return to Title" +}; +static const char *RTTMStr[]={ + "Really?", + "I've pressed the wrong key...", + "Do return to title!" }; class MainMenu { @@ -62,15 +115,23 @@ public: xoffset=start;onIn=true;active=true; selected=0;dyoffset=yoffset=-selected*30; ConfigureQuad(&UpperGradient,xoffset-140,100,320,50); - UpperGradient.v[0].col=UpperGradient.v[1].col=0xFF888820; - UpperGradient.v[2].col=UpperGradient.v[3].col=0x00888820; + UpperGradient.v[0].col=UpperGradient.v[1].col=SETA(DBGColor,0xFF); + UpperGradient.v[2].col=UpperGradient.v[3].col=SETA(DBGColor,0x00); ConfigureQuad(&LowerGradient,xoffset-140,300,320,100); - LowerGradient.v[0].col=LowerGradient.v[1].col=0x00888820; - LowerGradient.v[2].col=LowerGradient.v[3].col=0xFF888820; + LowerGradient.v[0].col=LowerGradient.v[1].col=SETA(DBGColor,0x00); + LowerGradient.v[2].col=LowerGradient.v[3].col=SETA(DBGColor,0xFF); } void Leave(){onOut=true;} int Update() { + if(DBGColor!=0xFF0A0A0A) + { + for(int i=0;i<4;++i)DBGColor=ColorTransfer(DBGColor,0xFF0A0A0A); + UpperGradient.v[0].col=UpperGradient.v[1].col=SETA(DBGColor,0xFF); + UpperGradient.v[2].col=UpperGradient.v[3].col=SETA(DBGColor,0x00); + LowerGradient.v[0].col=LowerGradient.v[1].col=SETA(DBGColor,0x00); + LowerGradient.v[2].col=LowerGradient.v[3].col=SETA(DBGColor,0xFF); + } if(onIn) { if(fabs(xoffset-650)Timer_GetDelta()*1600)return xoffset=650,onIn=false,-1; @@ -88,10 +149,11 @@ public: ConfigureQuad(&LowerGradient,xoffset-140,400,320,110); if(hge->Input_GetKeyStateEx(HGEK_UP)==HGEKST_HIT&&selected>0)--selected; if(hge->Input_GetKeyStateEx(HGEK_DOWN)==HGEKST_HIT&&selected<5-1)++selected; + if(hge->Input_GetKeyStateEx(HGEK_ESCAPE)==HGEKST_HIT)selected=4; yoffset=-selected*30; - if(fabs(dyoffset-yoffset)<0.2)dyoffset=yoffset; - if(dyoffsetTimer_GetDelta()*200; - if(dyoffset>yoffset)dyoffset-=hge->Timer_GetDelta()*200; + if(fabs(dyoffset-yoffset)<7)dyoffset=yoffset; + if(dyoffsetTimer_GetDelta()*400; + if(dyoffset>yoffset)dyoffset-=hge->Timer_GetDelta()*400; if(hge->Input_GetKeyStateEx(HGEK_Z)==HGEKST_HIT||hge->Input_GetKeyStateEx(HGEK_ENTER)==HGEKST_HIT) return selected; return -1; @@ -135,14 +197,14 @@ public: active=true;onIn=true;yoffset=275; selected=0;xoffset=-selected*300;moffset=450; ConfigureQuad(&LowerGradient,0,400+yoffset,800,120); - LowerGradient.v[0].col=LowerGradient.v[1].col=0x01888820; - LowerGradient.v[2].col=LowerGradient.v[3].col=0xFF888820; + LowerGradient.v[0].col=LowerGradient.v[1].col=SETA(DBGColor,0x00); + LowerGradient.v[2].col=LowerGradient.v[3].col=SETA(DBGColor,0xFF); ConfigureQuad(&LeftGradient,0,320+yoffset,100,200); - LeftGradient.v[0].col=LeftGradient.v[3].col=0xFF888820; - LeftGradient.v[1].col=LeftGradient.v[2].col=0x01888820; + LeftGradient.v[0].col=LeftGradient.v[3].col=SETA(DBGColor,0xFF); + LeftGradient.v[1].col=LeftGradient.v[2].col=SETA(DBGColor,0x00); ConfigureQuad(&RightGradient,700,320+yoffset,100,200); - RightGradient.v[0].col=RightGradient.v[3].col=0x01888820; - RightGradient.v[1].col=RightGradient.v[2].col=0xFF888820; + RightGradient.v[0].col=RightGradient.v[3].col=SETA(DBGColor,0x00); + RightGradient.v[1].col=RightGradient.v[2].col=SETA(DBGColor,0xFF); } void Leave(){onOut=true;} int Update() @@ -204,14 +266,14 @@ private: bool active,onIn,onOut,onSwitch,onSwitchi; int selected; double xoffset,yoffset,dyoffset,swoffset,moffset; - hgeSprite *Ribb,*msel; + hgeSprite *Ribb,*optt; hgeQuad UpperGradient,LowerGradient; public: bool isActive(){return active;} void Init_Once() { Ribb=new hgeSprite(MenuTex,256,350,64,16); - msel=new hgeSprite(MenuTex,256,192,256,64); + optt=new hgeSprite(MenuTex,256,192,256,64); Ribb->SetColor(0xCCFFFFFF); } void Init(double start) @@ -219,11 +281,11 @@ public: xoffset=start;onIn=active=true;onSwitch=onSwitchi=false; selected=0;dyoffset=yoffset=-selected*30;moffset=350; ConfigureQuad(&UpperGradient,xoffset-140,250,500,50); - UpperGradient.v[0].col=UpperGradient.v[1].col=0xFF888820; - UpperGradient.v[2].col=UpperGradient.v[3].col=0x00888820; + UpperGradient.v[0].col=UpperGradient.v[1].col=SETA(DBGColor,0xFF); + UpperGradient.v[2].col=UpperGradient.v[3].col=SETA(DBGColor,0x00); ConfigureQuad(&LowerGradient,xoffset-140,430,500,100); - LowerGradient.v[0].col=LowerGradient.v[1].col=0x00888820; - LowerGradient.v[2].col=LowerGradient.v[3].col=0xFF888820; + LowerGradient.v[0].col=LowerGradient.v[1].col=SETA(DBGColor,0x00); + LowerGradient.v[2].col=LowerGradient.v[3].col=SETA(DBGColor,0xFF); } void Leave(){onOut=true;} int Update() @@ -260,11 +322,12 @@ public: { if(hge->Input_GetKeyStateEx(HGEK_UP)==HGEKST_HIT&&selected>0)--selected; if(hge->Input_GetKeyStateEx(HGEK_DOWN)==HGEKST_HIT&&selected<6-1)++selected; + if(hge->Input_GetKeyStateEx(HGEK_ESCAPE)==HGEKST_HIT)selected=5; } yoffset=-selected*30; - if(fabs(dyoffset-yoffset)<0.2)dyoffset=yoffset; - if(dyoffsetTimer_GetDelta()*200; - if(dyoffset>yoffset)dyoffset-=hge->Timer_GetDelta()*200; + if(fabs(dyoffset-yoffset)<7)dyoffset=yoffset; + if(dyoffsetTimer_GetDelta()*400; + if(dyoffset>yoffset)dyoffset-=hge->Timer_GetDelta()*400; if(hge->Input_GetKeyStateEx(HGEK_RIGHT)==HGEKST_HIT&&hge->Input_GetKeyStateEx(HGEK_LEFT)==HGEKST_HIT)return -1; if(hge->Input_GetKeyStateEx(HGEK_RIGHT)==HGEKST_HIT||hge->Input_GetKeyStateEx(HGEK_Z)==HGEKST_HIT||hge->Input_GetKeyStateEx(HGEK_ENTER)==HGEKST_HIT) { @@ -292,7 +355,7 @@ public: if(hge->Input_GetKeyStateEx(HGEK_LEFT)==HGEKST_HIT) { if(onSwitch||onSwitchi)return -1; - if(selected<=2){onSwitch=true;swoffset=100;} + if(selected<=3){onSwitchi=true;swoffset=0;} if(selected==0)tfs=!tfs; if(selected==1) { @@ -303,7 +366,7 @@ public: if(selected==2)diffkey=!diffkey; if(selected==3) { - --VidMode;onSwitchi=true;swoffset=0; + --VidMode; if(VidMode<0)VidMode=4; } return selected; @@ -321,44 +384,80 @@ public: MenuFont->printf(xoffset,calcy,HGETEXT_LEFT,OMStr[i]); if(i==0) { - if(!onSwitch||selected!=0) + if(!(onSwitch||onSwitchi)||selected!=0) MenuFont->printf(xoffset+200,calcy,HGETEXT_LEFT,OMStr[tfs?6:7]); else { - MenuFont->SetColor(SETA(0xFFFFFF,255.0f*(swoffset/100.0f))); - MenuFont->printf(xoffset+100+swoffset,calcy,HGETEXT_LEFT,OMStr[tfs?7:6]); - MenuFont->SetColor(SETA(0xFFFFFF,255.0f-255.0f*(swoffset/100.0f))); - MenuFont->printf(xoffset+200+swoffset,calcy,HGETEXT_LEFT,OMStr[tfs?6:7]); - swoffset-=hge->Timer_GetDelta()*400; - if(swoffset<0)swoffset=0,onSwitch=false; + if(onSwitch) + { + MenuFont->SetColor(SETA(0xFFFFFF,255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+100+swoffset,calcy,HGETEXT_LEFT,OMStr[tfs?7:6]); + MenuFont->SetColor(SETA(0xFFFFFF,255.0f-255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+200+swoffset,calcy,HGETEXT_LEFT,OMStr[tfs?6:7]); + swoffset-=hge->Timer_GetDelta()*400; + if(swoffset<0)swoffset=0,onSwitch=false; + } + if(onSwitchi) + { + MenuFont->SetColor(SETA(0xFFFFFF,255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+100+swoffset,calcy,HGETEXT_LEFT,OMStr[tfs?6:7]); + MenuFont->SetColor(SETA(0xFFFFFF,255.0f-255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+200+swoffset,calcy,HGETEXT_LEFT,OMStr[tfs?7:6]); + swoffset+=hge->Timer_GetDelta()*400; + if(swoffset>100)swoffset=0,onSwitchi=false; + } } } if(i==1) { - if(!onSwitch||selected!=1) + if(!(onSwitch||onSwitchi)||selected!=1) MenuFont->printf(xoffset+200,calcy,HGETEXT_LEFT,OMStr[fpslvl==2?6:7]); else { - MenuFont->SetColor(SETA(0xFFFFFF,255.0f*(swoffset/100.0f))); - MenuFont->printf(xoffset+100+swoffset,calcy,HGETEXT_LEFT,OMStr[fpslvl==2?7:6]); - MenuFont->SetColor(SETA(0xFFFFFF,255.0f-255.0f*(swoffset/100.0f))); - MenuFont->printf(xoffset+200+swoffset,calcy,HGETEXT_LEFT,OMStr[fpslvl==2?6:7]); - swoffset-=hge->Timer_GetDelta()*400; - if(swoffset<0)swoffset=0,onSwitch=false; + if(onSwitch) + { + MenuFont->SetColor(SETA(0xFFFFFF,255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+100+swoffset,calcy,HGETEXT_LEFT,OMStr[fpslvl==2?7:6]); + MenuFont->SetColor(SETA(0xFFFFFF,255.0f-255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+200+swoffset,calcy,HGETEXT_LEFT,OMStr[fpslvl==2?6:7]); + swoffset-=hge->Timer_GetDelta()*400; + if(swoffset<0)swoffset=0,onSwitch=false; + } + if(onSwitchi) + { + MenuFont->SetColor(SETA(0xFFFFFF,255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+100+swoffset,calcy,HGETEXT_LEFT,OMStr[fpslvl==2?6:7]); + MenuFont->SetColor(SETA(0xFFFFFF,255.0f-255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+200+swoffset,calcy,HGETEXT_LEFT,OMStr[fpslvl==2?7:6]); + swoffset+=hge->Timer_GetDelta()*400; + if(swoffset>100)swoffset=0,onSwitchi=false; + } } } if(i==2) { - if(!onSwitch||selected!=2) + if(!(onSwitch||onSwitchi)||selected!=2) MenuFont->printf(xoffset+200,calcy,HGETEXT_LEFT,OMStr[diffkey?8:9]); else { - MenuFont->SetColor(SETA(0xFFFFFF,255.0f*(swoffset/100.0f))); - MenuFont->printf(xoffset+100+swoffset,calcy,HGETEXT_LEFT,OMStr[diffkey?9:8]); - MenuFont->SetColor(SETA(0xFFFFFF,255.0f-255.0f*(swoffset/100.0f))); - MenuFont->printf(xoffset+200+swoffset,calcy,HGETEXT_LEFT,OMStr[diffkey?8:9]); - swoffset-=hge->Timer_GetDelta()*400; - if(swoffset<0)swoffset=0,onSwitch=false; + if(onSwitch) + { + MenuFont->SetColor(SETA(0xFFFFFF,255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+100+swoffset,calcy,HGETEXT_LEFT,OMStr[diffkey?9:8]); + MenuFont->SetColor(SETA(0xFFFFFF,255.0f-255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+200+swoffset,calcy,HGETEXT_LEFT,OMStr[diffkey?8:9]); + swoffset-=hge->Timer_GetDelta()*400; + if(swoffset<0)swoffset=0,onSwitch=false; + } + if(onSwitchi) + { + MenuFont->SetColor(SETA(0xFFFFFF,255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+100+swoffset,calcy,HGETEXT_LEFT,OMStr[diffkey?8:9]); + MenuFont->SetColor(SETA(0xFFFFFF,255.0f-255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+200+swoffset,calcy,HGETEXT_LEFT,OMStr[diffkey?9:8]); + swoffset+=hge->Timer_GetDelta()*400; + if(swoffset>100)swoffset=0,onSwitchi=false; + } } } if(i==3) @@ -389,13 +488,398 @@ public: } } } - Ribb->RenderEx(xoffset-50,355,0,6,1); - Ribb->RenderEx(xoffset-50,382,0,6,1); + Ribb->RenderEx(xoffset-50,353,0,6,1); + Ribb->RenderEx(xoffset-50,380,0,6,1); hge->Gfx_RenderQuad(&UpperGradient); hge->Gfx_RenderQuad(&LowerGradient); - msel->Render(300,moffset+300); + optt->Render(300,moffset+300); } }optionMenu; +class PlayerPreferenceMenu +{ +private: + bool active,onIn,onOut,onSwitch,onSwitchi; + int selected; + double xoffset,yoffset,dyoffset,swoffset,moffset; + double shaketime,shakeoffset,shakedelay; + hgeSprite *Ribb,*optt; + hgeQuad UpperGradient,LowerGradient; +public: + bool isActive(){return active;} + void Init_Once() + { + Ribb=new hgeSprite(MenuTex,256,350,64,16); + optt=new hgeSprite(MenuTex,0,256,256,64); + Ribb->SetColor(0xCCFFFFFF); + } + void Init(double start) + { + xoffset=start;onIn=active=true;onSwitch=onSwitchi=false; + selected=0;dyoffset=yoffset=-selected*30;moffset=350;shaketime=0; + ConfigureQuad(&UpperGradient,xoffset-140,250,520,50); + UpperGradient.v[0].col=UpperGradient.v[1].col=SETA(DBGColor,0xFF); + UpperGradient.v[2].col=UpperGradient.v[3].col=SETA(DBGColor,0x00); + ConfigureQuad(&LowerGradient,xoffset-140,430,520,100); + LowerGradient.v[0].col=LowerGradient.v[1].col=SETA(DBGColor,0x00); + LowerGradient.v[2].col=LowerGradient.v[3].col=SETA(DBGColor,0xFF); + } + void Leave(){onOut=true;} + void Shake(){shaketime=0.2;shakeoffset=10;shakedelay=0.033;} + int Update() + { + if(onIn) + { + bool alldone=true; + if(fabs(xoffset-430)Timer_GetDelta()*1600)xoffset=430;else + { + alldone=false; + if(xoffset<430) + xoffset+=hge->Timer_GetDelta()*1600; + else + xoffset-=hge->Timer_GetDelta()*1600; + } + if(fabs(moffset-0)Timer_GetDelta()*1200) + moffset=0; + else alldone=false,moffset-=hge->Timer_GetDelta()*1200; + if(alldone)return onIn=false,-1; + } + if(onOut) + { + bool alldone=true; + xoffset+=hge->Timer_GetDelta()*1600; + if(xoffset<850)alldone=false; + if(fabs(moffset-450)Timer_GetDelta()*1200) + moffset=450; + else alldone=false,moffset+=hge->Timer_GetDelta()*800; + if(alldone)active=onOut=false; + } + ConfigureQuad(&UpperGradient,xoffset-140,250,520,100); + ConfigureQuad(&LowerGradient,xoffset-140,430,520,100); + if(!onSwitch) + { + if(hge->Input_GetKeyStateEx(HGEK_UP)==HGEKST_HIT&&selected>0) + --selected==4?--selected:0; + if(hge->Input_GetKeyStateEx(HGEK_DOWN)==HGEKST_HIT&&selected<6-1) + ++selected==4?++selected:0; + if(hge->Input_GetKeyStateEx(HGEK_ESCAPE)==HGEKST_HIT)selected=5; + } + yoffset=-selected*30; + if(fabs(dyoffset-yoffset)<7)dyoffset=yoffset; + if(dyoffsetTimer_GetDelta()*400; + if(dyoffset>yoffset)dyoffset-=hge->Timer_GetDelta()*400; + if(hge->Input_GetKeyStateEx(HGEK_RIGHT)==HGEKST_HIT&&hge->Input_GetKeyStateEx(HGEK_LEFT)==HGEKST_HIT)return -1; + if(hge->Input_GetKeyStateEx(HGEK_RIGHT)==HGEKST_HIT) + { + if(onSwitch||onSwitchi)return -1; + if(selected<=3) + { + onSwitch=true; + swoffset=100; + } + if(selected==0)++plrspd>5?plrspd=1:0; + if(selected==1)++plrslospd>5?plrslospd=1:0; + if(selected==2)++clrbns>4?clrbns=0:0; + if(selected==3)clrmode=!clrmode; + if(selected<=3)return selected; + } + if(hge->Input_GetKeyStateEx(HGEK_LEFT)==HGEKST_HIT) + { + if(onSwitch||onSwitchi)return -1; + if(selected<=3){onSwitchi=true;swoffset=0;} + if(selected==0)--plrspd<1?plrspd=5:0; + if(selected==1)--plrslospd<1?plrslospd=5:0; + if(selected==2)--clrbns<0?clrbns=4:0; + if(selected==3)clrmode=!clrmode; + if(selected<=3)return selected; + } + if(hge->Input_GetKeyStateEx(HGEK_Z)==HGEKST_HIT||hge->Input_GetKeyStateEx(HGEK_ENTER)==HGEKST_HIT) + return selected; + return -1; + } + void Render() + { + for(int i=0;i<6;++i) + { + double calcy=i*30+dyoffset+360; + if(calcy>249.9&&calcy<500.1) + { + MenuFont->SetColor(0xFFFFFFFF); + MenuFont->printf(xoffset-50,calcy,HGETEXT_LEFT,PPMStr[i]); + if(i==0) + { + if(!(onSwitch||onSwitchi)||selected!=0) + MenuFont->printf(xoffset+200,calcy,HGETEXT_LEFT,"%d",plrspd); + else + { + if(onSwitch) + { + MenuFont->SetColor(SETA(0xFFFFFF,255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+100+swoffset,calcy,HGETEXT_LEFT,"%d",plrspd==1?5:plrspd-1); + MenuFont->SetColor(SETA(0xFFFFFF,255.0f-255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+200+swoffset,calcy,HGETEXT_LEFT,"%d",plrspd); + swoffset-=hge->Timer_GetDelta()*400; + if(swoffset<0)swoffset=0,onSwitch=false; + } + if(onSwitchi) + { + MenuFont->SetColor(SETA(0xFFFFFF,255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+100+swoffset,calcy,HGETEXT_LEFT,"%d",plrspd); + MenuFont->SetColor(SETA(0xFFFFFF,255.0f-255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+200+swoffset,calcy,HGETEXT_LEFT,"%d",plrspd==5?1:plrspd+1); + swoffset+=hge->Timer_GetDelta()*400; + if(swoffset>100)swoffset=0,onSwitchi=false; + } + } + } + if(i==1) + { + if(!(onSwitch||onSwitchi)||selected!=1) + MenuFont->printf(xoffset+200,calcy,HGETEXT_LEFT,"%d",plrslospd); + else + { + if(onSwitch) + { + MenuFont->SetColor(SETA(0xFFFFFF,255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+100+swoffset,calcy,HGETEXT_LEFT,"%d",plrslospd==1?5:plrslospd-1); + MenuFont->SetColor(SETA(0xFFFFFF,255.0f-255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+200+swoffset,calcy,HGETEXT_LEFT,"%d",plrslospd); + swoffset-=hge->Timer_GetDelta()*400; + if(swoffset<0)swoffset=0,onSwitch=false; + } + if(onSwitchi) + { + MenuFont->SetColor(SETA(0xFFFFFF,255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+100+swoffset,calcy,HGETEXT_LEFT,"%d",plrslospd); + MenuFont->SetColor(SETA(0xFFFFFF,255.0f-255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+200+swoffset,calcy,HGETEXT_LEFT,"%d",plrslospd==5?1:plrslospd+1); + swoffset+=hge->Timer_GetDelta()*400; + if(swoffset>100)swoffset=0,onSwitchi=false; + } + } + } + if(i==2) + { + if(!(onSwitch||onSwitchi)||selected!=2) + MenuFont->printf(xoffset+200,calcy,HGETEXT_LEFT,"%d",clrbns); + else + { + if(onSwitch) + { + MenuFont->SetColor(SETA(0xFFFFFF,255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+100+swoffset,calcy,HGETEXT_LEFT,"%d",clrbns==0?4:clrbns-1); + MenuFont->SetColor(SETA(0xFFFFFF,255.0f-255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+200+swoffset,calcy,HGETEXT_LEFT,"%d",clrbns); + swoffset-=hge->Timer_GetDelta()*400; + if(swoffset<0)swoffset=0,onSwitch=false; + } + if(onSwitchi) + { + MenuFont->SetColor(SETA(0xFFFFFF,255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+100+swoffset,calcy,HGETEXT_LEFT,"%d",clrbns); + MenuFont->SetColor(SETA(0xFFFFFF,255.0f-255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+200+swoffset,calcy,HGETEXT_LEFT,"%d",clrbns==4?0:clrbns+1); + swoffset+=hge->Timer_GetDelta()*400; + if(swoffset>100)swoffset=0,onSwitchi=false; + } + } + } + if(i==3) + { + if(!(onSwitch||onSwitchi)||selected!=3) + MenuFont->printf(xoffset+200,calcy,HGETEXT_LEFT,PPMStr[clrmode?7:6]); + else + { + if(onSwitch) + { + MenuFont->SetColor(SETA(0xFFFFFF,255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+100+swoffset,calcy,HGETEXT_LEFT,PPMStr[clrmode?6:7]); + MenuFont->SetColor(SETA(0xFFFFFF,255.0f-255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+200+swoffset,calcy,HGETEXT_LEFT,PPMStr[clrmode?7:6]); + swoffset-=hge->Timer_GetDelta()*400; + if(swoffset<0)swoffset=0,onSwitch=false; + } + if(onSwitchi) + { + MenuFont->SetColor(SETA(0xFFFFFF,255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+100+swoffset,calcy,HGETEXT_LEFT,PPMStr[clrmode?7:6]); + MenuFont->SetColor(SETA(0xFFFFFF,255.0f-255.0f*(swoffset/100.0f))); + MenuFont->printf(xoffset+200+swoffset,calcy,HGETEXT_LEFT,PPMStr[clrmode?6:7]); + swoffset+=hge->Timer_GetDelta()*400; + if(swoffset>100)swoffset=0,onSwitchi=false; + } + } + } + if(i==4) + { + if(shaketime>0) + { + shaketime-=hge->Timer_GetDelta(); + shakedelay-=hge->Timer_GetDelta(); + if(shakedelay<0) + {shakeoffset=-shakeoffset;shakedelay=0.033;} + if(shaketime<=0)shaketime=shakeoffset=0; + } + MenuFont->printf(xoffset+200+shakeoffset,calcy,HGETEXT_LEFT,"%d/10000",AP_Update(plrspd,plrslospd,clrbns)); + } + } + } + Ribb->RenderEx(xoffset-80,355,0,7,1); + Ribb->RenderEx(xoffset-80,382,0,7,1); + hge->Gfx_RenderQuad(&UpperGradient); + hge->Gfx_RenderQuad(&LowerGradient); + optt->Render(125,moffset+300); + } +}playerPreferenceMenu; +class PauseMenu +{ +private: + bool active,onIn,onOut; + int selected; + double xoffset,yoffset,dyoffset; + hgeSprite *Ribb; + hgeQuad UpperGradient,LowerGradient; +public: + bool isActive(){return active;} + void Init_Once() + { + Ribb=new hgeSprite(MenuTex,256,350,64,16); + Ribb->SetColor(0xCCFFFFFF); + } + void Init(double start) + { + //special things to do.. + Music_Pause(); + Current_Position=11; + DisableAllTower=DisablePlayer=true; + xoffset=start;onIn=true;active=true; + selected=1;dyoffset=yoffset=-selected*30; + ConfigureQuad(&UpperGradient,xoffset-140,190,320,50); + UpperGradient.v[0].col=UpperGradient.v[1].col=SETA(DBGColor,0xFF); + UpperGradient.v[2].col=UpperGradient.v[3].col=SETA(DBGColor,0x00); + ConfigureQuad(&LowerGradient,xoffset-140,340,320,100); + LowerGradient.v[0].col=LowerGradient.v[1].col=SETA(DBGColor,0x00); + LowerGradient.v[2].col=LowerGradient.v[3].col=SETA(DBGColor,0xFF); + } + void Leave(){onOut=true;} + int Update() + { + if(onIn) + { + if(fabs(xoffset-350)Timer_GetDelta()*1600)return xoffset=350,onIn=false,-1; + if(xoffset<350) + xoffset+=hge->Timer_GetDelta()*1600; + else + xoffset-=hge->Timer_GetDelta()*1600; + } + if(onOut) + { + xoffset+=hge->Timer_GetDelta()*1600; + if(xoffset>=850) + { + active=onOut=false; + if(selected==1)Current_Position=1,DisableAllTower=DisablePlayer=false; + } + } + ConfigureQuad(&UpperGradient,xoffset-140,190,320,100); + ConfigureQuad(&LowerGradient,xoffset-140,340,320,110); + if(hge->Input_GetKeyStateEx(HGEK_UP)==HGEKST_HIT&&selected>1)--selected; + if(hge->Input_GetKeyStateEx(HGEK_DOWN)==HGEKST_HIT&&selected<3-1)++selected; + yoffset=-selected*30; + if(fabs(dyoffset-yoffset)<7)dyoffset=yoffset; + if(dyoffsetTimer_GetDelta()*400; + if(dyoffset>yoffset)dyoffset-=hge->Timer_GetDelta()*400; + if(hge->Input_GetKeyStateEx(HGEK_Z)==HGEKST_HIT||hge->Input_GetKeyStateEx(HGEK_ENTER)==HGEKST_HIT) + return selected; + if(hge->Input_GetKeyStateEx(HGEK_ESCAPE)==HGEKST_HIT&&!onIn)return 1; + return -1; + } + void Render() + { + for(int i=0;i<3;++i) + { + double calcy=i*30+dyoffset+300; + if(calcy>189.9&&calcy<440.1) + MenuFont->printf(xoffset,calcy,HGETEXT_LEFT,PMStr[i]); + } + Ribb->RenderEx(xoffset-50,295,0,4,1); + Ribb->RenderEx(xoffset-50,322,0,4,1); + hge->Gfx_RenderQuad(&UpperGradient); + hge->Gfx_RenderQuad(&LowerGradient); + } +}pauseMenu; +class ReturnToTitleMenu +{ +private: + bool active,onIn,onOut; + int selected; + double xoffset,yoffset,dyoffset; + hgeSprite *Ribb; + hgeQuad UpperGradient,LowerGradient; +public: + bool isActive(){return active;} + void Init_Once() + { + Ribb=new hgeSprite(MenuTex,256,350,64,16); + Ribb->SetColor(0xCCFFFFFF); + } + void Init(double start) + { + xoffset=start;onIn=true;active=true; + selected=1;dyoffset=yoffset=-selected*30; + ConfigureQuad(&UpperGradient,xoffset-140,190,320,50); + UpperGradient.v[0].col=UpperGradient.v[1].col=SETA(DBGColor,0xFF); + UpperGradient.v[2].col=UpperGradient.v[3].col=SETA(DBGColor,0x00); + ConfigureQuad(&LowerGradient,xoffset-140,340,320,100); + LowerGradient.v[0].col=LowerGradient.v[1].col=SETA(DBGColor,0x00); + LowerGradient.v[2].col=LowerGradient.v[3].col=SETA(DBGColor,0xFF); + } + void Leave(){onOut=true;} + int Update() + { + //The background color is likely on a change here... + UpperGradient.v[0].col=UpperGradient.v[1].col=SETA(DBGColor,0xFF); + UpperGradient.v[2].col=UpperGradient.v[3].col=SETA(DBGColor,0x00); + LowerGradient.v[0].col=LowerGradient.v[1].col=SETA(DBGColor,0x00); + LowerGradient.v[2].col=LowerGradient.v[3].col=SETA(DBGColor,0xFF); + if(onIn) + { + if(fabs(xoffset-350)Timer_GetDelta()*1600)return xoffset=350,onIn=false,-1; + if(xoffset<350) + xoffset+=hge->Timer_GetDelta()*1600; + else + xoffset-=hge->Timer_GetDelta()*1600; + } + if(onOut) + { + xoffset+=hge->Timer_GetDelta()*1600; + if(xoffset>=850)active=onOut=false; + } + ConfigureQuad(&UpperGradient,xoffset-140,190,320,100); + ConfigureQuad(&LowerGradient,xoffset-140,340,320,110); + if(hge->Input_GetKeyStateEx(HGEK_UP)==HGEKST_HIT&&selected>1)--selected; + if(hge->Input_GetKeyStateEx(HGEK_DOWN)==HGEKST_HIT&&selected<3-1)++selected; + yoffset=-selected*30; + if(fabs(dyoffset-yoffset)<7)dyoffset=yoffset; + if(dyoffsetTimer_GetDelta()*400; + if(dyoffset>yoffset)dyoffset-=hge->Timer_GetDelta()*400; + if(hge->Input_GetKeyStateEx(HGEK_Z)==HGEKST_HIT||hge->Input_GetKeyStateEx(HGEK_ENTER)==HGEKST_HIT) + return selected; + return -1; + } + void Render() + { + for(int i=0;i<3;++i) + { + double calcy=i*30+dyoffset+300; + if(calcy>189.9&&calcy<440.1) + MenuFont->printf(xoffset,calcy,HGETEXT_LEFT,RTTMStr[i]); + } + Ribb->RenderEx(xoffset-50,295,0,6.5,1); + Ribb->RenderEx(xoffset-50,322,0,6.5,1); + hge->Gfx_RenderQuad(&UpperGradient); + hge->Gfx_RenderQuad(&LowerGradient); + } +}returnToTitleMenu; //================================================================================== //Here's where old code dies... hgeGUI *StartGUI,*DeathGUI,*CompleteGUI,*HighScoreGUI; @@ -981,39 +1465,6 @@ void PauseGUI_FrameFnk() } } } -int AP_Update(int plrspd,int plrslospd,int clrbns) -{ - int res=0; - if (plrspd<=4)res+=plrspd*1200;else res+=5000; - switch (plrslospd) - { - case 1:res+=4000;break; - case 2:res+=3200;break; - case 3:res+=2000;break; - case 4:res+=1500;break; - case 5:res+=700;break; - } - switch (clrbns) - { - case 0:break; - case 1:res+=1500;break; - case 2:res+=2700;break; - case 3:res+=4000;break; - case 4:res+=5500;break; - } - return res; -} -void Options_Writeback() -{ - freopen("blr.cfg","w",stdout); - printf(";CBL"); - printf("%c",fpslvl==2?1:0); - printf("%c",tfs?1:0); - printf("%c",VidMode); - printf("%c",diffkey?1:0); - printf("%c%c%c%c",plrspd,plrslospd,clrbns,clrmode); - fclose(stdout); -} void OptionsGUI_Init() { OptionsGUI=new hgeGUI(); -- cgit v1.2.3