bool TestArchive(const std::list<CString> &rArcList,CConfigManager &ConfigManager) { CArchiverDLLManager &ArchiverManager=CArchiverDLLManager::GetInstance(); //XacRettはチェックが甘いため使わない //プログレスバー CProgressDialog dlg; int nFiles=rArcList.size(); dlg.Create(NULL); dlg.SetTotalFileCount(nFiles); dlg.ShowWindow(SW_SHOW); std::list<CString>::const_iterator ite=rArcList.begin(); const std::list<CString>::const_iterator end=rArcList.end(); //テスト結果を格納する std::vector<ARCLOG> LogArray; for(;ite!=end;++ite){ //プログレスバーを進める if(dlg.IsWindow())dlg.SetNextState(*ite); ARCLOG arcLog; arcLog.strFile=*ite; //アーカイバハンドラ取得 //NOTE:DenyExtによる対象絞り込みは既に行われているので2回は行わない CArchiverDLL *Archiver=ArchiverManager.GetArchiver(*ite,NULL); if(!Archiver){ //---対応するハンドラがなかった:原因を調査 //通常のエラー arcLog.strMsg.Format(IDS_ERROR_ILLEGAL_HANDLER,*ite); arcLog.Result=TEST_NOTARCHIVE; //UNICODE関係のチェック if(!UtilCheckT2A(*ite)){ //UNICODEに対応していないのにUNICODEファイル名のファイルを扱おうとした arcLog.strMsg+=_T("\r\n\r\n"); arcLog.strMsg.AppendFormat(IDS_ERROR_UNICODEPATH); } }else{ CString strTemp; arcLog.Result=Archiver->TestArchive(*ite,strTemp); arcLog.strMsg=Archiver->GetName(); arcLog.strMsg+=_T("\r\n\r\n"); arcLog.strMsg+=strTemp; } LogArray.push_back(arcLog); } //プログレスバーを閉じる if(dlg.IsWindow())dlg.DestroyWindow(); //ログに表示 CLogListDialog LogDlg(CString(MAKEINTRESOURCE(IDS_LOGINFO_OPERATION_TESTARCHIVE))); LogDlg.SetLogArray(LogArray); LogDlg.DoModal(::GetDesktopWindow()); return true; }
DWORD Process() { try { Process2(); } catch(const wchar_t *s) { Error = s; } catch(...) { Error = L"Error";} ProgressDialog->MyClose(); return 0; }
void testCProgressDialog() { CProgressDialog ProgressDialog; CThreadProgressDialog benchmarker; benchmarker.ProgressDialog = &ProgressDialog; NWindows::CThread thread; thread.Create(CThreadProgressDialog::MyThreadFunction, &benchmarker); // void StartProgressDialog(const UString &title) int ret = ProgressDialog.Create(L"testCProgressDialog", 0); if (ret == IDOK) myErrorMsg(wxT("CProgressDialog => IDOK")); else if (ret == IDCANCEL) myErrorMsg(wxT("CProgressDialog => IDCANCEL")); else myErrorMsg(wxT("CProgressDialog => ?")); }
HRESULT CExtractCallbackConsole::ExtractResult(HRESULT result) { /* 追加ここから */ CProgressDialog* pDlg = g_StdOut.GetProgressDialog(); if (pDlg) { pDlg->SetCompleted(pDlg->GetTotalSize()); pDlg->SendExtractingInfo(ARCEXTRACT_END); } /* 追加ここまで */ if (result == S_OK) { (*OutStream) << endl; if (NumFileErrorsInCurrentArchive == 0) (*OutStream) << kEverythingIsOk << endl; else { NumArchiveErrors++; (*OutStream) << "Sub items Errors: " << NumFileErrorsInCurrentArchive << endl; } } if (result == S_OK) return result; // NumArchiveErrors++; // 削除 // if (result == E_ABORT || result == ERROR_DISK_FULL) // 削除 // return result; // 削除 /* 追加ここから */ if (result == E_ABORT || result == ERROR_PASSWORD_FILE) { NumArchiveErrors = 0; NumFileErrors = 0; return result; } NumArchiveErrors++; if (result == ERROR_DISK_FULL) return ERROR_DISK_FULL; /* 追加ここまで */ (*OutStream) << endl << kError; if (result == E_OUTOFMEMORY) (*OutStream) << kMemoryExceptionMessage; else (*OutStream) << NError::MyFormatMessageW(result); (*OutStream) << endl; return S_OK; }
void CPetResurrectionDialog::OnActionEvent(LONG lId, void* p, DWORD we) { if( lId == PET_RES_DLG_CANCEL ) { SetActive( FALSE ); // 081021 LYW --- PetResurrectionDialog : 아이템의 락을 풀어준다. if( mUsedItem ) mUsedItem->SetLock( FALSE ) ; } if( lId == PET_RES_DLG_OK ) { CItem* pItem = ( CItem* )( mSourceItem->GetLinkItem() ); if( !pItem ) return; mMessage.Category = MP_PET; mMessage.Protocol = MP_PET_RESURRECTION_SYN; mMessage.dwObjectID = HEROID; mMessage.dwData1 = pItem->GetDBIdx(); mMessage.dwData2 = mUsedItem->GetPosition(); mMessage.dwData3 = mUsedItem->GetItemIdx(); GAMEIN->GetInventoryDialog()->SetCoolTime( mUsedItem->GetItemIdx(), WAITMILISECOND ); { cQuickSlotDlg* dialog = ( cQuickSlotDlg* )WINDOWMGR->GetWindowForID( QI1_QUICKSLOTDLG ); ASSERT( dialog ); //dialog->SetCoolTime( pItem->GetItemIdx(), changeSecond ); dialog->SetCoolTime( mUsedItem->GetItemIdx(), WAITMILISECOND ); } { CProgressDialog* dialog = ( CProgressDialog* )WINDOWMGR->GetWindowForID( PROGRESS_DIALOG ); ASSERT( dialog ); // 081112 LYW --- PetResurrectionDialog : 펫을 부활할 때, // 프로그레스 바의 출력 메시지를 부활중이라는 메시지로 수정 함.(정진문) dialog->SetText( CHATMGR->GetChatMsg( 1740 ) ) ; dialog->Wait( CProgressDialog::eActionPetResurrection ); } } }
HRESULT Process() { Sleep(1000); int total = 1000; ProgressDialog->ProgressSynch.SetTitleFileName(L"SetTitleFileName"); ProgressDialog->ProgressSynch.SetNumFilesTotal(100); ProgressDialog->ProgressSynch.SetNumFilesCur(1); ProgressDialog->ProgressSynch.SetProgress(total, 0); // ProgressDialog.ProgressSynch.SetRatioInfo(inSize, outSize); // ProgressDialog.ProgressSynch.SetCurrentFileName(name); ProgressDialog->ProgressSynch.SetPos(total/10); ProgressDialog->ProgressSynch.SetCurrentFileName(L"File1"); Sleep(1000); ProgressDialog->ProgressSynch.SetPos(total/2); ProgressDialog->ProgressSynch.SetCurrentFileName(L"File2"); Sleep(1000); ProgressDialog->ProgressSynch.SetPos(total); ProgressDialog->ProgressSynch.SetCurrentFileName(L"File3"); Sleep(1000); ProgressDialog->MyClose(); return 0; }
bool Extract(std::list<CString> &ParamList,CConfigManager &ConfigManager,DLL_ID ForceDLL,LPCTSTR lpSpecificOutputDir,const CMDLINEINFO* lpCmdLineInfo) { TRACE(_T("Function ::Extract() started.\n")); CConfigGeneral ConfGeneral; CConfigExtract ConfExtract; ConfGeneral.load(ConfigManager); ConfExtract.load(ConfigManager); //設定上書き if(lpCmdLineInfo){ if(-1!=lpCmdLineInfo->OutputToOverride){ ConfExtract.OutputDirType=lpCmdLineInfo->OutputToOverride; } if(-1!=lpCmdLineInfo->CreateDirOverride){ ConfExtract.CreateDir=lpCmdLineInfo->CreateDirOverride; } if(-1!=lpCmdLineInfo->DeleteAfterProcess){ ConfExtract.DeleteArchiveAfterExtract=lpCmdLineInfo->DeleteAfterProcess; } } //セマフォによる排他処理 CSemaphoreLocker SemaphoreLock; if(ConfExtract.LimitExtractFileCount){ SemaphoreLock.Lock(LHAFORGE_EXTRACT_SEMAPHORE_NAME,ConfExtract.MaxExtractFileCount); } UINT uFiles=ParamList.size(); //引数にあるファイルの数 //プログレスバー CProgressDialog dlg; //メッセージループを回すためのタイマー int timer=NULL; if(uFiles>=2){ //ファイルが複数ある時に限定 dlg.Create(NULL); dlg.SetTotalFileCount(uFiles); dlg.ShowWindow(SW_SHOW); timer=SetTimer(NULL,NULL,1000,UtilMessageLoopTimerProc); } //指定の出力先 CPath pathSpecificOutputDir(lpSpecificOutputDir ? lpSpecificOutputDir : _T("")); std::vector<ARCLOG> LogArray; //処理結果を保持 bool bAllOK=true; //すべて問題なく解凍されればtrue //解凍処理 for(std::list<CString>::iterator ite_param=ParamList.begin();ite_param!=ParamList.end();++ite_param){ //プログレスバーを進める if(dlg.IsWindow())dlg.SetNextState(*ite_param); ARCLOG arcLog; //メッセージループ while(UtilDoMessageLoop())continue; //アーカイバハンドラ取得 //ここでUNICODE非対応DLLにユニコードファイル名を渡そうとした場合は弾かれる。そして、ここでは失敗の原因を解明できない CArchiverDLL *lpArchiver=CArchiverDLLManager::GetInstance().GetArchiver(*ite_param,ConfExtract.DenyExt,ForceDLL); if(!lpArchiver){ //対応するハンドラがなかった arcLog.Result=EXTRACT_NOTARCHIVE; arcLog.strMsg.Format(IDS_ERROR_ILLEGAL_HANDLER,(LPCTSTR)*ite_param); arcLog.strFile=*ite_param; bAllOK=false; LogArray.push_back(arcLog); continue; } CPath pathOpenDir; //ファイラが開くべきフォルダ //解凍実行 bool bRet=ExtractOneArchive(ConfigManager,ConfGeneral,ConfExtract,lpArchiver,*ite_param,pathSpecificOutputDir,arcLog,pathOpenDir); //ログ保存 LogArray.push_back(arcLog); if(!bRet){ bAllOK=false; }else{ //出力先フォルダを開く if(ConfExtract.OpenDir){ if(ConfGeneral.Filer.UseFiler){ //パラメータ展開に必要な情報 std::map<stdString,CString> envInfo; MakeExpandInformationEx(envInfo,pathOpenDir,NULL); //コマンド・パラメータ展開 CString strCmd,strParam; UtilExpandTemplateString(strCmd,ConfGeneral.Filer.FilerPath,envInfo); //コマンド UtilExpandTemplateString(strParam,ConfGeneral.Filer.Param,envInfo); //パラメータ ShellExecute(NULL, _T("open"), strCmd,strParam, NULL, SW_SHOWNORMAL); }else{ //Explorerで開く UtilNavigateDirectory(pathOpenDir); } } //正常に解凍できた圧縮ファイルを削除orごみ箱に移動 if(bRet && ConfExtract.DeleteArchiveAfterExtract){ if(!ConfExtract.ForceDelete && lpArchiver->IsWeakErrorCheck()){ //エラーチェック機構が貧弱なため、解凍失敗時にも正常と判断してしまうような //DLLを使ったときには明示的に指定しない限り削除させない MessageBox(NULL,CString(MAKEINTRESOURCE(IDS_MESSAGE_EXTRACT_DELETE_SKIPPED)),UtilGetMessageCaption(),MB_OK|MB_ICONINFORMATION); }else{ //削除 DeleteOriginalArchives(ConfExtract,*ite_param); } } } } //プログレスバーを閉じる if(dlg.IsWindow())dlg.DestroyWindow(); //タイマーを閉じる if(timer)KillTimer(NULL,timer); //---ログ表示 switch(ConfGeneral.LogViewEvent){ case LOGVIEW_ON_ERROR: if(!bAllOK){ if(1==uFiles){ //ファイル一つだけの時はダイアログボックスで if(EXTRACT_CANCELED!=LogArray[0].Result){ ErrorMessage(LogArray[0].strMsg); } }else{ //ログに表示 CLogListDialog LogDlg(CString(MAKEINTRESOURCE(IDS_LOGINFO_OPERATION_EXTRACT))); LogDlg.SetLogArray(LogArray); LogDlg.DoModal(::GetDesktopWindow()); } } break; case LOGVIEW_ALWAYS: //ログに表示 CLogListDialog LogDlg(CString(MAKEINTRESOURCE(IDS_LOGINFO_OPERATION_EXTRACT))); LogDlg.SetLogArray(LogArray); LogDlg.DoModal(::GetDesktopWindow()); break; } TRACE(_T("Exit Extract()\n")); return bAllOK; }
void CPetManager::NetworkMsgParse(BYTE Protocol,void* pMsg) { switch( Protocol ) { case MP_PET_HATCH: { MSG_PET_INFO* pmsg = ( MSG_PET_INFO* )pMsg; PET_OBJECT_INFO* pObjectInfo = new PET_OBJECT_INFO; memcpy( pObjectInfo, &( pmsg->PetObjectInfo ), sizeof( PET_OBJECT_INFO ) ); mPetObjectInfoTable.Add( pObjectInfo, pObjectInfo->ItemDBIdx ); PET_INFO* pInfo = mPetInfoTable.GetData( pObjectInfo->Kind ); CItem* pItem = ITEMMGR->GetItem( pObjectInfo->ItemDBIdx ); if( !pInfo || !pItem ) return; CHATMGR->AddMsg( CTC_SYSMSG, CHATMGR->GetChatMsg(1573), pInfo->Name, pObjectInfo->SkillSlot ); pItem->ForcedUnseal(); ITEMMGR->RefreshItem( pItem ); } break; case MP_PET_EXP_NOTIFY: { HEROPET->AddExp(); } break; case MP_PET_LEVELUP_NOTIFY: { MSG_DWORD* pmsg = ( MSG_DWORD* )pMsg; CPet* pPet = ( CPet* )OBJECTMGR->GetObject( pmsg->dwData ); if( !pPet ) return; pPet->LevelUp(); APPEARANCEMGR->InitAppearance( pPet ); if( pPet == HEROPET ) { HEROPET->CalcStats(); // 081112 LYW --- PetManager : 펫이 레벨업 했을경우 잘못 출력되던 // 메시지 번호를 수정함. 1647 ->1659 (정진문) CHATMGR->AddMsg(CTC_SYSMSG, CHATMGR->GetChatMsg(1659)); } TARGETSET set; set.pTarget = pPet; EFFECTMGR->StartEffectProcess(mLevelUpEffect,pPet,&set,0,pPet->GetID()); } break; case MP_PET_LEVEL_NOTIFY: { MSG_DWORDBYTE* pmsg = ( MSG_DWORDBYTE* )pMsg; CPet* pPet = ( CPet* )OBJECTMGR->GetObject( pmsg->dwData ); if( !pPet ) return; pPet->SetLevel( pmsg->bData ); APPEARANCEMGR->InitAppearance( pPet ); if( pPet == HEROPET ) { HEROPET->CalcStats(); // 081112 LYW --- PetManager ; 펫이 레벨업 했을 경우 잘못 출력되던 메시지 번호를 수정함. // 메시지 번호를 수정함. 1647 ->1659 (정진문) CHATMGR->AddMsg(CTC_SYSMSG, CHATMGR->GetChatMsg(1659)); } } break; case MP_PET_GRADEUP_NOTIFY: { MSG_DWORDBYTE2* pmsg = ( MSG_DWORDBYTE2* )pMsg; CPet* pPet = ( CPet* )OBJECTMGR->GetObject( pmsg->dwData ); if( !pPet ) return; pPet->GradeUp(); APPEARANCEMGR->InitAppearance( pPet ); if( pPet == HEROPET ) { HEROPET->SetType( ePetType(pmsg->bData1)); HEROPET->SetSkillSlot( pmsg->bData2); HEROPET->CalcStats(); CHATMGR->AddMsg(CTC_SYSMSG, CHATMGR->GetChatMsg(1576)); CItem* pItem = ITEMMGR->GetItem( HEROPET->GetItemDBIdx() ); if( pItem ) { ITEMMGR->RefreshItem( pItem ); } } TARGETSET set; set.pTarget = pPet; EFFECTMGR->StartEffectProcess(mGradeUpEffect,pPet,&set,0,pPet->GetID()); } break; case MP_PET_FRIENDLY_SYNC: { MSG_BYTE* pmsg = ( MSG_BYTE* )pMsg; HEROPET->SetFriendly( pmsg->bData ); } break; case MP_PET_RESURRECTION_ACK: { MSG_PET_INFO* pmsg = ( MSG_PET_INFO* )pMsg; PET_OBJECT_INFO* oldinfo = mPetObjectInfoTable.GetData( pmsg->PetObjectInfo.ItemDBIdx ); if( oldinfo ) { memcpy( oldinfo, &( pmsg->PetObjectInfo ), sizeof( PET_OBJECT_INFO ) ); } CItem* pItem = ITEMMGR->GetItem( pmsg->PetObjectInfo.ItemDBIdx ); if( pItem ) { ITEMMGR->RefreshItem( pItem ); } CPetResurrectionDialog* window = GAMEIN->GetPetResurrectionDlg(); if( window && window->IsActive() ) { window->SetUsedItem( NULL ); window->SetActive( FALSE ); } QUICKMGR->RefreshQickItem(); } break; case MP_PET_LIFE_NOTIFY: { MSG_INT* pmsg = ( MSG_INT* )pMsg; if( HEROPET ) HEROPET->SetLife( HEROPET->GetLife() + pmsg->nData ); } break; case MP_PET_MAXLIFE_NOTIFY: { MSG_DWORD* pmsg = ( MSG_DWORD* )pMsg; CPet* pPet = (CPet*)OBJECTMGR->GetObject( pmsg->dwObjectID ); if( pPet ) pPet->SetMaxLife( pmsg->dwData ); } break; case MP_PET_MANA_NOTIFY: { MSG_DWORD* pmsg = ( MSG_DWORD* )pMsg; if( HEROPET ) HEROPET->SetMana( pmsg->dwData ); } break; case MP_PET_MAXMANA_NOTIFY: { MSG_DWORD* pmsg = ( MSG_DWORD* )pMsg; if( HEROPET ) HEROPET->SetMaxMana( pmsg->dwData ); } break; case MP_PET_OBJECT_INFO: { MSG_PET_INFO* pmsg = ( MSG_PET_INFO* )pMsg; PET_OBJECT_INFO* oldinfo = mPetObjectInfoTable.GetData( pmsg->PetObjectInfo.ItemDBIdx ); if( oldinfo ) { memcpy( oldinfo, &( pmsg->PetObjectInfo ), sizeof( PET_OBJECT_INFO ) ); } else { PET_OBJECT_INFO* pObjectInfo = new PET_OBJECT_INFO; memcpy( pObjectInfo, &( pmsg->PetObjectInfo ), sizeof( PET_OBJECT_INFO ) ); mPetObjectInfoTable.Add( pObjectInfo, pObjectInfo->ItemDBIdx ); } ITEMMGR->RefreshItemToolTip( pmsg->PetObjectInfo.ItemDBIdx ); // 퀵슬롯이 세팅된 후에 펫 정보가 전송된다. 따라서 사망 등의 정보가 변경되려면 재호출한다 QUICKMGR->RefreshQickItem(); } break; case MP_PET_DIE_NOTIFY: { MSG_DWORD* pmsg = ( MSG_DWORD* )pMsg; PET_OBJECT_INFO* oldinfo = mPetObjectInfoTable.GetData( pmsg->dwData ); if( oldinfo ) { oldinfo->HP = 0; oldinfo->MP = 0; oldinfo->Friendly = 0; oldinfo->State = ePetState_Die; } CItem* pItem = ITEMMGR->GetItem( pmsg->dwData ); if( pItem ) { ITEMMGR->RefreshItem( pItem ); } CHATMGR->AddMsg(CTC_SYSMSG, CHATMGR->GetChatMsg(1578)); // 081112 LYW --- PetManager : 펫이 사망하였을 경우 펫 ui를 닫도록 수정함. cDialog* pDlg = GAMEIN->GetPetUIDlg() ; if( pDlg ) { pDlg->SetActive( FALSE ) ; } // 090212 NYJ - 봉인중 죽어버리면 봉인취소 CProgressDialog* pProgressDlg = ( CProgressDialog* )WINDOWMGR->GetWindowForID( PROGRESS_DIALOG ); if(pProgressDlg && pProgressDlg->GetActionType()==CProgressDialog::eActionPetSummon) { pProgressDlg->Cancel(); } QUICKMGR->RefreshQickItem(); } break; case MP_PET_ITEM_INFO: { MSG_PET_ITEM_INFO* pmsg = ( MSG_PET_ITEM_INFO* )pMsg; CPet* pPet = ( CPet* )OBJECTMGR->GetObject( pmsg->ID ); if( pPet ) { pPet->SetWearedItem( pmsg->Item ); APPEARANCEMGR->InitAppearance( pPet ); } } break; case MP_PET_ITEM_DISCARD_ACK: { MSG_BYTE2* pmsg = ( MSG_BYTE2* )pMsg; //시간 소모로 삭제 되었다면 TRUE if( pmsg->bData2 ) { CPetWearedDialog* pDlg = GAMEIN->GetPetWearedDlg(); CItem* pItem = (pDlg) ? (CItem*)pDlg->GetIconForIdx( pmsg->bData1 ) : NULL ; if( pItem ) { CHATMGR->AddMsg( CTC_CHEAT_1, CHATMGR->GetChatMsg( 1192 ), CHATMGR->GetChatMsg( 1926 ), pItem->GetItemInfo()->ItemName ); } } GAMEIN->GetPetWearedDlg()->DeleteAck( pmsg->bData1 ); } break; case MP_PET_ITEM_MOVE_PLAYER_ACK: { MSG_PET_ITEM_MOVE_SYN* pmsg = ( MSG_PET_ITEM_MOVE_SYN* )pMsg; CInventoryExDialog* pPlayerInven = GAMEIN->GetInventoryDialog(); CStorageDialog* pPlayerStorage = GAMEIN->GetStorageDialog(); CPetWearedDialog* pPetInven = GAMEIN->GetPetWearedDlg(); CItem* pPlayerItem = NULL; const eITEMTABLE TableIdx = ITEMMGR->GetTableIdxForAbsPos( pmsg->PlayerPos ); if( TableIdx == eItemTable_Storage) { pPlayerStorage->DeleteItem( pmsg->PlayerPos, &pPlayerItem ); } else if( TableIdx == eItemTable_Inventory ) { pPlayerInven->DeleteItem( pmsg->PlayerPos, &pPlayerItem ); } else return; cIcon* pIcon = NULL; CItem* pPetItem = NULL; pPetInven->DeleteItem( pmsg->PetPos, &pIcon ); pPetItem = ( CItem* )pIcon; if( pPlayerItem ) { pPlayerItem->SetPosition( pmsg->PetPos ); pPetInven->AddItem( pmsg->PetPos, pPlayerItem ); } if( pPetItem ) { pPetItem->SetPosition( pmsg->PlayerPos ); if( TableIdx == eItemTable_Storage) { pPlayerStorage->AddItem( pPetItem ); } else if( TableIdx == eItemTable_Inventory ) { pPlayerInven->AddItem( pPetItem ); } else return; } } break; case MP_PET_ITEM_MOVE_PLAYER_NACK: { MSG_WORD* msg = (MSG_WORD*)pMsg; switch(msg->wData) { case 1: CHATMGR->AddMsg(CTC_SYSMSG, CHATMGR->GetChatMsg(1739)); break; } } break; // 090625 pdy 펫 기간제 아이템 착용처리 추가 case MP_PET_ITEM_TIMELIMT_ONEMINUTE_FROM_PETINVEN: { MSG_DWORD2* pmsg = (MSG_DWORD2*)pMsg ; ITEM_INFO* pItemInfo = NULL ; pItemInfo = ITEMMGR->GetItemInfo( pmsg->dwData1 ) ; if( !pItemInfo ) return ; POSTYPE pos = (POSTYPE)pmsg->dwData2 ; CPetWearedDialog* pDlg = GAMEIN->GetPetWearedDlg(); CItem* pItem= (pDlg) ? (CItem*)pDlg->GetIconForIdx(pos) : NULL ; const ITEMBASE* pItemBase = (pItem) ? &pItem->GetItemBaseInfo() : NULL ; if( pItemBase ) { CItem* pItem = NULL ; pItem = ITEMMGR->GetItem( pItemBase->dwDBIdx ) ; if( pItem ) { pItem->SetItemBaseInfo( *pItemBase ) ; pItem->SetLastCheckTime(gCurTime) ; pItem->SetRemainTime( 50 ) ; } } CHATMGR->AddMsg( CTC_CHEAT_1, CHATMGR->GetChatMsg( 1191 ), CHATMGR->GetChatMsg( 1926 ), pItemInfo->ItemName ) ; } break; case MP_PET_LIFE_BROAD: { const MSG_INT* const msg = (MSG_INT*)pMsg; CPet* pPet = (CPet*)OBJECTMGR->GetObject( msg->dwObjectID ); if( pPet ) { DWORD dwNewLife = pPet->GetLife() + msg->nData; pPet->SetLife( dwNewLife ); } } break; } }
void CApp::Combine() { int srcPanelIndex = GetFocusedPanelIndex(); CPanel &srcPanel = Panels[srcPanelIndex]; if (!srcPanel.IsFSFolder()) { srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); return; } CRecordVector<UInt32> indices; srcPanel.GetOperatedItemIndices(indices); if (indices.IsEmpty()) return; int index = indices[0]; if (indices.Size() != 1 || srcPanel.IsItemFolder(index)) { srcPanel.MessageBox(LangString(IDS_COMBINE_SELECT_ONE_FILE, 0x03020620)); return; } const UString itemName = srcPanel.GetItemName(index); UString srcPath = srcPanel._currentFolderPrefix + srcPanel.GetItemPrefix(index); UString path = srcPath; int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex); CPanel &destPanel = Panels[destPanelIndex]; if (NumPanels > 1) if (destPanel.IsFSFolder()) path = destPanel._currentFolderPrefix; CCopyDialog copyDialog; copyDialog.Value = path; copyDialog.Title = LangString(IDS_COMBINE, 0x03020600); copyDialog.Title += ' '; copyDialog.Title += srcPanel.GetItemRelPath(index); copyDialog.Static = LangString(IDS_COMBINE_TO, 0x03020601);; if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL) return; CThreadCombine combiner; // combiner.Panel = this; { CProgressDialog progressDialog; combiner.ProgressDialog = &progressDialog; UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000); UString title = LangString(IDS_COMBINING, 0x03020610); progressDialog.MainWindow = _window; progressDialog.MainTitle = progressWindowTitle; progressDialog.MainAddTitle = title + UString(L" "); path = copyDialog.Value; NFile::NName::NormalizeDirPathPrefix(path); if (!NFile::NDirectory::CreateComplexDirectory(path)) { srcPanel.MessageBoxMyError(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, 0x02000603, path)); return; } combiner.InputDirPrefix = srcPath; combiner.FirstVolumeName = itemName; combiner.OutputDirPrefix = path; // CPanel::CDisableTimerProcessing disableTimerProcessing1(srcPanel); // CPanel::CDisableTimerProcessing disableTimerProcessing2(destPanel); NWindows::CThread thread; if (thread.Create(CThreadCombine::MyThreadFunction, &combiner) != S_OK) throw 271824; progressDialog.Create(title, _window); } RefreshTitleAlways(); if (!combiner.Error.IsEmpty()) srcPanel.MessageBoxMyError(combiner.Error); // disableTimerProcessing1.Restore(); // disableTimerProcessing2.Restore(); // srcPanel.SetFocusToList(); // srcPanel.RefreshListCtrlSaveFocused(); }
void Process2() { // NCOM::CComInitializer comInitializer; ProgressDialog->WaitCreating(); CVolSeqName volSeqName; if (!volSeqName.ParseName(FirstVolumeName)) throw L"Can not detect file as splitted file"; UString nextName = InputDirPrefix + FirstVolumeName; UInt64 totalSize = 0; for (;;) { NFile::NFind::CFileInfoW fileInfo; if (!NFile::NFind::FindFile(nextName, fileInfo)) break; if (fileInfo.IsDirectory()) break; totalSize += fileInfo.Size; nextName = InputDirPrefix + volSeqName.GetNextName(); } if (totalSize == 0) throw L"no data"; ProgressDialog->ProgressSynch.SetProgress(totalSize, 0); if (!volSeqName.ParseName(FirstVolumeName)) throw L"Can not detect file as splitted file"; UString outName = volSeqName.UnchangedPart; while(!outName.IsEmpty()) { int lastIndex = outName.Length() - 1; if (outName[lastIndex] != L'.') break; outName.Delete(lastIndex); } if (outName.IsEmpty()) outName = L"file"; NFile::NIO::COutFile outFile; if (!outFile.Create(OutputDirPrefix + outName, false)) throw L"Can create open output file"; NFile::NIO::CInFile inFile; CMyBuffer bufferObject; if (!bufferObject.Allocate(kBufSize)) throw L"Can not allocate buffer"; Byte *buffer = (Byte *)(void *)bufferObject; UInt64 pos = 0; nextName = InputDirPrefix + FirstVolumeName; bool needOpen = true; for (;;) { if (needOpen) { NFile::NFind::CFileInfoW fileInfo; if (!NFile::NFind::FindFile(nextName, fileInfo)) break; if (fileInfo.IsDirectory()) break; if (!inFile.Open(nextName)) throw L"Can not open file"; ProgressDialog->ProgressSynch.SetCurrentFileName(fileInfo.Name); nextName = InputDirPrefix + volSeqName.GetNextName(); needOpen = false; } UInt32 processedSize; if (!inFile.Read(buffer, kBufSize, processedSize)) throw L"Can not read input file"; if (processedSize == 0) { needOpen = true; continue; } UInt32 needSize = processedSize; if (!outFile.Write(buffer, needSize, processedSize)) throw L"Can not write output file"; if (needSize != processedSize) throw L"Can not write output file"; pos += processedSize; HRESULT res = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(pos); if (res != S_OK) return; } }
void CApp::Split() { int srcPanelIndex = GetFocusedPanelIndex(); CPanel &srcPanel = Panels[srcPanelIndex]; if (!srcPanel.IsFSFolder()) { srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); return; } CRecordVector<UInt32> indices; srcPanel.GetOperatedItemIndices(indices); if (indices.IsEmpty()) return; if (indices.Size() != 1) { srcPanel.MessageBox(L"Select one file"); return; } int index = indices[0]; if (srcPanel.IsItemFolder(index)) { srcPanel.MessageBox(L"Select one file"); return; } const UString itemName = srcPanel.GetItemName(index); UString srcPath = srcPanel._currentFolderPrefix + srcPanel.GetItemPrefix(index); UString path = srcPath; int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex); CPanel &destPanel = Panels[destPanelIndex]; if (NumPanels > 1) if (destPanel.IsFSFolder()) path = destPanel._currentFolderPrefix; CSplitDialog splitDialog; splitDialog.FilePath = srcPanel.GetItemRelPath(index); splitDialog.Path = path; if (splitDialog.Create(srcPanel.GetParent()) == IDCANCEL) return; NFile::NFind::CFileInfoW fileInfo; if (!NFile::NFind::FindFile(srcPath + itemName, fileInfo)) { srcPanel.MessageBoxMyError(L"Can not find file"); return; } if (fileInfo.Size <= splitDialog.VolumeSizes.Front()) { srcPanel.MessageBoxMyError(LangString(IDS_SPLIT_VOL_MUST_BE_SMALLER, 0x03020522)); return; } const UInt64 numVolumes = GetNumberOfVolumes(fileInfo.Size, splitDialog.VolumeSizes); if (numVolumes >= 100) { wchar_t s[32]; ConvertUInt64ToString(numVolumes, s); if (::MessageBoxW(srcPanel, MyFormatNew(IDS_SPLIT_CONFIRM_MESSAGE, 0x03020521, s), LangString(IDS_SPLIT_CONFIRM_TITLE, 0x03020520), MB_YESNOCANCEL | MB_ICONQUESTION | MB_TASKMODAL) != IDYES) return; } path = splitDialog.Path; NFile::NName::NormalizeDirPathPrefix(path); if (!NFile::NDirectory::CreateComplexDirectory(path)) { srcPanel.MessageBoxMyError(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, 0x02000603, path)); return; } CThreadSplit spliter; // spliter.Panel = this; { CProgressDialog progressDialog; spliter.ProgressDialog = &progressDialog; UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000); UString title = LangString(IDS_SPLITTING, 0x03020510); progressDialog.MainWindow = _window; progressDialog.MainTitle = progressWindowTitle; progressDialog.MainAddTitle = title + UString(L" "); progressDialog.ProgressSynch.SetTitleFileName(itemName); spliter.FilePath = srcPath + itemName; spliter.VolBasePath = path + itemName; spliter.VolumeSizes = splitDialog.VolumeSizes; // if (splitDialog.VolumeSizes.Size() == 0) return; // CPanel::CDisableTimerProcessing disableTimerProcessing1(srcPanel); // CPanel::CDisableTimerProcessing disableTimerProcessing2(destPanel); NWindows::CThread thread; if (thread.Create(CThreadSplit::MyThreadFunction, &spliter) != S_OK) throw 271824; progressDialog.Create(title, _window); } RefreshTitleAlways(); if (!spliter.Error.IsEmpty()) srcPanel.MessageBoxMyError(spliter.Error); // disableTimerProcessing1.Restore(); // disableTimerProcessing2.Restore(); // srcPanel.SetFocusToList(); // srcPanel.RefreshListCtrlSaveFocused(); }
void Process2() { // NCOM::CComInitializer comInitializer; ProgressDialog->WaitCreating(); NFile::NIO::CInFile inFile; if (!inFile.Open(FilePath)) throw L"Can not open file"; NFile::NIO::COutFile outFile; CMyBuffer bufferObject; if (!bufferObject.Allocate(kBufSize)) throw L"Can not allocate buffer"; Byte *buffer = (Byte *)(void *)bufferObject; UInt64 curVolSize = 0; CVolSeqName seqName; UInt64 length; if (!inFile.GetLength(length)) throw "error"; ProgressDialog->ProgressSynch.SetProgress(length, 0); UInt64 pos = 0; int volIndex = 0; for (;;) { UInt64 volSize; if (volIndex < VolumeSizes.Size()) volSize = VolumeSizes[volIndex]; else volSize = VolumeSizes.Back(); UInt32 needSize = (UInt32)(MyMin((UInt64)kBufSize, volSize - curVolSize)); UInt32 processedSize; if (!inFile.Read(buffer, needSize, processedSize)) throw L"Can not read input file"; if (processedSize == 0) break; needSize = processedSize; if (curVolSize == 0) { UString name = VolBasePath; name += L"."; name += seqName.GetNextName(); if (!outFile.Create(name, false)) throw L"Can not create output file"; ProgressDialog->ProgressSynch.SetCurrentFileName(name); } if (!outFile.Write(buffer, needSize, processedSize)) throw L"Can not write output file"; if (needSize != processedSize) throw L"Can not write output file"; curVolSize += processedSize; if (curVolSize == volSize) { outFile.Close(); if (volIndex < VolumeSizes.Size()) volIndex++; curVolSize = 0; } pos += processedSize; HRESULT res = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(pos); if (res != S_OK) return; } }