author | tron |
Tue, 25 Oct 2005 18:29:32 +0000 | |
changeset 2554 | cd74b7099965 |
parent 2398 | 70de6626d65f |
child 2664 | fcefd29dd9d2 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
2189
d240b9097139
(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" |
d240b9097139
(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" |
d240b9097139
(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" |
d240b9097139
(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" |
d240b9097139
(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" |
d240b9097139
(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" |
d240b9097139
(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
40c928fbde8a
(svn r2725) Move MyShowCursor() back into win32.c, it fits better there
tron
parents:
2189
diff
changeset
|
10 |
#include "../win32.h" |
2189
d240b9097139
(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" |
d240b9097139
(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" |
2171
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
2163
diff
changeset
|
13 |
#include <windows.h> |
0 | 14 |
|
15 |
static struct { |
|
16 |
HWND main_wnd; |
|
17 |
HBITMAP dib_sect; |
|
2062 | 18 |
Pixel *bitmap_bits; |
19 |
Pixel *buffer_bits; |
|
20 |
Pixel *alloced_bits; |
|
0 | 21 |
HPALETTE gdi_palette; |
22 |
int width,height; |
|
23 |
int width_org, height_org; |
|
24 |
bool fullscreen; |
|
25 |
bool double_size; |
|
26 |
bool has_focus; |
|
27 |
bool running; |
|
28 |
} _wnd; |
|
29 |
||
1102
316643e34104
(svn r1603) -Fix: unused variable in FormatTinyDate
darkvater
parents:
1040
diff
changeset
|
30 |
static void MakePalette(void) |
0 | 31 |
{ |
32 |
LOGPALETTE *pal; |
|
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
33 |
uint i; |
0 | 34 |
|
35 |
pal = alloca(sizeof(LOGPALETTE) + (256-1) * sizeof(PALETTEENTRY)); |
|
36 |
||
37 |
pal->palVersion = 0x300; |
|
38 |
pal->palNumEntries = 256; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
39 |
|
1991
f3d5e35731a2
(svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents:
1957
diff
changeset
|
40 |
for (i = 0; i != 256; i++) { |
f3d5e35731a2
(svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents:
1957
diff
changeset
|
41 |
pal->palPalEntry[i].peRed = _cur_palette[i].r; |
f3d5e35731a2
(svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents:
1957
diff
changeset
|
42 |
pal->palPalEntry[i].peGreen = _cur_palette[i].g; |
f3d5e35731a2
(svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents:
1957
diff
changeset
|
43 |
pal->palPalEntry[i].peBlue = _cur_palette[i].b; |
0 | 44 |
pal->palPalEntry[i].peFlags = 0; |
45 |
||
46 |
} |
|
47 |
_wnd.gdi_palette = CreatePalette(pal); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
48 |
if (_wnd.gdi_palette == NULL) |
0 | 49 |
error("CreatePalette failed!\n"); |
50 |
} |
|
51 |
||
52 |
static void UpdatePalette(HDC dc, uint start, uint count) |
|
53 |
{ |
|
54 |
RGBQUAD rgb[256]; |
|
55 |
uint i; |
|
56 |
||
1995
6dacb8a758a3
(svn r2501) Forgot to change part of the win32 code in r2497
tron
parents:
1991
diff
changeset
|
57 |
for (i = 0; i != count; i++) { |
6dacb8a758a3
(svn r2501) Forgot to change part of the win32 code in r2497
tron
parents:
1991
diff
changeset
|
58 |
rgb[i].rgbRed = _cur_palette[start + i].r; |
6dacb8a758a3
(svn r2501) Forgot to change part of the win32 code in r2497
tron
parents:
1991
diff
changeset
|
59 |
rgb[i].rgbGreen = _cur_palette[start + i].g; |
6dacb8a758a3
(svn r2501) Forgot to change part of the win32 code in r2497
tron
parents:
1991
diff
changeset
|
60 |
rgb[i].rgbBlue = _cur_palette[start + i].b; |
0 | 61 |
rgb[i].rgbReserved = 0; |
62 |
} |
|
63 |
||
64 |
SetDIBColorTable(dc, start, count, rgb); |
|
65 |
} |
|
66 |
||
67 |
typedef struct { |
|
68 |
byte vk_from; |
|
69 |
byte vk_count; |
|
70 |
byte map_to; |
|
71 |
} VkMapping; |
|
72 |
||
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
73 |
#define AS(x, z) {x, 0, z} |
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
74 |
#define AM(x, y, z, w) {x, y - x, z} |
0 | 75 |
|
2026 | 76 |
#ifndef VK_OEM_3 |
153
3dbe2cfd7b3c
(svn r154) -Fix: some people while using MSVC don't have VK_OEM_3 defined? Or it could be Win2000/XP only
darkvater
parents:
151
diff
changeset
|
77 |
#define VK_OEM_3 0xC0 |
3dbe2cfd7b3c
(svn r154) -Fix: some people while using MSVC don't have VK_OEM_3 defined? Or it could be Win2000/XP only
darkvater
parents:
151
diff
changeset
|
78 |
#endif |
3dbe2cfd7b3c
(svn r154) -Fix: some people while using MSVC don't have VK_OEM_3 defined? Or it could be Win2000/XP only
darkvater
parents:
151
diff
changeset
|
79 |
|
0 | 80 |
static const VkMapping _vk_mapping[] = { |
81 |
// Pageup stuff + up/down |
|
82 |
AM(VK_PRIOR,VK_DOWN, WKC_PAGEUP, WKC_DOWN), |
|
83 |
// Map letters & digits |
|
84 |
AM('A','Z','A','Z'), |
|
85 |
AM('0','9','0','9'), |
|
86 |
||
87 |
AS(VK_ESCAPE, WKC_ESC), |
|
424
4c7808af7526
(svn r623) -Feature: [ 1066504 ] Pause key pauses the game
tron
parents:
394
diff
changeset
|
88 |
AS(VK_PAUSE, WKC_PAUSE), |
0 | 89 |
AS(VK_BACK, WKC_BACKSPACE), |
90 |
AM(VK_INSERT,VK_DELETE,WKC_INSERT, WKC_DELETE), |
|
91 |
||
92 |
AS(VK_SPACE, WKC_SPACE), |
|
93 |
AS(VK_RETURN, WKC_RETURN), |
|
94 |
AS(VK_TAB, WKC_TAB), |
|
95 |
||
96 |
// Function keys |
|
97 |
AM(VK_F1, VK_F12, WKC_F1, WKC_F12), |
|
98 |
||
99 |
// Numeric part. |
|
100 |
// What is the virtual keycode for numeric enter?? |
|
101 |
AM(VK_NUMPAD0,VK_NUMPAD9, WKC_NUM_0, WKC_NUM_9), |
|
102 |
AS(VK_DIVIDE, WKC_NUM_DIV), |
|
103 |
AS(VK_MULTIPLY, WKC_NUM_MUL), |
|
104 |
AS(VK_SUBTRACT, WKC_NUM_MINUS), |
|
105 |
AS(VK_ADD, WKC_NUM_PLUS), |
|
1466 | 106 |
AS(VK_DECIMAL, WKC_NUM_DECIMAL) |
0 | 107 |
}; |
108 |
||
1466 | 109 |
static uint MapWindowsKey(uint sym) |
0 | 110 |
{ |
1466 | 111 |
const VkMapping *map; |
112 |
uint key = 0; |
|
0 | 113 |
|
1466 | 114 |
for (map = _vk_mapping; map != endof(_vk_mapping); ++map) { |
115 |
if ((uint)(sym - map->vk_from) <= map->vk_count) { |
|
116 |
key = sym - map->vk_from + map->map_to; |
|
117 |
break; |
|
118 |
} |
|
119 |
} |
|
135
638fb31434eb
(svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents:
49
diff
changeset
|
120 |
|
2026 | 121 |
if (GetAsyncKeyState(VK_SHIFT) < 0) key |= WKC_SHIFT; |
122 |
if (GetAsyncKeyState(VK_CONTROL) < 0) key |= WKC_CTRL; |
|
123 |
if (GetAsyncKeyState(VK_MENU) < 0) key |= WKC_ALT; |
|
0 | 124 |
return key; |
125 |
} |
|
126 |
||
127 |
static void MakeWindow(bool full_screen); |
|
128 |
static bool AllocateDibSection(int w, int h); |
|
129 |
||
130 |
static void ClientSizeChanged(int w, int h) |
|
131 |
{ |
|
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
132 |
if (_wnd.double_size) { |
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
133 |
w /= 2; |
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
134 |
h /= 2; |
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
135 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
136 |
|
0 | 137 |
// allocate new dib section of the new size |
138 |
if (AllocateDibSection(w, h)) { |
|
139 |
// mark all palette colors dirty |
|
140 |
_pal_first_dirty = 0; |
|
141 |
_pal_last_dirty = 255; |
|
142 |
GameSizeChanged(); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
143 |
|
0 | 144 |
// redraw screen |
145 |
if (_wnd.running) { |
|
146 |
_screen.dst_ptr = _wnd.buffer_bits; |
|
147 |
UpdateWindows(); |
|
148 |
} |
|
149 |
} |
|
150 |
} |
|
151 |
||
1881
023a134a4b12
(svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents:
1829
diff
changeset
|
152 |
extern void DoExitSave(void); |
643
6f04156241bd
(svn r1076) Feature: Patch setting to autosave the game on exit
dominik
parents:
543
diff
changeset
|
153 |
|
2125
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
154 |
#ifdef _DEBUG |
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
155 |
// Keep this function here.. |
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
156 |
// It allows you to redraw the screen from within the MSVC debugger |
2171
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
2163
diff
changeset
|
157 |
int RedrawScreenDebug(void) |
2125
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
158 |
{ |
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
159 |
HDC dc,dc2; |
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
160 |
static int _fooctr; |
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
161 |
HBITMAP old_bmp; |
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
162 |
HPALETTE old_palette; |
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
163 |
|
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
164 |
_screen.dst_ptr = _wnd.buffer_bits; |
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
165 |
UpdateWindows(); |
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
166 |
|
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
167 |
dc = GetDC(_wnd.main_wnd); |
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
168 |
dc2 = CreateCompatibleDC(dc); |
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
169 |
|
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
170 |
old_bmp = SelectObject(dc2, _wnd.dib_sect); |
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
171 |
old_palette = SelectPalette(dc, _wnd.gdi_palette, FALSE); |
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
172 |
BitBlt(dc, 0, 0, _wnd.width, _wnd.height, dc2, 0, 0, SRCCOPY); |
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
173 |
SelectPalette(dc, old_palette, TRUE); |
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
174 |
SelectObject(dc2, old_bmp); |
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
175 |
DeleteDC(dc2); |
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
176 |
ReleaseDC(_wnd.main_wnd, dc); |
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
177 |
|
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
178 |
return _fooctr++; |
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
179 |
} |
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
180 |
#endif |
3098398bf7ff
(svn r2635) Fix: [ntp/misc] Improve the old pathfinder. Changed it to A* instead of Dijkstra.
ludde
parents:
2099
diff
changeset
|
181 |
|
0 | 182 |
static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) |
183 |
{ |
|
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
184 |
switch (msg) { |
0 | 185 |
case WM_PAINT: { |
186 |
PAINTSTRUCT ps; |
|
187 |
HDC dc,dc2; |
|
188 |
HBITMAP old_bmp; |
|
189 |
HPALETTE old_palette; |
|
190 |
BeginPaint(hwnd, &ps); |
|
191 |
dc = ps.hdc; |
|
192 |
dc2 = CreateCompatibleDC(dc); |
|
193 |
old_bmp = SelectObject(dc2, _wnd.dib_sect); |
|
194 |
old_palette = SelectPalette(dc, _wnd.gdi_palette, FALSE); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
195 |
|
0 | 196 |
if (_pal_last_dirty != -1) { |
197 |
UpdatePalette(dc2, _pal_first_dirty, _pal_last_dirty - _pal_first_dirty + 1); |
|
198 |
_pal_last_dirty = -1; |
|
199 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
200 |
|
0 | 201 |
BitBlt(dc, 0, 0, _wnd.width, _wnd.height, dc2, 0, 0, SRCCOPY); |
202 |
SelectPalette(dc, old_palette, TRUE); |
|
203 |
SelectObject(dc2, old_bmp); |
|
204 |
DeleteDC(dc2); |
|
205 |
EndPaint(hwnd, &ps); |
|
206 |
} |
|
207 |
return 0; |
|
208 |
||
209 |
case WM_PALETTECHANGED: |
|
210 |
if ((HWND)wParam == hwnd) |
|
211 |
return 0; |
|
212 |
// FALL THROUGH |
|
213 |
case WM_QUERYNEWPALETTE: { |
|
214 |
HDC hDC = GetWindowDC(hwnd); |
|
215 |
HPALETTE hOldPalette = SelectPalette(hDC, _wnd.gdi_palette, FALSE); |
|
216 |
UINT nChanged = RealizePalette(hDC); |
|
217 |
SelectPalette(hDC, hOldPalette, TRUE); |
|
218 |
ReleaseDC(hwnd, hDC); |
|
219 |
if (nChanged) |
|
220 |
InvalidateRect(hwnd, NULL, FALSE); |
|
221 |
return 0; |
|
222 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
223 |
|
0 | 224 |
case WM_CLOSE: |
646
2e8a3763ebe5
(svn r1079) -Fix: you can once again quit the game in windows by pressing ALT+F4 or the 'exit' button in the main menu.
darkvater
parents:
643
diff
changeset
|
225 |
if (_game_mode == GM_MENU) { // do not ask to quit on the main screen |
2e8a3763ebe5
(svn r1079) -Fix: you can once again quit the game in windows by pressing ALT+F4 or the 'exit' button in the main menu.
darkvater
parents:
643
diff
changeset
|
226 |
_exit_game = true; |
2e8a3763ebe5
(svn r1079) -Fix: you can once again quit the game in windows by pressing ALT+F4 or the 'exit' button in the main menu.
darkvater
parents:
643
diff
changeset
|
227 |
} else if (_patches.autosave_on_exit) { |
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
228 |
DoExitSave(); |
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
229 |
_exit_game = true; |
643
6f04156241bd
(svn r1076) Feature: Patch setting to autosave the game on exit
dominik
parents:
543
diff
changeset
|
230 |
} else |
646
2e8a3763ebe5
(svn r1079) -Fix: you can once again quit the game in windows by pressing ALT+F4 or the 'exit' button in the main menu.
darkvater
parents:
643
diff
changeset
|
231 |
AskExitGame(); |
2e8a3763ebe5
(svn r1079) -Fix: you can once again quit the game in windows by pressing ALT+F4 or the 'exit' button in the main menu.
darkvater
parents:
643
diff
changeset
|
232 |
|
0 | 233 |
return 0; |
234 |
||
235 |
case WM_LBUTTONDOWN: |
|
236 |
SetCapture(hwnd); |
|
237 |
_left_button_down = true; |
|
238 |
return 0; |
|
239 |
||
240 |
case WM_LBUTTONUP: |
|
241 |
ReleaseCapture(); |
|
242 |
_left_button_down = false; |
|
243 |
_left_button_clicked = false; |
|
244 |
return 0; |
|
245 |
||
246 |
case WM_RBUTTONDOWN: |
|
247 |
SetCapture(hwnd); |
|
248 |
_right_button_down = true; |
|
249 |
_right_button_clicked = true; |
|
250 |
return 0; |
|
251 |
||
252 |
case WM_RBUTTONUP: |
|
253 |
ReleaseCapture(); |
|
254 |
_right_button_down = false; |
|
255 |
return 0; |
|
256 |
||
257 |
case WM_MOUSEMOVE: { |
|
258 |
int x = (int16)LOWORD(lParam); |
|
259 |
int y = (int16)HIWORD(lParam); |
|
260 |
POINT pt; |
|
261 |
||
262 |
if (_wnd.double_size) { |
|
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
263 |
x /= 2; |
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
264 |
y /= 2; |
0 | 265 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
266 |
|
0 | 267 |
if (_cursor.fix_at) { |
268 |
int dx = x - _cursor.pos.x; |
|
269 |
int dy = y - _cursor.pos.y; |
|
270 |
if (dx != 0 || dy != 0) { |
|
271 |
_cursor.delta.x += dx; |
|
272 |
_cursor.delta.y += dy; |
|
273 |
||
274 |
pt.x = _cursor.pos.x; |
|
275 |
pt.y = _cursor.pos.y; |
|
276 |
||
277 |
if (_wnd.double_size) { |
|
278 |
pt.x *= 2; |
|
279 |
pt.y *= 2; |
|
280 |
} |
|
281 |
ClientToScreen(hwnd, &pt); |
|
282 |
SetCursorPos(pt.x, pt.y); |
|
283 |
} |
|
284 |
} else { |
|
285 |
_cursor.delta.x += x - _cursor.pos.x; |
|
286 |
_cursor.delta.y += y - _cursor.pos.y; |
|
287 |
_cursor.pos.x = x; |
|
288 |
_cursor.pos.y = y; |
|
289 |
_cursor.dirty = true; |
|
290 |
} |
|
291 |
MyShowCursor(false); |
|
292 |
return 0; |
|
293 |
} |
|
294 |
||
394
70651c0838a3
(svn r586) -Fix: [1066114] Code error in win32.c Thanks Shai
darkvater
parents:
318
diff
changeset
|
295 |
case WM_KEYDOWN: { |
135
638fb31434eb
(svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents:
49
diff
changeset
|
296 |
// this is the rewritten ascii input function |
638fb31434eb
(svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents:
49
diff
changeset
|
297 |
// it disables windows deadkey handling --> more linux like :D |
1582
5ac8f9425c09
(svn r2086) - Codechange: Two indentation fixes coming from Loic Guilloux' patch 1171208.
pasky
parents:
1580
diff
changeset
|
298 |
unsigned short w = 0; |
135
638fb31434eb
(svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents:
49
diff
changeset
|
299 |
int r = 0; |
638fb31434eb
(svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents:
49
diff
changeset
|
300 |
byte ks[256]; |
394
70651c0838a3
(svn r586) -Fix: [1066114] Code error in win32.c Thanks Shai
darkvater
parents:
318
diff
changeset
|
301 |
unsigned int scan = 0; |
719
14d8c2d40bb8
(svn r1171) Fix: Console hotkey works again on keyboards where this key is a deadkey.
dominik
parents:
704
diff
changeset
|
302 |
uint16 scancode = (( lParam & 0xFF0000 ) >> 16 ); |
14d8c2d40bb8
(svn r1171) Fix: Console hotkey works again on keyboards where this key is a deadkey.
dominik
parents:
704
diff
changeset
|
303 |
|
135
638fb31434eb
(svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents:
49
diff
changeset
|
304 |
GetKeyboardState(ks); |
394
70651c0838a3
(svn r586) -Fix: [1066114] Code error in win32.c Thanks Shai
darkvater
parents:
318
diff
changeset
|
305 |
r = ToAscii(wParam, scan, ks, &w, 0); |
70651c0838a3
(svn r586) -Fix: [1066114] Code error in win32.c Thanks Shai
darkvater
parents:
318
diff
changeset
|
306 |
if (r == 0) w = 0; // no translation was possible |
135
638fb31434eb
(svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents:
49
diff
changeset
|
307 |
|
638fb31434eb
(svn r136) -Feature/Fix: Console Rev #2 and WKC_BACKQUOTE this patch adds new features to the ingame console and inserts a new keymanagement for windows pcs... (sign_de)
darkvater
parents:
49
diff
changeset
|
308 |
_pressed_key = w | MapWindowsKey(wParam) << 16; |
394
70651c0838a3
(svn r586) -Fix: [1066114] Code error in win32.c Thanks Shai
darkvater
parents:
318
diff
changeset
|
309 |
|
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
310 |
if (scancode == 41) |
719
14d8c2d40bb8
(svn r1171) Fix: Console hotkey works again on keyboards where this key is a deadkey.
dominik
parents:
704
diff
changeset
|
311 |
_pressed_key = w | WKC_BACKQUOTE << 16; |
14d8c2d40bb8
(svn r1171) Fix: Console hotkey works again on keyboards where this key is a deadkey.
dominik
parents:
704
diff
changeset
|
312 |
|
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
313 |
if ((_pressed_key >> 16) == ('D' | WKC_CTRL) && !_wnd.fullscreen) { |
0 | 314 |
_double_size ^= 1; |
315 |
_wnd.double_size = _double_size; |
|
316 |
ClientSizeChanged(_wnd.width, _wnd.height); |
|
317 |
MarkWholeScreenDirty(); |
|
318 |
} |
|
2026 | 319 |
} break; |
0 | 320 |
|
198
0f3481fa50e1
(svn r199) -Fix: [993374] Pressing alt locks the game - sort of a bug. I hope I didn't break anything :O
darkvater
parents:
196
diff
changeset
|
321 |
case WM_SYSKEYDOWN: /* user presses F10 or Alt, both activating the title-menu */ |
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
322 |
switch (wParam) { |
1806
75dc9c737892
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1686
diff
changeset
|
323 |
case VK_RETURN: case 0x46: /* Full Screen on ALT + ENTER/F(VK_F) */ |
75dc9c737892
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1686
diff
changeset
|
324 |
ToggleFullScreen(!_wnd.fullscreen); |
0 | 325 |
return 0; |
199
10f6a586bfa6
(svn r200) -Fix: oops, ALT+F4 didn't work anymore. Fixed now.
darkvater
parents:
198
diff
changeset
|
326 |
case VK_MENU: /* Just ALT */ |
10f6a586bfa6
(svn r200) -Fix: oops, ALT+F4 didn't work anymore. Fixed now.
darkvater
parents:
198
diff
changeset
|
327 |
return 0; // do nothing |
1548
a69e1b3b7774
(svn r2052) - Fix Regression: ALT+F4 once again shuts down openttd in windows and F10, etc. is fixed.
darkvater
parents:
1508
diff
changeset
|
328 |
case VK_F10: /* F10, ignore activation of menu */ |
a69e1b3b7774
(svn r2052) - Fix Regression: ALT+F4 once again shuts down openttd in windows and F10, etc. is fixed.
darkvater
parents:
1508
diff
changeset
|
329 |
_pressed_key = MapWindowsKey(wParam) << 16; |
a69e1b3b7774
(svn r2052) - Fix Regression: ALT+F4 once again shuts down openttd in windows and F10, etc. is fixed.
darkvater
parents:
1508
diff
changeset
|
330 |
return 0; |
199
10f6a586bfa6
(svn r200) -Fix: oops, ALT+F4 didn't work anymore. Fixed now.
darkvater
parents:
198
diff
changeset
|
331 |
default: /* ALT in combination with something else */ |
0 | 332 |
_pressed_key = MapWindowsKey(wParam) << 16; |
1548
a69e1b3b7774
(svn r2052) - Fix Regression: ALT+F4 once again shuts down openttd in windows and F10, etc. is fixed.
darkvater
parents:
1508
diff
changeset
|
333 |
break; |
0 | 334 |
} |
335 |
break; |
|
336 |
case WM_NCMOUSEMOVE: |
|
337 |
MyShowCursor(true); |
|
338 |
return 0; |
|
339 |
||
340 |
case WM_SIZE: { |
|
341 |
if (wParam != SIZE_MINIMIZED) { |
|
342 |
ClientSizeChanged(LOWORD(lParam), HIWORD(lParam)); |
|
343 |
} |
|
344 |
return 0; |
|
345 |
} |
|
346 |
case WM_SIZING: { |
|
347 |
RECT* r = (RECT*)lParam; |
|
348 |
RECT r2; |
|
349 |
int w, h; |
|
350 |
||
351 |
SetRect(&r2, 0, 0, 0, 0); |
|
352 |
AdjustWindowRect(&r2, GetWindowLong(hwnd, GWL_STYLE), FALSE); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
353 |
|
0 | 354 |
w = r->right - r->left - (r2.right - r2.left); |
355 |
h = r->bottom - r->top - (r2.bottom - r2.top); |
|
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
356 |
if (_wnd.double_size) { |
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
357 |
w /= 2; |
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
358 |
h /= 2; |
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
359 |
} |
306
c44133836566
(svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents:
298
diff
changeset
|
360 |
w = clamp(w, 64, MAX_SCREEN_WIDTH); |
c44133836566
(svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents:
298
diff
changeset
|
361 |
h = clamp(h, 64, MAX_SCREEN_HEIGHT); |
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
362 |
if (_wnd.double_size) { |
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
363 |
w *= 2; |
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
364 |
h *= 2; |
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
365 |
} |
0 | 366 |
SetRect(&r2, 0, 0, w, h); |
367 |
||
368 |
AdjustWindowRect(&r2, GetWindowLong(hwnd, GWL_STYLE), FALSE); |
|
369 |
w = r2.right - r2.left; |
|
370 |
h = r2.bottom - r2.top; |
|
371 |
||
372 |
switch (wParam) { |
|
373 |
case WMSZ_BOTTOM: |
|
374 |
r->bottom = r->top + h; |
|
375 |
break; |
|
376 |
case WMSZ_BOTTOMLEFT: |
|
377 |
r->bottom = r->top + h; |
|
378 |
r->left = r->right - w; |
|
379 |
break; |
|
380 |
case WMSZ_BOTTOMRIGHT: |
|
381 |
r->bottom = r->top + h; |
|
382 |
r->right = r->left + w; |
|
383 |
break; |
|
384 |
case WMSZ_LEFT: |
|
385 |
r->left = r->right - w; |
|
386 |
break; |
|
387 |
case WMSZ_RIGHT: |
|
388 |
r->right = r->left + w; |
|
389 |
break; |
|
390 |
case WMSZ_TOP: |
|
391 |
r->top = r->bottom - h; |
|
392 |
break; |
|
393 |
case WMSZ_TOPLEFT: |
|
394 |
r->top = r->bottom - h; |
|
395 |
r->left = r->right - w; |
|
396 |
break; |
|
397 |
case WMSZ_TOPRIGHT: |
|
398 |
r->top = r->bottom - h; |
|
399 |
r->right = r->left + w; |
|
400 |
break; |
|
401 |
} |
|
402 |
return TRUE; |
|
403 |
} |
|
404 |
||
405 |
// needed for wheel |
|
406 |
#if !defined(WM_MOUSEWHEEL) |
|
407 |
# define WM_MOUSEWHEEL 0x020A |
|
408 |
#endif //WM_MOUSEWHEEL |
|
409 |
#if !defined(GET_WHEEL_DELTA_WPARAM) |
|
410 |
# define GET_WHEEL_DELTA_WPARAM(wparam) ((short)HIWORD(wparam)) |
|
411 |
#endif //GET_WHEEL_DELTA_WPARAM |
|
412 |
||
413 |
case WM_MOUSEWHEEL: { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
414 |
int delta = GET_WHEEL_DELTA_WPARAM(wParam); |
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
415 |
|
0 | 416 |
if (delta < 0) { |
417 |
_cursor.wheel++; |
|
418 |
} else if (delta > 0) { |
|
419 |
_cursor.wheel--; |
|
420 |
} |
|
421 |
return 0; |
|
422 |
} |
|
423 |
||
424 |
case WM_ACTIVATEAPP: |
|
425 |
_wnd.has_focus = (bool)wParam; |
|
426 |
break; |
|
427 |
} |
|
428 |
return DefWindowProc(hwnd, msg, wParam, lParam); |
|
429 |
} |
|
430 |
||
1102
316643e34104
(svn r1603) -Fix: unused variable in FormatTinyDate
darkvater
parents:
1040
diff
changeset
|
431 |
static void RegisterWndClass(void) |
0 | 432 |
{ |
433 |
static bool registered; |
|
434 |
if (!registered) { |
|
435 |
HINSTANCE hinst = GetModuleHandle(NULL); |
|
436 |
WNDCLASS wnd = { |
|
437 |
0, |
|
438 |
WndProcGdi, |
|
439 |
0, |
|
440 |
0, |
|
441 |
hinst, |
|
442 |
LoadIcon(hinst, MAKEINTRESOURCE(100)), |
|
443 |
LoadCursor(NULL, IDC_ARROW), |
|
444 |
0, |
|
445 |
0, |
|
1957
2a4aa85373c3
(svn r2463) - Fix: partly revert the strncat madness and update nightly script (invisible) to correctly insert date.
Darkvater
parents:
1953
diff
changeset
|
446 |
"OTTD" |
0 | 447 |
}; |
448 |
registered = true; |
|
449 |
if (!RegisterClass(&wnd)) |
|
450 |
error("RegisterClass failed"); |
|
451 |
} |
|
452 |
} |
|
453 |
||
659
a98c731921b4
(svn r1093) -Fix: Hopefully fixed windows revision issues once and for all. Removed globalness of _openttd_revision and put all such ifdefs into one place. If server has a revision only the same revisions can join; if the server has no revision everyone can join. I reckon this should be a server-side option to allow people to join or not to join.
darkvater
parents:
656
diff
changeset
|
454 |
extern const char _openttd_revision[]; |
a98c731921b4
(svn r1093) -Fix: Hopefully fixed windows revision issues once and for all. Removed globalness of _openttd_revision and put all such ifdefs into one place. If server has a revision only the same revisions can join; if the server has no revision everyone can join. I reckon this should be a server-side option to allow people to join or not to join.
darkvater
parents:
656
diff
changeset
|
455 |
|
0 | 456 |
static void MakeWindow(bool full_screen) |
457 |
{ |
|
458 |
_fullscreen = full_screen; |
|
459 |
||
460 |
_wnd.double_size = _double_size && !full_screen; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
461 |
|
0 | 462 |
// recreate window? |
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
463 |
if ((full_screen || _wnd.fullscreen) && _wnd.main_wnd) { |
0 | 464 |
DestroyWindow(_wnd.main_wnd); |
465 |
_wnd.main_wnd = 0; |
|
466 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
467 |
|
0 | 468 |
if (full_screen) { |
469 |
DEVMODE settings; |
|
470 |
memset(&settings, 0, sizeof(DEVMODE)); |
|
471 |
settings.dmSize = sizeof(DEVMODE); |
|
472 |
settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; |
|
473 |
||
474 |
if (_fullscreen_bpp) { |
|
475 |
settings.dmBitsPerPel = _fullscreen_bpp; |
|
476 |
settings.dmFields |= DM_BITSPERPEL; |
|
477 |
} |
|
478 |
settings.dmPelsWidth = _wnd.width_org; |
|
479 |
settings.dmPelsHeight = _wnd.height_org; |
|
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
480 |
settings.dmDisplayFrequency = _display_hz; |
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
481 |
if (settings.dmDisplayFrequency != 0) |
0 | 482 |
settings.dmFields |= DM_DISPLAYFREQUENCY; |
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
483 |
if (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) { |
0 | 484 |
MakeWindow(false); |
485 |
return; |
|
486 |
} |
|
487 |
} else if (_wnd.fullscreen) { |
|
488 |
// restore display? |
|
489 |
ChangeDisplaySettings(NULL, 0); |
|
490 |
} |
|
491 |
||
492 |
{ |
|
493 |
RECT r; |
|
494 |
uint style; |
|
495 |
int x, y, w, h; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
496 |
|
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
497 |
_wnd.fullscreen = full_screen; |
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
498 |
if (_wnd.fullscreen) { |
0 | 499 |
style = WS_POPUP | WS_VISIBLE; |
500 |
SetRect(&r, 0, 0, _wnd.width_org, _wnd.height_org); |
|
501 |
} else { |
|
502 |
style = WS_OVERLAPPEDWINDOW | WS_VISIBLE; |
|
503 |
SetRect(&r, 0, 0, _wnd.width, _wnd.height); |
|
504 |
} |
|
505 |
||
506 |
AdjustWindowRect(&r, style, FALSE); |
|
507 |
w = r.right - r.left; |
|
508 |
h = r.bottom - r.top; |
|
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
509 |
x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2; |
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
510 |
y = (GetSystemMetrics(SM_CYSCREEN) - h) / 2; |
0 | 511 |
|
512 |
if (_wnd.main_wnd) { |
|
513 |
SetWindowPos(_wnd.main_wnd, 0, x, y, w, h, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER); |
|
514 |
} else { |
|
1957
2a4aa85373c3
(svn r2463) - Fix: partly revert the strncat madness and update nightly script (invisible) to correctly insert date.
Darkvater
parents:
1953
diff
changeset
|
515 |
char Windowtitle[50]; |
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
516 |
|
1957
2a4aa85373c3
(svn r2463) - Fix: partly revert the strncat madness and update nightly script (invisible) to correctly insert date.
Darkvater
parents:
1953
diff
changeset
|
517 |
snprintf(Windowtitle, lengthof(Windowtitle), "OpenTTD %s", _openttd_revision); |
659
a98c731921b4
(svn r1093) -Fix: Hopefully fixed windows revision issues once and for all. Removed globalness of _openttd_revision and put all such ifdefs into one place. If server has a revision only the same revisions can join; if the server has no revision everyone can join. I reckon this should be a server-side option to allow people to join or not to join.
darkvater
parents:
656
diff
changeset
|
518 |
|
2171
008122046f7f
(svn r2685) -Codechange: Split the music/sound/video drivers into separate files and move them into subfolders.
tron
parents:
2163
diff
changeset
|
519 |
_wnd.main_wnd = CreateWindow("OTTD", Windowtitle, style, x, y, w, h, 0, 0, GetModuleHandle(NULL), 0); |
0 | 520 |
if (_wnd.main_wnd == NULL) |
521 |
error("CreateWindow failed"); |
|
522 |
} |
|
523 |
} |
|
298
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
287
diff
changeset
|
524 |
GameSizeChanged(); // invalidate all windows, force redraw |
0 | 525 |
} |
526 |
||
527 |
static bool AllocateDibSection(int w, int h) |
|
528 |
{ |
|
529 |
BITMAPINFO *bi; |
|
530 |
HDC dc; |
|
531 |
||
306
c44133836566
(svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents:
298
diff
changeset
|
532 |
w = clamp(w, 64, MAX_SCREEN_WIDTH); |
c44133836566
(svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents:
298
diff
changeset
|
533 |
h = clamp(h, 64, MAX_SCREEN_HEIGHT); |
0 | 534 |
|
535 |
if (w == _screen.width && h == _screen.height) |
|
536 |
return false; |
|
537 |
||
306
c44133836566
(svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents:
298
diff
changeset
|
538 |
_screen.width = w; |
2398
70de6626d65f
(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
|
539 |
_screen.pitch = ALIGN(w, 4); |
0 | 540 |
_screen.height = h; |
541 |
||
542 |
if (_wnd.alloced_bits) { |
|
543 |
free(_wnd.alloced_bits); |
|
544 |
_wnd.alloced_bits = NULL; |
|
545 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
546 |
|
0 | 547 |
bi = alloca(sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*256); |
548 |
memset(bi, 0, sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*256); |
|
549 |
bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
550 |
|
306
c44133836566
(svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents:
298
diff
changeset
|
551 |
if (_wnd.double_size) { |
2398
70de6626d65f
(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
|
552 |
w = ALIGN(w, 4); |
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
553 |
_wnd.alloced_bits = _wnd.buffer_bits = malloc(w * h); |
306
c44133836566
(svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents:
298
diff
changeset
|
554 |
w *= 2; |
c44133836566
(svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents:
298
diff
changeset
|
555 |
h *= 2; |
c44133836566
(svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents:
298
diff
changeset
|
556 |
} |
0 | 557 |
|
306
c44133836566
(svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents:
298
diff
changeset
|
558 |
bi->bmiHeader.biWidth = _wnd.width = w; |
c44133836566
(svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents:
298
diff
changeset
|
559 |
bi->bmiHeader.biHeight = -(_wnd.height = h); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
560 |
|
0 | 561 |
bi->bmiHeader.biPlanes = 1; |
562 |
bi->bmiHeader.biBitCount = 8; |
|
563 |
bi->bmiHeader.biCompression = BI_RGB; |
|
564 |
||
565 |
if (_wnd.dib_sect) |
|
566 |
DeleteObject(_wnd.dib_sect); |
|
567 |
||
568 |
dc = GetDC(0); |
|
2062 | 569 |
_wnd.dib_sect = CreateDIBSection(dc, bi, DIB_RGB_COLORS, (void**)&_wnd.bitmap_bits, NULL, 0); |
0 | 570 |
if (_wnd.dib_sect == NULL) |
571 |
error("CreateDIBSection failed"); |
|
572 |
ReleaseDC(0, dc); |
|
573 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
574 |
if (!_wnd.double_size) |
0 | 575 |
_wnd.buffer_bits = _wnd.bitmap_bits; |
576 |
||
577 |
return true; |
|
578 |
} |
|
579 |
||
580 |
static const uint16 default_resolutions[][2] = { |
|
1028
37e5cf7baa96
(svn r1529) -Feature: [1090950] Adding 16:10 resolutions for mainly laptops (doode)
darkvater
parents:
1023
diff
changeset
|
581 |
{ 640, 480}, |
37e5cf7baa96
(svn r1529) -Feature: [1090950] Adding 16:10 resolutions for mainly laptops (doode)
darkvater
parents:
1023
diff
changeset
|
582 |
{ 800, 600}, |
37e5cf7baa96
(svn r1529) -Feature: [1090950] Adding 16:10 resolutions for mainly laptops (doode)
darkvater
parents:
1023
diff
changeset
|
583 |
{1024, 768}, |
37e5cf7baa96
(svn r1529) -Feature: [1090950] Adding 16:10 resolutions for mainly laptops (doode)
darkvater
parents:
1023
diff
changeset
|
584 |
{1152, 864}, |
37e5cf7baa96
(svn r1529) -Feature: [1090950] Adding 16:10 resolutions for mainly laptops (doode)
darkvater
parents:
1023
diff
changeset
|
585 |
{1280, 800}, |
37e5cf7baa96
(svn r1529) -Feature: [1090950] Adding 16:10 resolutions for mainly laptops (doode)
darkvater
parents:
1023
diff
changeset
|
586 |
{1280, 960}, |
37e5cf7baa96
(svn r1529) -Feature: [1090950] Adding 16:10 resolutions for mainly laptops (doode)
darkvater
parents:
1023
diff
changeset
|
587 |
{1280, 1024}, |
37e5cf7baa96
(svn r1529) -Feature: [1090950] Adding 16:10 resolutions for mainly laptops (doode)
darkvater
parents:
1023
diff
changeset
|
588 |
{1400, 1050}, |
37e5cf7baa96
(svn r1529) -Feature: [1090950] Adding 16:10 resolutions for mainly laptops (doode)
darkvater
parents:
1023
diff
changeset
|
589 |
{1600, 1200}, |
37e5cf7baa96
(svn r1529) -Feature: [1090950] Adding 16:10 resolutions for mainly laptops (doode)
darkvater
parents:
1023
diff
changeset
|
590 |
{1680, 1050}, |
37e5cf7baa96
(svn r1529) -Feature: [1090950] Adding 16:10 resolutions for mainly laptops (doode)
darkvater
parents:
1023
diff
changeset
|
591 |
{1920, 1200} |
0 | 592 |
}; |
593 |
||
1102
316643e34104
(svn r1603) -Fix: unused variable in FormatTinyDate
darkvater
parents:
1040
diff
changeset
|
594 |
static void FindResolutions(void) |
0 | 595 |
{ |
596 |
int i = 0, n = 0; |
|
597 |
DEVMODE dm; |
|
598 |
||
1806
75dc9c737892
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1686
diff
changeset
|
599 |
while (EnumDisplaySettings(NULL, i++, &dm) != 0) { |
75dc9c737892
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1686
diff
changeset
|
600 |
if (dm.dmBitsPerPel == 8 && IS_INT_INSIDE(dm.dmPelsWidth, 640, MAX_SCREEN_WIDTH + 1) && |
75dc9c737892
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1686
diff
changeset
|
601 |
IS_INT_INSIDE(dm.dmPelsHeight, 480, MAX_SCREEN_HEIGHT + 1)){ |
75dc9c737892
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1686
diff
changeset
|
602 |
int j; |
75dc9c737892
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1686
diff
changeset
|
603 |
for (j = 0; j < n; j++) { |
75dc9c737892
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1686
diff
changeset
|
604 |
if (_resolutions[j][0] == dm.dmPelsWidth && _resolutions[j][1] == dm.dmPelsHeight) break; |
75dc9c737892
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1686
diff
changeset
|
605 |
} |
75dc9c737892
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1686
diff
changeset
|
606 |
|
75dc9c737892
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1686
diff
changeset
|
607 |
/* In the previous loop we have checked already existing/added resolutions if |
75dc9c737892
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1686
diff
changeset
|
608 |
* they are the same as the new ones. If this is not the case (j == n); we have |
75dc9c737892
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1686
diff
changeset
|
609 |
* looped all and found none, add the new one to the list. If we have reached the |
75dc9c737892
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1686
diff
changeset
|
610 |
* maximum amount of resolutions, then quit querying the display */ |
75dc9c737892
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1686
diff
changeset
|
611 |
if (j == n) { |
75dc9c737892
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1686
diff
changeset
|
612 |
_resolutions[j][0] = dm.dmPelsWidth; |
75dc9c737892
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1686
diff
changeset
|
613 |
_resolutions[j][1] = dm.dmPelsHeight; |
75dc9c737892
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1686
diff
changeset
|
614 |
if (++n == lengthof(_resolutions)) break; |
75dc9c737892
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1686
diff
changeset
|
615 |
} |
0 | 616 |
} |
617 |
} |
|
618 |
||
1806
75dc9c737892
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1686
diff
changeset
|
619 |
/* We have found no resolutions, show the default list */ |
0 | 620 |
if (n == 0) { |
621 |
memcpy(_resolutions, default_resolutions, sizeof(default_resolutions)); |
|
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
622 |
n = lengthof(default_resolutions); |
0 | 623 |
} |
624 |
||
625 |
_num_resolutions = n; |
|
1806
75dc9c737892
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1686
diff
changeset
|
626 |
SortResolutions(_num_resolutions); |
0 | 627 |
} |
628 |
||
629 |
||
1301
313804601383
(svn r1805) Teach the driver layer a few things about const correctness
tron
parents:
1230
diff
changeset
|
630 |
static const char *Win32GdiStart(const char * const *parm) |
0 | 631 |
{ |
632 |
memset(&_wnd, 0, sizeof(_wnd)); |
|
633 |
||
634 |
RegisterWndClass(); |
|
635 |
||
636 |
MakePalette(); |
|
637 |
||
638 |
FindResolutions(); |
|
639 |
||
640 |
// fullscreen uses those |
|
641 |
_wnd.width_org = _cur_resolution[0]; |
|
642 |
_wnd.height_org = _cur_resolution[1]; |
|
643 |
||
644 |
AllocateDibSection(_cur_resolution[0], _cur_resolution[1]); |
|
645 |
MarkWholeScreenDirty(); |
|
646 |
||
647 |
MakeWindow(_fullscreen); |
|
648 |
||
649 |
return NULL; |
|
650 |
} |
|
651 |
||
1102
316643e34104
(svn r1603) -Fix: unused variable in FormatTinyDate
darkvater
parents:
1040
diff
changeset
|
652 |
static void Win32GdiStop(void) |
0 | 653 |
{ |
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
654 |
if (_wnd.fullscreen) ChangeDisplaySettings(NULL, 0); |
0 | 655 |
MyShowCursor(true); |
656 |
DeleteObject(_wnd.gdi_palette); |
|
657 |
DeleteObject(_wnd.dib_sect); |
|
658 |
DestroyWindow(_wnd.main_wnd); |
|
659 |
} |
|
660 |
||
661 |
// simple upscaler by 2 |
|
662 |
static void filter(int left, int top, int width, int height) |
|
663 |
{ |
|
664 |
uint p = _screen.pitch; |
|
2062 | 665 |
const Pixel *s = _wnd.buffer_bits + top * p + left; |
666 |
Pixel *d = _wnd.bitmap_bits + top * p * 4 + left * 2; |
|
0 | 667 |
|
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
668 |
for (; height > 0; height--) { |
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
669 |
int i; |
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
670 |
|
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
671 |
for (i = 0; i != width; i++) { |
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
672 |
d[i * 2] = d[i * 2 + 1] = d[i * 2 + p * 2] = d[i * 2 + 1 + p * 2] = s[i]; |
0 | 673 |
} |
674 |
s += p; |
|
675 |
d += p * 4; |
|
676 |
} |
|
677 |
} |
|
678 |
||
679 |
static void Win32GdiMakeDirty(int left, int top, int width, int height) |
|
680 |
{ |
|
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
681 |
RECT r = { left, top, left + width, top + height }; |
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
682 |
|
0 | 683 |
if (_wnd.double_size) { |
684 |
filter(left, top, width, height); |
|
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
685 |
r.left *= 2; |
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
686 |
r.top *= 2; |
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
687 |
r.right *= 2; |
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
688 |
r.bottom *= 2; |
0 | 689 |
} |
690 |
InvalidateRect(_wnd.main_wnd, &r, FALSE); |
|
691 |
} |
|
692 |
||
1102
316643e34104
(svn r1603) -Fix: unused variable in FormatTinyDate
darkvater
parents:
1040
diff
changeset
|
693 |
static void CheckPaletteAnim(void) |
0 | 694 |
{ |
695 |
if (_pal_last_dirty == -1) |
|
696 |
return; |
|
697 |
InvalidateRect(_wnd.main_wnd, NULL, FALSE); |
|
698 |
} |
|
699 |
||
2228 | 700 |
static void Win32GdiMainLoop(void) |
0 | 701 |
{ |
702 |
MSG mesg; |
|
703 |
uint32 next_tick = GetTickCount() + 30, cur_ticks; |
|
704 |
||
705 |
_wnd.running = true; |
|
706 |
||
707 |
while(true) { |
|
708 |
while (PeekMessage(&mesg, NULL, 0, 0, PM_REMOVE)) { |
|
709 |
InteractiveRandom(); // randomness |
|
710 |
TranslateMessage(&mesg); |
|
711 |
DispatchMessage(&mesg); |
|
712 |
} |
|
2228 | 713 |
if (_exit_game) return; |
0 | 714 |
|
715 |
#if defined(_DEBUG) |
|
716 |
if (_wnd.has_focus && GetAsyncKeyState(VK_SHIFT) < 0) { |
|
1548
a69e1b3b7774
(svn r2052) - Fix Regression: ALT+F4 once again shuts down openttd in windows and F10, etc. is fixed.
darkvater
parents:
1508
diff
changeset
|
717 |
if ( |
0 | 718 |
#else |
719 |
if (_wnd.has_focus && GetAsyncKeyState(VK_TAB) < 0) { |
|
1403
6d9ed6c85a22
(svn r1907) - Fix: [ 1114261 ] Speeding up when pressing ALT+TAB (Windows)
darkvater
parents:
1390
diff
changeset
|
720 |
/* Disable speeding up game with ALT+TAB (if syskey is pressed, the |
6d9ed6c85a22
(svn r1907) - Fix: [ 1114261 ] Speeding up when pressing ALT+TAB (Windows)
darkvater
parents:
1390
diff
changeset
|
721 |
* real key is in the upper 16 bits (see WM_SYSKEYDOWN in WndProcGdi()) */ |
1548
a69e1b3b7774
(svn r2052) - Fix Regression: ALT+F4 once again shuts down openttd in windows and F10, etc. is fixed.
darkvater
parents:
1508
diff
changeset
|
722 |
if ((_pressed_key >> 16) & WKC_TAB && |
a69e1b3b7774
(svn r2052) - Fix Regression: ALT+F4 once again shuts down openttd in windows and F10, etc. is fixed.
darkvater
parents:
1508
diff
changeset
|
723 |
#endif |
1582
5ac8f9425c09
(svn r2086) - Codechange: Two indentation fixes coming from Loic Guilloux' patch 1171208.
pasky
parents:
1580
diff
changeset
|
724 |
!_networking && _game_mode != GM_MENU) |
1468
8073826fe82d
(svn r1972) Several cleanups and fix some latent bugs
tron
parents:
1466
diff
changeset
|
725 |
_fast_forward |= 2; |
1403
6d9ed6c85a22
(svn r1907) - Fix: [ 1114261 ] Speeding up when pressing ALT+TAB (Windows)
darkvater
parents:
1390
diff
changeset
|
726 |
} else if (_fast_forward & 2) |
0 | 727 |
_fast_forward = 0; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
728 |
|
1403
6d9ed6c85a22
(svn r1907) - Fix: [ 1114261 ] Speeding up when pressing ALT+TAB (Windows)
darkvater
parents:
1390
diff
changeset
|
729 |
cur_ticks = GetTickCount(); |
0 | 730 |
if ((_fast_forward && !_pause) || cur_ticks > next_tick) |
731 |
next_tick = cur_ticks; |
|
732 |
||
733 |
if (cur_ticks == next_tick) { |
|
734 |
next_tick += 30; |
|
735 |
_ctrl_pressed = _wnd.has_focus && GetAsyncKeyState(VK_CONTROL)<0; |
|
736 |
_shift_pressed = _wnd.has_focus && GetAsyncKeyState(VK_SHIFT)<0; |
|
737 |
_dbg_screen_rect = _wnd.has_focus && GetAsyncKeyState(VK_CAPITAL)<0; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
738 |
|
0 | 739 |
// determine which directional keys are down |
1230
701163ef52b8
(svn r1734) - Fix: [ 1112253 ] hijacking of arrow keys, game also scrolled when it was out of focus (dominik)
darkvater
parents:
1102
diff
changeset
|
740 |
if (_wnd.has_focus) { |
701163ef52b8
(svn r1734) - Fix: [ 1112253 ] hijacking of arrow keys, game also scrolled when it was out of focus (dominik)
darkvater
parents:
1102
diff
changeset
|
741 |
_dirkeys = |
701163ef52b8
(svn r1734) - Fix: [ 1112253 ] hijacking of arrow keys, game also scrolled when it was out of focus (dominik)
darkvater
parents:
1102
diff
changeset
|
742 |
(GetAsyncKeyState(VK_LEFT) < 0 ? 1 : 0) + |
701163ef52b8
(svn r1734) - Fix: [ 1112253 ] hijacking of arrow keys, game also scrolled when it was out of focus (dominik)
darkvater
parents:
1102
diff
changeset
|
743 |
(GetAsyncKeyState(VK_UP) < 0 ? 2 : 0) + |
701163ef52b8
(svn r1734) - Fix: [ 1112253 ] hijacking of arrow keys, game also scrolled when it was out of focus (dominik)
darkvater
parents:
1102
diff
changeset
|
744 |
(GetAsyncKeyState(VK_RIGHT) < 0 ? 4 : 0) + |
701163ef52b8
(svn r1734) - Fix: [ 1112253 ] hijacking of arrow keys, game also scrolled when it was out of focus (dominik)
darkvater
parents:
1102
diff
changeset
|
745 |
(GetAsyncKeyState(VK_DOWN) < 0 ? 8 : 0); |
701163ef52b8
(svn r1734) - Fix: [ 1112253 ] hijacking of arrow keys, game also scrolled when it was out of focus (dominik)
darkvater
parents:
1102
diff
changeset
|
746 |
} else |
701163ef52b8
(svn r1734) - Fix: [ 1112253 ] hijacking of arrow keys, game also scrolled when it was out of focus (dominik)
darkvater
parents:
1102
diff
changeset
|
747 |
_dirkeys = 0; |
0 | 748 |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
749 |
GameLoop(); |
0 | 750 |
_cursor.delta.x = _cursor.delta.y = 0; |
751 |
||
752 |
if (_force_full_redraw) |
|
753 |
MarkWholeScreenDirty(); |
|
754 |
||
755 |
GdiFlush(); |
|
756 |
_screen.dst_ptr = _wnd.buffer_bits; |
|
757 |
UpdateWindows(); |
|
758 |
CheckPaletteAnim(); |
|
759 |
} else { |
|
760 |
Sleep(1); |
|
761 |
GdiFlush(); |
|
762 |
_screen.dst_ptr = _wnd.buffer_bits; |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
763 |
DrawTextMessage(); |
0 | 764 |
DrawMouseCursor(); |
765 |
} |
|
766 |
} |
|
767 |
} |
|
768 |
||
769 |
static bool Win32GdiChangeRes(int w, int h) |
|
770 |
{ |
|
771 |
_wnd.width = _wnd.width_org = w; |
|
772 |
_wnd.height = _wnd.height_org = h; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
773 |
|
298
b3e83b94be19
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents:
287
diff
changeset
|
774 |
MakeWindow(_fullscreen); // _wnd.fullscreen screws up ingame resolution switching |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
775 |
|
0 | 776 |
return true; |
777 |
} |
|
778 |
||
1829
0b6de3b4458a
(svn r2334) - Fix (regression): moved togglefullscreen into the video-driver, now windows works, dedicated works and sdl works. Also reverted the change to the makefile.
Darkvater
parents:
1806
diff
changeset
|
779 |
static void Win32GdiFullScreen(bool full_screen) {MakeWindow(full_screen);} |
1806
75dc9c737892
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents:
1686
diff
changeset
|
780 |
|
0 | 781 |
const HalVideoDriver _win32_video_driver = { |
782 |
Win32GdiStart, |
|
783 |
Win32GdiStop, |
|
784 |
Win32GdiMakeDirty, |
|
785 |
Win32GdiMainLoop, |
|
786 |
Win32GdiChangeRes, |
|
1829
0b6de3b4458a
(svn r2334) - Fix (regression): moved togglefullscreen into the video-driver, now windows works, dedicated works and sdl works. Also reverted the change to the makefile.
Darkvater
parents:
1806
diff
changeset
|
787 |
Win32GdiFullScreen, |
0 | 788 |
}; |