src/music_gui.cpp
author rubidium
Fri, 04 Jul 2008 19:00:11 +0000
changeset 11118 f66e0a4ce878
parent 10641 13148f508e6d
permissions -rw-r--r--
(svn r13676) -Fix [FS#2126]: inactive companies from old (TTD) saves could be marked active in some cases, which then loads garbage in their statistics and such.
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
10429
1b99254f9607 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 8929
diff changeset
     3
/** @file music_gui.cpp GUI for the music playback. */
6527
f584ab6d87f8 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6450
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1884
diff changeset
     6
#include "openttd.h"
7425
350b9265b7a2 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents: 6987
diff changeset
     7
#include "fileio.h"
2159
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2155
diff changeset
     8
#include "variables.h"
4120
90e678fd7d8d (svn r5464) [Behaviour Fix] : When starting the game, the system will now verify the presence of music files in gm forlder.
belugas
parents: 3052
diff changeset
     9
#include "music.h"
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: 7425
diff changeset
    10
#include "music/music_driver.hpp"
8602
9e75e594a068 (svn r11667) -Codechange: split window.h into a header that defines some 'global' window related types, on that defined 'global' window functions and one that defines functions and types only used by *_gui.cpps.
rubidium
parents: 8493
diff changeset
    11
#include "window_gui.h"
8610
17cc343a23dd (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8609
diff changeset
    12
#include "strings_func.h"
8627
448ebf3a8291 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8617
diff changeset
    13
#include "window_func.h"
8653
a83f7a536919 (svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents: 8627
diff changeset
    14
#include "sound_func.h"
8720
4e60c30e2006 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8653
diff changeset
    15
#include "gfx_func.h"
4e60c30e2006 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8653
diff changeset
    16
#include "core/math_func.hpp"
8929
a8732ed52252 (svn r12003) -Codechange: don't declare InteractiveRandom[Range] in multiple places.
rubidium
parents: 8760
diff changeset
    17
#include "core/random_func.hpp"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    18
8760
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8720
diff changeset
    19
#include "table/strings.h"
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8720
diff changeset
    20
#include "table/sprites.h"
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8720
diff changeset
    21
2155
aa88ed6fe2e3 (svn r2665) Move some variables, which are only used by music_gui.c, there
tron
parents: 2140
diff changeset
    22
static byte _music_wnd_cursong;
aa88ed6fe2e3 (svn r2665) Move some variables, which are only used by music_gui.c, there
tron
parents: 2140
diff changeset
    23
static bool _song_is_active;
4120
90e678fd7d8d (svn r5464) [Behaviour Fix] : When starting the game, the system will now verify the presence of music files in gm forlder.
belugas
parents: 3052
diff changeset
    24
static byte _cur_playlist[NUM_SONGS_PLAYLIST];
2155
aa88ed6fe2e3 (svn r2665) Move some variables, which are only used by music_gui.c, there
tron
parents: 2140
diff changeset
    25
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    26
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    28
static byte _playlist_all[] = {
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2630
diff changeset
    29
	1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 0
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    30
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    31
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
static byte _playlist_old_style[] = {
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2630
diff changeset
    33
	1, 8, 2, 9, 14, 15, 19, 13, 0
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
};
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
static byte _playlist_new_style[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
	6, 11, 10, 17, 21, 18, 5, 0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
static byte _playlist_ezy_street[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
	12, 7, 16, 3, 20, 4, 0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    42
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
static byte * const _playlists[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
	_playlist_all,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
	_playlist_old_style,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
	_playlist_new_style,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
	_playlist_ezy_street,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
	msf.custom_1,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
	msf.custom_2,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6527
diff changeset
    53
static void SkipToPrevSong()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
	byte *b = _cur_playlist;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
	byte *p = b;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
	byte t;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
4867
68d23729ca86 (svn r6793) -Fix(5464): When checking items on an array, make sure to respect boundaries(jez).
belugas
parents: 4719
diff changeset
    59
	if (b[0] == 0) return; // empty playlist
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    60
4867
68d23729ca86 (svn r6793) -Fix(5464): When checking items on an array, make sure to respect boundaries(jez).
belugas
parents: 4719
diff changeset
    61
	do p++; while (p[0] != 0); // find the end
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
4867
68d23729ca86 (svn r6793) -Fix(5464): When checking items on an array, make sure to respect boundaries(jez).
belugas
parents: 4719
diff changeset
    63
	t = *--p; // and copy the bytes
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
	while (p != b) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
		p--;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
		p[1] = p[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
	*b = t;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
	_song_is_active = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6527
diff changeset
    73
static void SkipToNextSong()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
{
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2630
diff changeset
    75
	byte* b = _cur_playlist;
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2630
diff changeset
    76
	byte t;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2630
diff changeset
    78
	t = b[0];
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2630
diff changeset
    79
	if (t != 0) {
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2630
diff changeset
    80
		while (b[1] != 0) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
			b[0] = b[1];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
			b++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
		b[0] = t;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
	_song_is_active = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
static void MusicVolumeChanged(byte new_vol)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
{
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: 7425
diff changeset
    92
	_music_driver->SetVolume(new_vol);
0
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
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6527
diff changeset
    95
static void DoPlaySong()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
{
7425
350b9265b7a2 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents: 6987
diff changeset
    97
	char filename[MAX_PATH];
350b9265b7a2 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents: 6987
diff changeset
    98
	FioFindFullPath(filename, lengthof(filename), GM_DIR,
350b9265b7a2 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents: 6987
diff changeset
    99
			origin_songs_specs[_music_wnd_cursong - 1].filename);
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: 7425
diff changeset
   100
	_music_driver->PlaySong(filename);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6527
diff changeset
   103
static void DoStopMusic()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
{
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: 7425
diff changeset
   105
	_music_driver->StopSong();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6527
diff changeset
   108
static void SelectSongToPlay()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
{
2247
fe3f618ebcae (svn r2767) -Fix: fixed potential mem-leak
truelight
parents: 2186
diff changeset
   110
	uint i = 0;
4120
90e678fd7d8d (svn r5464) [Behaviour Fix] : When starting the game, the system will now verify the presence of music files in gm forlder.
belugas
parents: 3052
diff changeset
   111
	uint j = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
2247
fe3f618ebcae (svn r2767) -Fix: fixed potential mem-leak
truelight
parents: 2186
diff changeset
   113
	memset(_cur_playlist, 0, sizeof(_cur_playlist));
1884
ae1d6213c6dd (svn r2390) - Codechange: Fix some warnings on GCC 4.0.0
hackykid
parents: 1724
diff changeset
   114
	do {
7425
350b9265b7a2 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents: 6987
diff changeset
   115
		/* We are now checking for the existence of that file prior
350b9265b7a2 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents: 6987
diff changeset
   116
		 * to add it to the list of available songs */
350b9265b7a2 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents: 6987
diff changeset
   117
		if (FioCheckFileExists(origin_songs_specs[_playlists[msf.playlist][i]].filename, GM_DIR)) {
350b9265b7a2 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents: 6987
diff changeset
   118
			_cur_playlist[j] = _playlists[msf.playlist][i];
350b9265b7a2 (svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents: 6987
diff changeset
   119
			j++;
4120
90e678fd7d8d (svn r5464) [Behaviour Fix] : When starting the game, the system will now verify the presence of music files in gm forlder.
belugas
parents: 3052
diff changeset
   120
		}
2247
fe3f618ebcae (svn r2767) -Fix: fixed potential mem-leak
truelight
parents: 2186
diff changeset
   121
	} while (_playlists[msf.playlist][i++] != 0 && i < lengthof(_cur_playlist) - 1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
8240
453180ea6622 (svn r11281) -Revert(r11259): the problem was not there. In fact, it made it so that no more music were allowed on intro.
belugas
parents: 8220
diff changeset
   123
	/* Do not shuffle when on the intro-start window, as the song to play has to be the original TTD Theme*/
453180ea6622 (svn r11281) -Revert(r11259): the problem was not there. In fact, it made it so that no more music were allowed on intro.
belugas
parents: 8220
diff changeset
   124
	if (msf.shuffle && _game_mode != GM_MENU) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   125
		i = 500;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   126
		do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
			uint32 r = InteractiveRandom();
2140
d708eb80ab8b (svn r2650) Convert many explicit shifts+ands to extract bits to invocations of GB - should be a bit nicer to read
tron
parents: 2133
diff changeset
   128
			byte *a = &_cur_playlist[GB(r, 0, 5)];
d708eb80ab8b (svn r2650) Convert many explicit shifts+ands to extract bits to invocations of GB - should be a bit nicer to read
tron
parents: 2133
diff changeset
   129
			byte *b = &_cur_playlist[GB(r, 8, 5)];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   130
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
			if (*a != 0 && *b != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
				byte t = *a;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
				*a = *b;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   134
				*b = t;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   136
		} while (--i);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   137
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   139
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6527
diff changeset
   140
static void StopMusic()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   141
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   142
	_music_wnd_cursong = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
	DoStopMusic();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   144
	_song_is_active = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   145
	InvalidateWindowWidget(WC_MUSIC_WINDOW, 0, 9);
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
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6527
diff changeset
   148
static void PlayPlaylistSong()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
	if (_cur_playlist[0] == 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
		SelectSongToPlay();
4867
68d23729ca86 (svn r6793) -Fix(5464): When checking items on an array, make sure to respect boundaries(jez).
belugas
parents: 4719
diff changeset
   152
		/* if there is not songs in the playlist, it may indicate
68d23729ca86 (svn r6793) -Fix(5464): When checking items on an array, make sure to respect boundaries(jez).
belugas
parents: 4719
diff changeset
   153
		 * no file on the gm folder, or even no gm folder.
68d23729ca86 (svn r6793) -Fix(5464): When checking items on an array, make sure to respect boundaries(jez).
belugas
parents: 4719
diff changeset
   154
		 * Stop the playback, then */
4120
90e678fd7d8d (svn r5464) [Behaviour Fix] : When starting the game, the system will now verify the presence of music files in gm forlder.
belugas
parents: 3052
diff changeset
   155
		if (_cur_playlist[0] == 0) {
90e678fd7d8d (svn r5464) [Behaviour Fix] : When starting the game, the system will now verify the presence of music files in gm forlder.
belugas
parents: 3052
diff changeset
   156
			_song_is_active = false;
90e678fd7d8d (svn r5464) [Behaviour Fix] : When starting the game, the system will now verify the presence of music files in gm forlder.
belugas
parents: 3052
diff changeset
   157
			_music_wnd_cursong = 0;
90e678fd7d8d (svn r5464) [Behaviour Fix] : When starting the game, the system will now verify the presence of music files in gm forlder.
belugas
parents: 3052
diff changeset
   158
			msf.playing = false;
90e678fd7d8d (svn r5464) [Behaviour Fix] : When starting the game, the system will now verify the presence of music files in gm forlder.
belugas
parents: 3052
diff changeset
   159
			return;
90e678fd7d8d (svn r5464) [Behaviour Fix] : When starting the game, the system will now verify the presence of music files in gm forlder.
belugas
parents: 3052
diff changeset
   160
		}
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
	_music_wnd_cursong = _cur_playlist[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
	DoPlaySong();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   164
	_song_is_active = true;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   165
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
	InvalidateWindowWidget(WC_MUSIC_WINDOW, 0, 9);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6527
diff changeset
   169
void ResetMusic()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   170
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   171
	_music_wnd_cursong = 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
	DoPlaySong();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   173
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   174
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6527
diff changeset
   175
void MusicLoop()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
{
3052
95e4eaf303d5 (svn r3641) - Rename MusicFilesettings 'btn_down' to more sensible 'playing'
Darkvater
parents: 2952
diff changeset
   177
	if (!msf.playing && _song_is_active) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   178
		StopMusic();
3052
95e4eaf303d5 (svn r3641) - Rename MusicFilesettings 'btn_down' to more sensible 'playing'
Darkvater
parents: 2952
diff changeset
   179
	} else if (msf.playing && !_song_is_active) {
8240
453180ea6622 (svn r11281) -Revert(r11259): the problem was not there. In fact, it made it so that no more music were allowed on intro.
belugas
parents: 8220
diff changeset
   180
		PlayPlaylistSong();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
4120
90e678fd7d8d (svn r5464) [Behaviour Fix] : When starting the game, the system will now verify the presence of music files in gm forlder.
belugas
parents: 3052
diff changeset
   183
	if (!_song_is_active) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
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: 7425
diff changeset
   185
	if (!_music_driver->IsSongPlaying()) {
1724
f2df13e9b628 (svn r2228) - Fix: [ 1188986 ] Song in main menu screen should loop when it ends.
Darkvater
parents: 1608
diff changeset
   186
		if (_game_mode != GM_MENU) {
f2df13e9b628 (svn r2228) - Fix: [ 1188986 ] Song in main menu screen should loop when it ends.
Darkvater
parents: 1608
diff changeset
   187
			StopMusic();
f2df13e9b628 (svn r2228) - Fix: [ 1188986 ] Song in main menu screen should loop when it ends.
Darkvater
parents: 1608
diff changeset
   188
			SkipToNextSong();
f2df13e9b628 (svn r2228) - Fix: [ 1188986 ] Song in main menu screen should loop when it ends.
Darkvater
parents: 1608
diff changeset
   189
			PlayPlaylistSong();
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2630
diff changeset
   190
		} else {
1724
f2df13e9b628 (svn r2228) - Fix: [ 1188986 ] Song in main menu screen should loop when it ends.
Darkvater
parents: 1608
diff changeset
   191
			ResetMusic();
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2630
diff changeset
   192
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   193
	}
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
10606
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   196
struct MusicTrackSelectionWindow : public Window {
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   197
private:
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   198
	enum MusicTrackSelectionWidgets {
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   199
		MTSW_CLOSE,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   200
		MTSW_CAPTION,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   201
		MTSW_BACKGROUND,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   202
		MTSW_LIST_LEFT,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   203
		MTSW_LIST_RIGHT,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   204
		MTSW_ALL,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   205
		MTSW_OLD,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   206
		MTSW_NEW,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   207
		MTSW_EZY,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   208
		MTSW_CUSTOM1,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   209
		MTSW_CUSTOM2,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   210
		MTSW_CLEAR,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   211
		MTSW_SAVE,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   212
	};
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   213
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   214
public:
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   215
	MusicTrackSelectionWindow(const WindowDesc *desc, WindowNumber number) : Window(desc, number)
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   216
	{
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   217
		this->FindWindowPlacementAndResize(desc);
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   218
	}
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   219
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   220
	virtual void OnPaint()
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   221
	{
2630
35249d2ded3e (svn r3172) static, const
tron
parents: 2247
diff changeset
   222
		const byte* p;
2133
098c9da8292e (svn r2643) Get rid of some unnecessary casts
tron
parents: 1938
diff changeset
   223
		uint i;
098c9da8292e (svn r2643) Get rid of some unnecessary casts
tron
parents: 1938
diff changeset
   224
		int y;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   225
10606
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   226
		this->SetWidgetDisabledState(MTSW_CLEAR, msf.playlist <= 3);
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   227
		this->LowerWidget(MTSW_LIST_LEFT);
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   228
		this->LowerWidget(MTSW_LIST_RIGHT);
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   229
		this->DrawWidgets();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   230
6987
b0f13039bda2 (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6573
diff changeset
   231
		GfxFillRect(3, 23, 3 + 177, 23 + 191, 0);
b0f13039bda2 (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6573
diff changeset
   232
		GfxFillRect(251, 23, 251 + 177, 23 + 191, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   233
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8240
diff changeset
   234
		DrawStringCentered(92, 15, STR_01EE_TRACK_INDEX, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   236
		SetDParam(0, STR_01D5_ALL + msf.playlist);
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8240
diff changeset
   237
		DrawStringCentered(340, 15, STR_01EF_PROGRAM, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   238
2133
098c9da8292e (svn r2643) Get rid of some unnecessary casts
tron
parents: 1938
diff changeset
   239
		for (i = 1; i <= NUM_SONGS_AVAILABLE; i++) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   240
			SetDParam(0, i);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   241
			SetDParam(2, i);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   242
			SetDParam(1, SPECSTR_SONGNAME);
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8240
diff changeset
   243
			DrawString(4, 23 + (i - 1) * 6, (i < 10) ? STR_01EC_0 : STR_01ED, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   244
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   245
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2630
diff changeset
   246
		for (i = 0; i != 6; i++) {
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8240
diff changeset
   247
			DrawStringCentered(216, 45 + i * 8, STR_01D5_ALL + i, (i == msf.playlist) ? TC_WHITE : TC_BLACK);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   248
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   249
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8240
diff changeset
   250
		DrawStringCentered(216, 45 + 8 * 6 + 16, STR_01F0_CLEAR, TC_FROMSTRING);
4468
fb18502e2c12 (svn r6253) Comment out code with #if 0, not //. Join statements which needlessly span many lines into fewer lines
tron
parents: 4432
diff changeset
   251
#if 0
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8240
diff changeset
   252
		DrawStringCentered(216, 45 + 8 * 6 + 16 * 2, STR_01F1_SAVE, TC_FROMSTRING);
4468
fb18502e2c12 (svn r6253) Comment out code with #if 0, not //. Join statements which needlessly span many lines into fewer lines
tron
parents: 4432
diff changeset
   253
#endif
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   255
		y = 23;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2630
diff changeset
   256
		for (p = _playlists[msf.playlist], i = 0; (i = *p) != 0; p++) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   257
			SetDParam(0, i);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2630
diff changeset
   258
			SetDParam(1, SPECSTR_SONGNAME);
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   259
			SetDParam(2, i);
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8240
diff changeset
   260
			DrawString(252, y, (i < 10) ? STR_01EC_0 : STR_01ED, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   261
			y += 6;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   262
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   263
	}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   264
10606
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   265
	virtual void OnClick(Point pt, int widget)
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   266
	{
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   267
		switch (widget) {
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   268
			case MTSW_LIST_LEFT: { // add to playlist
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   269
				int y = (pt.y - 23) / 6;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   270
				uint i;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   271
				byte *p;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   272
10606
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   273
				if (msf.playlist < 4) return;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   274
				if (!IsInsideMM(y, 0, NUM_SONGS_AVAILABLE)) return;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   275
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   276
				p = _playlists[msf.playlist];
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   277
				for (i = 0; i != NUM_SONGS_PLAYLIST - 1; i++) {
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   278
					if (p[i] == 0) {
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   279
						p[i] = y + 1;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   280
						p[i + 1] = 0;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   281
						this->SetDirty();
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   282
						SelectSongToPlay();
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   283
						break;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   284
					}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
				}
10606
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   286
			} break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   287
10606
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   288
			case MTSW_LIST_RIGHT: { // remove from playlist
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   289
				int y = (pt.y - 23) / 6;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   290
				uint i;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   291
				byte *p;
4120
90e678fd7d8d (svn r5464) [Behaviour Fix] : When starting the game, the system will now verify the presence of music files in gm forlder.
belugas
parents: 3052
diff changeset
   292
10606
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   293
				if (msf.playlist < 4) return;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   294
				if (!IsInsideMM(y, 0, NUM_SONGS_AVAILABLE)) return;
4120
90e678fd7d8d (svn r5464) [Behaviour Fix] : When starting the game, the system will now verify the presence of music files in gm forlder.
belugas
parents: 3052
diff changeset
   295
10606
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   296
				p = _playlists[msf.playlist];
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   297
				for (i = y; i != NUM_SONGS_PLAYLIST - 1; i++) {
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   298
					p[i] = p[i + 1];
4120
90e678fd7d8d (svn r5464) [Behaviour Fix] : When starting the game, the system will now verify the presence of music files in gm forlder.
belugas
parents: 3052
diff changeset
   299
				}
90e678fd7d8d (svn r5464) [Behaviour Fix] : When starting the game, the system will now verify the presence of music files in gm forlder.
belugas
parents: 3052
diff changeset
   300
10606
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   301
				this->SetDirty();
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   302
				SelectSongToPlay();
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   303
			} break;
4120
90e678fd7d8d (svn r5464) [Behaviour Fix] : When starting the game, the system will now verify the presence of music files in gm forlder.
belugas
parents: 3052
diff changeset
   304
10606
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   305
			case MTSW_CLEAR: // clear
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   306
				_playlists[msf.playlist][0] = 0;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   307
				this->SetDirty();
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   308
				StopMusic();
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   309
				SelectSongToPlay();
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   310
				break;
4120
90e678fd7d8d (svn r5464) [Behaviour Fix] : When starting the game, the system will now verify the presence of music files in gm forlder.
belugas
parents: 3052
diff changeset
   311
4432
33631ac88c40 (svn r6195) -Codechange: do not use '//' in '/* ... */' style comments and '/*' or '*/' in '//' style comments.
rubidium
parents: 4344
diff changeset
   312
#if 0
10606
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   313
			case MTSW_SAVE: // save
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   314
				ShowInfo("MusicTrackSelectionWndProc:save not implemented");
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   315
				break;
4432
33631ac88c40 (svn r6195) -Codechange: do not use '//' in '/* ... */' style comments and '/*' or '*/' in '//' style comments.
rubidium
parents: 4344
diff changeset
   316
#endif
4120
90e678fd7d8d (svn r5464) [Behaviour Fix] : When starting the game, the system will now verify the presence of music files in gm forlder.
belugas
parents: 3052
diff changeset
   317
10606
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   318
			case MTSW_ALL: case MTSW_OLD: case MTSW_NEW:
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   319
			case MTSW_EZY: case MTSW_CUSTOM1: case MTSW_CUSTOM2: // set playlist
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   320
				msf.playlist = widget - MTSW_ALL;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   321
				this->SetDirty();
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   322
				InvalidateWindow(WC_MUSIC_WINDOW, 0);
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   323
				StopMusic();
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   324
				SelectSongToPlay();
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   325
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   326
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   327
	}
10606
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   328
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   329
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   330
static const Widget _music_track_selection_widgets[] = {
10606
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   331
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW},                  // MTSW_CLOSE
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   332
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   431,     0,    13, STR_01EB_MUSIC_PROGRAM_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS},        // MTSW_CAPTION
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   333
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   431,    14,   217, 0x0,                              STR_NULL},                               // MTSW_BACKGROUND
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   334
{      WWT_PANEL,   RESIZE_NONE,    14,     2,   181,    22,   215, 0x0,                              STR_01FA_CLICK_ON_MUSIC_TRACK_TO},       // MTSW_LIST_LEFT
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   335
{      WWT_PANEL,   RESIZE_NONE,    14,   250,   429,    22,   215, 0x0,                              STR_CLICK_ON_TRACK_TO_REMOVE},           // MTSW_LIST_RIGHT
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   336
{    WWT_PUSHBTN,   RESIZE_NONE,    14,   186,   245,    44,    51, 0x0,                              STR_01F3_SELECT_ALL_TRACKS_PROGRAM},     // MTSW_ALL
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   337
{    WWT_PUSHBTN,   RESIZE_NONE,    14,   186,   245,    52,    59, 0x0,                              STR_01F4_SELECT_OLD_STYLE_MUSIC},        // MTSW_OLD
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   338
{    WWT_PUSHBTN,   RESIZE_NONE,    14,   186,   245,    60,    67, 0x0,                              STR_01F5_SELECT_NEW_STYLE_MUSIC},        // MTSW_NEW
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   339
{    WWT_PUSHBTN,   RESIZE_NONE,    14,   186,   245,    68,    75, 0x0,                              STR_0330_SELECT_EZY_STREET_STYLE},       // MTSW_EZY
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   340
{    WWT_PUSHBTN,   RESIZE_NONE,    14,   186,   245,    76,    83, 0x0,                              STR_01F6_SELECT_CUSTOM_1_USER_DEFINED},  // MTSW_CUSTOM1
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   341
{    WWT_PUSHBTN,   RESIZE_NONE,    14,   186,   245,    84,    91, 0x0,                              STR_01F7_SELECT_CUSTOM_2_USER_DEFINED},  // MTSW_CUSTOM2
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   342
{    WWT_PUSHBTN,   RESIZE_NONE,    14,   186,   245,   108,   115, 0x0,                              STR_01F8_CLEAR_CURRENT_PROGRAM_CUSTOM1}, // MTSW_CLEAR
4468
fb18502e2c12 (svn r6253) Comment out code with #if 0, not //. Join statements which needlessly span many lines into fewer lines
tron
parents: 4432
diff changeset
   343
#if 0
10606
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   344
{    WWT_PUSHBTN,   RESIZE_NONE,    14,   186,   245,   124,   131, 0x0,                              STR_01F9_SAVE_MUSIC_SETTINGS},           // MTSW_SAVE
4468
fb18502e2c12 (svn r6253) Comment out code with #if 0, not //. Join statements which needlessly span many lines into fewer lines
tron
parents: 4432
diff changeset
   345
#endif
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 0
diff changeset
   346
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   347
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   348
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   349
static const WindowDesc _music_track_selection_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7762
diff changeset
   350
	104, 131, 432, 218, 432, 218,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5838
diff changeset
   351
	WC_MUSIC_TRACK_SELECTION, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   352
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   353
	_music_track_selection_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   354
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   355
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6527
diff changeset
   356
static void ShowMusicTrackSelection()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   357
{
10606
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   358
	AllocateWindowDescFront<MusicTrackSelectionWindow>(&_music_track_selection_desc, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   359
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
10606
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   361
struct MusicWindow : public Window {
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   362
private:
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   363
	enum MusicWidgets {
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   364
		MW_CLOSE,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   365
		MW_CAPTION,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   366
		MW_PREV,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   367
		MW_NEXT,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   368
		MW_STOP,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   369
		MW_PLAY,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   370
		MW_SLIDERS,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   371
		MW_GAUGE,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   372
		MW_BACKGROUND,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   373
		MW_INFO,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   374
		MW_SHUFFLE,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   375
		MW_PROGRAMME,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   376
		MW_ALL,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   377
		MW_OLD,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   378
		MW_NEW,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   379
		MW_EZY,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   380
		MW_CUSTOM1,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   381
		MW_CUSTOM2,
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   382
	};
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   383
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   384
public:
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   385
	MusicWindow(const WindowDesc *desc, WindowNumber number) : Window(desc, number)
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   386
	{
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   387
		this->FindWindowPlacementAndResize(desc);
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   388
	}
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   389
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   390
	virtual void OnPaint()
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   391
	{
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2630
diff changeset
   392
		uint i;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   393
		StringID str;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   394
10606
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   395
		this->RaiseWidget(MW_GAUGE);
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   396
		this->RaiseWidget(MW_INFO);
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   397
		this->DrawWidgets();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   398
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   399
		GfxFillRect(187, 16, 200, 33, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   400
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2630
diff changeset
   401
		for (i = 0; i != 8; i++) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   402
			int color = 0xD0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
			if (i > 4) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
				color = 0xBF;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   405
				if (i > 6) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   406
					color = 0xB8;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   407
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   408
			}
4120
90e678fd7d8d (svn r5464) [Behaviour Fix] : When starting the game, the system will now verify the presence of music files in gm forlder.
belugas
parents: 3052
diff changeset
   409
			GfxFillRect(187, NUM_SONGS_PLAYLIST - i * 2, 200, NUM_SONGS_PLAYLIST - i * 2, color);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   410
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   411
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   412
		GfxFillRect(60, 46, 239, 52, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   413
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2630
diff changeset
   414
		if (_song_is_active == 0 || _music_wnd_cursong == 0) {
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2630
diff changeset
   415
			str = STR_01E3;
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2630
diff changeset
   416
		} else {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   417
			SetDParam(0, _music_wnd_cursong);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2630
diff changeset
   418
			str = (_music_wnd_cursong < 10) ? STR_01E4_0 : STR_01E5;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   419
		}
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8240
diff changeset
   420
		DrawString(62, 46, str, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   421
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
		str = STR_01E6;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   423
		if (_song_is_active != 0 && _music_wnd_cursong != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   424
			str = STR_01E7;
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   425
			SetDParam(0, SPECSTR_SONGNAME);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   426
			SetDParam(1, _music_wnd_cursong);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   427
		}
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8240
diff changeset
   428
		DrawStringCentered(155, 46, str, TC_FROMSTRING);
0
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
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8240
diff changeset
   431
		DrawString(60, 38, STR_01E8_TRACK_XTITLE, TC_FROMSTRING);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   432
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2630
diff changeset
   433
		for (i = 0; i != 6; i++) {
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8240
diff changeset
   434
			DrawStringCentered(25 + i * 50, 59, STR_01D5_ALL + i, msf.playlist == i ? TC_WHITE : TC_BLACK);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   435
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   436
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8240
diff changeset
   437
		DrawStringCentered(31, 43, STR_01E9_SHUFFLE, (msf.shuffle ? TC_WHITE : TC_BLACK));
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8240
diff changeset
   438
		DrawStringCentered(269, 43, STR_01EA_PROGRAM, TC_FROMSTRING);
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8240
diff changeset
   439
		DrawStringCentered(141, 15, STR_01DB_MUSIC_VOLUME, TC_FROMSTRING);
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8240
diff changeset
   440
		DrawStringCentered(141, 29, STR_01DD_MIN_MAX, TC_FROMSTRING);
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8240
diff changeset
   441
		DrawStringCentered(247, 15, STR_01DC_EFFECTS_VOLUME, TC_FROMSTRING);
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8240
diff changeset
   442
		DrawStringCentered(247, 29, STR_01DD_MIN_MAX, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   443
1938
21bd6ef5f85e (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
   444
		DrawFrameRect(108, 23, 174, 26, 14, FR_LOWERED);
21bd6ef5f85e (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
   445
		DrawFrameRect(214, 23, 280, 26, 14, FR_LOWERED);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   446
4468
fb18502e2c12 (svn r6253) Comment out code with #if 0, not //. Join statements which needlessly span many lines into fewer lines
tron
parents: 4432
diff changeset
   447
		DrawFrameRect(
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   448
			108 + msf.music_vol / 2, 22, 111 + msf.music_vol / 2, 28, 14, FR_NONE
4468
fb18502e2c12 (svn r6253) Comment out code with #if 0, not //. Join statements which needlessly span many lines into fewer lines
tron
parents: 4432
diff changeset
   449
		);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   450
4468
fb18502e2c12 (svn r6253) Comment out code with #if 0, not //. Join statements which needlessly span many lines into fewer lines
tron
parents: 4432
diff changeset
   451
		DrawFrameRect(
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   452
			214 + msf.effect_vol / 2, 22, 217 + msf.effect_vol / 2, 28, 14, FR_NONE
4468
fb18502e2c12 (svn r6253) Comment out code with #if 0, not //. Join statements which needlessly span many lines into fewer lines
tron
parents: 4432
diff changeset
   453
		);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   454
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   455
10606
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   456
	virtual void OnClick(Point pt, int widget)
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   457
	{
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   458
		switch (widget) {
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   459
			case MW_PREV: // skip to prev
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   460
				if (!_song_is_active) return;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   461
				SkipToPrevSong();
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   462
				break;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   463
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   464
			case MW_NEXT: // skip to next
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   465
				if (!_song_is_active) return;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   466
				SkipToNextSong();
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   467
				break;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   468
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   469
			case MW_STOP: // stop playing
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   470
				msf.playing = false;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   471
				break;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   472
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   473
			case MW_PLAY: // start playing
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   474
				msf.playing = true;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   475
				break;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   476
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   477
			case MW_SLIDERS: { // volume sliders
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   478
				byte *vol, new_vol;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   479
				int x = pt.x - 88;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   480
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   481
				if (x < 0) return;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   482
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   483
				vol = &msf.music_vol;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   484
				if (x >= 106) {
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   485
					vol = &msf.effect_vol;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   486
					x -= 106;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   487
				}
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   488
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   489
				new_vol = min(max(x - 21, 0) * 2, 127);
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   490
				if (new_vol != *vol) {
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   491
					*vol = new_vol;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   492
					if (vol == &msf.music_vol) MusicVolumeChanged(new_vol);
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   493
					this->SetDirty();
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   494
				}
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   495
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   496
				_left_button_clicked = false;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   497
			} break;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   498
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   499
			case MW_SHUFFLE: //toggle shuffle
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   500
				msf.shuffle ^= 1;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   501
				StopMusic();
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   502
				SelectSongToPlay();
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   503
				break;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   504
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   505
			case MW_PROGRAMME: //show track selection
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   506
				ShowMusicTrackSelection();
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   507
				break;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   508
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   509
			case MW_ALL: case MW_OLD: case MW_NEW:
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   510
			case MW_EZY: case MW_CUSTOM1: case MW_CUSTOM2: // playlist
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   511
				msf.playlist = widget - MW_ALL;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   512
				this->SetDirty();
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   513
				InvalidateWindow(WC_MUSIC_TRACK_SELECTION, 0);
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   514
				StopMusic();
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   515
				SelectSongToPlay();
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   516
				break;
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   517
		}
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   518
	}
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   519
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   520
#if 0
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   521
	virtual void OnTick()
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   522
	{
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   523
		this->InvalidateWidget(MW_GAUGE);
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   524
	}
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   525
#endif
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   526
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   527
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   528
static const Widget _music_window_widgets[] = {
10606
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   529
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},                    // MW_CLOSE
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   530
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   299,     0,    13, STR_01D2_JAZZ_JUKEBOX, STR_018C_WINDOW_TITLE_DRAG_THIS},          // MW_CAPTION
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   531
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,     0,    21,    14,    35, SPR_IMG_SKIP_TO_PREV,  STR_01DE_SKIP_TO_PREVIOUS_TRACK},          // MW_PREV
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   532
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    22,    43,    14,    35, SPR_IMG_SKIP_TO_NEXT,  STR_01DF_SKIP_TO_NEXT_TRACK_IN_SELECTION}, // MW_NEXT
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   533
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    44,    65,    14,    35, SPR_IMG_STOP_MUSIC,    STR_01E0_STOP_PLAYING_MUSIC},              // MW_STOP
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   534
{ WWT_PUSHIMGBTN,   RESIZE_NONE,    14,    66,    87,    14,    35, SPR_IMG_PLAY_MUSIC,    STR_01E1_START_PLAYING_MUSIC},             // MW_PLAY
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   535
{      WWT_PANEL,   RESIZE_NONE,    14,    88,   299,    14,    35, 0x0,                   STR_01E2_DRAG_SLIDERS_TO_SET_MUSIC},       // MW_SLIDERS
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   536
{      WWT_PANEL,   RESIZE_NONE,    14,   186,   201,    15,    34, 0x0,                   STR_NULL},                                 // MW_GAUGE
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   537
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   299,    36,    57, 0x0,                   STR_NULL},                                 // MW_BACKGROUND
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   538
{      WWT_PANEL,   RESIZE_NONE,    14,    59,   240,    45,    53, 0x0,                   STR_NULL},                                 // MW_INFO
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   539
{    WWT_PUSHBTN,   RESIZE_NONE,    14,     6,    55,    42,    49, 0x0,                   STR_01FB_TOGGLE_PROGRAM_SHUFFLE},          // MW_SHUFFLE
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   540
{    WWT_PUSHBTN,   RESIZE_NONE,    14,   244,   293,    42,    49, 0x0,                   STR_01FC_SHOW_MUSIC_TRACK_SELECTION},      // MW_PROGRAMME
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   541
{    WWT_PUSHBTN,   RESIZE_NONE,    14,     0,    49,    58,    65, 0x0,                   STR_01F3_SELECT_ALL_TRACKS_PROGRAM},       // MW_ALL
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   542
{    WWT_PUSHBTN,   RESIZE_NONE,    14,    50,    99,    58,    65, 0x0,                   STR_01F4_SELECT_OLD_STYLE_MUSIC},          // MW_OLD
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   543
{    WWT_PUSHBTN,   RESIZE_NONE,    14,   100,   149,    58,    65, 0x0,                   STR_01F5_SELECT_NEW_STYLE_MUSIC},          // MW_NEW
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   544
{    WWT_PUSHBTN,   RESIZE_NONE,    14,   150,   199,    58,    65, 0x0,                   STR_0330_SELECT_EZY_STREET_STYLE},         // MW_EZY
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   545
{    WWT_PUSHBTN,   RESIZE_NONE,    14,   200,   249,    58,    65, 0x0,                   STR_01F6_SELECT_CUSTOM_1_USER_DEFINED},    // MW_CUSTOM1
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   546
{    WWT_PUSHBTN,   RESIZE_NONE,    14,   250,   299,    58,    65, 0x0,                   STR_01F7_SELECT_CUSTOM_2_USER_DEFINED},    // MW_CUSTOM2
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 0
diff changeset
   547
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   548
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   549
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   550
static const WindowDesc _music_window_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7762
diff changeset
   551
	0, 22, 300, 66, 300, 66,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5838
diff changeset
   552
	WC_MUSIC_WINDOW, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   553
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   554
	_music_window_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   555
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   556
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6527
diff changeset
   557
void ShowMusicWindow()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   558
{
10606
85598085994d (svn r13150) -Codechange: make classes of the Music[TrackSelection]Window.
glx
parents: 10595
diff changeset
   559
	AllocateWindowDescFront<MusicWindow>(&_music_window_desc, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   560
}