author | Darkvater |
Tue, 31 Oct 2006 23:04:47 +0000 | |
changeset 5009 | 0ae33f104d4f |
parent 4840 | a76d40e0aea4 |
child 5019 | 9046723a0878 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
2189
5cdc11ffeaa4
(svn r2704) Remove . from include path again, too much trouble. Also add some #ifdefs and #includes for the Windows build
tron
parents:
2186
diff
changeset
|
3 |
#include "../stdafx.h" |
5cdc11ffeaa4
(svn r2704) Remove . from include path again, too much trouble. Also add some #ifdefs and #includes for the Windows build
tron
parents:
2186
diff
changeset
|
4 |
#include "../openttd.h" |
5cdc11ffeaa4
(svn r2704) Remove . from include path again, too much trouble. Also add some #ifdefs and #includes for the Windows build
tron
parents:
2186
diff
changeset
|
5 |
#include "../functions.h" |
5cdc11ffeaa4
(svn r2704) Remove . from include path again, too much trouble. Also add some #ifdefs and #includes for the Windows build
tron
parents:
2186
diff
changeset
|
6 |
#include "../gfx.h" |
5cdc11ffeaa4
(svn r2704) Remove . from include path again, too much trouble. Also add some #ifdefs and #includes for the Windows build
tron
parents:
2186
diff
changeset
|
7 |
#include "../macros.h" |
5cdc11ffeaa4
(svn r2704) Remove . from include path again, too much trouble. Also add some #ifdefs and #includes for the Windows build
tron
parents:
2186
diff
changeset
|
8 |
#include "../network.h" |
5cdc11ffeaa4
(svn r2704) Remove . from include path again, too much trouble. Also add some #ifdefs and #includes for the Windows build
tron
parents:
2186
diff
changeset
|
9 |
#include "../variables.h" |
2207
be1ef1e1fc58
(svn r2725) Move MyShowCursor() back into win32.c, it fits better there
tron
parents:
2189
diff
changeset
|
10 |
#include "../win32.h" |
2189
5cdc11ffeaa4
(svn r2704) Remove . from include path again, too much trouble. Also add some #ifdefs and #includes for the Windows build
tron
parents:
2186
diff
changeset
|
11 |
#include "../window.h" |
5cdc11ffeaa4
(svn r2704) Remove . from include path again, too much trouble. Also add some #ifdefs and #includes for the Windows build
tron
parents:
2186
diff
changeset
|
12 |
#include "win32_v.h" |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
13 |
#include <windows.h> |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
14 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
15 |
static struct { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
16 |
HWND main_wnd; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
17 |
HBITMAP dib_sect; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
18 |
Pixel *bitmap_bits; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
19 |
Pixel *buffer_bits; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
20 |
Pixel *alloced_bits; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
21 |
HPALETTE gdi_palette; |
4489 | 22 |
int width; |
23 |
int height; |
|
24 |
int width_org; |
|
25 |
int height_org; |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
26 |
bool fullscreen; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
27 |
bool double_size; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
28 |
bool has_focus; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
29 |
bool running; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
30 |
} _wnd; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
31 |
|
3051
6a9ddcac6d56
(svn r3640) - Remove win32-only variables from variables.h and put them into win32_v.c. Also ifdef the win32 specific configuration file settings.
Darkvater
parents:
2952
diff
changeset
|
32 |
bool _force_full_redraw; |
6a9ddcac6d56
(svn r3640) - Remove win32-only variables from variables.h and put them into win32_v.c. Also ifdef the win32 specific configuration file settings.
Darkvater
parents:
2952
diff
changeset
|
33 |
bool _double_size; |
4258
087d44b3514f
(svn r5874) -Feature [FS#234]: Remember the maximized state and restore on start. This also fixes a bug where a different resolution is chosen for a maximized window, but it retains the maximized flag. Only win32.
Darkvater
parents:
4077
diff
changeset
|
34 |
bool _window_maximize; |
3051
6a9ddcac6d56
(svn r3640) - Remove win32-only variables from variables.h and put them into win32_v.c. Also ifdef the win32 specific configuration file settings.
Darkvater
parents:
2952
diff
changeset
|
35 |
uint _display_hz; |
6a9ddcac6d56
(svn r3640) - Remove win32-only variables from variables.h and put them into win32_v.c. Also ifdef the win32 specific configuration file settings.
Darkvater
parents:
2952
diff
changeset
|
36 |
uint _fullscreen_bpp; |
6a9ddcac6d56
(svn r3640) - Remove win32-only variables from variables.h and put them into win32_v.c. Also ifdef the win32 specific configuration file settings.
Darkvater
parents:
2952
diff
changeset
|
37 |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
38 |
static void MakePalette(void) |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
39 |
{ |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
40 |
LOGPALETTE *pal; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
41 |
uint i; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
42 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
43 |
pal = alloca(sizeof(LOGPALETTE) + (256-1) * sizeof(PALETTEENTRY)); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
44 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
45 |
pal->palVersion = 0x300; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
46 |
pal->palNumEntries = 256; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
47 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
48 |
for (i = 0; i != 256; i++) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
49 |
pal->palPalEntry[i].peRed = _cur_palette[i].r; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
50 |
pal->palPalEntry[i].peGreen = _cur_palette[i].g; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
51 |
pal->palPalEntry[i].peBlue = _cur_palette[i].b; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
52 |
pal->palPalEntry[i].peFlags = 0; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
53 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
54 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
55 |
_wnd.gdi_palette = CreatePalette(pal); |
4489 | 56 |
if (_wnd.gdi_palette == NULL) error("CreatePalette failed!\n"); |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
57 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
58 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
59 |
static void UpdatePalette(HDC dc, uint start, uint count) |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
60 |
{ |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
61 |
RGBQUAD rgb[256]; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
62 |
uint i; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
63 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
64 |
for (i = 0; i != count; i++) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
65 |
rgb[i].rgbRed = _cur_palette[start + i].r; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
66 |
rgb[i].rgbGreen = _cur_palette[start + i].g; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
67 |
rgb[i].rgbBlue = _cur_palette[start + i].b; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
68 |
rgb[i].rgbReserved = 0; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
69 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
70 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
71 |
SetDIBColorTable(dc, start, count, rgb); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
72 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
73 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
74 |
typedef struct { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
75 |
byte vk_from; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
76 |
byte vk_count; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
77 |
byte map_to; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
78 |
} VkMapping; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
79 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
80 |
#define AS(x, z) {x, 0, z} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
81 |
#define AM(x, y, z, w) {x, y - x, z} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
82 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
83 |
static const VkMapping _vk_mapping[] = { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
84 |
// Pageup stuff + up/down |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
85 |
AM(VK_PRIOR,VK_DOWN, WKC_PAGEUP, WKC_DOWN), |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
86 |
// Map letters & digits |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
87 |
AM('A','Z','A','Z'), |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
88 |
AM('0','9','0','9'), |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
89 |
|
4434
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4300
diff
changeset
|
90 |
AS(VK_ESCAPE, WKC_ESC), |
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4300
diff
changeset
|
91 |
AS(VK_PAUSE, WKC_PAUSE), |
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4300
diff
changeset
|
92 |
AS(VK_BACK, WKC_BACKSPACE), |
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4300
diff
changeset
|
93 |
AM(VK_INSERT, VK_DELETE, WKC_INSERT, WKC_DELETE), |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
94 |
|
4434
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4300
diff
changeset
|
95 |
AS(VK_SPACE, WKC_SPACE), |
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4300
diff
changeset
|
96 |
AS(VK_RETURN, WKC_RETURN), |
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4300
diff
changeset
|
97 |
AS(VK_TAB, WKC_TAB), |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
98 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
99 |
// Function keys |
4434
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4300
diff
changeset
|
100 |
AM(VK_F1, VK_F12, WKC_F1, WKC_F12), |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
101 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
102 |
// Numeric part. |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
103 |
// What is the virtual keycode for numeric enter?? |
4434
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4300
diff
changeset
|
104 |
AM(VK_NUMPAD0, VK_NUMPAD9, WKC_NUM_0, WKC_NUM_9), |
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4300
diff
changeset
|
105 |
AS(VK_DIVIDE, WKC_NUM_DIV), |
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4300
diff
changeset
|
106 |
AS(VK_MULTIPLY, WKC_NUM_MUL), |
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4300
diff
changeset
|
107 |
AS(VK_SUBTRACT, WKC_NUM_MINUS), |
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4300
diff
changeset
|
108 |
AS(VK_ADD, WKC_NUM_PLUS), |
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4300
diff
changeset
|
109 |
AS(VK_DECIMAL, WKC_NUM_DECIMAL) |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
110 |
}; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
111 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
112 |
static uint MapWindowsKey(uint sym) |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
113 |
{ |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
114 |
const VkMapping *map; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
115 |
uint key = 0; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
116 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
117 |
for (map = _vk_mapping; map != endof(_vk_mapping); ++map) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
118 |
if ((uint)(sym - map->vk_from) <= map->vk_count) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
119 |
key = sym - map->vk_from + map->map_to; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
120 |
break; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
121 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
122 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
123 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
124 |
if (GetAsyncKeyState(VK_SHIFT) < 0) key |= WKC_SHIFT; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
125 |
if (GetAsyncKeyState(VK_CONTROL) < 0) key |= WKC_CTRL; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
126 |
if (GetAsyncKeyState(VK_MENU) < 0) key |= WKC_ALT; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
127 |
return key; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
128 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
129 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
130 |
static bool AllocateDibSection(int w, int h); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
131 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
132 |
static void ClientSizeChanged(int w, int h) |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
133 |
{ |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
134 |
if (_wnd.double_size) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
135 |
w /= 2; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
136 |
h /= 2; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
137 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
138 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
139 |
// allocate new dib section of the new size |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
140 |
if (AllocateDibSection(w, h)) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
141 |
// mark all palette colors dirty |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
142 |
_pal_first_dirty = 0; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
143 |
_pal_last_dirty = 255; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
144 |
GameSizeChanged(); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
145 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
146 |
// redraw screen |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
147 |
if (_wnd.running) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
148 |
_screen.dst_ptr = _wnd.buffer_bits; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
149 |
UpdateWindows(); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
150 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
151 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
152 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
153 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
154 |
#ifdef _DEBUG |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
155 |
// Keep this function here.. |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
156 |
// It allows you to redraw the screen from within the MSVC debugger |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
157 |
int RedrawScreenDebug(void) |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
158 |
{ |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
159 |
HDC dc,dc2; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
160 |
static int _fooctr; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
161 |
HBITMAP old_bmp; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
162 |
HPALETTE old_palette; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
163 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
164 |
_screen.dst_ptr = _wnd.buffer_bits; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
165 |
UpdateWindows(); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
166 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
167 |
dc = GetDC(_wnd.main_wnd); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
168 |
dc2 = CreateCompatibleDC(dc); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
169 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
170 |
old_bmp = SelectObject(dc2, _wnd.dib_sect); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
171 |
old_palette = SelectPalette(dc, _wnd.gdi_palette, FALSE); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
172 |
BitBlt(dc, 0, 0, _wnd.width, _wnd.height, dc2, 0, 0, SRCCOPY); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
173 |
SelectPalette(dc, old_palette, TRUE); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
174 |
SelectObject(dc2, old_bmp); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
175 |
DeleteDC(dc2); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
176 |
ReleaseDC(_wnd.main_wnd, dc); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
177 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
178 |
return _fooctr++; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
179 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
180 |
#endif |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
181 |
|
3312
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
182 |
/* Windows 95 will not have a WM_MOUSELEAVE message, so define it if |
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
183 |
* needed. There is no such event as WM_MOUSEENTER, we just made this up :) */ |
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
184 |
#define WM_MOUSEENTER WM_USER + 1 |
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
185 |
#if !defined(WM_MOUSELEAVE) |
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
186 |
#define WM_MOUSELEAVE 0x02A3 |
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
187 |
#endif |
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
188 |
#define TID_POLLMOUSE 1 |
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
189 |
#define MOUSE_POLL_DELAY 75 |
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
190 |
|
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
191 |
static void CALLBACK TrackMouseTimerProc(HWND hwnd, UINT msg, UINT event, DWORD time) |
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
192 |
{ |
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
193 |
RECT rc; |
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
194 |
POINT pt; |
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
195 |
|
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
196 |
/* Get the rectangle of our window and translate it to screen coordinates. |
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
197 |
* Compare this with the current screen coordinates of the mouse and if it |
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
198 |
* falls outside of the area or our window we have left the window. */ |
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
199 |
GetClientRect(hwnd, &rc); |
3802
e3f0d57cc358
(svn r4810) - Fix: removed warning about strict-alias (release build)
glx
parents:
3325
diff
changeset
|
200 |
MapWindowPoints(hwnd, HWND_DESKTOP, (LPPOINT)(LPRECT)&rc, 2); |
3312
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
201 |
GetCursorPos(&pt); |
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
202 |
|
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
203 |
if (!PtInRect(&rc, pt) || (WindowFromPoint(pt) != hwnd)) { |
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
204 |
KillTimer(hwnd, event); |
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
205 |
PostMessage(hwnd, WM_MOUSELEAVE, 0, 0L); |
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
206 |
} |
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
207 |
} |
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
208 |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
209 |
static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
210 |
{ |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
211 |
switch (msg) { |
4489 | 212 |
case WM_CREATE: |
213 |
SetTimer(hwnd, TID_POLLMOUSE, MOUSE_POLL_DELAY, (TIMERPROC)TrackMouseTimerProc); |
|
214 |
break; |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
215 |
|
4489 | 216 |
case WM_PAINT: { |
217 |
PAINTSTRUCT ps; |
|
218 |
HDC dc,dc2; |
|
219 |
HBITMAP old_bmp; |
|
220 |
HPALETTE old_palette; |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
221 |
|
4489 | 222 |
BeginPaint(hwnd, &ps); |
223 |
dc = ps.hdc; |
|
224 |
dc2 = CreateCompatibleDC(dc); |
|
225 |
old_bmp = SelectObject(dc2, _wnd.dib_sect); |
|
226 |
old_palette = SelectPalette(dc, _wnd.gdi_palette, FALSE); |
|
3312
d28f88dc5587
(svn r4075) - Feature: Undraw the mouse when it leaves the window and Draw it again when it enters. Added both for WIN32 and SDL. Since Win95 has troubles with TrackMouseEvent(), this function was just simply rewritten which was the easiest. Based on a patch by DmitryKo.
Darkvater
parents:
3285
diff
changeset
|
227 |
|
4489 | 228 |
if (_pal_last_dirty != -1) { |
229 |
UpdatePalette(dc2, _pal_first_dirty, _pal_last_dirty - _pal_first_dirty + 1); |
|
230 |
_pal_last_dirty = -1; |
|
231 |
} |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
232 |
|
4489 | 233 |
BitBlt(dc, 0, 0, _wnd.width, _wnd.height, dc2, 0, 0, SRCCOPY); |
234 |
SelectPalette(dc, old_palette, TRUE); |
|
235 |
SelectObject(dc2, old_bmp); |
|
236 |
DeleteDC(dc2); |
|
237 |
EndPaint(hwnd, &ps); |
|
238 |
return 0; |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
239 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
240 |
|
4489 | 241 |
case WM_PALETTECHANGED: |
242 |
if ((HWND)wParam == hwnd) return 0; |
|
243 |
/* FALLTHROUGH */ |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
244 |
|
4489 | 245 |
case WM_QUERYNEWPALETTE: { |
246 |
HDC hDC = GetWindowDC(hwnd); |
|
247 |
HPALETTE hOldPalette = SelectPalette(hDC, _wnd.gdi_palette, FALSE); |
|
248 |
UINT nChanged = RealizePalette(hDC); |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
249 |
|
4489 | 250 |
SelectPalette(hDC, hOldPalette, TRUE); |
251 |
ReleaseDC(hwnd, hDC); |
|
252 |
if (nChanged) InvalidateRect(hwnd, NULL, FALSE); |
|
253 |
return 0; |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
254 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
255 |
|
4489 | 256 |
case WM_CLOSE: |
4548
6165e12570bf
(svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents:
4536
diff
changeset
|
257 |
HandleExitGameRequest(); |
4489 | 258 |
_window_maximize = IsZoomed(_wnd.main_wnd); |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
259 |
return 0; |
4489 | 260 |
|
261 |
case WM_LBUTTONDOWN: |
|
262 |
SetCapture(hwnd); |
|
263 |
_left_button_down = true; |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
264 |
return 0; |
4489 | 265 |
|
266 |
case WM_LBUTTONUP: |
|
267 |
ReleaseCapture(); |
|
268 |
_left_button_down = false; |
|
269 |
_left_button_clicked = false; |
|
270 |
return 0; |
|
271 |
||
272 |
case WM_RBUTTONDOWN: |
|
273 |
SetCapture(hwnd); |
|
274 |
_right_button_down = true; |
|
275 |
_right_button_clicked = true; |
|
276 |
return 0; |
|
277 |
||
278 |
case WM_RBUTTONUP: |
|
279 |
ReleaseCapture(); |
|
280 |
_right_button_down = false; |
|
281 |
return 0; |
|
282 |
||
283 |
case WM_MOUSEENTER: |
|
284 |
_cursor.in_window = true; |
|
285 |
DrawMouseCursor(); |
|
286 |
break; |
|
287 |
||
288 |
case WM_MOUSELEAVE: |
|
289 |
UndrawMouseCursor(); |
|
290 |
_cursor.in_window = false; |
|
291 |
break; |
|
292 |
||
293 |
case WM_MOUSEMOVE: { |
|
294 |
int x = (int16)LOWORD(lParam); |
|
295 |
int y = (int16)HIWORD(lParam); |
|
296 |
POINT pt; |
|
297 |
||
298 |
/* If the mouse was not in the window and it has moved it means it has |
|
299 |
* come into the window, so send a WM_MOUSEENTER message. Also start |
|
300 |
* tracking the mouse for exiting the window */ |
|
301 |
if (!_cursor.in_window) { |
|
302 |
_cursor.in_window = true; |
|
303 |
SetTimer(hwnd, TID_POLLMOUSE, MOUSE_POLL_DELAY, (TIMERPROC)TrackMouseTimerProc); |
|
304 |
||
305 |
if (hwnd != GetCapture()) PostMessage(hwnd, WM_MOUSEENTER, 0, 0L); |
|
306 |
} |
|
307 |
||
308 |
if (_wnd.double_size) { |
|
309 |
x /= 2; |
|
310 |
y /= 2; |
|
311 |
} |
|
312 |
||
313 |
if (_cursor.fix_at) { |
|
314 |
int dx = x - _cursor.pos.x; |
|
315 |
int dy = y - _cursor.pos.y; |
|
316 |
if (dx != 0 || dy != 0) { |
|
317 |
_cursor.delta.x += dx; |
|
318 |
_cursor.delta.y += dy; |
|
319 |
||
320 |
pt.x = _cursor.pos.x; |
|
321 |
pt.y = _cursor.pos.y; |
|
322 |
||
323 |
if (_wnd.double_size) { |
|
324 |
pt.x *= 2; |
|
325 |
pt.y *= 2; |
|
326 |
} |
|
327 |
ClientToScreen(hwnd, &pt); |
|
328 |
SetCursorPos(pt.x, pt.y); |
|
329 |
} |
|
330 |
} else { |
|
331 |
_cursor.delta.x += x - _cursor.pos.x; |
|
332 |
_cursor.delta.y += y - _cursor.pos.y; |
|
333 |
_cursor.pos.x = x; |
|
334 |
_cursor.pos.y = y; |
|
335 |
_cursor.dirty = true; |
|
336 |
} |
|
337 |
MyShowCursor(false); |
|
338 |
return 0; |
|
339 |
} |
|
340 |
||
341 |
case WM_KEYDOWN: { |
|
342 |
// this is the rewritten ascii input function |
|
343 |
// it disables windows deadkey handling --> more linux like :D |
|
344 |
WORD w = 0; |
|
345 |
byte ks[256]; |
|
346 |
uint scancode; |
|
347 |
||
348 |
GetKeyboardState(ks); |
|
349 |
if (ToAscii(wParam, 0, ks, &w, 0) == 0) { |
|
350 |
w = 0; // no translation was possible |
|
351 |
} |
|
352 |
||
353 |
_pressed_key = w | MapWindowsKey(wParam) << 16; |
|
354 |
||
355 |
scancode = GB(lParam, 16, 8); |
|
356 |
if (scancode == 41) _pressed_key = w | WKC_BACKQUOTE << 16; |
|
357 |
||
358 |
if ((_pressed_key >> 16) == ('D' | WKC_CTRL) && !_wnd.fullscreen) { |
|
359 |
_double_size ^= 1; |
|
360 |
_wnd.double_size = _double_size; |
|
361 |
ClientSizeChanged(_wnd.width, _wnd.height); |
|
362 |
MarkWholeScreenDirty(); |
|
363 |
} |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
364 |
break; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
365 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
366 |
|
4489 | 367 |
case WM_SYSKEYDOWN: /* user presses F10 or Alt, both activating the title-menu */ |
368 |
switch (wParam) { |
|
369 |
case VK_RETURN: |
|
370 |
case 'F': /* Full Screen on ALT + ENTER/F */ |
|
371 |
ToggleFullScreen(!_wnd.fullscreen); |
|
372 |
return 0; |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
373 |
|
4489 | 374 |
case VK_MENU: /* Just ALT */ |
375 |
return 0; // do nothing |
|
376 |
||
377 |
case VK_F10: /* F10, ignore activation of menu */ |
|
378 |
_pressed_key = MapWindowsKey(wParam) << 16; |
|
379 |
return 0; |
|
380 |
||
381 |
default: /* ALT in combination with something else */ |
|
382 |
_pressed_key = MapWindowsKey(wParam) << 16; |
|
383 |
break; |
|
384 |
} |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
385 |
break; |
4489 | 386 |
|
387 |
case WM_NCMOUSEMOVE: |
|
388 |
MyShowCursor(true); |
|
389 |
return 0; |
|
390 |
||
391 |
case WM_SIZE: |
|
392 |
if (wParam != SIZE_MINIMIZED) { |
|
393 |
ClientSizeChanged(LOWORD(lParam), HIWORD(lParam)); |
|
394 |
} |
|
395 |
return 0; |
|
396 |
||
397 |
case WM_SIZING: { |
|
398 |
RECT* r = (RECT*)lParam; |
|
399 |
RECT r2; |
|
400 |
int w, h; |
|
401 |
||
402 |
SetRect(&r2, 0, 0, 0, 0); |
|
403 |
AdjustWindowRect(&r2, GetWindowLong(hwnd, GWL_STYLE), FALSE); |
|
404 |
||
405 |
w = r->right - r->left - (r2.right - r2.left); |
|
406 |
h = r->bottom - r->top - (r2.bottom - r2.top); |
|
407 |
if (_wnd.double_size) { |
|
408 |
w /= 2; |
|
409 |
h /= 2; |
|
410 |
} |
|
411 |
w = clamp(w, 64, MAX_SCREEN_WIDTH); |
|
412 |
h = clamp(h, 64, MAX_SCREEN_HEIGHT); |
|
413 |
if (_wnd.double_size) { |
|
414 |
w *= 2; |
|
415 |
h *= 2; |
|
416 |
} |
|
417 |
SetRect(&r2, 0, 0, w, h); |
|
418 |
||
419 |
AdjustWindowRect(&r2, GetWindowLong(hwnd, GWL_STYLE), FALSE); |
|
420 |
w = r2.right - r2.left; |
|
421 |
h = r2.bottom - r2.top; |
|
422 |
||
423 |
switch (wParam) { |
|
424 |
case WMSZ_BOTTOM: |
|
425 |
r->bottom = r->top + h; |
|
426 |
break; |
|
427 |
||
428 |
case WMSZ_BOTTOMLEFT: |
|
429 |
r->bottom = r->top + h; |
|
430 |
r->left = r->right - w; |
|
431 |
break; |
|
432 |
||
433 |
case WMSZ_BOTTOMRIGHT: |
|
434 |
r->bottom = r->top + h; |
|
435 |
r->right = r->left + w; |
|
436 |
break; |
|
437 |
||
438 |
case WMSZ_LEFT: |
|
439 |
r->left = r->right - w; |
|
440 |
break; |
|
441 |
||
442 |
case WMSZ_RIGHT: |
|
443 |
r->right = r->left + w; |
|
444 |
break; |
|
445 |
||
446 |
case WMSZ_TOP: |
|
447 |
r->top = r->bottom - h; |
|
448 |
break; |
|
449 |
||
450 |
case WMSZ_TOPLEFT: |
|
451 |
r->top = r->bottom - h; |
|
452 |
r->left = r->right - w; |
|
453 |
break; |
|
454 |
||
455 |
case WMSZ_TOPRIGHT: |
|
456 |
r->top = r->bottom - h; |
|
457 |
r->right = r->left + w; |
|
458 |
break; |
|
459 |
} |
|
460 |
return TRUE; |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
461 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
462 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
463 |
// needed for wheel |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
464 |
#if !defined(WM_MOUSEWHEEL) |
4489 | 465 |
# define WM_MOUSEWHEEL 0x020A |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
466 |
#endif //WM_MOUSEWHEEL |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
467 |
#if !defined(GET_WHEEL_DELTA_WPARAM) |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
468 |
# define GET_WHEEL_DELTA_WPARAM(wparam) ((short)HIWORD(wparam)) |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
469 |
#endif //GET_WHEEL_DELTA_WPARAM |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
470 |
|
4489 | 471 |
case WM_MOUSEWHEEL: { |
472 |
int delta = GET_WHEEL_DELTA_WPARAM(wParam); |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
473 |
|
4489 | 474 |
if (delta < 0) { |
475 |
_cursor.wheel++; |
|
476 |
} else if (delta > 0) { |
|
477 |
_cursor.wheel--; |
|
478 |
} |
|
479 |
return 0; |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
480 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
481 |
|
4489 | 482 |
case WM_ACTIVATEAPP: |
483 |
_wnd.has_focus = (bool)wParam; |
|
484 |
break; |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
485 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
486 |
return DefWindowProc(hwnd, msg, wParam, lParam); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
487 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
488 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
489 |
static void RegisterWndClass(void) |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
490 |
{ |
4489 | 491 |
static bool registered = false; |
492 |
||
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
493 |
if (!registered) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
494 |
HINSTANCE hinst = GetModuleHandle(NULL); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
495 |
WNDCLASS wnd = { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
496 |
0, |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
497 |
WndProcGdi, |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
498 |
0, |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
499 |
0, |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
500 |
hinst, |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
501 |
LoadIcon(hinst, MAKEINTRESOURCE(100)), |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
502 |
LoadCursor(NULL, IDC_ARROW), |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
503 |
0, |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
504 |
0, |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
505 |
"OTTD" |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
506 |
}; |
4489 | 507 |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
508 |
registered = true; |
4489 | 509 |
if (!RegisterClass(&wnd)) error("RegisterClass failed"); |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
510 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
511 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
512 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
513 |
static void MakeWindow(bool full_screen) |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
514 |
{ |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
515 |
_fullscreen = full_screen; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
516 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
517 |
_wnd.double_size = _double_size && !full_screen; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
518 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
519 |
// recreate window? |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
520 |
if ((full_screen || _wnd.fullscreen) && _wnd.main_wnd) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
521 |
DestroyWindow(_wnd.main_wnd); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
522 |
_wnd.main_wnd = 0; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
523 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
524 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
525 |
if (full_screen) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
526 |
DEVMODE settings; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
527 |
|
4489 | 528 |
memset(&settings, 0, sizeof(settings)); |
529 |
settings.dmSize = sizeof(settings); |
|
530 |
settings.dmFields = |
|
531 |
(_fullscreen_bpp != 0 ? DM_BITSPERPEL : 0) | |
|
532 |
DM_PELSWIDTH | |
|
533 |
DM_PELSHEIGHT | |
|
534 |
(_display_hz != 0 ? DM_DISPLAYFREQUENCY : 0); |
|
535 |
settings.dmBitsPerPel = _fullscreen_bpp; |
|
536 |
settings.dmPelsWidth = _wnd.width_org; |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
537 |
settings.dmPelsHeight = _wnd.height_org; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
538 |
settings.dmDisplayFrequency = _display_hz; |
4489 | 539 |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
540 |
if (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
541 |
MakeWindow(false); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
542 |
return; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
543 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
544 |
} else if (_wnd.fullscreen) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
545 |
// restore display? |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
546 |
ChangeDisplaySettings(NULL, 0); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
547 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
548 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
549 |
{ |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
550 |
RECT r; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
551 |
uint style; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
552 |
int x, y, w, h; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
553 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
554 |
_wnd.fullscreen = full_screen; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
555 |
if (_wnd.fullscreen) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
556 |
style = WS_POPUP | WS_VISIBLE; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
557 |
SetRect(&r, 0, 0, _wnd.width_org, _wnd.height_org); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
558 |
} else { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
559 |
style = WS_OVERLAPPEDWINDOW | WS_VISIBLE; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
560 |
SetRect(&r, 0, 0, _wnd.width, _wnd.height); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
561 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
562 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
563 |
AdjustWindowRect(&r, style, FALSE); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
564 |
w = r.right - r.left; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
565 |
h = r.bottom - r.top; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
566 |
x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
567 |
y = (GetSystemMetrics(SM_CYSCREEN) - h) / 2; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
568 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
569 |
if (_wnd.main_wnd) { |
4258
087d44b3514f
(svn r5874) -Feature [FS#234]: Remember the maximized state and restore on start. This also fixes a bug where a different resolution is chosen for a maximized window, but it retains the maximized flag. Only win32.
Darkvater
parents:
4077
diff
changeset
|
570 |
ShowWindow(_wnd.main_wnd, SW_SHOWNORMAL); // remove maximize-flag |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
571 |
SetWindowPos(_wnd.main_wnd, 0, x, y, w, h, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
572 |
} else { |
4840
a76d40e0aea4
(svn r6766) -Codechange: Move _openttd_revision[] into the functions that use it instead of global
Darkvater
parents:
4548
diff
changeset
|
573 |
extern const char _openttd_revision[]; |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
574 |
char Windowtitle[50]; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
575 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
576 |
snprintf(Windowtitle, lengthof(Windowtitle), "OpenTTD %s", _openttd_revision); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
577 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
578 |
_wnd.main_wnd = CreateWindow("OTTD", Windowtitle, style, x, y, w, h, 0, 0, GetModuleHandle(NULL), 0); |
4258
087d44b3514f
(svn r5874) -Feature [FS#234]: Remember the maximized state and restore on start. This also fixes a bug where a different resolution is chosen for a maximized window, but it retains the maximized flag. Only win32.
Darkvater
parents:
4077
diff
changeset
|
579 |
if (_wnd.main_wnd == NULL) error("CreateWindow failed"); |
087d44b3514f
(svn r5874) -Feature [FS#234]: Remember the maximized state and restore on start. This also fixes a bug where a different resolution is chosen for a maximized window, but it retains the maximized flag. Only win32.
Darkvater
parents:
4077
diff
changeset
|
580 |
|
087d44b3514f
(svn r5874) -Feature [FS#234]: Remember the maximized state and restore on start. This also fixes a bug where a different resolution is chosen for a maximized window, but it retains the maximized flag. Only win32.
Darkvater
parents:
4077
diff
changeset
|
581 |
/* On startup let's see if we quit maximized the last time, restore that */ |
087d44b3514f
(svn r5874) -Feature [FS#234]: Remember the maximized state and restore on start. This also fixes a bug where a different resolution is chosen for a maximized window, but it retains the maximized flag. Only win32.
Darkvater
parents:
4077
diff
changeset
|
582 |
if (_window_maximize) { |
087d44b3514f
(svn r5874) -Feature [FS#234]: Remember the maximized state and restore on start. This also fixes a bug where a different resolution is chosen for a maximized window, but it retains the maximized flag. Only win32.
Darkvater
parents:
4077
diff
changeset
|
583 |
ShowWindow(_wnd.main_wnd, SW_MAXIMIZE); |
087d44b3514f
(svn r5874) -Feature [FS#234]: Remember the maximized state and restore on start. This also fixes a bug where a different resolution is chosen for a maximized window, but it retains the maximized flag. Only win32.
Darkvater
parents:
4077
diff
changeset
|
584 |
_window_maximize = false; |
087d44b3514f
(svn r5874) -Feature [FS#234]: Remember the maximized state and restore on start. This also fixes a bug where a different resolution is chosen for a maximized window, but it retains the maximized flag. Only win32.
Darkvater
parents:
4077
diff
changeset
|
585 |
} |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
586 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
587 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
588 |
GameSizeChanged(); // invalidate all windows, force redraw |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
589 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
590 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
591 |
static bool AllocateDibSection(int w, int h) |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
592 |
{ |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
593 |
BITMAPINFO *bi; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
594 |
HDC dc; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
595 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
596 |
w = clamp(w, 64, MAX_SCREEN_WIDTH); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
597 |
h = clamp(h, 64, MAX_SCREEN_HEIGHT); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
598 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
599 |
if (w == _screen.width && h == _screen.height) |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
600 |
return false; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
601 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
602 |
_screen.width = w; |
2398
912f16512ce2
(svn r2924) Introduce the ALIGN() macro which aligns values to multiples of a power of 2, for exact semantics see the commment in macros.h
tron
parents:
2228
diff
changeset
|
603 |
_screen.pitch = ALIGN(w, 4); |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
604 |
_screen.height = h; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
605 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
606 |
if (_wnd.alloced_bits) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
607 |
free(_wnd.alloced_bits); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
608 |
_wnd.alloced_bits = NULL; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
609 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
610 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
611 |
bi = alloca(sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*256); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
612 |
memset(bi, 0, sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*256); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
613 |
bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
614 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
615 |
if (_wnd.double_size) { |
2398
912f16512ce2
(svn r2924) Introduce the ALIGN() macro which aligns values to multiples of a power of 2, for exact semantics see the commment in macros.h
tron
parents:
2228
diff
changeset
|
616 |
w = ALIGN(w, 4); |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
617 |
_wnd.alloced_bits = _wnd.buffer_bits = malloc(w * h); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
618 |
w *= 2; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
619 |
h *= 2; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
620 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
621 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
622 |
bi->bmiHeader.biWidth = _wnd.width = w; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
623 |
bi->bmiHeader.biHeight = -(_wnd.height = h); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
624 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
625 |
bi->bmiHeader.biPlanes = 1; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
626 |
bi->bmiHeader.biBitCount = 8; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
627 |
bi->bmiHeader.biCompression = BI_RGB; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
628 |
|
4489 | 629 |
if (_wnd.dib_sect) DeleteObject(_wnd.dib_sect); |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
630 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
631 |
dc = GetDC(0); |
4489 | 632 |
_wnd.dib_sect = CreateDIBSection(dc, bi, DIB_RGB_COLORS, (VOID**)&_wnd.bitmap_bits, NULL, 0); |
633 |
if (_wnd.dib_sect == NULL) error("CreateDIBSection failed"); |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
634 |
ReleaseDC(0, dc); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
635 |
|
4489 | 636 |
if (!_wnd.double_size) _wnd.buffer_bits = _wnd.bitmap_bits; |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
637 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
638 |
return true; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
639 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
640 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
641 |
static const uint16 default_resolutions[][2] = { |
4489 | 642 |
{ 640, 480 }, |
643 |
{ 800, 600 }, |
|
644 |
{ 1024, 768 }, |
|
645 |
{ 1152, 864 }, |
|
646 |
{ 1280, 800 }, |
|
647 |
{ 1280, 960 }, |
|
648 |
{ 1280, 1024 }, |
|
649 |
{ 1400, 1050 }, |
|
650 |
{ 1600, 1200 }, |
|
651 |
{ 1680, 1050 }, |
|
652 |
{ 1920, 1200 } |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
653 |
}; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
654 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
655 |
static void FindResolutions(void) |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
656 |
{ |
4000
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3802
diff
changeset
|
657 |
uint n = 0; |
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3802
diff
changeset
|
658 |
uint i; |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
659 |
DEVMODE dm; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
660 |
|
4000
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3802
diff
changeset
|
661 |
for (i = 0; EnumDisplaySettings(NULL, i, &dm) != 0; i++) { |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
662 |
if (dm.dmBitsPerPel == 8 && IS_INT_INSIDE(dm.dmPelsWidth, 640, MAX_SCREEN_WIDTH + 1) && |
4000
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3802
diff
changeset
|
663 |
IS_INT_INSIDE(dm.dmPelsHeight, 480, MAX_SCREEN_HEIGHT + 1)) { |
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3802
diff
changeset
|
664 |
uint j; |
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3802
diff
changeset
|
665 |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
666 |
for (j = 0; j < n; j++) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
667 |
if (_resolutions[j][0] == dm.dmPelsWidth && _resolutions[j][1] == dm.dmPelsHeight) break; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
668 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
669 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
670 |
/* In the previous loop we have checked already existing/added resolutions if |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
671 |
* they are the same as the new ones. If this is not the case (j == n); we have |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
672 |
* looped all and found none, add the new one to the list. If we have reached the |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
673 |
* maximum amount of resolutions, then quit querying the display */ |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
674 |
if (j == n) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
675 |
_resolutions[j][0] = dm.dmPelsWidth; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
676 |
_resolutions[j][1] = dm.dmPelsHeight; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
677 |
if (++n == lengthof(_resolutions)) break; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
678 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
679 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
680 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
681 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
682 |
/* We have found no resolutions, show the default list */ |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
683 |
if (n == 0) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
684 |
memcpy(_resolutions, default_resolutions, sizeof(default_resolutions)); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
685 |
n = lengthof(default_resolutions); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
686 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
687 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
688 |
_num_resolutions = n; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
689 |
SortResolutions(_num_resolutions); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
690 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
691 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
692 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
693 |
static const char *Win32GdiStart(const char * const *parm) |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
694 |
{ |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
695 |
memset(&_wnd, 0, sizeof(_wnd)); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
696 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
697 |
RegisterWndClass(); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
698 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
699 |
MakePalette(); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
700 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
701 |
FindResolutions(); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
702 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
703 |
// fullscreen uses those |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
704 |
_wnd.width_org = _cur_resolution[0]; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
705 |
_wnd.height_org = _cur_resolution[1]; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
706 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
707 |
AllocateDibSection(_cur_resolution[0], _cur_resolution[1]); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
708 |
MarkWholeScreenDirty(); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
709 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
710 |
MakeWindow(_fullscreen); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
711 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
712 |
return NULL; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
713 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
714 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
715 |
static void Win32GdiStop(void) |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
716 |
{ |
3285
50f77357b94a
(svn r3999) - Fix: [win32] Change the order of DestroyWindow and ChangeDisplay. On some machines a sizechange messagequeue is handled before sending WM_DISPLAYCHANGE resulting in an improper resolution written to the configuration file when exiting from fullscreen. (Frostregen)
Darkvater
parents:
3051
diff
changeset
|
717 |
DeleteObject(_wnd.gdi_palette); |
50f77357b94a
(svn r3999) - Fix: [win32] Change the order of DestroyWindow and ChangeDisplay. On some machines a sizechange messagequeue is handled before sending WM_DISPLAYCHANGE resulting in an improper resolution written to the configuration file when exiting from fullscreen. (Frostregen)
Darkvater
parents:
3051
diff
changeset
|
718 |
DeleteObject(_wnd.dib_sect); |
50f77357b94a
(svn r3999) - Fix: [win32] Change the order of DestroyWindow and ChangeDisplay. On some machines a sizechange messagequeue is handled before sending WM_DISPLAYCHANGE resulting in an improper resolution written to the configuration file when exiting from fullscreen. (Frostregen)
Darkvater
parents:
3051
diff
changeset
|
719 |
DestroyWindow(_wnd.main_wnd); |
50f77357b94a
(svn r3999) - Fix: [win32] Change the order of DestroyWindow and ChangeDisplay. On some machines a sizechange messagequeue is handled before sending WM_DISPLAYCHANGE resulting in an improper resolution written to the configuration file when exiting from fullscreen. (Frostregen)
Darkvater
parents:
3051
diff
changeset
|
720 |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
721 |
if (_wnd.fullscreen) ChangeDisplaySettings(NULL, 0); |
2773
121bea441d07
(svn r3320) - Fix: FS#22 - Exiting with double size enabled saves wrong window size. Reset the window size to its true size upon exiting when double-size is active. Is set in ClientSizeChanged.
Darkvater
parents:
2665
diff
changeset
|
722 |
if (_double_size) { |
121bea441d07
(svn r3320) - Fix: FS#22 - Exiting with double size enabled saves wrong window size. Reset the window size to its true size upon exiting when double-size is active. Is set in ClientSizeChanged.
Darkvater
parents:
2665
diff
changeset
|
723 |
_cur_resolution[0] *= 2; |
121bea441d07
(svn r3320) - Fix: FS#22 - Exiting with double size enabled saves wrong window size. Reset the window size to its true size upon exiting when double-size is active. Is set in ClientSizeChanged.
Darkvater
parents:
2665
diff
changeset
|
724 |
_cur_resolution[1] *= 2; |
121bea441d07
(svn r3320) - Fix: FS#22 - Exiting with double size enabled saves wrong window size. Reset the window size to its true size upon exiting when double-size is active. Is set in ClientSizeChanged.
Darkvater
parents:
2665
diff
changeset
|
725 |
} |
121bea441d07
(svn r3320) - Fix: FS#22 - Exiting with double size enabled saves wrong window size. Reset the window size to its true size upon exiting when double-size is active. Is set in ClientSizeChanged.
Darkvater
parents:
2665
diff
changeset
|
726 |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
727 |
MyShowCursor(true); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
728 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
729 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
730 |
// simple upscaler by 2 |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
731 |
static void filter(int left, int top, int width, int height) |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
732 |
{ |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
733 |
uint p = _screen.pitch; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
734 |
const Pixel *s = _wnd.buffer_bits + top * p + left; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
735 |
Pixel *d = _wnd.bitmap_bits + top * p * 4 + left * 2; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
736 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
737 |
for (; height > 0; height--) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
738 |
int i; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
739 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
740 |
for (i = 0; i != width; i++) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
741 |
d[i * 2] = d[i * 2 + 1] = d[i * 2 + p * 2] = d[i * 2 + 1 + p * 2] = s[i]; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
742 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
743 |
s += p; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
744 |
d += p * 4; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
745 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
746 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
747 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
748 |
static void Win32GdiMakeDirty(int left, int top, int width, int height) |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
749 |
{ |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
750 |
RECT r = { left, top, left + width, top + height }; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
751 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
752 |
if (_wnd.double_size) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
753 |
filter(left, top, width, height); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
754 |
r.left *= 2; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
755 |
r.top *= 2; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
756 |
r.right *= 2; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
757 |
r.bottom *= 2; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
758 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
759 |
InvalidateRect(_wnd.main_wnd, &r, FALSE); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
760 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
761 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
762 |
static void CheckPaletteAnim(void) |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
763 |
{ |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
764 |
if (_pal_last_dirty == -1) |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
765 |
return; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
766 |
InvalidateRect(_wnd.main_wnd, NULL, FALSE); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
767 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
768 |
|
2228 | 769 |
static void Win32GdiMainLoop(void) |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
770 |
{ |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
771 |
MSG mesg; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
772 |
uint32 next_tick = GetTickCount() + 30, cur_ticks; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
773 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
774 |
_wnd.running = true; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
775 |
|
2952 | 776 |
for (;;) { |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
777 |
while (PeekMessage(&mesg, NULL, 0, 0, PM_REMOVE)) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
778 |
InteractiveRandom(); // randomness |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
779 |
TranslateMessage(&mesg); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
780 |
DispatchMessage(&mesg); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
781 |
} |
2228 | 782 |
if (_exit_game) return; |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
783 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
784 |
#if defined(_DEBUG) |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
785 |
if (_wnd.has_focus && GetAsyncKeyState(VK_SHIFT) < 0) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
786 |
if ( |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
787 |
#else |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
788 |
if (_wnd.has_focus && GetAsyncKeyState(VK_TAB) < 0) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
789 |
/* Disable speeding up game with ALT+TAB (if syskey is pressed, the |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
790 |
* real key is in the upper 16 bits (see WM_SYSKEYDOWN in WndProcGdi()) */ |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
791 |
if ((_pressed_key >> 16) & WKC_TAB && |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
792 |
#endif |
4536
d532b2611952
(svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents:
4489
diff
changeset
|
793 |
!_networking && _game_mode != GM_MENU) |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
794 |
_fast_forward |= 2; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4000
diff
changeset
|
795 |
} else if (_fast_forward & 2) { |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
796 |
_fast_forward = 0; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4000
diff
changeset
|
797 |
} |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
798 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
799 |
cur_ticks = GetTickCount(); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
800 |
if ((_fast_forward && !_pause) || cur_ticks > next_tick) |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
801 |
next_tick = cur_ticks; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
802 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
803 |
if (cur_ticks == next_tick) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
804 |
next_tick += 30; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
805 |
_ctrl_pressed = _wnd.has_focus && GetAsyncKeyState(VK_CONTROL)<0; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
806 |
_shift_pressed = _wnd.has_focus && GetAsyncKeyState(VK_SHIFT)<0; |
2664
875d6800baaf
(svn r3206) Wrap all instances of _dbg_screen_rect in #ifdef _DEBUG
tron
parents:
2398
diff
changeset
|
807 |
#ifdef _DEBUG |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
808 |
_dbg_screen_rect = _wnd.has_focus && GetAsyncKeyState(VK_CAPITAL)<0; |
2665 | 809 |
#endif |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
810 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
811 |
// determine which directional keys are down |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
812 |
if (_wnd.has_focus) { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
813 |
_dirkeys = |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
814 |
(GetAsyncKeyState(VK_LEFT) < 0 ? 1 : 0) + |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
815 |
(GetAsyncKeyState(VK_UP) < 0 ? 2 : 0) + |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
816 |
(GetAsyncKeyState(VK_RIGHT) < 0 ? 4 : 0) + |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
817 |
(GetAsyncKeyState(VK_DOWN) < 0 ? 8 : 0); |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4000
diff
changeset
|
818 |
} else { |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
819 |
_dirkeys = 0; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4000
diff
changeset
|
820 |
} |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
821 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
822 |
GameLoop(); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
823 |
_cursor.delta.x = _cursor.delta.y = 0; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
824 |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4000
diff
changeset
|
825 |
if (_force_full_redraw) MarkWholeScreenDirty(); |
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
826 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
827 |
GdiFlush(); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
828 |
_screen.dst_ptr = _wnd.buffer_bits; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
829 |
UpdateWindows(); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
830 |
CheckPaletteAnim(); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
831 |
} else { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
832 |
Sleep(1); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
833 |
GdiFlush(); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
834 |
_screen.dst_ptr = _wnd.buffer_bits; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
835 |
DrawTextMessage(); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
836 |
DrawMouseCursor(); |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
837 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
838 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
839 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
840 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
841 |
static bool Win32GdiChangeRes(int w, int h) |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
842 |
{ |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
843 |
_wnd.width = _wnd.width_org = w; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
844 |
_wnd.height = _wnd.height_org = h; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
845 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
846 |
MakeWindow(_fullscreen); // _wnd.fullscreen screws up ingame resolution switching |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
847 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
848 |
return true; |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
849 |
} |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
850 |
|
4489 | 851 |
static void Win32GdiFullScreen(bool full_screen) |
852 |
{ |
|
853 |
MakeWindow(full_screen); |
|
854 |
} |
|
2174
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
855 |
|
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
856 |
const HalVideoDriver _win32_video_driver = { |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
857 |
Win32GdiStart, |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
858 |
Win32GdiStop, |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
859 |
Win32GdiMakeDirty, |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
860 |
Win32GdiMainLoop, |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
861 |
Win32GdiChangeRes, |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
862 |
Win32GdiFullScreen, |
24d868f1c576
(svn r2688) MSVC and Watcom can't handle identical file names in different directories, oh my...
tron
parents:
diff
changeset
|
863 |
}; |