src/video/sdl_v.cpp
author convert-repo
Mon, 07 Apr 2008 16:21:55 +0000
changeset 10076 dfd70e42c4ae
parent 9082 8217cb013e23
child 10247 145d0458b685
permissions -rw-r--r--
update tags
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2174
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2174
diff changeset
     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
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
#ifdef WITH_SDL
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
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 "../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
     8
#include "../debug.h"
8619
c2434269c3eb (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8617
diff changeset
     9
#include "../gfx_func.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
    10
#include "../sdl.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
    11
#include "../variables.h"
7433
8e410e7ec0d7 (svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents: 7374
diff changeset
    12
#include "../blitter/factory.hpp"
8617
931e0970d509 (svn r11682) -Codechange: move some 'generic' geometry related types into a single file and do not include gfx.h everywhere to get a Point type.
rubidium
parents: 8609
diff changeset
    13
#include "../network/network.h"
8743
62a558995c35 (svn r11811) -Fix: make compilation without networking work again (and thus move the debugdumpcommand stuff out of the network 'area').
rubidium
parents: 8667
diff changeset
    14
#include "../core/math_func.hpp"
8929
a8732ed52252 (svn r12003) -Codechange: don't declare InteractiveRandom[Range] in multiple places.
rubidium
parents: 8743
diff changeset
    15
#include "../core/random_func.hpp"
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
    16
#include "sdl_v.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    17
#include <SDL.h>
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    18
7666
a5fccd76176a (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents: 7515
diff changeset
    19
static FVideoDriver_SDL iFVideoDriver_SDL;
a5fccd76176a (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents: 7515
diff changeset
    20
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    21
static SDL_Surface *_sdl_screen;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    22
static bool _all_modes;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    23
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    24
#define MAX_DIRTY_RECTS 100
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    25
static SDL_Rect _dirty_rects[MAX_DIRTY_RECTS];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    26
static int _num_dirty_rects;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
7666
a5fccd76176a (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents: 7515
diff changeset
    28
void VideoDriver_SDL::MakeDirty(int left, int top, int width, int height)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    30
	if (_num_dirty_rects < MAX_DIRTY_RECTS) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    31
		_dirty_rects[_num_dirty_rects].x = left;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
		_dirty_rects[_num_dirty_rects].y = top;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
		_dirty_rects[_num_dirty_rects].w = width;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
		_dirty_rects[_num_dirty_rects].h = height;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
	_num_dirty_rects++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
2226
efc1f77d27fc (svn r2746) -Fix: SDL_SetColors() has the number of palette entries to change as parameter, not one beyond the last entry to change
tron
parents: 2210
diff changeset
    39
static void UpdatePalette(uint start, uint count)
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
    40
{
2226
efc1f77d27fc (svn r2746) -Fix: SDL_SetColors() has the number of palette entries to change as parameter, not one beyond the last entry to change
tron
parents: 2210
diff changeset
    41
	SDL_Color pal[256];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    42
	uint i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
2226
efc1f77d27fc (svn r2746) -Fix: SDL_SetColors() has the number of palette entries to change as parameter, not one beyond the last entry to change
tron
parents: 2210
diff changeset
    44
	for (i = 0; i != count; i++) {
efc1f77d27fc (svn r2746) -Fix: SDL_SetColors() has the number of palette entries to change as parameter, not one beyond the last entry to change
tron
parents: 2210
diff changeset
    45
		pal[i].r = _cur_palette[start + i].r;
efc1f77d27fc (svn r2746) -Fix: SDL_SetColors() has the number of palette entries to change as parameter, not one beyond the last entry to change
tron
parents: 2210
diff changeset
    46
		pal[i].g = _cur_palette[start + i].g;
efc1f77d27fc (svn r2746) -Fix: SDL_SetColors() has the number of palette entries to change as parameter, not one beyond the last entry to change
tron
parents: 2210
diff changeset
    47
		pal[i].b = _cur_palette[start + i].b;
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1891
diff changeset
    48
		pal[i].unused = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
2226
efc1f77d27fc (svn r2746) -Fix: SDL_SetColors() has the number of palette entries to change as parameter, not one beyond the last entry to change
tron
parents: 2210
diff changeset
    51
	SDL_CALL SDL_SetColors(_sdl_screen, pal, start, count);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
    54
static void InitPalette()
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
    55
{
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
	UpdatePalette(0, 256);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
    59
static void CheckPaletteAnim()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
{
7457
b380079242fa (svn r10217) -Fix r10216: forgot to declare 'blitter' in win32 and cocoa driver (tnx glx)
truelight
parents: 7456
diff changeset
    61
	if (_pal_count_dirty != 0) {
b380079242fa (svn r10217) -Fix r10216: forgot to declare 'blitter' in win32 and cocoa driver (tnx glx)
truelight
parents: 7456
diff changeset
    62
		Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter();
7456
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7433
diff changeset
    63
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7433
diff changeset
    64
		switch (blitter->UsePaletteAnimation()) {
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7433
diff changeset
    65
			case Blitter::PALETTE_ANIMATION_VIDEO_BACKEND:
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7433
diff changeset
    66
				UpdatePalette(_pal_first_dirty, _pal_count_dirty);
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7433
diff changeset
    67
				break;
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7433
diff changeset
    68
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7433
diff changeset
    69
			case Blitter::PALETTE_ANIMATION_BLITTER:
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7433
diff changeset
    70
				blitter->PaletteAnimate(_pal_first_dirty, _pal_count_dirty);
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7433
diff changeset
    71
				break;
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7433
diff changeset
    72
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7433
diff changeset
    73
			case Blitter::PALETTE_ANIMATION_NONE:
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7433
diff changeset
    74
				break;
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7433
diff changeset
    75
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7433
diff changeset
    76
			default:
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7433
diff changeset
    77
				NOT_REACHED();
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7433
diff changeset
    78
		}
0c0636370335 (svn r10216) -Fix: palette animation always redid all palette entries, where in fact only a few indexes were needed
truelight
parents: 7433
diff changeset
    79
		_pal_count_dirty = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
	}
18
7428dd7c5732 (svn r19) SDL performance fix fo palette animation and mouse jumping (jirif)
dominik
parents: 0
diff changeset
    81
}
7428dd7c5732 (svn r19) SDL performance fix fo palette animation and mouse jumping (jirif)
dominik
parents: 0
diff changeset
    82
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
    83
static void DrawSurfaceToScreen()
18
7428dd7c5732 (svn r19) SDL performance fix fo palette animation and mouse jumping (jirif)
dominik
parents: 0
diff changeset
    84
{
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
    85
	int n = _num_dirty_rects;
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
    86
	if (n != 0) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
		_num_dirty_rects = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
		if (n > MAX_DIRTY_RECTS)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
			SDL_CALL SDL_UpdateRect(_sdl_screen, 0, 0, 0, 0);
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
    90
		else
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
			SDL_CALL SDL_UpdateRects(_sdl_screen, n, _dirty_rects);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
static const uint16 default_resolutions[][2] = {
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
    96
	{ 640,  480},
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
    97
	{ 800,  600},
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
    98
	{1024,  768},
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
    99
	{1152,  864},
1028
37e5cf7baa96 (svn r1529) -Feature: [1090950] Adding 16:10 resolutions for mainly laptops (doode)
darkvater
parents: 1022
diff changeset
   100
	{1280,  800},
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   101
	{1280,  960},
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   102
	{1280, 1024},
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   103
	{1400, 1050},
1028
37e5cf7baa96 (svn r1529) -Feature: [1090950] Adding 16:10 resolutions for mainly laptops (doode)
darkvater
parents: 1022
diff changeset
   104
	{1600, 1200},
37e5cf7baa96 (svn r1529) -Feature: [1090950] Adding 16:10 resolutions for mainly laptops (doode)
darkvater
parents: 1022
diff changeset
   105
	{1680, 1050},
37e5cf7baa96 (svn r1529) -Feature: [1090950] Adding 16:10 resolutions for mainly laptops (doode)
darkvater
parents: 1022
diff changeset
   106
	{1920, 1200}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   109
static void GetVideoModes()
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   110
{
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
	int i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
	SDL_Rect **modes;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
	modes = SDL_CALL SDL_ListModes(NULL, SDL_SWSURFACE + (_fullscreen ? SDL_FULLSCREEN : 0));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   116
	if (modes == NULL)
245
4f6f81046437 (svn r246) -Fix: 64bit machine warnings for sdl.c (Tron)
darkvater
parents: 222
diff changeset
   117
		error("sdl: no modes available");
119
82c0f4713cad (svn r120) Fix: (SDL) same resolution was displayed more than once in game options
dominik
parents: 60
diff changeset
   118
245
4f6f81046437 (svn r246) -Fix: 64bit machine warnings for sdl.c (Tron)
darkvater
parents: 222
diff changeset
   119
	_all_modes = (modes == (void*)-1);
4f6f81046437 (svn r246) -Fix: 64bit machine warnings for sdl.c (Tron)
darkvater
parents: 222
diff changeset
   120
4f6f81046437 (svn r246) -Fix: 64bit machine warnings for sdl.c (Tron)
darkvater
parents: 222
diff changeset
   121
	if (_all_modes) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
		// all modes available, put some default ones here
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
		memcpy(_resolutions, default_resolutions, sizeof(default_resolutions));
245
4f6f81046437 (svn r246) -Fix: 64bit machine warnings for sdl.c (Tron)
darkvater
parents: 222
diff changeset
   124
		_num_resolutions = lengthof(default_resolutions);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   125
	} else {
128
28ebd80f6521 (svn r129) Fix: no more same multiple resolutions due to incorrect SDL implementation (Tron)
dominik
parents: 119
diff changeset
   126
		int n = 0;
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   127
		for (i = 0; modes[i]; i++) {
128
28ebd80f6521 (svn r129) Fix: no more same multiple resolutions due to incorrect SDL implementation (Tron)
dominik
parents: 119
diff changeset
   128
			int w = modes[i]->w;
28ebd80f6521 (svn r129) Fix: no more same multiple resolutions due to incorrect SDL implementation (Tron)
dominik
parents: 119
diff changeset
   129
			int h = modes[i]->h;
8450
dce58137301f (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 8418
diff changeset
   130
			if (IsInsideMM(w, 640, MAX_SCREEN_WIDTH + 1) &&
dce58137301f (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 8418
diff changeset
   131
					IsInsideMM(h, 480, MAX_SCREEN_HEIGHT + 1)) {
128
28ebd80f6521 (svn r129) Fix: no more same multiple resolutions due to incorrect SDL implementation (Tron)
dominik
parents: 119
diff changeset
   132
				int j;
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: 1509
diff changeset
   133
				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: 1509
diff changeset
   134
					if (_resolutions[j][0] == w && _resolutions[j][1] == h) 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: 1509
diff changeset
   135
				}
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: 1509
diff changeset
   136
128
28ebd80f6521 (svn r129) Fix: no more same multiple resolutions due to incorrect SDL implementation (Tron)
dominik
parents: 119
diff changeset
   137
				if (j == 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: 1509
diff changeset
   138
					_resolutions[j][0] = w;
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: 1509
diff changeset
   139
					_resolutions[j][1] = h;
245
4f6f81046437 (svn r246) -Fix: 64bit machine warnings for sdl.c (Tron)
darkvater
parents: 222
diff changeset
   140
					if (++n == lengthof(_resolutions)) break;
128
28ebd80f6521 (svn r129) Fix: no more same multiple resolutions due to incorrect SDL implementation (Tron)
dominik
parents: 119
diff changeset
   141
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   142
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   144
		_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: 1509
diff changeset
   145
		SortResolutions(_num_resolutions);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   146
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   148
4501
16ca2f0e465e (svn r6286) Nobody cares for the return value of GetAvailableVideoMode(), therefore remove it
tron
parents: 4434
diff changeset
   149
static void GetAvailableVideoMode(int *w, int *h)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
	int i;
306
c44133836566 (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 302
diff changeset
   152
	int best;
c44133836566 (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 302
diff changeset
   153
	uint delta;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   155
	// all modes available?
4501
16ca2f0e465e (svn r6286) Nobody cares for the return value of GetAvailableVideoMode(), therefore remove it
tron
parents: 4434
diff changeset
   156
	if (_all_modes) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   157
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
	// is the wanted mode among the available modes?
306
c44133836566 (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 302
diff changeset
   159
	for (i = 0; i != _num_resolutions; i++) {
4501
16ca2f0e465e (svn r6286) Nobody cares for the return value of GetAvailableVideoMode(), therefore remove it
tron
parents: 4434
diff changeset
   160
		if (*w == _resolutions[i][0] && *h == _resolutions[i][1]) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
306
c44133836566 (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 302
diff changeset
   163
	// use the closest possible resolution
c44133836566 (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 302
diff changeset
   164
	best = 0;
c44133836566 (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 302
diff changeset
   165
	delta = abs((_resolutions[0][0] - *w) * (_resolutions[0][1] - *h));
c44133836566 (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 302
diff changeset
   166
	for (i = 1; i != _num_resolutions; ++i) {
c44133836566 (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 302
diff changeset
   167
		uint newdelta = abs((_resolutions[i][0] - *w) * (_resolutions[i][1] - *h));
c44133836566 (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 302
diff changeset
   168
		if (newdelta < delta) {
c44133836566 (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 302
diff changeset
   169
			best = i;
c44133836566 (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 302
diff changeset
   170
			delta = newdelta;
c44133836566 (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 302
diff changeset
   171
		}
c44133836566 (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 302
diff changeset
   172
	}
c44133836566 (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 302
diff changeset
   173
	*w = _resolutions[best][0];
c44133836566 (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 302
diff changeset
   174
	*h = _resolutions[best][1];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
4256
877a6c0f4991 (svn r5872) - Feature: Add an icon to the SDL openttd executable.
Darkvater
parents: 4077
diff changeset
   177
#ifndef ICON_DIR
877a6c0f4991 (svn r5872) - Feature: Add an icon to the SDL openttd executable.
Darkvater
parents: 4077
diff changeset
   178
#define ICON_DIR "media"
877a6c0f4991 (svn r5872) - Feature: Add an icon to the SDL openttd executable.
Darkvater
parents: 4077
diff changeset
   179
#endif
877a6c0f4991 (svn r5872) - Feature: Add an icon to the SDL openttd executable.
Darkvater
parents: 4077
diff changeset
   180
877a6c0f4991 (svn r5872) - Feature: Add an icon to the SDL openttd executable.
Darkvater
parents: 4077
diff changeset
   181
#ifdef WIN32
877a6c0f4991 (svn r5872) - Feature: Add an icon to the SDL openttd executable.
Darkvater
parents: 4077
diff changeset
   182
/* Let's redefine the LoadBMP macro with because we are dynamically
877a6c0f4991 (svn r5872) - Feature: Add an icon to the SDL openttd executable.
Darkvater
parents: 4077
diff changeset
   183
 * loading SDL and need to 'SDL_CALL' all functions */
877a6c0f4991 (svn r5872) - Feature: Add an icon to the SDL openttd executable.
Darkvater
parents: 4077
diff changeset
   184
#undef SDL_LoadBMP
877a6c0f4991 (svn r5872) - Feature: Add an icon to the SDL openttd executable.
Darkvater
parents: 4077
diff changeset
   185
#define SDL_LoadBMP(file)	SDL_LoadBMP_RW(SDL_CALL SDL_RWFromFile(file, "rb"), 1)
877a6c0f4991 (svn r5872) - Feature: Add an icon to the SDL openttd executable.
Darkvater
parents: 4077
diff changeset
   186
#endif
877a6c0f4991 (svn r5872) - Feature: Add an icon to the SDL openttd executable.
Darkvater
parents: 4077
diff changeset
   187
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
static bool CreateMainSurface(int w, int h)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
{
4840
176bc2a66322 (svn r6766) -Codechange: Move _openttd_revision[] into the functions that use it instead of global
Darkvater
parents: 4548
diff changeset
   190
	extern const char _openttd_revision[];
4256
877a6c0f4991 (svn r5872) - Feature: Add an icon to the SDL openttd executable.
Darkvater
parents: 4077
diff changeset
   191
	SDL_Surface *newscreen, *icon;
1474
d83520edcda6 (svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents: 1428
diff changeset
   192
	char caption[50];
7374
54c06f06ecc8 (svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents: 7111
diff changeset
   193
	int bpp = BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   194
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   195
	GetAvailableVideoMode(&w, &h);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   196
7374
54c06f06ecc8 (svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents: 7111
diff changeset
   197
	DEBUG(driver, 1, "SDL: using mode %dx%dx%d", w, h, bpp);
54c06f06ecc8 (svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents: 7111
diff changeset
   198
54c06f06ecc8 (svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents: 7111
diff changeset
   199
	if (bpp == 0) error("Can't use a blitter that blits 0 bpp for normal visuals");
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   200
4256
877a6c0f4991 (svn r5872) - Feature: Add an icon to the SDL openttd executable.
Darkvater
parents: 4077
diff changeset
   201
	/* Give the application an icon */
877a6c0f4991 (svn r5872) - Feature: Add an icon to the SDL openttd executable.
Darkvater
parents: 4077
diff changeset
   202
	icon = SDL_CALL SDL_LoadBMP(ICON_DIR PATHSEP "openttd.32.bmp");
877a6c0f4991 (svn r5872) - Feature: Add an icon to the SDL openttd executable.
Darkvater
parents: 4077
diff changeset
   203
	if (icon != NULL) {
877a6c0f4991 (svn r5872) - Feature: Add an icon to the SDL openttd executable.
Darkvater
parents: 4077
diff changeset
   204
		/* Get the colourkey, which will be magenta */
877a6c0f4991 (svn r5872) - Feature: Add an icon to the SDL openttd executable.
Darkvater
parents: 4077
diff changeset
   205
		uint32 rgbmap = SDL_CALL SDL_MapRGB(icon->format, 255, 0, 255);
4507
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   206
4256
877a6c0f4991 (svn r5872) - Feature: Add an icon to the SDL openttd executable.
Darkvater
parents: 4077
diff changeset
   207
		SDL_CALL SDL_SetColorKey(icon, SDL_SRCCOLORKEY, rgbmap);
877a6c0f4991 (svn r5872) - Feature: Add an icon to the SDL openttd executable.
Darkvater
parents: 4077
diff changeset
   208
		SDL_CALL SDL_WM_SetIcon(icon, NULL);
877a6c0f4991 (svn r5872) - Feature: Add an icon to the SDL openttd executable.
Darkvater
parents: 4077
diff changeset
   209
		SDL_CALL SDL_FreeSurface(icon);
877a6c0f4991 (svn r5872) - Feature: Add an icon to the SDL openttd executable.
Darkvater
parents: 4077
diff changeset
   210
	}
877a6c0f4991 (svn r5872) - Feature: Add an icon to the SDL openttd executable.
Darkvater
parents: 4077
diff changeset
   211
36
c1b3b884584e (svn r37) Do not change to HWSURFACE since it's not working!
darkvater
parents: 34
diff changeset
   212
	// DO NOT CHANGE TO HWSURFACE, IT DOES NOT WORK
7374
54c06f06ecc8 (svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents: 7111
diff changeset
   213
	newscreen = SDL_CALL SDL_SetVideoMode(w, h, bpp, SDL_SWSURFACE | SDL_HWPALETTE | (_fullscreen ? SDL_FULLSCREEN : SDL_RESIZABLE));
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   214
	if (newscreen == NULL)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   215
		return false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   216
306
c44133836566 (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 302
diff changeset
   217
	_screen.width = newscreen->w;
c44133836566 (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 302
diff changeset
   218
	_screen.height = newscreen->h;
7374
54c06f06ecc8 (svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents: 7111
diff changeset
   219
	_screen.pitch = newscreen->pitch / (bpp / 8);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   220
	_sdl_screen = newscreen;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   221
	InitPalette();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
1474
d83520edcda6 (svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents: 1428
diff changeset
   223
	snprintf(caption, sizeof(caption), "OpenTTD %s", _openttd_revision);
902
df8c96ee70d5 (svn r1388) Feature: [SDL] Show revision number in window title
dominik
parents: 810
diff changeset
   224
	SDL_CALL SDL_WM_SetCaption(caption, caption);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   225
	SDL_CALL SDL_ShowCursor(0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   226
306
c44133836566 (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 302
diff changeset
   227
	GameSizeChanged();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   228
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   229
	return true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   230
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   231
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   232
struct VkMapping {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   233
	uint16 vk_from;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   234
	byte vk_count;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
	byte map_to;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   236
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   237
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   238
#define AS(x, z) {x, 0, z}
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   239
#define AM(x, y, z, w) {x, y - x, z}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   240
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   241
static const VkMapping _vk_mapping[] = {
7807
81a0f019daa2 (svn r10663) -Fix r10662: bad me, didn't comply with coding style, as penalty I updated the surrounding code to comply with coding style too; I will never do it again (I hope :p)
truelight
parents: 7806
diff changeset
   242
	/* Pageup stuff + up/down */
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   243
	AM(SDLK_PAGEUP, SDLK_PAGEDOWN, WKC_PAGEUP, WKC_PAGEDOWN),
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4300
diff changeset
   244
	AS(SDLK_UP,     WKC_UP),
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4300
diff changeset
   245
	AS(SDLK_DOWN,   WKC_DOWN),
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4300
diff changeset
   246
	AS(SDLK_LEFT,   WKC_LEFT),
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4300
diff changeset
   247
	AS(SDLK_RIGHT,  WKC_RIGHT),
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   248
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4300
diff changeset
   249
	AS(SDLK_HOME,   WKC_HOME),
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4300
diff changeset
   250
	AS(SDLK_END,    WKC_END),
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   251
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4300
diff changeset
   252
	AS(SDLK_INSERT, WKC_INSERT),
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4300
diff changeset
   253
	AS(SDLK_DELETE, WKC_DELETE),
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
7807
81a0f019daa2 (svn r10663) -Fix r10662: bad me, didn't comply with coding style, as penalty I updated the surrounding code to comply with coding style too; I will never do it again (I hope :p)
truelight
parents: 7806
diff changeset
   255
	/* Map letters & digits */
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   256
	AM(SDLK_a, SDLK_z, 'A', 'Z'),
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   257
	AM(SDLK_0, SDLK_9, '0', '9'),
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   258
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4300
diff changeset
   259
	AS(SDLK_ESCAPE,    WKC_ESC),
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4300
diff changeset
   260
	AS(SDLK_PAUSE,     WKC_PAUSE),
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4300
diff changeset
   261
	AS(SDLK_BACKSPACE, WKC_BACKSPACE),
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   262
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4300
diff changeset
   263
	AS(SDLK_SPACE,     WKC_SPACE),
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4300
diff changeset
   264
	AS(SDLK_RETURN,    WKC_RETURN),
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4300
diff changeset
   265
	AS(SDLK_TAB,       WKC_TAB),
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   266
7807
81a0f019daa2 (svn r10663) -Fix r10662: bad me, didn't comply with coding style, as penalty I updated the surrounding code to comply with coding style too; I will never do it again (I hope :p)
truelight
parents: 7806
diff changeset
   267
	/* Function keys */
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   268
	AM(SDLK_F1, SDLK_F12, WKC_F1, WKC_F12),
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   269
7807
81a0f019daa2 (svn r10663) -Fix r10662: bad me, didn't comply with coding style, as penalty I updated the surrounding code to comply with coding style too; I will never do it again (I hope :p)
truelight
parents: 7806
diff changeset
   270
	/* Numeric part. */
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   271
	AM(SDLK_KP0, SDLK_KP9, WKC_NUM_0, WKC_NUM_9),
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4300
diff changeset
   272
	AS(SDLK_KP_DIVIDE,   WKC_NUM_DIV),
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4300
diff changeset
   273
	AS(SDLK_KP_MULTIPLY, WKC_NUM_MUL),
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4300
diff changeset
   274
	AS(SDLK_KP_MINUS,    WKC_NUM_MINUS),
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4300
diff changeset
   275
	AS(SDLK_KP_PLUS,     WKC_NUM_PLUS),
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4300
diff changeset
   276
	AS(SDLK_KP_ENTER,    WKC_NUM_ENTER),
7806
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7666
diff changeset
   277
	AS(SDLK_KP_PERIOD,   WKC_NUM_DECIMAL),
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7666
diff changeset
   278
7807
81a0f019daa2 (svn r10663) -Fix r10662: bad me, didn't comply with coding style, as penalty I updated the surrounding code to comply with coding style too; I will never do it again (I hope :p)
truelight
parents: 7806
diff changeset
   279
	/* Other non-letter keys */
7806
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7666
diff changeset
   280
	AS(SDLK_SLASH,        WKC_SLASH),
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7666
diff changeset
   281
	AS(SDLK_SEMICOLON,    WKC_SEMICOLON),
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7666
diff changeset
   282
	AS(SDLK_EQUALS,       WKC_EQUALS),
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7666
diff changeset
   283
	AS(SDLK_LEFTBRACKET,  WKC_L_BRACKET),
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7666
diff changeset
   284
	AS(SDLK_BACKSLASH,    WKC_BACKSLASH),
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7666
diff changeset
   285
	AS(SDLK_RIGHTBRACKET, WKC_R_BRACKET),
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7666
diff changeset
   286
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7666
diff changeset
   287
	AS(SDLK_QUOTE,   WKC_SINGLEQUOTE),
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7666
diff changeset
   288
	AS(SDLK_COMMA,   WKC_COMMA),
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7666
diff changeset
   289
	AS(SDLK_MINUS,   WKC_MINUS),
65bd17ca1609 (svn r10662) -Add: added 'V' as new shortcut for new viewport (bilbo)
truelight
parents: 7666
diff changeset
   290
	AS(SDLK_PERIOD,  WKC_PERIOD)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
static uint32 ConvertSdlKeyIntoMy(SDL_keysym *sym)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   294
{
2026
02dfa0aa2c2f (svn r2535) Tabs
tron
parents: 1991
diff changeset
   295
	const VkMapping *map;
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   296
	uint key = 0;
4507
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   297
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   298
	for (map = _vk_mapping; map != endof(_vk_mapping); ++map) {
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   299
		if ((uint)(sym->sym - map->vk_from) <= map->vk_count) {
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   300
			key = sym->sym - map->vk_from + map->map_to;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   301
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   302
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   303
	}
129
df1a60bc0d70 (svn r130) Change: hotkey for console is Backquote (the key left to '1', regardless of keyboard layout
dominik
parents: 128
diff changeset
   304
df1a60bc0d70 (svn r130) Change: hotkey for console is Backquote (the key left to '1', regardless of keyboard layout
dominik
parents: 128
diff changeset
   305
	// check scancode for BACKQUOTE key, because we want the key left of "1", not anything else (on non-US keyboards)
810
7c51ba5a4368 (svn r1281) -Fix: the OS/2 is now finished. Fixes:
truelight
parents: 798
diff changeset
   306
#if defined(WIN32) || defined(__OS2__)
5099
fe33b77e1b66 (svn r7170) -Fix: [sdl] Non-working console toggle for some keyboard layouts. Do not OR the backquote
Darkvater
parents: 5090
diff changeset
   307
	if (sym->scancode == 41) key = WKC_BACKQUOTE;
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   308
#elif defined(__APPLE__)
5099
fe33b77e1b66 (svn r7170) -Fix: [sdl] Non-working console toggle for some keyboard layouts. Do not OR the backquote
Darkvater
parents: 5090
diff changeset
   309
	if (sym->scancode == 10) key = WKC_BACKQUOTE;
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   310
#elif defined(__MORPHOS__)
5099
fe33b77e1b66 (svn r7170) -Fix: [sdl] Non-working console toggle for some keyboard layouts. Do not OR the backquote
Darkvater
parents: 5090
diff changeset
   311
	if (sym->scancode == 0)  key = WKC_BACKQUOTE;  // yes, that key is code '0' under MorphOS :)
435
62863eb5148a (svn r637) Add keycode for the key to open the console on BeOS
tron
parents: 424
diff changeset
   312
#elif defined(__BEOS__)
5099
fe33b77e1b66 (svn r7170) -Fix: [sdl] Non-working console toggle for some keyboard layouts. Do not OR the backquote
Darkvater
parents: 5090
diff changeset
   313
	if (sym->scancode == 17) key = WKC_BACKQUOTE;
570
7506629cb749 (svn r981) SunOS: fixed the hotkey for console (Oskar)
bjarni
parents: 543
diff changeset
   314
#elif defined(__SVR4) && defined(__sun)
5099
fe33b77e1b66 (svn r7170) -Fix: [sdl] Non-working console toggle for some keyboard layouts. Do not OR the backquote
Darkvater
parents: 5090
diff changeset
   315
	if (sym->scancode == 60) key = WKC_BACKQUOTE;
fe33b77e1b66 (svn r7170) -Fix: [sdl] Non-working console toggle for some keyboard layouts. Do not OR the backquote
Darkvater
parents: 5090
diff changeset
   316
	if (sym->scancode == 49) key = WKC_BACKSPACE;
1810
bf33a29287e5 (svn r2314) - Feature: [ 1187490 ] Patches for building on IRIX (jgilje)
Darkvater
parents: 1808
diff changeset
   317
#elif defined(__sgi__)
5099
fe33b77e1b66 (svn r7170) -Fix: [sdl] Non-working console toggle for some keyboard layouts. Do not OR the backquote
Darkvater
parents: 5090
diff changeset
   318
	if (sym->scancode == 22) key = WKC_BACKQUOTE;
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: 129
diff changeset
   319
#else
5099
fe33b77e1b66 (svn r7170) -Fix: [sdl] Non-working console toggle for some keyboard layouts. Do not OR the backquote
Darkvater
parents: 5090
diff changeset
   320
	if (sym->scancode == 49) key = WKC_BACKQUOTE;
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: 129
diff changeset
   321
#endif
572
e0a2654c186f (svn r983) SunOS: fixed backspace key (Oskar)
bjarni
parents: 570
diff changeset
   322
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
	// META are the command keys on mac
4507
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   324
	if (sym->mod & KMOD_META)  key |= WKC_META;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
	if (sym->mod & KMOD_SHIFT) key |= WKC_SHIFT;
4507
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   326
	if (sym->mod & KMOD_CTRL)  key |= WKC_CTRL;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   327
	if (sym->mod & KMOD_ALT)   key |= WKC_ALT;
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   328
	// these two lines really help porting hotkey combos. Uncomment to use -- Bjarni
4507
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   329
#if 0
5568
75f13d7bfaed (svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents: 5217
diff changeset
   330
	DEBUG(driver, 0, "Scancode character pressed %u", sym->scancode);
75f13d7bfaed (svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents: 5217
diff changeset
   331
	DEBUG(driver, 0, "Unicode character pressed %u", sym->unicode);
4507
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   332
#endif
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   333
	return (key << 16) + sym->unicode;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   334
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   335
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   336
static int PollEvent()
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   337
{
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   338
	SDL_Event ev;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   339
4507
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   340
	if (!SDL_CALL SDL_PollEvent(&ev)) return -2;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   341
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   342
	switch (ev.type) {
4507
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   343
		case SDL_MOUSEMOTION:
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   344
			if (_cursor.fix_at) {
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   345
				int dx = ev.motion.x - _cursor.pos.x;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   346
				int dy = ev.motion.y - _cursor.pos.y;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   347
				if (dx != 0 || dy != 0) {
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   348
					_cursor.delta.x += dx;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   349
					_cursor.delta.y += dy;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   350
					SDL_CALL SDL_WarpMouse(_cursor.pos.x, _cursor.pos.y);
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   351
				}
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   352
			} else {
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   353
				_cursor.delta.x = ev.motion.x - _cursor.pos.x;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   354
				_cursor.delta.y = ev.motion.y - _cursor.pos.y;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   355
				_cursor.pos.x = ev.motion.x;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   356
				_cursor.pos.y = ev.motion.y;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   357
				_cursor.dirty = true;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   358
			}
5090
8907f67c2c15 (svn r7157) -Fix [FS#221, SF1168820]: Some mouse events possibly lost under high CPU load, handle
Darkvater
parents: 5089
diff changeset
   359
			HandleMouseEvents();
4507
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   360
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
4507
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   362
		case SDL_MOUSEBUTTONDOWN:
4508
645368259e79 (svn r6293) -Codechange: Simply use KMOD_CTRL instead of KMOD_LCTRL | KMOD_RCTRL, same for KMOD_SHIFT
tron
parents: 4507
diff changeset
   363
			if (_rightclick_emulate && SDL_CALL SDL_GetModState() & KMOD_CTRL) {
4507
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   364
				ev.button.button = SDL_BUTTON_RIGHT;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   365
			}
3312
593789444b01 (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: 2952
diff changeset
   366
4507
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   367
			switch (ev.button.button) {
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   368
				case SDL_BUTTON_LEFT:
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   369
					_left_button_down = true;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   370
					break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   371
4507
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   372
				case SDL_BUTTON_RIGHT:
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   373
					_right_button_down = true;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   374
					_right_button_clicked = true;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   375
					break;
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: 1509
diff changeset
   376
4507
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   377
				case SDL_BUTTON_WHEELUP:   _cursor.wheel--; break;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   378
				case SDL_BUTTON_WHEELDOWN: _cursor.wheel++; break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   379
4507
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   380
				default: break;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   381
			}
5090
8907f67c2c15 (svn r7157) -Fix [FS#221, SF1168820]: Some mouse events possibly lost under high CPU load, handle
Darkvater
parents: 5089
diff changeset
   382
			HandleMouseEvents();
4507
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   383
			break;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   384
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   385
		case SDL_MOUSEBUTTONUP:
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   386
			if (_rightclick_emulate) {
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   387
				_right_button_down = false;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   388
				_left_button_down = false;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   389
				_left_button_clicked = false;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   390
			} else if (ev.button.button == SDL_BUTTON_LEFT) {
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   391
				_left_button_down = false;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   392
				_left_button_clicked = false;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   393
			} else if (ev.button.button == SDL_BUTTON_RIGHT) {
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   394
				_right_button_down = false;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   395
			}
5090
8907f67c2c15 (svn r7157) -Fix [FS#221, SF1168820]: Some mouse events possibly lost under high CPU load, handle
Darkvater
parents: 5089
diff changeset
   396
			HandleMouseEvents();
4507
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   397
			break;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   398
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   399
		case SDL_ACTIVEEVENT:
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   400
			if (!(ev.active.state & SDL_APPMOUSEFOCUS)) break;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   401
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   402
			if (ev.active.gain) { // mouse entered the window, enable cursor
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   403
				_cursor.in_window = true;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   404
			} else {
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   405
				UndrawMouseCursor(); // mouse left the window, undraw cursor
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   406
				_cursor.in_window = false;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   407
			}
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   408
			break;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   409
4548
23b56455df33 (svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents: 4536
diff changeset
   410
		case SDL_QUIT: HandleExitGameRequest(); break;
4507
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   411
4548
23b56455df33 (svn r6380) -Codechange: unify all ways to quit OTTD.
rubidium
parents: 4536
diff changeset
   412
		case SDL_KEYDOWN: /* Toggle full-screen on ALT + ENTER/F */
4507
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   413
			if ((ev.key.keysym.mod & (KMOD_ALT | KMOD_META)) &&
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   414
					(ev.key.keysym.sym == SDLK_RETURN || ev.key.keysym.sym == SDLK_f)) {
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   415
				ToggleFullScreen(!_fullscreen);
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   416
			} else {
5086
99e0b202b9fb (svn r7153) -Fix [FS#279]: Some keyboard events possibly lost under high CPU load, handle
Darkvater
parents: 5015
diff changeset
   417
				HandleKeypress(ConvertSdlKeyIntoMy(&ev.key.keysym));
4507
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   418
			}
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   419
			break;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   420
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   421
		case SDL_VIDEORESIZE: {
8418
b49fc6be1ab9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 7950
diff changeset
   422
			int w = Clamp(ev.resize.w, 64, MAX_SCREEN_WIDTH);
b49fc6be1ab9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 7950
diff changeset
   423
			int h = Clamp(ev.resize.h, 64, MAX_SCREEN_HEIGHT);
4507
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   424
			ChangeResInGame(w, h);
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   425
			break;
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   426
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   427
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   428
	return -1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   429
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   430
7666
a5fccd76176a (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents: 7515
diff changeset
   431
const char *VideoDriver_SDL::Start(const char * const *parm)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   432
{
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   433
	char buf[30];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   434
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   435
	const char *s = SdlOpen(SDL_INIT_VIDEO);
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   436
	if (s != NULL) return s;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   437
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   438
	SDL_CALL SDL_VideoDriverName(buf, 30);
5568
75f13d7bfaed (svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents: 5217
diff changeset
   439
	DEBUG(driver, 1, "SDL: using driver '%s'", buf);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   440
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   441
	GetVideoModes();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   442
	CreateMainSurface(_cur_resolution[0], _cur_resolution[1]);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   443
	MarkWholeScreenDirty();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   444
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   445
	SDL_CALL SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   446
	SDL_CALL SDL_EnableUNICODE(1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   447
	return NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   448
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   449
7666
a5fccd76176a (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents: 7515
diff changeset
   450
void VideoDriver_SDL::Stop()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   451
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   452
	SdlClose(SDL_INIT_VIDEO);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   453
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   454
7666
a5fccd76176a (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents: 7515
diff changeset
   455
void VideoDriver_SDL::MainLoop()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   456
{
5832
28aa8ad3bb04 (svn r8028) -Fix: overflow of ticks was not handled properly, possibly resulting a non-reacting gameserver/gameclient.
rubidium
parents: 5726
diff changeset
   457
	uint32 cur_ticks = SDL_CALL SDL_GetTicks();
7514
98a024616010 (svn r10276) -Codechange: made a counter based on milliseconds and independent of the game-state to base double-click and TGP Generation Process on
truelight
parents: 7495
diff changeset
   458
	uint32 last_cur_ticks = cur_ticks;
5832
28aa8ad3bb04 (svn r8028) -Fix: overflow of ticks was not handled properly, possibly resulting a non-reacting gameserver/gameclient.
rubidium
parents: 5726
diff changeset
   459
	uint32 next_tick = cur_ticks + 30;
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   460
	uint32 pal_tick = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   461
	uint32 mod;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   462
	int numkeys;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   463
	Uint8 *keys;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   464
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   465
	for (;;) {
5832
28aa8ad3bb04 (svn r8028) -Fix: overflow of ticks was not handled properly, possibly resulting a non-reacting gameserver/gameclient.
rubidium
parents: 5726
diff changeset
   466
		uint32 prev_cur_ticks = cur_ticks; // to check for wrapping
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   467
		InteractiveRandom(); // randomness
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   468
5089
9d290a04d79c (svn r7156) -Codechange: Remove obsolete variable, localize global variable, use GB and change logic
Darkvater
parents: 5086
diff changeset
   469
		while (PollEvent() == -1) {}
2228
7014d372374f (svn r2748) Remove unused cruft from the main loop
tron
parents: 2226
diff changeset
   470
		if (_exit_game) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   471
18
7428dd7c5732 (svn r19) SDL performance fix fo palette animation and mouse jumping (jirif)
dominik
parents: 0
diff changeset
   472
		mod = SDL_CALL SDL_GetModState();
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   473
		keys = SDL_CALL SDL_GetKeyState(&numkeys);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   474
#if defined(_DEBUG)
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   475
		if (_shift_pressed)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   476
#else
5712
1cf8721b1882 (svn r7727) -Fix (FS#498): sometimes ALT-TAB could trigger the fast forward.
rubidium
parents: 5568
diff changeset
   477
		/* Speedup when pressing tab, except when using ALT+TAB
1cf8721b1882 (svn r7727) -Fix (FS#498): sometimes ALT-TAB could trigger the fast forward.
rubidium
parents: 5568
diff changeset
   478
		 * to switch to another application */
1cf8721b1882 (svn r7727) -Fix (FS#498): sometimes ALT-TAB could trigger the fast forward.
rubidium
parents: 5568
diff changeset
   479
		if (keys[SDLK_TAB] && (mod & KMOD_ALT) == 0)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   480
#endif
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   481
		{
4536
f13408cba18f (svn r6365) -Cleanup: remove IsGeneratingWorld calls that are either not called or have no effect.
rubidium
parents: 4508
diff changeset
   482
			if (!_networking && _game_mode != GM_MENU) _fast_forward |= 2;
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   483
		} else if (_fast_forward & 2) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   484
			_fast_forward = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   485
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   486
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   487
		cur_ticks = SDL_CALL SDL_GetTicks();
6557
8381016f71f3 (svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight
parents: 6314
diff changeset
   488
		if (cur_ticks >= next_tick || (_fast_forward && !_pause_game) || cur_ticks < prev_cur_ticks) {
7515
46295cf47928 (svn r10278) -Fix r10276: make the _realtime_tick less demanding on the CPU
truelight
parents: 7514
diff changeset
   489
			_realtime_tick += cur_ticks - last_cur_ticks;
46295cf47928 (svn r10278) -Fix r10276: make the _realtime_tick less demanding on the CPU
truelight
parents: 7514
diff changeset
   490
			last_cur_ticks = cur_ticks;
5832
28aa8ad3bb04 (svn r8028) -Fix: overflow of ticks was not handled properly, possibly resulting a non-reacting gameserver/gameclient.
rubidium
parents: 5726
diff changeset
   491
			next_tick = cur_ticks + 30;
18
7428dd7c5732 (svn r19) SDL performance fix fo palette animation and mouse jumping (jirif)
dominik
parents: 0
diff changeset
   492
9082
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8929
diff changeset
   493
			bool old_ctrl_pressed = _ctrl_pressed;
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8929
diff changeset
   494
4508
645368259e79 (svn r6293) -Codechange: Simply use KMOD_CTRL instead of KMOD_LCTRL | KMOD_RCTRL, same for KMOD_SHIFT
tron
parents: 4507
diff changeset
   495
			_ctrl_pressed  = !!(mod & KMOD_CTRL);
645368259e79 (svn r6293) -Codechange: Simply use KMOD_CTRL instead of KMOD_LCTRL | KMOD_RCTRL, same for KMOD_SHIFT
tron
parents: 4507
diff changeset
   496
			_shift_pressed = !!(mod & KMOD_SHIFT);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   497
18
7428dd7c5732 (svn r19) SDL performance fix fo palette animation and mouse jumping (jirif)
dominik
parents: 0
diff changeset
   498
			// determine which directional keys are down
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   499
			_dirkeys =
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   500
				(keys[SDLK_LEFT]  ? 1 : 0) |
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   501
				(keys[SDLK_UP]    ? 2 : 0) |
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   502
				(keys[SDLK_RIGHT] ? 4 : 0) |
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   503
				(keys[SDLK_DOWN]  ? 8 : 0);
9082
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8929
diff changeset
   504
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8929
diff changeset
   505
			if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged();
8217cb013e23 (svn r12167) -Feature(tte): change colour of autorail and autoroad selection when Ctrl is pressed
smatz
parents: 8929
diff changeset
   506
18
7428dd7c5732 (svn r19) SDL performance fix fo palette animation and mouse jumping (jirif)
dominik
parents: 0
diff changeset
   507
			GameLoop();
7428dd7c5732 (svn r19) SDL performance fix fo palette animation and mouse jumping (jirif)
dominik
parents: 0
diff changeset
   508
7374
54c06f06ecc8 (svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents: 7111
diff changeset
   509
			_screen.dst_ptr = _sdl_screen->pixels;
18
7428dd7c5732 (svn r19) SDL performance fix fo palette animation and mouse jumping (jirif)
dominik
parents: 0
diff changeset
   510
			UpdateWindows();
423
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   511
			if (++pal_tick > 4) {
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   512
				CheckPaletteAnim();
9e28d68fa333 (svn r621) Merge r450 to trunk:
tron
parents: 410
diff changeset
   513
				pal_tick = 1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   514
			}
2026
02dfa0aa2c2f (svn r2535) Tabs
tron
parents: 1991
diff changeset
   515
			DrawSurfaceToScreen();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   516
		} else {
18
7428dd7c5732 (svn r19) SDL performance fix fo palette animation and mouse jumping (jirif)
dominik
parents: 0
diff changeset
   517
			SDL_CALL SDL_Delay(1);
7374
54c06f06ecc8 (svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents: 7111
diff changeset
   518
			_screen.dst_ptr = _sdl_screen->pixels;
7950
3d3ed007127a (svn r10932) -Codechange: replace "text" with "chat" for the chat related function and variables.
rubidium
parents: 7807
diff changeset
   519
			DrawChatMessage();
18
7428dd7c5732 (svn r19) SDL performance fix fo palette animation and mouse jumping (jirif)
dominik
parents: 0
diff changeset
   520
			DrawMouseCursor();
7428dd7c5732 (svn r19) SDL performance fix fo palette animation and mouse jumping (jirif)
dominik
parents: 0
diff changeset
   521
			DrawSurfaceToScreen();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   522
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   523
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   524
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   525
7666
a5fccd76176a (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents: 7515
diff changeset
   526
bool VideoDriver_SDL::ChangeResolution(int w, int h)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   527
{
2169
f6d2ec3ecd5b (svn r2683) Remove redundant function call propagate return value
tron
parents: 2163
diff changeset
   528
	return CreateMainSurface(w, h);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   529
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   530
8667
c916a5375166 (svn r11734) -Change: Allow ToggleFullScreen to return the result of the operation' attempt. Previously, only visual clues were available.
belugas
parents: 8627
diff changeset
   531
bool VideoDriver_SDL::ToggleFullscreen(bool fullscreen)
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: 1509
diff changeset
   532
{
7666
a5fccd76176a (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents: 7515
diff changeset
   533
	_fullscreen = fullscreen;
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: 1509
diff changeset
   534
	GetVideoModes(); // get the list of available video modes
7666
a5fccd76176a (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents: 7515
diff changeset
   535
	if (_num_resolutions == 0 || !this->ChangeResolution(_cur_resolution[0], _cur_resolution[1])) {
4507
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   536
		// switching resolution failed, put back full_screen to original status
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   537
		_fullscreen ^= true;
8667
c916a5375166 (svn r11734) -Change: Allow ToggleFullScreen to return the result of the operation' attempt. Previously, only visual clues were available.
belugas
parents: 8627
diff changeset
   538
		return false;
4507
7a53f49bfec4 (svn r6292) -Cleanup: Indentation, bracing, etc.
tron
parents: 4501
diff changeset
   539
	}
8667
c916a5375166 (svn r11734) -Change: Allow ToggleFullScreen to return the result of the operation' attempt. Previously, only visual clues were available.
belugas
parents: 8627
diff changeset
   540
	return true;
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: 1509
diff changeset
   541
}
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: 1509
diff changeset
   542
6314
f738bcf05ad6 (svn r8691) -Cleanup: Some proper #endif comments for sound/music/video files, and a little elimination of magic numbers in Win32SoundStart
Darkvater
parents: 5838
diff changeset
   543
#endif /* WITH_SDL */