Beispiel #1
0
 void InitializeGameProcess::Main()
 {
     FILE* fp = fopen("GameData.dat","rb");
     
     if(fp)
     {
         fseek(fp,0,SEEK_END);
         size_t sz = ftell(fp);
         fseek(fp,0,SEEK_SET);
         
         SetTaskName(FormatString("Reading %lu bytes (1/2)",sz));
         
         ByteStream* Data = new ByteStream();
         for(i32 i = 0;i < sz;i++)
         {
             Data->WriteByte(getc(fp));
             SetProgress(((Scalar)i) / ((Scalar)sz));
         }
         fclose(fp);
         
         SetTaskName("Deserializing data (2/2)");
         SetProgress(0.0f);
     }
     
     m_Completed = true;
 }
Beispiel #2
0
int removePath(char *path, uint32_t *value, uint32_t max, void (* SetProgress)(uint32_t value, uint32_t max)) {
	SceUID dfd = sceIoDopen(path);
	if (dfd >= 0) {
		int res = 0;

		do {
			SceIoDirent dir;
			memset(&dir, 0, sizeof(SceIoDirent));

			res = sceIoDread(dfd, &dir);
			if (res > 0) {
				if (strcmp(dir.d_name, ".") == 0 || strcmp(dir.d_name, "..") == 0)
					continue;

				char *new_path = malloc(strlen(path) + strlen(dir.d_name) + 2);
				snprintf(new_path, MAX_PATH_LENGTH, "%s/%s", path, dir.d_name);

				if (SCE_S_ISDIR(dir.d_stat.st_mode)) {
					removePath(new_path, value, max, SetProgress);
				} else {
					sceIoRemove(new_path);

					if (value)
						(*value)++;

					if (SetProgress)
						SetProgress(value ? *value : 0, max);
				}

				free(new_path);
			}
		} while (res > 0);

		sceIoDclose(dfd);

		int ret = sceIoRmdir(path);
		if (ret < 0)
			return ret;

		if (value)
			(*value)++;

		if (SetProgress)
			SetProgress(value ? *value : 0, max);
	} else {
		int ret = sceIoRemove(path);
		if (ret < 0)
			return ret;

		if (value)
			(*value)++;

		if (SetProgress)
			SetProgress(value ? *value : 0, max);
	}

	return 0;
}
void
BF_GUI_FilesPanel_Task::RenameNodes(
    const BF_NodeCollection & lo_Node,
    const BF_FilesPath & o_SrcPath,
    const BL_String &s_NewName)
{
    BF_Node 	*poNode=NULL;
    BL_String 	s;
    const char  *pcNewName = NULL;
    BL_String 	sAfterMask;


    // check drive for read_only //
    if(o_SrcPath.IsVolumeReadOnly()) {
        Ask_Error(BF_DictAt(BF_DICT_TASKS_READONLYVOL),false);
        return;
    }


    // check mask
    if(s_NewName.FindFirst("*")<0)
    {   // has not mask_chars
        // check count
        if(lo_Node.CountItems()>1) {
            Ask_Error(BF_DictAt(BF_DICT_TASKS_ONENAMEMANYFILES),false,s_NewName.String());
            return;
        }
    }

    SetProgress(0,lo_Node.CountItems());

    for(int i=0; i<lo_Node.CountItems(); i++) {
        poNode = lo_Node.NodeAt(i);

        pcNewName = s_NewName.String();

        if(poNode->ConvertNameByMask(s_NewName,sAfterMask)) {
            pcNewName = sAfterMask.String();
        }

        ASSERT(pcNewName);

        status_t uRes = BF_Roster_RenameNode(o_SrcPath,poNode,pcNewName);
        if(uRes!=B_OK) {
            BL_String s;
            BL_System_TranslError(uRes,s);
            if(BF_GUI_OPERTASK_ERROR_OK!=Ask_Error(s.String())) return;
        }

        SetProgress(i,lo_Node.CountItems());
        if(Canceled()) return;
    }
}
Beispiel #4
0
LRESULT CSplashDlg::OnSplashProgress(WPARAM wParam, LPARAM lParam)
{
	// set message and enable buttons
	SetProgress( wParam );

	return 1;
}
Beispiel #5
0
CDuiSlider::CDuiSlider(HWND hWnd, CDuiObject* pDuiObject, UINT uControlID, CRect rc, int nProgress/* = 0*/, 
					 BOOL bIsVisible/* = TRUE*/, BOOL bIsDisable/* = FALSE*/)
	: CControlBaseFont(hWnd, pDuiObject, uControlID, rc, TEXT(""), bIsVisible, bIsDisable)
{
	m_bHover = false;
	m_enButtonState = enBSNormal;

	m_bRunTime = false;
	m_nMaxProgress = 100;

	SetBitmapCount(2);

	m_pImageBackGround = NULL;
	m_sizeBackGround = CSize(0, 0);
	m_pImageForeGround = NULL;
	m_sizeForeGround = CSize(0, 0);
	m_pImageThumb = NULL;
	m_sizeThumb = CSize(0, 0);
	m_nSliderHeight = 0;
	m_nThumbWidth = 0;
	m_nThumbHeight = 0;
	m_nThumbTop = 0;
	m_nHeadLength = 0;
	m_rcThumb = CRect(0, 0, 0, 0);

	m_clrText = Color(254, 128, 128, 128);
	m_uAlignment = Align_Center;
	m_uVAlignment = VAlign_Middle;
	m_bShowText = FALSE;

	m_nProgress = 0;
	SetProgress(nProgress);
}
void InterfOptimizGpGpu::Prepare(uint x, uint y, ushort penteMax, ushort NBDir,float zReg,float zRegQuad, ushort costDefMask,ushort costDefMaskTrans, bool hasMaskAuto)
{
    uint size = (uint)(1.5f*sqrt((float)x *x + y * y));

    _H_data2Opt.setDzMax(_poInitCost._maxDz);
    _D_data2Opt.setDzMax(_poInitCost._maxDz);

    ResetIdBuffer();
    SetPreComp(true);

    SetProgress(NBDir);

    _H_data2Opt.ReallocParam(size);
    _D_data2Opt.ReallocParam(size);    
    _D_data2Opt.setPenteMax(penteMax);
    _D_data2Opt.setZReg(zReg);
    _D_data2Opt.setZRegQuad(zRegQuad);
    _D_data2Opt.setCostDefMasked(costDefMask);
    _D_data2Opt.setCostTransMaskNoMask(costDefMaskTrans);
    _D_data2Opt.setHasMaskAuto(hasMaskAuto);

    _FinalDefCor.Fill(0);
    _preFinalCost1D.Fill(0);

}
Beispiel #7
0
CDuiSlider::CDuiSlider(HWND hWnd, CDuiObject* pDuiObject)
	: CControlBaseFont(hWnd, pDuiObject)
{
	m_bHover = false;
	m_enButtonState = enBSNormal;

	m_bRunTime = false;
	m_nMaxProgress = 100;

	SetBitmapCount(2);

	m_pImageBackGround = NULL;
	m_sizeBackGround = CSize(0, 0);
	m_pImageForeGround = NULL;
	m_sizeForeGround = CSize(0, 0);
	m_pImageThumb = NULL;
	m_sizeThumb = CSize(0, 0);
	m_nSliderHeight = 0;
	m_nThumbWidth = 0;
	m_nThumbHeight = 0;
	m_nThumbTop = 0;
	m_nHeadLength = 0;
	m_rcThumb = CRect(0, 0, 0, 0);

	m_clrText = Color(254, 128, 128, 128);
	m_uAlignment = Align_Center;
	m_uVAlignment = VAlign_Middle;
	m_bShowText = FALSE;

	m_nProgress = 0;
	SetProgress(0);
}
BOOL CUserProgressDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	PrgAPI* pAPI = PRGAPI();

	SetWindowText(pAPI->GetString(IDS_WORKING));

	m_header.SetTitleFont(pAPI->GetFont(FONT_DialogsBigBold));
	m_header.SetDescFont(pAPI->GetFont(FONT_Dialogs));
	m_header.SetIconSize(32, 32);
	m_header.SetDraggable(FALSE);

	m_header.SetTitleText(m_title);
	m_header.SetIconHandle(m_icon);
	m_header.SetDescText(m_message);

	m_header.Init(this);
	m_header.MoveCtrls(this);

	m_progress.SetRange(0, 1000);
	SetProgress(m_progressValue);
	SetIcon(m_icon);
	SetTitle(m_title);//Default

	CenterWindow();

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
Beispiel #9
0
void ProgressBar::SetMaximumProgress(unsigned maximum_progress)
{
    _maximum_progress = maximum_progress;

    // Reset the progress incase the maximum progress is now less than the progress.
    SetProgress(_progress);
}
Beispiel #10
0
	VOID ExportConsoleDialog::StartNewTask( const CHAR* strCaption, FLOAT fTaskPercentOfWhole )
	{
		SetCaption( strCaption );
		m_fCurrentTaskMin += m_fCurrentTaskSize;
		m_fCurrentTaskSize = fTaskPercentOfWhole;
		SetProgress( 0 );
	}
bool
BF_GUI_FilesPanel_DeleteTask::DeleteList(BF_NodeCollection & lo_Node)
{
    BF_Node  	*poNode;
    status_t	uRes;
    BL_String   s;

    for(int i=0; i<lo_Node.CountItems(); i++) {
        poNode = (BF_Node*)lo_Node.ItemAt(i);

        if(poNode->iType==BF_NODE_TYPE_DIR) {
            // check folder_path+name //
            ASSERT(lo_Node.poPath);
            s = lo_Node.poPath->Path();
            s << "/";
            s << poNode->sName;
            if(!CheckFolder_ForSys(s.String())) {
                return false;
            }
        }

        if(poNode->ploChild) {
            DeleteList(*poNode->ploChild);
        }
        // check, remove file or move it to trash
        if(BF_FILESPANEL_DELETE_TO_VOID==iDeleteType) {
            BF_Roster_RemoveNode(*lo_Node.poPath,poNode);
        } else if(BF_FILESPANEL_DELETE_TO_TRASH==iDeleteType) {
            int64		iIndex = 1;
            char		*pcName=NULL;
            while(TRUE) {
                uRes = BF_Roster_MoveNode(*lo_Node.poPath,poNode,sTrashPath.String(),pcName);
                if(B_OK==uRes) break;
                /* try to move to new name */
                if(B_FILE_EXISTS==uRes) {
                    s=poNode->sName;
                    s<<" ";
                    s<<iIndex++;
                    pcName = (char*)s.String();
                    continue;
                }
                /* ups....some error */
                BL_System_TranslError(uRes,s);

                BL_List	*ploMenu = new BL_List();
                ploMenu->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_TRYAGAIN),"try"));
                ploMenu->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_SKIP),"skip"));

                if(1==Ask_Message(s.String(),ploMenu)) break;
            }
        }
        //
        SetProgress(++iOperIndex,iOperCount);
        /* check for cancel_process */
        if(Canceled()) return false;

    }
    return true;
}
void
BF_GUI_FilesPanel_CopyTask::Move_Nodes()
{
    iOperCount = loNode.CountItems();
    SetProgress(iOperIndex,iOperCount);

    BF_Node  	*poNode=NULL;
    status_t	uRes=B_ERROR;


    for(int i=0; i<loNode.CountItems(); i++) {
        poNode = loNode.NodeAt(i);
        while(true) {
            uRes = BF_Roster_MoveNode(oPathSrc,poNode,oPathDest.Path());
            if(uRes==B_OK) break;
            if(B_FILE_EXISTS == uRes) {
                BL_String s(BF_DictAt(BF_DICT_TASKS_DESTFILE));
                s<<poNode->sName;
                s<<BF_DictAt(BF_DICT_TASKS_DESTFILEEXIST);
                BL_List *ploMenu= new BL_List();
                ploMenu->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_OWERWRITE),"") );
                ploMenu->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_SKIP),"") );
                ploMenu->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_CANCELALL),"") );
                int iRes = Ask_Message(s.String(),ploMenu);
                if(iRes==0) {
                    // delete dest_file //
                    BF_Roster_RemoveNode(oPathDest,poNode->sName.String());
                    continue;
                } else if(iRes==2) {
                    // cancel all //
                    i = loNode.CountItems()+1;
                }
            } else {
                BL_String s(BF_DictAt(BF_DICT_TASKS_CANTMOVE)),s1;
                BL_System_TranslError(uRes,s1);
                s<<poNode->sName;
                if(BF_GUI_OPERTASK_ERROR_CANCEL_ALL==Ask_Error(s.String(),true,s1.String()) ) {
                    // cancel all //
                    i = loNode.CountItems()+1;
                }
            }
            break;
        }
        SetProgress(++iOperIndex,iOperCount);
    }
}
void CMediaWin::Stop()
{
	ChangeBtnStatus(true);
	thePlayer->Stop();
	SetTimeText(_T(""));
	SetProgress(0,false);
	_ui.m_pTitle->SetText(_T("逸听视频播放"));
}
Beispiel #14
0
bool CProgressJob::ShouldCancel(unsigned int progress, unsigned int total) const
{
  if (IsCancelled())
    return true;

  SetProgress(progress, total);

  return CJob::ShouldCancel(progress, total);
}
Beispiel #15
0
//=================================================================================================
bool Quest_Orcs2::HandleLocationEvent(LocationEventHandler::Event event)
{
	if(event == LocationEventHandler::CLEARED && prog == Progress::TalkedWhereIsCamp)
	{
		SetProgress(Progress::ClearedCamp);
		return true;
	}
	return false;
}
Beispiel #16
0
void CProgressJob::SetProgress(int currentStep, int totalSteps) const
{
  if (!m_updateProgress)
    return;

  if (m_progress != NULL)
    m_progress->SetProgress(currentStep, totalSteps);
  else if (m_progressDialog != NULL)
    SetProgress((static_cast<float>(currentStep) * 100.0f) / totalSteps);
}
void CCMatchShutdown::OnRun(unsigned long nClock)
{
	if (IsShutdown() == false) return;

	int nIndex = GetProgressIndex();
	if (nIndex < (int)m_ShutdownNotifyArray.size())
	{
		MShutdownNotify* pNotify = m_ShutdownNotifyArray[nIndex];
		if (nClock - GetTimeLastProgress() < pNotify->GetDelay())
			return;
		Notify(nIndex);
		SetProgress(nIndex+1, nClock);
	}
	else if (nIndex == m_ShutdownNotifyArray.size())
	{
		Terminate();
		SetProgress(nIndex+1, nClock);
	}
}
Beispiel #18
0
bool ProgressBar::Create(wxWindow* parent, wxWindowID id, long style, const wxString& name)
{
	bool res = wxStatusBar::Create(parent, id, style, name);
	if (res) {
		m_progress.Create(this, wxID_ANY, 1000, wxPoint(0, 0), wxDefaultSize, wxGA_HORIZONTAL | wxGA_SMOOTH);
		SetProgress(0);
		Resize();
	}
	return res;
}
Beispiel #19
0
//=================================================================================================
void Quest_Orcs2::HandleUnitEvent(UnitEventHandler::TYPE event, Unit* unit)
{
	assert(unit);

	if(event == UnitEventHandler::DIE && prog == Progress::TalkedWhereIsBase)
	{
		SetProgress(Progress::KilledBoss);
		unit->event_handler = nullptr;
	}
}
Beispiel #20
0
void Task::OnTaskEnd()
{
	if (endCalled)
		return;
	endCalled = true;
	SetProgress(100);
	
	TaskEvent event(wxEVT_TASK_END, this);
	m_evtHandler->AddPendingEvent(event);
}
Beispiel #21
0
//=================================================================================================
bool Quest_Orcs::HandleLocationEvent(LocationEventHandler::Event event)
{
	if(event == LocationEventHandler::CLEARED && prog == Progress::Started)
	{
		levels_cleared |= (1 << L.dungeon_level);
		if(CountBits(levels_cleared) == dungeon_levels)
			SetProgress(Progress::ClearedLocation);
	}
	return false;
}
Beispiel #22
0
//=================================================================================================
void Quest_Goblins::HandleUnitEvent(UnitEventHandler::TYPE event, Unit* unit)
{
	assert(unit);

	if(event == UnitEventHandler::DIE && prog == Progress::TalkedWithInnkeeper)
	{
		SetProgress(Progress::KilledBoss);
		unit->event_handler = nullptr;
	}
}
Beispiel #23
0
void
BitmapImage::PixmapComplete ()
{
	MoonPixbuf *pixbuf;
	
	SetProgress (1.0);

	if (!loader) {
		if (!moon_error)
			moon_error = new MoonError (MoonError::EXCEPTION, 4001, "no loader");
		goto failed;
	}

	loader->Close (moon_error == NULL ? &moon_error : NULL);

	if (moon_error)
		goto failed;

	if (!(pixbuf = loader->GetPixbuf ())) {
		moon_error = new MoonError (MoonError::EXCEPTION, 4001, "failed to create image data");
		goto failed;
	}
	
	SetPixelWidth (pixbuf->GetWidth ());
	SetPixelHeight (pixbuf->GetHeight ());
	
	// PixelFormat has been dropped and only Pbgra32 is supported
	// http://blogs.msdn.com/silverlight_sdk/archive/2009/07/01/breaking-changes-document-errata-silverlight-3.aspx
	// not clear if '3' channel is still supported (converted to 4) in SL3
	if (pixbuf->GetNumChannels () == 4) {
		SetBitmapData (premultiply_rgba (pixbuf), true);
	} else {
		SetBitmapData (expand_rgb_to_argb (pixbuf), true);
	}
	
	Invalidate ();
	
	delete loader;
	loader = NULL;
	
	if (HasHandlers (ImageOpenedEvent))
		Emit (ImageOpenedEvent, new RoutedEventArgs ());
	
	return;
	
failed:
	ImageErrorEventArgs *args = NULL;

	if (HasHandlers (ImageFailedEvent))
		args = new ImageErrorEventArgs (*moon_error);
	CleanupLoader ();
	if (args)
		Emit (ImageFailedEvent, args);
}
Beispiel #24
0
void InstallerWindow::OnExecBegin()
{
	SetProgress(m_recorded_progress + 1);

	SetControlValues();

	InstallConfiguration * p_configuration = reinterpret_cast<InstallConfiguration *>(get(m_configuration));
	CHECK_BOOL(p_configuration != NULL, L"Invalid configuration");

    ExtractCab(L"", p_configuration->show_cab_dialog);		
}
ECode RatingBar::SetStepSize(
    /* [in] */ Float stepSize)
{
    if (stepSize <= 0) {
        return NOERROR;
    }
    Float newMax = mNumStars / stepSize;
    Int32 newProgress = (Int32)(newMax / GetMax() * GetProgress());
    SetMax((Int32)newMax);
    SetProgress(newProgress);
    return NOERROR;
}
void								
BF_GUI_FtpPanel_DeleteTask::Run()
{
	iOperIndex  = 0;
	iOperCount = loNode.CountAll(true);	
	SetProgress(iOperIndex,iOperCount);
	Delete_List(&loNode);	
	
	// reload panel_nodes 
	BMessenger 	oMessenger(poPanel);
	BMessage	oMessage(BF_FTP_MSG_DIR_RELOAD_START);
	oMessenger.SendMessage(&oMessage);
}
void
BF_GUI_FilesPanel_ChangeCaseTask::Run()
{
    // check drive for read_only //
    if(oPath.IsVolumeReadOnly()) {
        Ask_Error(BF_DictAt(BF_DICT_TASKS_READONLYVOL),false);
        return;
    }

    BF_Node *poNode=NULL;
    BL_String s;

    SetProgress(iOperIndex,iOperCount);

    for(int i=0; i<loNode.CountItems(); i++) {
        poNode = loNode.NodeAt(i);
        s = poNode->sName;
        switch(iCaseType) {
        case 0:
            s.ToLower();
            break;
        case 1:
            s.ToUpper();
            break;
        case 2:
            s.Capitalize();
            break;
        case 3:
            s.CapitalizeEachWord();
            break;
        }
        BF_Roster_RenameNode(oPath,poNode,s.String());
        SetProgress(++iOperIndex,iOperCount);
        if(Canceled()) return;
    }
}
Beispiel #28
0
bool InstallerWindow::RunDownloadConfiguration(const DownloadDialogPtr& p_Configuration)
{
	if (! p_Configuration->IsRequired())
	{
		LOG(L"*** Component '" << p_Configuration->component_id << L"': SKIPPING DOWNLOAD/COPY");
		return true;
	}

	m_downloaddialog = p_Configuration;
	p_Configuration->callback = this;

	html_save_progress progress_saved(& progress, m_recorded_progress, m_total_progress);
	SetProgress(0);
	return 0 == p_Configuration->ExecOnThread();
}
Beispiel #29
0
OCStackResult StartProvisioningProcess(const EnrolleeNWProvInfo_t *netInfo,
                                       OCProvisioningStatusCB provisioningStatusCallback,
                                       char *findResQuery) {

    if(findResQuery != NULL)
    {
        OICStrcpy(szFindResourceQueryUri, sizeof(szFindResourceQueryUri) - 1, findResQuery);
    }
    else
    {
        OIC_LOG(ERROR, ES_PROV_TAG, PCF("Find resource query is NULL"));
        goto Error;
    }

    pthread_t thread_handle;

    if (!ValidateEasySetupParams(netInfo, provisioningStatusCallback)) {
        goto Error;
    }

    if (!SetProgress(provisioningStatusCallback)) {
        // Device provisioning session is running already.
        OIC_LOG(INFO, ES_PROV_TAG, PCF("Device provisioning session is running already"));
        goto Error;
    }

    if (!ConfigEnrolleeObject(netInfo)) {
        goto Error;
    }

    if (pthread_create(&thread_handle, NULL, FindProvisioningResource, NULL)) {
        goto Error;

    }

    pthread_join(thread_handle, NULL);


    return OC_STACK_OK;

    Error:
    {
        ErrorCallback(DEVICE_NOT_PROVISIONED);
        ClearMemory();
        return OC_STACK_ERROR;
    }

}
void								
BF_GUI_FtpPanel_DeleteTask::Delete_List(BF_NodeCollection *plo_Node)
{
	ASSERT(plo_Node);
	
	BF_Node *poNode;
	for(int i=0;i<plo_Node->CountItems();i++){
		poNode = plo_Node->NodeAt(i);
		switch(poNode->iType){
		case BF_NODE_TYPE_FILE:
			Delete_File(poNode);
			break;
		}
		SetProgress(++iOperIndex,iOperCount);		
	}
}