(from Yitzhak) part2

part 2 touches only port files

Makes Borland happy with current sources.
Fixes bug in WM_PAINT handling in rip/splash code.
Fixes getline() bug (H0009)
Tidies up source.
Fixes up copyright notices.
Adds TODO docs for Borland. (Removes "TODO" note)
Small changes to defaults formatting.
Fixes ALT key on Graphical Port non NetHack mode.
Hilites pet in Graphical Port text mode.

Also Implements windowcolors for status and message window in graphical port.
On graphical port,
tested to see it actually works.

Tested on platforms Makefile MSC/BCC Graphical/Console, MSC IDE for
compile and run and performing hilite pet in graphical text, not
displaying rawio, alt key.
This commit is contained in:
nethack.allison
2002-03-10 17:41:11 +00:00
parent d40c1b8202
commit db2bdaadcb
15 changed files with 341 additions and 82 deletions

View File

@@ -176,7 +176,8 @@ Setting Up
For building the TTY version, ensure that GRAPHICAL is set to "N",
or commented out. (If you aren't building the TTY version, you are
currently reading the wrong section, and following the wrong set of
steps. In that case, you may wish to start reading from the top again.)
steps. In that case, you may wish to start reading from the top
again.)
Optional step:
If you elected not to use the high-quality BSD random number routines by
@@ -314,7 +315,7 @@ Setting Up
they are not necessary for building the graphical version of NetHack
(you can delete them to save space if you wish.)
Required Directories for a Win32 Console NetHack:
Required Directories for a Win32 Graphical NetHack:
top
|
@@ -350,6 +351,11 @@ Setting Up
Microsoft compiler users, perform step 3a.
Borland compiler users, perform step 3b.
Note for Microsoft users: It's possible to build a graphical version
using the Makefile. For simplicity's sake, however, only the Visual
C IDE build will be explained. The IDE build has full game
functionality and is the officially released build.s
a) Microsoft compiler:
Start the Visual C IDE. In the Visual C IDE Menus, choose:
File | Open Workspace
@@ -405,8 +411,11 @@ Setting Up
b) Borland Compiler only:
o Edit the Makefile. Ensure the following are set correctly.
GRAPHICS should be set to "Y"
{TODO: put a list of other things to check in Makefile.bcc here}
GRAPHICAL should be set to "Y"
o Ensure that all your tools directories are set up properly.
By default, your tools are assumed to be in the same
directory as the MAKE program.
Building

View File

@@ -35,10 +35,10 @@
TARGETOS=BOTH
APPVER=4.0
bccroot = c:\borland\bcc55
bccbin = $(MAKEDIR)
bccroot = $(MAKEDIR)\..
bccinc = $(bccroot)\include
bcclib = $(bccroot)\lib
bccbin = $(bccroot)\bin
!IFNDEF APPVER
APPVER = 4.0
@@ -136,8 +136,8 @@ DO_LEX = LEX_MSG
# - Specify your yacc and lex programs (or work-alikes) here.
#YACC = bison -y
YACC = byacc
YACC = bison -y
#YACC = byacc
#YACC = yacc
#LEX = lex
@@ -150,9 +150,9 @@ LEX = flex
FLEXSKEL =
#FLEXSKEL = -S../tools/flex.ske
YTABC = y_tab.c
YTABH = y_tab.h
LEXYYC = lexyy.c
YTABC = y.tab.c
YTABH = y.tab.h
LEXYYC = lex.yy.c
#
# Optional high-quality BSD random number generation routines
@@ -587,10 +587,10 @@ $(NHRES): $(TILEBMP16) $(WIN32)\winhack.rc $(WIN32)\mnsel.bmp \
$(WIN32)\mnselcnt.bmp $(WIN32)\mnunsel.bmp \
$(WIN32)\petmark.bmp $(WIN32)\NetHack.ico $(WIN32)\rip.bmp \
$(WIN32)\splash.bmp
@$(rc) -r -fo$@ -i$(WIN32) -dNDEBUG $(WIN32)\winhack.rc
@$(rc) -r -fo$@ -i$(WIN32) -i$(bccinc) -dNDEBUG $(WIN32)\winhack.rc
!ELSE
$(NHRES): $(NTSYS)\console.rc $(NTSYS)\NetHack.ico
@$(rc) -r -fo$@ -i$(NTSYS) -dNDEBUG $(NTSYS)\console.rc
@$(rc) -r -fo$@ -i$(NTSYS) -i$(bccinc) -dNDEBUG $(NTSYS)\console.rc
!ENDIF
#==========================================
@@ -737,7 +737,7 @@ $(O)lev_yacc.o: $(HACK_H) $(SP_LEV_H) $(INCL)\lev_comp.h $(U)lev_yacc.c
$(O)lev_$(LEX).o: $(HACK_H) $(INCL)\lev_comp.h $(SP_LEV_H) \
$(U)lev_$(LEX).c
@$(cc) $(LEVCFLAGS) -o$@ $(U)lev_$(LEX).c
@$(cc) $(LEVCFLAGS) -D__IO_H -o$@ $(U)lev_$(LEX).c
$(O)lev_main.o: $(U)lev_main.c $(HACK_H) $(SP_LEV_H)
@$(cc) $(LEVCFLAGS) -o$@ $(U)lev_main.c
@@ -794,7 +794,7 @@ $(O)dgn_yacc.o: $(HACK_H) $(DGN_FILE_H) $(INCL)\dgn_comp.h $(U)dgn_yacc.c
$(O)dgn_$(LEX).o: $(HACK_H) $(DGN_FILE_H) $(INCL)\dgn_comp.h \
$(U)dgn_$(LEX).c
@$(cc) $(LEVCFLAGS) -o$@ $(U)dgn_$(LEX).c
@$(cc) $(LEVCFLAGS) -D__IO_H -o$@ $(U)dgn_$(LEX).c
$(O)dgn_main.o: $(HACK_H) $(U)dgn_main.c
@$(cc) $(LEVCFLAGS) -o$@ $(U)dgn_main.c

View File

@@ -1,5 +1,5 @@
/* SCCS Id: @(#)console.rc 3.4 2002/02/14 */
/* Copyright (c) NetHack Win32 Porting Team, 2002. */
/* Copyright (c) Yitzhak Sapir, 2002. */
/* NetHack may be freely redistributed. See license for details. */
#include "windows.h"

View File

@@ -21,18 +21,25 @@ OPTIONS=IBMGraphics
# ascii7x12|ascii8x12|ascii16x12|ascii12x16|
# ascii10x18|ascii_fit_to_screen
OPTIONS=map_mode:tiles,scroll_margin:5
#
# Message window settings
OPTIONS=align_message:top,hilite_pet
OPTIONS=align_message:top
#
# Menu settings
OPTIONS=font_menu:Arial,font_size_menu:9
#
# Status window settings
OPTIONS=font_size_status:10
#
# Other
OPTIONS=font_size_text:9,font_size_message:9,toptenwin
OPTIONS=font_size_text:9,font_size_message:9,hilite_pet
# Top Ten Window. Highly Recommended.
OPTIONS=toptenwin
# *** Personal Preferences ***
# Some options to set personal preferences. Uncomment and change these to

View File

@@ -50,11 +50,17 @@ int mswin_getlin_window (
BOOL CALLBACK GetlinDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
struct getlin_data* data;
RECT main_rt, text_rt, dlg_rt, edit_rt;
RECT main_rt, dlg_rt;
SIZE dlg_sz;
TCHAR wbuf[BUFSZ];
HDC hdc;
HWND control;
HDC WindowDC;
HWND ControlHWND;
SIZE WindowExtents;
SIZE ViewPortExtents;
RECT ControlRect;
RECT ClientRect;
LONG Division;
LONG ButtonOffset;
switch (message)
{
@@ -63,17 +69,28 @@ BOOL CALLBACK GetlinDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara
SetWindowText(hWnd, NH_A2W(data->question, wbuf, sizeof(wbuf)));
SetWindowLong(hWnd, GWL_USERDATA, lParam);
/* get title text width */
SetRect(&text_rt, 0, 0, 100, 50);
hdc = GetWindowDC(hWnd);
DrawText(hdc, wbuf, _tcslen(wbuf), &text_rt,
DT_CALCRECT | DT_SINGLELINE | DT_NOPREFIX | DT_LEFT | DT_VCENTER );
ReleaseDC(hWnd, hdc);
/* center dialog in the main window */
GetWindowRect(hWnd, &dlg_rt);
GetWindowRect(GetNHApp()->hMainWnd, &main_rt);
dlg_sz.cx = max(dlg_rt.right-dlg_rt.left, text_rt.right-text_rt.left );
WindowDC = GetWindowDC(hWnd);
if (!GetWindowExtEx(WindowDC, &WindowExtents) ||
!GetViewportExtEx(WindowDC, &ViewPortExtents) ||
!GetTextExtentPoint32(GetWindowDC (hWnd), wbuf, _tcslen(wbuf), &dlg_sz))
{
dlg_sz.cx = 0;
}
else
{
/* I think we need to do the following scaling */
dlg_sz.cx *= ViewPortExtents.cx; dlg_sz.cx /= WindowExtents.cx;
/* Add the size of the various items in the caption bar */
dlg_sz.cx += GetSystemMetrics(SM_CXSIZE) +
2 * (GetSystemMetrics (SM_CXBORDER) + GetSystemMetrics(SM_CXFRAME));
}
if (dlg_sz.cx < dlg_rt.right - dlg_rt.left)
dlg_sz.cx = dlg_rt.right - dlg_rt.left;
dlg_sz.cy = dlg_rt.bottom - dlg_rt.top;
dlg_rt.left = (main_rt.left+main_rt.right-dlg_sz.cx)/2;
dlg_rt.right = dlg_rt.left + dlg_sz.cx;
@@ -86,38 +103,31 @@ BOOL CALLBACK GetlinDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara
dlg_sz.cy,
TRUE );
/* change layout of controls */
GetClientRect(hWnd, &dlg_rt);
/* set focus and size of the edit control */
ControlHWND = GetDlgItem(hWnd, IDC_GETLIN_EDIT);
SetFocus(ControlHWND);
GetClientRect (hWnd, &ClientRect);
GetWindowRect (ControlHWND, &ControlRect);
MoveWindow (ControlHWND, 0, 0,
ClientRect.right - ClientRect.left,
ControlRect.bottom - ControlRect.top, TRUE);
ButtonOffset = ControlRect.bottom - ControlRect.top;
control = GetDlgItem(hWnd, IDC_GETLIN_EDIT);
GetWindowRect(control, &edit_rt);
MoveWindow( control,
0,
0,
dlg_rt.right - dlg_rt.left,
edit_rt.bottom - edit_rt.top,
TRUE );
control = GetDlgItem(hWnd, IDOK);
GetWindowRect(control, &text_rt);
MoveWindow( control,
0,
edit_rt.bottom - edit_rt.top,
(dlg_rt.right-dlg_rt.left)/2,
text_rt.bottom - text_rt.top,
TRUE );
control = GetDlgItem(hWnd, IDCANCEL);
GetWindowRect(control, &text_rt);
MoveWindow( control,
(dlg_rt.right-dlg_rt.left)/2,
edit_rt.bottom - edit_rt.top,
(dlg_rt.right-dlg_rt.left)/2,
text_rt.bottom - text_rt.top,
TRUE );
/* set focus to the edit control */
SetFocus(GetDlgItem(hWnd, IDC_GETLIN_EDIT));
/* Now get the OK and CANCEL buttons */
ControlHWND = GetDlgItem(hWnd, IDOK);
GetWindowRect (ControlHWND, &ControlRect);
Division = ((ClientRect.right - ClientRect.left) -
2 * (ControlRect.right - ControlRect.left)) / 3;
MoveWindow (ControlHWND, Division,
ButtonOffset,
ControlRect.right - ControlRect.left,
ControlRect.bottom - ControlRect.top, TRUE);
ControlHWND = GetDlgItem(hWnd, IDCANCEL);
MoveWindow (ControlHWND,
Division * 2 + ControlRect.right - ControlRect.left,
ButtonOffset,
ControlRect.right - ControlRect.left,
ControlRect.bottom - ControlRect.top, TRUE);
/* tell windows that we've set the focus */
return FALSE;

View File

@@ -132,7 +132,18 @@ numpad[KEY_LAST][3] = {
(mode)==MAP_MODE_TILES_FIT_TO_SCREEN )
#define IS_MAP_ASCII(mode) ((mode)!=MAP_MODE_TILES && (mode)!=MAP_MODE_TILES_FIT_TO_SCREEN)
static const char *extendedlist_nhmode = "abcdefijlmnopqrstuvw?";
static const char *extendedlist_winmode = "abcdeijlnopqrtuvw?";
#define SCANLO 0x02
static const char scanmap[] = { /* ... */
'1','2','3','4','5','6','7','8','9','0',0,0,0,0,
'q','w','e','r','t','y','u','i','o','p','[',']', '\n',
0, 'a','s','d','f','g','h','j','k','l',';','\'', '`',
0, '\\', 'z','x','c','v','b','n','m',',','.','?' /* ... */
};
/*
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
@@ -367,11 +378,25 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
If not nethackmode, don't handle Alt-keys here.
If no Alt-key pressed it can never be an extended command
*/
if (GetNHApp()->regNetHackMode && (lParam & 1<<29))
if ((lParam & 1<<29) != 0)
{
unsigned char c = (unsigned char)(wParam & 0xFF);
NHEVENT_KBD(M(c));
return 0;
unsigned char scancode = (lParam >> 16) & 0xFF;
if (index(
GetNHApp()->regNetHackMode
? extendedlist_nhmode : extendedlist_winmode,
tolower(c)) != 0)
{
if (tolower(c) == 'b') {
NHEVENT_KBD(M('2'));
} else {
NHEVENT_KBD(M(tolower(c)));
}
} else if (scancode == (SCANLO + SIZE(scanmap)) - 1) {
NHEVENT_KBD(M('?'));
} else
return DefWindowProc(hWnd, message, wParam, lParam);
return 0;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}

View File

@@ -11,6 +11,6 @@
HWND mswin_init_main_window (void);
void mswin_layout_main_window(HWND changed_child);
void mswin_select_map_mode(int map_mode);
void mswin_menu_check_intf_mode();
void mswin_menu_check_intf_mode(void);
#endif /* MSWINMainWindow_h */

View File

@@ -553,18 +553,30 @@ void onPaint(HWND hWnd)
RECT glyph_rect;
int color;
unsigned special, mgch;
HBRUSH back_brush;
nhcoord2display(data, i, j, &glyph_rect);
#if (VERSION_MAJOR < 4) && (VERSION_MINOR < 4) && (PATCHLEVEL < 2)
nhglyph2charcolor(data->map[i][j], &ch, &color);
SetTextColor (hDC, nhcolor_to_RGB(color) );
#else
/* rely on NetHack core helper routine */
mapglyph(data->map[i][j], &mgch, &color,
&special, i, j);
ch = (uchar)mgch;
if (((special & MG_PET) && iflags.hilite_pet) ||
((special & MG_DETECT) && iflags.use_inverse)) {
back_brush = CreateSolidBrush(RGB(192, 192, 192));
FillRect (hDC, &glyph_rect, back_brush);
DeleteObject (back_brush);
SetTextColor( hDC, RGB(0, 0, 0) );
} else
{
SetTextColor (hDC, nhcolor_to_RGB(color) );
}
#endif
SetTextColor( hDC, nhcolor_to_RGB(color) );
nhcoord2display(data, i, j, &glyph_rect);
DrawText(hDC,
NH_A2W(&ch, &wch, 1),
1,

View File

@@ -12,7 +12,9 @@
#define MAX_MSG_LINES 32
#define MSG_LINES (int)min(iflags.msg_history, MAX_MSG_LINES)
#define MAXWINDOWTEXT 200
#define NHMSG_BKCOLOR RGB(192, 192, 192)
#define DEFAULT_COLOR_BG_MSG COLOR_WINDOW
#define DEFAULT_COLOR_FG_MSG COLOR_WINDOWTEXT
struct window_line {
int attr;
@@ -92,7 +94,7 @@ void register_message_window_class()
wcex.hInstance = GetNHApp()->hApp;
wcex.hIcon = NULL;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)CreateSolidBrush(NHMSG_BKCOLOR);
wcex.hbrBackground = message_bg_brush ? message_bg_brush : SYSCLR_TO_BRUSH(DEFAULT_COLOR_BG_MSG);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szMessageWindowClass;
@@ -408,10 +410,12 @@ void onPaint(HWND hWnd)
HGDIOBJ oldFont;
TCHAR wbuf[MAXWINDOWTEXT+2];
size_t wlen;
COLORREF OldBg, OldFg;
hdc = BeginPaint(hWnd, &ps);
SetBkColor(hdc, NHMSG_BKCOLOR);
OldBg = SetBkColor(hdc, message_bg_brush ? message_bg_color : (COLORREF)GetSysColor(DEFAULT_COLOR_BG_MSG));
OldFg = SetTextColor(hdc, message_fg_brush ? message_fg_color : (COLORREF)GetSysColor(DEFAULT_COLOR_FG_MSG));
data = (PNHMessageWindow)GetWindowLong(hWnd, GWL_USERDATA);
@@ -473,6 +477,8 @@ void onPaint(HWND hWnd)
}
}
SetTextColor (hdc, OldFg);
SetBkColor (hdc, OldBg);
EndPaint(hWnd, &ps);
}

View File

@@ -144,7 +144,9 @@ BOOL CALLBACK NHRIPWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
RECT textrect;
HDC hdcBitmap;
HANDLE OldBitmap;
hdc = GetDC (hWnd);
PAINTSTRUCT ps;
hdc = BeginPaint (hWnd, &ps);
hdcBitmap = CreateCompatibleDC(hdc);
SetBkMode (hdc, TRANSPARENT);
GetClientRect (hWnd, &clientrect);
@@ -176,7 +178,7 @@ BOOL CALLBACK NHRIPWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
}
SelectObject (hdcBitmap, OldBitmap);
DeleteDC (hdcBitmap);
ReleaseDC(hWnd, hdc);
EndPaint (hWnd, &ps);
}
break;

View File

@@ -1,4 +1,4 @@
/* Copyright (C) 2002 Yitzhak Sapir */
/* Copyright (C) 2001 by Alex Kompel <shurikk@pacbell.net> */
/* NetHack may be freely redistributed. See license for details. */
#include "winMS.h"
@@ -108,8 +108,9 @@ BOOL CALLBACK NHSplashWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
HDC hdcBitmap;
HANDLE OldBitmap;
HANDLE OldFont;
PAINTSTRUCT ps;
hdc = GetDC (hWnd);
hdc = BeginPaint (hWnd, &ps);
/* Show splash graphic */
hdcBitmap = CreateCompatibleDC(hdc);
@@ -149,7 +150,7 @@ BOOL CALLBACK NHSplashWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
DT_LEFT | DT_NOPREFIX | DT_LEFT | DT_VCENTER);
SelectObject(hdc, OldFont);
ReleaseDC(hWnd, hdc);
EndPaint (hWnd, &ps);
}
break;

View File

@@ -18,6 +18,9 @@ static TCHAR szStatusWindowClass[] = TEXT("MSNHStatusWndClass");
LRESULT CALLBACK StatusWndProc(HWND, UINT, WPARAM, LPARAM);
static void register_status_window_class(void);
#define DEFAULT_COLOR_BG_STATUS COLOR_WINDOW
#define DEFAULT_COLOR_FG_STATUS COLOR_WINDOWTEXT
HWND mswin_init_status_window () {
static int run_once = 0;
HWND ret;
@@ -64,7 +67,8 @@ void register_status_window_class()
wcex.hInstance = GetNHApp()->hApp;
wcex.hIcon = NULL;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.hbrBackground = status_bg_brush
? status_bg_brush : SYSCLR_TO_BRUSH(DEFAULT_COLOR_BG_STATUS);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szStatusWindowClass;
@@ -107,11 +111,17 @@ LRESULT CALLBACK StatusWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
SIZE sz;
HGDIOBJ oldFont;
TCHAR wbuf[BUFSZ];
COLORREF OldBg, OldFg;
hdc = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rt);
oldFont = SelectObject(hdc, mswin_get_font(NHW_STATUS, ATR_NONE, hdc, FALSE));
OldBg = SetBkColor(hdc, status_bg_brush
? status_bg_color : (COLORREF)GetSysColor(DEFAULT_COLOR_BG_STATUS));
OldFg = SetTextColor(hdc, status_fg_brush
? status_fg_color : (COLORREF)GetSysColor(DEFAULT_COLOR_FG_STATUS));
for(i=0; i<NHSW_LINES; i++ ) {
GetTextExtentPoint32(hdc, NH_A2W(data->window_text[i], wbuf, sizeof(wbuf)), strlen(data->window_text[i]), &sz);
@@ -121,7 +131,8 @@ LRESULT CALLBACK StatusWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
}
SelectObject(hdc, oldFont);
SetTextColor (hdc, OldFg);
SetBkColor (hdc, OldBg);
EndPaint(hWnd, &ps);
} break;

View File

@@ -35,6 +35,29 @@ void logDebug(const char *fmt, ...) { }
static void mswin_main_loop(void);
static BOOL initMapTiles(void);
static void mswin_color_from_string(char *colorstring, HBRUSH* brushptr, COLORREF *colorptr);
#define TOTAL_BRUSHES 10
HBRUSH brush_table[TOTAL_BRUSHES];
int max_brush = 0;
HBRUSH menu_bg_brush = NULL;
HBRUSH menu_fg_brush = NULL;
HBRUSH text_bg_brush = NULL;
HBRUSH text_fg_brush = NULL;
HBRUSH status_bg_brush = NULL;
HBRUSH status_fg_brush = NULL;
HBRUSH message_bg_brush = NULL;
HBRUSH message_fg_brush = NULL;
COLORREF menu_bg_color = RGB(0, 0, 0);
COLORREF menu_fg_color = RGB(0xFF, 0xFF, 0xFF);
COLORREF text_bg_color = RGB(0, 0, 0);
COLORREF text_fg_color = RGB(0xFF, 0xFF, 0xFF);
COLORREF status_bg_color = RGB(0, 0, 0);
COLORREF status_fg_color = RGB(0xFF, 0xFF, 0xFF);
COLORREF message_bg_color = RGB(0, 0, 0);
COLORREF message_fg_color = RGB(0xFF, 0xFF, 0xFF);
/* Interface definition, for windows.c */
struct window_procs mswin_procs = {
@@ -43,7 +66,7 @@ struct window_procs mswin_procs = {
WC_INVERSE|WC_SCROLL_MARGIN|WC_MAP_MODE|
WC_FONT_MESSAGE|WC_FONT_STATUS|WC_FONT_MENU|WC_FONT_TEXT|
WC_FONTSIZ_MESSAGE|WC_FONTSIZ_STATUS|WC_FONTSIZ_MENU|WC_FONTSIZ_TEXT|
WC_TILE_WIDTH|WC_TILE_HEIGHT|WC_TILE_FILE|WC_VARY_MSGCOUNT,
WC_TILE_WIDTH|WC_TILE_HEIGHT|WC_TILE_FILE|WC_VARY_MSGCOUNT|WC_WINDOWCOLORS,
mswin_init_nhwindows,
mswin_player_selection,
mswin_askname,
@@ -184,6 +207,15 @@ void mswin_init_nhwindows(int* argc, char** argv)
SET_IN_GAME
);
mswin_color_from_string(iflags.wc_foregrnd_menu, &menu_fg_brush, &menu_fg_color);
mswin_color_from_string(iflags.wc_foregrnd_message, &message_fg_brush, &message_fg_color);
mswin_color_from_string(iflags.wc_foregrnd_status, &status_fg_brush, &status_fg_color);
mswin_color_from_string(iflags.wc_foregrnd_text, &text_fg_brush, &text_fg_color);
mswin_color_from_string(iflags.wc_backgrnd_menu, &menu_bg_brush, &menu_bg_color);
mswin_color_from_string(iflags.wc_backgrnd_message, &message_bg_brush, &message_bg_color);
mswin_color_from_string(iflags.wc_backgrnd_status, &status_bg_brush, &status_bg_color);
mswin_color_from_string(iflags.wc_backgrnd_text, &text_bg_brush, &text_bg_color);
mswin_display_splash_window();
iflags.window_inited = TRUE;
}
@@ -276,6 +308,8 @@ void mswin_exit_nhwindows(const char *str)
logDebug("mswin_exit_nhwindows(%s)\n", str);
/* Write Window settings to the registry */
mswin_write_reg();
while (max_brush)
DeleteObject(brush_table[--max_brush]);
}
/* Prepare the window to be suspended. */
@@ -1299,6 +1333,7 @@ void mswin_preference_update(const char *pref)
mswin_layout_main_window(NULL);
return;
}
}
@@ -1502,3 +1537,103 @@ mswin_destroy_reg()
/* Prevent saving on exit */
GetNHApp()->saveRegistrySettings = 0;
}
typedef struct ctv
{
char *colorstring;
COLORREF colorvalue;
} color_table_value;
static color_table_value color_table[] = {
{ "black", RGB(0x00, 0x00, 0x00)},
{ "silver", RGB(0xC0, 0xC0, 0xC0)},
{ "gray", RGB(0x80, 0x80, 0x80)},
{ "grey", RGB(0x80, 0x80, 0x80)},
{ "white", RGB(0xFF, 0xFF, 0xFF)},
{ "maroon", RGB(0x80, 0x00, 0x00)},
{ "red", RGB(0xFF, 0x00, 0x00)},
{ "purple", RGB(0x80, 0x00, 0x80)},
{ "fuchsia", RGB(0xFF, 0x00, 0xFF)},
{ "green", RGB(0x00, 0x80, 0x00)},
{ "lime", RGB(0x00, 0xFF, 0x00)},
{ "olive", RGB(0x80, 0x80, 0x00)},
{ "yellow", RGB(0xFF, 0xFF, 0x00)},
{ "navy", RGB(0x00, 0x00, 0x80)},
{ "blue", RGB(0x00, 0x00, 0xFF)},
{ "teal", RGB(0x00, 0x80, 0x80)},
{ "aqua", RGB(0x00, 0xFF, 0xFF)},
{ "", RGB(0x00, 0x00, 0x00)},
};
typedef struct ctbv
{
char *colorstring;
int syscolorvalue;
} color_table_brush_value;
static color_table_brush_value color_table_brush[] = {
{ "activeborder", COLOR_ACTIVEBORDER },
{ "activecaption", COLOR_ACTIVECAPTION },
{ "appworkspace", COLOR_APPWORKSPACE },
{ "background", COLOR_BACKGROUND },
{ "btnface", COLOR_BTNFACE },
{ "btnshadow", COLOR_BTNSHADOW },
{ "btntext", COLOR_BTNTEXT },
{ "captiontext", COLOR_CAPTIONTEXT },
{ "graytext", COLOR_GRAYTEXT },
{ "greytext", COLOR_GRAYTEXT },
{ "highlight", COLOR_HIGHLIGHT },
{ "highlighttext", COLOR_HIGHLIGHTTEXT },
{ "inactiveborder", COLOR_INACTIVEBORDER },
{ "inactivecaption", COLOR_INACTIVECAPTION },
{ "menu", COLOR_MENU },
{ "menutext", COLOR_MENUTEXT },
{ "scrollbar", COLOR_SCROLLBAR },
{ "window", COLOR_WINDOW },
{ "windowframe", COLOR_WINDOWFRAME },
{ "windowtext", COLOR_WINDOWTEXT },
{ "", -1 },
};
static void mswin_color_from_string(char *colorstring, HBRUSH* brushptr, COLORREF *colorptr)
{
color_table_value *ctv_ptr = color_table;
color_table_brush_value *ctbv_ptr = color_table_brush;
int red_value, blue_value, green_value;
static char *hexadecimals = "0123456789abcdef";
if (colorstring == NULL) return;
if (*colorstring == '#') {
if (strlen(++colorstring) != 6) return;
red_value = index(hexadecimals, tolower(*colorstring++)) - hexadecimals;
red_value *= 16;
red_value += index(hexadecimals, tolower(*colorstring++)) - hexadecimals;
green_value = index(hexadecimals, tolower(*colorstring++)) - hexadecimals;
green_value *= 16;
green_value += index(hexadecimals, tolower(*colorstring++)) - hexadecimals;
blue_value = index(hexadecimals, tolower(*colorstring++)) - hexadecimals;
blue_value *= 16;
blue_value += index(hexadecimals, tolower(*colorstring++)) - hexadecimals;
*colorptr = RGB(red_value, blue_value, green_value);
} else {
while (*ctv_ptr->colorstring && stricmp(ctv_ptr->colorstring, colorstring))
++ctv_ptr;
if (*ctv_ptr->colorstring) {
*colorptr = ctv_ptr->colorvalue;
} else {
while (*ctbv_ptr->colorstring && stricmp(ctbv_ptr->colorstring, colorstring))
++ctbv_ptr;
if (*ctbv_ptr->colorstring) {
*brushptr = SYSCLR_TO_BRUSH(ctbv_ptr->syscolorvalue);
*colorptr = GetSysColor(ctbv_ptr->syscolorvalue);
}
}
}
if (max_brush > TOTAL_BRUSHES) panic("Too many colors!");
*brushptr = CreateSolidBrush(*colorptr);
brush_table[max_brush++] = *brushptr;
}

View File

@@ -134,9 +134,30 @@ void nhapply_image_transparent(
COLORREF cTransparent
);
void mswin_read_reg();
void mswin_destroy_reg();
void mswin_write_reg();
void mswin_read_reg(void);
void mswin_destroy_reg(void);
void mswin_write_reg(void);
extern HBRUSH menu_bg_brush;
extern HBRUSH menu_fg_brush;
extern HBRUSH text_bg_brush;
extern HBRUSH text_fg_brush;
extern HBRUSH status_bg_brush;
extern HBRUSH status_fg_brush;
extern HBRUSH message_bg_brush;
extern HBRUSH message_fg_brush;
extern COLORREF menu_bg_color;
extern COLORREF menu_fg_color;
extern COLORREF text_bg_color;
extern COLORREF text_fg_color;
extern COLORREF status_bg_color;
extern COLORREF status_fg_color;
extern COLORREF message_bg_color;
extern COLORREF message_fg_color;
#define SYSCLR_TO_BRUSH(x) ((HBRUSH)((x) + 1))
/* unicode stuff */
#ifdef UNICODE

View File

@@ -6,13 +6,33 @@
#include <process.h>
#include "winMS.h"
#include <shlwapi.h>
#include "hack.h"
#include "dlb.h"
#include "resource.h"
#include "mhmain.h"
#include "mhmap.h"
#ifndef __BORLANDC__
#include <shlwapi.h>
#else /* Borland redefines "boolean" in shlwapi.h so just use the little bit we need */
typedef struct _DLLVERSIONINFO
{
DWORD cbSize;
DWORD dwMajorVersion; // Major version
DWORD dwMinorVersion; // Minor version
DWORD dwBuildNumber; // Build number
DWORD dwPlatformID; // DLLVER_PLATFORM_*
} DLLVERSIONINFO;
//
// The caller should always GetProcAddress("DllGetVersion"), not
// implicitly link to it.
//
typedef HRESULT (CALLBACK* DLLGETVERSIONPROC)(DLLVERSIONINFO *);
#endif
#ifdef OVL0
#define SHARED_DCL
#else