void GUI::FreeMessages() { if(GetMessages()) { GetMessages()->Clear(); delete GetMessages(); SetMessages(NULL); } }
// -------------------- void Edit(void){ char M,Str[256]; int I,LX,LY; SetLevel(0); DrawGame(); DrawMenu(M_Fg); DrawMenu(M_Bg); DrawTxtMenu(M_Txt); DrawMsg(""); while (1){ LX=MX; LY=MY; UC=0; if (!MB) SDL_Delay(200); else SDL_Delay(50); SDL_PollEvent(&event); OperMenu(&M_Fg); OperMenu(&M_Bg); if ((UC>='0')&&(UC<='9')){ Lvl[Level].M[MX/20][MY/20].txt=UC-'0'; DrawGame(); } if (Shift){ Lvl[Level].M[MX/20][MY/20].txt=-1; DrawGame(); } if ((MB==1)&&(MX<400)&&(MY<400)){ if ((LX/20!=MX/20)||(LY/2!=MY/20)) MBlock=0; if (!MBlock){ Lvl[Level].M[MX/20][MY/20].FSpr=M_Fg.E[M_Fg.Akt].Spr; Lvl[Level].M[MX/20][MY/20].FTyp=M_Fg.E[M_Fg.Akt].Typ; Lvl[Level].M[MX/20][MY/20].BSpr=M_Bg.E[M_Bg.Akt].Spr; Lvl[Level].M[MX/20][MY/20].BTyp=M_Bg.E[M_Bg.Akt].Typ; MBlock=1; DrawGame(); } } if ((MB==2)&&(MX<400)&&(MY<400)){ for (I=0;I<M_Fg.L;I++) if ((Lvl[Level].M[MX/20][MY/20].FSpr==M_Fg.E[I].Spr)&&(Lvl[Level].M[MX/20][MY/20].FTyp==M_Fg.E[I].Typ)){ M_Fg.Top=M_Fg.Akt=I; DrawMenu(M_Fg); } for (I=0;I<M_Bg.L;I++) if ((Lvl[Level].M[MX/20][MY/20].BSpr==M_Bg.E[I].Spr)&&(Lvl[Level].M[MX/20][MY/20].BTyp==M_Bg.E[I].Typ)){ M_Bg.Top=M_Bg.Akt=I; DrawMenu(M_Bg); } MBlock=1; DrawGame(); } if (M=OperTxtMenu(M_Txt)){ if (M==1){ //name InputScr("Enter level name:"); GetString(Lvl[Level].Name,50,1,195); SetCaption(); DrawGame(); } else if (M==2){ //password InputScr("Enter level password:"******"Enter time limit (0-999 secs):"); sprintf(Str,"%d",Lvl[Level].DL); GetString(Str,3,1,195); Lvl[Level].DL=atoi(Str); DrawGame(); } else if (M==4) //bgimg SelectBgImg(); else if (M==5) //txt SetMessages(); else if (M==6){ //go to InputScr("Enter level no. (0-99):"); sprintf(Str,"%d",Level); GetString(Str,2,1,195); Level=atoi(Str); SetLevel(Level); DrawGame(); } else if (M==7){ //save InputScr("Enter filename:"); if (GetString(LFile,255,1,195)){ if (Save(LFile)) DrawMsg("Saved..."); else DrawMsg("Can't save!"); }else DrawMsg("Aborted..."); DrawGame(); } } if (Up&&(Level<99)){ SetLevel(Level+1); DrawGame(); SDL_Delay(200); } if ((Down)&&(Level>0)){ SetLevel(Level-1); DrawGame(); SDL_Delay(200); } if (Quit==2) return; } }