2006-07-01 01:40:18 +00:00
|
|
|
#ifndef RENDERTYPEWIN
|
|
|
|
#error Only for Windows
|
|
|
|
#endif
|
|
|
|
|
2006-12-21 12:53:11 +00:00
|
|
|
#include "compat.h"
|
2006-07-01 01:40:18 +00:00
|
|
|
#include "build.h"
|
|
|
|
#include "editor.h"
|
|
|
|
#include "winlayer.h"
|
|
|
|
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#include <windows.h>
|
|
|
|
#include <windowsx.h>
|
|
|
|
#define _WIN32_IE 0x0300
|
|
|
|
#include <commctrl.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "startwin.editor.h"
|
|
|
|
|
|
|
|
#define TAB_CONFIG 0
|
|
|
|
#define TAB_MESSAGES 1
|
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
static struct
|
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
int fullscreen;
|
|
|
|
int xdim2d, ydim2d;
|
|
|
|
int xdim3d, ydim3d, bpp3d;
|
|
|
|
int forcesetup;
|
|
|
|
} settings;
|
|
|
|
|
|
|
|
static HWND startupdlg = NULL;
|
|
|
|
static HWND pages[2] = { NULL, NULL};
|
2006-07-01 12:00:26 +00:00
|
|
|
static int done = -1, mode = TAB_CONFIG;
|
2006-07-01 01:40:18 +00:00
|
|
|
|
|
|
|
static void PopulateForm(void)
|
|
|
|
{
|
|
|
|
int i,j;
|
|
|
|
char buf[64];
|
|
|
|
int mode2d, mode3d;
|
|
|
|
HWND hwnd2d, hwnd3d;
|
|
|
|
|
|
|
|
hwnd2d = GetDlgItem(pages[TAB_CONFIG], IDC2DVMODE);
|
|
|
|
hwnd3d = GetDlgItem(pages[TAB_CONFIG], IDC3DVMODE);
|
|
|
|
|
|
|
|
mode2d = checkvideomode(&settings.xdim2d, &settings.ydim2d, 8, settings.fullscreen, 1);
|
|
|
|
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1);
|
|
|
|
if (mode2d < 0) mode2d = 0;
|
2007-12-12 17:42:14 +00:00
|
|
|
if (mode3d < 0)
|
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
int cd[] = { 32, 24, 16, 15, 8, 0 };
|
2007-12-12 17:42:14 +00:00
|
|
|
for (i=0; cd[i];) { if (cd[i] >= settings.bpp3d) i++; else break; }
|
|
|
|
for (; cd[i]; i++)
|
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1);
|
|
|
|
if (mode3d < 0) continue;
|
|
|
|
settings.bpp3d = cd[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), (settings.fullscreen ? BST_CHECKED : BST_UNCHECKED));
|
|
|
|
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.forcesetup ? BST_CHECKED : BST_UNCHECKED));
|
|
|
|
|
2008-03-23 00:14:22 +00:00
|
|
|
(void)ComboBox_ResetContent(hwnd2d);
|
|
|
|
(void)ComboBox_ResetContent(hwnd3d);
|
2007-12-12 17:42:14 +00:00
|
|
|
for (i=0; i<validmodecnt; i++)
|
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
if (validmode[i].fs != settings.fullscreen) continue;
|
|
|
|
|
|
|
|
// all modes get added to the 3D mode list
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(buf, "%d x %d %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp);
|
2006-07-01 01:40:18 +00:00
|
|
|
j = ComboBox_AddString(hwnd3d, buf);
|
2008-03-23 00:14:22 +00:00
|
|
|
(void)ComboBox_SetItemData(hwnd3d, j, i);
|
|
|
|
if (i == mode3d) (void)ComboBox_SetCurSel(hwnd3d, j);
|
2006-07-01 01:40:18 +00:00
|
|
|
|
|
|
|
// only 8-bit modes get used for 2D
|
2008-01-28 01:13:10 +00:00
|
|
|
if (validmode[i].bpp != 8 || validmode[i].xdim < 640 || validmode[i].ydim < 480) continue;
|
2007-12-12 17:42:14 +00:00
|
|
|
Bsprintf(buf, "%d x %d", validmode[i].xdim, validmode[i].ydim);
|
2006-07-01 01:40:18 +00:00
|
|
|
j = ComboBox_AddString(hwnd2d, buf);
|
2008-03-23 00:14:22 +00:00
|
|
|
(void)ComboBox_SetItemData(hwnd2d, j, i);
|
|
|
|
if (i == mode2d) (void)ComboBox_SetCurSel(hwnd2d, j);
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2007-12-12 17:42:14 +00:00
|
|
|
switch (uMsg)
|
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
case WM_COMMAND:
|
2007-12-12 17:42:14 +00:00
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
case IDCFULLSCREEN:
|
|
|
|
settings.fullscreen = !settings.fullscreen;
|
|
|
|
PopulateForm();
|
|
|
|
return TRUE;
|
|
|
|
case IDC2DVMODE:
|
2007-12-12 17:42:14 +00:00
|
|
|
if (HIWORD(wParam) == CBN_SELCHANGE)
|
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
int i;
|
|
|
|
i = ComboBox_GetCurSel((HWND)lParam);
|
|
|
|
if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
|
2007-12-12 17:42:14 +00:00
|
|
|
if (i != CB_ERR)
|
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
settings.xdim2d = validmode[i].xdim;
|
|
|
|
settings.ydim2d = validmode[i].ydim;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
case IDC3DVMODE:
|
2007-12-12 17:42:14 +00:00
|
|
|
if (HIWORD(wParam) == CBN_SELCHANGE)
|
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
int i;
|
|
|
|
i = ComboBox_GetCurSel((HWND)lParam);
|
|
|
|
if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
|
2007-12-12 17:42:14 +00:00
|
|
|
if (i != CB_ERR)
|
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
settings.xdim3d = validmode[i].xdim;
|
|
|
|
settings.ydim3d = validmode[i].ydim;
|
|
|
|
settings.bpp3d = validmode[i].bpp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
case IDCALWAYSSHOW:
|
|
|
|
settings.forcesetup = IsDlgButtonChecked(hwndDlg, IDCALWAYSSHOW) == BST_CHECKED;
|
|
|
|
return TRUE;
|
2006-11-13 23:12:47 +00:00
|
|
|
default:
|
|
|
|
break;
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-11-13 23:12:47 +00:00
|
|
|
default:
|
|
|
|
break;
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void SetPage(int n)
|
|
|
|
{
|
|
|
|
HWND tab;
|
|
|
|
int cur;
|
|
|
|
tab = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL);
|
|
|
|
cur = (int)SendMessage(tab, TCM_GETCURSEL,0,0);
|
|
|
|
ShowWindow(pages[cur],SW_HIDE);
|
|
|
|
SendMessage(tab, TCM_SETCURSEL, n, 0);
|
|
|
|
ShowWindow(pages[n],SW_SHOW);
|
2006-11-13 23:12:47 +00:00
|
|
|
mode = n;
|
2006-07-01 07:14:56 +00:00
|
|
|
|
|
|
|
SetFocus(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL));
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void EnableConfig(int n)
|
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
//EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_CANCEL), n);
|
2006-07-01 01:40:18 +00:00
|
|
|
EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_START), n);
|
|
|
|
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), n);
|
|
|
|
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDC2DVMODE), n);
|
|
|
|
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDC3DVMODE), n);
|
|
|
|
}
|
|
|
|
|
|
|
|
static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
static HBITMAP hbmp = NULL;
|
|
|
|
HDC hdc;
|
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
HWND hwnd;
|
|
|
|
RECT r, rdlg, chrome, rtab, rcancel, rstart;
|
|
|
|
int xoffset = 0, yoffset = 0;
|
|
|
|
|
|
|
|
// Fetch the positions (in screen coordinates) of all the windows we need to tweak
|
|
|
|
ZeroMemory(&chrome, sizeof(chrome));
|
|
|
|
AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE);
|
|
|
|
GetWindowRect(hwndDlg, &rdlg);
|
|
|
|
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), &rtab);
|
|
|
|
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), &rcancel);
|
|
|
|
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart);
|
|
|
|
|
|
|
|
// Knock off the non-client area of the main dialogue to give just the client area
|
|
|
|
rdlg.left -= chrome.left; rdlg.top -= chrome.top;
|
|
|
|
rdlg.right -= chrome.right; rdlg.bottom -= chrome.bottom;
|
|
|
|
|
|
|
|
// Translate them to client-relative coordinates wrt the main dialogue window
|
|
|
|
rtab.right -= rtab.left - 1; rtab.bottom -= rtab.top - 1;
|
|
|
|
rtab.left -= rdlg.left; rtab.top -= rdlg.top;
|
|
|
|
|
|
|
|
rcancel.right -= rcancel.left - 1; rcancel.bottom -= rcancel.top - 1;
|
|
|
|
rcancel.left -= rdlg.left; rcancel.top -= rdlg.top;
|
|
|
|
|
|
|
|
rstart.right -= rstart.left - 1; rstart.bottom -= rstart.top - 1;
|
|
|
|
rstart.left -= rdlg.left; rstart.top -= rdlg.top;
|
|
|
|
|
|
|
|
// And then convert the main dialogue coordinates to just width/length
|
|
|
|
rdlg.right -= rdlg.left - 1; rdlg.bottom -= rdlg.top - 1;
|
|
|
|
rdlg.left = 0; rdlg.top = 0;
|
|
|
|
|
|
|
|
// Load the bitmap into the bitmap control and fetch its dimensions
|
|
|
|
hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP));
|
|
|
|
hwnd = GetDlgItem(hwndDlg,WIN_STARTWIN_BITMAP);
|
|
|
|
SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp);
|
|
|
|
GetClientRect(hwnd, &r);
|
|
|
|
xoffset = r.right;
|
|
|
|
yoffset = r.bottom - rdlg.bottom;
|
|
|
|
|
|
|
|
// Shift and resize the controls that require it
|
|
|
|
rtab.left += xoffset; rtab.bottom += yoffset;
|
|
|
|
rcancel.left += xoffset; rcancel.top += yoffset;
|
|
|
|
rstart.left += xoffset; rstart.top += yoffset;
|
|
|
|
rdlg.right += xoffset;
|
|
|
|
rdlg.bottom += yoffset;
|
|
|
|
|
|
|
|
// Move the controls to their new positions
|
|
|
|
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), rtab.left, rtab.top, rtab.right, rtab.bottom, FALSE);
|
|
|
|
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), rcancel.left, rcancel.top, rcancel.right, rcancel.bottom, FALSE);
|
|
|
|
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_START), rstart.left, rstart.top, rstart.right, rstart.bottom, FALSE);
|
|
|
|
|
|
|
|
// Move the main dialogue to the centre of the screen
|
|
|
|
hdc = GetDC(NULL);
|
|
|
|
rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2;
|
|
|
|
rdlg.top = (GetDeviceCaps(hdc, VERTRES) - rdlg.bottom) / 2;
|
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
MoveWindow(hwndDlg, rdlg.left + chrome.left, rdlg.top + chrome.left,
|
|
|
|
rdlg.right + (-chrome.left+chrome.right), rdlg.bottom + (-chrome.top+chrome.bottom), TRUE);
|
|
|
|
|
|
|
|
// Add tabs to the tab control
|
|
|
|
{
|
|
|
|
TCITEM tab;
|
|
|
|
|
|
|
|
hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL);
|
|
|
|
|
|
|
|
ZeroMemory(&tab, sizeof(tab));
|
|
|
|
tab.mask = TCIF_TEXT;
|
|
|
|
tab.pszText = TEXT("Configuration");
|
|
|
|
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)0, (LPARAM)&tab);
|
|
|
|
tab.mask = TCIF_TEXT;
|
|
|
|
tab.pszText = TEXT("Messages");
|
|
|
|
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)1, (LPARAM)&tab);
|
|
|
|
|
|
|
|
// Work out the position and size of the area inside the tab control for the pages
|
|
|
|
ZeroMemory(&r, sizeof(r));
|
2006-07-01 01:40:18 +00:00
|
|
|
GetClientRect(hwnd, &r);
|
2006-11-13 23:12:47 +00:00
|
|
|
SendMessage(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM)&r);
|
|
|
|
r.right -= r.left-1;
|
|
|
|
r.bottom -= r.top-1;
|
|
|
|
r.top += rtab.top;
|
|
|
|
r.left += rtab.left;
|
|
|
|
|
|
|
|
// Create the pages and position them in the tab control, but hide them
|
|
|
|
pages[TAB_CONFIG] = CreateDialog((HINSTANCE)win_gethinstance(),
|
|
|
|
MAKEINTRESOURCE(WIN_STARTWINPAGE_CONFIG), hwndDlg, ConfigPageProc);
|
|
|
|
pages[TAB_MESSAGES] = GetDlgItem(hwndDlg, WIN_STARTWIN_MESSAGES);
|
|
|
|
SetWindowPos(pages[TAB_CONFIG], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
|
|
|
|
SetWindowPos(pages[TAB_MESSAGES], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
|
|
|
|
|
|
|
|
// Tell the editfield acting as the console to exclude the width of the scrollbar
|
|
|
|
GetClientRect(pages[TAB_MESSAGES],&r);
|
|
|
|
r.right -= GetSystemMetrics(SM_CXVSCROLL)+4;
|
|
|
|
r.left = r.top = 0;
|
|
|
|
SendMessage(pages[TAB_MESSAGES], EM_SETRECTNP,0,(LPARAM)&r);
|
|
|
|
|
|
|
|
SetFocus(GetDlgItem(hwndDlg, WIN_STARTWIN_START));
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
2006-11-13 23:12:47 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2006-07-01 01:40:18 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
case WM_NOTIFY:
|
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
LPNMHDR nmhdr = (LPNMHDR)lParam;
|
|
|
|
int cur;
|
|
|
|
if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break;
|
|
|
|
cur = (int)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0);
|
2007-12-12 17:42:14 +00:00
|
|
|
switch (nmhdr->code)
|
|
|
|
{
|
|
|
|
case TCN_SELCHANGING:
|
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
if (cur < 0 || !pages[cur]) break;
|
|
|
|
ShowWindow(pages[cur],SW_HIDE);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2007-12-12 17:42:14 +00:00
|
|
|
case TCN_SELCHANGE:
|
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
if (cur < 0 || !pages[cur]) break;
|
|
|
|
ShowWindow(pages[cur],SW_SHOW);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
2006-11-13 23:12:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-07-01 01:40:18 +00:00
|
|
|
|
|
|
|
case WM_CLOSE:
|
2006-11-13 23:12:47 +00:00
|
|
|
if (mode == TAB_CONFIG) done = 0;
|
|
|
|
else quitevent++;
|
2006-07-01 01:40:18 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case WM_DESTROY:
|
2007-12-12 17:42:14 +00:00
|
|
|
if (hbmp)
|
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
DeleteObject(hbmp);
|
|
|
|
hbmp = NULL;
|
|
|
|
}
|
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
if (pages[TAB_CONFIG])
|
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
DestroyWindow(pages[TAB_CONFIG]);
|
|
|
|
pages[TAB_CONFIG] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
startupdlg = NULL;
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
2007-12-12 17:42:14 +00:00
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
case WIN_STARTWIN_CANCEL:
|
|
|
|
if (mode == TAB_CONFIG) done = 0;
|
|
|
|
else quitevent++;
|
|
|
|
return TRUE;
|
|
|
|
case WIN_STARTWIN_START:
|
|
|
|
done = 1; return TRUE;
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
case WM_CTLCOLORSTATIC:
|
|
|
|
if ((HWND)lParam == pages[TAB_MESSAGES])
|
|
|
|
return (BOOL)GetSysColorBrush(COLOR_WINDOW);
|
|
|
|
break;
|
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
default:
|
|
|
|
break;
|
2006-07-01 01:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int startwin_open(void)
|
|
|
|
{
|
|
|
|
INITCOMMONCONTROLSEX icc;
|
|
|
|
if (startupdlg) return 1;
|
|
|
|
icc.dwSize = sizeof(icc);
|
|
|
|
icc.dwICC = ICC_TAB_CLASSES;
|
|
|
|
InitCommonControlsEx(&icc);
|
|
|
|
startupdlg = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc);
|
2007-12-12 17:42:14 +00:00
|
|
|
if (startupdlg)
|
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
SetPage(TAB_MESSAGES);
|
|
|
|
EnableConfig(0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int startwin_close(void)
|
|
|
|
{
|
|
|
|
if (!startupdlg) return 1;
|
|
|
|
DestroyWindow(startupdlg);
|
|
|
|
startupdlg = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int startwin_puts(const char *buf)
|
|
|
|
{
|
|
|
|
const char *p = NULL, *q = NULL;
|
|
|
|
char workbuf[1024];
|
|
|
|
static int newline = 0;
|
|
|
|
int curlen, linesbefore, linesafter;
|
|
|
|
HWND edctl;
|
|
|
|
int vis;
|
|
|
|
|
|
|
|
if (!startupdlg) return 1;
|
|
|
|
|
|
|
|
edctl = pages[TAB_MESSAGES];
|
|
|
|
if (!edctl) return -1;
|
|
|
|
|
|
|
|
vis = ((int)SendMessage(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL), TCM_GETCURSEL,0,0) == TAB_MESSAGES);
|
|
|
|
|
|
|
|
if (vis) SendMessage(edctl, WM_SETREDRAW, FALSE,0);
|
|
|
|
curlen = SendMessage(edctl, WM_GETTEXTLENGTH, 0,0);
|
|
|
|
SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen);
|
|
|
|
linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
|
|
|
|
p = buf;
|
2007-12-12 17:42:14 +00:00
|
|
|
while (*p)
|
|
|
|
{
|
|
|
|
if (newline)
|
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)"\r\n");
|
|
|
|
newline = 0;
|
|
|
|
}
|
|
|
|
q = p;
|
|
|
|
while (*q && *q != '\n') q++;
|
|
|
|
memcpy(workbuf, p, q-p);
|
2007-12-12 17:42:14 +00:00
|
|
|
if (*q == '\n')
|
|
|
|
{
|
|
|
|
if (!q[1])
|
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
newline = 1;
|
|
|
|
workbuf[q-p] = 0;
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
workbuf[q-p] = '\r';
|
|
|
|
workbuf[q-p+1] = '\n';
|
|
|
|
workbuf[q-p+2] = 0;
|
|
|
|
}
|
|
|
|
p = q+1;
|
2007-12-12 17:42:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
workbuf[q-p] = 0;
|
|
|
|
p = q;
|
|
|
|
}
|
|
|
|
SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)workbuf);
|
|
|
|
}
|
|
|
|
linesafter = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
|
|
|
|
SendMessage(edctl, EM_LINESCROLL, 0, linesafter-linesbefore);
|
|
|
|
if (vis) SendMessage(edctl, WM_SETREDRAW, TRUE,0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int startwin_settitle(const char *str)
|
|
|
|
{
|
|
|
|
if (!startupdlg) return 1;
|
|
|
|
SetWindowText(startupdlg, str);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int startwin_idle(void *v)
|
|
|
|
{
|
|
|
|
if (!startupdlg || !IsWindow(startupdlg)) return 0;
|
|
|
|
if (IsDialogMessage(startupdlg, (MSG*)v)) return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int startwin_run(void)
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
if (!startupdlg) return 1;
|
|
|
|
|
|
|
|
done = -1;
|
|
|
|
|
|
|
|
SetPage(TAB_CONFIG);
|
|
|
|
EnableConfig(1);
|
|
|
|
|
|
|
|
settings.fullscreen = fullscreen;
|
|
|
|
settings.xdim2d = xdim2d;
|
|
|
|
settings.ydim2d = ydim2d;
|
|
|
|
settings.xdim3d = xdimgame;
|
|
|
|
settings.ydim3d = ydimgame;
|
|
|
|
settings.bpp3d = bppgame;
|
|
|
|
settings.forcesetup = forcesetup;
|
|
|
|
PopulateForm();
|
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
while (done < 0)
|
|
|
|
{
|
|
|
|
switch (GetMessage(&msg, NULL, 0,0))
|
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
case 0:
|
|
|
|
done = 1; break;
|
|
|
|
case -1:
|
|
|
|
return -1;
|
2006-07-01 01:40:18 +00:00
|
|
|
default:
|
|
|
|
if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break;
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SetPage(TAB_MESSAGES);
|
|
|
|
EnableConfig(0);
|
2007-12-12 17:42:14 +00:00
|
|
|
if (done)
|
|
|
|
{
|
2006-07-01 01:40:18 +00:00
|
|
|
fullscreen = settings.fullscreen;
|
|
|
|
xdim2d = settings.xdim2d;
|
|
|
|
ydim2d = settings.ydim2d;
|
|
|
|
xdimgame = settings.xdim3d;
|
|
|
|
ydimgame = settings.ydim3d;
|
|
|
|
bppgame = settings.bpp3d;
|
|
|
|
forcesetup = settings.forcesetup;
|
|
|
|
}
|
|
|
|
|
|
|
|
return done;
|
|
|
|
}
|
|
|
|
|