bool AvalancheEngine::loadGame(const int16 slot) { Common::String fileName = getSaveFileName(slot); Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(fileName); if (!f) return false; uint32 signature = f->readUint32LE(); if (signature != MKTAG('A', 'V', 'A', 'L')) return false; // Check version. We can't restore from obsolete versions. byte saveVersion = f->readByte(); if (saveVersion > kSavegameVersion) { warning("Savegame of incompatible version!"); delete f; return false; } // Read the description. uint32 descSize = f->readUint32LE(); Common::String description; for (uint32 i = 0; i < descSize; i++) { char actChar = f->readByte(); description += actChar; } description.toUppercase(); Graphics::skipThumbnail(*f); // Read the time the game was saved. TimeDate t; t.tm_mday = f->readSint16LE(); t.tm_mon = f->readSint16LE(); t.tm_year = f->readSint16LE(); resetAllVariables(); Common::Serializer sz(f, NULL); synchronize(sz); delete f; _isLoaded = true; _animationsEnabled = false; if (_holdTheDawn) { _holdTheDawn = false; fadeIn(); } _background->release(); minorRedraw(); _dropdown->setup(); setRoom(kPeopleAvalot, _room); _alive = true; refreshObjectList(); _animation->updateSpeed(); drawDirection(); _animation->animLink(); _background->update(); Common::String tmpStr = Common::String::format("%cLoaded: %c%s.ASG%c%c%c%s%c%csaved on %s.", kControlItalic, kControlRoman, description.c_str(), kControlCenter, kControlNewLine, kControlNewLine, _roomnName.c_str(), kControlNewLine, kControlNewLine, expandDate(t.tm_mday, t.tm_mon, t.tm_year).c_str()); _dialogs->displayText(tmpStr); AnimationType *avvy = _animation->_sprites[0]; if (avvy->_quick && avvy->_visible) _animation->setMoveSpeed(0, _animation->getDirection()); // We push Avvy in the right direction is he was moving. return true; }
void getBt(int Id, int ind){ int cod, getOK = false; char dado[50], codi; switch(Id){ case WINLOGIN: //janela de login switch(ind){ case 1: //bot�o entrar if((strcmp(win.id[Id].fd[1].text, "MATHEUS") == 0) && (strcmp(win.id[Id].fd[2].text, "123") == 0)){ win.id[Id].act = false; //refaz o palco hidemouseptr(); RemakeStage(); showmouseptr(); //tira o listener da janela mexit = true; }else{ MsgLine("Senha ou Usuario nao comferem!", "Incorreto", ERRO); } break; } break; case WINROOM: //janela de entrada de salas switch(ind){ case 1: //botão salvar cod = setRoom(); WinClose(WINROOM); MsgLine("Nova Sala incluida! cod: ", "Sucesso!", ALERTA); cprintf("%d", cod); break; } break; case GOOGLE: switch(ind){ case 1: //botão buscar if(strtol(win.id[GOOGLE].fd[1].text, NULL, 10) <= recordsDB(WINROOM)-1){ hidemouseptr(); //chama cabe�alho da janela de edição MakeWindow(27, 4, 43, 13, "Edita Sala", WHITE, BLACK, WINROOME); MakeField(4, 3, 4, "Numero:", BLACK, WHITE, NUMBERS, WINROOME); MakeField(15, 3, 2, "Bloco:", BLACK, WHITE, NUMBERS, WINROOME); MakeField(25, 3, 3, "Lotacao:", BLACK, WHITE, NUMBERS, WINROOME); MakeField(4, 7, 2, "Data Show:", BLACK, WHITE, CHECK, WINROOME); MakeField(15, 7, 2, "Lousa Digital:", BLACK, WHITE, CHECK, WINROOME); MakeField(4, 10, 2, "Ar Cond.:", BLACK, WHITE, CHECK, WINROOME); MakeField(15, 10, 2, "Computador:", BLACK, WHITE, CHECK, WINROOME); MakeField(30, 7, 2, "Ventilador:", BLACK, WHITE, NUMBERS, WINROOME); MakeField(30, 10, 2, "Tomadas:", BLACK, WHITE, NUMBERS, WINROOME); MakeButton(31, 12, 10, "Salva", MAGENTA, WHITE, WINROOME); MakeButton(19, 12, 3, "<-", MAGENTA, WHITE, WINROOME); MakeButton(25, 12, 3, "->", MAGENTA, WHITE, WINROOME); //agora preenche campos if(getRoom(win.id[GOOGLE].fd[1].text) == true){ showmouseptr(); last = c; WinListener(WINROOME); WinClose(GOOGLE); }else{ WinClose(WINROOME); WinClose(GOOGLE); showmouseptr(); MsgLine("Registro nao encontrado!", "405!", ERRO); } //cprintf("Acabou o listener"); }else{ MsgLine("Registro nao encontrado!", "404!", ERRO); } break; } break; case GOOGLE1: switch(ind){ case 1: //botão buscar if(strtol(win.id[GOOGLE1].fd[1].text, NULL, 10) <= recordsDB(AGEND)-1){ hidemouseptr(); //chama cabe�alho da janela de novo agendamento MakeWindow(27, 4, 43, 16, "Novo Agendamento", WHITE, BLACK, AGENDE); MakeField(4, 3, 4, "Sala:", BLACK, WHITE, NUMBERS, AGENDE); MakeField(4, 6, 2, "Dia:", BLACK, WHITE, NUMBERS, AGENDE); MakeField(8, 6, 2, "Mes:", BLACK, WHITE, NUMBERS, AGENDE); MakeField(12, 6, 4, "Ano:", BLACK, WHITE, NUMBERS, AGENDE); MakeField(4, 9, 5, "Hora Ini.:", BLACK, WHITE, HORAS, AGENDE); MakeField(16, 9, 5, "Hora Fin.:", BLACK, WHITE, HORAS, AGENDE); MakeField(4, 12, 35, "Responsavel:", BLACK, WHITE, CHARS, AGENDE); MakeButton(18, 15, 3, "<-", MAGENTA, WHITE, AGENDE); MakeButton(24, 15, 3, "->", MAGENTA, WHITE, AGENDE); //agora preenche campos if(getAgend(win.id[GOOGLE1].fd[1].text) == true){ showmouseptr(); last = c; WinListener(AGENDE); WinClose(GOOGLE1); }else{ WinClose(AGENDE); WinClose(GOOGLE1); showmouseptr(); MsgLine("Registro nao encontrado!", "405!", ERRO); } }else{ MsgLine("Registro nao encontrado!", "404!", ERRO); } break; } break; case DELROOM: switch(ind){ case 1: //apagar delay(200); hidemouseptr(); //chama cabe�alho da janela de edição MakeWindow(35, 6, 23, 7, "Certeza!?", WHITE, BLACK, SHURE); MakeField(5, 4, 4, "Deseja Apagar?", WHITE, YELLOW, NUMBERS, SHURE); MakeButton(5, 6, 5, "Sim", MAGENTA, WHITE, SHURE); MakeButton(13, 6, 5, "Nao", MAGENTA, WHITE, SHURE); showmouseptr(); WinListener(SHURE); strcpy(&dado, win.id[DELROOM].fd[1].text); WinClose(DELROOM); if(deler == true){ if(delRoom(dado) == true){ MsgLine("Registro removido com sucesso!", "Sucesso!", ALERTA); }else{ MsgLine("Registro nao encontrado!", "404!", ERRO); } } break; } break; case SHURE: switch(ind){ case 1: //sim WinClose(SHURE); deler = true; break; case 2: //não WinClose(SHURE); deler = false; break; } break; case WINROOME: switch(ind){ case 1: //salvar //cprintf("Agora sim..."); if(editRoom(c) == true) MsgLine("Editado com Sucesso!", "Sucesso!", ALERTA); else MsgLine("Erro ao Editar Arquivo!", "500!", ERRO); delay(130); break; case 2: //para frente if(c >= 1){ cod = c-1; if(cod >= 1){ //pega codigo sprintf(&dado, "%d", cod); //limpa campos TrashField(WINROOME); getOK = getRoom(dado); //agora preenche campos while((getOK == false) && (cod >= 1)){ c --; cod = c; sprintf(&dado, "%d", cod); getOK = getRoom(dado); //e manda de novo } if(getOK == true){ last = c; //cprintf("manolo %d", last); getchar(); sprintf(&dado, "Edita Sala cod: %d", c); strcpy(&win.id[Id].label, dado); //refaz tuto hidemouseptr(); RemakeStage(); showmouseptr(); }else{ cod = last; //cprintf("manolo %d", last); getchar(); sprintf(&dado, "%d", cod); getOK = getRoom(dado); //e manda de novo sprintf(&dado, "Edita Sala cod: %d", c); strcpy(&win.id[Id].label, dado); //refaz tuto hidemouseptr(); RemakeStage(); showmouseptr(); MsgLine("Comeco dos Registros", "Total!", ALERTA); } }else{ MsgLine("Comeco dos Registros", "Total!", ALERTA); } delay(120); } break; case 3: //para trás gambiarra lembra m = variavel global if(c < recordsDB(WINROOM)){ cod = c+1; if(cod < recordsDB(WINROOM)){ //pega codigo sprintf(&dado, "%d", cod); //limpa campos TrashField(WINROOME); //agora preenche campos getOK = getRoom(dado); //verifica se existe mesmo while((getOK == false) && (cod < recordsDB(WINROOM))){ c++; cod = c; sprintf(&dado, "%d", cod); getOK = getRoom(dado); //e manda de novo } if(getOK == true){ last = c; //cprintf("manolo %d", last); getchar(); sprintf(&dado, "Edita Sala cod: %d", c); strcpy(&win.id[Id].label, dado); //refaz tuto hidemouseptr(); RemakeStage(); showmouseptr(); }else{ cod = last; //cprintf("manolo %d", last); getchar(); sprintf(&dado, "%d", cod); getOK = getRoom(dado); //e manda de novo sprintf(&dado, "Edita Sala cod: %d", c); strcpy(&win.id[Id].label, dado); //refaz tuto hidemouseptr(); RemakeStage(); showmouseptr(); MsgLine("Fim dos Registros", "Total!", ALERTA); } }else{ MsgLine("Fim dos Registros", "Total!", ALERTA); } delay(120); } break; } break; case AGENDE: switch(ind){ case 1: //para frente if(c >= 1){ cod = c-1; if(cod >= 1){ //pega codigo sprintf(&dado, "%d", cod); //limpa campos TrashField(AGENDE); getOK = getAgend(dado); //agora preenche campos while((getOK == false) && (cod >= 1)){ c --; cod = c; sprintf(&dado, "%d", cod); getOK = getAgend(dado); //e manda de novo } if(getOK == true){ last = c; //cprintf("manolo %d", last); getchar(); sprintf(&dado, "Mostra Agendamento cod: %d", c); strcpy(&win.id[Id].label, dado); //refaz tuto hidemouseptr(); RemakeStage(); showmouseptr(); }else{ cod = last; //cprintf("manolo %d", last); getchar(); sprintf(&dado, "%d", cod); getOK = getAgend(dado); //e manda de novo sprintf(&dado, "Mosta Agendamento cod: %d", c); strcpy(&win.id[Id].label, dado); //refaz tuto hidemouseptr(); RemakeStage(); showmouseptr(); MsgLine("Comeco dos Registros", "Total!", ALERTA); } }else{ MsgLine("Comeco dos Registros", "Total!", ALERTA); } delay(120); } break; case 2: //para trás gambiarra lembra m = variavel global if(c < recordsDB(AGEND)){ cod = c+1; if(cod < recordsDB(AGEND)){ //pega codigo sprintf(&dado, "%d", cod); //limpa campos TrashField(AGENDE); //agora preenche campos getOK = getAgend(dado); //verifica se existe mesmo while((getOK == false) && (cod < recordsDB(AGEND))){ c++; cod = c; sprintf(&dado, "%d", cod); getOK = getAgend(dado); //e manda de novo } if(getOK == true){ last = c; //cprintf("manolo %d", last); getchar(); sprintf(&dado, "Mostra Agendamento cod: %d", c); strcpy(win.id[Id].label, dado); //refaz tuto hidemouseptr(); RemakeStage(); showmouseptr(); }else{ cod = last; //cprintf("manolo %d", last); getchar(); sprintf(dado, "%d", cod); getOK = getRoom(dado); //e manda de novo sprintf(&dado, "Mostra Agendamento cod: %d", c); strcpy(&win.id[Id].label, dado); //refaz tuto hidemouseptr(); RemakeStage(); showmouseptr(); MsgLine("Fim dos Registros", "Total!", ALERTA); } }else{ MsgLine("Fim dos Registros", "Total!", ALERTA); } delay(120); } break; } break; case DELAGEND: switch(ind){ case 1: //apagar delay(200); hidemouseptr(); //chama cabe�alho da janela de edição MakeWindow(35, 6, 23, 7, "Certeza!?", WHITE, BLACK, SHURE); MakeField(5, 4, 4, "Deseja Apagar?", WHITE, YELLOW, NUMBERS, SHURE); MakeButton(5, 6, 5, "Sim", MAGENTA, WHITE, SHURE); MakeButton(13, 6, 5, "Nao", MAGENTA, WHITE, SHURE); showmouseptr(); WinListener(SHURE); strcpy(dado, win.id[DELAGEND].fd[1].text); WinClose(DELAGEND); if(deler == true){ if(delAgend(dado) == true){ MsgLine("Registro removido com sucesso!", "Sucesso!", ALERTA); }else{ MsgLine("Registro nao encontrado!", "404!", ERRO); } } break; } break; case AGEND: switch(ind){ case 1: //botao salvar //cod = setAgend(); codi = setAgend(); if(codi == 'S'){ WinClose(AGEND); MsgLine("Novo Agendamento incluido! cod: ", "Sucesso!", ALERTA); cprintf("%d", recordsDB(AGEND)-1); }else if(codi == 'N'){ MsgLine("Sala nao existe! ", "Inexistente!", ERRO); //cprintf("%c", codi); }else if(codi == 'H'){ MsgLine("Horario ja esta em uso!", "Ocupado!", ERRO); }else{ MsgLine("Erro Indeterminado!", "GATES!", ERRO); } break; } break; case RELATR: funcRelar(ind); break; } }