bool SceneGame::touch(s3ePointerTouchEvent* event) { // don't handle if the touch is up, not down if(event->m_Pressed != 1) return IGNode::touch(event); char debugStr[200]; float x = IGDistorter::getInstance()->distortBackX((float)event->m_x); float y = IGDistorter::getInstance()->distortBackY((float)event->m_y); // touch input for the keyboard if(!keyboardUp) { // touching inside the puzzle area? if(y > 30 && y <= 214) { unsigned int i; for(i=0; i<strlen(ciphertext); i++) { if(ciphertext[i] >= 'A' && ciphertext[i] <= 'Z') { GameSlot* slot = (GameSlot*)this->getChildByTag(SceneGameTagSlots+i); if(slot != NULL) { if(slot->collidingWith(x, y, centerOffset)) { // touching a character, pop up the keyboard sprintf(debugStr, "SceneGame touching slot %i, ciphertext %c, plaintext %c", i, ciphertext[i], plaintext[i]); Sounds::getInstance()->playClick(); IGLog(debugStr); selectedChar = ciphertext[i]; popUpKeyboard(); return true; } } } } } } return IGNode::touch(event); }
/** This is called from user_config when reading the config file */ void UnlockManager::load() { const std::string filename=file_manager->getChallengeFile("challenges.xml"); XMLNode* root = file_manager->createXMLTree(filename); if(!root || root->getName() != "challenges") { std::cerr << "Challenge file '" << filename << "' will be created." << std::endl; createSlotsIfNeeded(); save(); if (root) delete root; return; } std::vector<XMLNode*> xml_game_slots; root->getNodes("gameslot", xml_game_slots); for (unsigned int n=0; n<xml_game_slots.size(); n++) { std::string player_id; if (!xml_game_slots[n]->get("playerID", &player_id)) { fprintf(stderr, "[UnlockManager] WARNING: Found game slot without a player ID attached. Discarding it\n"); continue; } GameSlot* slot = new GameSlot(player_id); std::string kart_id; xml_game_slots[n]->get("kart", &kart_id); slot->setKartIdent(kart_id); m_game_slots[player_id] = slot; bool first_time = true; xml_game_slots[n]->get("firstTime", &first_time); slot->setFirstTime(first_time); for(AllChallengesType::iterator i = m_all_challenges.begin(); i!=m_all_challenges.end(); i++) { ChallengeData* curr = i->second; Challenge* state = new Challenge(curr); slot->m_challenges_state[curr->getId()] = state; state->load(xml_game_slots[n]); } slot->computeActive(); } bool something_changed = createSlotsIfNeeded(); if (something_changed) save(); delete root; } // load
/** Creates a gameslot for players that don't have one yet * \return true if any were created */ bool UnlockManager::createSlotsIfNeeded() { bool something_changed = false; // make sure all players have at least one game slot associated PtrVector<PlayerProfile>& players = UserConfigParams::m_all_players; for (int n=0; n<players.size(); n++) { bool exists = false; std::map<std::string, GameSlot*>::iterator it; for (it = m_game_slots.begin(); it != m_game_slots.end(); it++) { GameSlot* curr_slot = it->second; if (curr_slot->getPlayerID() == players[n].getUniqueID()) { exists = true; break; } } if (!exists) { GameSlot* slot = new GameSlot(players[n].getUniqueID()); for(AllChallengesType::iterator i = m_all_challenges.begin(); i!=m_all_challenges.end(); i++) { ChallengeData* cd = i->second; slot->m_challenges_state[cd->getId()] = new Challenge(cd); } slot->computeActive(); m_game_slots[players[n].getUniqueID()] = slot; something_changed = true; } } return something_changed; } // UnlockManager::createSlotsIfNeeded
// ----------------------------------------------------------------------- unsigned int getNumHardTrophies() const { return m_game_slot->getNumHardTrophies(); } // getNumHardTropies
// ------------------------------------------------------------------------ unsigned int getNumMediumTrophies() const { return m_game_slot->getNumMediumTrophies(); } // getNumEasyTrophies
// ------------------------------------------------------------------------ const Challenge* getChallenge(const std::string &id) { return m_game_slot->getChallenge(id); } // getChallenge
/** Returns the current challenge for this player. */ const Challenge* getCurrentChallenge() const { return m_game_slot->getCurrentChallenge(); } // getCurrentChallenge
// ------------------------------------------------------------------------ void clearUnlocked() { m_game_slot->clearUnlocked(); }
/** Returnes if the feature (kart, track) is locked. */ bool isLocked(const std::string &feature) const { return m_game_slot->isLocked(feature); } // isLocked
// ------------------------------------------------------------------------ void setFirstTime(bool b) { m_game_slot->setFirstTime(b); }
// ------------------------------------------------------------------------ unsigned int getPoints() const { return m_game_slot->getPoints(); }
/** Callback when a GP is finished (to test if a challenge was * fulfilled). */ void grandPrixFinished() { m_game_slot->grandPrixFinished(); }
/** Notification of a finished race, which can trigger fulfilling * challenges. */ void raceFinished() { m_game_slot->raceFinished(); }
/** Sets the currently active challenge. */ void setCurrentChallenge(const std::string &name) { m_game_slot->setCurrentChallenge(name); } // setCurrentChallenge
/** Returns the list of recently completed challenges. */ std::vector<const ChallengeData*> getRecentlyCompletedChallenges() { return m_game_slot->getRecentlyCompletedChallenges(); } // getRecently Completed Challenges
/** Returns all active challenges. */ void computeActive() { m_game_slot->computeActive(); }
// ------------------------------------------------------------------------ bool isFirstTime() const { return m_game_slot->isFirstTime(); }
void MainMenuScreen::eventCallback(Widget* widget, const std::string& name, const int playerID) { // most interesting stuff is in the ribbons, so start there RibbonWidget* ribbon = dynamic_cast<RibbonWidget*>(widget); if (ribbon == NULL) return; // what's that event?? // ---- A ribbon icon was clicked std::string selection = ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER); /* if (selection == "story") { StateManager::get()->enterGameState(); race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE); race_manager->setNumKarts( 0 ); race_manager->setNumPlayers(0); race_manager->setNumLocalPlayers(0); race_manager->startSingleRace("endcutscene", 999, false); std::vector<std::string> parts; parts.push_back("introcutscene"); parts.push_back("introcutscene2"); ((CutsceneWorld*)World::getWorld())->setParts(parts); //race_manager->startSingleRace("introcutscene2", 999, false); return; } */ #if DEBUG_MENU_ITEM if (selection == "options") { // The DEBUG item FeatureUnlockedCutScene* scene = FeatureUnlockedCutScene::getInstance(); scene->addTrophy(RaceManager::DIFFICULTY_EASY); StateManager::get()->pushScreen(scene); /* static int i = 1; i++; if (i % 4 == 0) { // the passed kart will not be modified, that's why I allow myself // to use const_cast scene->addUnlockedKart( const_cast<KartProperties*>( kart_properties_manager->getKart("tux") ), L"Unlocked" ); StateManager::get()->pushScreen(scene); } else if (i % 4 == 1) { std::vector<video::ITexture*> textures; textures.push_back(irr_driver->getTexture( track_manager->getTrack("lighthouse") ->getScreenshotFile().c_str())); textures.push_back(irr_driver->getTexture( track_manager->getTrack("crescentcrossing") ->getScreenshotFile().c_str())); textures.push_back(irr_driver->getTexture( track_manager->getTrack("sandtrack") ->getScreenshotFile().c_str())); textures.push_back(irr_driver->getTexture( track_manager->getTrack("snowmountain") ->getScreenshotFile().c_str())); scene->addUnlockedPictures(textures, 1.0, 0.75, L"You did it"); StateManager::get()->pushScreen(scene); } else if (i % 4 == 2) { GrandPrixWin* scene = GrandPrixWin::getInstance(); const std::string winners[] = { "elephpant", "nolok", "pidgin" }; StateManager::get()->pushScreen(scene); scene->setKarts( winners ); } else { GrandPrixLose* scene = GrandPrixLose::getInstance(); StateManager::get()->pushScreen(scene); std::vector<std::string> losers; losers.push_back("nolok"); losers.push_back("elephpant"); losers.push_back("wilber"); scene->setKarts( losers ); } */ } else #endif if (selection == "new") { KartSelectionScreen* s = KartSelectionScreen::getInstance(); s->setMultiplayer(false); s->setFromOverworld(false); StateManager::get()->pushScreen( s ); } else if (selection == "multiplayer") { KartSelectionScreen* s = KartSelectionScreen::getInstance(); s->setMultiplayer(true); s->setFromOverworld(false); StateManager::get()->pushScreen( s ); } else if (selection == "options") { StateManager::get()->pushScreen( OptionsScreenVideo::getInstance() ); } else if (selection == "quit") { StateManager::get()->popMenu(); return; } else if (selection == "about") { StateManager::get()->pushScreen(CreditsScreen::getInstance()); } else if (selection == "help") { StateManager::get()->pushScreen(HelpScreen1::getInstance()); } else if (selection == "story") { GameSlot* slot = unlock_manager->getCurrentSlot(); if (slot->isFirstTime()) { StateManager::get()->enterGameState(); race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE); race_manager->setNumKarts( 0 ); race_manager->setNumPlayers(0); race_manager->setNumLocalPlayers(0); race_manager->startSingleRace("introcutscene", 999, false); std::vector<std::string> parts; parts.push_back("introcutscene"); parts.push_back("introcutscene2"); ((CutsceneWorld*)World::getWorld())->setParts(parts); //race_manager->startSingleRace("introcutscene2", 999, false); return; } else { OverWorld::enterOverWorld(); } } else if (selection == "tutorial") { StateManager::get()->pushScreen(TutorialScreen::getInstance()); } else if (selection == "addons") { StateManager::get()->pushScreen(AddonsScreen::getInstance()); } } // eventCallback