void COverlappedWindow::startNewGame(int width, int height) { getGameInfo().heightGridNumber = width; getGameInfo().widthGridNumber = height; settingsGameInfo = applyedGameInfo; startNewGame(); }
void COverlappedWindow::drawPoints(HDC paintDC, const RECT& rect) { if (isGameStarted) { for (int x = 0; x < getGameInfo().widthGridNumber; ++x) { for (int y = 0; y < getGameInfo().heightGridNumber; ++y) { if (game.getPointState(x, y) != EMPTY) { drawPoint(paintDC, rect, x, y, game.getPointState(x, y)); } } } } }
void COverlappedWindow::startNewGame() { getGameInfo().isFirstNextStep = true; setWindowSize(); game = Game(getGameInfo().widthGridNumber, getGameInfo().heightGridNumber); isGameStarted = true; isDoneFirstStep = false; ::InvalidateRect(handle, 0, 0); }
Common::UString getEngineTypeName(Aurora::GameID game, size_t n) { const GameInfo *info = getGameInfo(game); if (!info || (n >= info->engineTypeCount)) return getGenericEngineTypeName(n); return info->engineTypeNames[n]; }
size_t getFunctionCount(Aurora::GameID game) { const GameInfo *info = getGameInfo(game); if (!info) return 0; return info->functionCount; }
Common::UString getFunctionName(Aurora::GameID game, size_t n) { const GameInfo *info = getGameInfo(game); if (!info || (n >= info->functionCount)) return ""; return info->functionNames[n]; }
int main () { srand (time (NULL)); int numGames, numPlayers; Card deck[NUM_CARDS]; Card hand[MAX_PLAYER][HAND_SIZE]; getGameInfo (&numGames); initFile (numGames); for (int i = 0; i < numGames; i++) { getNumPlayers (&numPlayers); int handScores[numPlayers][1 + HAND_SIZE]; memset(handScores, 0, numPlayers * (1 + HAND_SIZE) * sizeof(int)); int bestHandIndices[numPlayers]; memset (bestHandIndices, 0, numPlayers*sizeof(int)); int *numTied = (int *)malloc(sizeof(int)); *numTied = 0; printfName (i + 1, numPlayers); initDeck (deck); shuffleDeck (deck); dealHands (deck, hand, numPlayers); evaluateWinner (hand, numPlayers, handScores, bestHandIndices, numTied); for (int j = 0; j < numPlayers; j++) { printResults (&hand[j][0], HAND_SIZE, j, handScores); } printWinner (i + 1, hand, numPlayers, handScores, bestHandIndices, *numTied); } }
bool matches (char const* file, SearchStruct* ss) { GameCache* game = &gcache[getGameInfo (file, GC_FLAGS)]; char ftitle[256]; _splitpath (file, NULL, NULL, ftitle, NULL); if (!str_matches (ss->ffunc, ftitle, ss->ftext)) return false; if (!str_matches (ss->nfunc, game->name, ss->ntext)) return false; if (!matchMode (game->mode, ss->mtext, ss->mfunc)) return false; if (game->count < ss->numa || game->count > ss->numb) return false; if (game->map < ss->vera || game->map > ss->verb) return false; if (game->patch < ss->pata || game->patch > ss->patb) return false; if (game->length < ss->lena || game->length > ss->lenb) return false; if (game->mod < ss->sava || game->mod > ss->savb) return false; for (int i = 0; i < 5; i++) { bool found = false; for (int j = 0; j < game->count && !found; j++) { if (str_matches (ss->pmode[i], game->pname[j], ss->pname[i]) && (ss->phero[i] == 0 || ss->phero[i] == game->phero[j])) found = true; } if (!found) return false; } return true; }
VariableType getFunctionReturnType(Aurora::GameID game, size_t n) { const GameInfo *info = getGameInfo(game); if (!info || (n >= info->functionCount)) return kTypeVoid; return info->functionSignatures[n][0]; }
size_t getEngineTypeCount(Aurora::GameID game) { const GameInfo *info = getGameInfo(game); if (!info) return 0; return info->engineTypeCount; }
const VariableType *getFunctionParameters(Aurora::GameID game, size_t n) { const GameInfo *info = getGameInfo(game); if (!info || (n >= info->functionCount)) return 0; return &info->functionSignatures[n][1]; }
void COverlappedWindow::setWindowSize() { int indent = getDrawInfo().lineIndent; int unexpectedXIndent = 20; int unexpectedYIndent = 65; int widthNumber = getGameInfo().widthGridNumber; int heightNumber = getGameInfo().heightGridNumber; int scoreboardSize = getDrawInfo().scoreboardSize; RECT rect; GetWindowRect(handle, &rect); int x = rect.left; int y = rect.top; ::SetWindowPos(handle, 0, x, y, (widthNumber + 1) * indent + unexpectedXIndent, (heightNumber + 1) * indent + unexpectedYIndent + scoreboardSize, SWP_SHOWWINDOW); }
void COverlappedWindow::drawScoreboard(HDC paintDC, const RECT& rect) { int indent = getDrawInfo().lineIndent; int y = indent * (getGameInfo().heightGridNumber + 1) + getDrawInfo().scoreboardSize / 3; int x = indent * (getGameInfo().widthGridNumber + 1) / 2; int firstScore = 0; int secondScore = 0; if (isGameStarted) { firstScore = game.getFirstResult(); secondScore = game.getSecondResult(); } std::string string = "First player " + std::to_string(firstScore) + ":" + std::to_string(secondScore) + " Second player"; std::wstring str = getWC(string.c_str()); writeText(paintDC, getDrawInfo().scoreboardFont, x, y, str); }
void COverlappedWindow::OnLButtonDown(WPARAM wParam, LPARAM lParam) { if (!isPause) { POINT pos; GetCursorPos(&pos); ScreenToClient(handle, &pos); int indent = getDrawInfo().lineIndent; int x_num = abs(pos.x - indent / 2) / indent; int y_num = abs(pos.y - indent / 2) / indent; if (game.isInField(x_num, y_num) && game.markPoint(x_num, y_num, getGameInfo().isFirstNextStep)) { getGameInfo().isFirstNextStep = !getGameInfo().isFirstNextStep; isDoneFirstStep = true; game.buildGame(); } ::InvalidateRect(handle, 0, 0); } }
void COverlappedWindow::drawGrid(HDC paintDC, const RECT& rect) { HBRUSH brush = ::CreateSolidBrush(getDrawInfo().lineColor); HPEN pen = ::CreatePen(PS_SOLID, getDrawInfo().lineStroke, getDrawInfo().lineColor); ::SelectObject(paintDC, pen); ::SelectObject(paintDC, brush); int indent = getDrawInfo().lineIndent; int widthNumber = getGameInfo().widthGridNumber; int heightNumber = getGameInfo().heightGridNumber; for (int i = 0; i < widthNumber; ++i) { Line(paintDC, (i + 1) * indent, 0, (i + 1) * indent, (heightNumber + 1) * indent); } for (int i = 0; i < heightNumber; ++i) { Line(paintDC, 0, (i + 1) * indent, (widthNumber + 1) * indent, (i + 1) * indent); } ::DeleteObject(brush); ::DeleteObject(pen); }
size_t getFunctionParameterCount(Aurora::GameID game, size_t n) { const GameInfo *info = getGameInfo(game); if (!info || (n >= info->functionCount)) return 0; size_t count = 0; for (size_t i = 1; (i < GameInfo::kMaxSignatureSize) && (info->functionSignatures[n][i] != kTypeVoid); i++) count++; return count; }
bool ContactManager::onContactBeginPro_End(){ target_pro = node_Pro->getScheduler()->pauseAllTargets(); MenuManager menuManager; Node* layer =menuManager.create_Menu(SUCCESS_LAYER); getScore(); strstream ss; string score; ss<<SCORE_GET; ss>>score; auto text_score=layer->getChildByName<ui::TextBMFont*>("Text_Score"); text_score->setString(score); if(GameManager::stepNow==STEP){ STEP++; } //此处应该有个算星星的方法 int stateN = getState(); strstream ss1; string state; ss1<<stateN; ss1>>state; CCLOG("星星:%d",stateN); auto text_state=layer->getChildByName<ui::TextBMFont*>("Text_State"); text_state->setString(state); GameVo gVo; GameVo gvoG = getGameInfo(GameManager::stepNow); if(gvoG._score<SCORE_GET){ gVo.setData(SCORE_GET, 3, getState()); setGameInfo(gVo,GameManager::stepNow); } updateConstant(); node_else->getParent()->addChild(layer); MenuManager::move_in(layer); return false; }
int NetSpadesGame::mapPos( int pos ) { if(getGameInfo().getNumPlayers() < 4) { if(pos == 3) { pos = 2; } else if(pos == 2) { pos = 3; } } return pos; }
int executeGame(char* path) { // cli_frontend does the heavy lifting; if we have osd-specific options, we // create a derivative of cli_options and add our own int paramCount; int result = 0; int gameRot=0; int driverIndex; FirstTimeUpdate = 1; screenRot = 0; //split the path to directory and the name without the zip extension result = parsePath(path, MgamePath, MgameName); if (result == 0) { write_log("parse path failed! path=%s\n", path); strcpy(MgameName,path); // return -1; } //split the path to directory and the name without the zip extension result = parseSystemName(path, MsystemName); if (result == 0) { write_log("parse path failed! path=%s\n", path); strcpy(MsystemName,path ); // return -1; } //get the parent path result = parseParentPath(path, MparentPath); if (result == 0) { write_log("parse path failed! path=%s\n", path); strcpy(MparentPath,path ); // return -1; } #ifdef WANT_MAME //find if the driver exists for MgameName, if not, exit if (getGameInfo(MgameName, &gameRot, &driverIndex) == 0) { write_log("driver not found: %s\n", MgameName); return -2; } #else if(!commandline_enabled) { //find if the driver exists for MgameName, if not, check if a driver exists for MsystemName, if not, exit if (getGameInfo(MgameName, &gameRot, &driverIndex) == 0) { write_log("driver not found: %s\n", MgameName); if (getGameInfo(MsystemName, &gameRot, &driverIndex) == 0) { write_log("driver not found: %s\n", MsystemName); return -2; } } } #endif //tate enabled if (tate) { //horizontal game if (gameRot == ROT0) { screenRot = 1; } else if (gameRot & ORIENTATION_FLIP_X) { write_log("*********** flip X \n"); screenRot = 3; } } else { if (gameRot != ROT0) { screenRot = 1; if (gameRot & ORIENTATION_FLIP_X) { write_log("*********** flip X \n"); screenRot = 2; } } } write_log("creating frontend... game=%s\n", MgameName); printf("using softlists: %d\n", softlist_enabled); //find how many parameters we have for (paramCount = 0; xargv[paramCount] != NULL; paramCount++) printf("args: %s\n",xargv[paramCount]); xargv[paramCount++] = (char*)("-cfg_directory"); char cfg_dir[256]; sprintf(cfg_dir, "%s%c%s%c%s", retro_save_directory, slash, core, slash, "cfg"); xargv[paramCount++] = (char*)(cfg_dir); xargv[paramCount++] = (char*)("-nvram_directory"); char nv_dir[256]; sprintf(nv_dir, "%s%c%s%c%s", retro_save_directory, slash, core, slash, "nvram"); xargv[paramCount++] = (char*)(nv_dir); xargv[paramCount++] = (char*)("-memcard_directory"); char mem_dir[256]; sprintf(mem_dir, "%s%c%s%c%s", retro_save_directory, slash, core, slash, "memcard"); xargv[paramCount++] = (char*)(mem_dir); xargv[paramCount++] = (char*)("-input_directory"); char inp_dir[256]; sprintf(inp_dir, "%s%c%s%c%s", retro_save_directory, slash, core, slash, "input"); xargv[paramCount++] = (char*)(inp_dir); xargv[paramCount++] = (char*)("-state_directory"); char state_dir[256]; sprintf(state_dir, "%s%c%s%c%s", retro_save_directory, slash, core, slash, "states"); xargv[paramCount++] = (char*)(state_dir); xargv[paramCount++] = (char*)("-snapshot_directory"); char snap_dir[256]; sprintf(snap_dir, "%s%c%s%c%s", retro_save_directory, slash, core, slash, "snaps"); xargv[paramCount++] = (char*)(snap_dir); xargv[paramCount++] = (char*)("-diff_directory"); char diff_dir[256]; sprintf(diff_dir, "%s%c%s%c%s", retro_save_directory, slash, core, slash, "diff"); xargv[paramCount++] = (char*)(diff_dir); xargv[paramCount++] = (char*)("-samplepath"); char samples_dir[256]; sprintf(samples_dir, "%s%c%s%c%s", retro_system_directory, slash, core, slash, "samples"); xargv[paramCount++] = (char*)(samples_dir); xargv[paramCount++] = (char*)("-artpath"); char art_dir[256]; sprintf(art_dir, "%s%c%s%c%s", retro_system_directory, slash, core, slash, "artwork"); xargv[paramCount++] = (char*)(art_dir); xargv[paramCount++] = (char*)("-cheatpath"); char cheat_dir[256]; sprintf(cheat_dir, "%s%c%s%c%s", retro_system_directory, slash, core, slash, "cheat"); xargv[paramCount++] = (char*)(cheat_dir); xargv[paramCount++] = (char*)("-inipath"); char ini_dir[256]; sprintf(ini_dir, "%s%c%s%c%s", retro_system_directory, slash, core, slash, "ini"); xargv[paramCount++] = (char*)(ini_dir); xargv[paramCount++] = (char*)("-hashpath"); char hash_dir[256]; sprintf(hash_dir, "%s%c%s%c%s", retro_system_directory, slash, core, slash, "hash"); xargv[paramCount++] = (char*)(hash_dir); if (tate) { if (screenRot == 3) { xargv[paramCount++] =(char*) "-rol"; } else { xargv[paramCount++] = (char*)(screenRot ? "-mouse" : "-ror"); } } else { if (screenRot == 2) { xargv[paramCount++] = (char*)"-rol"; } else { xargv[paramCount++] = (char*)(screenRot ? "-ror" : "-mouse"); } } xargv[paramCount++] = (char*)("-rompath"); char rom_dir[256]; #ifdef WANT_MAME sprintf(rom_dir, "%s", MgamePath); xargv[paramCount++] = (char*)(rom_dir); if(!boot_to_osd_enabled) xargv[paramCount++] = MgameName; #else if(!commandline_enabled) { if(!boot_to_osd_enabled) { sprintf(rom_dir, "%s", MgamePath); xargv[paramCount++] = (char*)(rom_dir); if(softlist_enabled) { if(!arcade) { xargv[paramCount++] = MsystemName; if(!boot_to_bios_enabled) { if(!softlist_auto) xargv[paramCount++] = (char*)mediaType; xargv[paramCount++] = (char*)MgameName; } } else { xargv[paramCount++] = (char*)MgameName; } } else { if (strcmp(mediaType, "-rom") == 0) { xargv[paramCount++] = MgameName; } else { xargv[paramCount++] = MsystemName; xargv[paramCount++] = (char*)mediaType; xargv[paramCount++] = (char*)gameName; } } } else { sprintf(rom_dir, "%s;%s", MgamePath,MparentPath); xargv[paramCount++] = (char*)(rom_dir); } } else xargv[paramCount++] = (char*)gameName; #endif write_log("frontend parameters:%i\n", paramCount); for (int i = 0; xargv[i] != NULL; i++){ write_log(" %s\n",xargv[i]); } osd_init_midi(); cli_options MRoptions; mini_osd_interface MRosd; cli_frontend frontend(MRoptions, MRosd); result = frontend.execute(paramCount, ( char **)xargv); xargv[paramCount - 2] = NULL; return result; }
int executeGame_cmd(char* path) { char tmp_dir[256]; int paramCount; int result = 0; int gameRot=0; int driverIndex; bool CreateConf = ( strcmp(ARGUV[0],"-cc") == 0 || strcmp(ARGUV[0],"-createconfig") == 0 )?1:0; bool Only1Arg = ( ARGUC==1 )?1:0; FirstTimeUpdate = 1; screenRot = 0; for (int i = 0; i<64; i++)xargv_cmd[i]=NULL; //split the path to directory and the name without the zip extension if (parsePath(Only1Arg?path:ARGUV[ARGUC-1], MgamePath, MgameName) == 0) { write_log("parse path failed! path=%s\n", path); strcpy(MgameName,path ); } //Find the game info. Exit if game driver was not found. if (getGameInfo(Only1Arg?MgameName:ARGUV[0], &gameRot, &driverIndex) == 0) { // handle -cc/-createconfig case if(CreateConf){ write_log("create an %s config\n", core); } else { write_log("game not found: %s\n", MgameName); return -2; } } //some hardcoded default Options paramCount=0; sprintf(XARGV[paramCount++],"%s\0",core); sprintf(XARGV[paramCount++],"%s\0","-joystick"); sprintf(XARGV[paramCount++],"%s\0","-samplerate"); sprintf(XARGV[paramCount++],"%s\0","48000"); sprintf(XARGV[paramCount++],"%s\0","-sound"); sprintf(XARGV[paramCount++],"%s\0","-cheat"); sprintf(XARGV[paramCount++],"%s\0","-mouse"); //Setup path Option according to retro (save/system) directory or current if NULL for(int i=0;i<NB_OPTPATH;i++){ sprintf(XARGV[paramCount++],"%s\0",(char*)(opt_name[i])); if(opt_type[i]==0){ if(retro_save_directory!=NULL)sprintf(tmp_dir, "%s%c%s%c%s", retro_save_directory, slash, core, slash,dir_name[i]); else sprintf(tmp_dir, "%s%c%s%c%s", ".", slash, core, slash,dir_name[i]); } else { if(retro_system_directory!=NULL)sprintf(tmp_dir, "%s%c%s%c%s", retro_system_directory, slash, core, slash,dir_name[i]); else sprintf(tmp_dir, "%s%c%s%c%s", ".", slash, core, slash,dir_name[i]); } sprintf(XARGV[paramCount++],"%s\0",(char*)(tmp_dir)); } if(Only1Arg){// Assume arcade rom with full path or -cc if(CreateConf) sprintf(XARGV[paramCount++],"%s\0",(char*)"-createconfig"); else { sprintf(XARGV[paramCount++],"%s\0",(char*)"-rp"); sprintf(XARGV[paramCount++],"%s\0",(char*)g_rom_dir); sprintf(XARGV[paramCount++],"%s\0",MgameName); } } else { // Pass all cmdline args for(int i=0;i<ARGUC;i++) sprintf(XARGV[paramCount++],"%s\0", ARGUV[i]); } write_log("frontend parameters:%i\n", paramCount); for (int i = 0; i<paramCount; i++){ xargv_cmd[i] = (char*)(XARGV[i]); write_log(" %s\n",XARGV[i]); } osd_init_midi(); cli_options MRoptions; mini_osd_interface MRosd; cli_frontend frontend(MRoptions, MRosd); result = frontend.execute(paramCount, ( char **)xargv_cmd); xargv_cmd[paramCount - 2] = NULL; return result; }
int executeGame(char* path) { char tmp_dir[256]; int gameRot=0; int driverIndex; FirstTimeUpdate = 1; screenRot = 0; for (int i = 0; i<64; i++)xargv_cmd[i]=NULL; Extract_AllPath(path); #ifdef WANT_MAME //find if the driver exists for MgameName, if not, exit if (getGameInfo(MgameName, &gameRot, &driverIndex,&arcade) == 0) { write_log("driver not found: %s\n", MgameName); return -2; } #else if(!commandline_enabled) { //find if the driver exists for MgameName, if not, check if a driver exists for MsystemName, if not, exit if (getGameInfo(MgameName, &gameRot, &driverIndex,&arcade) == 0) { write_log("driver not found: %s\n", MgameName); if (getGameInfo(MsystemName, &gameRot, &driverIndex,&arcade) == 0) { write_log("driver not found: %s\n", MsystemName); return -2; } } // handle case where Arcade game exist and game on a System also if(arcade==true){ // test system if (getGameInfo(MsystemName, &gameRot, &driverIndex,&arcade) == 0) { write_log("System not found: %s\n", MsystemName); } else { write_log("System found: %s\n", MsystemName); arcade=false; } } } #endif // useless ? if (tate) { //horizontal game if (gameRot == ROT0) { screenRot = 1; } else if (gameRot & ORIENTATION_FLIP_X) { write_log("*********** flip X \n"); screenRot = 3; } } else { if (gameRot != ROT0) { screenRot = 1; if (gameRot & ORIENTATION_FLIP_X) { write_log("*********** flip X \n"); screenRot = 2; } } } write_log("creating frontend... game=%s\n", MgameName); printf("using softlists: %d\n", softlist_enabled); Set_Default_Option(); Set_Path_Option(); // useless ? if (tate) { if (screenRot == 3) { Add_Option((char*) "-rol"); } } else { if (screenRot == 2) { Add_Option((char*)"-rol"); } } Add_Option((char*)("-rompath")); #ifdef WANT_MAME sprintf(tmp_dir, "%s", MgamePath); Add_Option((char*)(tmp_dir)); if(!boot_to_osd_enabled) Add_Option(MgameName); #else if(!commandline_enabled) { if(!boot_to_osd_enabled) { sprintf(tmp_dir, "%s", MgamePath); Add_Option((char*)(tmp_dir)); if(softlist_enabled) { if(!arcade) { Add_Option(MsystemName); if(!boot_to_bios_enabled) { if(!softlist_auto) Add_Option((char*)mediaType); Add_Option((char*)MgameName); } } else { Add_Option((char*)MgameName); } } else { if (strcmp(mediaType, "-rom") == 0) { Add_Option(MgameName); } else { Add_Option(MsystemName); Add_Option((char*)mediaType); Add_Option((char*)gameName); } } } else { sprintf(tmp_dir, "%s;%s", MgamePath,MparentPath); Add_Option((char*)(tmp_dir)); } } else Add_Option((char*)gameName); #endif return 0; }