void WPassGen::OnSpinNumber(wxSpinEvent& event) { pass_type passtype = (pass_type)choiceType->GetSelection(); bool skip_similar = checkboxSkipSimilarChar->GetValue(); bool skip_swapped = checkboxSkipSwappedChar->GetValue(); wxString extrachar = textctrlExtraChar->GetValue(); int passlen = spinctrlLength->GetValue(); bool enumerate = checkboxEnumerate->GetValue(); int passnumber = event.GetPosition(); Preset preset(_T(""), passtype, skip_similar, skip_swapped, extrachar, passlen); if (standalone) { // Fill wxTextCtrl with passwords wxString oldtext = textctrlPasslist->GetValue(); wxStringTokenizer oldtexttoken(oldtext, _T("\n")); wxString newtext; for (int i = 0; i < passnumber; i++) { if (oldtexttoken.HasMoreTokens()) { newtext += oldtexttoken.GetNextToken() + _T("\n"); } else { if (enumerate) newtext += wxString::Format(_T("%u "), i); newtext += MakePassword(preset) + _T("\n"); } } textctrlPasslist->SetValue(newtext); } else { // Fill wxListCtrl with passwords int oldcount = listctrlPasslist->GetItemCount(); for (int i = oldcount; i > passnumber; --i) { listctrlPasslist->DeleteItem(i - 1); } for (int i = oldcount; i < passnumber; i++) { listctrlPasslist->InsertItem(i, MakePassword(preset)); } } buttonOK->Disable(); }
BOOL CheckPassword(const char *cfgPasswd, const char *inputPasswd) { char buf[MAX_NAMEBUF]; MakePassword(inputPasswd, buf); return strcmp(buf, cfgPasswd) == 0 ? TRUE : FALSE; }
void WPassGen::GenerateList() { pass_type passtype = (pass_type)choiceType->GetSelection(); bool skip_similar = checkboxSkipSimilarChar->GetValue(); bool skip_swapped = checkboxSkipSwappedChar->GetValue(); wxString extrachar = textctrlExtraChar->GetValue(); int passlen = spinctrlLength->GetValue(); bool enumerate = checkboxEnumerate->GetValue(); int passnumber = spinctrlNumber->GetValue(); Preset preset(_T(""), passtype, skip_similar, skip_swapped, extrachar, passlen); if (standalone) { // Fill wxTextCtrl with passwords wxString text; for (int i = 0; i < passnumber; i++) { if (enumerate) text += wxString::Format(_T("%u "), i); text += MakePassword(preset) + _T("\n"); } textctrlPasslist->SetValue(text); } else { // Fill wxListCtrl with passwords listctrlPasslist->DeleteAllItems(); for (int i = 0; i < passnumber; i++) { listctrlPasslist->InsertItem(i, MakePassword(preset)); } } buttonOK->Disable(); }
bool ScreenMissionSummary(CampaignOptions *c, struct MissionOptions *m) { // Save password MissionSave ms; MissionSaveInit(&ms); ms.Campaign = c->Entry; // Don't make password for next level if there is none int passwordIndex = m->index + 1; if (passwordIndex == c->Entry.NumMissions) { passwordIndex--; } strcpy(ms.Password, MakePassword(passwordIndex, 0)); ms.MissionsCompleted = m->index + 1; AutosaveAddMission(&gAutosave, &ms, ms.Campaign.BuiltinIndex); AutosaveSave(&gAutosave, GetConfigFilePath(AUTOSAVE_FILE)); // Calculate bonus scores // Bonuses only apply if at least one player has lived if (AreAnySurvived()) { int bonus = 0; // Objective bonuses for (int i = 0; i < (int)m->missionData->Objectives.size; i++) { const struct Objective *o = CArrayGet(&m->Objectives, i); const MissionObjective *mo = CArrayGet(&m->missionData->Objectives, i); if (o->done == mo->Count && o->done > mo->Required) { // Perfect bonus += PERFECT_BONUS; } } bonus += GetAccessBonus(m); bonus += GetTimeBonus(m, NULL); for (int i = 0; i < (int)gPlayerDatas.size; i++) { PlayerData *p = CArrayGet(&gPlayerDatas, i); ApplyBonuses(p, bonus); } } GameLoopWaitForAnyKeyOrButtonData wData; GameLoopData gData = GameLoopDataNew( &wData, GameLoopWaitForAnyKeyOrButtonFunc, m, MissionSummaryDraw); GameLoop(&gData); if (wData.IsOK) { SoundPlay(&gSoundDevice, StrSound("mg")); } return wData.IsOK; }
void CMessageKeyProcessor::ProcessKeyPress(TChar aChar) { TInt error = KErrNone; aChar.UpperCase(); switch(aChar) { case 'Q': case EKeyEscape: { TInt err = KErrNone; for(TInt j=0; j<KMaxDrives; j++) { err = RestoreMount(j); if (err) { // Mount is busy/locked and can not be restored. break; } } if (err == KErrNone) { CActiveScheduler::Stop(); return; } } break; #if defined(_DEBUG) case 'T': iTraceEnable = !iTraceEnable; if (iTraceEnable) // 0x44008401 User::SetDebugMask(KHARDWARE|KDLL|KSCRATCH|KPOWER|KMEMTRACE); else User::SetDebugMask(0); break; #endif case 'D': if(++selectedDriveIndex >= PropertyHandlers::allDrivesStatus.Length()/2) { selectedDriveIndex = 0; } ShowDriveSelection(); break; case 'M': if(PropertyHandlers::allDrivesStatus.Length()) { MountMsFs(PropertyHandlers::allDrivesStatus[selectedDriveIndex*2]); } break; case 'U': if(PropertyHandlers::allDrivesStatus.Length()) { RestoreMount(PropertyHandlers::allDrivesStatus[selectedDriveIndex*2]); } break; case 'L': { // lock unprotected drive TMediaPassword password; MakePassword(password); _LIT(KEmpty, ""); TMediaPassword nul; nul.Copy(KEmpty); error = fs.LockDrive(PropertyHandlers::allDrivesStatus[selectedDriveIndex*2], nul, password, ETrue); console->SetPos(0,9); LogPrint(_L("LockDrive %S (%d)"), (error?&KError:&KOk), error); break; } case 'I': { // lock password protected drive TMediaPassword password; MakePassword(password); error = fs.LockDrive(PropertyHandlers::allDrivesStatus[selectedDriveIndex*2], password, password, ETrue); console->SetPos(0,9); LogPrint(_L("LockDrive %S (%d)"), (error?&KError:&KOk), error); break; } case 'N': { TMediaPassword password; MakePassword(password); error = fs.UnlockDrive(PropertyHandlers::allDrivesStatus[selectedDriveIndex*2], password, ETrue); Clear(9); LogPrint(_L("UnlockDrive %S (%d)"), (error?&KError:&KOk), error); } break; case 'C': { TMediaPassword password; MakePassword(password); error = fs.ClearPassword(PropertyHandlers::allDrivesStatus[selectedDriveIndex*2], password); Clear(9); LogPrint(_L("ClearPassword %S (%d)"), (error?&KError:&KOk), error); } break; default: break; } RequestCharacter(); }
bool ScreenMissionSummary( CampaignOptions *c, struct MissionOptions *m, const bool completed) { if (completed) { // Save password MissionSave ms; MissionSaveInit(&ms); ms.Campaign = c->Entry; // Don't make password for next level if there is none int passwordIndex = m->index + 1; if (passwordIndex == c->Entry.NumMissions) { passwordIndex--; } strcpy(ms.Password, MakePassword(passwordIndex, 0)); ms.MissionsCompleted = m->index + 1; AutosaveAddMission(&gAutosave, &ms); AutosaveSave(&gAutosave, GetConfigFilePath(AUTOSAVE_FILE)); } // Calculate bonus scores // Bonuses only apply if at least one player has lived if (AreAnySurvived()) { int bonus = 0; // Objective bonuses CA_FOREACH(const Objective, o, m->missionData->Objectives) if (ObjectiveIsPerfect(o)) { bonus += PERFECT_BONUS; } CA_FOREACH_END() bonus += GetAccessBonus(m); bonus += GetTimeBonus(m, NULL); CA_FOREACH(PlayerData, p, gPlayerDatas) ApplyBonuses(p, bonus); CA_FOREACH_END() } MenuSystem ms; const int h = FontH() * 10; MenuSystemInit( &ms, &gEventHandlers, &gGraphicsDevice, Vec2iNew(0, gGraphicsDevice.cachedConfig.Res.y - h), Vec2iNew(gGraphicsDevice.cachedConfig.Res.x, h)); ms.current = ms.root = MenuCreateNormal("", "", MENU_TYPE_NORMAL, 0); // Use return code 0 for whether to continue the game if (completed) { MenuAddSubmenu(ms.root, MenuCreateReturn("Continue", 0)); } else { MenuAddSubmenu(ms.root, MenuCreateReturn("Replay mission", 0)); MenuAddSubmenu(ms.root, MenuCreateReturn("Back to menu", 1)); } ms.allowAborts = true; MenuAddExitType(&ms, MENU_TYPE_RETURN); MenuSystemAddCustomDisplay(&ms, MissionSummaryDraw, m); MenuLoop(&ms); return ms.current->u.returnCode == 0; }
BOOL TSetupSheet::GetData() { char buf[MAX_PATH_U8]; int i; if (resId == SETUP_SHEET1) { BOOL need_broadcast = FALSE; GetDlgItemTextU8(NICKNAME_EDIT, buf, MAX_NAMEBUF); if (strcmp(cfg->NickNameStr, buf)) { need_broadcast = TRUE; strcpy(cfg->NickNameStr, buf); } GetDlgItemTextU8(GROUP_COMBO, buf, MAX_NAMEBUF); if (strcmp(cfg->GroupNameStr, buf)) { need_broadcast = TRUE; strcpy(cfg->GroupNameStr, buf); } if (need_broadcast) { ::PostMessage(GetMainWnd(), WM_IPMSG_BRNOTIFY, 0, IPMSG_DEFAULT_PORT); } if (SendDlgItemMessage(CLIPMODE_CHECK, BM_GETCHECK, 0, 0)) { cfg->ClipMode |= CLIP_ENABLE; } else { cfg->ClipMode &= ~CLIP_ENABLE; } if (SendDlgItemMessage(CLIPCONFIRM_CHECK, BM_GETCHECK, 0, 0)) { cfg->ClipMode |= CLIP_CONFIRM; } else { cfg->ClipMode &= ~CLIP_CONFIRM; } cfg->brList.Reset(); for (i=0; SendDlgItemMessage(BROADCAST_LIST, LB_GETTEXT, i, (LPARAM)buf) != LB_ERR; i++) cfg->brList.SetHostRaw(buf, ResolveAddr(buf)); cfg->DialUpCheck = (int)SendDlgItemMessage(DIALUP_CHECK, BM_GETCHECK, 0, 0); } else if (resId == SETUP_SHEET2) { cfg->BalloonNotify = (int)SendDlgItemMessage(BALLOONNOTIFY_CHECK, BM_GETCHECK, 0, 0); cfg->OpenCheck = (int)SendDlgItemMessage(OPEN_COMBO, CB_GETCURSEL, 0, 0); // cfg->OpenCheck = (int)SendDlgItemMessage(OPEN_CHECK, BM_GETCHECK, 0, 0); GetDlgItemTextU8(QUOTE_EDIT, cfg->QuoteStr, sizeof(cfg->QuoteStr)); cfg->HotKeyCheck = (int)SendDlgItemMessage(HOTKEY_CHECK, BM_GETCHECK, 0, 0); cfg->AbnormalButton = (int)SendDlgItemMessage(ABNORMALBTN_CHECK, BM_GETCHECK, 0, 0); if (::IsWindowEnabled(GetDlgItem(LCID_CHECK))) { cfg->lcid = IsDlgButtonChecked(LCID_CHECK) ? 0x409 : -1; } cfg->ExtendBroadcast = (int)SendDlgItemMessage(EXTBROADCAST_COMBO, CB_GETCURSEL, 0, 0); GetDlgItemTextU8(MAINICON_EDIT, cfg->IconFile, sizeof(cfg->IconFile)); GetDlgItemTextU8(REVICON_EDIT, cfg->RevIconFile, sizeof(cfg->RevIconFile)); ::SendMessage(GetMainWnd(), WM_IPMSG_INITICON, 0, 0); SetDlgIcon(hWnd); SetHotKey(cfg); } else if (resId == SETUP_SHEET3) { cfg->QuoteCheck = (int)SendDlgItemMessage(QUOTE_CHECK, BM_GETCHECK, 0, 0); cfg->SecretCheck = (int)SendDlgItemMessage(SECRET_CHECK, BM_GETCHECK, 0, 0); cfg->OneClickPopup = (int)SendDlgItemMessage(ONECLICK_CHECK, BM_GETCHECK, 0, 0); GetDlgItemTextU8(LRUUSER_EDIT, buf, sizeof(buf)); cfg->lruUserMax = atoi(buf); // ControlIME ... 0:off, 1:senddlg on (finddlg:off), 2:always on cfg->ControlIME = (int)SendDlgItemMessage(CONTROLIME_CHECK, BM_GETCHECK, 0, 0); if (cfg->ControlIME && SendDlgItemMessage(FINDDLGIME_CHECK, BM_GETCHECK, 0, 0) == 0) { cfg->ControlIME = 2; } cfg->NoPopupCheck = (int)SendDlgItemMessage(NOPOPUP_CHECK, BM_GETCHECK, 0, 0); cfg->NoBeep = (int)SendDlgItemMessage(NOBEEP_CHECK, BM_GETCHECK, 0, 0); cfg->AbsenceNonPopup = (int)SendDlgItemMessage(ABSENCENONPOPUP_CHECK, BM_GETCHECK, 0, 0); cfg->RecvLogonDisp = (int)SendDlgItemMessage(RECVLOGON_CHECK, BM_GETCHECK, 0, 0); cfg->RecvIPAddr = (int)SendDlgItemMessage(RECVIPADDR_CHECK, BM_GETCHECK, 0, 0); cfg->NoErase = (int)SendDlgItemMessage(NOERASE_CHECK, BM_GETCHECK, 0, 0); GetDlgItemTextU8(SOUND_EDIT, cfg->SoundFile, sizeof(cfg->SoundFile)); } else if (resId == SETUP_SHEET4) { cfg->LogCheck = (int)SendDlgItemMessage(LOG_CHECK, BM_GETCHECK, 0, 0); cfg->LogonLog = (int)SendDlgItemMessage(LOGONLOG_CHECK, BM_GETCHECK, 0, 0); cfg->IPAddrCheck = (int)SendDlgItemMessage(IPADDR_CHECK, BM_GETCHECK, 0, 0); if (SendDlgItemMessage(IMAGESAVE_CHECK, BM_GETCHECK, 0, 0)) { cfg->ClipMode |= 2; } else { cfg->ClipMode &= ~2; } cfg->LogUTF8 = (int)SendDlgItemMessage(LOGUTF8_CHECK, BM_GETCHECK, 0, 0); cfg->PasswdLogCheck = (int)SendDlgItemMessage(PASSWDLOG_CHECK, BM_GETCHECK, 0, 0); GetDlgItemTextU8(LOG_EDIT, cfg->LogFile, sizeof(cfg->LogFile)); if (cfg->LogCheck) LogMng::StrictLogFile(cfg->LogFile); } else if (resId == SETUP_SHEET5) { char buf[MAX_NAMEBUF]; GetDlgItemTextU8(OLDPASSWORD_EDIT, buf, sizeof(buf)); if (CheckPassword(cfg->PasswordStr, buf)) { GetDlgItemTextU8(NEWPASSWORD_EDIT, buf, sizeof(buf)); MakePassword(buf, cfg->PasswordStr); } } else if (resId == SETUP_SHEET6) { cfg->DefaultUrl = (int)SendDlgItemMessage(DEFAULTURL_CHECK, BM_GETCHECK, 0, 0); for (UrlObj *tmp_obj = (UrlObj *)tmpUrlList.TopObj(); tmp_obj; tmp_obj = (UrlObj *)tmpUrlList.NextObj(tmp_obj)) { UrlObj *obj = SearchUrlObj(&cfg->urlList, tmp_obj->protocol); if (!obj) { obj = new UrlObj; cfg->urlList.AddObj(obj); strcpy(obj->protocol, tmp_obj->protocol); } strcpy(obj->program, tmp_obj->program); } cfg->ShellExec = (int)SendDlgItemMessage(SHELLEXEC_CHECK, BM_GETCHECK, 0, 0); } return TRUE; }