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