コード例 #1
0
ファイル: CLanguageTokenizer.cpp プロジェクト: kbjava/haiku
Token&
Tokenizer::_ParseHexOperand()
{
	const char* begin = fCurrentChar;
	fCurrentChar += 2;
		// skip "0x"

	if (!_IsHexDigit(*fCurrentChar))
		throw ParseException("expected hex digit", _CurrentPos());

	fCurrentChar++;
	while (_IsHexDigit(*fCurrentChar))
		fCurrentChar++;

	int32 length = fCurrentChar - begin;
	fCurrentToken = Token(begin, length, _CurrentPos() - length,
		TOKEN_CONSTANT);

	if (length <= 10) {
		// including the leading 0x, a 32-bit constant will be at most
		// 10 characters. Anything larger, and 64 is necessary.
		fCurrentToken.value.SetTo((uint32)strtoul(
			fCurrentToken.string.String(), NULL, 16));
	} else {
		fCurrentToken.value.SetTo((uint64)strtoull(
			fCurrentToken.string.String(), NULL, 16));
	}
	return fCurrentToken;
}
コード例 #2
0
//-----------------------------------------------------------------------------
// Read Webserver Configurationfile for languages
//-----------------------------------------------------------------------------
void Cyhttpd::ReadLanguage(void) {
	// Init Class vars
	CLanguage *lang = CLanguage::getInstance();
	log_level_printf(3, "ReadLanguage:%s\n",
			ConfigList["Language.selected"].c_str());
	lang->setLanguage(ConfigList["Language.selected"]);
}
コード例 #3
0
ATMO_BOOL CAtmoColorPicker::InitDialog(WPARAM wParam) 
{
	CLanguage *Lng = new CLanguage;

	HWND hwndCtrl;
	hwndCtrl = this->getDlgItem(IDC_EDT_RED);
	Edit_LimitText(hwndCtrl,3);
	hwndCtrl = this->getDlgItem(IDC_EDT_GREEN);
	Edit_LimitText(hwndCtrl,3);
	hwndCtrl = this->getDlgItem(IDC_EDT_BLUE);
	Edit_LimitText(hwndCtrl,3);

	hwndCtrl = this->getDlgItem(IDC_SL_RED);
	SendMessage(hwndCtrl, TBM_SETRANGEMIN, 0, 0);
	SendMessage(hwndCtrl, TBM_SETRANGEMAX, 0, 255);
	SendMessage(hwndCtrl, TBM_SETPOS, 1, this->m_iRed);
	SendMessage(hwndCtrl, TBM_SETTICFREQ, 8, 0);

	hwndCtrl = this->getDlgItem(IDC_SL_GREEN);
	SendMessage(hwndCtrl, TBM_SETRANGEMIN, 0, 0);
	SendMessage(hwndCtrl, TBM_SETRANGEMAX, 0, 255);
	SendMessage(hwndCtrl, TBM_SETPOS, 1, this->m_iGreen);
	SendMessage(hwndCtrl, TBM_SETTICFREQ, 8, 0);

	hwndCtrl = this->getDlgItem(IDC_SL_BLUE);
	SendMessage(hwndCtrl, TBM_SETRANGEMIN, 0, 0);
	SendMessage(hwndCtrl, TBM_SETRANGEMAX, 0, 255);
	SendMessage(hwndCtrl, TBM_SETPOS, 1, this->m_iBlue);
	SendMessage(hwndCtrl, TBM_SETTICFREQ, 8, 0);

	UpdateColorControls(ATMO_TRUE, ATMO_TRUE);

	Lng->szCurrentDir[Lng->SetLngPath()];

	sprintf(Lng->szFileINI, "%s\\Language.ini\0", Lng->szCurrentDir);

	GetPrivateProfileString("Common", "Language", "English", Lng->szLang, 256, Lng->szFileINI);

	// Read Buffer from IniFile
	sprintf(Lng->szTemp, "%s\\%s.xml\0", Lng->szCurrentDir, Lng->szLang);

	Lng->XMLParse(Lng->szTemp, Lng->sTextCPicker, "ColorPicker");

	SendMessage(getDlgItem(IDC_STATIC22), WM_SETTEXT, 0, (LPARAM)(LPCTSTR)(Lng->sTextCPicker[0]));
	SendMessage(getDlgItem(IDC_STATIC23), WM_SETTEXT, 0, (LPARAM)(LPCTSTR)(Lng->sTextCPicker[1]));
	SendMessage(getDlgItem(IDC_STATIC24), WM_SETTEXT, 0, (LPARAM)(LPCTSTR)(Lng->sTextCPicker[2]));
	SendMessage(this->m_hDialog, WM_SETTEXT, 0, (LPARAM)(LPCTSTR)(Lng->sTextCPicker[3]));
	SendMessage(getDlgItem(IDCANCEL), WM_SETTEXT, 0, (LPARAM)(LPCTSTR)(Lng->sTextCPicker[4]));

	return ATMO_TRUE;

}
コード例 #4
0
void CSelectLanguageDlg::ListLanguages(CString sLanguageFolder)
{
	// Declare variables
	WIN32_FIND_DATA wfd;
	HANDLE hFile;
	CString sFile;
	CString sSpec = sLanguageFolder + _T("*.xml");
	CString sPathFile;
	CLanguage * pLanguage = CLanguage::Instance();
	CFunctions * pFunctions = CFunctions::Instance();
	CPath * pPath = CPath::Instance();
	LanguageType oLangType;

	// Find the first file
	hFile = FindFirstFile(sSpec, &wfd);

	if (hFile != INVALID_HANDLE_VALUE)
	{
		do
		{
			// Get file info
			sFile = wfd.cFileName;
			sPathFile = sLanguageFolder + sFile;

			// Get language info
			if (pLanguage->LoadLanguage(sPathFile, _T(""), false))
			{
				// Check if it is the right version
				if (pFunctions->CompareVersions(pLanguage->GetLanguageVersion(), VERSION_LANGUAGE) != COMPAREVERSION_FIRSTSMALLER)
				{
					// Add to list of languages
					oLangType.sFilename = pPath->StripFileExtension(pPath->ExtractFileName(sPathFile));
					oLangType.sDescription = pLanguage->GetLanguageName();
					m_arrLanguages[m_iLanguageCount++] = oLangType;
				}
			}
		}
		while (FindNextFile(hFile, &wfd));

		// Close handle to file
		FindClose(hFile);
	}

	// Release last language
	pLanguage->ReleaseLanguage();
}
コード例 #5
0
ファイル: CLanguageTokenizer.cpp プロジェクト: kbjava/haiku
void
Tokenizer::SetTo(const char* string)
{
	fString = string;
	fCurrentChar = fString.String();
	fCurrentToken = Token();
	fReuseToken = false;
}
コード例 #6
0
ファイル: q4.cpp プロジェクト: elitak/gamescanner
DWORD Q4_ConnectToMasterServer(GAME_INFO *pGI, int iMasterIdx)
{
	size_t packetlen=0;
	char sendbuf[40];
	ZeroMemory(sendbuf,sizeof(sendbuf));
	
	int len = 0;
	len = UTILZ_ConvertEscapeCodes(pGI->szMasterQueryString,sendbuf,sizeof(sendbuf));
	char szIP[260];
	strcpy(szIP,pGI->szMasterServerIP[iMasterIdx]);
	
	SplitIPandPORT(szIP,pGI->dwMasterServerPORT);

	dbg_print("Master server %s:%d",szIP,(unsigned short)pGI->dwMasterServerPORT);

	SOCKET ConnectSocket = getsockudp(szIP,(unsigned short)pGI->dwMasterServerPORT);
   
	if(INVALID_SOCKET==ConnectSocket)
	{
		dbg_print("Error connecting to socket!");
		return 1001;
	}
	dbg_print("Sending command %s Len: %d",sendbuf,len);
	if(send(ConnectSocket, sendbuf, len, 0)==SOCKET_ERROR) 
	{
		closesocket(ConnectSocket);		
		dbg_print("Error sending packet!");
		return 1002;
	}

	int i = 0;
	unsigned char *packet[iMAX_PACKETS];
	size_t packlen[iMAX_PACKETS];

	DWORD Q4_dwNewTotalServers=0;
	// Let's retrieve all packets as fast as possible, that's the reason for splitting up int two for loop.
	for(i=0; i<iMAX_PACKETS;i++)
	{
		packet[i] = NULL;
		packet[i]=(unsigned char*)getpacket(ConnectSocket, &packlen[i]);
		if(packet[i]==NULL) //End of transfer
			break;  	
	}
	//Now parse all server IP's from recieved packets
	for(i=0; i<iMAX_PACKETS;i++)
	{
		if(packet[i]==NULL) //End of packets
			break;  	
		Q4_dwNewTotalServers += Q4_ParseServers((char*)packet[i],packlen[i],pGI,Q4_InsertServerItem);
		SetStatusText(pGI->iIconIndex,g_lang.GetString("StatusReceivingMaster"),Q4_dwNewTotalServers,pGI->szGAME_NAME);		
		free(packet[i]);
	}
	
	closesocket(ConnectSocket);
	pGI->dwTotalServers = pGI->vSI.size();
	return 	0;
}
コード例 #7
0
ファイル: language.cpp プロジェクト: DeegC/ZeidonTools
int CEdit::GetLanguageDef( LPCTSTR pszName, CM_LANGUAGE *pLang )
{
   int cbLang = 0;
   for ( int i = 0; i < g_nLanguageCount; i++ )
   {
      CLanguage *pLangFound = g_pLanguages[ i ];
      if ( _tcsicmp( pLangFound->m_szName, pszName ) == 0 )
      {
         cbLang = pLangFound->GetSize();
         if ( pLang )
         {
            memcpy( pLang, pLangFound->m_pLang, cbLang );
         }
         break;
      }
   }

   return cbLang;
}
コード例 #8
0
ファイル: CLanguageTokenizer.cpp プロジェクト: kbjava/haiku
bool
Tokenizer::_ParseOperator()
{
	int32 type = TOKEN_NONE;
	int32 length = 0;
	switch (*fCurrentChar) {
		case '+':
			type = TOKEN_PLUS;
			length = 1;
			break;

		case '-':
			 if (_Peek() == '>') {
			 	type = TOKEN_MEMBER_PTR;
			 	length = 2;
			 } else {
				type = TOKEN_MINUS;
				length = 1;
			 }
			break;

		case '*':
			switch (_Peek()) {
				case '/':
					type = TOKEN_END_COMMENT_BLOCK;
					length = 2;
					break;
				default:
					type = TOKEN_STAR;
					length = 1;
					break;
			}
			break;

		case '/':
			switch (_Peek()) {
				case '*':
					type = TOKEN_BEGIN_COMMENT_BLOCK;
					length = 2;
					break;
				case '/':
					type = TOKEN_INLINE_COMMENT;
					length = 2;
					break;
				default:
					type = TOKEN_SLASH;
					length = 1;
					break;
			}
			break;

		case '%':
			type = TOKEN_MODULO;
			length = 1;
			break;

		case '^':
			type = TOKEN_BITWISE_XOR;
			length = 1;
			break;

		case '&':
			if (_Peek() == '&') {
			 	type = TOKEN_LOGICAL_AND;
			 	length = 2;
			} else {
				type = TOKEN_BITWISE_AND;
				length = 1;
			}
			break;

		case '|':
			if (_Peek() == '|') {
				type = TOKEN_LOGICAL_OR;
				length = 2;
			} else {
				type = TOKEN_BITWISE_OR;
				length = 1;
			}
			break;

		case '!':
			if (_Peek() == '=') {
				type = TOKEN_NE;
				length = 2;
			} else {
				type = TOKEN_LOGICAL_NOT;
				length = 1;
			}
			break;

		case '=':
			if (_Peek() == '=') {
				type = TOKEN_EQ;
				length = 2;
			} else {
				type = TOKEN_ASSIGN;
				length = 1;
			}
			break;

		case '>':
			if (_Peek() == '=') {
				type = TOKEN_GE;
				length = 2;
			} else {
				type = TOKEN_GT;
				length = 1;
			}
			break;

		case '<':
			if (_Peek() == '=') {
				type = TOKEN_LE;
				length = 2;
			} else {
				type = TOKEN_LT;
				length = 1;
			}
			break;

		case '~':
			type = TOKEN_BITWISE_NOT;
			length = 1;
			break;


		case '?':
			type = TOKEN_CONDITION;
			length = 1;
			break;

		case '.':
			type = TOKEN_MEMBER_PTR;
			length = 1;
			break;

		default:
			break;
	}

	if (length == 0)
		return false;

	fCurrentToken = Token(fCurrentChar, length, _CurrentPos(), type);
	fCurrentChar += length;

	return true;
}
コード例 #9
0
ファイル: BuddyManager.cpp プロジェクト: elitak/gamescanner
LRESULT CALLBACK Buddy_AddBuddyProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)

{
	static BOOL bEditBuddyname = FALSE;
	switch (message)
	{
	case WM_INITDIALOG:
		{
			SetDlgItemText(hDlg,IDC_STATIC_BUDDY_NAME,g_lang.GetString("BuddyName"));
			CenterWindow(hDlg);
			bEditBuddyname = (BOOL) lParam;
			if(bEditBuddyname) //Edit mode
			{

			//	if(pEditBuddy!=NULL)
				{
					if(itBuddyEdit->cMatchOnColorEncoded)
						CheckDlgButton(hDlg,IDC_CHECK_NO_COLOR_MATCH,BST_CHECKED);
					else			
						CheckDlgButton(hDlg,IDC_CHECK_NO_COLOR_MATCH,BST_UNCHECKED);

					if(itBuddyEdit->cMatchExact)
						CheckDlgButton(hDlg,IDC_CHECK_EXACT_MATCH,BST_CHECKED);
					else
						CheckDlgButton(hDlg,IDC_CHECK_EXACT_MATCH,BST_UNCHECKED);

					PostMessage(GetDlgItem(hDlg,IDC_EDIT_NICKNAME_FILTER),EM_SETSEL,0,strlen(itBuddyEdit->szPlayerName));
					PostMessage(GetDlgItem(hDlg,IDC_EDIT_NICKNAME_FILTER),EM_SETSEL,(WPARAM)-1,-1);
				}
				SetWindowText(hDlg,g_lang.GetString("TitleEditBuddy")); 
				SetDlgItemText(hDlg,IDC_EDIT_NICKNAME_FILTER,(TCHAR*)itBuddyEdit->szPlayerName);
			}
			else
			{
				SetWindowText(hDlg,g_lang.GetString("TitleAddBuddy")); 
			}
			SetFocus(GetDlgItem(hDlg,IDC_EDIT_NICKNAME_FILTER));
				
			//return TRUE;
			}
		break;
	case WM_COMMAND:

		if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) 
		{
			if(LOWORD(wParam) == IDOK)
			{
				char szBuddy[100];
			
				GetDlgItemText(hDlg,IDC_EDIT_NICKNAME_FILTER,szBuddy,sizeof(szBuddy)-1);
				if(!bEditBuddyname)
				{					
					bm.Add(szBuddy,NULL);
					bm.UpdateList();
				}else if(bEditBuddyname)
				{
					strcpy_s(itBuddyEdit->szPlayerName,szBuddy);
					itBuddyEdit->cMatchOnColorEncoded = IsDlgButtonChecked(hDlg,IDC_CHECK_NO_COLOR_MATCH);
					itBuddyEdit->cMatchExact = IsDlgButtonChecked(hDlg,IDC_CHECK_EXACT_MATCH);
				}

			}
			EndDialog(hDlg, LOWORD(wParam));
			return TRUE;
		}
		break;
	}
	return FALSE;
}
コード例 #10
0
ファイル: BuddyManager.cpp プロジェクト: elitak/gamescanner
LRESULT APIENTRY Buddy_ListViewSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 
{ 
	HMENU hPopMenu;
	 if(uMsg == WM_COMMAND)
	 {
			DWORD wmId;
			DWORD wmEvent;
			wmId    = LOWORD(wParam); 
			wmEvent = HIWORD(wParam); 
			// Parse the menu selections:
			switch (wmId)
			{
				case IDM_EDIT_BUDDY:
					{
					
						//pEditBuddy = Buddy_GetBuddyInfoBySelection();
						itBuddyEdit = bm.FindBuddyInfoByID(bm.GetBuddyIDBySelection());
						if(itBuddyEdit!=bm.BuddyList.end())
						{						
							DialogBoxParam(g_hInst, (LPCTSTR)IDD_DLG_ADD_BUDDY, g_hWnd, (DLGPROC)Buddy_AddBuddyProc,TRUE);
						}
						bm.UpdateList();
					}
				break;
				case IDM_REFRESH:				
				break;
				case IDM_ADD:
					bm.Buddy_Add(g_hInst,g_hWnd,true);					
				break;
				case IDM_DELETE:
					bm.Remove();
				break;
				case IDM_COPYIP:
					{
						int n=-1;
						char szIP[40];
						n = ListView_GetSelectionMark(g_hwndListBuddy);
						ListView_GetItemText(g_hwndListBuddy,n,2,szIP,sizeof(szIP)-1);
						if(n!=-1)
						{
							EditCopy(szIP);
						}
						else
							MessageBox(hwnd,g_lang.GetString("ErrorServerCopyToClipBoard"),NULL,MB_OK);
					}
				break;
				case IDM_CONNECT:
					StartGame_ConnectToServer(true);
				break;
			}
		}
		else if(uMsg==WM_LBUTTONDBLCLK)
		{
			PostMessage(hwnd,WM_COMMAND,LOWORD(IDM_CONNECT),0);
	    }
 		else if(uMsg == WM_RBUTTONDOWN)
		{
			//get mouse cursor position x and y as lParam has the message itself 
			POINT lpClickPoint;
			GetCursorPos(&lpClickPoint);
			hPopMenu = CreatePopupMenu();
			int n=-1;
			n = ListView_GetSelectionMark(g_hwndListBuddy);
			if(n!=-1)
			{
				//place the window/menu there if needed 						
				
				InsertMenu(hPopMenu,0xFFFFFFFF,MF_BYPOSITION|MF_STRING,IDM_CONNECT,g_lang.GetString("MenuConnect"));				
				InsertMenu(hPopMenu,0xFFFFFFFF,MF_BYPOSITION|MF_STRING,IDM_DELETE,g_lang.GetString("Remove"));
				InsertMenu(hPopMenu,0xFFFFFFFF,MF_BYPOSITION|MF_STRING,IDM_EDIT_BUDDY,g_lang.GetString("Edit"));
				InsertMenu(hPopMenu,0xFFFFFFFF,MF_BYPOSITION|MF_STRING,IDM_COPYIP,g_lang.GetString("MenuCopyIP"));
			}
						
				InsertMenu(hPopMenu,0xFFFFFFFF,MF_BYPOSITION|MF_STRING,IDM_ADD,g_lang.GetString("Add"));			
				//InsertMenu(hPopMenu,0xFFFFFFFF,MF_BYPOSITION|MF_STRING,IDM_REFRESH,"&Refresh");
												
				//workaround for microsoft bug, to hide menu w/o selecting
				SetForegroundWindow(hwnd);
				TrackPopupMenu(hPopMenu,TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_BOTTOMALIGN,lpClickPoint.x, lpClickPoint.y,0,hwnd,NULL);
				SendMessage(hwnd,WM_NULL,0,0);
				DestroyMenu(hPopMenu);
			return 0;
		}				
    return CallWindowProc((WNDPROC)g_wpOrigListBuddyProc, hwnd, uMsg,  wParam, lParam); 
} 
コード例 #11
0
BOOL CCloseApplicationDlg::OnInitDialog()
{
	// Declare variables
	CString sTemp;
	CLanguage * pLanguage = CLanguage::Instance();

	// Call original function
	CDialog::OnInitDialog();

	// Set icon
	m_icoApplication.SetSize(40, 40);
	m_icoApplication.SetTransparentColor(RGB(0, 0, 0));
	m_icoApplication.LoadIcon(m_hIcon);

	// Set window text
	sTemp.Format(pLanguage->GetString(IDS_CLOSEAPPLICATION_TITLE), m_sApplicationTitle);
	SetWindowText(sTemp);
	m_lblTitle.SetWindowText(sTemp);

	// Set explanation text
	sTemp.Format(pLanguage->GetString(IDS_CLOSEAPPLICATION_EXPLANATION), m_sApplicationTitle,
		m_iCountDown, m_sApplicationTitle);
	m_lblExplanation.SetWindowText(sTemp);

	// Set button text
	m_btnCancel.SetWindowText(pLanguage->GetString(IDS_GENERAL_CANCEL));
	m_btnEndNow.SetWindowText(pLanguage->GetString(IDS_CLOSEAPPLICATION_ENDNOW));

	// Create and set font
	m_fntTitle.DeleteObject();
	m_fntTitle.CreateFont(
		20,								// nHeight
		0,								// nWidth
		0,								// nEscapement
		0,								// nOrientation
		FW_BOLD,						// nWeight
		FALSE,							// bItalic
		FALSE,							// bUnderline
		0,								// cStrikeOut
		DEFAULT_CHARSET,				// nCharSet
		OUT_DEFAULT_PRECIS,				// nOutPrecision
		CLIP_DEFAULT_PRECIS,			// nClipPrecision
		PROOF_QUALITY,					// nQuality
		DEFAULT_PITCH | FF_DONTCARE,	// nPitchAndFamily
		NULL);
	m_lblTitle.SetFont(&m_fntTitle);

	// Auto resize controls
	AutoResizeControls();

	// Set control properties
	m_prgEnd.SetRange32(0, CLOSEAPPLICATION_TIME);
	m_prgEnd.SetPos(0);

	// Start timer
	SetTimer(TIMER_COUNTDOWN, 1000, NULL);

	// Try to close application in a nice way
	std::string strVersion;
	UINT uWinPlatform;
	UINT uVersion = getWinVersion(strVersion, uWinPlatform);
	CString sProcess = CPath::Instance()->ExtractFileName(m_sApplicationPath);
	if ((uVersion == WINDOWS_NT3) || (uVersion == WINDOWS_NT4))
	{
		CloseNTApplication(sProcess.GetBuffer(sProcess.GetLength()));
	}
	else
	{
		CloseAllWinApplication(sProcess.GetBuffer(sProcess.GetLength()));
	}

	// Return TRUE unless you want to set focus to a control
	return TRUE;
}
コード例 #12
0
ATMO_BOOL CAtmoGradients::InitDialog(WPARAM wParam) 
{
	HWND groupBox = getDlgItem( IDC_ZONE_GROUP );
	CLanguage *Lng = new CLanguage;

	Lng->szCurrentDir[Lng->SetLngPath()];

	sprintf(Lng->szFileINI, "%s\\Language.ini\0", Lng->szCurrentDir);

	GetPrivateProfileString("Common", "Language", "English", Lng->szLang, 256, Lng->szFileINI);

	// Read Buffer from IniFile
	sprintf(Lng->szTemp, "%s\\%s.xml\0", Lng->szCurrentDir, Lng->szLang);

	Lng->XMLParse(Lng->szTemp, Lng->sGradientsText, "Gradients");  	

	SetWindowLongPtr(groupBox, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
	OrgGroupBoxProc = (WNDPROC)SetWindowLongPtr(groupBox, GWL_WNDPROC, reinterpret_cast<LONG_PTR>(GroupBoxProc));

	int zonenIdx = 0;
	char zonename[100];
	int xpos, ypos;

	int zoneCount = m_pConfig->getZoneCount() + 1;
	m_ZoneRadios = new HWND[ zoneCount ];

	for(int i=0; i<zoneCount; i++)
		m_ZoneRadios[i] = 0;

#define radio_width 60
#define radio_height 20


	xpos = 10;
	ypos = 12;
	RECT rect, rrect;
	GetClientRect( groupBox, &rect );
	GetWindowRect( groupBox, &rrect );

	if(m_pConfig->getZonesTopCount() > 0) 
	{
		int radioWidth = (rect.right - rect.left - 20) /  (m_pConfig->getZonesTopCount() + 1);

		xpos = 10 + radioWidth -  radio_width/2;

		for( int zone=0; zone < m_pConfig->getZonesTopCount(); zone++)
		{
			sprintf( zonename, Lng->sGradientsText[0] + "%d", zonenIdx );
			HWND handle = CreateWindow("BUTTON", zonename,
				BS_AUTORADIOBUTTON  | BS_LEFTTEXT  | WS_VISIBLE | WS_TABSTOP | WS_CHILD, 
				xpos, ypos, radio_width, radio_height, groupBox, NULL, m_hInst, NULL);
			SetWindowFont(handle, GetWindowFont(m_hDialog), false);

			m_ZoneRadios[ zonenIdx ] = handle;
			zonenIdx++;
			xpos += radioWidth;
		}
	}

	if( m_pConfig->getZonesLRCount() > 0 )
	{
		int radioHeight = (rect.bottom - rect.top - 40) / (m_pConfig->getZonesLRCount() + 1);

		xpos = rect.right - 10 - radio_width;
		ypos = rect.top + 20 + radioHeight - radio_height / 2;

		for( int zone=0; zone < m_pConfig->getZonesLRCount(); zone++)
		{
			sprintf( zonename, Lng->sGradientsText[0] + "%d", zonenIdx );
			HWND handle = CreateWindow("BUTTON", zonename,
				BS_AUTORADIOBUTTON  | BS_LEFTTEXT  | WS_VISIBLE | WS_TABSTOP | WS_CHILD, 
				xpos, ypos, radio_width, radio_height, groupBox, NULL, m_hInst, NULL);
			SetWindowFont(handle, GetWindowFont(m_hDialog), false);


			m_ZoneRadios[ zonenIdx ] = handle;
			zonenIdx++;
			ypos += radioHeight;
		}
	}

	if(m_pConfig->getZonesBottomCount() > 0) 
	{
		int radioWidth = (rect.right - rect.left - 20) /  (m_pConfig->getZonesBottomCount() + 1);
		xpos = rect.right -  10 - radioWidth - radio_width/2 ;
		ypos = rect.bottom - 30;

		for( int zone=0; zone < m_pConfig->getZonesBottomCount(); zone++)
		{
			sprintf( zonename, Lng->sGradientsText[0] + "%d", zonenIdx );

			HWND handle = CreateWindow("BUTTON", zonename,
				BS_AUTORADIOBUTTON  | BS_LEFTTEXT  | WS_VISIBLE | WS_TABSTOP | WS_CHILD, 
				xpos, ypos, radio_width, radio_height, groupBox, NULL, m_hInst, NULL);
			SetWindowFont(handle, GetWindowFont(m_hDialog), false);


			m_ZoneRadios[ zonenIdx ] = handle;

			zonenIdx++;
			xpos -= radioWidth;
		}
	}

	if( m_pConfig->getZonesLRCount() > 0 )
	{
		int radioHeight = (rect.bottom - rect.top - 40) / (m_pConfig->getZonesLRCount() + 1);

		xpos = rect.left + 10;
		ypos = rect.bottom - 20 - radioHeight - radio_height / 2;

		for( int zone=0; zone < m_pConfig->getZonesLRCount(); zone++)
		{
			sprintf( zonename, Lng->sGradientsText[0] + "%d", zonenIdx );
			HWND handle = CreateWindow("BUTTON", zonename,
				BS_AUTORADIOBUTTON  | BS_RIGHT | WS_VISIBLE | WS_TABSTOP | WS_CHILD, 
				xpos, ypos, radio_width, radio_height, groupBox, NULL, m_hInst, NULL);
			SetWindowFont(handle, GetWindowFont(m_hDialog), false);


			m_ZoneRadios[ zonenIdx ] = handle;
			zonenIdx++;
			ypos -= radioHeight;
		}
	}

	if( m_pConfig->getZoneSummary() )
	{
		xpos = rect.left + 20 + radio_width;
		ypos = (rect.bottom - 50);

		sprintf( zonename, Lng->sGradientsText[1] + "%d", zonenIdx );
		HWND handle = CreateWindow("BUTTON", zonename,
			BS_AUTORADIOBUTTON  | BS_RIGHT | WS_VISIBLE | WS_TABSTOP | WS_CHILD, 
			xpos, ypos, 100, radio_height, groupBox, NULL, m_hInst, NULL);

		SetWindowFont(handle, GetWindowFont(m_hDialog), false);

		m_ZoneRadios[ zonenIdx ] = handle;
		zonenIdx++;
	}

	m_ZoneRadios[ zonenIdx ] = 0;

	this->SetupSliderControl(IDC_EDGE_WEIGHT,1,30,this->m_edge_weight,5);
	SendMessage(getDlgItem(IDC_EDGE_WEIGHT),TBM_SETPAGESIZE,0,2);

	char buffer[32];
	sprintf(buffer,Lng->sGradientsText[2] + "[%d]",m_edge_weight);
	SetWindowText( getDlgItem(IDC_STATIC_EDGEW), buffer);

	if(zonenIdx > 0) {
		SetActiveZone( 0 );
		SendMessage( m_ZoneRadios[ 0 ], (UINT)BM_SETCHECK, BST_CHECKED, 0);
	}

	SendMessage(this->m_hDialog, WM_SETTEXT, 0, (LPARAM)(LPCTSTR)(Lng->sGradientsText[15]));
	SendMessage(getDlgItem(IDCANCEL), WM_SETTEXT, 0, (LPARAM)(LPCTSTR)(Lng->sGradientsText[16]));
	SendMessage(getDlgItem(IDC_ZONE_GROUP), WM_SETTEXT, 0, (LPARAM)(LPCTSTR)(Lng->sGradientsText[17]));

	return ATMO_FALSE;
}
コード例 #13
0
ファイル: CLanguageTokenizer.cpp プロジェクト: kbjava/haiku
const Token&
Tokenizer::NextToken()
{
	if (fCurrentToken.type == TOKEN_END_OF_LINE)
		return fCurrentToken;

	if (fReuseToken) {
		fReuseToken = false;
		return fCurrentToken;
	}

	while (*fCurrentChar != 0 && isspace(*fCurrentChar))
		fCurrentChar++;

	if (*fCurrentChar == 0) {
		return fCurrentToken = Token("", 0, _CurrentPos(),
			TOKEN_END_OF_LINE);
	}

	bool decimal = *fCurrentChar == '.';

	if (decimal || isdigit(*fCurrentChar)) {
		if (*fCurrentChar == '0' && fCurrentChar[1] == 'x')
			return _ParseHexOperand();

		BString temp;

		const char* begin = fCurrentChar;

		// optional digits before the comma
		while (isdigit(*fCurrentChar)) {
			temp << *fCurrentChar;
			fCurrentChar++;
		}

		// optional post decimal part
		// (required if there are no digits before the decimal)
		if (*fCurrentChar == '.') {
			decimal = true;
			temp << '.';
			fCurrentChar++;

			// optional post decimal digits
			while (isdigit(*fCurrentChar)) {
				temp << *fCurrentChar;
				fCurrentChar++;
			}
		}

		int32 length = fCurrentChar - begin;
		if (length == 1 && decimal) {
			// check for . operator
			fCurrentChar = begin;
			if (!_ParseOperator())
				throw ParseException("unexpected character", _CurrentPos());

			return fCurrentToken;
		}

		BString test = temp;
		test << "&_";
		double value;
		char t[2];
		int32 matches = sscanf(test.String(), "%lf&%s", &value, t);
		if (matches != 2)
			throw ParseException("error in constant", _CurrentPos() - length);

		fCurrentToken = Token(begin, length, _CurrentPos() - length,
			TOKEN_CONSTANT);
		if (decimal)
			fCurrentToken.value.SetTo(value);
		else
			fCurrentToken.value.SetTo((int64)strtoll(temp.String(), NULL, 10));
	} else if (isalpha(*fCurrentChar) || *fCurrentChar == '_') {
		const char* begin = fCurrentChar;
		while (*fCurrentChar != 0 && (isalpha(*fCurrentChar)
			|| isdigit(*fCurrentChar) || *fCurrentChar == '_')) {
			fCurrentChar++;
		}
		int32 length = fCurrentChar - begin;
		fCurrentToken = Token(begin, length, _CurrentPos() - length,
			TOKEN_IDENTIFIER);
	} else if (*fCurrentChar == '"' || *fCurrentChar == '\'') {
		const char* begin = fCurrentChar++;
		while (*fCurrentChar != 0) {
			if (*fCurrentChar == '\\') {
				if (*(fCurrentChar++) != 0)
					fCurrentChar++;
			} else if (*(fCurrentChar++) == *begin)
				break;
		}
		int32 length = fCurrentChar - begin;
		fCurrentToken = Token(begin, length, _CurrentPos() - length,
			TOKEN_STRING_LITERAL);
	} else {
		if (!_ParseOperator()) {
			int32 type = TOKEN_NONE;
			switch (*fCurrentChar) {
				case '\n':
					type = TOKEN_END_OF_LINE;
					break;

				case '(':
					type = TOKEN_OPENING_PAREN;
					break;
				case ')':
					type = TOKEN_CLOSING_PAREN;
					break;

				case '[':
					type = TOKEN_OPENING_SQUARE_BRACKET;
					break;
				case ']':
					type = TOKEN_CLOSING_SQUARE_BRACKET;
					break;

				case '{':
					type = TOKEN_OPENING_CURLY_BRACE;
					break;
				case '}':
					type = TOKEN_CLOSING_CURLY_BRACE;
					break;

				case '\\':
					type = TOKEN_BACKSLASH;
					break;

				case ':':
					type = TOKEN_COLON;
					break;

				case ';':
					type = TOKEN_SEMICOLON;
					break;

				case ',':
					type = TOKEN_COMMA;
					break;

				case '.':
					type = TOKEN_PERIOD;
					break;

				case '#':
					type = TOKEN_POUND;
					break;

				default:
					throw ParseException("unexpected character",
						_CurrentPos());
			}
			fCurrentToken = Token(fCurrentChar, 1, _CurrentPos(),
				type);
			fCurrentChar++;
		}
	}

	return fCurrentToken;
}
コード例 #14
0
ファイル: config.cpp プロジェクト: elitak/gamescanner
LRESULT CALLBACK CFG_MainProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
		case WM_INITDIALOG:
		{
		
			g_tvIndexCFG = 0;
			g_hwndTree = GetDlgItem(hDlg,IDC_TREE_CONF);

			SendMessage(g_hwndTree, TVM_SETIMAGELIST , TVSIL_NORMAL, (LPARAM)g_hImageListIcons);
			SendMessage(g_hwndTree, TVM_SETIMAGELIST , TVSIL_STATE, (LPARAM)g_hImageListStates);
			HTREEITEM hNewItem;
			hNewItem = TreeView_AddItem(27,g_lang.GetString("ConfigGeneral"));
			hNewItem = TreeView_AddItem(15,g_lang.GetString("ConfigMinimizer"));
			hNewItem = TreeView_AddItem(28,"mIRC");
			hNewItem = TreeView_AddItem(3,"Account (XMPP)");
			hNewItem = TreeView_AddItem(16,g_lang.GetString("ConfigExtExe"));

			hNewItem = TreeView_AddItem(25,g_lang.GetString("ConfigGraphic"));
			hNewItem = TreeView_AddItem(13,g_lang.GetString("ConfigNetwork"));
			hNewItem = TreeView_AddItem(20 ,g_lang.GetString("ConfigGames"));
			if (hNewItem)
				TreeView_Select(g_hwndTree, hNewItem, TVGN_CARET);

			for(UINT i=0;i<gm.GamesInfo.size();i++)
				hNewItem = TreeView_AddItem(gm.GamesInfo[i].iIconIndex,gm.GamesInfo[i].szGAME_SHORTNAME);

			TreeView_Select(g_hwndTree, NULL, TVGN_CARET);

			for(UINT i=0; i<gm.GamesInfo.size();i++)
			{
					GamesInfoCFG[i].bActive = gm.GamesInfo[i].bActive;
					GamesInfoCFG[i].bUseHTTPServerList[0] = gm.GamesInfo[i].bUseHTTPServerList[0];
					GamesInfoCFG[i].dwMasterServerPORT = gm.GamesInfo[i].dwMasterServerPORT;
					strcpy(GamesInfoCFG[i].szGAME_NAME, gm.GamesInfo[i].szGAME_NAME);
					strcpy(GamesInfoCFG[i].szMasterServerIP[0], gm.GamesInfo[i].szMasterServerIP[0]);					
					GamesInfoCFG[i].vGAME_INST = gm.GamesInfo[i].vGAME_INST;								
			}
			memcpy(&AppCFGtemp,&AppCFG,sizeof(APP_SETTINGS_NEW));
			CFG_g_sMIRCoutputTemp = g_sMIRCoutput;
			SetDlgItemText(hDlg,IDOK,g_lang.GetString("Ok"));
			SetDlgItemText(hDlg,IDC_BUTTON_DEFAULT,g_lang.GetString("SetDefault"));
			SetDlgItemText(hDlg,IDCANCEL,g_lang.GetString("Cancel"));
			
			CenterWindow(hDlg);
			CFG_OnTabbedDialogInit(hDlg) ;
			return TRUE;			
		}	

  case WM_NOTIFY: 
	  {
		NMTREEVIEW *lpnmtv;
		lpnmtv = (LPNMTREEVIEW)lParam;

		switch (wParam) 
		{ 
			case IDC_TREE_CONF:
				{
					NMTREEVIEW *pnmtv;
					pnmtv = (LPNMTREEVIEW) lParam;
					if((lpnmtv->hdr.code  == TVN_SELCHANGED)  )
					{
						if((g_bChanged==true) && (pnmtv->action == TVC_BYMOUSE))
							CFG_ApplySettings();

						CFG_OnSelChanged(hDlg);
					}
				}
			break;

		} 
		break; 
	  }

	case WM_COMMAND:
		{
			switch (LOWORD(wParam))				
			{
				case  IDCANCEL:	
					LocalFree(g_pHdr);
					EndDialog(hDlg, LOWORD(wParam)); 
				return TRUE;
				case IDOK:
				{					
					CFG_ApplySettings();
					
					if(AppCFGtemp.bAutostart)
						AddAutoRun(EXE_PATH);
					else
						RemoveAutoRun();
					
					if(AppCFGtemp.bUse_minimize)
					{	
						UnregisterHotKey(NULL, HOTKEY_ID);
						if (!RegisterHotKey(NULL, HOTKEY_ID, AppCFGtemp.dwMinimizeMODKey ,AppCFGtemp.cMinimizeKey))
						{
							//probably already registred
							MessageBox(NULL,g_lang.GetString("ErrorRegHotkey"),"Hotkey error",NULL);
						}
					}else
					{
						UnregisterHotKey(NULL, HOTKEY_ID);
					}
					
					
					for(UINT i=0; i<gm.GamesInfo.size();i++)
					{
						gm.GamesInfo[i].bActive = GamesInfoCFG[i].bActive;
						gm.GamesInfo[i].bUseHTTPServerList[0] = GamesInfoCFG[i].bUseHTTPServerList[0];
						gm.GamesInfo[i].dwMasterServerPORT = GamesInfoCFG[i].dwMasterServerPORT;					
						strcpy(gm.GamesInfo[i].szMasterServerIP[0], GamesInfoCFG[i].szMasterServerIP[0]);
						gm.GamesInfo[i].vGAME_INST = GamesInfoCFG[i].vGAME_INST;	
					}

					memcpy(&AppCFG,&AppCFGtemp,sizeof(APP_SETTINGS_NEW));
					//memcpy(&GI,&GamesInfoCFG,sizeof(GAME_INFO)*GamesInfo.size());
				//	ZeroMemory(&GamesInfoCFG,sizeof(GAME_INFO)*GamesInfo.size());
					ZeroMemory(&AppCFGtemp,sizeof(APP_SETTINGS_NEW));
					HANDLE hThread=NULL; 
					DWORD dwThreadIdBrowser=0;				
					hThread = CreateThread( NULL, 0, &CFG_Save,(LPVOID)0 ,0, &dwThreadIdBrowser);                
					if (hThread == NULL) 
					{
						g_log.AddLogInfo(GS_LOG_WARNING, "CreateThread CFG_Save failed (%d)\n", GetLastError() ); 
					} else
					{
						CloseHandle( hThread );
					}

			//		CFG_Save(0);
					LocalFree(g_pHdr);
					EndDialog(hDlg, LOWORD(wParam));
					return TRUE;
				}
				case IDC_BUTTON_DEFAULT:
				{				
					Default_Appsettings();
				//	Default_GameSettings();
					memcpy(&AppCFGtemp,&AppCFG,sizeof(APP_SETTINGS_NEW));
					//memcpy(&GamesInfoCFG,&GI,sizeof(GAME_INFO)*GamesInfo.size());
					//GamesInfoCFG = GamesInfo;
					g_currSelCfg=-1;
					CFG_OnSelChanged(hDlg); 
					return TRUE;
				}			

				break;
			}
		}
	}
	
	return FALSE;
}
コード例 #15
0
ファイル: config.cpp プロジェクト: elitak/gamescanner
LRESULT CALLBACK  CFG_EditInstall_Proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	TCHAR szFile[260];
	switch(uMsg)
	{
		case WM_INITDIALOG:
			{
				CFG_editexeIdx = lParam;
				int gameID = CFG_GetGameID(g_currSelCfg);	
				GAME_INSTALLATIONS gi;
				gi = GamesInfoCFG[gameID].vGAME_INST.at(lParam);

				g_cfgScriptTmp.clear();
				g_cfgFilterNameTmp.clear();

				g_EditorTI.sScript = gi.sScript;
				g_EditorTI.sName  = gi.sFilterName;


				CheckDlgButton(hDlg,IDC_CHECK_CONDITION,gi.bActiveScript);			
				SetDlgItemText(hDlg,IDC_EDIT_SCRIPTNAME,gi.sFilterName.c_str());

				SetDlgItemText(hDlg,IDC_EDIT_CFG_PROPNAME,gi.sName.c_str());
				SetDlgItemText(hDlg,IDC_EDIT_PATH,gi.szGAME_PATH.c_str());
				SetDlgItemText(hDlg,IDC_EDIT_CMD,gi.szGAME_CMD.c_str());
		//		SetDlgItemText(hDlg,IDC_EDIT_CFG_MOD,gi.sMod.c_str());
		//		SetDlgItemText(hDlg,IDC_EDIT_CFG_VERSION,gi.sVersion.c_str());
				break;
			}
		case WM_COMMAND:
			{
				switch (LOWORD(wParam))
	            {
					case IDC_BUTTON_EDIT_SCRIPT:
						DialogBoxParam(g_hInst, (LPCTSTR)IDD_DLG_EDIT_FILTER, hDlg, (DLGPROC)FilterEditor_Dlg,-2);
						g_cfgScriptTmp = g_EditorTI.sScript;
						g_cfgFilterNameTmp = g_EditorTI.sName;
						SetDlgItemText(hDlg,IDC_EDIT_SCRIPTNAME,g_cfgFilterNameTmp.c_str());
					break;
					case IDC_BUTTON_CFG_EXE_CANCEL:
						EndDialog(hDlg,0);
						break;
					case IDC_BUTTON_EXE_CFG_OK:
						{
							int gameID = CFG_GetGameID(g_currSelCfg);
							TCHAR szTemp[MAX_PATH*2];
							GAME_INSTALLATIONS gi;
							GetDlgItemText(hDlg,IDC_EDIT_CFG_PROPNAME,szTemp,MAX_PATH);
							if(strlen(szTemp)==0)
							{
								MessageBox(hDlg,g_lang.GetString("NoName"),"Error saving",MB_OK);
								return TRUE;
							}
							if(IsDlgButtonChecked(hDlg,IDC_CHECK_CONDITION)==BST_CHECKED)
								gi.bActiveScript=TRUE;
							else
								gi.bActiveScript=FALSE;

							gi.sFilterName = g_cfgFilterNameTmp;
							gi.sScript = g_cfgScriptTmp;

							gi.sName = szTemp;
							GetDlgItemText(hDlg,IDC_EDIT_PATH,szTemp,MAX_PATH);
							gi.szGAME_PATH = szTemp;
							GetDlgItemText(hDlg,IDC_EDIT_CMD,szTemp,MAX_PATH*2);
							gi.szGAME_CMD = szTemp;
							GamesInfoCFG[gameID].vGAME_INST.at(CFG_editexeIdx) = gi;
							EndDialog(hDlg,0);
						}
						break;

					case IDC_BUTTON_ET_PATH:
					{	
						 
						OPENFILENAME ofn;
						memset(&ofn,0,sizeof(OPENFILENAME));
						ofn.lStructSize = sizeof (OPENFILENAME);
						ofn.hwndOwner = hDlg;
						ofn.lpstrFilter = NULL;
						ofn.lpstrFile = szFile;

						// Set lpstrFile[0] to '\0' so that GetOpenFileName does not 
						// use the contents of szFile to initialize itself.
						//
						ofn.lpstrFile[0] = '\0';
						ofn.nMaxFile = sizeof(szFile);
						ofn.lpstrFilter = "All\0*.*\0Executable\0*.exe\0";
						ofn.nFilterIndex = 2;
						ofn.lpstrFileTitle = NULL;
						ofn.nMaxFileTitle = 0;
						ofn.lpstrInitialDir = NULL;
						int gameID=-1;
						gameID = CFG_GetGameID(g_currSelCfg);

						if(gameID!=-1)
						{
							if(GamesInfoCFG[gameID].vGAME_INST.size()>0)
								ofn.lpstrInitialDir = GamesInfoCFG[gameID].vGAME_INST[CFG_editexeIdx].szGAME_PATH.c_str();
						}
						ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

						if(GetOpenFileName(&ofn))
							SetDlgItemText(hDlg,IDC_EDIT_PATH,ofn.lpstrFile);

						return TRUE;					
					}

				}
				break;
			}

	}
	return FALSE;
}
コード例 #16
0
ファイル: config.cpp プロジェクト: elitak/gamescanner
LRESULT CALLBACK  CFG_AddNewInstall_Proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	TCHAR szFile[360];
	switch(uMsg)
	{
		case WM_INITDIALOG:
			{
				g_cfgScriptTmp.clear();
				g_cfgFilterNameTmp.clear();
				SetWindowText(hDlg,g_lang.GetString("TitleNewInstall"));
				SetDlgItemText(hDlg,IDC_BUTTON_EXE_CFG_OK,g_lang.GetString("Save"));
				SetDlgItemText(hDlg,IDC_BUTTON_CFG_EXE_CANCEL,g_lang.GetString("Cancel"));
				SetDlgItemText(hDlg,IDC_STATIC_ADDNEWINSTALL,g_lang.GetString("AddNewInstall"));
				SetDlgItemText(hDlg,IDC_STATIC_EXE,g_lang.GetString("ColumnExePath"));
				SetDlgItemText(hDlg,IDC_STATIC_COMMAND,g_lang.GetString("ColumnCommand"));
				SetDlgItemText(hDlg,IDC_EDIT_CFG_PROPNAME,"Default");
				int gameID = CFG_GetGameID(g_currSelCfg);
				if(gm.GamesInfo[gameID].vGAME_INST_DEFAULT.size()>0)
				{
					SetDlgItemText(hDlg,IDC_EDIT_CMD,gm.GamesInfo[gameID].vGAME_INST_DEFAULT.at(0).szGAME_CMD.c_str());
				}
				
				break;
			}
		case WM_COMMAND:
			{
				switch (LOWORD(wParam))
	            {
					case IDC_BUTTON_EDIT_SCRIPT:
						DialogBoxParam(g_hInst, (LPCTSTR)IDD_DLG_EDIT_FILTER, hDlg, (DLGPROC)FilterEditor_Dlg,-1);
						g_cfgScriptTmp = g_EditorTI.sScript;
						g_cfgFilterNameTmp = g_EditorTI.sName;
						SetDlgItemText(hDlg,IDC_EDIT_SCRIPTNAME,g_cfgFilterNameTmp.c_str());
					break;
					case IDC_BUTTON_CFG_EXE_CANCEL:
						EndDialog(hDlg,0);
						break;
					case IDC_BUTTON_EXE_CFG_OK:
						{
							int gameID = CFG_GetGameID(g_currSelCfg);
							TCHAR szTemp[MAX_PATH*2];
							GAME_INSTALLATIONS gi;
							GetDlgItemText(hDlg,IDC_EDIT_CFG_PROPNAME,szTemp,MAX_PATH);
							if(strlen(szTemp)==0)
							{
								MessageBox(hDlg,g_lang.GetString("NoName"),"Error saving",MB_OK);
								return TRUE;
							}
							if(IsDlgButtonChecked(hDlg,IDC_CHECK_CONDITION)==BST_CHECKED)
								gi.bActiveScript=TRUE;
							else
								gi.bActiveScript=FALSE;

							gi.sFilterName = g_cfgFilterNameTmp;
							gi.sScript = g_cfgScriptTmp;
							gi.sName = szTemp;
							GetDlgItemText(hDlg,IDC_EDIT_PATH,szTemp,MAX_PATH*2);
							gi.szGAME_PATH = szTemp;
							GetDlgItemText(hDlg,IDC_EDIT_CMD,szTemp,MAX_PATH*2);
							gi.szGAME_CMD = szTemp;

//USE below function for above code!!!
//GetDlgItemTextToString(HWND hWnd,int nID, string &pOutString)
							GamesInfoCFG[gameID].vGAME_INST.push_back(gi);

							EndDialog(hDlg,0);
						}
						break;

					case IDC_BUTTON_ET_PATH:
					{	
						 
						OPENFILENAME ofn;
						memset(&ofn,0,sizeof(OPENFILENAME));
						ofn.lStructSize = sizeof (OPENFILENAME);
						ofn.hwndOwner = hDlg;
						ofn.lpstrFilter = NULL;
						ofn.lpstrFile = szFile;

						// Set lpstrFile[0] to '\0' so that GetOpenFileName does not 
						// use the contents of szFile to initialize itself.
						//
						ofn.lpstrFile[0] = '\0';
						ofn.nMaxFile = sizeof(szFile);
						ofn.lpstrFilter = "All\0*.*\0Executable\0*.exe\0";
						ofn.nFilterIndex = 2;
						ofn.lpstrFileTitle = NULL;
						ofn.nMaxFileTitle = 0;
						ofn.lpstrInitialDir = NULL;
						int gameID=-1;
						gameID = CFG_GetGameID(g_currSelCfg);

						if(gameID!=-1)
						{
								if(GamesInfoCFG[gameID].vGAME_INST.size()>0)
									ofn.lpstrInitialDir = GamesInfoCFG[gameID].vGAME_INST[CFG_editexeIdx].szGAME_PATH.c_str();
						}
						ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

						if(GetOpenFileName(&ofn))
							SetDlgItemText(hDlg,IDC_EDIT_PATH,ofn.lpstrFile);

						return TRUE;					
					}

				}
				break;
			}

	}
	return FALSE;
}
コード例 #17
0
ファイル: config.cpp プロジェクト: elitak/gamescanner
LRESULT CALLBACK CFG_OnSelChangedProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	TCHAR szText[256];
	TCHAR tmp[20];
	TCHAR szFile[260];
	
	hwndConfDialog = hDlg;
	switch(uMsg)
    {
		case WM_INITDIALOG:
			{
			
				g_bChanged = false;
				CFG_OnChildDialogInit(hDlg);
		 		
				SendDlgItemMessage (hDlg,IDC_COMBO_MOD, CB_ADDSTRING, 0, (LPARAM)"ALT");  
				SendDlgItemMessage (hDlg,IDC_COMBO_MOD, CB_ADDSTRING, 0 ,(LPARAM)"CONTROL");  
				SendDlgItemMessage (hDlg,IDC_COMBO_MOD, CB_ADDSTRING, 0, (LPARAM)"SHIFT");  
			
				if(AppCFGtemp.dwMinimizeMODKey == MOD_ALT)
					SendDlgItemMessage (hDlg,IDC_COMBO_MOD, CB_SETCURSEL, 0, 0);  
				else if(AppCFGtemp.dwMinimizeMODKey == MOD_CONTROL)
					SendDlgItemMessage (hDlg,IDC_COMBO_MOD, CB_SETCURSEL, 1, 0);  
				else if(AppCFGtemp.dwMinimizeMODKey == MOD_SHIFT)
					SendDlgItemMessage (hDlg,IDC_COMBO_MOD, CB_SETCURSEL, 2, 0);  

				sprintf(tmp,"%c",AppCFGtemp.cMinimizeKey);
				SetDlgItemText(hDlg,IDC_EDIT_KEY,tmp);
				SendDlgItemMessage (hDlg,IDC_EDIT_KEY, EM_SETLIMITTEXT,1, 0);  

		
				CheckDlgButton(hDlg,IDC_CHECK_CONNECT_CLOSE,AppCFGtemp.bCloseOnConnect);
				CheckDlgButton(hDlg,IDC_CHECK1,AppCFGtemp.bAutostart);
				CheckDlgButton(hDlg,IDC_CHECK_SHORTNAME,AppCFGtemp.bUseShortCountry);
				CheckDlgButton(hDlg,IDC_CHECK_REG_WEB_PROTOCOLS,AppCFGtemp.bRegisterWebProtocols);
				CheckDlgButton(hDlg,IDC_CHECK_NO_MAP_RESIZE,AppCFGtemp.bNoMapResize);
				CheckDlgButton(hDlg,IDC_CHECK_REFRESH_AT_START_UP,AppCFGtemp.bAutoRefreshServerlist);


				LVCOLUMN lvColumn;
				//initialize the columns
				lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM ;
				lvColumn.fmt = LVCFMT_LEFT;

				HWND hwndLVexes;
				hwndLVexes = GetDlgItem(hDlg,IDC_LIST_CFG_EXES);

				lvColumn.cx = 80;
				lvColumn.pszText = (LPSTR)g_lang.GetString("ColumnName");
				ListView_InsertColumn(hwndLVexes, 0, &lvColumn);
				lvColumn.cx = 120;
				lvColumn.pszText = (LPSTR)g_lang.GetString("LaunchByScript");
				ListView_InsertColumn(hwndLVexes, 1, &lvColumn);
				lvColumn.cx = 180;
				lvColumn.pszText =  (LPSTR)g_lang.GetString("ColumnExePath"); 
				ListView_InsertColumn(hwndLVexes, 3, &lvColumn);
				lvColumn.pszText =  (LPSTR)g_lang.GetString("ColumnCommand"); 
				ListView_InsertColumn(hwndLVexes, 4, &lvColumn);

				DWORD dwExStyle=0;
				dwExStyle = ListView_GetExtendedListViewStyle(hwndLVexes);
				dwExStyle |= LVS_EX_FULLROWSELECT |  LVS_EX_LABELTIP ;
				ListView_SetExtendedListViewStyle(hwndLVexes,dwExStyle);			

			
			CheckDlgButton(hDlg,IDC_CHECK2,AppCFGtemp.bUse_minimize);
			CheckDlgButton(hDlg,IDC_CHECK_SCR_RESTORE,AppCFGtemp.bUSE_SCREEN_RESTORE );				

			
			sprintf(szText,"%d",AppCFGtemp.iAutoRefreshEveryMinuteInterval);
			SetDlgItemText(hDlg,IDC_EDIT_AUTO_REFRESH_INTERVAL,szText);


			sprintf(szText,"%d",(AppCFGtemp.socktimeout.tv_sec*1000)+AppCFGtemp.socktimeout.tv_usec);
			SetDlgItemText(hDlg,IDC_EDIT_SOCK_TIMEOUT_S,szText);
			
			sprintf(szText,"%d",AppCFGtemp.dwRetries);
			SetDlgItemText(hDlg,IDC_EDIT_CFG_RETRIES,szText);


			CheckDlgButton(hDlg,IDC_CHECK_XMPP_ACTIVE,AppCFGtemp.bXMPP_Active);
			SetDlgItemText(hDlg,IDC_EDIT_XMPP_USERNAME,AppCFGtemp.szXMPP_USERNAME);
			SetDlgItemText(hDlg,IDC_EDIT_XMPP_PASSWORD,AppCFGtemp.szXMPP_PASSWORD);
			SetDlgItemText(hDlg,IDC_EDIT_XMPP_SERVER,AppCFGtemp.szXMPP_SERVER);
			

			CheckDlgButton(hDlg,IDC_CHECK_BUDDY_NOTIFY,AppCFGtemp.bBuddyNotify);
			CheckDlgButton(hDlg,IDC_CHECK_USE_WAV_FILE,AppCFGtemp.bUseBuddySndNotify);
			SetDlgItemText(hDlg,IDC_EDIT_WAV_FILE,AppCFGtemp.szNotifySoundWAVfile);						

			SetDlgItemText(hDlg,IDC_EDIT_MIRC,g_sMIRCoutput.c_str());
					
			CheckDlgButton(hDlg,IDC_CHECK_EXT_ACTIVE,AppCFGtemp.bUse_EXT_APP);
			CheckDlgButton(hDlg,IDC_CHECK_EXT_ACTIVE2,AppCFGtemp.bUse_EXT_APP2);
			CheckDlgButton(hDlg,IDC_CHECK_MIRC,AppCFGtemp.bUseMIRC);
	

		   g_lang.EnumerateLanguage();
		   for( map<string,string>::iterator ii=g_lang.m_Languages.begin(); ii!=g_lang.m_Languages.end(); ++ii)
		   {			   
			   const TCHAR *psz = (*ii).first.c_str() ;
			   SendMessage(GetDlgItem(hDlg,IDC_COMBO_LANG),   (UINT) CB_ADDSTRING, 0, (LPARAM)psz );  			
		   }
		   
		   SendMessage(GetDlgItem(hDlg,IDC_COMBO_LANG),   (UINT) CB_SELECTSTRING, 0, (LPARAM)g_lang.m_strCurrentLang.c_str() );  			
		
			int gameID=-1;
			gameID = CFG_GetGameID(g_currSelCfg);
			if(gameID!=-1)
			{
				sprintf(szText,g_lang.GetString("CFGSettingsTitle"),GamesInfoCFG[gameID].szGAME_NAME);
				SetWindowText(GetDlgItem(hDlg,IDC_STATIC_GAME_NAME),szText);
				
				TCHAR szTempMaster[200];
				if(GamesInfoCFG[gameID].bUseHTTPServerList==FALSE)
					sprintf(szTempMaster,"%s:%d",GamesInfoCFG[gameID].szMasterServerIP[0],GamesInfoCFG[gameID].dwMasterServerPORT);
				else
					sprintf(szTempMaster,"%s",GamesInfoCFG[gameID].szMasterServerIP[0]);
	
				SetDlgItemText(hDlg,IDC_EDIT_MASTER_SERVER,szTempMaster);//GamesInfoCFG[gameID].szMasterServerIP[0]);

			
				CheckDlgButton(hDlg,IDC_CHECK_USE_HTTP,GamesInfoCFG[gameID].bUseHTTPServerList[0]);								
				CheckDlgButton(hDlg,IDC_CHECK_ACTIVE,GamesInfoCFG[gameID].bActive);

				sprintf(szText,"Example web protocol: %s://10.0.0.1:%d",gm.GamesInfo[gameID].szWebProtocolName,gm.GamesInfo[gameID].dwDefaultPort);
				SetDlgItemText(hDlg,IDC_STATIC_WEB_PROTOCOL,szText);


				CFG_Enumerate_installations(hDlg,gameID);
			}
			SetDlgItemText(hDlg,IDC_BUTTON_ADD_INSTALL,g_lang.GetString("CFGAddInstall"));
			SetDlgItemText(hDlg,IDC_BUTTON_EDIT_INSTALL,g_lang.GetString("CFGEditInstall"));
			SetDlgItemText(hDlg,IDC_BUTTON_DELETE_INSTALL,g_lang.GetString("CFGDeleteInstall"));

			SetDlgItemText(hDlg,IDC_EDIT_EXT_EXE,AppCFGtemp.szEXT_EXE_PATH);
			SetDlgItemText(hDlg,IDC_EDIT_EXT_CMD,AppCFGtemp.szEXT_EXE_CMD);
			SetDlgItemText(hDlg,IDC_EDIT_EXT_WINDOWNAME,AppCFGtemp.szEXT_EXE_WINDOWNAME);
			SetDlgItemText(hDlg,IDC_EDIT_WINDOWNAME,AppCFGtemp.szET_WindowName);

			SetDlgItemText(hDlg,IDC_EDIT_EXT_EXE2,AppCFGtemp.szOnReturn_EXE_PATH);
			SetDlgItemText(hDlg,IDC_EDIT_EXT_CMD2,AppCFGtemp.szOnReturn_EXE_CMD);


			SetDlgItemText(hDlg,IDC_STATIC_INSTALL_PATH,EXE_PATH);		

			g_hwndScrollTrans = GetDlgItem(hDlg,IDC_SLIDER_TRANS);
			SendMessage(g_hwndScrollTrans,TBM_SETRANGE,TRUE,(LPARAM)MAKELONG(MIN_TRANSPARANCY, 100)) ; //AppCFG.g_cTransparancy);
			SendMessage(g_hwndScrollTrans,TBM_SETPOS,TRUE,(LPARAM)AppCFGtemp.g_cTransparancy ) ; //AppCFG.g_cTransparancy);
			SetDlgTrans(hDlg,AppCFGtemp.g_cTransparancy);



			 g_hwndSleepSlider =  GetDlgItem(hDlg,IDC_SLIDER_SLEEP_VAL);
			SendMessage(g_hwndSleepSlider,TBM_SETRANGE,TRUE,(LPARAM)MAKELONG(0, 2000)) ;
			SendMessage(g_hwndSleepSlider,TBM_SETPOS,TRUE,(LPARAM)AppCFGtemp.dwSleep) ; 
			TCHAR sztemp[100];
			sprintf(sztemp,"Sleep time is %d ms",AppCFGtemp.dwSleep);
			SetDlgItemText(hDlg,IDC_STATIC_SLEEP_VAL,sztemp);


			g_hwndScrollThreads =  GetDlgItem(hDlg,IDC_SLIDER_THREADS);
			SendMessage( g_hwndScrollThreads,TBM_SETRANGE,TRUE,(LPARAM)MAKELONG(1, 256)) ;
			SendMessage(g_hwndScrollThreads,TBM_SETPOS,TRUE,(LPARAM)AppCFGtemp.dwThreads) ; 

				
			SetDlgItemText(hDlg,IDC_STATIC_THREAD,_itoa(AppCFGtemp.dwThreads ,sztemp,10));
			break;
		}
		case WM_VSCROLL:
		{
			if(lParam==(LPARAM)g_hwndScrollTrans)
			{
				int i = (TCHAR)SendMessage(GetDlgItem(hDlg,IDC_SLIDER_TRANS),TBM_GETPOS,0,(LPARAM)0) ; 
				SetDlgTrans(GetParent(hDlg),i);
			} else if (lParam==(LPARAM)g_hwndScrollThreads)
			{
				DWORD i = (DWORD)SendMessage(GetDlgItem(hDlg,IDC_SLIDER_THREADS),TBM_GETPOS,0,(LPARAM)0) ; 
				TCHAR sztemp[20];
				AppCFGtemp.dwThreads = i;
				SetDlgItemText(hDlg,IDC_STATIC_THREAD,_itoa(i,sztemp,10));
			}	
			else if (lParam==(LPARAM)g_hwndSleepSlider)
			{
				DWORD i = (DWORD)SendMessage(GetDlgItem(hDlg,IDC_SLIDER_SLEEP_VAL),TBM_GETPOS,0,(LPARAM)0) ; 
				TCHAR sztemp[100];
				AppCFG.dwSleep = i;
				AppCFGtemp.dwSleep = i;
				sprintf(sztemp,"Sleep time is %d ms",i);
				SetDlgItemText(hDlg,IDC_STATIC_SLEEP_VAL,sztemp);
			}
			return FALSE;
		}
		case WM_COMMAND:

			switch(HIWORD(wParam))		
			{
				case CBN_SELCHANGE:
					{
						if(LOWORD(wParam)==IDC_COMBO_LANG)
						{							
							TCHAR sztemp[200];
							int idx=   SendMessage(GetDlgItem(hDlg,IDC_COMBO_LANG),   (UINT) CB_GETCURSEL, 0, (LPARAM)0 );  
							SendMessage(GetDlgItem(hDlg,IDC_COMBO_LANG),   (UINT) CB_GETLBTEXT, idx, (LPARAM)sztemp );
							strcpy(AppCFGtemp.szLanguageFilename,g_lang.m_Languages[sztemp].c_str());
							g_lang.loadFile(g_lang.m_Languages[sztemp].c_str());
							MessageBox(NULL,g_lang.GetString("AlertRestartRequired"),"Alert!",MB_OK);							 
						}
					}
					break;

				case CBN_CLOSEUP :
					g_bChanged = true;
				
					break;
				case BN_CLICKED:					
					break;
				case EN_CHANGE:
				{
					g_bChanged = true;								
				}
			}
			
			switch (LOWORD(wParam))
            {
				case IDC_CHECK_USE_HTTP:
					g_bChanged = true;
					break;
				case IDC_BUTTON_SEL_FONT:
					HFONT hf;
					hf = CFG_SelectFont();
					DeleteObject(g_hf);				
					g_hf = hf;
					ChangeFont(g_hWnd, g_hf);
					break;
				case IDCANCEL:	
					EndDialog(hDlg, 0);
				break;
				case IDC_BUTTON_ADD_INSTALL:
					{
						DialogBox(g_hInst, (LPCTSTR)IDD_ADD_NEW_GAME_INSTALLATION, hDlg, (DLGPROC)CFG_AddNewInstall_Proc);				
						int gameID = CFG_GetGameID(g_currSelCfg);			
						CFG_Enumerate_installations(hDlg,gameID);
					}
					break;
				case IDC_BUTTON_EDIT_INSTALL:
					{
						int n;
						n = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_LIST_CFG_EXES));
						if(n!=-1)
						{
							DialogBoxParam(g_hInst, (LPCTSTR)IDD_ADD_NEW_GAME_INSTALLATION, hDlg, (DLGPROC)CFG_EditInstall_Proc,n);				
							int gameID = CFG_GetGameID(g_currSelCfg);			
							CFG_Enumerate_installations(hDlg,gameID);
						}
					}
					break;
				case IDC_BUTTON_DELETE_INSTALL:
					{
						int n;
						n = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_LIST_CFG_EXES));
						if(n!=-1)
						{
									
							int gameID = CFG_GetGameID(g_currSelCfg);	
							if(gameID!=-1)
							{
								GamesInfoCFG[gameID].vGAME_INST.erase(GamesInfoCFG[gameID].vGAME_INST.begin()+n);
								CFG_Enumerate_installations(hDlg,gameID);
							}
						}
					}
					break;

				case IDC_EXT_EXE:
				{
			
					OPENFILENAME ofn;
					memset(&ofn,0,sizeof(OPENFILENAME));
					ofn.lStructSize = sizeof (OPENFILENAME);
					ofn.hwndOwner = hDlg;
					ofn.lpstrFilter = NULL;
					ofn.lpstrFile = szFile;
					ofn.lpstrFile[0] = '\0';
					ofn.nMaxFile = sizeof(szFile);
					ofn.lpstrFilter = "All\0*.*\0External exe\0*.exe\0";
					ofn.nFilterIndex = 2;
					ofn.lpstrFileTitle = NULL;
					ofn.nMaxFileTitle = 0;
					ofn.lpstrInitialDir = NULL;
					ofn.lpstrInitialDir = AppCFGtemp.szEXT_EXE_PATH;
					ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

					if(GetOpenFileName(&ofn))
						SetDlgItemText(hDlg,IDC_EDIT_EXT_EXE,ofn.lpstrFile);

					return TRUE;
				}
	
				case IDC_EXT_EXE2:
				{
			
					OPENFILENAME ofn;
					memset(&ofn,0,sizeof(OPENFILENAME));
					ofn.lStructSize = sizeof (OPENFILENAME);
					ofn.hwndOwner = hDlg;
					ofn.lpstrFilter = NULL;
					ofn.lpstrFile = szFile;
					ofn.lpstrFile[0] = '\0';
					ofn.nMaxFile = sizeof(szFile);
					ofn.lpstrFilter = "All\0*.*\0External exe\0*.exe\0";
					ofn.nFilterIndex = 2;
					ofn.lpstrFileTitle = NULL;
					ofn.nMaxFileTitle = 0;
					ofn.lpstrInitialDir = NULL;
					ofn.lpstrInitialDir = AppCFGtemp.szOnReturn_EXE_PATH;
					ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

					if(GetOpenFileName(&ofn))
						SetDlgItemText(hDlg,IDC_EDIT_EXT_EXE2,ofn.lpstrFile);

					return TRUE;
				}

				case IDC_BUTTON_WAV_FILE:
				{
			
					OPENFILENAME ofn;
					memset(&ofn,0,sizeof(OPENFILENAME));
					ofn.lStructSize = sizeof (OPENFILENAME);
					ofn.hwndOwner = hDlg;
					ofn.lpstrFilter = NULL;
					ofn.lpstrFile = szFile;
					ofn.lpstrFile[0] = '\0';
					ofn.nMaxFile = sizeof(szFile);
					ofn.lpstrFilter = "All\0*.*\0Wav\0*.wav\0";
					ofn.nFilterIndex = 2;
					ofn.lpstrFileTitle = NULL;
					ofn.nMaxFileTitle = 0;
					ofn.lpstrInitialDir = NULL;
					ofn.lpstrInitialDir = AppCFGtemp.szNotifySoundWAVfile;
					ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

					if(GetOpenFileName(&ofn))
						SetDlgItemText(hDlg,IDC_EDIT_WAV_FILE,ofn.lpstrFile);

					return TRUE;
				}
			}
			break;
	}

	return FALSE;
}
コード例 #18
0
ファイル: q3.cpp プロジェクト: elitak/gamescanner
DWORD Q3_ConnectToMasterServer(GAME_INFO *pGI, int iMasterIdx)
{
	size_t packetlen=0;
	char sendbuf[80];
	ZeroMemory(sendbuf,sizeof(sendbuf));
	SOCKET ConnectSocket;

//	UINT_PTR timerProgressWait = SetTimer(g_hWnd,IDT_TIMER_1SECOND,100,NULL);
	
	int i = 0;
	unsigned char *packet[MAX_PACKETS];
	size_t packet_len[MAX_PACKETS];

	for(i=0; i<MAX_PACKETS;i++)
		packet[i] = NULL;

	i = 0;

	char szIP[260];
	strcpy(szIP,pGI->szMasterServerIP[iMasterIdx]);
	
	SplitIPandPORT(szIP,pGI->dwMasterServerPORT);

	int len = 0;//(int)strlen(sendbuf);
	string query;
	query = pGI->szMasterQueryString;
	ReplaceStrInStr(query,"%PROTOCOL%",pGI->szGameProtocol[iMasterIdx]);
	len = UTILZ_ConvertEscapeCodes((TCHAR*)query.c_str(),sendbuf,sizeof(sendbuf));

	ConnectSocket = getsockudp(szIP,(unsigned short)pGI->dwMasterServerPORT); // etmaster.idsoftware.com"27950 master server
	if(INVALID_SOCKET==ConnectSocket)
	{

		KillTimer(g_hWnd,IDT_1SECOND);
		g_log.AddLogInfo(GS_LOG_ERROR,"Error connecting to server %s:%d!",szIP,pGI->dwMasterServerPORT);
		return 1;
	}

	WSAEVENT hEvent;
	hEvent = WSACreateEvent();
	if (hEvent == WSA_INVALID_EVENT)
	{
		KillTimer(g_hWnd,IDT_1SECOND);
		g_log.AddLogInfo(GS_LOG_ERROR,"WSACreateEvent() = WSA_INVALID_EVENT");
		closesocket(ConnectSocket);
		return 1;
	}

	//
	// Make the socket non-blocking and 
	// associate it with network events
	//
	int nRet;
	nRet = WSAEventSelect(ConnectSocket, hEvent,FD_READ|FD_CONNECT|FD_CLOSE);
	if (nRet == SOCKET_ERROR)
	{
		KillTimer(g_hWnd,IDT_1SECOND);
		g_log.AddLogInfo(GS_LOG_ERROR,"EventSelect() = SOCKET_ERROR");
		closesocket(ConnectSocket);
		WSACloseEvent(hEvent);
		return 5;
	}



	//
	// Handle async network events
	//

	WSANETWORKEVENTS events;
	while(1)
	{
		//
		// Wait for something to happen
		//
		//dbg_print("\nWaitForMultipleEvents()");
		DWORD dwRet;
		dwRet = WSAWaitForMultipleEvents(1, &hEvent, FALSE,4000,FALSE);
		if (dwRet == WSA_WAIT_TIMEOUT)
		{
			g_log.AddLogInfo(GS_LOG_ERROR,"WSAWaitForMultipleEvents = WSA_WAIT_TIMEOUT");
			break;
		}

		//
		// Figure out what happened
		//
		//g_log.AddLogInfo(0,"\nWSAEnumNetworkEvents()");
		nRet = WSAEnumNetworkEvents(ConnectSocket, hEvent, &events);
		if (nRet == SOCKET_ERROR)
		{
			g_log.AddLogInfo(GS_LOG_ERROR,"WSAEnumNetworkEvents() = SOCKET_ERROR");
			break;
		}

		//				 //
		// Handle events //
		//				 //

		// Connect event?
		if (events.lNetworkEvents & FD_CONNECT)
		{
			//g_log.AddLogInfo(0,"\nFD_CONNECT: %d", events.iErrorCode[FD_CONNECT_BIT]);
			g_log.AddLogInfo(0,"Master server %s",pGI->szMasterServerIP[0]);
			g_log.AddLogInfo(0,"Sending packet string: [%s]  Length: %d",sendbuf,len);
			g_log.AddLogInfo(0,"xml config: %s ",pGI->szMasterQueryString);

			if(send(ConnectSocket, sendbuf, len , 0)==SOCKET_ERROR) 
			{
				KillTimer(g_hWnd,IDT_1SECOND);
				WSACloseEvent(hEvent);
				closesocket(ConnectSocket);		
				g_log.AddLogInfo(GS_LOG_ERROR,"Error sending master query packet!");
				return 2;
			}
		}

		// Read event?
		if (events.lNetworkEvents & FD_READ)
		{
			//g_log.AddLogInfo(0,"\nFD_READ: %d, %d",events.iErrorCode[FD_READ_BIT],i);
			// Read the data and write it to stdout
			packet[i]=(unsigned char*)ReadPacket(ConnectSocket, &packetlen);
			packet_len[i] = packetlen;
			i++;

			if(i>=MAX_PACKETS)
				break;
	
		}

		// Close event?
		if (events.lNetworkEvents & FD_CLOSE)
		{
			g_log.AddLogInfo(0,"\nFD_CLOSE: %d",events.iErrorCode[FD_CLOSE_BIT]);
			break;
		}
/*
		// Write event?
		if (events.lNetworkEvents & FD_WRITE)
		{
			g_log.AddLogInfo(0,"\nFD_WRITE: %d",events.iErrorCode[FD_WRITE_BIT]);
		}
*/
	}
	
	closesocket(ConnectSocket);
	WSACloseEvent(hEvent);

	DWORD Q3_dwNewTotalServers=0;
	for(i=0; i<MAX_PACKETS;i++)
	{
		if(packet[i] != NULL)
		{
		    Q3_dwNewTotalServers += Q3_ParseServers((char*)packet[i],packet_len[i],pGI);
			free(packet[i]);			
			packet[i]=NULL;
			SetStatusText(pGI->iIconIndex,g_lang.GetString("StatusReceivingMaster"),Q3_dwNewTotalServers,pGI->szGAME_NAME);
			if(g_bCancel)
			{
				//ensure to clean up
				for(i=0; i<MAX_PACKETS;i++)
				{
					if(packet[i] != NULL)
					{
						free(packet[i]);			
						packet[i]=NULL;
					}
				}			
				break;
			}
			Sleep(50); //give cpu sometime to breath
		}
	}

//	KillTimer(g_hWnd,IDT_TIMER_1SECOND);
	pGI->dwTotalServers += Q3_dwNewTotalServers;


	return 0;
}
コード例 #19
0
ファイル: scanner.cpp プロジェクト: bdamage/gamescanner
DWORD WINAPI  Get_ServerStatusThread2(LPVOID lpParam)
{
	GAME_INFO *pGI = (GAME_INFO *)lpParam;
	SERVER_INFO *pSI=NULL;
	DWORD idx=0;
	DWORD size = pGI->vRefScanSI.size();

	char szScanStatus[256];  //cache local language status text
	strcpy(szScanStatus,g_lang.GetString("ScanStatus"));

	while(pGI->dwScanIdx<size)
	{			
		if(SCANNER_bCloseApp)
		{
			dbg_print("Stop scanning SIGNALED!");
			break;
		}
		
		pSI=NULL;

		EnterCriticalSection(&SCANNER_cs);
		if(pGI->dwScanIdx<size)
		{
			SetStatusText(pGI->iIconIndex,szScanStatus,pGI->dwScanIdx,size);
			pSI = pGI->vRefScanSI.at(pGI->dwScanIdx).pServerInfo; //pGI->vSI.at(pGI->vRefScanSI.at(pGI->dwScanIdx).dwIndex);
			pGI->dwScanIdx++;
		}
		LeaveCriticalSection(&SCANNER_cs);
		
		//Is there any more server to scan?
		if(pSI==NULL) //if(pSI->usPort==0) //if the port is zero then no equal empty SERVER_INFO structure, (Ugly hack but  it works :))
		{
			//OutputDebugString(">>>>ERROR? Breaked scanning thread\n");
			break;
		}

		//Do non-filtered scan of all servers
		Get_ServerStatus(pSI,NULL,NULL);			

		UpdateServerItem(size-pGI->dwScanIdx); 

		if(g_hwndProgressBar!=NULL)
				SendMessage(g_hwndProgressBar, PBM_STEPIT, (WPARAM) 0, 0);
			
		Sleep(AppCFG.dwSleep);				
	}

	SetStatusText(pGI->iIconIndex, g_lang.GetString("ScanWaitingForThreads") );
	
	//This ensures that all threads has been created properly and thread count critical sections works correctly
	//dbg_print("Waiting for all threads to finish the loop!\n");
	DWORD dwWaitResult = WaitForSingleObject(SCAN_hContinueEvent,INFINITE);    // infinite wait
	switch (dwWaitResult) 
	{
		// Both event objects were signaled.
		case WAIT_OBJECT_0: 
		//	dbg_print("WAIT_OBJECT_0:\n"); 
			break; 
		case WAIT_ABANDONED:
			dbg_print("WAIT_ABANDONED: \n"); 
			break;
		case WAIT_TIMEOUT:
			dbg_print("WAIT_TIMEOUT:\n"); 
			break;
		case WAIT_FAILED:
			dbg_print("WAIT_FAILED:\n"); 
			break;

		// An error occurred.
		default: 
			dbg_print("WaitForSingleObject error: \n");        
	}

	DWORD id=0;
	//Decrease thread counter....
	EnterCriticalSection( &SCANNER_CSthreadcounter ); 
	id = SCANNER_dwThreadCounter;
	SCANNER_dwThreadCounter--;  
	LeaveCriticalSection( &SCANNER_CSthreadcounter ); 
	
//	ExitThread(id);

	return id;
}