SubgameSpec findSubgame(const std::string &id) { if(id == "") return SubgameSpec(); std::string share = porting::path_share; std::string user = porting::path_user; std::vector<GameFindPath> find_paths; Strfnd search_paths(getSubgamePathEnv()); while (!search_paths.at_end()) { std::string path = search_paths.next(PATH_DELIM); find_paths.push_back(GameFindPath( path + DIR_DELIM + id, false)); find_paths.push_back(GameFindPath( path + DIR_DELIM + id + "_game", false)); } find_paths.push_back(GameFindPath( user + DIR_DELIM + "games" + DIR_DELIM + id + "_game", true)); find_paths.push_back(GameFindPath( user + DIR_DELIM + "games" + DIR_DELIM + id, true)); find_paths.push_back(GameFindPath( share + DIR_DELIM + "games" + DIR_DELIM + id + "_game", false)); find_paths.push_back(GameFindPath( share + DIR_DELIM + "games" + DIR_DELIM + id, false)); // Find game directory std::string game_path; bool user_game = true; // Game is in user's directory for(u32 i=0; i<find_paths.size(); i++){ const std::string &try_path = find_paths[i].path; if(fs::PathExists(try_path)){ game_path = try_path; user_game = find_paths[i].user_specific; break; } } if(game_path == "") return SubgameSpec(); std::string gamemod_path = game_path + DIR_DELIM + "files"; // Find mod directories std::set<std::string> mods_paths; if(!user_game) mods_paths.insert(share + DIR_DELIM + "files"); if(user != share || user_game) mods_paths.insert(user + DIR_DELIM + "files"); std::string game_name = getGameName(game_path); if(game_name == "") game_name = id; std::string menuicon_path; #ifndef SERVER menuicon_path = getImagePath(game_path + DIR_DELIM + "menu" + DIR_DELIM + "icon.png"); #endif return SubgameSpec(id, game_path, gamemod_path, mods_paths, game_name, menuicon_path); }
void SummarizeGame(int game_id) { cout << "Players who played " << getGameName(game_id) << ":" << endl; for (int i = 0; i < player_database.size(); i++) { for (int j = 0; j < player_database[i].games_played.size(); j++) { cout << j+1 << ". "; if (game_id == player_database[i].games_played[j].second->getId()) { cout << player_database[i].games_played[j].first->getName() << endl; } } } }
void MainLoop::getSaveOptions(const vector<pair<Model::GameType, string>>& games, vector<View::ListElem>& options, vector<SaveFileInfo>& allFiles) { for (auto elem : games) { vector<SaveFileInfo> files = getSaveFiles(userPath, getSaveSuffix(elem.first)); files = ::filter(files, [this] (const SaveFileInfo& info) { return isCompatible(getSaveVersion(info));}); append(allFiles, files); if (!files.empty()) { options.emplace_back(elem.second, View::TITLE); append(options, transform2<View::ListElem>(files, [this] (const SaveFileInfo& info) { return getGameName(info);})); } } }
SubgameSpec findWorldSubgame(const std::string &world_path) { std::string world_gameid = getWorldGameId(world_path, true); // See if world contains an embedded game; if so, use it. std::string world_gamepath = world_path + DIR_DELIM + "game"; if(fs::PathExists(world_gamepath)){ SubgameSpec gamespec; gamespec.id = world_gameid; gamespec.path = world_gamepath; gamespec.gamemods_path= world_gamepath + DIR_DELIM + "files"; gamespec.name = getGameName(world_gamepath); if(gamespec.name == "") gamespec.name = "unknown"; return gamespec; } return findSubgame(world_gameid); }
void MyGame::CreateText(){ ResourceCache* cache = GetSubsystem<ResourceCache>(); // Construct the text object SharedPtr<Text> myText(new Text(context_)); // Set text to display myText->SetText("Hello Wolrd from " + getGameName()); // Set font and text color myText->SetFont(cache->GetResource<Font>("Fonts/Anonymous Pro.ttf"), 30); myText->SetColor(Color(0.0f, 1.0f, 0.0f)); // Align Text center-screen myText->SetHorizontalAlignment(HA_CENTER); myText->SetVerticalAlignment(VA_CENTER); // Add Text instance to the UI root element GetSubsystem<UI>()->GetRoot()->AddChild(myText); }
SubgameSpec findSubgame(const std::string &id) { if(id == "") return SubgameSpec(); std::string share = porting::path_share; std::string user = porting::path_user; std::vector<GameFindPath> find_paths; find_paths.push_back(GameFindPath( user + DIR_DELIM + "games" + DIR_DELIM + id + "_game", true)); find_paths.push_back(GameFindPath( user + DIR_DELIM + "games" + DIR_DELIM + id, true)); find_paths.push_back(GameFindPath( share + DIR_DELIM + "games" + DIR_DELIM + id + "_game", false)); find_paths.push_back(GameFindPath( share + DIR_DELIM + "games" + DIR_DELIM + id, false)); // Find game directory std::string game_path; bool user_game = true; // Game is in user's directory for(u32 i=0; i<find_paths.size(); i++){ const std::string &try_path = find_paths[i].path; if(fs::PathExists(try_path)){ game_path = try_path; user_game = find_paths[i].user_specific; break; } } if(game_path == "") return SubgameSpec(); // Find mod directories std::set<std::string> mods_paths; mods_paths.insert(game_path + DIR_DELIM + "mods"); if(!user_game) mods_paths.insert(share + DIR_DELIM + "mods" + DIR_DELIM + id); if(user != share || user_game) mods_paths.insert(user + DIR_DELIM + "mods" + DIR_DELIM + id); std::string game_name = getGameName(game_path); if(game_name == "") game_name = id; return SubgameSpec(id, game_path, mods_paths, game_name); }
bool PBase::init() { if ( !WJLayer::init() ) { return false; } #if (COCOS2D_DEBUG) CCLOG("Init Scene: %s...", getGameName().c_str()); #endif m_winSize = Director::getInstance()->getWinSize(); m_visibleSize = Director::getInstance()->getVisibleSize(); m_origin = Director::getInstance()->getVisibleOrigin(); m_visibleRect = Rect(m_origin.x, m_origin.y, m_visibleSize.width, m_visibleSize.height); // top layer m_topLayer = WJLayer::create(); m_topLayer->saveCurrentPosition(); this->addChild(m_topLayer, ZORDER_TOP_LAYER); // p001 welcome if (getGameNumber() == GameNumber::P000 || getGameNumber() == GameNumber::P010) { // android back key this->addChild(LBToolbar::createBackKey([&]() { // quit app WJUtils::callaction_void(ACTION_VOID_CONFIRM_QUIT); })); } else { initPopupMenu(); initSnapshot(); initAdsBanner(); } return true; }