git repos / blockattack-game

blame: source/code/menudef.cpp

normal view · raw

593aeae4 sago007 2011-06-25 22:42 1
/*
af35c39d sago007 2013-11-16 16:37 2
===========================================================================
af35c39d sago007 2013-11-16 16:37 3
blockattack - Block Attack - Rise of the Blocks
af35c39d sago007 2013-11-16 16:37 4
Copyright (C) 2005-2013 Poul Sander
af35c39d sago007 2013-11-16 16:37 5
af35c39d sago007 2013-11-16 16:37 6
This program is free software: you can redistribute it and/or modify
af35c39d sago007 2013-11-16 16:37 7
it under the terms of the GNU General Public License as published by
af35c39d sago007 2013-11-16 16:37 8
the Free Software Foundation, either version 2 of the License, or
af35c39d sago007 2013-11-16 16:37 9
(at your option) any later version.
af35c39d sago007 2013-11-16 16:37 10
af35c39d sago007 2013-11-16 16:37 11
This program is distributed in the hope that it will be useful,
af35c39d sago007 2013-11-16 16:37 12
but WITHOUT ANY WARRANTY; without even the implied warranty of
af35c39d sago007 2013-11-16 16:37 13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
af35c39d sago007 2013-11-16 16:37 14
GNU General Public License for more details.
af35c39d sago007 2013-11-16 16:37 15
af35c39d sago007 2013-11-16 16:37 16
You should have received a copy of the GNU General Public License
af35c39d sago007 2013-11-16 16:37 17
along with this program.  If not, see http://www.gnu.org/licenses/
af35c39d sago007 2013-11-16 16:37 18
af35c39d sago007 2013-11-16 16:37 19
Source information and contacts persons can be found at
021de090 sago007 2015-12-30 18:56 20
http://blockattack.net
af35c39d sago007 2013-11-16 16:37 21
===========================================================================
593aeae4 sago007 2011-06-25 22:42 22
*/
26ddb424 sago007 2011-06-09 20:06 23
#include "global.hpp"
26ddb424 sago007 2011-06-09 20:06 24
#include <iostream>
26ddb424 sago007 2011-06-09 20:06 25
#include <stdlib.h>
26ddb424 sago007 2011-06-09 20:06 26
#include "MenuSystem.h"
c9dd376f sago007 2012-01-20 17:13 27
#include "common.h"
d8fe60bd sago007 2018-04-02 16:15 28
#include "HelpHowtoState.hpp"
54d2d583 sago007 2018-04-05 17:52 29
#include "HelpGamepadState.hpp"
5147de4e Poul Sander 2018-05-06 12:59 30
#include "HelpAboutState.hpp"
0471a1d3 sago007 2018-05-19 10:26 31
#include "ShowFileState.hpp"
26ddb424 sago007 2011-06-09 20:06 32
26ddb424 sago007 2011-06-09 20:06 33
3838c95c sago007 2016-01-23 10:47 34
#if 0
26ddb424 sago007 2011-06-09 20:06 35
//Menu
ecef5838 sago007 2015-11-24 20:01 36
static void PrintHi(Button* b) {
161a010c sago007 2016-05-06 14:00 37
	cout << "Hi" <<"\n";
26ddb424 sago007 2011-06-09 20:06 38
}
3838c95c sago007 2016-01-23 10:47 39
#endif
26ddb424 sago007 2011-06-09 20:06 40
593aeae4 sago007 2011-06-25 22:42 41
//Stores the controls
ecef5838 sago007 2015-11-24 20:01 42
struct control {
1d2e2129 sago007 2015-12-23 15:41 43
	SDL_Keycode up;
1d2e2129 sago007 2015-12-23 15:41 44
	SDL_Keycode down;
1d2e2129 sago007 2015-12-23 15:41 45
	SDL_Keycode left;
1d2e2129 sago007 2015-12-23 15:41 46
	SDL_Keycode right;
1d2e2129 sago007 2015-12-23 15:41 47
	SDL_Keycode change;
1d2e2129 sago007 2015-12-23 15:41 48
	SDL_Keycode push;
593aeae4 sago007 2011-06-25 22:42 49
};
593aeae4 sago007 2011-06-25 22:42 50
26ddb424 sago007 2011-06-09 20:06 51
void OpenScoresDisplay();
593aeae4 sago007 2011-06-25 22:42 52
extern control keySettings[3];
593aeae4 sago007 2011-06-25 22:42 53
593aeae4 sago007 2011-06-25 22:42 54
//Function to return the name of a key, to be displayed...
97546fef Poul Sander 2020-08-08 17:21 55
std::string getKeyName(SDL_Keycode key) {
97546fef Poul Sander 2020-08-08 17:21 56
	std::string keyname(SDL_GetKeyName(key));
d82fedb9 Poul Sander 2018-06-20 16:48 57
	if (key == SDLK_UP) {
d82fedb9 Poul Sander 2018-06-20 16:48 58
		keyname = _("Up arrow");
d82fedb9 Poul Sander 2018-06-20 16:48 59
	}
d82fedb9 Poul Sander 2018-06-20 16:48 60
	if (key == SDLK_DOWN) {
d82fedb9 Poul Sander 2018-06-20 16:48 61
		keyname = _("Down arrow");
d82fedb9 Poul Sander 2018-06-20 16:48 62
	}
d82fedb9 Poul Sander 2018-06-20 16:48 63
	if (key == SDLK_LEFT) {
d82fedb9 Poul Sander 2018-06-20 16:48 64
		keyname = _("Left arrow");
d82fedb9 Poul Sander 2018-06-20 16:48 65
	}
d82fedb9 Poul Sander 2018-06-20 16:48 66
	if (key == SDLK_RIGHT) {
d82fedb9 Poul Sander 2018-06-20 16:48 67
		keyname = _("Right arrow");
d82fedb9 Poul Sander 2018-06-20 16:48 68
	}
d82fedb9 Poul Sander 2018-06-20 16:48 69
	if (key == SDLK_RCTRL) {
d82fedb9 Poul Sander 2018-06-20 16:48 70
		keyname = _("Right Ctrl");
d82fedb9 Poul Sander 2018-06-20 16:48 71
	}
d82fedb9 Poul Sander 2018-06-20 16:48 72
	if (key == SDLK_LCTRL) {
d82fedb9 Poul Sander 2018-06-20 16:48 73
		keyname = _("Left Ctrl");
d82fedb9 Poul Sander 2018-06-20 16:48 74
	}
d82fedb9 Poul Sander 2018-06-20 16:48 75
	if (key == SDLK_RSHIFT) {
d82fedb9 Poul Sander 2018-06-20 16:48 76
		keyname = _("Right shift");
d82fedb9 Poul Sander 2018-06-20 16:48 77
	}
d82fedb9 Poul Sander 2018-06-20 16:48 78
	if (key == SDLK_LSHIFT) {
d82fedb9 Poul Sander 2018-06-20 16:48 79
		keyname = _("Left shift");
d82fedb9 Poul Sander 2018-06-20 16:48 80
	}
d82fedb9 Poul Sander 2018-06-20 16:48 81
	if (key == SDLK_RALT) {
d82fedb9 Poul Sander 2018-06-20 16:48 82
		keyname = _("Right alt");
d82fedb9 Poul Sander 2018-06-20 16:48 83
	}
d82fedb9 Poul Sander 2018-06-20 16:48 84
	if (key == SDLK_LALT) {
d82fedb9 Poul Sander 2018-06-20 16:48 85
		keyname = _("Left alt");
d82fedb9 Poul Sander 2018-06-20 16:48 86
	}
d82fedb9 Poul Sander 2018-06-20 16:48 87
	if (key == SDLK_RETURN) {
d82fedb9 Poul Sander 2018-06-20 16:48 88
		keyname = _("Return");
d82fedb9 Poul Sander 2018-06-20 16:48 89
	}
d82fedb9 Poul Sander 2018-06-20 16:48 90
	if (key == SDLK_SPACE) {
d82fedb9 Poul Sander 2018-06-20 16:48 91
		keyname = _("Space");
d82fedb9 Poul Sander 2018-06-20 16:48 92
	}
72383a9e sago007 2016-10-30 11:56 93
	if (globalData.verboseLevel) {
b1f06489 Poul Sander 2020-08-08 17:19 94
		std::cout << key << " translated to " << keyname << "\n";
acd79baf sago007 2015-11-22 19:37 95
	}
c53e6443 sago007 2012-04-17 11:04 96
	return keyname;
593aeae4 sago007 2011-06-25 22:42 97
}
593aeae4 sago007 2011-06-25 22:42 98
ecef5838 sago007 2015-11-24 20:01 99
class Button_changekey : public Button {
593aeae4 sago007 2011-06-25 22:42 100
private:
1d2e2129 sago007 2015-12-23 15:41 101
	SDL_Keycode* m_key2change;
97546fef Poul Sander 2020-08-08 17:21 102
	std::string m_keyname;
593aeae4 sago007 2011-06-25 22:42 103
public:
7192940a Poul Sander 2020-08-08 17:18 104
	Button_changekey(SDL_Keycode* key, const char* keyname);
c53e6443 sago007 2012-04-17 11:04 105
	void doAction();
593aeae4 sago007 2011-06-25 22:42 106
};
593aeae4 sago007 2011-06-25 22:42 107
6710d462 sago007 2012-05-12 17:23 108
7192940a Poul Sander 2020-08-08 17:18 109
Button_changekey::Button_changekey(SDL_Keycode* key, const char* keyname)
3674f7f0 sago007 2020-07-12 12:16 110
	: m_key2change{key}, m_keyname{keyname} {
c53e6443 sago007 2012-04-17 11:04 111
	setLabel(m_keyname+" : "+getKeyName(*m_key2change));
593aeae4 sago007 2011-06-25 22:42 112
}
593aeae4 sago007 2011-06-25 22:42 113
ecef5838 sago007 2015-11-24 20:01 114
void Button_changekey::doAction() {
c53e6443 sago007 2012-04-17 11:04 115
	SDL_Event event;
c53e6443 sago007 2012-04-17 11:04 116
c53e6443 sago007 2012-04-17 11:04 117
	bool finnish = false;
ecef5838 sago007 2015-11-24 20:01 118
	while (!finnish) {
c53e6443 sago007 2012-04-17 11:04 119
		SDL_Delay(10);
ecef5838 sago007 2015-11-24 20:01 120
		while ( SDL_PollEvent(&event) ) {
ecef5838 sago007 2015-11-24 20:01 121
			if (event.type == SDL_KEYDOWN) {
acd79baf sago007 2015-11-22 19:37 122
				if (event.key.keysym.sym != SDLK_ESCAPE) {
c53e6443 sago007 2012-04-17 11:04 123
					*m_key2change = event.key.keysym.sym;
acd79baf sago007 2015-11-22 19:37 124
				}
c53e6443 sago007 2012-04-17 11:04 125
				finnish = true;
c53e6443 sago007 2012-04-17 11:04 126
			}
c53e6443 sago007 2012-04-17 11:04 127
		}
c53e6443 sago007 2012-04-17 11:04 128
	}
c53e6443 sago007 2012-04-17 11:04 129
	setLabel(m_keyname+" : "+getKeyName(*m_key2change));
593aeae4 sago007 2011-06-25 22:42 130
}
26ddb424 sago007 2011-06-09 20:06 131
ecef5838 sago007 2015-11-24 20:01 132
void InitMenues() {
094b2dfe sago007 2016-06-12 10:50 133
	standardButton.setSurfaces();
26ddb424 sago007 2011-06-09 20:06 134
}
26ddb424 sago007 2011-06-09 20:06 135
4379ec19 Poul Sander 2019-01-30 18:27 136
static void runSinglePlayerEndless0() {
de81e07d sago007 2016-07-10 20:22 137
	runGame(Gametype::SinglePlayerEndless, 0);
26ddb424 sago007 2011-06-09 20:06 138
}
26ddb424 sago007 2011-06-09 20:06 139
4379ec19 Poul Sander 2019-01-30 18:27 140
static void runSinglePlayerEndless1() {
4379ec19 Poul Sander 2019-01-30 18:27 141
	runGame(Gametype::SinglePlayerEndless, 1);
4379ec19 Poul Sander 2019-01-30 18:27 142
}
4379ec19 Poul Sander 2019-01-30 18:27 143
4379ec19 Poul Sander 2019-01-30 18:27 144
static void runSinglePlayerEndless2() {
4379ec19 Poul Sander 2019-01-30 18:27 145
	runGame(Gametype::SinglePlayerEndless, 2);
4379ec19 Poul Sander 2019-01-30 18:27 146
}
4379ec19 Poul Sander 2019-01-30 18:27 147
4379ec19 Poul Sander 2019-01-30 18:27 148
static void runSinglePlayerEndless3() {
4379ec19 Poul Sander 2019-01-30 18:27 149
	runGame(Gametype::SinglePlayerEndless, 3);
4379ec19 Poul Sander 2019-01-30 18:27 150
}
4379ec19 Poul Sander 2019-01-30 18:27 151
4379ec19 Poul Sander 2019-01-30 18:27 152
static void runSinglePlayerEndless4() {
4379ec19 Poul Sander 2019-01-30 18:27 153
	runGame(Gametype::SinglePlayerEndless, 4);
4379ec19 Poul Sander 2019-01-30 18:27 154
}
4379ec19 Poul Sander 2019-01-30 18:27 155
4379ec19 Poul Sander 2019-01-30 18:27 156
static void runSinglePlayerEndless() {
4379ec19 Poul Sander 2019-01-30 18:27 157
	Menu sp(globalData.screen,_("Single Player Endless"),true);
4379ec19 Poul Sander 2019-01-30 18:27 158
	Button d0,d1,d2,d3,d4;
4379ec19 Poul Sander 2019-01-30 18:27 159
	d0.setPopOnRun(true);
4379ec19 Poul Sander 2019-01-30 18:27 160
	d1.setPopOnRun(true);
4379ec19 Poul Sander 2019-01-30 18:27 161
	d2.setPopOnRun(true);
4379ec19 Poul Sander 2019-01-30 18:27 162
	d3.setPopOnRun(true);
4379ec19 Poul Sander 2019-01-30 18:27 163
	d4.setPopOnRun(true);
4379ec19 Poul Sander 2019-01-30 18:27 164
	d0.setLabel(_("Slow"));
4379ec19 Poul Sander 2019-01-30 18:27 165
	d1.setLabel(_("Fast"));
4379ec19 Poul Sander 2019-01-30 18:27 166
	d2.setLabel(_("Faster"));
4379ec19 Poul Sander 2019-01-30 18:27 167
	d3.setLabel(_("Even faster"));
4379ec19 Poul Sander 2019-01-30 18:27 168
	d4.setLabel(_("Fastest"));
4379ec19 Poul Sander 2019-01-30 18:27 169
	d0.setAction(runSinglePlayerEndless0);
4379ec19 Poul Sander 2019-01-30 18:27 170
	d1.setAction(runSinglePlayerEndless1);
4379ec19 Poul Sander 2019-01-30 18:27 171
	d2.setAction(runSinglePlayerEndless2);
4379ec19 Poul Sander 2019-01-30 18:27 172
	d3.setAction(runSinglePlayerEndless3);
4379ec19 Poul Sander 2019-01-30 18:27 173
	d4.setAction(runSinglePlayerEndless4);
4379ec19 Poul Sander 2019-01-30 18:27 174
	sp.addButton(&d0);
4379ec19 Poul Sander 2019-01-30 18:27 175
	sp.addButton(&d1);
4379ec19 Poul Sander 2019-01-30 18:27 176
	sp.addButton(&d2);
4379ec19 Poul Sander 2019-01-30 18:27 177
	sp.addButton(&d3);
4379ec19 Poul Sander 2019-01-30 18:27 178
	sp.addButton(&d4);
4379ec19 Poul Sander 2019-01-30 18:27 179
	RunGameState(sp);
4379ec19 Poul Sander 2019-01-30 18:27 180
}
4379ec19 Poul Sander 2019-01-30 18:27 181
29edda2d sago007 2016-10-08 18:06 182
static void runSinglePlayerTimeTrial() {
de81e07d sago007 2016-07-10 20:22 183
	runGame(Gametype::SinglePlayerTimeTrial, 0);
26ddb424 sago007 2011-06-09 20:06 184
}
26ddb424 sago007 2011-06-09 20:06 185
29edda2d sago007 2016-10-08 18:06 186
static void runStageClear() {
de81e07d sago007 2016-07-10 20:22 187
	runGame(Gametype::StageClear, 0);
aede0664 sago007 2012-04-19 19:45 188
}
aede0664 sago007 2012-04-19 19:45 189
29edda2d sago007 2016-10-08 18:06 190
static void runSinglePlayerPuzzle() {
de81e07d sago007 2016-07-10 20:22 191
	runGame(Gametype::Puzzle, 0);
26ddb424 sago007 2011-06-09 20:06 192
}
26ddb424 sago007 2011-06-09 20:06 193
29edda2d sago007 2016-10-08 18:06 194
class RunSinglePlayerVsButton : public Button {
29edda2d sago007 2016-10-08 18:06 195
	virtual void doAction() override {
29edda2d sago007 2016-10-08 18:06 196
		runGame(Gametype::SinglePlayerVs, iGeneric1);
29edda2d sago007 2016-10-08 18:06 197
	}
29edda2d sago007 2016-10-08 18:06 198
};
26ddb424 sago007 2011-06-09 20:06 199
29edda2d sago007 2016-10-08 18:06 200
static void runTwoPlayerTimeTrial() {
de81e07d sago007 2016-07-10 20:22 201
	runGame(Gametype::TwoPlayerTimeTrial, 0);
b0222eff sago007 2012-04-22 15:06 202
}
b0222eff sago007 2012-04-22 15:06 203
29edda2d sago007 2016-10-08 18:06 204
static void runTwoPlayerVs() {
de81e07d sago007 2016-07-10 20:22 205
	runGame(Gametype::TwoPlayerVs, 0);
b0222eff sago007 2012-04-22 15:06 206
}
b0222eff sago007 2012-04-22 15:06 207
1029dfed Poul Sander 2019-03-13 17:22 208
static void SetAlwaysSoftwareLabel(Button* b) {
1029dfed Poul Sander 2019-03-13 17:22 209
	b->setLabel(Config::getInstance()->getInt("always-software")?
9c7fa9a1 sago007 2020-06-27 22:09 210
	            _("Always use software render: On")
9c7fa9a1 sago007 2020-06-27 22:09 211
	            : _("Always use software render: Off"));
1029dfed Poul Sander 2019-03-13 17:22 212
}
1029dfed Poul Sander 2019-03-13 17:22 213
e17d4be2 Poul Sander 2019-03-13 17:29 214
static void SetMusicLabel (Button* b) {
e17d4be2 Poul Sander 2019-03-13 17:29 215
	b->setLabel(globalData.MusicEnabled? _("Music: On") : _("Music: Off") );
e17d4be2 Poul Sander 2019-03-13 17:29 216
}
e17d4be2 Poul Sander 2019-03-13 17:29 217
e17d4be2 Poul Sander 2019-03-13 17:29 218
static void SetSoundLabel (Button* b) {
e17d4be2 Poul Sander 2019-03-13 17:29 219
	b->setLabel(globalData.SoundEnabled? _("Sound: On") : _("Sound: Off") );
e17d4be2 Poul Sander 2019-03-13 17:29 220
}
e17d4be2 Poul Sander 2019-03-13 17:29 221
e17d4be2 Poul Sander 2019-03-13 17:29 222
static void SetFullscreenLabel (Button* b) {
e17d4be2 Poul Sander 2019-03-13 17:29 223
	b->setLabel(globalData.bFullscreen? _("Fullscreen: On") : _("Fullscreen: Off") );
e17d4be2 Poul Sander 2019-03-13 17:29 224
}
e17d4be2 Poul Sander 2019-03-13 17:29 225
1029dfed Poul Sander 2019-03-13 17:22 226
class AlwaysSoftwareRenderButton : public Button {
1029dfed Poul Sander 2019-03-13 17:22 227
	virtual void doAction() override {
1029dfed Poul Sander 2019-03-13 17:22 228
		Config::getInstance()->setInt("always-software", !Config::getInstance()->getInt("always-software"));
1029dfed Poul Sander 2019-03-13 17:22 229
		SetAlwaysSoftwareLabel(this);
1029dfed Poul Sander 2019-03-13 17:22 230
	}
1029dfed Poul Sander 2019-03-13 17:22 231
};
1029dfed Poul Sander 2019-03-13 17:22 232
29edda2d sago007 2016-10-08 18:06 233
class MusicButton : public Button {
29edda2d sago007 2016-10-08 18:06 234
	virtual void doAction() override {
72383a9e sago007 2016-10-30 11:56 235
		globalData.MusicEnabled = !globalData.MusicEnabled;
e17d4be2 Poul Sander 2019-03-13 17:29 236
		SetMusicLabel(this);
29edda2d sago007 2016-10-08 18:06 237
	}
29edda2d sago007 2016-10-08 18:06 238
};
26ddb424 sago007 2011-06-09 20:06 239
29edda2d sago007 2016-10-08 18:06 240
class SoundButton : public Button {
29edda2d sago007 2016-10-08 18:06 241
	virtual void doAction() override {
72383a9e sago007 2016-10-30 11:56 242
		globalData.SoundEnabled = !globalData.SoundEnabled;
e17d4be2 Poul Sander 2019-03-13 17:29 243
		SetSoundLabel(this);
29edda2d sago007 2016-10-08 18:06 244
	}
29edda2d sago007 2016-10-08 18:06 245
};
29edda2d sago007 2016-10-08 18:06 246
29edda2d sago007 2016-10-08 18:06 247
class FullscreenButton : public Button {
29edda2d sago007 2016-10-08 18:06 248
	virtual void doAction() override {
72383a9e sago007 2016-10-30 11:56 249
		globalData.bFullscreen = !globalData.bFullscreen;
e17d4be2 Poul Sander 2019-03-13 17:29 250
		SetFullscreenLabel(this);
29edda2d sago007 2016-10-08 18:06 251
		ResetFullscreen();
29edda2d sago007 2016-10-08 18:06 252
	}
29edda2d sago007 2016-10-08 18:06 253
};
26ddb424 sago007 2011-06-09 20:06 254
29edda2d sago007 2016-10-08 18:06 255
static void buttonActionPlayer1Name() {
72383a9e sago007 2016-10-30 11:56 256
	if ( OpenDialogbox(200, 100, globalData.player1name, _("Enter player 1 name:")) ) {
acd79baf sago007 2015-11-22 19:37 257
		return;    //must save if true
acd79baf sago007 2015-11-22 19:37 258
	}
26ddb424 sago007 2011-06-09 20:06 259
}
26ddb424 sago007 2011-06-09 20:06 260
29edda2d sago007 2016-10-08 18:06 261
static void buttonActionPlayer2Name() {
72383a9e sago007 2016-10-30 11:56 262
	if ( OpenDialogbox(200, 100, globalData.player2name, _("Enter player 2 name:")) ) {
acd79baf sago007 2015-11-22 19:37 263
		return;    //must save if true
acd79baf sago007 2015-11-22 19:37 264
	}
26ddb424 sago007 2011-06-09 20:06 265
}
26ddb424 sago007 2011-06-09 20:06 266
29edda2d sago007 2016-10-08 18:06 267
static void buttonActionHighscores() {
c53e6443 sago007 2012-04-17 11:04 268
	OpenScoresDisplay();
26ddb424 sago007 2011-06-09 20:06 269
}
26ddb424 sago007 2011-06-09 20:06 270
ecef5838 sago007 2015-11-24 20:01 271
static void ChangeKeysMenu(long playernumber) {
72383a9e sago007 2016-10-30 11:56 272
	Menu km(globalData.screen,_("Change key bindings"),true);
c53e6443 sago007 2012-04-17 11:04 273
	Button_changekey bLeft(&keySettings[playernumber].left,_("Left") );
c53e6443 sago007 2012-04-17 11:04 274
	Button_changekey bRight(&keySettings[playernumber].right,_("Right") );
c53e6443 sago007 2012-04-17 11:04 275
	Button_changekey bUp(&keySettings[playernumber].up,_("Up") );
c53e6443 sago007 2012-04-17 11:04 276
	Button_changekey bDown(&keySettings[playernumber].down,_("Down") );
c53e6443 sago007 2012-04-17 11:04 277
	Button_changekey bPush(&keySettings[playernumber].push,_("Push") );
c53e6443 sago007 2012-04-17 11:04 278
	Button_changekey bSwitch(&keySettings[playernumber].change,_("Change") );
c53e6443 sago007 2012-04-17 11:04 279
	km.addButton(&bLeft);
c53e6443 sago007 2012-04-17 11:04 280
	km.addButton(&bRight);
c53e6443 sago007 2012-04-17 11:04 281
	km.addButton(&bUp);
c53e6443 sago007 2012-04-17 11:04 282
	km.addButton(&bDown);
c53e6443 sago007 2012-04-17 11:04 283
	km.addButton(&bPush);
c53e6443 sago007 2012-04-17 11:04 284
	km.addButton(&bSwitch);
20d77c6e sago007 2016-11-12 16:28 285
	RunGameState(km);
c53e6443 sago007 2012-04-17 11:04 286
}
c53e6443 sago007 2012-04-17 11:04 287
29edda2d sago007 2016-10-08 18:06 288
static void ChangeKeysMenu1() {
c53e6443 sago007 2012-04-17 11:04 289
	ChangeKeysMenu(0);
593aeae4 sago007 2011-06-25 22:42 290
}
593aeae4 sago007 2011-06-25 22:42 291
29edda2d sago007 2016-10-08 18:06 292
static void ChangeKeysMenu2() {
c53e6443 sago007 2012-04-17 11:04 293
	ChangeKeysMenu(2);
593aeae4 sago007 2011-06-25 22:42 294
}
fc8e3d6a sago007 2011-06-25 16:31 295
29edda2d sago007 2016-10-08 18:06 296
static void ConfigureMenu() {
72383a9e sago007 2016-10-30 11:56 297
	Menu cm(globalData.screen,_("Configuration"),true);
29edda2d sago007 2016-10-08 18:06 298
	Button bPlayer1Name,bPlayer2Name;
c53e6443 sago007 2012-04-17 11:04 299
	Button bPlayer1Keys, bPlayer2Keys;
1029dfed Poul Sander 2019-03-13 17:22 300
	AlwaysSoftwareRenderButton bSoftware;
29edda2d sago007 2016-10-08 18:06 301
	MusicButton bMusic;
29edda2d sago007 2016-10-08 18:06 302
	SoundButton bSound;
29edda2d sago007 2016-10-08 18:06 303
	FullscreenButton buttonFullscreen;
1029dfed Poul Sander 2019-03-13 17:22 304
	SetAlwaysSoftwareLabel(&bSoftware);
e17d4be2 Poul Sander 2019-03-13 17:29 305
	SetMusicLabel(&bMusic);
e17d4be2 Poul Sander 2019-03-13 17:29 306
	SetSoundLabel(&bSound);
e17d4be2 Poul Sander 2019-03-13 17:29 307
	SetFullscreenLabel(&buttonFullscreen);
c53e6443 sago007 2012-04-17 11:04 308
	bPlayer1Name.setAction(buttonActionPlayer1Name);
c53e6443 sago007 2012-04-17 11:04 309
	bPlayer1Name.setLabel(_("Change player 1's name") );
c53e6443 sago007 2012-04-17 11:04 310
	bPlayer2Name.setAction(buttonActionPlayer2Name);
c53e6443 sago007 2012-04-17 11:04 311
	bPlayer2Name.setLabel(_("Change player 2's name") );
c53e6443 sago007 2012-04-17 11:04 312
	bPlayer1Keys.setAction(ChangeKeysMenu1);
c53e6443 sago007 2012-04-17 11:04 313
	bPlayer1Keys.setLabel(_("Change player 1's keys") );
c53e6443 sago007 2012-04-17 11:04 314
	bPlayer2Keys.setAction(ChangeKeysMenu2);
c53e6443 sago007 2012-04-17 11:04 315
	bPlayer2Keys.setLabel(_("Change player 2's keys") );
c53e6443 sago007 2012-04-17 11:04 316
	cm.addButton(&bMusic);
c53e6443 sago007 2012-04-17 11:04 317
	cm.addButton(&bSound);
1029dfed Poul Sander 2019-03-13 17:22 318
	cm.addButton(&bSoftware);
c53e6443 sago007 2012-04-17 11:04 319
	cm.addButton(&buttonFullscreen);
c53e6443 sago007 2012-04-17 11:04 320
	cm.addButton(&bPlayer1Name);
c53e6443 sago007 2012-04-17 11:04 321
	cm.addButton(&bPlayer2Name);
c53e6443 sago007 2012-04-17 11:04 322
	cm.addButton(&bPlayer1Keys);
c53e6443 sago007 2012-04-17 11:04 323
	cm.addButton(&bPlayer2Keys);
20d77c6e sago007 2016-11-12 16:28 324
	RunGameState(cm);
26ddb424 sago007 2011-06-09 20:06 325
}
26ddb424 sago007 2011-06-09 20:06 326
29edda2d sago007 2016-10-08 18:06 327
static void SinglePlayerVsMenu() {
72383a9e sago007 2016-10-30 11:56 328
	Menu spvs(globalData.screen,_("Single player VS"),true);
29edda2d sago007 2016-10-08 18:06 329
	RunSinglePlayerVsButton d1,d2,d3,d4,d5,d6,d7;
67a32395 sago007 2012-04-19 18:40 330
	d1.setPopOnRun(true);
67a32395 sago007 2012-04-19 18:40 331
	d2.setPopOnRun(true);
67a32395 sago007 2012-04-19 18:40 332
	d3.setPopOnRun(true);
67a32395 sago007 2012-04-19 18:40 333
	d4.setPopOnRun(true);
67a32395 sago007 2012-04-19 18:40 334
	d5.setPopOnRun(true);
67a32395 sago007 2012-04-19 18:40 335
	d6.setPopOnRun(true);
67a32395 sago007 2012-04-19 18:40 336
	d7.setPopOnRun(true);
e68d08eb sago007 2013-11-15 22:33 337
	d1.iGeneric1 = 0;
e68d08eb sago007 2013-11-15 22:33 338
	d2.iGeneric1 = 1;
e68d08eb sago007 2013-11-15 22:33 339
	d3.iGeneric1 = 2;
e68d08eb sago007 2013-11-15 22:33 340
	d4.iGeneric1 = 3;
e68d08eb sago007 2013-11-15 22:33 341
	d5.iGeneric1 = 4;
e68d08eb sago007 2013-11-15 22:33 342
	d6.iGeneric1 = 5;
e68d08eb sago007 2013-11-15 22:33 343
	d7.iGeneric1 = 6;
67a32395 sago007 2012-04-19 18:40 344
	d1.setLabel(_("Very easy"));
67a32395 sago007 2012-04-19 18:40 345
	d2.setLabel(_("Easy"));
67a32395 sago007 2012-04-19 18:40 346
	d3.setLabel(_("Below normal"));
67a32395 sago007 2012-04-19 18:40 347
	d4.setLabel(_("Normal"));
67a32395 sago007 2012-04-19 18:40 348
	d5.setLabel(_("Above normal"));
67a32395 sago007 2012-04-19 18:40 349
	d6.setLabel(_("Hard"));
67a32395 sago007 2012-04-19 18:40 350
	d7.setLabel(_("Hardest"));
67a32395 sago007 2012-04-19 18:40 351
	spvs.addButton(&d1);
67a32395 sago007 2012-04-19 18:40 352
	spvs.addButton(&d2);
67a32395 sago007 2012-04-19 18:40 353
	spvs.addButton(&d3);
67a32395 sago007 2012-04-19 18:40 354
	spvs.addButton(&d4);
67a32395 sago007 2012-04-19 18:40 355
	spvs.addButton(&d5);
67a32395 sago007 2012-04-19 18:40 356
	spvs.addButton(&d6);
67a32395 sago007 2012-04-19 18:40 357
	spvs.addButton(&d7);
20d77c6e sago007 2016-11-12 16:28 358
	RunGameState(spvs);
67a32395 sago007 2012-04-19 18:40 359
}
67a32395 sago007 2012-04-19 18:40 360
29edda2d sago007 2016-10-08 18:06 361
static void MultiplayerMenu() {
72383a9e sago007 2016-10-30 11:56 362
	Menu mm(globalData.screen,_("Multiplayer"),true);
de81e07d sago007 2016-07-10 20:22 363
	Button bTT, bVs;
b0222eff sago007 2012-04-22 15:06 364
	bTT.setLabel(_("Two player - time trial"));
b0222eff sago007 2012-04-22 15:06 365
	bTT.setAction(runTwoPlayerTimeTrial);
b0222eff sago007 2012-04-22 15:06 366
	bVs.setLabel(_("Two player - vs"));
b0222eff sago007 2012-04-22 15:06 367
	bVs.setAction(runTwoPlayerVs);
b0222eff sago007 2012-04-22 15:06 368
	mm.addButton(&bTT);
b0222eff sago007 2012-04-22 15:06 369
	mm.addButton(&bVs);
20d77c6e sago007 2016-11-12 16:28 370
	RunGameState(mm);
b0222eff sago007 2012-04-22 15:06 371
}
b0222eff sago007 2012-04-22 15:06 372
d8fe60bd sago007 2018-04-02 16:15 373
static void runHowto() {
d8fe60bd sago007 2018-04-02 16:15 374
	HelpHowtoState howto;
d8fe60bd sago007 2018-04-02 16:15 375
	RunGameState(howto);
d8fe60bd sago007 2018-04-02 16:15 376
}
d8fe60bd sago007 2018-04-02 16:15 377
54d2d583 sago007 2018-04-05 17:52 378
static void runHelpGamepad() {
54d2d583 sago007 2018-04-05 17:52 379
	HelpGamepadState helpGamepad;
54d2d583 sago007 2018-04-05 17:52 380
	RunGameState(helpGamepad);
54d2d583 sago007 2018-04-05 17:52 381
}
54d2d583 sago007 2018-04-05 17:52 382
5147de4e Poul Sander 2018-05-06 12:59 383
static void runHelpAbout() {
5147de4e Poul Sander 2018-05-06 12:59 384
	HelpAboutState helpAbout;
5147de4e Poul Sander 2018-05-06 12:59 385
	RunGameState(helpAbout);
5147de4e Poul Sander 2018-05-06 12:59 386
}
5147de4e Poul Sander 2018-05-06 12:59 387
0471a1d3 sago007 2018-05-19 10:26 388
static void runCredits() {
0471a1d3 sago007 2018-05-19 10:26 389
	ShowFileState creditsFile;
0471a1d3 sago007 2018-05-19 10:26 390
	creditsFile.SetData("misc/AUTHORS", _("Credits"));
0471a1d3 sago007 2018-05-19 10:26 391
	RunGameState(creditsFile);
0471a1d3 sago007 2018-05-19 10:26 392
}
0471a1d3 sago007 2018-05-19 10:26 393
d8fe60bd sago007 2018-04-02 16:15 394
static void HelpMenu() {
d8fe60bd sago007 2018-04-02 16:15 395
	Menu m(globalData.screen, _("Help"), true);
d8fe60bd sago007 2018-04-02 16:15 396
	Button bHowto;
d8fe60bd sago007 2018-04-02 16:15 397
	bHowto.setLabel(_("How to"));
d8fe60bd sago007 2018-04-02 16:15 398
	bHowto.setAction(runHowto);
d8fe60bd sago007 2018-04-02 16:15 399
	m.addButton(&bHowto);
54d2d583 sago007 2018-04-05 17:52 400
	Button bGamepad;
54d2d583 sago007 2018-04-05 17:52 401
	bGamepad.setLabel(_("Gamepad"));
54d2d583 sago007 2018-04-05 17:52 402
	bGamepad.setAction(runHelpGamepad);
54d2d583 sago007 2018-04-05 17:52 403
	m.addButton(&bGamepad);
0471a1d3 sago007 2018-05-19 10:26 404
	Button bCredits;
0471a1d3 sago007 2018-05-19 10:26 405
	bCredits.setLabel(_("Credits"));
0471a1d3 sago007 2018-05-19 10:26 406
	bCredits.setAction(runCredits);
0471a1d3 sago007 2018-05-19 10:26 407
	m.addButton(&bCredits);
5147de4e Poul Sander 2018-05-06 12:59 408
	Button bAbout;
5147de4e Poul Sander 2018-05-06 12:59 409
	bAbout.setLabel(_("About"));
5147de4e Poul Sander 2018-05-06 12:59 410
	bAbout.setAction(runHelpAbout);
5147de4e Poul Sander 2018-05-06 12:59 411
	m.addButton(&bAbout);
d8fe60bd sago007 2018-04-02 16:15 412
	RunGameState(m);
d8fe60bd sago007 2018-04-02 16:15 413
}
d8fe60bd sago007 2018-04-02 16:15 414
2f331f0c sago007 2017-08-19 16:17 415
static void SinglePlayerMenu() {
2f331f0c sago007 2017-08-19 16:17 416
	Menu m(globalData.screen, _("Single player"), true);
2f331f0c sago007 2017-08-19 16:17 417
	Button bHi,bTimetrial1, bStageClear, bPuzzle, bVs1;
c53e6443 sago007 2012-04-17 11:04 418
	bHi.setLabel(_("Single player - endless") );
c53e6443 sago007 2012-04-17 11:04 419
	bHi.setAction(runSinglePlayerEndless);
c53e6443 sago007 2012-04-17 11:04 420
	bTimetrial1.setLabel(_("Single player - time trial") );
c53e6443 sago007 2012-04-17 11:04 421
	bTimetrial1.setAction(runSinglePlayerTimeTrial);
aede0664 sago007 2012-04-19 19:45 422
	bStageClear.setLabel(_("Single player - stage clear") );
aede0664 sago007 2012-04-19 19:45 423
	bStageClear.setAction(runStageClear);
c53e6443 sago007 2012-04-17 11:04 424
	bPuzzle.setLabel(_("Single player - puzzle mode") );
c53e6443 sago007 2012-04-17 11:04 425
	bPuzzle.setAction(runSinglePlayerPuzzle);
c53e6443 sago007 2012-04-17 11:04 426
	bVs1.setLabel(_("Single player - vs") );
67a32395 sago007 2012-04-19 18:40 427
	bVs1.setAction(SinglePlayerVsMenu);
2f331f0c sago007 2017-08-19 16:17 428
	m.addButton(&bHi);
2f331f0c sago007 2017-08-19 16:17 429
	m.addButton(&bTimetrial1);
2f331f0c sago007 2017-08-19 16:17 430
	m.addButton(&bStageClear);
2f331f0c sago007 2017-08-19 16:17 431
	m.addButton(&bPuzzle);
2f331f0c sago007 2017-08-19 16:17 432
	m.addButton(&bVs1);
2f331f0c sago007 2017-08-19 16:17 433
	RunGameState(m);
2f331f0c sago007 2017-08-19 16:17 434
}
2f331f0c sago007 2017-08-19 16:17 435
ccee1ad0 Poul Sander 2019-03-13 18:39 436
void SafeModeMenu() {
ccee1ad0 Poul Sander 2019-03-13 18:39 437
	if (Config::getInstance()->getInt("always-software")) {
ccee1ad0 Poul Sander 2019-03-13 18:39 438
		return;
ccee1ad0 Poul Sander 2019-03-13 18:39 439
	}
ccee1ad0 Poul Sander 2019-03-13 18:39 440
	InitMenues();
ccee1ad0 Poul Sander 2019-03-13 18:39 441
	Menu safeMode(globalData.screen, _("Game did not shutdown as it should"), true);
ccee1ad0 Poul Sander 2019-03-13 18:39 442
	Button bOnce;
ccee1ad0 Poul Sander 2019-03-13 18:39 443
	Button bAlways;
ccee1ad0 Poul Sander 2019-03-13 18:39 444
	bOnce.setLabel(_("Use software renderer this time"));
ccee1ad0 Poul Sander 2019-03-13 18:39 445
	bAlways.setLabel(_("Always use software renderer"));
ccee1ad0 Poul Sander 2019-03-13 18:39 446
	bOnce.setPopOnRun(true);
9c7fa9a1 sago007 2020-06-27 22:09 447
	bAlways.setAction([]() {
9c7fa9a1 sago007 2020-06-27 22:09 448
		Config::getInstance()->setInt("always-software", 1);
9c7fa9a1 sago007 2020-06-27 22:09 449
	});
ccee1ad0 Poul Sander 2019-03-13 18:39 450
	bAlways.setPopOnRun(true);
ccee1ad0 Poul Sander 2019-03-13 18:39 451
	safeMode.addButton(&bOnce);
ccee1ad0 Poul Sander 2019-03-13 18:39 452
	safeMode.addButton(&bAlways);
ccee1ad0 Poul Sander 2019-03-13 18:39 453
	RunGameState(safeMode);
ccee1ad0 Poul Sander 2019-03-13 18:39 454
}
ccee1ad0 Poul Sander 2019-03-13 18:39 455
2f331f0c sago007 2017-08-19 16:17 456
void MainMenu() {
2f331f0c sago007 2017-08-19 16:17 457
	InitMenues();
2f331f0c sago007 2017-08-19 16:17 458
	Menu m(globalData.screen,_("Block Attack - Rise of the blocks"),false);
d8fe60bd sago007 2018-04-02 16:15 459
	Button bHi, bMulti, bConfigure, bHighscore, bHelp;
2f331f0c sago007 2017-08-19 16:17 460
	bHi.setLabel(_("Single player") );
2f331f0c sago007 2017-08-19 16:17 461
	bHi.setAction(SinglePlayerMenu);
b0222eff sago007 2012-04-22 15:06 462
	bMulti.setLabel(_("Multi player") );
b0222eff sago007 2012-04-22 15:06 463
	bMulti.setAction(MultiplayerMenu);
c53e6443 sago007 2012-04-17 11:04 464
	bConfigure.setLabel(_("Configure") );
c53e6443 sago007 2012-04-17 11:04 465
	bConfigure.setAction(ConfigureMenu);
c53e6443 sago007 2012-04-17 11:04 466
	bHighscore.setLabel(_("Highscores") );
c53e6443 sago007 2012-04-17 11:04 467
	bHighscore.setAction(buttonActionHighscores);
d8fe60bd sago007 2018-04-02 16:15 468
	bHelp.setLabel(_("Help"));
d8fe60bd sago007 2018-04-02 16:15 469
	bHelp.setAction(HelpMenu);
c53e6443 sago007 2012-04-17 11:04 470
	m.addButton(&bHi);
b0222eff sago007 2012-04-22 15:06 471
	m.addButton(&bMulti);
c53e6443 sago007 2012-04-17 11:04 472
	m.addButton(&bConfigure);
c53e6443 sago007 2012-04-17 11:04 473
	m.addButton(&bHighscore);
d8fe60bd sago007 2018-04-02 16:15 474
	m.addButton(&bHelp);
95ab6b0d sago007 2016-11-12 16:11 475
	RunGameState(m);
593aeae4 sago007 2011-06-25 22:42 476
}
1970-01-01 00:00 477