Skip to content

Commit

Permalink
Use player's default browser; remove browser setting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Meridian59 committed Sep 7, 2018
1 parent bb84b94 commit 2e4b857
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 133 deletions.
20 changes: 6 additions & 14 deletions clientd3d/client.rc
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ BEGIN
PUSHBUTTON "Abbrechen",2,267,183,50,14
END

116 DIALOGEX 0, 0, 256, 271
116 DIALOGEX 0, 0, 256, 236
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Meridian 59 Voreinstellungen"
FONT 8, "MS Sans Serif", 0, 0, 0x0
Expand Down Expand Up @@ -371,12 +371,8 @@ BEGIN
CONTROL "�bertragungsrate anzeigen",147,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,88,168,77,9
CONTROL "Textfilter an/aus",1173,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,202,77,9
PUSHBUTTON "&Einstellungen",1164,101,200,142,12
GROUPBOX "Web Browser",IDC_STATIC,6,217,245,31,WS_GROUP
LTEXT "Programm:",IDC_STATIC,13,231,36,8
EDITTEXT 1155,51,228,141,12,ES_AUTOHSCROLL
PUSHBUTTON "&Durchsuchen",1162,195,228,51,12
DEFPUSHBUTTON "Best�tigen",1,145,254,50,12,WS_GROUP
PUSHBUTTON "Abbrechen",2,201,254,50,12,WS_GROUP
DEFPUSHBUTTON "Best�tigen",1,145,219,50,12,WS_GROUP
PUSHBUTTON "Abbrechen",2,201,219,50,12,WS_GROUP
CONTROL "Dynamische Karte",1198,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,88,179,79,10
CONTROL "Bunter Text",1199,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,172,168,72,10
END
Expand Down Expand Up @@ -893,7 +889,7 @@ BEGIN
LISTBOX IDC_QUANLIST,143,118,22,20,LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_WANTKEYBOARDINPUT | NOT WS_VISIBLE | WS_TABSTOP
END

IDD_SETTINGS DIALOGEX 0, 0, 257, 265
IDD_SETTINGS DIALOGEX 0, 0, 257, 230
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Meridian 59 Preferences"
FONT 8, "MS Sans Serif", 0, 0, 0x0
Expand Down Expand Up @@ -929,12 +925,8 @@ BEGIN
CONTROL "Show colored text",IDC_COLORCODES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,172,159,72,10
CONTROL "Map annotations",IDC_MAP_ANNOTATIONS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,172,170,72,10
PUSHBUTTON "&Profanity Options and Policy...",IDC_PROFANESETTINGS,101,191,142,12
GROUPBOX "Web Browser",IDC_STATIC,6,208,245,31,WS_GROUP
LTEXT "Application:",IDC_STATIC,13,221,45,8
EDITTEXT IDC_BROWSER,59,219,136,12,ES_AUTOHSCROLL
PUSHBUTTON "&Search...",IDC_FIND,197,219,49,12
DEFPUSHBUTTON "OK",IDOK,145,247,50,12,WS_GROUP
PUSHBUTTON "Cancel",IDCANCEL,201,247,50,12,WS_GROUP
DEFPUSHBUTTON "OK",IDOK,145,212,50,12,WS_GROUP
PUSHBUTTON "Cancel",IDCANCEL,201,212,50,12,WS_GROUP
END

IDD_COLOR DIALOG 0, 0, 201, 92
Expand Down
49 changes: 0 additions & 49 deletions clientd3d/maindlg.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,8 @@ void AbortPreferencesDialog(void)
/*****************************************************************************/
BOOL CALLBACK PreferencesDialogProc(HWND hDlg, UINT message, UINT wParam, LONG lParam)
{
static HWND hBrowser;
static Bool browser_changed;
Bool toolbar_changed, lagbox_changed, temp;
CommSettings *comm = &config.comm;
OPENFILENAME ofn;
static char *dir; // Working directory before dialog (OpenFile may change it)
int new_val;

switch (message)
Expand All @@ -165,14 +161,6 @@ BOOL CALLBACK PreferencesDialogProc(HWND hDlg, UINT message, UINT wParam, LONG l
}
hPreferencesDialog = hDlg;

hBrowser = GetDlgItem(hDlg, IDC_BROWSER);

Edit_LimitText(hBrowser, MAX_PATH);

SetWindowFont(hBrowser, GetFont(FONT_INPUT), FALSE);

SetWindowText(hBrowser, config.browser);

CheckDlgButton(hDlg, IDC_SCROLLLOCK, config.scroll_lock);
CheckDlgButton(hDlg, IDC_DRAWNAMES, config.draw_names);
CheckDlgButton(hDlg, IDC_TOOLTIPS, config.tooltips);
Expand Down Expand Up @@ -203,38 +191,11 @@ BOOL CALLBACK PreferencesDialogProc(HWND hDlg, UINT message, UINT wParam, LONG l
Trackbar_SetPos(GetDlgItem(hDlg, IDC_SOUND_VOLUME), config.sound_volume);
Trackbar_SetPos(GetDlgItem(hDlg, IDC_MUSIC_VOLUME), config.music_volume);

dir = (char *) SafeMalloc(MAX_PATH + 1);
GetWorkingDirectory(dir, MAX_PATH);

browser_changed = False;
return TRUE;

case WM_COMMAND:
switch(GET_WM_COMMAND_ID(wParam, lParam))
{
case IDC_BROWSER:
if (GET_WM_COMMAND_CMD(wParam, lParam) != EN_CHANGE)
break;

browser_changed = True;
return TRUE;

case IDC_FIND:
memset(&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hDlg;
ofn.lpstrFilter = EXE_filter;
ofn.lpstrFile = config.browser;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
if (GetOpenFileName(&ofn))
{
SetWindowText(hBrowser, config.browser);
browser_changed = True;
}
else debug(("GetOpenFileName failed, error = %d\n", CommDlgExtendedError()));
return TRUE;

case IDCANCEL:
EndDialog(hDlg, IDCANCEL);
return TRUE;
Expand All @@ -250,11 +211,6 @@ BOOL CALLBACK PreferencesDialogProc(HWND hDlg, UINT message, UINT wParam, LONG l
return TRUE;

case IDOK:
Edit_GetText(hBrowser, config.browser, MAX_PATH);

if (browser_changed)
config.default_browser = False;

config.scroll_lock = IsDlgButtonChecked(hDlg, IDC_SCROLLLOCK);
config.draw_names = IsDlgButtonChecked(hDlg, IDC_DRAWNAMES);
config.tooltips = IsDlgButtonChecked(hDlg, IDC_TOOLTIPS);
Expand Down Expand Up @@ -321,11 +277,6 @@ BOOL CALLBACK PreferencesDialogProc(HWND hDlg, UINT message, UINT wParam, LONG l
break;

case WM_DESTROY:
// Restore working drive and directory
if (chdir(dir) != 0)
debug(("chdir failed to %s\n", dir));
SafeFree(dir);

hPreferencesDialog = NULL;
return TRUE;
}
Expand Down
66 changes: 1 addition & 65 deletions clientd3d/web.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,79 +8,15 @@
/*
* web.c: Handle interface to Web browser.
*
* We store the location of the Web browser in the "config" variable. This location is
* updated each time the client is run by finding the default browser in the registry.
*/

#include "client.h"

/************************************************************************/
/*
* WebFindDefaultBrowser: Look up the default browser in the registry, and
* save it in "config" if it's found.
* Return True on success, False otherwise.
*/
Bool WebFindDefaultBrowser(void)
{
char *key_name;
DWORD size = MAX_PATH;
int retval;
HKEY hKey;
char *ptr1, *ptr2;

key_name = GetString(hInst, IDS_HTTPKEY);

retval = RegOpenKeyEx(HKEY_LOCAL_MACHINE, key_name, 0, KEY_READ, &hKey);
if (retval != ERROR_SUCCESS)
{
debug(("error opening registry key for default browser\n"));
return False;
}

retval = RegQueryValueEx(hKey, NULL, NULL, NULL, (LPBYTE) config.browser, &size);
if (retval != ERROR_SUCCESS)
{
debug(("Default Web browser key lookup failed\n"));
RegCloseKey(hKey);
return False;
}

// Remove junky command line arguments from command line; look for \ after - (- in pathname)
ptr1 = strrchr(config.browser, '-');
if (ptr1 != NULL)
{
ptr2 = strchr(ptr1, '\\');

if (ptr2 == NULL)
*ptr1 = 0;
}

debug(("Found browser %s\n", config.browser));
RegCloseKey(hKey);
return True;
}

/************************************************************************/
/*
* WebLaunchBrowser: Attempt to run browser on given URL.
*/
void WebLaunchBrowser(char *url)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
char command_line[MAX_CMDLINE];

sprintf(command_line, "%s %s", config.browser, url);

memset(&si, sizeof(si), 0);
si.cb = sizeof(si);
GetStartupInfo(&si); /* shouldn't need to do this. very weird */

if (!CreateProcess(NULL, command_line,
NULL,NULL,FALSE,0,NULL,NULL,&si,&pi))
{
debug(("Failed running browser, command line = %s\n", command_line));

ClientError(hInst, hMain, IDS_NOBROWSER, config.browser);
}
ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL);
}
1 change: 0 additions & 1 deletion clientd3d/web.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#ifndef _WEB_H
#define _WEB_H

Bool WebFindDefaultBrowser(void);
void WebLaunchBrowser(char *url);

#endif /* #ifndef _WEB_H */
4 changes: 0 additions & 4 deletions clientd3d/winmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,6 @@ BOOL MainInit(HWND hwnd, LPCREATESTRUCT lpCreateStruct)

SetMainCursor(LoadCursor(NULL, IDC_ARROW));

// Find default Web browser, if not set manually
if (config.default_browser)
WebFindDefaultBrowser();

return TRUE;
}
/****************************************************************************/
Expand Down

0 comments on commit 2e4b857

Please sign in to comment.