void DVDWorker::ExtractCurrentClassicItem() {
	string copydvdname;
	int namelength;
	m_CurrentItem->setTitle(L"Xbox Classic DVD");
	XboxExecutable xbe;
	xbe.OpenExecutable("dvd:\\default.xbe");
	xbe.GetTitleName(&copydvdname, &namelength);
	wstring Title = strtowstr(copydvdname);
	wstring fullTitle = sprintfaW(L"Play %s", strtowstr(copydvdname).c_str());
	m_CurrentItem->setTitle(Title);
	m_CurrentItem->setFullTitle(fullTitle);

	VOID* classicImage = NULL;	int classicImageSize = 0;
	xbe.GetGameThumbnail(&classicImage, &classicImageSize);


	// Convert ot dxt5
	if(classicImageSize > 0 && classicImage != NULL) {
		BYTE* thumbnailData = NULL; long thumbnailSize = 0;
		ConvertImageInMemoryToDXT5Buffer((BYTE*)classicImage, (long)classicImageSize, 
			&thumbnailData, &thumbnailSize);

		iconData dataIcon;
		dataIcon.thumbnailData = thumbnailData;
		dataIcon.thumbnailSize = thumbnailSize;
		m_CurrentItem->SetThumbData(dataIcon);
		m_CurrentItem->setHaveThumb(true);
	}
	// Trigger the download complete function
	if(m_CurrentItem->requester != NULL)
		m_CurrentItem->requester->ExtractCompleted(m_CurrentItem);	
}
void SkinManager::RegisterFonts(CFreestyleUIApp&  g_uiApp, string path)
{
	HRESULT hr;

	vector<FontInfo>::iterator itr;
	for(itr = CurrentSkin.Fonts.begin(); itr != CurrentSkin.Fonts.end(); itr++)
	{
		string FontPath = "file://" + path + (*itr).FontFile;

		if((*itr).FontDefault)  
		{  
			DebugMsg("SkinManager","Loading default font %s as %s",FontPath.c_str(),(*itr).FontName.c_str());  
			hr = g_uiApp.RegisterDefaultTypeface(strtowstr((*itr).FontName).c_str(), strtowstr(FontPath).c_str());  
			CurrentSkin.HasDefaultFont = true;
		}  
		else  
		{  
			DebugMsg("SkinManager","Loading no default font %s as %s",FontPath.c_str(),(*itr).FontName.c_str());  
			hr = g_uiApp.RegisterTypeface( strtowstr((*itr).FontName).c_str(), strtowstr(FontPath).c_str());  
		}  
		if(hr!=S_OK)
		{
			DebugMsg("SkinManager","Couldnt load font...");  
		}
	}
}
void CScnGameControls::UpdateFileProgress()
{
	ULONGLONG sizeDone = FileOperationManager::getInstance().GetSizeDone()/1024/1024;
	ULONGLONG totalSize = FileOperationManager::getInstance().GetTotalSize()/1024/1024;
	
	string currentStatus = FileOperationManager::getInstance().GetCurrentItemStatus();
	string PercentDone = sprintfaA("%d%%", (int)((sizeDone*1.0/totalSize*1.0)*100.0));

	m_FileName.SetText(strtowstr(currentStatus).c_str());
	m_OverallPercent.SetText(strtowstr(PercentDone).c_str());

	m_TotalProgressBar.SetValue((int)((sizeDone*1.0/totalSize*1.0)*100.0));
}
void entryPoint(const std::vector<std::string *> arguments)
{
	try
	{
		WhatsAppViewer whatsAppViewer;

		if (arguments.size() > 1)
		{
			whatsAppViewer.openDatabase(*arguments[1]);
		}

		bool run = true;
		while (run)
		{
			if (!whatsAppViewer.tick())
			{
				run = false;
			}
		}
	}
	catch (Exception &exception)
	{
		std::wstring cause = strtowstr(exception.getCause());
		MessageBox(NULL, cause.c_str(), L"Error", MB_OK | MB_ICONERROR);
	}
}
// Handles the kai message for a player joining the general chat
void ChatManager::OnJoinsChat( string aOpponent )
{
	// If the chat scene is not active, lets not handle any messages
	if(bChatActive == false) return;

	CHAT_LOCK;		// Lock

	// Iterator through the vector of CKaiPlayers to search for duplicates
	vector<CKaiPlayer>::iterator itr;
	for(itr = m_vChatPlayers.begin(); itr != m_vChatPlayers.end(); ++itr)
	{
		wstring aOpponentW = strtowstr(aOpponent);
		if(wcscmp((*itr).GetPlayerName(),aOpponentW.c_str()) == 0) { 
			CHAT_UNLOCK;
			return;
		}
	}

	// Player wasn't found so let's create a new player item
	CKaiPlayer * pPlayer = new CKaiPlayer(aOpponent);
	
	// Add him to the player list
	m_vChatPlayers.push_back(*pPlayer);

	delete pPlayer;

	CHAT_UNLOCK;		// Unlock
}
HRESULT CScnOptionsContentSettings::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled )
{
	switch (pTimer->nId) 
	{
	case TM_KEYBOARD:
		if(XHasOverlappedIoCompleted(&m_kbOverlapped)) {
			bHandled = TRUE;
			KillTimer(TM_KEYBOARD);

			if(m_kbOverlapped.dwExtendedError == ERROR_SUCCESS) {
				if(m_dwKeyboardMode == KBMODE_USERNAME) {
					m_dwKeyboardMode = KBMODE_NONE;
					m_CoverUser.SetText(m_kbBuffer);
					string m_szUsername = wstrtostr(m_kbBuffer);
					SETTINGS::getInstance().setCoverUser(m_szUsername);

				} else if(m_dwKeyboardMode == KBMODE_PASSWORD) {
					m_dwKeyboardMode = KBMODE_NONE;
					string m_szPassword = wstrtostr(m_kbBuffer);
					m_CoverPass.SetText(strtowstr(GetPasswordMask(m_szPassword.length(), "*")).c_str());					
					SETTINGS::getInstance().setCoverPass(m_szPassword);

				} else {
					// Unhandled Keyboard Mode
				}
			}
		}
		break;
	default:
		break;
	};

	// Return successfully
	return S_OK;
}
int ChatControlMessageFrame::getRemoteResourceHeight()
{
    HDC deviceContext = GetDC(NULL);
    int height = calculateDrawTextHeight(deviceContext, strtowstr(message->getMessage().getRemoteResource()).c_str(), width, dateFont);
    ReleaseDC(NULL, deviceContext);
    return height;
}
std::string SettingsRegistry::read(const std::string &key)
{
	HKEY keyHandle;
	if (RegOpenKeyEx(HKEY_CURRENT_USER, L"Software\\WhatsApp Viewer", 0, KEY_READ, &keyHandle) != ERROR_SUCCESS)
	{
		throw Exception("Could not open registry key");
	}

	DWORD type;
	DWORD size;
	std::wstring keyW = strtowstr(key);
	if (RegQueryValueEx(keyHandle, keyW.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS)
	{
		RegCloseKey(keyHandle);
		throw KeyNotFoundException("Could not read registry value");
	}

	if (type != REG_SZ)
	{
		RegCloseKey(keyHandle);
		throw Exception("Incorrect registry value type");
	}

	std::wstring value(size / sizeof(wchar_t), L'\0');
	if (RegQueryValueEx(keyHandle, keyW.c_str(), NULL, NULL, reinterpret_cast<BYTE *>(&value[0]), &size) != ERROR_SUCCESS)
	{
		RegCloseKey(keyHandle);
		throw Exception("Could not read registry value");
	}

	RegCloseKey(keyHandle);

	return wstrtostr(value.c_str());
}
void ChatManager::OnChat(string aVector, string aOpponent, string aMessage, bool bPrivate)
{
	// First, let's check if the chat is active- ( we don't want to build our buffer up if we're not viewing it )
	if( bChatActive == false ) return;
	
	// This class doesn't handle private messages, so let's bail if it is one.
	if( bPrivate == true) return;
	
	CHAT_LOCK;			// Lock

	m_szChatBuffer.append( strtowstr( aOpponent ) );
	m_szChatBuffer.append( L" : " );
	m_szChatBuffer.append( strtowstr( aMessage ) );
	m_szChatBuffer.append( L"\n"  );

	CHAT_UNLOCK;		// Unlock
}
void SettingsRegistry::write(const std::string &key, const std::string &value)
{
	HKEY keyHandle;
	if (RegCreateKeyEx(HKEY_CURRENT_USER, L"Software\\WhatsApp Viewer", 0, NULL, 0, KEY_SET_VALUE, NULL, &keyHandle, NULL) != ERROR_SUCCESS)
	{
		throw Exception("Could not create registry key");
	}

	std::wstring keyW = strtowstr(key);
	std::wstring valueW = strtowstr(value);
	if (RegSetValueEx(keyHandle, keyW.c_str(), 0, REG_SZ, reinterpret_cast<const BYTE *>(valueW.c_str()), valueW.size() * sizeof(WCHAR)) != ERROR_SUCCESS)
	{
		RegCloseKey(keyHandle);
		throw Exception("Could not write registry value");
	}

	RegCloseKey(keyHandle);
}
INT_PTR DecryptDatabaseDialog7::callback(HWND dialog, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
		case WM_INITDIALOG:
		{
			SetDlgItemText(dialog, IDC_DECRYPT_CRYPT7_DATABASE, strtowstr(openDatabaseStruct.filename).c_str());
			SetDlgItemText(dialog, IDC_DECRYPT_CRYPT7_KEYFILE, strtowstr(openDatabaseStruct.keyFilename).c_str());
		} break;
		case WM_COMMAND:
		{
			switch (HIWORD(wParam))
			{
				case BN_CLICKED:
				{
					switch (LOWORD(wParam))
					{
						case IDC_DECRYPT_CRYPT7_SELECT_DATABASE:
						{
							selectDatabaseFile();
						} break;
						case IDC_DECRYPT_CRYPT7_SELECT_KEY:
						{
							selectKeyFile();
						} break;
						case IDOK:
						{
							clickOk(wParam);
							return TRUE;
						} break;
						case IDCANCEL:
						{
							close(LOWORD(wParam));
							return TRUE;
						} break;
					}
				} break;
			}
		} break;
	}

	return 0;
}
Exemple #12
0
/*
 * convert utf8 encoded string to wstring
 * 1st, convert utf8 encoded string to native string
 * 2nd, call strtowstr
 */
std::wstring sunjwbase::strtowstrutf8(const std::string& str)
{
	// Convert an utf8 encoded string to a wstring
#if defined (WIN32)
	return _strtowstr(str, CP_UTF8);
#endif
#if defined (__APPLE__) || defined (__unix)
	return strtowstr(striconv(str, "ASCII", "UTF-8"));
#endif
}
void SkinManager::loadScene(string sceneName, HXUIOBJ curScene, bool stayVisible, string objectRef, void * pvInitData)
{
	HXUIOBJ hScene;
	
	string path;
	if (CurrentSkin.isCompressed)
	{
		path = "file://" + CurrentSkin.XZPPath;
	} else {
		path = "file://" + CurrentSkin.SkinPath;
	}
	CXuiScene::SceneCreate( strtowstr(path).c_str(), strtowstr(sceneName).c_str(), &hScene, pvInitData);
	
	if(objectRef == "")
		objectRef = sceneName;
		
	getXurObjectHandle[objectRef] = hScene;

	DebugMsg("SkinManager", "SceneObjectMap- Scene Name:  %s,  HXUIOBJ:  %08X", objectRef.c_str(), hScene);
	XuiSceneNavigateForward(curScene, stayVisible, hScene, XUSER_INDEX_ANY);
}
void SkinManager::loadSkin( CFreestyleUIApp&  g_uiApp , string firstScene, bool firstLoad )
{
	
	HRESULT hr;
	string path;

	if(firstLoad)
	{
		ExtractTempSkinInfo();
	}		

	if (CurrentSkin.isCompressed)
	{
		path = CurrentSkin.XZPPath;
	} else {
		path = CurrentSkin.SkinPath;
	}

	RegisterFonts(g_uiApp, path);

	string skinload;
	string sceneload;
	skinload = "file://" + path + "skin.xur";
	sceneload = "file://" + path;


	//DebugMsg("SkinManager","loading %s as default skin", skinload.c_str());
	hr = g_uiApp.LoadSkin( strtowstr(skinload).c_str() );
	if (hr != S_OK)
	{
		DebugMsg("SkinManager", "Skin Loaded with HRESULT : %08x");
		return;
	}
	//DebugMsg("SkinManager","loading %s %s as default scene", sceneload.c_str(),firstScene.c_str());
	hr = g_uiApp.LoadFirstScene( strtowstr(sceneload).c_str(), strtowstr(firstScene).c_str() );
	if (hr != S_OK)
	{
		DebugMsg("SkinManager", "Scene Loaded with HRESULT : %08x");
	}
}
Exemple #15
0
void CScnAbout::ReadSkinData( void )
{
	string strBuffer = "";
	
	if(hasXexVersion)
	{
		m_XexVersion.SetText(strtowstr(VersionManager::getInstance().getFSDDashVersionAsString()).c_str());
	}
	if(hasSkinName)
	{
		m_SkinName.SetText(strtowstr(SETTINGS::getInstance().getSkin()).c_str());
	}

	if(hasSkinVersion)
	{
		m_SkinVersion.SetText(strtowstr(VersionManager::getInstance().getFSDSkinVersionAsString()).c_str());
	}

	if(hasKernelVersion)
	{
		m_KernelVersion.SetText(strtowstr(VersionManager::getInstance().getKernelAsString()).c_str());
	}

}
void ChatControlMessageFrame::renderFrame(HDC deviceContext, int x, int y)
{
    SetBkColor(deviceContext, color);

    RECT completeRect = { x, y, x + width, y + getHeight() };
    HBRUSH brush = CreateSolidBrush(color);
    FillRect(deviceContext, &completeRect, brush);
    DeleteObject(brush);

    SetTextColor(deviceContext, RGB(110, 110, 110));
    int dateHeight = calculateDrawTextHeight(deviceContext, wcharDate.c_str(), width, dateFont);
    drawTextRight(deviceContext, wcharDate.c_str(), x, y + getHeight() - dateHeight, width, dateFont);

    if (message->getMessage().getRemoteResource().size() > 0)
    {
        std::wstring remoteResource = strtowstr(message->getMessage().getRemoteResource());
        int remoteResourceHeight = calculateDrawTextHeight(deviceContext, remoteResource.c_str(), width, dateFont);
        drawTextRight(deviceContext, remoteResource.c_str(), x, y + getHeight() - dateHeight - remoteResourceHeight, width, dateFont);
    }
}
HRESULT CAchievementList::OnInit(XUIMessageInit *pInitData, BOOL& bHandled)
{
	DebugMsg("AchievementList","AchievementList Init");

	AchievementIconPaths.szMissingAchievementIcon = strtowstr(AchievementManager::getInstance().GetAchievementSetting("MISSINGACHIEVEMENTPATH"));

	m_sListState = GameContentManager::getInstance().getGameListSnapshot(false);

	if(m_sListState.CurrentGame == NULL)
		return S_OK;

	wstring szGameID = m_sListState.CurrentGame->ContentRef->getId();

	m_AchievementList.ListSize = AchievementManager::getInstance().GetAchievementCount(szGameID);
	AchievementManager::getInstance().CreateAchievementList(szGameID);

	InsertItems( 0, m_AchievementList.ListSize);

	DebugMsg("AchievementList","%d Items inserted into list", m_AchievementList.ListSize);

	SetCurSel(0);
	
	return S_OK;
}
Exemple #18
0
	/// @brief	current locale change.
	/// @param	sSrc	source string (utf8)
	/// @return	 change string
	string ChgCurLocale(const string& sStr)
	{
		#ifndef HAVE_ICONV
			return sStr;
		#endif

		#ifndef 	__CYGWIN_C__
		bool bUS = true;
		wstring	wstr = strtowstr(sStr);
		if (wstr.size() != 0)
		{
			for (int n = 0; n < (int)wstr.size(); n++)
			{
				if (wstr[n] > 0x80) {
					bUS = false;
					break;
				}
			}
			if ( bUS ) return sStr;
		}
		#endif

		return KorCodeChg( sStr, e_nCurLang );
	}
// handles the kai message when a player leaves the general chat
void ChatManager::OnLeavesChat( string aOpponent ) {

	if( bChatActive == false ) return;

	CHAT_LOCK;		// Lock
	
	// Iterate through the list of players to search for the player leaving
	vector<CKaiPlayer>::iterator itr; bool bFoundPlayer = false;
	for(itr = m_vChatPlayers.begin(); itr != m_vChatPlayers.end(); ++itr) {
		wstring aOpponentW = strtowstr(aOpponent);
		if(wcscmp((*itr).GetPlayerName(),aOpponentW.c_str()) == 0)	{
			bFoundPlayer = true;
			break;
		}
	}

	// Check if we found a matching player, and if so, erase it from the list
	if(bFoundPlayer == true ) {
		m_vChatPlayers.erase(itr);
	}

	CHAT_UNLOCK;		// Unlock

}
HRESULT CScnOptionsContentSettings::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandled )
{
	if( hObjPressed == m_UseBackgrounds ) {
		SETTINGS::getInstance().setUseBackground(1 - SETTINGS::getInstance().getUseBackground());
		m_UseBackgrounds.SetCheck(SETTINGS::getInstance().getUseBackground());
		bHandled = TRUE;
	} else if( hObjPressed == m_UseScreenshots ) {
		SETTINGS::getInstance().setUseScreenshots(1 - SETTINGS::getInstance().getUseScreenshots());
		m_UseScreenshots.SetCheck(SETTINGS::getInstance().getUseScreenshots());
		bHandled = TRUE;
	} else if( hObjPressed == m_GameListVisual ) {
		SETTINGS::getInstance().setGameListVisual(m_GameListVisual.GetCurSel());
		for (unsigned int nCount = 0; nCount < 3; nCount++) {
			m_GameListVisual.SetItemCheck(nCount, FALSE);
		}
		m_GameListVisual.SetItemCheck(SETTINGS::getInstance().getGameListVisual(), TRUE);
		bHandled = TRUE;
	} else if( hObjPressed == m_GameListTransition ) {
		SETTINGS::getInstance().setGameListTransition(m_GameListTransition.GetCurSel());
		for (unsigned int nCount = 0; nCount < 3; nCount++) {
			m_GameListTransition.SetItemCheck(nCount, FALSE);
		}
		m_GameListTransition.SetItemCheck(SETTINGS::getInstance().getGameListTransition(), TRUE);
		bHandled = TRUE;
	
	} else if( hObjPressed == m_LocaleList ) {
		// Nothing happens here

	} else if( hObjPressed == m_SetLocale ) {
		if( strcmp(m_szSelectedLocale.c_str(), "Select New Locale") != 0 ) {
			string szLocaleCode = m_LocaleMap[m_szSelectedLocale];
			SETTINGS::getInstance().setLocale(szLocaleCode);
			m_szCurrentLocale = m_szSelectedLocale;
			m_CurrentLocale.SetText(strtowstr(m_szCurrentLocale).c_str());

		} else {
			XNotifyQueueUICustom(L"Please select a new locale from the locale list");

		}
		bHandled = TRUE;

	} else if( hObjPressed == m_ManagePaths ) {
		// XUI Handles this

	} else if( hObjPressed == m_DownloadIcons ) {
		SETTINGS::getInstance().setDownloadIcon(1 - SETTINGS::getInstance().getDownloadIcon());
		m_DownloadIcons.SetCheck(SETTINGS::getInstance().getDownloadIcon());
		bHandled = TRUE;
	} else if( hObjPressed == m_DownloadBoxart ) {
		SETTINGS::getInstance().setDownloadBoxart(1 - SETTINGS::getInstance().getDownloadBoxart());
		m_DownloadBoxart.SetCheck(SETTINGS::getInstance().getDownloadBoxart());
		bHandled = TRUE;
	} else if( hObjPressed == m_DownloadBanners ) {
		SETTINGS::getInstance().setDownloadBanner(1 - SETTINGS::getInstance().getDownloadBanner());
		m_DownloadBanners.SetCheck(SETTINGS::getInstance().getDownloadBanner());
		bHandled = TRUE;
	} else if( hObjPressed == m_DownloadScreenshots ) {
		SETTINGS::getInstance().setDownloadScreenshots(1 - SETTINGS::getInstance().getDownloadScreenshots());
		m_DownloadScreenshots.SetCheck(SETTINGS::getInstance().getDownloadScreenshots());
		bHandled = TRUE;
	} else if( hObjPressed == m_DownloadBackgrounds ) {
		SETTINGS::getInstance().setDownloadBackground(1 - SETTINGS::getInstance().getDownloadBackground());
		m_DownloadBackgrounds.SetCheck(SETTINGS::getInstance().getDownloadBackground());
		bHandled = TRUE;
	} else if( hObjPressed == m_DownloadVideos ) {
		SETTINGS::getInstance().setDownloadVideo(1 - SETTINGS::getInstance().getDownloadVideo());
		m_DownloadVideos.SetCheck(SETTINGS::getInstance().getDownloadVideo());
		bHandled = TRUE;
	} else if( hObjPressed == m_AutoResumeAssets ) {
		SETTINGS::getInstance().setResumeAssetDownload(1 - SETTINGS::getInstance().getResumeAssetDownload());
		m_AutoResumeAssets.SetCheck(SETTINGS::getInstance().getResumeAssetDownload());
		bHandled = TRUE;
	} else if( hObjPressed == m_DisableAutoScan ) {
		SETTINGS::getInstance().setDisableAutoScan(1- SETTINGS::getInstance().getDisableAutoScan());
		m_DisableAutoScan.SetCheck(SETTINGS::getInstance().getDisableAutoScan());
		bHandled = TRUE;
	} else if( hObjPressed == m_StartManualScan) {
		DebugMsg("ScnOptionsContentSettings", "Start Manual Scan Button pressed.");
		vector<ScanPath> ScanPaths = FSDSql::getInstance().getScanPaths();
		if(ScanPaths.size() > 0) {
			if(ContentManager::getInstance().IsCurrentlyScanning() == FALSE)
			{
				for(unsigned int x = 0; x < ScanPaths.size(); x++)
				{
					ContentManager::getInstance().AddScanPath(ScanPaths.at(x));
				}
			}
			else
			{
				XNotifyQueueUICustom(L"The Scanning Queue is currently busy.  Please try again once scanning has completed.");
			}
		}
		else
		{
			XNotifyQueueUICustom(L"There are currently no defined Scan Paths.  Please add paths and try again.");
		}
		bHandled = TRUE;
	} else if (hObjPressed == m_CoverDownload) {
		if (SETTINGS::getInstance().getCoverCheck())
		  SETTINGS::getInstance().setCoverCheck(false);
		else SETTINGS::getInstance().setCoverCheck(true);
		ContentManager::getInstance().UpdateTimer();
		m_CoverDownload.SetCheck(SETTINGS::getInstance().getCoverCheck());
		bHandled = TRUE;
	} else if( hObjPressed == m_CoverUser ) {
		memset(&m_kbOverlapped, 0, sizeof(m_kbOverlapped));
		memset(m_kbBuffer, 0, sizeof(m_kbBuffer));

		// Convert our string to a wstring
		m_szTemp = strtowstr(m_szUsername);

		// Set Variables to display our Keyboard
		m_dwKeyboardMode = KBMODE_USERNAME;
		XShowKeyboardUI(0, VKBD_DEFAULT, m_szTemp.c_str(), m_szKeyboardUsernameCaption.c_str(), m_szKeyboardUsernamePrompt.c_str(),
			m_kbBuffer, 32, &m_kbOverlapped);
		SetTimer(TM_KEYBOARD, 50);
		bHandled = TRUE;

	} else if( hObjPressed == m_CoverPass ) {
		memset(&m_kbOverlapped, 0, sizeof(m_kbOverlapped));
		memset(m_kbBuffer, 0, sizeof(m_kbBuffer));

		// Convert our string to a wstring
		m_szTemp = strtowstr(m_szPassword);

		// Set Variables to display our Keyboard
		m_dwKeyboardMode = KBMODE_PASSWORD;
		XShowKeyboardUI(0, VKBD_DEFAULT, m_szTemp.c_str(), m_szKeyboardPasswordCaption.c_str(), m_szKeyboardPasswordPrompt.c_str(),
			m_kbBuffer, 32, &m_kbOverlapped);
		SetTimer(TM_KEYBOARD, 50);
		bHandled = TRUE;
	} else if( hObjPressed == m_CoverLowRes) {
		m_CoverLowRes.SetCheck(TRUE);
		m_CoverMedRes.SetCheck(FALSE);
		m_CoverHighRes.SetCheck(FALSE);
		SETTINGS::getInstance().setCoverQuality(2);
	} else if( hObjPressed == m_CoverMedRes) {
		m_CoverLowRes.SetCheck(FALSE);
		m_CoverMedRes.SetCheck(TRUE);
		m_CoverHighRes.SetCheck(FALSE);
		SETTINGS::getInstance().setCoverQuality(1);
	} else if( hObjPressed == m_CoverHighRes) {
		m_CoverLowRes.SetCheck(FALSE);
		m_CoverMedRes.SetCheck(FALSE);
		m_CoverHighRes.SetCheck(TRUE);
		SETTINGS::getInstance().setCoverQuality(0);
	} else {
		// Button press not recognized

	}

	// Return successfully
	return S_OK;
}
Exemple #21
0
	/// @brief	현재 사용하는 코드로 바꿔준다. US 면 utf-8로 바꾼다.
	/// @param	sSrc	문자열
	/// @param	eEncode	리턴 현재 인코드
	/// @return	 바꾼 문자열
	string	isKorCode(const string& sSrc, ENCODING* eEncode)
	{
		string	sCodeConvertStr;
		string	strData1, strData2;
		if (eEncode != NULL) *eEncode = US;
		if (sSrc == "") return "";
		bool 	bUS = true;
		
		#ifndef 	__CYGWIN_C__
		
		wstring	wstr = strtowstr(sSrc);
		if (wstr.size() != 0)
		{
			for (int n = 0; n < (int)wstr.size(); n++)
			{
				if (wstr[n] > 0x80) {
					bUS = false;
					break;
				}
			}
			if (bUS == true) {
				if (eEncode != NULL) *eEncode = US;
				return sSrc;
			}
		}
		
		#else
		
		unsigned char cData;

		if (sSrc.size() != 0)
		{
			for (int n = 0; n < (int)sSrc.size(); n++)
			{
				cData = sSrc[n];
				if (cData > 0x0080) {
					bUS = false;
					break;
				}
			}
			if (bUS == true) {
				if (eEncode != NULL) *eEncode = US;
				return sSrc;
			}
		}
		#endif

		if (e_nCurLang == KO_EUCKR)
		{
			#ifndef HAVE_ICONV
				sCodeConvertStr = sSrc;
				if (eEncode != NULL) *eEncode = KO_EUCKR;
				return sCodeConvertStr;
			#endif

			// EUCKR 로 본다.
			strData1 = CodeConvert(sSrc, "UTF-8", "EUC-KR"); 			// UTF8 로 바꿔봄.	
	
			if ( strData1 == "" )
			{
				// 현재 : UTF8
				strData1 = CodeConvert(sSrc, "EUC-KR", "UTF-8"); 		// EUCKR 로 바꿔봄.
				strData2 = CodeConvert(strData1, "UTF-8", "EUC-KR");	// UTF8 로 바꿔봄.
				
				if ( strData1 != "" && sSrc == strData2 )
				{
					if (eEncode != NULL) *eEncode = KO_UTF8;
					return strData1;
				}
			}
			else
			{
				strData2 = CodeConvert(strData1, "EUC-KR", "UTF-8"); 		// EUCKR 로 바꿔봄.	
				if ( sSrc == strData2 )
				{
					if (eEncode != NULL) *eEncode = KO_EUCKR;
					return sSrc; // UTF8
				}
			}	
		}
		else // 나머지는 utf-8로 바꿈.
		{
			#ifndef HAVE_ICONV
				sCodeConvertStr = sSrc;
				if (eEncode != NULL) *eEncode = KO_UTF8;
				return sCodeConvertStr;
			#endif
			
			// 현재 : UTF8
			strData1 = CodeConvert(sSrc, "EUC-KR", "UTF-8"); 			// EUCKR 로 바꿔봄.
			
			if ( strData1 == "" )
			{
				// EUCKR 로 본다.
				strData1 = CodeConvert(sSrc, "UTF-8", "EUC-KR"); 		// UTF8 로 바꿔봄.
				strData2 = CodeConvert(strData1, "EUC-KR", "UTF-8"); 	// EUCKR 로 바꿔봄.
				
				if ( strData1 != "" && sSrc == strData2 )
				{
					if (eEncode != NULL) *eEncode = KO_EUCKR;
					return strData1;
				}
			}
			else
			{	
				strData2 = CodeConvert(strData1, "UTF-8", "EUC-KR"); 		// UTF8 로 바꿔봄.
				
				if ( sSrc == strData2 )
				{
					if (eEncode != NULL) *eEncode = KO_UTF8;
					return sSrc; // UTF8
				}
			}	
		}
		return sSrc;
	}
HRESULT CScnOptionsContentSettings::ReadUserSettings( void )
{
	// Set initial state of Cover Downloading Settings Controls
	m_CoverPoll.SetValue(SETTINGS::getInstance().getCoverPoll());
	m_CoverDownload.SetCheck(SETTINGS::getInstance().getCoverCheck());
	wstring NewValue = sprintfaW(L"Current: %d mins", SETTINGS::getInstance().getCoverPoll());
	m_CurrentPoll.SetText(NewValue.c_str());
	m_szUsername = SETTINGS::getInstance().getCoverUser();
	NewValue = strtowstr(m_szUsername);
	if (m_szUsername != "")
		m_CoverUser.SetText(NewValue.c_str());
	m_szPassword = SETTINGS::getInstance().getCoverPass();
	if (m_szPassword != "")
		m_CoverPass.SetText(strtowstr(GetPasswordMask(m_szPassword.length(), "*")).c_str());
	
	// Set initial state of Game List Setting controls
	m_UseBackgrounds.SetCheck(SETTINGS::getInstance().getUseBackground());
	m_UseScreenshots.SetCheck(SETTINGS::getInstance().getUseScreenshots());

	// Set initial state of Marketplace Option controls
	m_DownloadIcons.SetCheck(SETTINGS::getInstance().getDownloadIcon());
	m_DownloadBoxart.SetCheck(SETTINGS::getInstance().getDownloadBoxart());
	m_DownloadBanners.SetCheck(SETTINGS::getInstance().getDownloadBanner());
	m_DownloadScreenshots.SetCheck(SETTINGS::getInstance().getDownloadScreenshots());
	m_DownloadBackgrounds.SetCheck(SETTINGS::getInstance().getDownloadBackground());
	m_DownloadVideos.SetCheck(SETTINGS::getInstance().getDownloadVideo());

	m_ScreenshotSlider.SetValue(SETTINGS::getInstance().getMaxScreenshots());
	wstring szSliderText = sprintfaW(L"%d", SETTINGS::getInstance().getMaxScreenshots());
	m_ScreenshotCountText.SetText(szSliderText.c_str());

	// Set intial state of Game List Visual List
	for( unsigned int nCount = 0; nCount < 3; nCount++ ) {
		m_GameListVisual.SetItemCheck( nCount, FALSE );
	}
	m_GameListVisual.SetItemCheck( SETTINGS::getInstance().getGameListVisual(), TRUE );

	// Set intial state of Game List Transition List
	for( unsigned int nCount = 0; nCount < 3; nCount++ ) {
		m_GameListTransition.SetItemCheck( nCount, FALSE );
	}
	m_GameListTransition.SetItemCheck( SETTINGS::getInstance().getGameListTransition(), TRUE );

	// Set initial state of Marketplace Locale controls
	m_szCurrentLocaleCode = SETTINGS::getInstance().getLocale();
	
	// Fill List Items
	m_LocaleList.InsertItems(0, m_LocaleMap.size() + 1);
	m_LocaleList.SetText(0, L"Select New Locale");
	unsigned int nCount = 1;
	unsigned int nCurSel = 0;
	map<string, string>::iterator iter;
	for( iter = m_LocaleMap.begin(); iter != m_LocaleMap.end(); ++iter) {
		m_LocaleList.SetText( nCount, strtowstr((*iter).first).c_str() );
		DebugMsg("Locale", "Locale Found:  %s", (*iter).first.c_str());
		if( strcmp((*iter).second.c_str(), m_szCurrentLocaleCode.c_str())== 0) {
			m_szCurrentLocale = (*iter).first;
			nCurSel = nCount;
		}
		nCount++;
	}
	// Set the current locale text and some member variables for later use
	m_CurrentLocale.SetText(L"");
	m_CurrentLocale.SetText(strtowstr(m_szCurrentLocale).c_str());
	m_szSelectedLocale = "Select New Locale";
	
	// Set initial state for other stuff here
	m_AutoResumeAssets.SetCheck(SETTINGS::getInstance().getResumeAssetDownload());
	m_DisableAutoScan.SetCheck(SETTINGS::getInstance().getDisableAutoScan());

	// Initalize the check boxes for the cover quality
	switch ( SETTINGS::getInstance().getCoverQuality() ) {
		case 0:		// High Resolution
			m_CoverLowRes.SetCheck(FALSE);
			m_CoverMedRes.SetCheck(FALSE);
			m_CoverHighRes.SetCheck(TRUE);
			break;
		case 1:		// Medium Resolution
			m_CoverLowRes.SetCheck(FALSE);
			m_CoverMedRes.SetCheck(TRUE);
			m_CoverHighRes.SetCheck(FALSE);
			break;
		case 2:		// Low Resolution
			m_CoverLowRes.SetCheck(TRUE);
			m_CoverMedRes.SetCheck(FALSE);
			m_CoverHighRes.SetCheck(FALSE);
			break;
	}
	// *** Future

	return S_OK;
}
//----------------------------------------------------------------------------------
// Handler for the button press message.
//----------------------------------------------------------------------------------
HRESULT CScnGameControls::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandled )
{
	if(hObjPressed == m_GameScreenshots) {
		// Launch the Game Screenshots Scene
		SkinManager::getInstance().setScene("screenshots.xur", *this, false);
		bHandled = true;

	} else if (hObjPressed == m_GameSaves) {
		// Launch the Game Saves Scene
		SkinManager::getInstance().setScene("savedgames.xur", *this, false);
		bHandled = true;

	} else if (hObjPressed == m_ManageTUs) {
		// Launch the Title Update Manager Scene
		SkinManager::getInstance().setScene("TitleUpdateManager.xur", *this, false);
		bHandled = true;

	} else if (hObjPressed == m_Achievements) {
		// Launch the Achievements Scene
		SkinManager::getInstance().setScene("Achievements.xur", *this, false);
		bHandled = true;

	} else if (hObjPressed == m_ManageTrainers) {
		// Launch the Trainers Scene
		if(PluginLoader::getInstance().IsLoaded() == TRUE) { 
			SkinManager::getInstance().setScene("Trainers.xur", this->m_hObj, false, "Trainers", NULL);
		}else {
			XNotifyQueueUICustom(L"This feature requires that you run the FSDPlugin.");
		}
		bHandled = true;
	} else if (hObjPressed == m_RenameGame) {
		// Initiate the Rename Process
		memset(&xoKeyboard, 0, sizeof(xoKeyboard));
		LPCWSTR szGameTitle = listPack.CurrentGame->Content.m_szTitle;
		// Launch Keyboard Scene to rename game
		XShowKeyboardUI(0, VKBD_DEFAULT, szGameTitle, szRenameCaption, szRenameDescription, 
			kbBuffer, 200, &xoKeyboard);
		SetTimer(TM_KEYBOARD, 50);
		bHandled = true;

	} else if (hObjPressed == m_DeleteGame) {
		// Laucnh a Message Box for Game Deletion
//		string szGameTitle = wstrtostr(listPack.CurrentGame->Content.m_szTitle);
//		szTempString = sprintfaW(szDeleteDescription, szGameTitle.c_str());
		nMsgType = 1;
		if (listPack.CurrentGame->ContentRef->GetFileType() == CONTENT_FILE_TYPE_CONTAINER)
			szTempStringPath = strtowstr(listPack.CurrentGame->ContentRef->getRoot()) + strtowstr(listPack.CurrentGame->ContentRef->getPath());
		else 
			szTempStringPath = strtowstr(listPack.CurrentGame->ContentRef->getRoot()) + strtowstr(listPack.CurrentGame->ContentRef->getDirectory());
		szTempString = sprintfaW(szDeleteDescription, listPack.CurrentGame->Content.m_szTitle, szTempStringPath.c_str());
		ShowMessageBoxEx(L"XuiMessageBox2", CFreestyleUIApp::getInstance().GetRootObj(), szDeleteCaption,
			szTempString.c_str(), 2, szBtnOk, 1, NULL, NULL);
		bHandled = true;

	} else if (hObjPressed == m_MoveGame) {
		if(bIsNested) {
			m_GameControls.FindNamedFrame(L"MoveGame", &nFrameStart);
			m_GameControls.FindNamedFrame(L"EndMoveGame", &nFrameEnd);

			m_GameControls.PlayTimeline(nFrameStart, nFrameStart, nFrameEnd, false, false);
		} else {
			this->FindNamedFrame(L"MoveGame", &nFrameStart);
			this->FindNamedFrame(L"EndMoveGame", &nFrameEnd);

			this->PlayTimeline(nFrameStart, nFrameStart, nFrameEnd, false, false);
		}
		m_MoveXbox360.SetFocus(XUSER_INDEX_ANY);
		bBackToMain = true;
		m_Back.SetText(L"Cancel");
		bHandled = true;

	} else if (hObjPressed == m_Back) {
		if(bBackToMain)	{
			if(bIsNested) {
				m_GameControls.FindNamedFrame(L"BackToMain", &nFrameStart);
				m_GameControls.FindNamedFrame(L"EndBackToMain", &nFrameEnd);

				m_GameControls.PlayTimeline( nFrameStart, nFrameStart, nFrameEnd, false, false);
			} else {
				this->FindNamedFrame(L"BackToMain", &nFrameStart);
				this->FindNamedFrame(L"EndBackToMain", &nFrameEnd);

				this->PlayTimeline( nFrameStart, nFrameStart, nFrameEnd, false, false);
			}

			m_GameScreenshots.SetFocus(XUSER_INDEX_ANY);
			bBackToMain = false;
			m_Back.SetText(L"Back");
		} else {
			NavigateBack(XUSER_INDEX_ANY);
		}
		bHandled = true;

	}else if (hObjPressed == m_DownloadGame) {
		// Start downloading of assets to refresh
		if(CFreestyleApp::getInstance().hasInternetConnection() == false) {
			XNotifyQueueUICustom(L"No network connection detected.");
		} else {
			pContentItem->RefreshAssets();
		}
		bHandled = true;

	// Handle all the Content Moves
	} else if (hObjPressed == m_MoveXbox360) {
		ReloadContent(CONTENT_360);
		bHandled = true;
	} else if (hObjPressed == m_MoveXBLA) {
		ReloadContent(CONTENT_XBLA);
		bHandled = true;
	} else if (hObjPressed == m_MoveHomebrew) {
		ReloadContent(CONTENT_HOMEBREW); 
		bHandled = true;
	} else if (hObjPressed == m_MoveXbox1) {
		ReloadContent(CONTENT_XBOX1);
		bHandled = true;
	} else if (hObjPressed == m_MoveEmulators) {
		ReloadContent(CONTENT_EMULATOR);
		bHandled = true;
	}else if (hObjPressed == m_MoveNoSection) {
		nMsgType = 2;
		if (listPack.CurrentGame->ContentRef->GetFileType() == CONTENT_FILE_TYPE_CONTAINER)
			szTempStringPath = strtowstr(listPack.CurrentGame->ContentRef->getRoot()) + strtowstr(listPack.CurrentGame->ContentRef->getPath());
		else 
			szTempStringPath = strtowstr(listPack.CurrentGame->ContentRef->getRoot()) + strtowstr(listPack.CurrentGame->ContentRef->getDirectory());
		
		szTempString = sprintfaW(szRemoveDescription, listPack.CurrentGame->Content.m_szTitle, szTempStringPath.c_str() );
		ShowMessageBoxEx(L"XuiMessageBox2", CFreestyleUIApp::getInstance().GetRootObj(), szRemoveCaption,
			szTempString.c_str(), 2, szBtnOk, 1, NULL, NULL);
		bHandled = true;
	}
    return S_OK;
}
void DVDWorker::ExtractCurrentUnknownItem() {
	m_CurrentItem->setTitle(strtowstr("Unrecognized Disc"));
	// Trigger the download complete function
	if(m_CurrentItem->requester != NULL)
		m_CurrentItem->requester->ExtractCompleted(m_CurrentItem);	
}
void DVDWorker::ExtractCurrentDataDVDItem() {
	m_CurrentItem->setTitle(strtowstr("Data DVD/CD"));
	// Trigger the download complete function
	if(m_CurrentItem->requester != NULL)
		m_CurrentItem->requester->ExtractCompleted(m_CurrentItem);	
}
DayBreak::DayBreak(const std::string &dayString, int width, Font &font)
	: width(width), font(font)
{
	dayStringW = strtowstr(dayString);
}
ChatControlMessageFrame::ChatControlMessageFrame(ChatControlMessage *message, int width, int color, HFONT dateFont)
    : message(message), width(width), color(color), height(0), dateFont(dateFont)
{
    wcharDate = strtowstr(formatTimestamp(message->getMessage().getTimestamp()));
}
void ContentManager::ScanDirectory(ScanPath* ScanPath, string Directory, int Levels) {
    
	// Check to make sure the default path doesnt already exist in the database
	string defaultFilePath = Directory + "default.xex";
	string defaultPath = defaultFilePath.substr(defaultFilePath.find_first_of(":") + 1);
	DebugMsg("ContentManager", "File Path : %s", defaultFilePath.c_str());
	if(FSDSql::getInstance().ItemPathExistsInDB(defaultPath, ScanPath)) {
		return;
	}

	// Check to make sure the default path doesnt already exist in the database
	defaultFilePath = Directory + "default.xbe";
	defaultPath = defaultFilePath.substr(defaultFilePath.find_first_of(":") + 1);
	DebugMsg("ContentManager", "File Path : %s", defaultFilePath.c_str());
	if(FSDSql::getInstance().ItemPathExistsInDB(defaultPath, ScanPath)) {
		return;
	}


	if(Levels == ScanPath->ScanDepth - 1)
		szStatusMsg = strtowstr(Directory);

	// Try and create default.xex
	ContentItemNew* item = ContentItemNew::CreateItem(ScanPath, Directory, "default.xex");
	if(item != NULL) {
		
		// We found a valid item so no need to continue
		AddItem(item);
		return;
	}

	// Try and create default.xbe
	item = ContentItemNew::CreateItem(ScanPath, Directory, "default.xbe");
	if(item != NULL) {
		
		// We found a valid item so no need to continue
		AddItem(item);
		return;
	}

	// Start finding our files
	string strFind = Directory + "*";
    WIN32_FIND_DATA wfd; HANDLE hFind;
    hFind = FindFirstFile( strFind.c_str(), &wfd );
    if(hFind == INVALID_HANDLE_VALUE) return;

	// Loop and find each
	do {

		// Lets check if this is a directory (and make sure its not our default!)
		if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
			
			string nextDirectory = Directory + wfd.cFileName + "\\";
			if(Levels == -1)
				ScanDirectory(ScanPath, nextDirectory, -1);
			else if(Levels > 0)
				ScanDirectory(ScanPath, nextDirectory, Levels - 1);

			continue;
		}

		// Make sure its not in our db
		string filePath = Directory + wfd.cFileName;
		string filePathShort = filePath.substr(filePath.find_first_of(":") + 1);
		if(FSDSql::getInstance().ItemPathExistsInDB(filePathShort, ScanPath))
			continue;
		
		// Try and create our item
		ContentItemNew* item = ContentItemNew::CreateItem(ScanPath, 
			Directory, wfd.cFileName);
		if(item != NULL)
			AddItem(item);

	}while(FindNextFile(hFind, &wfd));

	// Done finding
	FindClose( hFind );
}
WCHAR *buildWcharString(const std::string &text)
{
	return buildWcharString(strtowstr(text));
}