initial import of incomplete installer
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401657
This commit is contained in:
parent
45f99fbb9c
commit
142fb2f652
203
tools/installer/ChooseMethod.cpp
Normal file
203
tools/installer/ChooseMethod.cpp
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
#include "InstallerMain.h"
|
||||||
|
#include "InstallerUtil.h"
|
||||||
|
#include "ChooseMethod.h"
|
||||||
|
#include "Welcome.h"
|
||||||
|
#include "GamesList.h"
|
||||||
|
#include "SelectGame.h"
|
||||||
|
|
||||||
|
unsigned int method_chosen = 0;
|
||||||
|
TCHAR method_path[MAX_PATH];
|
||||||
|
|
||||||
|
bool SelectFolder(HWND hOwner)
|
||||||
|
{
|
||||||
|
BROWSEINFO info;
|
||||||
|
LPITEMIDLIST pidlist;
|
||||||
|
TCHAR path[MAX_PATH];
|
||||||
|
|
||||||
|
if (FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
info.hwndOwner = hOwner;
|
||||||
|
info.pidlRoot = NULL;
|
||||||
|
info.pszDisplayName = path;
|
||||||
|
info.lpszTitle = _T("Select a game/mod folder");
|
||||||
|
info.ulFlags = BIF_EDITBOX | BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
|
||||||
|
info.lpfn = NULL;
|
||||||
|
info.lParam = 0;
|
||||||
|
info.iImage = 0;
|
||||||
|
|
||||||
|
if ((pidlist = SHBrowseForFolder(&info)) == NULL)
|
||||||
|
{
|
||||||
|
CoUninitialize();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This hellish code is from MSDN and translate shortcuts to real targets.
|
||||||
|
* God almighty, I wish Window used real symlinks.
|
||||||
|
*/
|
||||||
|
bool acquire_success = false;
|
||||||
|
bool is_link = false;
|
||||||
|
IShellFolder *psf = NULL;
|
||||||
|
LPCITEMIDLIST new_item_list;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
hr = SHBindToParent(pidlist, IID_IShellFolder, (void **)&psf, &new_item_list);
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
IShellLink *psl = NULL;
|
||||||
|
|
||||||
|
hr = psf->GetUIObjectOf(hOwner, 1, &new_item_list, IID_IShellLink, NULL, (void **)&psl);
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
LPITEMIDLIST new_item_list;
|
||||||
|
|
||||||
|
hr = psl->GetIDList(&new_item_list);
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
is_link = true;
|
||||||
|
|
||||||
|
hr = SHGetPathFromIDList(new_item_list, method_path);
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
acquire_success = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CoTaskMemFree(new_item_list);
|
||||||
|
}
|
||||||
|
psl->Release();
|
||||||
|
}
|
||||||
|
psf->Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!acquire_success && !is_link)
|
||||||
|
{
|
||||||
|
hr = SHGetPathFromIDList(pidlist, method_path);
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
acquire_success = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* That was awful. shoo, shoo, COM */
|
||||||
|
CoTaskMemFree(pidlist);
|
||||||
|
CoUninitialize();
|
||||||
|
|
||||||
|
return acquire_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT_PTR CALLBACK ChooseMethodHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
switch (message)
|
||||||
|
{
|
||||||
|
case WM_COMMAND:
|
||||||
|
{
|
||||||
|
if (LOWORD(wParam) == ID_METHOD_BACK)
|
||||||
|
{
|
||||||
|
EndDialog(hDlg, (INT_PTR)DisplayWelcome);
|
||||||
|
return (INT_PTR)TRUE;
|
||||||
|
}
|
||||||
|
else if (LOWORD(wParam) == ID_METHOD_EXIT
|
||||||
|
|| LOWORD(wParam) == ID_CLOSE)
|
||||||
|
{
|
||||||
|
return AskToExit(hDlg);
|
||||||
|
}
|
||||||
|
else if (LOWORD(wParam) == IDC_METHOD_DED_SERVER
|
||||||
|
|| LOWORD(wParam) == IDC_METHOD_ALONE_SERVER
|
||||||
|
|| LOWORD(wParam) == IDC_METHOD_LISTEN_SERVER
|
||||||
|
|| LOWORD(wParam) == IDC_METHOD_UPLOAD_FTP
|
||||||
|
|| LOWORD(wParam) == IDC_METHOD_CUSTOM_FOLDER)
|
||||||
|
{
|
||||||
|
method_chosen = LOWORD(wParam);
|
||||||
|
HWND button = GetDlgItem(hDlg, ID_METHOD_NEXT);
|
||||||
|
EnableWindow(button, TRUE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (LOWORD(wParam) == ID_METHOD_NEXT)
|
||||||
|
{
|
||||||
|
unsigned int game_type = 0;
|
||||||
|
|
||||||
|
switch (method_chosen)
|
||||||
|
{
|
||||||
|
case IDC_METHOD_DED_SERVER:
|
||||||
|
{
|
||||||
|
game_type = GAMES_DEDICATED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case IDC_METHOD_ALONE_SERVER:
|
||||||
|
{
|
||||||
|
game_type = GAMES_STANDALONE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case IDC_METHOD_LISTEN_SERVER:
|
||||||
|
{
|
||||||
|
game_type = GAMES_LISTEN;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case IDC_METHOD_UPLOAD_FTP:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case IDC_METHOD_CUSTOM_FOLDER:
|
||||||
|
{
|
||||||
|
int val;
|
||||||
|
|
||||||
|
if (!SelectFolder(hDlg))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
val = IsValidFolder(method_path);
|
||||||
|
if (val != GAMEINFO_IS_USABLE)
|
||||||
|
{
|
||||||
|
DisplayBadFolderDialog(hDlg, val);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (game_type != 0)
|
||||||
|
{
|
||||||
|
int reason;
|
||||||
|
|
||||||
|
if ((reason = FindGames(game_type)) < 1)
|
||||||
|
{
|
||||||
|
DisplayBadGamesDialog(hDlg, game_type, reason);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we got a valid games list, we can display the next
|
||||||
|
* dialog box.
|
||||||
|
*/
|
||||||
|
EndDialog(hDlg, (INT_PTR)DisplaySelectGame);
|
||||||
|
return (INT_PTR)TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WM_INITDIALOG:
|
||||||
|
{
|
||||||
|
return (INT_PTR)TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (INT_PTR)FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *DisplayChooseMethod(HWND hWnd)
|
||||||
|
{
|
||||||
|
INT_PTR val;
|
||||||
|
|
||||||
|
if ((val = DialogBox(
|
||||||
|
g_hInstance,
|
||||||
|
MAKEINTRESOURCE(IDD_CHOOSE_METHOD),
|
||||||
|
hWnd,
|
||||||
|
ChooseMethodHandler)) == -1)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (void *)val;
|
||||||
|
}
|
||||||
|
|
8
tools/installer/ChooseMethod.h
Normal file
8
tools/installer/ChooseMethod.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#ifndef _INCLUDE_INSTALLER_CHOOSE_METHOD_H_
|
||||||
|
#define _INCLUDE_INSTALLER_CHOOSE_METHOD_H_
|
||||||
|
|
||||||
|
#include "InstallerMain.h"
|
||||||
|
|
||||||
|
void *DisplayChooseMethod(HWND hWnd);
|
||||||
|
|
||||||
|
#endif //_INCLUDE_INSTALLER_CHOOSE_METHOD_H_
|
496
tools/installer/GamesList.cpp
Normal file
496
tools/installer/GamesList.cpp
Normal file
@ -0,0 +1,496 @@
|
|||||||
|
#include "GamesList.h"
|
||||||
|
#include "InstallerUtil.h"
|
||||||
|
#include "InstallerMain.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
mod_info_t *g_mod_list = NULL;
|
||||||
|
unsigned int g_mod_count = 0;
|
||||||
|
|
||||||
|
int IsValidFolder(const TCHAR *path)
|
||||||
|
{
|
||||||
|
DWORD attr;
|
||||||
|
TCHAR gameinfo_file[MAX_PATH];
|
||||||
|
|
||||||
|
UTIL_PathFormat(gameinfo_file, sizeof(gameinfo_file), _T("%s\\gameinfo.txt"), path);
|
||||||
|
|
||||||
|
if ((attr = GetFileAttributes(gameinfo_file)) == INVALID_FILE_ATTRIBUTES)
|
||||||
|
{
|
||||||
|
return GAMEINFO_DOES_NOT_EXIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((attr & FILE_ATTRIBUTE_READONLY) == FILE_ATTRIBUTE_READONLY)
|
||||||
|
{
|
||||||
|
return GAMEINFO_IS_READ_ONLY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((attr & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)
|
||||||
|
{
|
||||||
|
return GAMEINFO_DOES_NOT_EXIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GAMEINFO_IS_USABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayBadFolderDialog(HWND hDlg, int reason)
|
||||||
|
{
|
||||||
|
TCHAR message_string[255];
|
||||||
|
UINT resource;
|
||||||
|
|
||||||
|
if (reason == GAMEINFO_DOES_NOT_EXIST)
|
||||||
|
{
|
||||||
|
resource = IDS_NO_GAMEINFO;
|
||||||
|
}
|
||||||
|
else if (reason == GAMEINFO_IS_READ_ONLY)
|
||||||
|
{
|
||||||
|
resource = IDS_READONLY_GAMEINFO;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LoadString(g_hInstance,
|
||||||
|
resource,
|
||||||
|
message_string,
|
||||||
|
sizeof(message_string) / sizeof(TCHAR)
|
||||||
|
) == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBox(hDlg,
|
||||||
|
message_string,
|
||||||
|
_T("SourceMod Installer"),
|
||||||
|
MB_OK|MB_ICONWARNING);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddModToList(mod_info_t **mod_list,
|
||||||
|
unsigned int *total_mods,
|
||||||
|
const mod_info_t *mod_info)
|
||||||
|
{
|
||||||
|
mod_info_t *mods = *mod_list;
|
||||||
|
unsigned int total = *total_mods;
|
||||||
|
|
||||||
|
if (mods == NULL)
|
||||||
|
{
|
||||||
|
mods = (mod_info_t *)malloc(sizeof(mod_info_t));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mods = (mod_info_t *)realloc(mods, sizeof(mod_info_t) * (total + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(&mods[total], mod_info, sizeof(mod_info_t));
|
||||||
|
total++;
|
||||||
|
|
||||||
|
*mod_list = mods;
|
||||||
|
*total_mods = total;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TryToAddMod(const TCHAR *path, int eng_type, mod_info_t **mod_list, unsigned *total_mods)
|
||||||
|
{
|
||||||
|
FILE *fp;
|
||||||
|
TCHAR gameinfo_path[MAX_PATH];
|
||||||
|
|
||||||
|
UTIL_PathFormat(gameinfo_path,
|
||||||
|
sizeof(gameinfo_path),
|
||||||
|
_T("%s\\gameinfo.txt"),
|
||||||
|
path);
|
||||||
|
|
||||||
|
if ((fp = _tfopen(gameinfo_path, _T("rt"))) == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int pos;
|
||||||
|
char buffer[512];
|
||||||
|
char key[256], value[256];
|
||||||
|
while (!feof(fp) && fgets(buffer, sizeof(buffer), fp) != NULL)
|
||||||
|
{
|
||||||
|
if ((pos = BreakStringA(buffer, key, sizeof(key))) == -1)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ((pos = BreakStringA(&buffer[pos], value, sizeof(value))) == -1)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (strcmp(key, "game") == 0)
|
||||||
|
{
|
||||||
|
mod_info_t mod;
|
||||||
|
AnsiToUnicode(value, mod.name, sizeof(mod.name));
|
||||||
|
UTIL_Format(mod.mod_path, sizeof(mod.mod_path), _T("%s"), path);
|
||||||
|
mod.source_engine = eng_type;
|
||||||
|
AddModToList(mod_list, total_mods, &mod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddModsFromFolder(const TCHAR *path, int eng_type, mod_info_t **mod_list, unsigned int *total_mods)
|
||||||
|
{
|
||||||
|
HANDLE hFind;
|
||||||
|
WIN32_FIND_DATA fd;
|
||||||
|
TCHAR temp_path[MAX_PATH];
|
||||||
|
TCHAR search_path[MAX_PATH];
|
||||||
|
|
||||||
|
UTIL_Format(search_path,
|
||||||
|
sizeof(search_path),
|
||||||
|
_T("%s\\*.*"),
|
||||||
|
path);
|
||||||
|
|
||||||
|
if ((hFind = FindFirstFile(search_path, &fd)) == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tstrcasecmp(fd.cFileName, _T(".")) == 0
|
||||||
|
|| tstrcasecmp(fd.cFileName, _T("..")) == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
UTIL_PathFormat(temp_path,
|
||||||
|
sizeof(temp_path),
|
||||||
|
_T("%s\\%s"),
|
||||||
|
path,
|
||||||
|
fd.cFileName);
|
||||||
|
TryToAddMod(temp_path, eng_type, mod_list, total_mods);
|
||||||
|
|
||||||
|
} while (FindNextFile(hFind, &fd));
|
||||||
|
|
||||||
|
FindClose(hFind);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddValveModsFromFolder(const TCHAR *path,
|
||||||
|
unsigned int game_type,
|
||||||
|
mod_info_t **mod_list,
|
||||||
|
unsigned int *total_mods)
|
||||||
|
{
|
||||||
|
HANDLE hFind;
|
||||||
|
WIN32_FIND_DATA fd;
|
||||||
|
TCHAR temp_path[MAX_PATH];
|
||||||
|
TCHAR search_path[MAX_PATH];
|
||||||
|
|
||||||
|
UTIL_PathFormat(search_path,
|
||||||
|
sizeof(search_path) / sizeof(TCHAR),
|
||||||
|
_T("%s\\*.*"),
|
||||||
|
path);
|
||||||
|
|
||||||
|
if ((hFind = FindFirstFile(search_path, &fd)) == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tstrcasecmp(fd.cFileName, _T(".")) == 0
|
||||||
|
|| tstrcasecmp(fd.cFileName, _T("..")) == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
TCHAR *mod_folder = NULL;
|
||||||
|
int eng_type = SOURCE_ENGINE_UNKNOWN;
|
||||||
|
|
||||||
|
if (game_type == GAMES_LISTEN)
|
||||||
|
{
|
||||||
|
if (tstrcasecmp(fd.cFileName, _T( "counter-strike source")) == 0)
|
||||||
|
{
|
||||||
|
mod_folder = _T("cstrike");
|
||||||
|
}
|
||||||
|
else if (tstrcasecmp(fd.cFileName, _T("day of defeat source")) == 0)
|
||||||
|
{
|
||||||
|
mod_folder = _T("dod");
|
||||||
|
}
|
||||||
|
else if (tstrcasecmp(fd.cFileName, _T("half-life 2 deathmatch")) == 0)
|
||||||
|
{
|
||||||
|
mod_folder = _T("hl2mp");
|
||||||
|
}
|
||||||
|
else if (tstrcasecmp(fd.cFileName, _T("half-life deathmatch source")) == 0)
|
||||||
|
{
|
||||||
|
mod_folder = _T("hl1mp");
|
||||||
|
}
|
||||||
|
else if (tstrcasecmp(fd.cFileName, _T("team fortress 2")) == 0)
|
||||||
|
{
|
||||||
|
mod_folder = _T("tf");
|
||||||
|
eng_type = SOURCE_ENGINE_2007;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (game_type == GAMES_DEDICATED)
|
||||||
|
{
|
||||||
|
if (tstrcasecmp(fd.cFileName, _T("source dedicated server")) == 0)
|
||||||
|
{
|
||||||
|
UTIL_PathFormat(temp_path,
|
||||||
|
sizeof(temp_path) / sizeof(TCHAR),
|
||||||
|
_T("%s\\%s"),
|
||||||
|
path,
|
||||||
|
fd.cFileName);
|
||||||
|
AddModsFromFolder(temp_path, SOURCE_ENGINE_2004, mod_list, total_mods);
|
||||||
|
}
|
||||||
|
else if (tstrcasecmp(fd.cFileName, _T("source 2007 dedicated server")) == 0)
|
||||||
|
{
|
||||||
|
UTIL_PathFormat(temp_path,
|
||||||
|
sizeof(temp_path) / sizeof(TCHAR),
|
||||||
|
_T("%s\\%s"),
|
||||||
|
path,
|
||||||
|
fd.cFileName);
|
||||||
|
AddModsFromFolder(temp_path, SOURCE_ENGINE_2007, mod_list, total_mods);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mod_folder != NULL)
|
||||||
|
{
|
||||||
|
UTIL_PathFormat(temp_path,
|
||||||
|
sizeof(temp_path) / sizeof(TCHAR),
|
||||||
|
_T("%s\\%s\\%s"),
|
||||||
|
path,
|
||||||
|
fd.cFileName,
|
||||||
|
mod_folder);
|
||||||
|
TryToAddMod(temp_path, eng_type, mod_list, total_mods);
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (FindNextFile(hFind, &fd));
|
||||||
|
|
||||||
|
FindClose(hFind);
|
||||||
|
}
|
||||||
|
|
||||||
|
int BuildGameList(unsigned int game_type, mod_info_t **mod_list)
|
||||||
|
{
|
||||||
|
unsigned int total_mods = 0;
|
||||||
|
|
||||||
|
if (game_type == GAMES_LISTEN
|
||||||
|
|| game_type == GAMES_DEDICATED)
|
||||||
|
{
|
||||||
|
HKEY hkPath;
|
||||||
|
DWORD dwLen, dwType;
|
||||||
|
HANDLE hFind;
|
||||||
|
WIN32_FIND_DATA fd;
|
||||||
|
TCHAR temp_path[MAX_PATH];
|
||||||
|
TCHAR steam_path[MAX_PATH];
|
||||||
|
TCHAR steamapps_path[MAX_PATH];
|
||||||
|
|
||||||
|
if (RegOpenKeyEx(HKEY_CURRENT_USER,
|
||||||
|
_T("Software\\Valve\\Steam"),
|
||||||
|
0,
|
||||||
|
KEY_READ,
|
||||||
|
&hkPath) != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
DWORD err = GetLastError();
|
||||||
|
return GAME_LIST_CANT_READ;
|
||||||
|
}
|
||||||
|
|
||||||
|
dwLen = sizeof(steam_path) / sizeof(TCHAR);
|
||||||
|
if (RegQueryValueEx(hkPath,
|
||||||
|
_T("SteamPath"),
|
||||||
|
NULL,
|
||||||
|
&dwType,
|
||||||
|
(LPBYTE)steam_path,
|
||||||
|
&dwLen) != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
RegCloseKey(hkPath);
|
||||||
|
return GAME_LIST_CANT_READ;
|
||||||
|
}
|
||||||
|
|
||||||
|
UTIL_PathFormat(steamapps_path,
|
||||||
|
sizeof(steamapps_path) / sizeof(TCHAR),
|
||||||
|
_T("%s\\steamapps\\*.*"),
|
||||||
|
steam_path);
|
||||||
|
|
||||||
|
if ((hFind = FindFirstFile(steamapps_path, &fd)) == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
RegCloseKey(hkPath);
|
||||||
|
return GAME_LIST_CANT_READ;
|
||||||
|
}
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tstrcasecmp(fd.cFileName, _T(".")) == 0
|
||||||
|
|| tstrcasecmp(fd.cFileName, _T("..")) == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we get a folder called "SourceMods," look for third party mods */
|
||||||
|
if (game_type == GAMES_LISTEN
|
||||||
|
&& tstrcasecmp(fd.cFileName, _T("SourceMods")) == 0)
|
||||||
|
{
|
||||||
|
UTIL_PathFormat(temp_path,
|
||||||
|
sizeof(temp_path) / sizeof(TCHAR),
|
||||||
|
_T("%s\\steamapps\\%s"),
|
||||||
|
steam_path,
|
||||||
|
fd.cFileName);
|
||||||
|
AddModsFromFolder(temp_path, SOURCE_ENGINE_UNKNOWN, mod_list, &total_mods);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UTIL_PathFormat(temp_path,
|
||||||
|
sizeof(temp_path) / sizeof(TCHAR),
|
||||||
|
_T("%s\\steamapps\\%s"),
|
||||||
|
steam_path,
|
||||||
|
fd.cFileName);
|
||||||
|
AddValveModsFromFolder(temp_path, game_type, mod_list, &total_mods);
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (FindNextFile(hFind, &fd));
|
||||||
|
|
||||||
|
FindClose(hFind);
|
||||||
|
RegCloseKey(hkPath);
|
||||||
|
}
|
||||||
|
else if (game_type == GAMES_STANDALONE)
|
||||||
|
{
|
||||||
|
HKEY hkPath;
|
||||||
|
int eng_type = SOURCE_ENGINE_UNKNOWN;
|
||||||
|
DWORD dwLen, dwType, dwAttr;
|
||||||
|
TCHAR temp_path[MAX_PATH];
|
||||||
|
TCHAR hlds_path[MAX_PATH];
|
||||||
|
|
||||||
|
if (RegOpenKeyEx(HKEY_CURRENT_USER,
|
||||||
|
_T("Software\\Valve\\HLServer"),
|
||||||
|
0,
|
||||||
|
KEY_READ,
|
||||||
|
&hkPath) != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
return GAME_LIST_CANT_READ;
|
||||||
|
}
|
||||||
|
|
||||||
|
dwLen = sizeof(hlds_path) / sizeof(TCHAR);
|
||||||
|
if (RegQueryValueEx(hkPath,
|
||||||
|
_T("InstallPath"),
|
||||||
|
NULL,
|
||||||
|
&dwType,
|
||||||
|
(LPBYTE)hlds_path,
|
||||||
|
&dwLen) != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
RegCloseKey(hkPath);
|
||||||
|
return GAME_LIST_CANT_READ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make sure there is a "srcds.exe" file */
|
||||||
|
UTIL_PathFormat(temp_path,
|
||||||
|
sizeof(temp_path) / sizeof(TCHAR),
|
||||||
|
_T("%s\\srcds.exe"),
|
||||||
|
hlds_path);
|
||||||
|
dwAttr = GetFileAttributes(temp_path);
|
||||||
|
if (dwAttr == INVALID_FILE_ATTRIBUTES)
|
||||||
|
{
|
||||||
|
return GAME_LIST_HALFLIFE1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If there is an "orangebox" sub folder, we can make a better guess
|
||||||
|
* at the engine state.
|
||||||
|
*/
|
||||||
|
UTIL_PathFormat(temp_path,
|
||||||
|
sizeof(temp_path) / sizeof(TCHAR),
|
||||||
|
_T("%s\\orangebox"),
|
||||||
|
hlds_path);
|
||||||
|
dwAttr = GetFileAttributes(temp_path);
|
||||||
|
if (dwAttr != INVALID_FILE_ATTRIBUTES
|
||||||
|
&& ((dwAttr & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY))
|
||||||
|
{
|
||||||
|
eng_type = SOURCE_ENGINE_2004;
|
||||||
|
AddModsFromFolder(temp_path, SOURCE_ENGINE_2007, mod_list, &total_mods);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add everything from the server */
|
||||||
|
AddModsFromFolder(hlds_path, eng_type, mod_list, &total_mods);
|
||||||
|
|
||||||
|
RegCloseKey(hkPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (g_mod_list == NULL) ? GAME_LIST_NO_GAMES : (int)total_mods;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FreeGameList(mod_info_t *mod_list)
|
||||||
|
{
|
||||||
|
free(mod_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
int _SortModList(const void *item1, const void *item2)
|
||||||
|
{
|
||||||
|
const mod_info_t *mod1 = (const mod_info_t *)item1;
|
||||||
|
const mod_info_t *mod2 = (const mod_info_t *)item2;
|
||||||
|
|
||||||
|
return tstrcasecmp(mod1->name, mod2->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
int FindGames(unsigned int game_type)
|
||||||
|
{
|
||||||
|
int reason;
|
||||||
|
|
||||||
|
ReleaseGamesList();
|
||||||
|
|
||||||
|
if ((reason = BuildGameList(game_type, &g_mod_list)) > 0)
|
||||||
|
{
|
||||||
|
g_mod_count = (unsigned)reason;
|
||||||
|
qsort(g_mod_list, g_mod_count, sizeof(mod_info_t), _SortModList);
|
||||||
|
}
|
||||||
|
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReleaseGamesList()
|
||||||
|
{
|
||||||
|
if (g_mod_list == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(g_mod_list);
|
||||||
|
g_mod_list = NULL;
|
||||||
|
g_mod_count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayBadGamesDialog(HWND hWnd, unsigned int game_type, int reason)
|
||||||
|
{
|
||||||
|
TCHAR message[256];
|
||||||
|
UINT idc = 0;
|
||||||
|
|
||||||
|
if (reason == GAME_LIST_CANT_READ)
|
||||||
|
{
|
||||||
|
idc = IDS_GAME_FAIL_READ;
|
||||||
|
}
|
||||||
|
else if (reason == GAME_LIST_HALFLIFE1)
|
||||||
|
{
|
||||||
|
idc = IDS_GAME_FAIL_HL1;
|
||||||
|
}
|
||||||
|
else if (reason == GAME_LIST_NO_GAMES)
|
||||||
|
{
|
||||||
|
idc = IDS_GAME_FAIL_NONE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LoadString(g_hInstance,
|
||||||
|
idc,
|
||||||
|
message,
|
||||||
|
sizeof(message) / sizeof(TCHAR)) == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBox(hWnd,
|
||||||
|
message,
|
||||||
|
_T("SourceMod Installer"),
|
||||||
|
MB_OK|MB_ICONWARNING);
|
||||||
|
}
|
39
tools/installer/GamesList.h
Normal file
39
tools/installer/GamesList.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#ifndef _INCLUDE_INSTALLER_GAMES_LIST_H_
|
||||||
|
#define _INCLUDE_INSTALLER_GAMES_LIST_H_
|
||||||
|
|
||||||
|
#include "platform_headers.h"
|
||||||
|
|
||||||
|
#define GAMEINFO_IS_USABLE 0
|
||||||
|
#define GAMEINFO_DOES_NOT_EXIST 1
|
||||||
|
#define GAMEINFO_IS_READ_ONLY 2
|
||||||
|
|
||||||
|
#define GAME_LIST_HALFLIFE1 -2
|
||||||
|
#define GAME_LIST_CANT_READ -1
|
||||||
|
#define GAME_LIST_NO_GAMES 0
|
||||||
|
|
||||||
|
#define GAMES_DEDICATED 1
|
||||||
|
#define GAMES_LISTEN 2
|
||||||
|
#define GAMES_STANDALONE 3
|
||||||
|
|
||||||
|
#define SOURCE_ENGINE_UNKNOWN 0
|
||||||
|
#define SOURCE_ENGINE_2004 1
|
||||||
|
#define SOURCE_ENGINE_2007 2
|
||||||
|
|
||||||
|
struct mod_info_t
|
||||||
|
{
|
||||||
|
TCHAR name[128];
|
||||||
|
TCHAR mod_path[MAX_PATH];
|
||||||
|
int source_engine;
|
||||||
|
};
|
||||||
|
|
||||||
|
int IsValidFolder(const TCHAR *path);
|
||||||
|
void DisplayBadFolderDialog(HWND hWnd, int reason);
|
||||||
|
|
||||||
|
int FindGames(unsigned int game_type);
|
||||||
|
void DisplayBadGamesDialog(HWND hWnd, unsigned int game_type, int reason);
|
||||||
|
void ReleaseGamesList();
|
||||||
|
|
||||||
|
extern mod_info_t *g_mod_list;
|
||||||
|
extern unsigned int g_mod_count;
|
||||||
|
|
||||||
|
#endif //_INCLUDE_INSTALLER_GAMES_LIST_H_
|
23
tools/installer/ICopyMethod.h
Normal file
23
tools/installer/ICopyMethod.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef _INCLUDE_INSTALLER_COPY_METHOD_H_
|
||||||
|
#define _INCLUDE_INSTALLER_COPY_METHOD_H_
|
||||||
|
|
||||||
|
#include "platform_headers.h"
|
||||||
|
|
||||||
|
class ICopyProgress
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void UpdateProgress(float percent_complete) =0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ICopyMethod
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual bool CheckForExistingInstall() =0;
|
||||||
|
virtual void TrackProgress(ICopyProgress *pProgress) =0;
|
||||||
|
virtual bool SetCurrentFolder(const TCHAR *path, TCHAR *buffer, size_t maxchars) =0;
|
||||||
|
virtual bool SendFile(const TCHAR *path, TCHAR *buffer, size_t maxchars) =0;
|
||||||
|
virtual bool CreateFolder(const TCHAR *name, TCHAR *buffer, size_t maxchars) =0;
|
||||||
|
virtual void CancelCurrentCopy() =0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //_INCLUDE_INSTALLER_COPY_METHOD_H_
|
112
tools/installer/InstallerMain.cpp
Normal file
112
tools/installer/InstallerMain.cpp
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
#include "InstallerMain.h"
|
||||||
|
#include "Welcome.h"
|
||||||
|
|
||||||
|
#define WMU_INIT_INSTALLER WM_USER+1
|
||||||
|
|
||||||
|
HINSTANCE g_hInstance;
|
||||||
|
NEXT_DIALOG next_dialog = DisplayWelcome;
|
||||||
|
|
||||||
|
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
switch (message)
|
||||||
|
{
|
||||||
|
case WMU_INIT_INSTALLER:
|
||||||
|
{
|
||||||
|
while (next_dialog != NULL)
|
||||||
|
{
|
||||||
|
next_dialog = (NEXT_DIALOG)next_dialog(hWnd);
|
||||||
|
}
|
||||||
|
PostQuitMessage(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WM_DESTROY:
|
||||||
|
{
|
||||||
|
PostQuitMessage(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
|
||||||
|
{
|
||||||
|
WNDCLASSEX wcex;
|
||||||
|
BOOL bRet;
|
||||||
|
|
||||||
|
wcex.cbSize = sizeof(wcex);
|
||||||
|
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||||
|
wcex.lpfnWndProc = MainWndProc;
|
||||||
|
wcex.cbClsExtra = 0;
|
||||||
|
wcex.cbWndExtra = 0;
|
||||||
|
wcex.hInstance = hInstance;
|
||||||
|
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_INSTALLER));
|
||||||
|
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
|
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
||||||
|
wcex.lpszMenuName = _T("InstallerMenu");
|
||||||
|
wcex.lpszClassName = _T("Installer");
|
||||||
|
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
|
||||||
|
|
||||||
|
if (!RegisterClassEx(&wcex))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
INITCOMMONCONTROLSEX ccex;
|
||||||
|
ccex.dwSize = sizeof(ccex);
|
||||||
|
ccex.dwICC = ICC_BAR_CLASSES
|
||||||
|
|ICC_HOTKEY_CLASS
|
||||||
|
|ICC_LISTVIEW_CLASSES
|
||||||
|
|ICC_PROGRESS_CLASS
|
||||||
|
|ICC_WIN95_CLASSES
|
||||||
|
|ICC_TAB_CLASSES;
|
||||||
|
|
||||||
|
if (!InitCommonControlsEx(&ccex))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_hInstance = hInstance;
|
||||||
|
|
||||||
|
HWND hWnd = CreateWindow(
|
||||||
|
_T("Installer"),
|
||||||
|
_T("InstallerMain"),
|
||||||
|
WS_OVERLAPPEDWINDOW,
|
||||||
|
CW_USEDEFAULT,
|
||||||
|
CW_USEDEFAULT,
|
||||||
|
CW_USEDEFAULT,
|
||||||
|
CW_USEDEFAULT,
|
||||||
|
(HWND)NULL,
|
||||||
|
(HMENU)NULL,
|
||||||
|
hInstance,
|
||||||
|
NULL);
|
||||||
|
if (hWnd == NULL)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowWindow(hWnd, SW_HIDE);
|
||||||
|
UpdateWindow(hWnd);
|
||||||
|
|
||||||
|
PostMessage(hWnd, WMU_INIT_INSTALLER, 0, 0);
|
||||||
|
|
||||||
|
MSG msg;
|
||||||
|
while ((bRet = GetMessage(&msg, NULL, 0, 0)) != 0)
|
||||||
|
{
|
||||||
|
if (bRet == -1)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessage(&msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int)msg.wParam;
|
||||||
|
}
|
11
tools/installer/InstallerMain.h
Normal file
11
tools/installer/InstallerMain.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#ifndef _INCLUDE_INSTALLER_H_
|
||||||
|
#define _INCLUDE_INSTALLER_H_
|
||||||
|
|
||||||
|
#include "platform_headers.h"
|
||||||
|
#include "Resource.h"
|
||||||
|
|
||||||
|
typedef void *(*NEXT_DIALOG)(HWND);
|
||||||
|
|
||||||
|
extern HINSTANCE g_hInstance;
|
||||||
|
|
||||||
|
#endif //_INCLUDE_INSTALLER_H_
|
231
tools/installer/InstallerUtil.cpp
Normal file
231
tools/installer/InstallerUtil.cpp
Normal file
@ -0,0 +1,231 @@
|
|||||||
|
#include "InstallerUtil.h"
|
||||||
|
#include "InstallerMain.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
int tstrcasecmp(const TCHAR *str1, const TCHAR *str2)
|
||||||
|
{
|
||||||
|
#if defined _UNICODE
|
||||||
|
return _wcsicmp(str1, str2);
|
||||||
|
#else
|
||||||
|
return _stricmp(str1, str2);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t AnsiToUnicode(const char *str, wchar_t *buffer, size_t maxchars)
|
||||||
|
{
|
||||||
|
if (maxchars < 1)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t total =
|
||||||
|
(size_t)MultiByteToWideChar(CP_UTF8,
|
||||||
|
0,
|
||||||
|
str,
|
||||||
|
-1,
|
||||||
|
buffer,
|
||||||
|
(int)maxchars);
|
||||||
|
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsWhiteSpaceA(const char *stream)
|
||||||
|
{
|
||||||
|
char c = *stream;
|
||||||
|
if (c & (1<<7))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return isspace(c) != 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int BreakStringA(const char *str, char *out, size_t maxchars)
|
||||||
|
{
|
||||||
|
const char *inptr = str;
|
||||||
|
while (*inptr != '\0' && IsWhiteSpaceA(inptr))
|
||||||
|
{
|
||||||
|
inptr++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*inptr == '\0')
|
||||||
|
{
|
||||||
|
if (maxchars)
|
||||||
|
{
|
||||||
|
*out = '\0';
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *start, *end = NULL;
|
||||||
|
|
||||||
|
bool quoted = (*inptr == '"');
|
||||||
|
if (quoted)
|
||||||
|
{
|
||||||
|
inptr++;
|
||||||
|
start = inptr;
|
||||||
|
/* Read input until we reach a quote. */
|
||||||
|
while (*inptr != '\0' && *inptr != '"')
|
||||||
|
{
|
||||||
|
/* Update the end point, increment the stream. */
|
||||||
|
end = inptr++;
|
||||||
|
}
|
||||||
|
/* Read one more token if we reached an end quote */
|
||||||
|
if (*inptr == '"')
|
||||||
|
{
|
||||||
|
inptr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
start = inptr;
|
||||||
|
/* Read input until we reach a space */
|
||||||
|
while (*inptr != '\0' && !IsWhiteSpaceA(inptr))
|
||||||
|
{
|
||||||
|
/* Update the end point, increment the stream. */
|
||||||
|
end = inptr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Copy the string we found, if necessary */
|
||||||
|
if (end == NULL)
|
||||||
|
{
|
||||||
|
if (maxchars)
|
||||||
|
{
|
||||||
|
*out = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (maxchars)
|
||||||
|
{
|
||||||
|
char *outptr = out;
|
||||||
|
maxchars--;
|
||||||
|
for (const char *ptr=start;
|
||||||
|
(ptr <= end) && ((unsigned)(outptr - out) < (maxchars));
|
||||||
|
ptr++, outptr++)
|
||||||
|
{
|
||||||
|
*outptr = *ptr;
|
||||||
|
}
|
||||||
|
*outptr = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Consume more of the string until we reach non-whitespace */
|
||||||
|
while (*inptr != '\0' && IsWhiteSpaceA(inptr))
|
||||||
|
{
|
||||||
|
inptr++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int)(inptr - str);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t UTIL_Format(TCHAR *buffer, size_t count, const TCHAR *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
len = UTIL_FormatArgs(buffer, count, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (len >= count)
|
||||||
|
{
|
||||||
|
len = count - 1;
|
||||||
|
buffer[len] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t UTIL_FormatArgs(TCHAR *buffer, size_t count, const TCHAR *fmt, va_list ap)
|
||||||
|
{
|
||||||
|
size_t len = _vsntprintf(buffer, count, fmt, ap);
|
||||||
|
|
||||||
|
if (len >= count)
|
||||||
|
{
|
||||||
|
len = count - 1;
|
||||||
|
buffer[len] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t UTIL_PathFormat(TCHAR *buffer, size_t count, const TCHAR *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
len = UTIL_FormatArgs(buffer, count, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
if (buffer[i] == '/')
|
||||||
|
{
|
||||||
|
buffer[i] = '\\';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TCHAR *GetFileFromPath(const TCHAR *path)
|
||||||
|
{
|
||||||
|
size_t len = _tcslen(path);
|
||||||
|
|
||||||
|
for (size_t i = 0;
|
||||||
|
i >= 0 && i < len - 1;
|
||||||
|
i--)
|
||||||
|
{
|
||||||
|
if (path[i] == '\\' || path[i] == '/')
|
||||||
|
{
|
||||||
|
return &path[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GenerateErrorMessage(DWORD err, TCHAR *buffer, size_t maxchars)
|
||||||
|
{
|
||||||
|
if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
|
NULL,
|
||||||
|
err,
|
||||||
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
|
buffer,
|
||||||
|
(DWORD)maxchars,
|
||||||
|
NULL) == 0)
|
||||||
|
{
|
||||||
|
UTIL_Format(buffer, maxchars, _T("Unknown error"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
INT_PTR AskToExit(HWND hWnd)
|
||||||
|
{
|
||||||
|
TCHAR verify_exit[100];
|
||||||
|
|
||||||
|
if (LoadString(g_hInstance,
|
||||||
|
IDS_VERIFY_EXIT,
|
||||||
|
verify_exit,
|
||||||
|
sizeof(verify_exit) / sizeof(TCHAR)
|
||||||
|
) == 0)
|
||||||
|
{
|
||||||
|
return (INT_PTR)FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int val = MessageBox(
|
||||||
|
hWnd,
|
||||||
|
_T("Are you sure you want to exit?"),
|
||||||
|
_T("SourceMod Installer"),
|
||||||
|
MB_YESNO|MB_ICONQUESTION);
|
||||||
|
|
||||||
|
if (val == 0 || val == IDYES)
|
||||||
|
{
|
||||||
|
EndDialog(hWnd, NULL);
|
||||||
|
return (INT_PTR)TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (INT_PTR)FALSE;
|
||||||
|
}
|
18
tools/installer/InstallerUtil.h
Normal file
18
tools/installer/InstallerUtil.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#ifndef _INCLUDE_INSTALLER_UTIL_H_
|
||||||
|
#define _INCLUDE_INSTALLER_UTIL_H_
|
||||||
|
|
||||||
|
#include "platform_headers.h"
|
||||||
|
|
||||||
|
bool IsWhiteSpaceA(const char *stream);
|
||||||
|
size_t UTIL_FormatArgs(TCHAR *buffer, size_t count, const TCHAR *fmt, va_list ap);
|
||||||
|
size_t UTIL_Format(TCHAR *buffer, size_t count, const TCHAR *fmt, ...);
|
||||||
|
size_t UTIL_PathFormat(TCHAR *buffer, size_t count, const TCHAR *fmt, ...);
|
||||||
|
int tstrcasecmp(const TCHAR *str1, const TCHAR *str2);
|
||||||
|
int BreakStringA(const char *str, char *out, size_t maxchars);
|
||||||
|
size_t AnsiToUnicode(const char *str, wchar_t *buffer, size_t maxchars);
|
||||||
|
const TCHAR *GetFileFromPath(const TCHAR *path);
|
||||||
|
void GenerateErrorMessage(DWORD err, TCHAR *buffer, size_t maxchars);
|
||||||
|
|
||||||
|
INT_PTR AskToExit(HWND hWnd);
|
||||||
|
|
||||||
|
#endif //_INCLUDE_INSTALLER_UTIL_H_
|
158
tools/installer/LocalCopyMethod.cpp
Normal file
158
tools/installer/LocalCopyMethod.cpp
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
#include "InstallerUtil.h"
|
||||||
|
#include "LocalCopyMethod.h"
|
||||||
|
|
||||||
|
LocalCopyMethod g_LocalCopier;
|
||||||
|
|
||||||
|
DWORD CALLBACK CopyProgressRoutine(LARGE_INTEGER TotalFileSize,
|
||||||
|
LARGE_INTEGER TotalBytesTransferred,
|
||||||
|
LARGE_INTEGER StreamSize,
|
||||||
|
LARGE_INTEGER StreamBytesTransferred,
|
||||||
|
DWORD dwStreamNumber,
|
||||||
|
DWORD dwCallbackReason,
|
||||||
|
HANDLE hSourceFile,
|
||||||
|
HANDLE hDestinationFile,
|
||||||
|
LPVOID lpData)
|
||||||
|
{
|
||||||
|
ICopyProgress *progress = (ICopyProgress *)lpData;
|
||||||
|
|
||||||
|
float percent = (float)(TotalBytesTransferred.QuadPart) / (float)(TotalFileSize.QuadPart);
|
||||||
|
|
||||||
|
progress->UpdateProgress(percent);
|
||||||
|
|
||||||
|
return PROGRESS_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalCopyMethod::LocalCopyMethod()
|
||||||
|
{
|
||||||
|
m_pProgress = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LocalCopyMethod::SetOutputPath(const TCHAR *path)
|
||||||
|
{
|
||||||
|
UTIL_PathFormat(m_OutputPath,
|
||||||
|
sizeof(m_OutputPath) / sizeof(TCHAR),
|
||||||
|
_T("%s"),
|
||||||
|
path);
|
||||||
|
|
||||||
|
UTIL_PathFormat(m_CurrentPath,
|
||||||
|
sizeof(m_CurrentPath) / sizeof(TCHAR),
|
||||||
|
_T("%s"),
|
||||||
|
path);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LocalCopyMethod::TrackProgress(ICopyProgress *pProgress)
|
||||||
|
{
|
||||||
|
m_pProgress = pProgress;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LocalCopyMethod::CreateFolder(const TCHAR *name, TCHAR *buffer, size_t maxchars)
|
||||||
|
{
|
||||||
|
TCHAR path[MAX_PATH];
|
||||||
|
|
||||||
|
UTIL_PathFormat(path,
|
||||||
|
sizeof(path) / sizeof(TCHAR),
|
||||||
|
_T("%s\\%s"),
|
||||||
|
m_CurrentPath,
|
||||||
|
name);
|
||||||
|
|
||||||
|
if (CreateDirectory(name, NULL))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD error = GetLastError();
|
||||||
|
if (error == ERROR_ALREADY_EXISTS)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
GenerateErrorMessage(error, buffer, maxchars);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LocalCopyMethod::SetCurrentFolder(const TCHAR *path, TCHAR *buffer, size_t maxchars)
|
||||||
|
{
|
||||||
|
if (path == NULL)
|
||||||
|
{
|
||||||
|
UTIL_PathFormat(m_CurrentPath,
|
||||||
|
sizeof(m_CurrentPath) / sizeof(TCHAR),
|
||||||
|
_T("%s"),
|
||||||
|
m_OutputPath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UTIL_PathFormat(m_CurrentPath,
|
||||||
|
sizeof(m_CurrentPath) / sizeof(TCHAR),
|
||||||
|
_T("%s\\%s"),
|
||||||
|
m_OutputPath,
|
||||||
|
path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LocalCopyMethod::SendFile(const TCHAR *path, TCHAR *buffer, size_t maxchars)
|
||||||
|
{
|
||||||
|
const TCHAR *filename = GetFileFromPath(path);
|
||||||
|
|
||||||
|
if (filename == NULL)
|
||||||
|
{
|
||||||
|
UTIL_Format(buffer, maxchars, _T("Invalid filename"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
TCHAR new_path[MAX_PATH];
|
||||||
|
UTIL_PathFormat(new_path,
|
||||||
|
sizeof(new_path) / sizeof(TCHAR),
|
||||||
|
_T("%s\\%s"),
|
||||||
|
m_CurrentPath,
|
||||||
|
filename);
|
||||||
|
|
||||||
|
m_bCancelStatus = FALSE;
|
||||||
|
|
||||||
|
if (CopyFileEx(path,
|
||||||
|
new_path,
|
||||||
|
m_pProgress ? CopyProgressRoutine : NULL,
|
||||||
|
m_pProgress,
|
||||||
|
&m_bCancelStatus,
|
||||||
|
0) == 0)
|
||||||
|
{
|
||||||
|
/* Delete the file in case it was a partial copy */
|
||||||
|
DeleteFile(new_path);
|
||||||
|
|
||||||
|
GenerateErrorMessage(GetLastError(), buffer, maxchars);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LocalCopyMethod::CancelCurrentCopy()
|
||||||
|
{
|
||||||
|
m_bCancelStatus = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LocalCopyMethod::CheckForExistingInstall()
|
||||||
|
{
|
||||||
|
TCHAR path[MAX_PATH];
|
||||||
|
|
||||||
|
UTIL_PathFormat(path,
|
||||||
|
sizeof(path) / sizeof(TCHAR),
|
||||||
|
_T("%s\\addons\\sourcemod"),
|
||||||
|
m_CurrentPath);
|
||||||
|
if (GetFileAttributes(path) == INVALID_FILE_ATTRIBUTES)
|
||||||
|
{
|
||||||
|
UTIL_PathFormat(path,
|
||||||
|
sizeof(path) / sizeof(TCHAR),
|
||||||
|
_T("%s\\cfg\\sourcemod"),
|
||||||
|
m_CurrentPath);
|
||||||
|
if (GetFileAttributes(path) == INVALID_FILE_ATTRIBUTES)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
29
tools/installer/LocalCopyMethod.h
Normal file
29
tools/installer/LocalCopyMethod.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#ifndef _INCLUDE_INSTALL_LOCAL_COPY_METHOD_H_
|
||||||
|
#define _INCLUDE_INSTALL_LOCAL_COPY_METHOD_H_
|
||||||
|
|
||||||
|
#include "platform_headers.h"
|
||||||
|
#include "ICopyMethod.h"
|
||||||
|
|
||||||
|
class LocalCopyMethod : public ICopyMethod
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LocalCopyMethod();
|
||||||
|
public:
|
||||||
|
virtual void TrackProgress(ICopyProgress *pProgress);
|
||||||
|
virtual bool SetCurrentFolder(const TCHAR *path, TCHAR *buffer, size_t maxchars);
|
||||||
|
virtual bool SendFile(const TCHAR *path, TCHAR *buffer, size_t maxchars);
|
||||||
|
virtual bool CreateFolder(const TCHAR *name, TCHAR *buffer, size_t maxchars);
|
||||||
|
virtual void CancelCurrentCopy();
|
||||||
|
virtual bool CheckForExistingInstall();
|
||||||
|
public:
|
||||||
|
void SetOutputPath(const TCHAR *path);
|
||||||
|
private:
|
||||||
|
ICopyProgress *m_pProgress;
|
||||||
|
TCHAR m_OutputPath[MAX_PATH];
|
||||||
|
TCHAR m_CurrentPath[MAX_PATH];
|
||||||
|
BOOL m_bCancelStatus;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern LocalCopyMethod g_LocalCopier;
|
||||||
|
|
||||||
|
#endif //_INCLUDE_INSTALL_LOCAL_COPY_METHOD_H_
|
244
tools/installer/PerformInstall.cpp
Normal file
244
tools/installer/PerformInstall.cpp
Normal file
@ -0,0 +1,244 @@
|
|||||||
|
#include "InstallerMain.h"
|
||||||
|
#include "InstallerUtil.h"
|
||||||
|
#include "PerformInstall.h"
|
||||||
|
|
||||||
|
struct folder_t
|
||||||
|
{
|
||||||
|
TCHAR path[MAX_PATH];
|
||||||
|
};
|
||||||
|
|
||||||
|
ICopyMethod *g_pCopyMethod = NULL;
|
||||||
|
bool do_not_copy_binaries = false;
|
||||||
|
TCHAR source_path[MAX_PATH];
|
||||||
|
|
||||||
|
void SetInstallMethod(ICopyMethod *pCopyMethod)
|
||||||
|
{
|
||||||
|
g_pCopyMethod = pCopyMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CopyStructureRecursively(const TCHAR *basepath,
|
||||||
|
const TCHAR *local_path,
|
||||||
|
TCHAR *errbuf,
|
||||||
|
size_t maxchars)
|
||||||
|
{
|
||||||
|
HANDLE hFind;
|
||||||
|
WIN32_FIND_DATA fd;
|
||||||
|
TCHAR search_path[MAX_PATH];
|
||||||
|
folder_t *folder_list = NULL;
|
||||||
|
unsigned int folder_count = 0;
|
||||||
|
|
||||||
|
if (local_path == NULL)
|
||||||
|
{
|
||||||
|
UTIL_PathFormat(search_path,
|
||||||
|
sizeof(search_path) / sizeof(TCHAR),
|
||||||
|
_T("%s\\*.*"),
|
||||||
|
basepath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UTIL_PathFormat(search_path,
|
||||||
|
sizeof(search_path) / sizeof(TCHAR),
|
||||||
|
_T("%s\\%s\\*.*"),
|
||||||
|
basepath,
|
||||||
|
local_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!g_pCopyMethod->SetCurrentFolder(local_path, errbuf, maxchars))
|
||||||
|
{
|
||||||
|
/* :TODO: set fail state */
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((hFind = FindFirstFile(search_path, &fd)) == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
/* :TODO: set a fail state */
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (tstrcasecmp(fd.cFileName, _T(".")) == 0
|
||||||
|
|| tstrcasecmp(fd.cFileName, _T("..")) == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)
|
||||||
|
{
|
||||||
|
/* We cache the folder list so we don't have to keep changing folders back and forth,
|
||||||
|
* which could be annoying on a slow copy connection.
|
||||||
|
*/
|
||||||
|
if (folder_list == NULL)
|
||||||
|
{
|
||||||
|
folder_list = (folder_t *)malloc(sizeof(folder_t) * (folder_count + 1));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
folder_list = (folder_t *)realloc(folder_list, sizeof(folder_t) * (folder_count + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
UTIL_Format(folder_list[folder_count].path, MAX_PATH, _T("%s"), fd.cFileName);
|
||||||
|
folder_count++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TCHAR file_path[MAX_PATH];
|
||||||
|
|
||||||
|
if (local_path == NULL)
|
||||||
|
{
|
||||||
|
UTIL_PathFormat(file_path,
|
||||||
|
sizeof(file_path),
|
||||||
|
_T("%s\\%s"),
|
||||||
|
basepath,
|
||||||
|
fd.cFileName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UTIL_PathFormat(file_path,
|
||||||
|
sizeof(file_path),
|
||||||
|
_T("%s\\%s\\%s"),
|
||||||
|
basepath,
|
||||||
|
local_path,
|
||||||
|
fd.cFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!g_pCopyMethod->SendFile(file_path, errbuf, maxchars))
|
||||||
|
{
|
||||||
|
FindClose(hFind);
|
||||||
|
free(folder_list);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (FindNextFile(hFind, &fd));
|
||||||
|
|
||||||
|
FindClose(hFind);
|
||||||
|
|
||||||
|
/* Now copy folders */
|
||||||
|
for (unsigned int i = 0; i < folder_count; i++)
|
||||||
|
{
|
||||||
|
/* Try creating the folder */
|
||||||
|
if (!g_pCopyMethod->CreateFolder(folder_list[i].path, errbuf, maxchars))
|
||||||
|
{
|
||||||
|
free(folder_list);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
TCHAR new_local_path[MAX_PATH];
|
||||||
|
if (local_path == NULL)
|
||||||
|
{
|
||||||
|
UTIL_PathFormat(new_local_path,
|
||||||
|
sizeof(new_local_path) / sizeof(TCHAR),
|
||||||
|
_T("%s"),
|
||||||
|
folder_list[i].path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UTIL_PathFormat(new_local_path,
|
||||||
|
sizeof(new_local_path) / sizeof(TCHAR),
|
||||||
|
_T("%s\\%s"),
|
||||||
|
local_path,
|
||||||
|
folder_list[i].path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CopyStructureRecursively(basepath, new_local_path, errbuf, maxchars))
|
||||||
|
{
|
||||||
|
free(folder_list);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(folder_list);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool StartInstallProcess(HWND hWnd)
|
||||||
|
{
|
||||||
|
if (g_pCopyMethod->CheckForExistingInstall())
|
||||||
|
{
|
||||||
|
int val = MessageBox(
|
||||||
|
hWnd,
|
||||||
|
_T("It looks like a previous SourceMod installation exists. Do you want to upgrade? Select \"Yes\" to upgrade and keep configuration files. Select \"No\" to perform a full re-install."),
|
||||||
|
_T("SourceMod Installer"),
|
||||||
|
MB_YESNO|MB_ICONQUESTION);
|
||||||
|
|
||||||
|
if (val == 0 || val == IDYES)
|
||||||
|
{
|
||||||
|
do_not_copy_binaries = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
do_not_copy_binaries = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TCHAR cur_path[MAX_PATH];
|
||||||
|
if (_tgetcwd(cur_path, sizeof(cur_path)) == NULL)
|
||||||
|
{
|
||||||
|
MessageBox(
|
||||||
|
hWnd,
|
||||||
|
_T("Could not locate current directory!"),
|
||||||
|
_T("SourceMod Installer"),
|
||||||
|
MB_OK|MB_ICONERROR);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
UTIL_PathFormat(source_path,
|
||||||
|
sizeof(source_path) / sizeof(TCHAR),
|
||||||
|
_T("%s\\files"),
|
||||||
|
cur_path);
|
||||||
|
|
||||||
|
if (GetFileAttributes(source_path) == INVALID_FILE_ATTRIBUTES)
|
||||||
|
{
|
||||||
|
MessageBox(
|
||||||
|
hWnd,
|
||||||
|
_T("Could not locate the source installation files!"),
|
||||||
|
_T("SourceMod Installer"),
|
||||||
|
MB_OK|MB_ICONERROR);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT_PTR CALLBACK PerformInstallHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
switch (message)
|
||||||
|
{
|
||||||
|
case WM_INITDIALOG:
|
||||||
|
{
|
||||||
|
return (INT_PTR)TRUE;
|
||||||
|
}
|
||||||
|
case WM_COMMAND:
|
||||||
|
{
|
||||||
|
if (LOWORD(wParam) == ID_INSTALL_CANCEL
|
||||||
|
|| LOWORD(wParam) == ID_CLOSE)
|
||||||
|
{
|
||||||
|
/* :TODO: enhance */
|
||||||
|
EndDialog(hDlg, NULL);
|
||||||
|
return (INT_PTR)TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (INT_PTR)FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *DisplayPerformInstall(HWND hWnd)
|
||||||
|
{
|
||||||
|
INT_PTR val;
|
||||||
|
|
||||||
|
if ((val = DialogBox(
|
||||||
|
g_hInstance,
|
||||||
|
MAKEINTRESOURCE(IDD_PERFORM_INSTALL),
|
||||||
|
hWnd,
|
||||||
|
PerformInstallHandler)) == -1)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (void *)val;
|
||||||
|
}
|
10
tools/installer/PerformInstall.h
Normal file
10
tools/installer/PerformInstall.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef _INCLUDE_PERFORM_INSTALL_H_
|
||||||
|
#define _INCLUDE_PERFORM_INSTALL_H_
|
||||||
|
|
||||||
|
#include "InstallerMain.h"
|
||||||
|
#include "ICopyMethod.h"
|
||||||
|
|
||||||
|
void *DisplayPerformInstall(HWND hWnd);
|
||||||
|
void SetInstallMethod(ICopyMethod *pCopyMethod);
|
||||||
|
|
||||||
|
#endif //_INCLUDE_PERFORM_INSTALL_H_
|
59
tools/installer/Resource.h
Normal file
59
tools/installer/Resource.h
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
//{{NO_DEPENDENCIES}}
|
||||||
|
// Microsoft Visual C++ generated include file.
|
||||||
|
// Used by installer.rc
|
||||||
|
//
|
||||||
|
#define ID_CLOSE 2
|
||||||
|
#define IDD_INSTALLER_DIALOG 102
|
||||||
|
#define IDS_APP_TITLE 103
|
||||||
|
#define IDM_ABOUT 104
|
||||||
|
#define IDM_EXIT 105
|
||||||
|
#define IDI_INSTALLER 107
|
||||||
|
#define IDI_SMALL 108
|
||||||
|
#define IDC_INSTALLER 109
|
||||||
|
#define IDR_MAINFRAME 128
|
||||||
|
#define IDD_WELCOME 130
|
||||||
|
#define IDD_CHOOSE_METHOD 132
|
||||||
|
#define IDS_NO_GAMEINFO 132
|
||||||
|
#define IDS_READONLY_GAMEINFO 133
|
||||||
|
#define IDS_GAME_FAIL_HL1 134
|
||||||
|
#define IDS_GAME_FAIL_READ 135
|
||||||
|
#define IDS_GAME_FAIL_NONE 136
|
||||||
|
#define IDS_VERIFY_EXIT 137
|
||||||
|
#define ID_WELCOME_NEXT 1001
|
||||||
|
#define IDC_WELCOME_PANEL 1002
|
||||||
|
#define IDC_METHOD_TEXT 1003
|
||||||
|
#define ID_WELCOME_EXIT 1003
|
||||||
|
#define ID_METHOD_NEXT 1004
|
||||||
|
#define ID_METHOD_EXIT 1005
|
||||||
|
#define ID_METHOD_BACK 1006
|
||||||
|
#define IDC_METHOD_DED_SERVER 1007
|
||||||
|
#define IDC_METHOD_LISTEN_SERVER 1008
|
||||||
|
#define IDC_SELGAME_LIST 1008
|
||||||
|
#define IDC_METHOD_ALONE_SERVER 1009
|
||||||
|
#define IDC_METHOD_CUSTOM_FOLDER 1010
|
||||||
|
#define IDC_METHOD_UPLOAD_FTP 1011
|
||||||
|
#define ID_SELGAME_NEXT 1012
|
||||||
|
#define ID_SELGAME_EXIT 1013
|
||||||
|
#define ID_SELGAME_BACK 1014
|
||||||
|
#define IDC_SELGAME_TEXT 1015
|
||||||
|
#define IDC_SELGAME_PANEL 1016
|
||||||
|
#define IDD_SELECT_GAME 1017
|
||||||
|
#define IDD_PERFORM_INSTALL 1018
|
||||||
|
#define ID_INSTALL_CANCEL 1019
|
||||||
|
#define IDC_INSTALL_PANEL 1020
|
||||||
|
#define IDC_INSTALL_TEXT 1021
|
||||||
|
#define IDC_STATIC -1
|
||||||
|
#define IDC_WELCOME_TEXT -1
|
||||||
|
#define IDC_METHOD_PANEL -1
|
||||||
|
|
||||||
|
// Next default values for new objects
|
||||||
|
//
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
#define _APS_NO_MFC 1
|
||||||
|
#define _APS_NEXT_RESOURCE_VALUE 133
|
||||||
|
#define _APS_NEXT_COMMAND_VALUE 32771
|
||||||
|
#define _APS_NEXT_CONTROL_VALUE 1009
|
||||||
|
#define _APS_NEXT_SYMED_VALUE 110
|
||||||
|
#endif
|
||||||
|
#endif
|
138
tools/installer/SelectGame.cpp
Normal file
138
tools/installer/SelectGame.cpp
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
#include "InstallerMain.h"
|
||||||
|
#include "InstallerUtil.h"
|
||||||
|
#include "SelectGame.h"
|
||||||
|
#include "GamesList.h"
|
||||||
|
#include "ChooseMethod.h"
|
||||||
|
#include "PerformInstall.h"
|
||||||
|
#include "LocalCopyMethod.h"
|
||||||
|
|
||||||
|
int selected_game_index = -1;
|
||||||
|
mod_info_t **game_sel_list = NULL;
|
||||||
|
unsigned int game_sel_count = 0;
|
||||||
|
|
||||||
|
void AppendSelectableGame(mod_info_t *mod)
|
||||||
|
{
|
||||||
|
if (game_sel_list == NULL)
|
||||||
|
{
|
||||||
|
game_sel_list =
|
||||||
|
(mod_info_t **)malloc(sizeof(mod_info_t *) * (game_sel_count + 1));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
game_sel_list =
|
||||||
|
(mod_info_t **)realloc(game_sel_list,
|
||||||
|
sizeof(mod_info_t *) * (game_sel_count + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
game_sel_list[game_sel_count++] = mod;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT_PTR CALLBACK ChooseGameHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
switch (message)
|
||||||
|
{
|
||||||
|
case WM_INITDIALOG:
|
||||||
|
{
|
||||||
|
HWND lbox = GetDlgItem(hDlg, IDC_SELGAME_LIST);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < g_mod_count; i++)
|
||||||
|
{
|
||||||
|
LRESULT res = SendMessage(lbox,
|
||||||
|
LB_ADDSTRING,
|
||||||
|
0,
|
||||||
|
(LPARAM)g_mod_list[i].name);
|
||||||
|
|
||||||
|
if (res == LB_ERR || res == LB_ERRSPACE)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppendSelectableGame(&g_mod_list[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateWindow(lbox);
|
||||||
|
|
||||||
|
return (INT_PTR)TRUE;
|
||||||
|
}
|
||||||
|
case WM_COMMAND:
|
||||||
|
{
|
||||||
|
if (LOWORD(wParam) == ID_SELGAME_EXIT
|
||||||
|
|| LOWORD(wParam) == ID_CLOSE)
|
||||||
|
{
|
||||||
|
return AskToExit(hDlg);
|
||||||
|
}
|
||||||
|
else if (LOWORD(wParam) == ID_SELGAME_BACK)
|
||||||
|
{
|
||||||
|
EndDialog(hDlg, (INT_PTR)DisplayChooseMethod);
|
||||||
|
return (INT_PTR)TRUE;
|
||||||
|
}
|
||||||
|
else if (LOWORD(wParam) == IDC_SELGAME_LIST)
|
||||||
|
{
|
||||||
|
if (HIWORD(wParam) == LBN_SELCHANGE)
|
||||||
|
{
|
||||||
|
HWND lbox = (HWND)lParam;
|
||||||
|
LRESULT cursel = SendMessage(lbox, LB_GETCURSEL, 0, 0);
|
||||||
|
|
||||||
|
selected_game_index = -1;
|
||||||
|
|
||||||
|
if (cursel == LB_ERR)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cursel >= (LRESULT)g_mod_count)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
selected_game_index = (int)cursel;
|
||||||
|
|
||||||
|
HWND button = GetDlgItem(hDlg, ID_SELGAME_NEXT);
|
||||||
|
EnableWindow(button, TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (LOWORD(wParam) == ID_SELGAME_NEXT)
|
||||||
|
{
|
||||||
|
if (selected_game_index == -1)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_LocalCopier.SetOutputPath(game_sel_list[selected_game_index]->mod_path);
|
||||||
|
SetInstallMethod(&g_LocalCopier);
|
||||||
|
|
||||||
|
EndDialog(hDlg, (INT_PTR)DisplayPerformInstall);
|
||||||
|
|
||||||
|
return (INT_PTR)TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WM_DESTROY:
|
||||||
|
{
|
||||||
|
ReleaseGamesList();
|
||||||
|
free(game_sel_list);
|
||||||
|
game_sel_list = NULL;
|
||||||
|
game_sel_count = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (INT_PTR)FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *DisplaySelectGame(HWND hWnd)
|
||||||
|
{
|
||||||
|
INT_PTR val;
|
||||||
|
|
||||||
|
if ((val = DialogBox(
|
||||||
|
g_hInstance,
|
||||||
|
MAKEINTRESOURCE(IDD_SELECT_GAME),
|
||||||
|
hWnd,
|
||||||
|
ChooseGameHandler)) == -1)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (void *)val;
|
||||||
|
}
|
||||||
|
|
8
tools/installer/SelectGame.h
Normal file
8
tools/installer/SelectGame.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#ifndef _INCLUDE_INSTALLER_SELECT_GAME_H_
|
||||||
|
#define _INCLUDE_INSTALLER_SELECT_GAME_H_
|
||||||
|
|
||||||
|
#include "InstallerMain.h"
|
||||||
|
|
||||||
|
void *DisplaySelectGame(HWND hWnd);
|
||||||
|
|
||||||
|
#endif //_INCLUDE_INSTALLER_SELECT_GAME_H_
|
48
tools/installer/Welcome.cpp
Normal file
48
tools/installer/Welcome.cpp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#include "InstallerMain.h"
|
||||||
|
#include "Welcome.h"
|
||||||
|
#include "ChooseMethod.h"
|
||||||
|
|
||||||
|
INT_PTR CALLBACK WelcomeHandler(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
switch (message)
|
||||||
|
{
|
||||||
|
case WM_INITDIALOG:
|
||||||
|
{
|
||||||
|
return (INT_PTR)TRUE;
|
||||||
|
}
|
||||||
|
case WM_COMMAND:
|
||||||
|
{
|
||||||
|
if (LOWORD(wParam) == ID_WELCOME_EXIT
|
||||||
|
|| LOWORD(wParam) == ID_CLOSE)
|
||||||
|
{
|
||||||
|
EndDialog(hDlg, NULL);
|
||||||
|
return (INT_PTR)TRUE;
|
||||||
|
}
|
||||||
|
else if (LOWORD(wParam) == ID_WELCOME_NEXT)
|
||||||
|
{
|
||||||
|
EndDialog(hDlg, (INT_PTR)DisplayChooseMethod);
|
||||||
|
return (INT_PTR)TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (INT_PTR)FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *DisplayWelcome(HWND hWnd)
|
||||||
|
{
|
||||||
|
INT_PTR val;
|
||||||
|
|
||||||
|
if ((val = DialogBox(
|
||||||
|
g_hInstance,
|
||||||
|
MAKEINTRESOURCE(IDD_WELCOME),
|
||||||
|
hWnd,
|
||||||
|
WelcomeHandler)) == -1)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (void *)val;
|
||||||
|
}
|
||||||
|
|
6
tools/installer/Welcome.h
Normal file
6
tools/installer/Welcome.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef _INCLUDE_INSTALLER_WELCOME_H_
|
||||||
|
#define _INCLUDE_INSTALLER_WELCOME_H_
|
||||||
|
|
||||||
|
void *DisplayWelcome(HWND hWnd);
|
||||||
|
|
||||||
|
#endif //_INCLUDE_INSTALLER_WELCOME_H_
|
BIN
tools/installer/installer.ico
Normal file
BIN
tools/installer/installer.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
208
tools/installer/installer.rc
Normal file
208
tools/installer/installer.rc
Normal file
@ -0,0 +1,208 @@
|
|||||||
|
// Microsoft Visual C++ generated resource script.
|
||||||
|
//
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
#define APSTUDIO_READONLY_SYMBOLS
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 2 resource.
|
||||||
|
//
|
||||||
|
#define APSTUDIO_HIDDEN_SYMBOLS
|
||||||
|
#include "windows.h"
|
||||||
|
#undef APSTUDIO_HIDDEN_SYMBOLS
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#undef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// English (U.S.) resources
|
||||||
|
|
||||||
|
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||||
|
#ifdef _WIN32
|
||||||
|
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||||
|
#pragma code_page(1252)
|
||||||
|
#endif //_WIN32
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Icon
|
||||||
|
//
|
||||||
|
|
||||||
|
// Icon with lowest ID value placed first to ensure application icon
|
||||||
|
// remains consistent on all systems.
|
||||||
|
IDI_INSTALLER ICON "installer.ico"
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Menu
|
||||||
|
//
|
||||||
|
|
||||||
|
IDC_INSTALLER MENU
|
||||||
|
BEGIN
|
||||||
|
POPUP "&File"
|
||||||
|
BEGIN
|
||||||
|
MENUITEM "E&xit", IDM_EXIT
|
||||||
|
END
|
||||||
|
POPUP "&Help"
|
||||||
|
BEGIN
|
||||||
|
MENUITEM "&About ...", IDM_ABOUT
|
||||||
|
END
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Accelerator
|
||||||
|
//
|
||||||
|
|
||||||
|
IDC_INSTALLER ACCELERATORS
|
||||||
|
BEGIN
|
||||||
|
"?", IDM_ABOUT, ASCII, ALT
|
||||||
|
"/", IDM_ABOUT, ASCII, ALT
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Dialog
|
||||||
|
//
|
||||||
|
|
||||||
|
IDD_WELCOME DIALOGEX 0, 0, 230, 66
|
||||||
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
|
CAPTION "SourceMod Installer"
|
||||||
|
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||||
|
BEGIN
|
||||||
|
DEFPUSHBUTTON "&Next",ID_WELCOME_NEXT,177,50,50,14
|
||||||
|
GROUPBOX "",IDC_WELCOME_PANEL,2,3,225,44
|
||||||
|
LTEXT "Welcome to the SourceMod Installer. This tool can be used to install SourcecMod to a local server/game installation, or upload SourceMod to a server via FTP.",IDC_WELCOME_TEXT,9,11,209,24
|
||||||
|
DEFPUSHBUTTON "E&xit",ID_WELCOME_EXIT,2,50,50,14
|
||||||
|
END
|
||||||
|
|
||||||
|
IDD_CHOOSE_METHOD DIALOGEX 0, 0, 244, 130
|
||||||
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
|
CAPTION "SourceMod Installer"
|
||||||
|
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||||
|
BEGIN
|
||||||
|
PUSHBUTTON "&Next",ID_METHOD_NEXT,191,113,50,14,WS_DISABLED
|
||||||
|
PUSHBUTTON "E&xit",ID_METHOD_EXIT,2,113,50,14
|
||||||
|
GROUPBOX "",IDC_METHOD_PANEL,2,3,239,108
|
||||||
|
DEFPUSHBUTTON "&Back",ID_METHOD_BACK,136,113,50,14
|
||||||
|
GROUPBOX "",IDC_METHOD_PANEL,17,30,154,69
|
||||||
|
LTEXT "Please select an installation method:",IDC_METHOD_TEXT,9,15,122,12
|
||||||
|
CONTROL "Steam Dedicated Server",IDC_METHOD_DED_SERVER,"Button",BS_AUTORADIOBUTTON,21,35,98,15
|
||||||
|
CONTROL "Steam Listen Server",IDC_METHOD_LISTEN_SERVER,"Button",BS_AUTORADIOBUTTON,21,46,93,16
|
||||||
|
CONTROL "Standalone Server",IDC_METHOD_ALONE_SERVER,"Button",BS_AUTORADIOBUTTON,21,58,93,16
|
||||||
|
CONTROL "Select Destination Folder",IDC_METHOD_CUSTOM_FOLDER,
|
||||||
|
"Button",BS_AUTORADIOBUTTON,21,70,95,16
|
||||||
|
CONTROL "Upload via FTP",IDC_METHOD_UPLOAD_FTP,"Button",BS_AUTORADIOBUTTON,21,82,94,16
|
||||||
|
END
|
||||||
|
|
||||||
|
IDD_SELECT_GAME DIALOGEX 0, 0, 244, 130
|
||||||
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
|
CAPTION "SourceMod Installer"
|
||||||
|
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||||
|
BEGIN
|
||||||
|
PUSHBUTTON "&Next",ID_SELGAME_NEXT,191,113,50,14,WS_DISABLED
|
||||||
|
PUSHBUTTON "E&xit",ID_SELGAME_EXIT,2,113,50,14
|
||||||
|
GROUPBOX "",IDC_SELGAME_PANEL,2,3,239,108
|
||||||
|
DEFPUSHBUTTON "&Back",ID_SELGAME_BACK,136,113,50,14
|
||||||
|
LTEXT "Please select a game:",IDC_SELGAME_TEXT,9,15,122,12
|
||||||
|
LISTBOX IDC_SELGAME_LIST,17,30,177,69,LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
|
||||||
|
END
|
||||||
|
|
||||||
|
IDD_PERFORM_INSTALL DIALOGEX 0, 0, 244, 130
|
||||||
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
|
CAPTION "SourceMod Installer"
|
||||||
|
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||||
|
BEGIN
|
||||||
|
PUSHBUTTON "&Cancel",ID_INSTALL_CANCEL,2,113,50,14
|
||||||
|
GROUPBOX "",IDC_INSTALL_PANEL,2,3,239,108
|
||||||
|
LTEXT "Please wait while SourceMod is installed...",IDC_INSTALL_TEXT,9,15,122,12
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// TEXTINCLUDE
|
||||||
|
//
|
||||||
|
|
||||||
|
1 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"resource.h\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
2 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
|
||||||
|
"#include ""windows.h""\r\n"
|
||||||
|
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
3 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// DESIGNINFO
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
GUIDELINES DESIGNINFO
|
||||||
|
BEGIN
|
||||||
|
IDD_WELCOME, DIALOG
|
||||||
|
BEGIN
|
||||||
|
LEFTMARGIN, 2
|
||||||
|
RIGHTMARGIN, 227
|
||||||
|
TOPMARGIN, 3
|
||||||
|
BOTTOMMARGIN, 64
|
||||||
|
END
|
||||||
|
|
||||||
|
IDD_CHOOSE_METHOD, DIALOG
|
||||||
|
BEGIN
|
||||||
|
LEFTMARGIN, 2
|
||||||
|
RIGHTMARGIN, 241
|
||||||
|
TOPMARGIN, 3
|
||||||
|
BOTTOMMARGIN, 127
|
||||||
|
END
|
||||||
|
END
|
||||||
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// String Table
|
||||||
|
//
|
||||||
|
|
||||||
|
STRINGTABLE
|
||||||
|
BEGIN
|
||||||
|
IDS_NO_GAMEINFO "The folder you selected does not appear to be a valid Half-Life 2 game/mod folder."
|
||||||
|
IDS_READONLY_GAMEINFO "The folder you selected may contain a valid Half-Life 2 game/mod, but its gameinfo.txt is read-only. You must make it writable to continue."
|
||||||
|
IDS_GAME_FAIL_HL1 "A Source dedicated server installation could not be found. This may occur if you used the standalone server to install HLDS. Try navigating to the folder manually."
|
||||||
|
IDS_GAME_FAIL_READ "Could not locate a valid Source installation. Please make sure Steam is installed and its games have been run at least once."
|
||||||
|
IDS_GAME_FAIL_NONE "No Source games or mods were found. Please make sure that Steam is installed and its games have been run at least once."
|
||||||
|
IDS_VERIFY_EXIT "Are you sure you want to exit?"
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // English (U.S.) resources
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 3 resource.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#endif // not APSTUDIO_INVOKED
|
||||||
|
|
20
tools/installer/installer.sln
Normal file
20
tools/installer/installer.sln
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||||
|
# Visual Studio 2005
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "installer", "installer.vcproj", "{B2479B33-A265-423B-A996-F994546644F9}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Win32 = Debug|Win32
|
||||||
|
Release|Win32 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{B2479B33-A265-423B-A996-F994546644F9}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{B2479B33-A265-423B-A996-F994546644F9}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{B2479B33-A265-423B-A996-F994546644F9}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{B2479B33-A265-423B-A996-F994546644F9}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
286
tools/installer/installer.vcproj
Normal file
286
tools/installer/installer.vcproj
Normal file
@ -0,0 +1,286 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="8.00"
|
||||||
|
Name="installer"
|
||||||
|
ProjectGUID="{B2479B33-A265-423B-A996-F994546644F9}"
|
||||||
|
RootNamespace="installer"
|
||||||
|
Keyword="Win32Proj"
|
||||||
|
>
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"
|
||||||
|
/>
|
||||||
|
</Platforms>
|
||||||
|
<ToolFiles>
|
||||||
|
</ToolFiles>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="1"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE"
|
||||||
|
MinimalRebuild="true"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="1"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="true"
|
||||||
|
DebugInformationFormat="4"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="comctl32.lib"
|
||||||
|
LinkIncremental="2"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
SubSystem="2"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="1"
|
||||||
|
WholeProgramOptimization="1"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
|
||||||
|
RuntimeLibrary="2"
|
||||||
|
UsePrecompiledHeader="2"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="true"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
LinkIncremental="1"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
SubSystem="2"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\GamesList.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\InstallerUtil.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\LocalCopyMethod.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||||
|
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\GamesList.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\ICopyMethod.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\InstallerUtil.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\LocalCopyMethod.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\platform_headers.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Resource.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Resource Files"
|
||||||
|
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||||
|
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\installer.ico"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\installer.rc"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Window Headers"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\ChooseMethod.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\InstallerMain.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\PerformInstall.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\SelectGame.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Welcome.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Window Source"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\ChooseMethod.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\InstallerMain.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\PerformInstall.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\SelectGame.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Welcome.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
33
tools/installer/platform_headers.h
Normal file
33
tools/installer/platform_headers.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#ifndef _INCLUDE_INSTALLER_PLATFORM_HEADERS_H_
|
||||||
|
#define _INCLUDE_INSTALLER_PLATFORM_HEADERS_H_
|
||||||
|
|
||||||
|
// Refer to MSDN for the latest info on corresponding values for different platforms.
|
||||||
|
#ifndef WINVER // Allow use of features specific to Windows XP or later.
|
||||||
|
#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
|
||||||
|
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
|
||||||
|
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later.
|
||||||
|
#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
|
// Windows Header Files:
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
// C RunTime Header Files
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
#include <commctrl.h>
|
||||||
|
#include <shlobj.h>
|
||||||
|
|
||||||
|
#endif //_INCLUDE_INSTALLER_PLATFORM_HEADERS_H_
|
Loading…
Reference in New Issue
Block a user