void GetValue(wxVariant &variant, unsigned int col) const override { if (col == 0) variant = to_wx(combo.Str()); else if (col == 1) { wxIcon icon; try { auto icon_bmp = cmd::get(combo.CmdName())->Icon(16); if (icon_bmp.IsOk()) icon.CopyFromBitmap(icon_bmp); } catch (agi::Exception const&) { // Just use no icon; error is reported in the description column } variant << wxDataViewIconText(to_wx(combo.CmdName()), icon); } else if (col == 2) { try { variant = cmd::get(combo.CmdName())->StrHelp(); } catch (agi::Exception const& e) { variant = to_wx(e.GetChainedMessage()); } } else throw agi::InternalError("HotkeyDataViewModel asked for an invalid column number", nullptr); }
HotkeyModelCombo(HotkeyModelCategory *parent, Combo const& combo) : parent(parent) , combo(combo) , cmd_name(to_wx(combo.CmdName())) , cmd_str(to_wx(combo.Str())) { }
TEST(lagi_hotkey, combo_stuff) { Hotkey::HotkeyMap hm = Hotkey("", simple_valid).GetHotkeyMap(); Hotkey::HotkeyMap::const_iterator it, end; std::tr1::tie(it, end) = hm.equal_range("cmd1"); EXPECT_EQ(3, std::distance(it, end)); std::tr1::tie(it, end) = hm.equal_range("cmd2"); ASSERT_EQ(1, std::distance(it, end)); Combo c = it->second; EXPECT_STREQ("Ctrl-C", c.StrMenu().c_str()); EXPECT_STREQ("cmd2", c.CmdName().c_str()); EXPECT_STREQ("Default", c.Context().c_str()); EXPECT_EQ(2, c.Get().size()); }
bool LOCA::StatusTest::Combo::isSafe(Abstract& a) { // Are we trying to add "this" to "this"? This would result in an infinite recursion. if (&a == this) return false; // Recursively test that we're not adding something that's already // in the list because that can also lead to infinite recursions. for (std::vector<Teuchos::RCP<Abstract> >::iterator i = tests.begin(); i != tests.end(); ++i) { Combo* ptr = dynamic_cast<Combo*>(i->get()); if (ptr != NULL) if (!ptr->isSafe(a)) return false; } // Otherwise, it's safe to add a to the list. return true; }
bool SetValue(wxVariant const& variant, unsigned int col) override { if (col == 0) { wxArrayString toks = wxSplit(variant.GetString(), '-'); std::vector<std::string> keys; keys.reserve(toks.size()); transform(toks.begin(), toks.end(), back_inserter(keys), (std::string(*)(wxString const&))&from_wx); combo = Combo(combo.Context(), combo.CmdName(), keys); cmd_str = to_wx(combo.Str()); return true; } else if (col == 1) { wxDataViewIconText text; text << variant; combo = Combo(combo.Context(), from_wx(text.GetText()), combo.Get()); cmd_name = text.GetText(); return true; } return false; }
bool SetValue(wxVariant const& variant, unsigned int col) { if (col == 0) { wxArrayString toks = wxSplit(variant.GetString(), '-'); std::vector<std::string> keys; keys.resize(toks.size()); for (size_t i = 0; i < toks.size(); ++i) keys[i] = STD_STR(toks[i]); combo = Combo(combo.Context(), combo.CmdName(), keys); cmd_str = combo.Str(); return true; } else if (col == 1) { wxDataViewIconText text; text << variant; combo = Combo(combo.Context(), STD_STR(text.GetText()), combo.Get()); cmd_name = text.GetText(); return true; } return false; }
void GetValue(wxVariant &variant, unsigned int col) const { if (col == 0) variant = to_wx(combo.Str()); else if (col == 1) { wxBitmap icon_bmp(icon::get(combo.CmdName(), 16)); wxIcon icon; if (icon_bmp.IsOk()) icon.CopyFromBitmap(icon_bmp); variant << wxDataViewIconText(to_wx(combo.CmdName()), icon); } else if (col == 2) { try { variant = cmd::get(combo.CmdName())->StrHelp(); } catch (agi::Exception const& e) { variant = to_wx(e.GetChainedMessage()); } } else throw agi::InternalError("HotkeyDataViewModel asked for an invalid column number", 0); }
void startGame() { g_game->resetLevel( g_levelNdx ); g_state = STATE_PLAYING; if (musicOn) { //Mix_HaltMusic(); Mix_PlayMusic( music_ingame, -1 ); } #if 0 // add some combos.. TODO.. make dependant on level Combo c; // debugging combos c = Combo( 10 ); c.addGroup( PUMPKIN, 3 ); c.m_name = "Three Pumpkins"; c.m_desc = "Three matching items"; g_game->addCombo( c ); c = Combo( 20 ); c.addGroup( PUMPKIN, 4 ); c.m_name = "Four Pumpkins"; c.m_desc = "Four matching items"; g_game->addCombo( c ); c = Combo( 30 ); c.addGroup( PUMPKIN, 2 ); c.addGroup( SKULL, 2 ); c.addGroup( FISH_HEAD, 1 ); c.m_name = "Mixed Bag"; g_game->addCombo( c ); c = Combo( 40 ); c.addGroup( PUMPKIN, 1 ); c.addGroup( PUMPKIN+1, 1 ); c.addGroup( PUMPKIN+2, 1 ); c.addGroup( PUMPKIN+3, 1 ); c.addGroup( SKULL, 1 ); c.m_name = "One of each"; g_game->addCombo( c ); // real combos c = Combo( 10 ); c.addGroup( ANY_ITEM, 3 ); c.m_name = "Three of a kind"; c.m_desc = "Three matching items"; g_game->addCombo( c ); c = Combo( 20 ); c.addGroup( ANY_ITEM, 4 ); c.m_name = "Four of a kind"; c.m_desc = "Four matching items"; g_game->addCombo( c ); c = Combo( 60 ); c.addGroup( ANY_ITEM, 5 ); c.m_name = "Jumbo Pie"; c.m_desc = "Five matching items"; g_game->addCombo( c ); c = Combo( 30 ); c.addGroup( ANY_ITEM, 3 ); c.addGroup( ANY_ITEM, 2 ); c.m_name = "Full House"; c.m_desc = "A pair and three matching items"; g_game->addCombo( c ); c = Combo( 15 ); c.addGroup( ANY_PUMPKIN, 2 ); c.addGroup( SKULL, 1 ); c.m_name = "Pumpkin Surprise"; c.m_desc = "Pair of Pumpkins and a Skull"; g_game->addCombo( c ); c = Combo( 15 ); c.addGroup( ANY_PUMPKIN, 2 ); c.addGroup( ANY_PUMPKIN, 2 ); c.m_name = "Pumpkin Medly"; c.m_desc = "Two pairs of pumpkins"; g_game->addCombo( c ); c = Combo( 50 ); c.addGroup( PUMPKIN, 1 ); c.addGroup( PUMPKIN_ORANGE, 1 ); c.addGroup( PUMPKIN_YELLOW, 1 ); c.addGroup( PUMPKIN_RED, 1 ); c.m_name = "Pumpkin Supreme"; c.m_desc = "One of each pumpkin"; g_game->addCombo( c ); c = Combo( 75 ); c.addGroup( ANY_PUMPKIN, 4 ); c.addGroup( FISH_HEAD, 1 ); c.m_name = "Stargazy Pie"; c.m_desc = "Four Pumpkins and a Fishhead"; g_game->addCombo( c ); #endif }
int main(VOID) { DWORD cNumRead, fdwMode, i; INPUT_RECORD irInBuf[128]; int counter = 0; Combo *combo = new Combo(5, { "1990", "1991", "1992", "1993" }); //combo->draw(); Panel panel(30, 30); panel.AddiControl(*combo, 2, 3); panel.draw(); // Get the standard input handle. hStdin = GetStdHandle(STD_INPUT_HANDLE); if (hStdin == INVALID_HANDLE_VALUE) combo->ErrorExit("GetStdHandle", hStdin, fdwSaveOldMode); hStdout = GetStdHandle(STD_OUTPUT_HANDLE); if (!GetConsoleMode(hStdin, &fdwSaveOldMode)) combo->ErrorExit("GetConsoleMode", hStdin, fdwSaveOldMode); // Enable the window and mouse input events. fdwMode = ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT; if (!SetConsoleMode(hStdin, fdwMode)) combo->ErrorExit("SetConsoleMode", hStdin, fdwSaveOldMode); while (counter++ != EOF) { // Wait for the events. if (!ReadConsoleInput( hStdin, // input buffer handle irInBuf, // buffer to read into 128, // size of read buffer &cNumRead)) // number of records read combo->ErrorExit("ReadConsoleInput", hStdin, fdwSaveOldMode); // Dispatch the events to the appropriate handler. for (i = 0; i < cNumRead; i++) { switch (irInBuf[i].EventType) { case KEY_EVENT: // keyboard input combo->KeyEventProc(irInBuf[i].Event.KeyEvent, hStdout); break; case MOUSE_EVENT: // mouse input combo->MouseEventProc(irInBuf[i].Event.MouseEvent, hStdout); break; case WINDOW_BUFFER_SIZE_EVENT: // scrn buf. resizing combo->ResizeEventProc(irInBuf[i].Event.WindowBufferSizeEvent); break; default: //combo->ErrorExit("Unknown event type", hStdin, fdwSaveOldMode); break; } } } // Restore input mode on exit. SetConsoleMode(hStdin, fdwSaveOldMode); return 0; }
void GameState::loadLevels( const std::string &filename ) { FILE *fp = fopen( filename.c_str(), "rt" ); if (!fp) { printf ("Can't open level file %s!! This is bad...\n", filename.c_str() ); return; } Combo c; char line[1000], cmd[100]; while (!feof(fp)) { fgets( line, 1000, fp ); // skip comments and blank lines if ((line[0]=='\n') || (line[0]=='#')) continue; sscanf( line, "%s", cmd ); // remove newlines if (line[strlen(line)-1] == '\n') { line[strlen(line)-1]=0; } if (!strcmp(cmd, "combo")) { char cname[100], secret[10], comboData[20]; int cval; c = Combo(); sscanf( line, "%*s %s %d %s %s", cname, &cval, secret, comboData ); c.m_desc = cname; c.m_value = cval; if (!strcmp(secret, "yes")) { c.m_secret = true; } else { c.m_secret = false; } for (char *ch = comboData; *ch; ch +=2 ) { int type, num; switch (*ch) { case 'A': type = ANY_ITEM; break; case 'P': type = ANY_PUMPKIN; break; case 'a': type = PUMPKIN; break; case 'b': type = PUMPKIN_ORANGE; break; case 'c': type = PUMPKIN_YELLOW; break; case 'd': type = PUMPKIN_RED; break; case 'S': type = SKULL; break; case 'F': type = FISH_HEAD; break; case 'B': type = BLACKBIRD; break; default: printf( "Unknown combo code %c. Using 'P' instead.\n", *ch ); break; } num = ((*(ch+1)) - '1') + 1; c.addGroup( type, num ); //printf("Adding combogroup %s %d - %d %d\n", c.m_desc.c_str(), // c.m_value, type, num ); } c.m_name = std::string( strchr( line, ':' )+1 ); m_allCombos.push_back( c ); } else if (!strcmp(cmd, "level")) { Level l; char group[100], combos[2000]; int rate; sscanf( line, "%*s %s %d %s", group, &rate, combos ); l = Level(); l.m_group = group; l.m_prodrate = rate; // read the title fgets( line, 1000, fp ); if (line[strlen(line)-1] == '\n') { line[strlen(line)-1]=0; } l.m_title = line; // read the description while (!feof(fp)) { fgets( line, 1000, fp ); if (line[0]=='\n') break; l.m_desc.append( line ); } // add the combos char *tok = strtok( combos, "," ); while( tok ) { for (int i = 0; i < m_allCombos.size(); i++) { if (!strcmp( m_allCombos[i].m_desc.c_str(), tok)) { l.m_combos.push_back( m_allCombos[i] ); break; } } tok = strtok( NULL, "," ); } // yay m_levels.push_back( l ); } } }
void ComBoard :: Load(const char *fileName, xBYTE I_bones) { Destroy(); this->I_bones = I_bones; FileName = Filesystem::GetFullPath(fileName); std::ifstream in; in.open(FileName.c_str()); if (in.is_open()) { std::string dir = Filesystem::GetParentDir(fileName); char buffer[255]; int len; AutoHint hint; Action action; Combo combo; action.Clear(); combo.Clear(); enum LoadMode { LoadMode_None, LoadMode_Auto, LoadMode_Mirror, LoadMode_Action, LoadMode_Combo } mode = LoadMode_None; while (in.good()) { in.getline(buffer, 255); if (buffer[0] == 0 || buffer[0] == '#') continue; len = strlen(buffer); if (buffer[len - 1] == '\r') buffer[len - 1] = 0; if (*buffer == '[') { if (StartsWith(buffer, "[action]")) { if (combo.SN_action.length()) action.L_combos.push_back(combo); if (action.SN_name.length()) L_actions.push_back(action); else action.Destroy(); action.Clear(); combo.Clear(); mode = LoadMode_Action; continue; } if (StartsWith(buffer, "[auto]")) { mode = LoadMode_Auto; continue; } if (StartsWith(buffer, "[mirror]")) { mode = LoadMode_Mirror; continue; } mode = LoadMode_None; continue; } if (mode == LoadMode_Action || mode == LoadMode_Combo) { if (*buffer == '(') { if (mode != LoadMode_None && StartsWith(buffer, "(combo)")) { if (combo.SN_action.length()) action.L_combos.push_back(combo); combo.Clear(); mode = LoadMode_Combo; continue; } continue; } } if (mode == LoadMode_Auto) { if (StartsWith(buffer, "stop")) { StopAction.SN_action = ReadSubstring(buffer+4); continue; } if (StartsWith(buffer, "step")) { const char* params = NULL; hint.SN_action = ReadSubstring(buffer+4, params); if (params) { int flag = 1; sscanf(params, "%f %d", &hint.S_max_change, &flag); hint.FL_breakable = flag; } L_hint[AutoHint::HINT_STEP].push_back(hint); continue; } if (StartsWith(buffer, "back")) { const char* params = NULL; hint.SN_action = ReadSubstring(buffer+4, params); if (params) { int flag = 1; sscanf(params, "%f %d", &hint.S_max_change, &flag); hint.FL_breakable = flag; } L_hint[AutoHint::HINT_BACK].push_back(hint); continue; } if (StartsWith(buffer, "left")) { const char* params = NULL; hint.SN_action = ReadSubstring(buffer+4, params); if (params) { int flag = 1; sscanf(params, "%f %d", &hint.S_max_change, &flag); hint.FL_breakable = flag; } L_hint[AutoHint::HINT_LEFT].push_back(hint); continue; } if (StartsWith(buffer, "right")) { const char* params = NULL; hint.SN_action = ReadSubstring(buffer+5, params); if (params) { int flag = 1; sscanf(params, "%f %d", &hint.S_max_change, &flag); hint.FL_breakable = flag; } L_hint[AutoHint::HINT_RIGHT].push_back(hint); continue; } } if (mode == LoadMode_Mirror) { if (StartsWith(buffer, "bones")) { int b1, b2; sscanf(buffer+5, "%d %d", &b1, &b2); Mirror mirror; mirror.ID_bone1 = b1; mirror.ID_bone2 = b2; L_mirror.push_back(mirror); continue; } } if (mode == LoadMode_Action) { if (StartsWith(buffer, "name")) { action.SN_name = ReadSubstring(buffer+4); continue; } if (StartsWith(buffer, "anim")) { const char* params = NULL; std::string animFile = Filesystem::GetFullPath(dir + "/" + ReadSubstring(buffer+4, params)); int start = 0, end = 0; if (params) sscanf(params, "%d %d", &start, &end); if (end <= start) action.Anims.AddAnimation(animFile.c_str(), start); else action.Anims.AddAnimation(animFile.c_str(), start, end); continue; } if (StartsWith(buffer, "time")) { float time; sscanf(buffer+4, "%f", &time); action.T_duration = time; continue; } if (StartsWith(buffer, "post")) { action.SN_next = ReadSubstring(buffer+4); continue; } if (StartsWith(buffer, "rotate")) { int val; sscanf(buffer+6, "%d", &val); action.FL_pos_rotation = val != 0; continue; } if (StartsWith(buffer, "mirror")) { int val; sscanf(buffer+6, "%d", &val); action.FL_mirror = val; continue; } if (StartsWith(buffer, "power")) { sscanf(buffer+5, "%f", &action.W_punch); continue; } if (StartsWith(buffer, "puncht")) { sscanf(buffer+6, "%f", &action.T_punch); continue; } } if (mode == LoadMode_Combo) { if (StartsWith(buffer, "action")) { combo.SN_action = ReadSubstring(buffer+6); continue; } if (StartsWith(buffer, "key")) { char name[255]; sscanf(buffer+3, "%s", name); if (StartsWith(name, "LeftPunch")) combo.Key = Combo::Keys::LeftPunch; else if (StartsWith(name, "LeftKick")) combo.Key = Combo::Keys::LeftKick; else if (StartsWith(name, "LeftHandGuard")) combo.Key = Combo::Keys::LeftHandGuard; else if (StartsWith(name, "LeftLegGuard")) combo.Key = Combo::Keys::LeftLegGuard; else if (StartsWith(name, "RightPunch")) combo.Key = Combo::Keys::RightPunch; else if (StartsWith(name, "RightKick")) combo.Key = Combo::Keys::RightKick; else if (StartsWith(name, "RightHandGuard")) combo.Key = Combo::Keys::RightHandGuard; else if (StartsWith(name, "RightLegGuard")) combo.Key = Combo::Keys::RightLegGuard; else if (StartsWith(name, "Forward")) combo.Key = Combo::Keys::Forward; else if (StartsWith(name, "Backward")) combo.Key = Combo::Keys::Backward; else if (StartsWith(name, "Left")) combo.Key = Combo::Keys::Left; else if (StartsWith(name, "Right")) combo.Key = Combo::Keys::Right; else combo.Key = Combo::Keys::Undefined; continue; } if (StartsWith(buffer, "first")) { float time; sscanf(buffer+5, "%f", &time); combo.T_first = time; continue; } if (StartsWith(buffer, "last")) { float time; sscanf(buffer+4, "%f", &time); combo.T_last = time; continue; } if (StartsWith(buffer, "time")) { float time; sscanf(buffer+4, "%f", &time); combo.T_time = time; continue; } if (StartsWith(buffer, "prec")) { int val; sscanf(buffer+4, "%d", &val); combo.FL_time_shift = val == 0; continue; } if (StartsWith(buffer, "shift")) { int val; sscanf(buffer+5, "%d", &val); combo.FL_pos_shift = val != 0; continue; } } } if (combo.SN_action.length()) action.L_combos.push_back(combo); if (action.SN_name.length()) L_actions.push_back(action); else action.Destroy(); // Release animations in.close(); UpdateIDs(); } }
void Apply(Hotkey::HotkeyMap *hk_map) { if (combo.CmdName().size() || combo.Str().size()) hk_map->insert(make_pair(combo.CmdName(), combo)); }
void Hotkey::ComboInsert(Combo const& combo) { str_map.insert(make_pair(combo.Str(), combo)); cmd_map.insert(make_pair(combo.CmdName(), combo)); }
bool Combo::operator ==(const Combo &ev) { return left() == ev.left() && right() == ev.right() && up() == ev.up() && down() == ev.down() && mid() == ev.mid(); }