bool SPInputManager::SetCursor( SPString path )
	{
		SPFilePtr file = SPFileManager::GetSingleton().OpenFile(path);

		if (!file)
		{
			return false;
		}

		LONGLONG length = file->GetFileLength();
		char* pData = new char[length];
		file->Read(pData, length);

		wchar_t tname[10];		
		_wtmpnam_s(tname, 10);

		SPString name = SPString(tname);// + path.substr(path.find_last_of(L".") + 1);

		HANDLE newFile = CreateFile(name.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL,
			CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

		if (newFile == INVALID_HANDLE_VALUE)
		{
			return false;
		}

		DWORD numOfByte;
		if(FALSE == WriteFile(newFile, pData, length, &numOfByte, NULL))
		{ 
			delete [] pData;
			SPFileManager::GetSingleton().CloseFile(path);
			CloseHandle(newFile);
			DeleteFile(name.c_str());
			return false;
		}

		CloseHandle(newFile);
		HCURSOR cursor = LoadCursorFromFile(name.c_str());
		if (!cursor)
		{
			DWORD err = GetLastError();
			delete [] pData;
			SPFileManager::GetSingleton().CloseFile(path);
			CloseHandle(newFile);
			DeleteFile(name.c_str());
			return false;
		}

		SPWindow::GetSingleton().SetCursor(cursor);

		DeleteFile(name.c_str());

		delete [] pData;
		SPFileManager::GetSingleton().CloseFile(path);
		//CloseHandle(newFile);

		return true;
	}
Beispiel #2
0
	void SPWindow::SetTitle( SPString title )
	{
		modificationLock.Lock();
		SetWindowText(GetHWnd(), title.c_str());
		this->title = title;
		modificationLock.Unlock();
	}
Beispiel #3
0
	void SPPathHelper::MakeSurePathExist( SPString path )
	{
		SPPointer<SPStringList> parts = SplitPath(path);
		SPString currentDir = (*parts)[0];
		for (int i = 0; i < parts->size() - 1; i++)
		{
			CreateDirectory(currentDir.c_str(), NULL);
			currentDir = currentDir + L"\\" + (*parts)[i + 1];
		}
	}
Beispiel #4
0
	bool SPFileHelper::CreatePath( SPString path )
	{
		if (path.size() == 0 || path == L"/" || path == L"\\")
		{
			return true;
		}

		if(IsPathExists(path.c_str()))
		{
			return true;
		}

		if(!CreatePath(GetUpperPath(path)))
		{
			return false;
		}

		if( FALSE == CreateDirectory(path.c_str(), NULL))
		{
			return false;
		}

		return true;
	}
Beispiel #5
0
	bool SPFont::Load( 
		INT			Height, 
		UINT		Width, 
		UINT		Weight, 
		UINT		MipLevels, 
		BOOL		Italic, 
		DWORD		CharSet, 
		DWORD		OutputPrecision, 
		DWORD		Quality, 
		DWORD		PitchAndFamily, 
		SPString	FontName )
	{
		float rate = SPFontManager::GetSingleton().GetSizeRate();

		if (FAILED(D3DXCreateFont(
			SPDevice::GetSingleton().GetD3DDevice(),
			Height * rate , Width * rate, Weight, MipLevels, Italic, 
			CharSet, OutputPrecision, Quality,
			PitchAndFamily, FontName.c_str(), &font)))
		{		
			return false;
		}

	
		//D3DXFONT_DESCA des;
		//Font->GetDescA(&des);

		width = Width;
		height = Height;
		weight = Weight;
		italic = Italic == TRUE;
		miplevel = MipLevels;
		name = FontName;

		return true;
	}
Beispiel #6
0
	bool SPXAudio::Load()
	{
		TCHAR Buffer[MAX_PATH]; 
		GetSystemDirectory(Buffer, MAX_PATH);
		SPString path = SPString(Buffer) + L"\\XAudio2_7.dll";

		if(PathFileExists( path.c_str()) == FALSE) 
		{
			// Register xaudio			
			SPLogHelper::WriteLog(L"[XAudio] Copying XAudio " + path );
			CopyFile(L"XAudio2_7.dll", path.c_str(), TRUE);
			SPLogHelper::WriteLog("[XAudio] Registering XAudio ..." );
			UINT result = WinExec("regsvr32.exe XAudio2_7.dll ", SW_HIDE);
		}

		//void* fnc = GetProcAddress(module, "XAudio2Create");

		SPLogHelper::WriteLog("[XAudio] Initializing XAudio ...");

		HRESULT hr = S_OK;//CoInitializeEx(NULL, COINIT_MULTITHREADED);

		if (FAILED(hr) && hr != -2147417850)
		{
			SPLogHelper::WriteLog("[XAudio] ERROR: Failed to initialize XAudio2!");
			SPMessageHelper::Msg("Failed to initialize XAudio2!");
			return false;
		}	

		IXAudio2* pXAudio2;

		hr = CoCreateInstance((0 & XAUDIO2_DEBUG_ENGINE) ? __uuidof(XAudio2_Debug) : __uuidof(XAudio2),
			NULL, CLSCTX_INPROC_SERVER, __uuidof(IXAudio2), (void**)&pXAudio2);

		if (SUCCEEDED(hr))
		{
			hr = pXAudio2->Initialize(0, XAUDIO2_DEFAULT_PROCESSOR);

			if (SUCCEEDED(hr))
			{
				xAudio = pXAudio2;
			}
			else
			{
				pXAudio2->Release();
			}
		}
		else
		{
			SPLogHelper::WriteLog("[XAudio] ERROR: Failed to create XAudio2! %d %d", __uuidof(IXAudio2), __uuidof(XAudio2_Debug));
		}

		//hr = XAudio2Create( &xAudio, 0, XAUDIO2_DEFAULT_PROCESSOR );

		if (FAILED(hr))
		{
			SPLogHelper::WriteLog("[XAudio] ERROR: Failed to create XAudio2! %d %d", hr, GetLastError());
			
			SPMessageHelper::Msg("Failed to create XAudio2!");
			return false;
		}

		// Enumerate and select devices
		UINT32 deviceCount;
		xAudio->GetDeviceCount(&deviceCount);

		XAUDIO2_DEVICE_DETAILS deviceDetails;
		int preferredDevice = 0;
		for (unsigned int i = 0; i < deviceCount; i++)
		{
			xAudio->GetDeviceDetails(i,&deviceDetails);
			if (deviceDetails.OutputFormat.Format.nChannels > 2)
			{
				preferredDevice = i;
				break;
			}
		}

		// Create mastering voice device
		if ( FAILED(xAudio->CreateMasteringVoice( &masterVoice, XAUDIO2_DEFAULT_CHANNELS,
			XAUDIO2_DEFAULT_SAMPLERATE, 0, preferredDevice, NULL ) ) )
		{
			SPLogHelper::WriteLog("[XAudio] WARNING: Failed to create Mastering Voice!");
			//MessageBoxA(NULL, "Failed to create mastering voice!", NULL, NULL);
			Unload();
			return false;
		}

		return true;
	}
Beispiel #7
0
	bool SPFileHelper::IsPathExists( SPString path )
	{
		return TRUE == PathFileExists(path.c_str());
	}