Пример #1
0
void UpdateDlg::OnProgress(wxCommandEvent& event)
{
    int prg = -1;
    if (m_CurrFileSize != 0)
        prg = event.GetInt() * 100 / m_CurrFileSize;
    UpdateStatus(_("Downloading: ") + event.GetString(), prg);

    wxStaticText* lbl = XRCCTRL(*this, "lblProgress", wxStaticText);

    wxString msg;
    msg.Printf(_("%s of %s"), GetSizeString(event.GetInt()).c_str(), GetSizeString(m_CurrFileSize).c_str());
    lbl->SetLabel(msg);
}
/////////////////////////////////////////////////////////////////////////////
// CFeedbackNotEnoughSpaceDlg message handlers
void CFeedbackNotEnoughSpaceDlg::UpdateDialog()
{
	// format needed text
	ictranslate::CFormat fmt(GetResManager().LoadString(IDS_NERPATH_STRING));
	fmt.SetParam(_t("%path"), m_strDisk);

	CWnd* pWnd=GetDlgItem(IDC_HEADER_STATIC);
	if (pWnd)
		pWnd->SetWindowText(fmt);

	// now the sizes
	TCHAR szData[128];
	pWnd=GetDlgItem(IDC_REQUIRED_STATIC);
	if (pWnd)
		pWnd->SetWindowText(GetSizeString(m_ullRequired, szData, 128));
	ull_t ullFree;
	pWnd=GetDlgItem(IDC_AVAILABLE_STATIC);
	if (pWnd && GetDynamicFreeSpace(m_strDisk, &ullFree, NULL))
		pWnd->SetWindowText(GetSizeString(ullFree, szData, 128));
}
void CFeedbackNotEnoughSpaceDlg::OnTimer(UINT_PTR nIDEvent) 
{
	if (nIDEvent == 1601)
	{
		// update free space
		ull_t ullFree;
		CWnd *pWnd=GetDlgItem(IDC_AVAILABLE_STATIC);
		if (pWnd && GetDynamicFreeSpace(m_strDisk, &ullFree, NULL))
		{
			TCHAR szData[128];
			pWnd->SetWindowText(GetSizeString(ullFree, szData, 128));

			// end dialog if this is enough
			if (m_ullRequired <= ullFree)
			{
				CLanguageDialog::OnTimer(nIDEvent);
				EndDialog(ID_RETRY);
			}
		}
	}
	
	CLanguageDialog::OnTimer(nIDEvent);
}
Пример #4
0
UpdateRec* ReadConf(const IniParser& ini, int* recCount, const wxString& currentServer, const wxString& appPath)
{
    *recCount = 0;
    int groupsCount = ini.GetGroupsCount();
    if (groupsCount == 0)
        return 0;

    UpdateRec* list = new UpdateRec[ini.GetGroupsCount()];
    for (int i = 0; i < groupsCount; ++i)
    {
        UpdateRec& rec = list[i];

        rec.title = ini.GetGroupName(i);

        // fix title
        // devpaks.org has changed the title to contain some extra info
        // e.g.: [libunicows   Library version: 1.1.1   Devpak revision: 1sid]
        int pos = rec.title.Lower().Find(_T("library version:"));
        if (pos != -1)
        {
            int revpos = rec.title.Lower().Find(_T("devpak revision:"));
            if (revpos != -1) {
                rec.revision = rec.title.Mid(revpos).AfterFirst(_T(':')).Trim(false);
                rec.revision.Replace(_T("\t"), _T(" "));
                rec.revision = rec.revision.BeforeFirst(_T(' '));
            }

            rec.title.Truncate(pos);
            rec.title = rec.title.Trim(false);
            rec.title = rec.title.Trim(true);
        }

        rec.name = ini.GetKeyValue(i, _T("Name"));
        rec.desc = ini.GetKeyValue(i, _T("Description"));
        rec.remote_file = ini.GetKeyValue(i, _T("RemoteFilename"));
        rec.local_file = ini.GetKeyValue(i, _T("LocalFilename"));
        rec.groups = GetArrayFromString(ini.GetKeyValue(i, _T("Group")), _T(","));
        rec.install_path = ini.GetKeyValue(i, _T("InstallPath"));
        rec.version = ini.GetKeyValue(i, _T("Version"));
        ini.GetKeyValue(i, _T("Size")).ToLong(&rec.bytes);
        rec.date = ini.GetKeyValue(i, _T("Date"));
        rec.installable = ini.GetKeyValue(i, _T("Execute")) == _T("1");

        // read .entry file (if exists)
        rec.entry = (!rec.name.IsEmpty() ? rec.name : wxFileName(rec.local_file).GetName()) + _T(".entry");
        IniParser p;
        p.ParseFile(appPath + rec.entry);
        rec.installed_version = p.GetValue(_T("Setup"), _T("AppVersion"));

        rec.downloaded = wxFileExists(appPath + _T("/") + rec.local_file);
        rec.installed = !rec.installed_version.IsEmpty();

        // calculate size
        rec.size = GetSizeString(rec.bytes);

        // fix-up
        if (rec.name.IsEmpty())
            rec.name = rec.title;
        rec.desc.Replace(_T("<CR>"), _T("\n"));
        rec.desc.Replace(_T("<LF>"), _T("\r"));
        wxURL url(rec.remote_file);
        if (!url.GetServer().IsEmpty())
        {
            rec.remote_server = url.GetScheme() + _T("://") + url.GetServer();
            int pos = rec.remote_file.Find(url.GetServer());
            if (pos != wxNOT_FOUND)
                rec.remote_file.Remove(0, pos + url.GetServer().Length() + 1);
        }
        else
            rec.remote_server = currentServer;
    }

    *recCount = groupsCount;
    return list;
}
Пример #5
0
void CRapiFileDialog::UpdateDialog(void)
{
    m_pathname.MakeAbsolute();
    m_currentpaths.clear();
    m_currentsizes.clear();
    m_currentdates.clear();

    GetFileList()->ClearAll();

    if(m_mode==REPORTMODE)
    {
        GetFileList()->SetWindowStyle(wxLC_REPORT|wxLC_SINGLE_SEL);
        GetFileList()->InsertColumn(0,wxT("Name"),wxLIST_FORMAT_LEFT,160);
        GetFileList()->InsertColumn(1,wxT("Size"));
        GetFileList()->InsertColumn(2,wxT("Date"));
    }
    else if(m_mode==ICONMODE)
    {
        GetFileList()->SetWindowStyle(wxLC_ICON|wxLC_SINGLE_SEL);
    }
    else if(m_mode==SMALLICONMODE)
    {
        GetFileList()->SetWindowStyle(wxLC_SMALL_ICON|wxLC_SINGLE_SEL);
    }
    else if(m_mode==LISTMODE)
    {
        GetFileList()->SetWindowStyle(wxLC_LIST|wxLC_SINGLE_SEL);
    }

    // Ensure we have a file type selection
    if(GetFilesOfType()->GetCount()==0)
    {
        AddFileType(wxT("All Files (*.*)"),wxT("*"));
    }
    if(GetFilesOfType()->GetSelection()==wxNOT_FOUND)
    {
        GetFilesOfType()->SetSelection(0);
    }
    
    // Get item names
    DWORD dwFound;
    LPCE_FIND_DATA pFoundDataArray=NULL;
    if(!g_RAPI.CeFindAllFiles(m_pathname.GetPath(true)+wxT("*"),FAF_ATTRIBUTES|FAF_SIZE_HIGH|FAF_SIZE_LOW|FAF_NAME|FAF_LASTWRITE_TIME,&dwFound,&pFoundDataArray))
    {
        GetFileList()->Enable(false);
    }
    else
    {
        GetFileList()->Enable(true);
    }

    if(pFoundDataArray)
    {
        wxString strMatch=m_filetypes[GetFilesOfType()->GetSelection()];

        // Fill in file list
        for(DWORD dw=0;dw<dwFound;dw++)
        {
            if(pFoundDataArray[dw].dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
            {
                // It's a folder
                wxFileName dname(m_pathname.GetPath(true)+pFoundDataArray[dw].cFileName,wxT(""));
                m_currentpaths.push_back(dname.GetPath(true));
                m_currentsizes.push_back(0);
                m_currentdates.push_back(pFoundDataArray[dw].ftLastWriteTime);
            }
            else
            {
                // It's a file
                wxFileName dname(m_pathname.GetPath(true)+pFoundDataArray[dw].cFileName);

                if(dname.GetFullName().Lower().Matches(strMatch.Lower()))
                {
                    m_currentpaths.push_back(dname.GetFullPath());
                    m_currentsizes.push_back(((wxUint64)pFoundDataArray[dw].nFileSizeLow)|(((wxUint64)pFoundDataArray[dw].nFileSizeHigh)<<32));
                    m_currentdates.push_back(pFoundDataArray[dw].ftLastWriteTime);
                }
            }
        }
        g_RAPI.CeRapiFreeBuffer(pFoundDataArray);
    }

    wxImageList *pilSmall=new wxImageList(16,16,true,1);
    pilSmall->Add(RapiFileDialogBitmapsFunc(0),wxColour(255,0,255));
    pilSmall->Add(RapiFileDialogBitmapsFunc(1),wxColour(255,0,255));
    pilSmall->Add(RapiFileDialogBitmapsFunc(2),wxColour(255,0,255));

    wxImageList *pilBig=new wxImageList(32,32,true,1);
    pilBig->Add(RapiFileDialogBitmapsLgFunc(0),wxColour(255,0,255));
    pilBig->Add(RapiFileDialogBitmapsLgFunc(1),wxColour(255,0,255));
    pilBig->Add(RapiFileDialogBitmapsLgFunc(2),wxColour(255,0,255));

    size_t i=0,count=m_currentpaths.size();
    for(i=0;i<count;i++)
    {
        if(m_currentpaths[i].Last()==wxT('\\'))
        {
            GetFileList()->InsertItem((long)i,wxFileName(m_currentpaths[i],wxT("")).GetDirs().Last(),0);
            GetFileList()->SetItemImage((long)i,0,1);
            if(m_mode==REPORTMODE)
            {
//              GetFileList()->SetItem((long)i,1,(const TCHAR *)GetSizeString(m_currentsizes[i]));
                GetFileList()->SetItem((long)i,2,(const TCHAR *)GetDateString(m_currentdates[i]));
            }

        }
        else
        {
            GetFileList()->InsertItem((long)i,wxFileName(m_currentpaths[i]).GetFullName(),2);
            if(m_mode==REPORTMODE)
            {
                GetFileList()->SetItem((long)i,1,(const TCHAR *)GetSizeString(m_currentsizes[i]));
                GetFileList()->SetItem((long)i,2,(const TCHAR *)GetDateString(m_currentdates[i]));
            }
        }

        if(m_currentpaths[i].Last()==m_pathname.GetFullPath())
        {
            GetFileList()->SetItemState((long)i,wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED,wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED);
        }
        GetFileList()->SetItemData((long)i,(long)i);
    }

    GetFileList()->AssignImageList(pilSmall,wxIMAGE_LIST_SMALL);
    GetFileList()->AssignImageList(pilBig,wxIMAGE_LIST_NORMAL);

    // Fill in Look-In Choice Box
    GetLookIn()->Clear();
    count=m_pathname.GetDirCount();
    
    wxString dir=wxT("\\");
    GetLookIn()->Append(dir);        

    for(i=0;i<count;i++)
    {
        dir=wxT("\\");
        for(size_t j=0;j<=i;j++)
        {
            dir+=m_pathname.GetDirs()[j];
            if(j!=i)
            {
                dir+=wxT("\\");
            }
        }
        GetLookIn()->Append(dir);
    }
    GetLookIn()->SetSelection((int)count);

    GetUp()->Enable(count>0);
    GetBack()->Enable(m_history.size()>1);
    GetOk()->Enable(m_pathname.GetFullPath().Last()!=wxT('\\'));

    GetFileList()->SortItems(ListCompareFunction,(long)this);
}
void FDistanceFieldVolumeTextureAtlas::UpdateAllocations()
{
	if (PendingAllocations.Num() > 0)
	{
		// Sort largest to smallest for best packing
		PendingAllocations.Sort(FCompareVolumeAllocation());

		for (int32 AllocationIndex = 0; AllocationIndex < PendingAllocations.Num(); AllocationIndex++)
		{
			FDistanceFieldVolumeTexture* Texture = PendingAllocations[AllocationIndex];
			const FIntVector Size = Texture->VolumeData.Size;

			if (!BlockAllocator.AddElement((uint32&)Texture->AtlasAllocationMin.X, (uint32&)Texture->AtlasAllocationMin.Y, (uint32&)Texture->AtlasAllocationMin.Z, Size.X, Size.Y, Size.Z))
			{
				UE_LOG(LogStaticMesh,Error,TEXT("Failed to allocate %ux%ux%u in distance field atlas"), Size.X, Size.Y, Size.Z);
				PendingAllocations.RemoveAt(AllocationIndex);
				AllocationIndex--;
			}
		}

		if (!VolumeTextureRHI
			|| BlockAllocator.GetSizeX() > VolumeTextureRHI->GetSizeX()
			|| BlockAllocator.GetSizeY() > VolumeTextureRHI->GetSizeY()
			|| BlockAllocator.GetSizeZ() > VolumeTextureRHI->GetSizeZ())
		{
			if (CurrentAllocations.Num() > 0)
			{
				static const auto CVarXY = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DistanceFields.AtlasSizeXY"));
				const int32 AtlasXY = CVarXY->GetValueOnAnyThread();

				static const auto CVarZ = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DistanceFields.AtlasSizeZ"));
				const int32 AtlasZ = CVarZ->GetValueOnAnyThread();

				// Remove all allocations from the layout so we have a clean slate
				BlockAllocator = FTextureLayout3d(0, 0, 0, AtlasXY, AtlasXY, AtlasZ, false, false);
				
				Generation++;

				// Re-upload all textures since we had to reallocate
				PendingAllocations.Append(CurrentAllocations);
				CurrentAllocations.Empty();

				// Sort largest to smallest for best packing
				PendingAllocations.Sort(FCompareVolumeAllocation());

				// Add all allocations back to the layout
				for (int32 AllocationIndex = 0; AllocationIndex < PendingAllocations.Num(); AllocationIndex++)
				{
					FDistanceFieldVolumeTexture* Texture = PendingAllocations[AllocationIndex];
					const FIntVector Size = Texture->VolumeData.Size;

					if (!BlockAllocator.AddElement((uint32&)Texture->AtlasAllocationMin.X, (uint32&)Texture->AtlasAllocationMin.Y, (uint32&)Texture->AtlasAllocationMin.Z, Size.X, Size.Y, Size.Z))
					{
						UE_LOG(LogStaticMesh,Error,TEXT("Failed to allocate %ux%ux%u in distance field atlas"), Size.X, Size.Y, Size.Z);
						PendingAllocations.RemoveAt(AllocationIndex);
						AllocationIndex--;
					}
				}
			}

			FRHIResourceCreateInfo CreateInfo;

			VolumeTextureRHI = RHICreateTexture3D(
				BlockAllocator.GetSizeX(), 
				BlockAllocator.GetSizeY(), 
				BlockAllocator.GetSizeZ(), 
				Format,
				1,
				TexCreate_ShaderResource,
				CreateInfo);

			UE_LOG(LogStaticMesh,Log,TEXT("Allocated %s"), *GetSizeString());
		}

		for (int32 AllocationIndex = 0; AllocationIndex < PendingAllocations.Num(); AllocationIndex++)
		{
			FDistanceFieldVolumeTexture* Texture = PendingAllocations[AllocationIndex];
			const FIntVector Size = Texture->VolumeData.Size;

			const FUpdateTextureRegion3D UpdateRegion(
				Texture->AtlasAllocationMin.X,
				Texture->AtlasAllocationMin.Y,
				Texture->AtlasAllocationMin.Z,
				0,
				0,
				0,
				Size.X,
				Size.Y,
				Size.Z);

			const int32 FormatSize = GPixelFormats[Format].BlockBytes;

			// Update the volume texture atlas
			RHIUpdateTexture3D(VolumeTextureRHI, 0, UpdateRegion, Size.X * FormatSize, Size.X * Size.Y * FormatSize, (const uint8*)Texture->VolumeData.DistanceFieldVolume.GetData());
		}

		CurrentAllocations.Append(PendingAllocations);
		PendingAllocations.Empty();
	}	
}
Пример #7
0
BOOL UpdateProgressBarProc (__int64 byteOffset)
{
	wchar_t text[100];
	wchar_t speed[100];
	HWND hProgressBar = GetDlgItem (hCurPage, nPbar);
	int time = GetTickCount ();
	int elapsed = (time - startTime) / 1000;

	uint64 bytesDone = (bProgressBarReverse ? (TotalSize - byteOffset) : byteOffset);
	uint64 bytesPerSec = (bProgressBarReverse ? (resumedPointBytesDone - byteOffset) : (bytesDone - resumedPointBytesDone)) / (elapsed + 1);

	if (bPercentMode)
	{
		double perc = (double) (100.0 * (bProgressBarReverse ? ((double) (TotalSize - byteOffset)) : ((double) byteOffset)) / (TotalSize == 0 ? 0.0001 : ((double) TotalSize)));

		if (perc > 99.999999999)
			StringCchCopyW (text,ARRAYSIZE(text),  GetString ("PROCESSED_PORTION_100_PERCENT"));
		else
			StringCchPrintfW (text, ARRAYSIZE (text), GetString ("PROCESSED_PORTION_X_PERCENT"), perc);

		StringCchCatW (text, ARRAYSIZE(text), L" ");
	}
	else
	{
		GetSizeString (bytesDone, text, sizeof(text));
		if (bytesDone < (unsigned __int64) BYTES_PER_MB * 1000000)
			StringCchPrintfW(text, ARRAYSIZE(text), L"%I64d %s ", bytesDone / BYTES_PER_MB, GetString ("MB"));
		else if (bytesDone < (unsigned __int64) BYTES_PER_GB * 1000000)
			StringCchPrintfW(text, ARRAYSIZE(text), L"%I64d %s ", bytesDone / BYTES_PER_GB, GetString ("GB"));
		else if (bytesDone < (unsigned __int64) BYTES_PER_TB * 1000000)
			StringCchPrintfW(text, ARRAYSIZE(text), L"%I64d %s ", bytesDone / BYTES_PER_TB, GetString ("TB"));
		else
			StringCchPrintfW(text, ARRAYSIZE(text), L"%I64d %s ", bytesDone / BYTES_PER_PB, GetString ("PB"));
	}

	SetWindowTextW (GetDlgItem (hCurPage, IDC_BYTESWRITTEN), text);

	if (!bShowStatus)
	{
		GetSpeedString (bRWThroughput ? bytesPerSec*2 : bytesPerSec, speed, sizeof(speed));
		StringCchCatW (speed, ARRAYSIZE(speed), L" ");
		SetWindowTextW (GetDlgItem (hCurPage, IDC_WRITESPEED), speed);
	}

	if (byteOffset < TotalSize)
	{
		int64 sec = (int64) ((bProgressBarReverse ? byteOffset : (TotalSize - byteOffset)) / (bytesPerSec == 0 ? 0.001 : bytesPerSec));

		if (bytesPerSec == 0 || sec > 60 * 60 * 24 * 999)
			StringCchPrintfW (text, ARRAYSIZE(text), L"%s ", GetString ("NOT_APPLICABLE_OR_NOT_AVAILABLE"));
		else if (sec >= 60 * 60 * 24 * 2)
			StringCchPrintfW (text, ARRAYSIZE(text), L"%I64d %s ", sec / (60 * 24 * 60), days);
		else if (sec >= 120 * 60)
			StringCchPrintfW (text, ARRAYSIZE(text), L"%I64d %s ", sec / (60 * 60), hours);
		else if (sec >= 120)
			StringCchPrintfW (text, ARRAYSIZE(text), L"%I64d %s ", sec / 60, minutes);
		else
			StringCchPrintfW (text, ARRAYSIZE(text), L"%I64d %s ", sec, seconds);

		SetWindowTextW (GetDlgItem (hCurPage, IDC_TIMEREMAIN), text);
	}

	prevTime = time;

	SendMessage (hProgressBar, PBM_SETPOS,
		(int) (10000.0 * (bProgressBarReverse ? (TotalSize - byteOffset) : byteOffset) / (TotalSize == 0 ? 1 : TotalSize)),
		0);

	return bVolTransformThreadCancel;
}
Пример #8
0
String CFile::GetUncompressedSizeString ()
{
	return GetSizeString ( GetUncompressedDataSize() );
}
Пример #9
0
String CFile::GetDataSizeString ()
{
	return GetSizeString ( m_lDataSize );
}