void GameStateCutscene::logic() { if (!initialized) { if (settings->music_volume > 0 && !music.empty()) { // restart music so that game devs can sync with cutscene playback snd->stopMusic(); snd->loadMusic(music); } initialized = true; } if (scenes.empty() || scene_index >= scenes.size()) { if (game_slot != -1) { showLoading(); GameStatePlay *gsp = new GameStatePlay(); gsp->resetGame(); save_load->setGameSlot(game_slot); save_load->loadGame(); setRequestedGameState(gsp); return; } // return to previous gamestate showLoading(); setRequestedGameState(previous_gamestate); return; } // status is processed after we render this scene if (scene_index < scenes.size()) status = scenes[scene_index]->logic(); }
void GameStateNew::logic() { if (!input_name->inFocus) tablist.logic(); button_permadeath->checkClick(); if (show_classlist) class_list->checkClick(); // require character name if (input_name->getText() == "") { if (button_create->enabled) { button_create->enabled = false; button_create->refresh(); } } else { if (!button_create->enabled) { button_create->enabled = true; button_create->refresh(); } } if ((inpt->pressing[CANCEL] && !inpt->lock[CANCEL]) || button_exit->checkClick()) { inpt->lock[CANCEL] = true; delete requestedGameState; requestedGameState = new GameStateLoad(); } if (button_create->checkClick()) { // start the new game GameStatePlay* play = new GameStatePlay(); Avatar *pc = play->getAvatar(); pc->stats.gfx_base = base[current_option]; pc->stats.gfx_head = head[current_option]; pc->stats.gfx_portrait = portrait[current_option]; pc->stats.name = input_name->getText(); pc->stats.permadeath = button_permadeath->isChecked(); play->game_slot = game_slot; play->resetGame(); play->loadClass(class_list->getSelected()); requestedGameState = play; } // scroll through portrait options if (button_next->checkClick()) { current_option++; if (current_option == (int)portrait.size()) current_option = 0; loadPortrait(portrait[current_option]); setName(name[current_option]); } else if (button_prev->checkClick()) { current_option--; if (current_option == -1) current_option = portrait.size()-1; loadPortrait(portrait[current_option]); setName(name[current_option]); } input_name->logic(); if (input_name->getText() != name[current_option]) modified_name = true; }
void GameStateLoad::logicLoading() { // load an existing game GameStatePlay* play = new GameStatePlay(); play->resetGame(); play->game_slot = selected_slot + 1; play->loadGame(); requestedGameState = play; loaded = true; loading = false; }
void GameStateLoad::logicLoading() { // load an existing game inpt->lock_all = true; delete_items = false; showLoading(); GameStatePlay* play = new GameStatePlay(); play->resetGame(); save_load->setGameSlot(game_slots[selected_slot]->id); save_load->loadGame(); loaded = true; loading = false; setRequestedGameState(play); }
void GameStateNew::logic() { button_permadeath->checkClick(); // require character name if (input_name->getText() == "") { if (button_create->enabled) { button_create->enabled = false; button_create->refresh(); } } else { if (!button_create->enabled) { button_create->enabled = true; button_create->refresh(); } } if (button_exit->checkClick()) { requestedGameState = new GameStateLoad(); } if (button_create->checkClick()) { // start the new game GameStatePlay* play = new GameStatePlay(); play->pc->stats.base = base[current_option]; play->pc->stats.head = head[current_option]; play->pc->stats.portrait = portrait[current_option]; play->pc->stats.name = input_name->getText(); play->pc->permadeath = button_permadeath->isChecked(); play->game_slot = game_slot; play->resetGame(); requestedGameState = play; } // scroll through portrait options if (button_next->checkClick()) { current_option++; if (current_option == option_count) current_option = 0; loadPortrait(portrait[current_option]); } else if (button_prev->checkClick()) { current_option--; if (current_option == -1) current_option = option_count-1; loadPortrait(portrait[current_option]); } input_name->logic(); }
void GameStateLoad::logic() { frame_ticker++; if (frame_ticker == 64) frame_ticker = 0; if (frame_ticker < 32) current_frame = frame_ticker / 8; else current_frame = (63 - frame_ticker) / 8; if (button_exit->checkClick()) { requestedGameState = new GameStateTitle(screen, inp, font); } if (button_action->checkClick()) { if (stats[selected_slot].name == "") { // create a new game GameStateNew* newgame = new GameStateNew(screen, inp, font); newgame->game_slot = selected_slot + 1; requestedGameState = newgame; } else { // load an existing game GameStatePlay* play = new GameStatePlay(screen, inp, font); play->resetGame(); play->game_slot = selected_slot + 1; play->loadGame(); requestedGameState = play; } } // check clicking game slot if (inp->pressing[MAIN1] && !inp->lock[MAIN1]) { for (int i=0; i<GAME_SLOT_MAX; i++) { if (isWithin(slot_pos[i], inp->mouse)) { selected_slot = i; inp->lock[MAIN1] = true; loadPortrait(selected_slot); button_action->enabled = true; if (stats[selected_slot].name == "") { button_action->label = "New Game"; } else { button_action->label = "Load Game"; } } } } }
void GameStateCutscene::logic() { if (scenes.empty()) { if (game_slot != -1) { GameStatePlay *gsp = new GameStatePlay(); gsp->resetGame(); gsp->game_slot = game_slot; gsp->loadGame(); previous_gamestate = gsp; } /* return to previous gamestate */ delete requestedGameState; requestedGameState = previous_gamestate; return; } while (!scenes.empty() && !scenes.front().logic(&caption_margins, scale_graphics)) scenes.pop(); }
void GameStateCutscene::logic() { if (scenes.empty()) { if (game_slot != -1) { GameStatePlay *gsp = new GameStatePlay(); gsp->resetGame(); save_load->setGameSlot(game_slot); save_load->loadGame(); previous_gamestate = gsp; } /* return to previous gamestate */ delete requestedGameState; requestedGameState = previous_gamestate; requestedGameState->refreshWidgets(); return; } while (!scenes.empty() && !scenes.front()->logic()) { delete scenes.front(); scenes.pop(); } }
void GameStateNew::logic() { button_permadeath->checkClick(); // require character name if (input_name->getText() == "" && DEFAULT_NAME == "") { if (inpt->pressing[ACCEPT] && !inpt->lock[ACCEPT]) { inpt->lock[ACCEPT] = true; input_name->inFocus = true; } if (button_create->enabled) { button_create->enabled = false; button_create->refresh(); } } else { if (!button_create->enabled) { button_create->enabled = true; button_create->refresh(); } } if (inpt->pressing[CANCEL] && !inpt->lock[CANCEL] && input_name->inFocus) { inpt->lock[CANCEL] = true; input_name->inFocus = false; } if (button_exit->checkClick() || (inpt->pressing[CANCEL] && !inpt->lock[CANCEL] && !input_name->inFocus)) { inpt->lock[CANCEL] = true; delete requestedGameState; requestedGameState = new GameStateLoad(); } if (button_create->checkClick() || (inpt->pressing[ACCEPT] && !inpt->lock[ACCEPT] && button_create->enabled)) { inpt->lock[ACCEPT] = true; // start the new game GameStatePlay* play = new GameStatePlay(); play->pc->stats.base = base[current_option]; play->pc->stats.head = head[current_option]; play->pc->stats.portrait = portrait[current_option]; play->pc->stats.name = input_name->getText(); play->pc->stats.permadeath = button_permadeath->isChecked(); play->game_slot = game_slot; play->resetGame(); requestedGameState = play; } // scroll through portrait options if (button_next->checkClick() || (inpt->pressing[RIGHT] && !inpt->lock[RIGHT] && !input_name->inFocus)) { inpt->lock[RIGHT] = true; current_option++; if (current_option == (int)base.size()) current_option = 0; loadPortrait(portrait[current_option]); } else if (button_prev->checkClick() || (inpt->pressing[LEFT] && !inpt->lock[LEFT] && !input_name->inFocus)) { inpt->lock[LEFT] = true; current_option--; if (current_option == -1) current_option = base.size()-1; loadPortrait(portrait[current_option]); } if (DEFAULT_NAME == "") input_name->logic(); }