tools/installer/ChooseMethod.cpp
branchsourcemod-1.1.0
changeset 2283 03a67e41afbc
parent 1951 c7b4237fff50
child 2287 017a725c9d17
     1.1 --- a/tools/installer/ChooseMethod.cpp	Fri Mar 28 06:21:34 2008 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,203 +0,0 @@
     1.4 -#include "InstallerMain.h"
     1.5 -#include "InstallerUtil.h"
     1.6 -#include "ChooseMethod.h"
     1.7 -#include "Welcome.h"
     1.8 -#include "GamesList.h"
     1.9 -#include "SelectGame.h"
    1.10 -
    1.11 -unsigned int method_chosen = 0;
    1.12 -TCHAR method_path[MAX_PATH];
    1.13 -
    1.14 -bool SelectFolder(HWND hOwner)
    1.15 -{
    1.16 -	BROWSEINFO info;
    1.17 -	LPITEMIDLIST pidlist;
    1.18 -	TCHAR path[MAX_PATH];
    1.19 -
    1.20 -	if (FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
    1.21 -	{
    1.22 -		return false;
    1.23 -	}
    1.24 -	
    1.25 -	info.hwndOwner = hOwner;
    1.26 -	info.pidlRoot = NULL;
    1.27 -	info.pszDisplayName = path;
    1.28 -	info.lpszTitle = _T("Select a game/mod folder");
    1.29 -	info.ulFlags = BIF_EDITBOX | BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
    1.30 -	info.lpfn = NULL;
    1.31 -	info.lParam = 0;
    1.32 -	info.iImage = 0;
    1.33 -
    1.34 -	if ((pidlist = SHBrowseForFolder(&info)) == NULL)
    1.35 -	{
    1.36 -		CoUninitialize();
    1.37 -		return false;
    1.38 -	}
    1.39 -
    1.40 -	/* This hellish code is from MSDN and translate shortcuts to real targets.
    1.41 -	 * God almighty, I wish Window used real symlinks.
    1.42 -	 */
    1.43 -	bool acquire_success = false;
    1.44 -	bool is_link = false;
    1.45 -	IShellFolder *psf = NULL;
    1.46 -	LPCITEMIDLIST new_item_list;
    1.47 -	HRESULT hr;
    1.48 -	
    1.49 -	hr = SHBindToParent(pidlist, IID_IShellFolder, (void **)&psf, &new_item_list);
    1.50 -	if (SUCCEEDED(hr))
    1.51 -	{
    1.52 -		IShellLink *psl = NULL;
    1.53 -
    1.54 -		hr = psf->GetUIObjectOf(hOwner, 1, &new_item_list, IID_IShellLink, NULL, (void **)&psl);
    1.55 -		if (SUCCEEDED(hr))
    1.56 -		{
    1.57 -			LPITEMIDLIST new_item_list;
    1.58 -
    1.59 -			hr = psl->GetIDList(&new_item_list);
    1.60 -			if (SUCCEEDED(hr))
    1.61 -			{
    1.62 -				is_link = true;
    1.63 -
    1.64 -				hr = SHGetPathFromIDList(new_item_list, method_path);
    1.65 -				if (SUCCEEDED(hr))
    1.66 -				{
    1.67 -					acquire_success = true;
    1.68 -				}
    1.69 -
    1.70 -				CoTaskMemFree(new_item_list);
    1.71 -			}
    1.72 -			psl->Release();
    1.73 -		}
    1.74 -		psf->Release();
    1.75 -	}
    1.76 -
    1.77 -	if (!acquire_success && !is_link)
    1.78 -	{
    1.79 -		hr = SHGetPathFromIDList(pidlist, method_path);
    1.80 -		if (SUCCEEDED(hr))
    1.81 -		{
    1.82 -			acquire_success = true;
    1.83 -		}
    1.84 -	}
    1.85 -
    1.86 -	/* That was awful.  shoo, shoo, COM */
    1.87 -	CoTaskMemFree(pidlist);
    1.88 -	CoUninitialize();
    1.89 -
    1.90 -	return acquire_success;
    1.91 -}
    1.92 -
    1.93 -INT_PTR CALLBACK ChooseMethodHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
    1.94 -{
    1.95 -	switch (message)
    1.96 -	{
    1.97 -	case WM_COMMAND:
    1.98 -		{
    1.99 -			if (LOWORD(wParam) == ID_METHOD_BACK)
   1.100 -			{
   1.101 -				EndDialog(hDlg, (INT_PTR)DisplayWelcome);
   1.102 -				return (INT_PTR)TRUE;
   1.103 -			}
   1.104 -			else if (LOWORD(wParam) == ID_METHOD_EXIT
   1.105 -					 || LOWORD(wParam) == ID_CLOSE)
   1.106 -			{
   1.107 -				return AskToExit(hDlg);
   1.108 -			}
   1.109 -			else if (LOWORD(wParam) == IDC_METHOD_DED_SERVER
   1.110 -					 || LOWORD(wParam) == IDC_METHOD_ALONE_SERVER
   1.111 -					 || LOWORD(wParam) == IDC_METHOD_LISTEN_SERVER
   1.112 -					 || LOWORD(wParam) == IDC_METHOD_UPLOAD_FTP
   1.113 -					 || LOWORD(wParam) == IDC_METHOD_CUSTOM_FOLDER)
   1.114 -			{
   1.115 -				method_chosen = LOWORD(wParam);
   1.116 -				HWND button = GetDlgItem(hDlg, ID_METHOD_NEXT);
   1.117 -				EnableWindow(button, TRUE);
   1.118 -				break;
   1.119 -			}
   1.120 -			else if (LOWORD(wParam) == ID_METHOD_NEXT)
   1.121 -			{
   1.122 -				unsigned int game_type = 0;
   1.123 -
   1.124 -				switch (method_chosen)
   1.125 -				{
   1.126 -				case IDC_METHOD_DED_SERVER:
   1.127 -					{
   1.128 -						game_type = GAMES_DEDICATED;
   1.129 -						break;
   1.130 -					}
   1.131 -				case IDC_METHOD_ALONE_SERVER:
   1.132 -					{
   1.133 -						game_type = GAMES_STANDALONE;
   1.134 -						break;
   1.135 -					}
   1.136 -				case IDC_METHOD_LISTEN_SERVER:
   1.137 -					{
   1.138 -						game_type = GAMES_LISTEN;
   1.139 -						break;
   1.140 -					}
   1.141 -				case IDC_METHOD_UPLOAD_FTP:
   1.142 -					{
   1.143 -						break;
   1.144 -					}
   1.145 -				case IDC_METHOD_CUSTOM_FOLDER:
   1.146 -					{
   1.147 -						int val;
   1.148 -
   1.149 -						if (!SelectFolder(hDlg))
   1.150 -						{
   1.151 -							break;
   1.152 -						}
   1.153 -						
   1.154 -						val = IsValidFolder(method_path);
   1.155 -						if (val != GAMEINFO_IS_USABLE)
   1.156 -						{
   1.157 -							DisplayBadFolderDialog(hDlg, val);
   1.158 -							break;
   1.159 -						}
   1.160 -					}
   1.161 -				}
   1.162 -
   1.163 -				if (game_type != 0)
   1.164 -				{
   1.165 -					int reason;
   1.166 -
   1.167 -					if ((reason = FindGames(game_type)) < 1)
   1.168 -					{
   1.169 -						DisplayBadGamesDialog(hDlg, game_type, reason);
   1.170 -						break;
   1.171 -					}
   1.172 -
   1.173 -					/* If we got a valid games list, we can display the next 
   1.174 -					 * dialog box.
   1.175 -					 */
   1.176 -					EndDialog(hDlg, (INT_PTR)DisplaySelectGame);
   1.177 -					return (INT_PTR)TRUE;
   1.178 -				}
   1.179 -			}
   1.180 -			break;
   1.181 -		}
   1.182 -	case WM_INITDIALOG:
   1.183 -		{
   1.184 -			return (INT_PTR)TRUE;
   1.185 -		}
   1.186 -	}
   1.187 -
   1.188 -	return (INT_PTR)FALSE;
   1.189 -}
   1.190 -
   1.191 -void *DisplayChooseMethod(HWND hWnd)
   1.192 -{
   1.193 -	INT_PTR val;
   1.194 -	
   1.195 -	if ((val = DialogBox(
   1.196 -		g_hInstance, 
   1.197 -		MAKEINTRESOURCE(IDD_CHOOSE_METHOD),
   1.198 -		hWnd,
   1.199 -		ChooseMethodHandler)) == -1)
   1.200 -	{
   1.201 -		return NULL;
   1.202 -	}
   1.203 -
   1.204 -	return (void *)val;
   1.205 -}
   1.206 -