(from Yitzhak)

This commit is contained in:
nethack.allison
2002-03-11 23:38:59 +00:00
parent 59938d5bc6
commit d936f1a1bf
3 changed files with 62 additions and 42 deletions
+21 -20
View File
@@ -548,11 +548,12 @@ void onPaint(HWND hWnd)
for(i=paint_rt.left; i<paint_rt.right; i++) for(i=paint_rt.left; i<paint_rt.right; i++)
for(j=paint_rt.top; j<paint_rt.bottom; j++) for(j=paint_rt.top; j<paint_rt.bottom; j++)
if(data->map[i][j]>=0) { if(data->map[i][j]>=0) {
uchar ch; char ch;
TCHAR wch; TCHAR wch;
RECT glyph_rect; RECT glyph_rect;
int color; int color;
unsigned special, mgch; unsigned special;
int mgch;
HBRUSH back_brush; HBRUSH back_brush;
nhcoord2display(data, i, j, &glyph_rect); nhcoord2display(data, i, j, &glyph_rect);
@@ -564,7 +565,7 @@ void onPaint(HWND hWnd)
/* rely on NetHack core helper routine */ /* rely on NetHack core helper routine */
mapglyph(data->map[i][j], &mgch, &color, mapglyph(data->map[i][j], &mgch, &color,
&special, i, j); &special, i, j);
ch = (uchar)mgch; ch = (char)mgch;
if (((special & MG_PET) && iflags.hilite_pet) || if (((special & MG_PET) && iflags.hilite_pet) ||
((special & MG_DETECT) && iflags.use_inverse)) { ((special & MG_DETECT) && iflags.use_inverse)) {
back_brush = CreateSolidBrush(RGB(192, 192, 192)); back_brush = CreateSolidBrush(RGB(192, 192, 192));
@@ -848,23 +849,23 @@ void nhglyph2charcolor(short g, uchar* ch, int* color)
COLORREF nhcolor_to_RGB(int c) COLORREF nhcolor_to_RGB(int c)
{ {
switch(c) { switch(c) {
case CLR_BLACK: return RGB( 85, 85, 85); case CLR_BLACK: return RGB(0x55, 0x55, 0x55);
case CLR_RED: return RGB(255, 0, 0); case CLR_RED: return RGB(0xFF, 0x00, 0x00);
case CLR_GREEN: return RGB( 0, 128, 0); case CLR_GREEN: return RGB(0x00, 0x80, 0x00);
case CLR_BROWN: return RGB(165, 42, 42); case CLR_BROWN: return RGB(0xA5, 0x2A, 0x2A);
case CLR_BLUE: return RGB( 0, 0, 255); case CLR_BLUE: return RGB(0x00, 0x00, 0xFF);
case CLR_MAGENTA: return RGB(255, 0, 255); case CLR_MAGENTA: return RGB(0xFF, 0x00, 0xFF);
case CLR_CYAN: return RGB( 0, 255, 255); case CLR_CYAN: return RGB(0x00, 0xFF, 0xFF);
case CLR_GRAY: return RGB(192, 192, 192); case CLR_GRAY: return RGB(0xC0, 0xC0, 0xC0);
case NO_COLOR: return RGB(255, 255, 255); case NO_COLOR: return RGB(0xFF, 0xFF, 0xFF);
case CLR_ORANGE: return RGB(255, 165, 0); case CLR_ORANGE: return RGB(0xFF, 0xA5, 0x00);
case CLR_BRIGHT_GREEN: return RGB( 0, 255, 0); case CLR_BRIGHT_GREEN: return RGB(0x00, 0xFF, 0x00);
case CLR_YELLOW: return RGB(255, 255, 0); case CLR_YELLOW: return RGB(0xFF, 0xFF, 0x00);
case CLR_BRIGHT_BLUE: return RGB(0, 191, 255); case CLR_BRIGHT_BLUE: return RGB(0x00, 0xC0, 0xFF);
case CLR_BRIGHT_MAGENTA: return RGB(255, 127, 255); case CLR_BRIGHT_MAGENTA: return RGB(0xFF, 0x80, 0xFF);
case CLR_BRIGHT_CYAN: return RGB(127, 255, 255); /* something close to aquamarine */ case CLR_BRIGHT_CYAN: return RGB(0x80, 0xFF, 0xFF); /* something close to aquamarine */
case CLR_WHITE: return RGB(255, 255, 255); case CLR_WHITE: return RGB(0xFF, 0xFF, 0xFF);
default: return RGB( 0, 0, 0); /* black */ default: return RGB(0x00, 0x00, 0x00); /* black */
} }
} }
+6
View File
@@ -59,6 +59,7 @@ void mswin_display_RIP_window (HWND hWnd)
RECT clientrect; RECT clientrect;
RECT textrect; RECT textrect;
HDC hdc; HDC hdc;
HFONT OldFont;
data = (PNHRIPWindow)GetWindowLong(hWnd, GWL_USERDATA); data = (PNHRIPWindow)GetWindowLong(hWnd, GWL_USERDATA);
@@ -75,8 +76,10 @@ void mswin_display_RIP_window (HWND hWnd)
if (data->window_text) if (data->window_text)
{ {
hdc = GetDC (hWnd); hdc = GetDC (hWnd);
OldFont = SelectObject (hdc, mswin_get_font(NHW_TEXT, 0, hdc, FALSE));
DrawText (hdc, data->window_text, strlen(data->window_text), &textrect, DrawText (hdc, data->window_text, strlen(data->window_text), &textrect,
DT_LEFT | DT_NOPREFIX | DT_CALCRECT); DT_LEFT | DT_NOPREFIX | DT_CALCRECT);
SelectObject (hdc, OldFont);
ReleaseDC(hWnd, hdc); ReleaseDC(hWnd, hdc);
} }
if (textrect.right - textrect.left > RIP_WIDTH) if (textrect.right - textrect.left > RIP_WIDTH)
@@ -145,8 +148,10 @@ BOOL CALLBACK NHRIPWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
HDC hdcBitmap; HDC hdcBitmap;
HANDLE OldBitmap; HANDLE OldBitmap;
PAINTSTRUCT ps; PAINTSTRUCT ps;
HFONT OldFont;
hdc = BeginPaint (hWnd, &ps); hdc = BeginPaint (hWnd, &ps);
OldFont = SelectObject (hdc, mswin_get_font(NHW_TEXT, 0, hdc, FALSE));
hdcBitmap = CreateCompatibleDC(hdc); hdcBitmap = CreateCompatibleDC(hdc);
SetBkMode (hdc, TRANSPARENT); SetBkMode (hdc, TRANSPARENT);
GetClientRect (hWnd, &clientrect); GetClientRect (hWnd, &clientrect);
@@ -177,6 +182,7 @@ BOOL CALLBACK NHRIPWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
DT_CENTER | DT_VCENTER | DT_NOPREFIX | DT_WORDBREAK); DT_CENTER | DT_VCENTER | DT_NOPREFIX | DT_WORDBREAK);
} }
SelectObject (hdcBitmap, OldBitmap); SelectObject (hdcBitmap, OldBitmap);
SelectObject (hdc, OldFont);
DeleteDC (hdcBitmap); DeleteDC (hdcBitmap);
EndPaint (hWnd, &ps); EndPaint (hWnd, &ps);
} }
+35 -22
View File
@@ -1549,29 +1549,42 @@ typedef struct ctv
COLORREF colorvalue; COLORREF colorvalue;
} color_table_value; } color_table_value;
/*
* The color list here is a combination of:
* NetHack colors. (See mhmap.c)
* HTML colors. (See http://www.w3.org/TR/REC-html40/types.html#h-6.5 )
*/
static color_table_value color_table[] = { static color_table_value color_table[] = {
{ "black", RGB(0x00, 0x00, 0x00)}, /* NetHack colors */
{ "red", RGB(0xFF, 0x00, 0x00)}, { "black", RGB(0x55, 0x55, 0x55)},
{ "green", RGB(0x00, 0x80, 0x00)}, { "red", RGB(0xFF, 0x00, 0x00)},
{ "brown", RGB(200,160,0)}, { "green", RGB(0x00, 0x80, 0x00)},
{ "blue", RGB(0,0,170)}, { "brown", RGB(0xA5, 0x2A, 0x2A)},
{ "magenta", RGB(160,0,160)}, { "blue", RGB(0x00, 0x00, 0xFF)},
{ "cyan", RGB(0,160,160,)}, { "magenta", RGB(0xFF, 0x00, 0xFF)},
{ "gray", RGB(0x80, 0x80, 0x80)}, { "cyan", RGB(0x00, 0xFF, 0xFF)},
{ "orange", RGB(255,140,0)}, { "orange", RGB(0xFF, 0xA5, 0x00)},
{ "yellow", RGB(0xFF, 0xFF, 0x00)}, { "brightgreen", RGB(0x00, 0xFF, 0x00)},
{ "white", RGB(0xFF, 0xFF, 0xFF)}, { "yellow", RGB(0xFF, 0xFF, 0x00)},
{ "purple", RGB(0x80, 0x00, 0x80)}, { "brightblue", RGB(0x00, 0xC0, 0xFF)},
{ "silver", RGB(0xC0, 0xC0, 0xC0)}, { "brightmagenta", RGB(0xFF, 0x80, 0xFF)},
{ "grey", RGB(0x80, 0x80, 0x80)}, { "brightcyan", RGB(0x80, 0xFF, 0xFF)},
{ "maroon", RGB(0x80, 0x00, 0x00)}, { "white", RGB(0xFF, 0xFF, 0xFF)},
{ "fuchsia", RGB(0xFF, 0x00, 0xFF)}, /* Remaining HTML colors */
{ "lime", RGB(0x00, 0xFF, 0x00)}, { "trueblack", RGB(0x00, 0x00, 0x00)},
{ "olive", RGB(0x80, 0x80, 0x00)}, { "gray", RGB(0x80, 0x80, 0x80)},
{ "navy", RGB(0x00, 0x00, 0x80)}, { "grey", RGB(0x80, 0x80, 0x80)},
{ "teal", RGB(0x00, 0x80, 0x80)}, { "purple", RGB(0x80, 0x00, 0x80)},
{ "aqua", RGB(0x00, 0xFF, 0xFF)}, { "silver", RGB(0xC0, 0xC0, 0xC0)},
{ "", RGB(0x00, 0x00, 0x00)}, { "maroon", RGB(0x80, 0x00, 0x00)},
{ "fuchsia", RGB(0xFF, 0x00, 0xFF)}, /* = NetHack magenta */
{ "lime", RGB(0x00, 0xFF, 0x00)}, /* = NetHack bright green */
{ "olive", RGB(0x80, 0x80, 0x00)},
{ "navy", RGB(0x00, 0x00, 0x80)},
{ "teal", RGB(0x00, 0x80, 0x80)},
{ "aqua", RGB(0x00, 0xFF, 0xFF)}, /* = NetHack cyan */
{ "", RGB(0x00, 0x00, 0x00)},
}; };
typedef struct ctbv typedef struct ctbv