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"
bfb4fed7 Poul Sander 2022-02-14 19:35 29
#include "HelpModInfoState.hpp"
54d2d583 sago007 2018-04-05 17:52 30
#include "HelpGamepadState.hpp"
5147de4e Poul Sander 2018-05-06 12:59 31
#include "HelpAboutState.hpp"
0471a1d3 sago007 2018-05-19 10:26 32
#include "ShowFileState.hpp"
16476649 Poul Sander 2022-01-09 10:29 33
#include <fmt/core.h>
26ddb424 sago007 2011-06-09 20:06 34
26ddb424 sago007 2011-06-09 20:06 35
3838c95c sago007 2016-01-23 10:47 36
#if 0
26ddb424 sago007 2011-06-09 20:06 37
//Menu
ecef5838 sago007 2015-11-24 20:01 38
static void PrintHi(Button* b) {
161a010c sago007 2016-05-06 14:00 39
	cout << "Hi" <<"\n";
26ddb424 sago007 2011-06-09 20:06 40
}
3838c95c sago007 2016-01-23 10:47 41
#endif
26ddb424 sago007 2011-06-09 20:06 42
593aeae4 sago007 2011-06-25 22:42 43
//Stores the controls
ecef5838 sago007 2015-11-24 20:01 44
struct control {
1d2e2129 sago007 2015-12-23 15:41 45
	SDL_Keycode up;
1d2e2129 sago007 2015-12-23 15:41 46
	SDL_Keycode down;
1d2e2129 sago007 2015-12-23 15:41 47
	SDL_Keycode left;
1d2e2129 sago007 2015-12-23 15:41 48
	SDL_Keycode right;
1d2e2129 sago007 2015-12-23 15:41 49
	SDL_Keycode change;
1d2e2129 sago007 2015-12-23 15:41 50
	SDL_Keycode push;
593aeae4 sago007 2011-06-25 22:42 51
};
593aeae4 sago007 2011-06-25 22:42 52
26ddb424 sago007 2011-06-09 20:06 53
void OpenScoresDisplay();
593aeae4 sago007 2011-06-25 22:42 54
extern control keySettings[3];
593aeae4 sago007 2011-06-25 22:42 55
593aeae4 sago007 2011-06-25 22:42 56
//Function to return the name of a key, to be displayed...
97546fef Poul Sander 2020-08-08 17:21 57
std::string getKeyName(SDL_Keycode key) {
97546fef Poul Sander 2020-08-08 17:21 58
	std::string keyname(SDL_GetKeyName(key));
d82fedb9 Poul Sander 2018-06-20 16:48 59
	if (key == SDLK_UP) {
d82fedb9 Poul Sander 2018-06-20 16:48 60
		keyname = _("Up arrow");
d82fedb9 Poul Sander 2018-06-20 16:48 61
	}
d82fedb9 Poul Sander 2018-06-20 16:48 62
	if (key == SDLK_DOWN) {
d82fedb9 Poul Sander 2018-06-20 16:48 63
		keyname = _("Down arrow");
d82fedb9 Poul Sander 2018-06-20 16:48 64
	}
d82fedb9 Poul Sander 2018-06-20 16:48 65
	if (key == SDLK_LEFT) {
d82fedb9 Poul Sander 2018-06-20 16:48 66
		keyname = _("Left arrow");
d82fedb9 Poul Sander 2018-06-20 16:48 67
	}
d82fedb9 Poul Sander 2018-06-20 16:48 68
	if (key == SDLK_RIGHT) {
d82fedb9 Poul Sander 2018-06-20 16:48 69
		keyname = _("Right arrow");
d82fedb9 Poul Sander 2018-06-20 16:48 70
	}
d82fedb9 Poul Sander 2018-06-20 16:48 71
	if (key == SDLK_RCTRL) {
d82fedb9 Poul Sander 2018-06-20 16:48 72
		keyname = _("Right Ctrl");
d82fedb9 Poul Sander 2018-06-20 16:48 73
	}
d82fedb9 Poul Sander 2018-06-20 16:48 74
	if (key == SDLK_LCTRL) {
d82fedb9 Poul Sander 2018-06-20 16:48 75
		keyname = _("Left Ctrl");
d82fedb9 Poul Sander 2018-06-20 16:48 76
	}
d82fedb9 Poul Sander 2018-06-20 16:48 77
	if (key == SDLK_RSHIFT) {
d82fedb9 Poul Sander 2018-06-20 16:48 78
		keyname = _("Right shift");
d82fedb9 Poul Sander 2018-06-20 16:48 79
	}
d82fedb9 Poul Sander 2018-06-20 16:48 80
	if (key == SDLK_LSHIFT) {
d82fedb9 Poul Sander 2018-06-20 16:48 81
		keyname = _("Left shift");
d82fedb9 Poul Sander 2018-06-20 16:48 82
	}
d82fedb9 Poul Sander 2018-06-20 16:48 83
	if (key == SDLK_RALT) {
d82fedb9 Poul Sander 2018-06-20 16:48 84
		keyname = _("Right alt");
d82fedb9 Poul Sander 2018-06-20 16:48 85
	}
d82fedb9 Poul Sander 2018-06-20 16:48 86
	if (key == SDLK_LALT) {
d82fedb9 Poul Sander 2018-06-20 16:48 87
		keyname = _("Left alt");
d82fedb9 Poul Sander 2018-06-20 16:48 88
	}
d82fedb9 Poul Sander 2018-06-20 16:48 89
	if (key == SDLK_RETURN) {
d82fedb9 Poul Sander 2018-06-20 16:48 90
		keyname = _("Return");
d82fedb9 Poul Sander 2018-06-20 16:48 91
	}
d82fedb9 Poul Sander 2018-06-20 16:48 92
	if (key == SDLK_SPACE) {
d82fedb9 Poul Sander 2018-06-20 16:48 93
		keyname = _("Space");
d82fedb9 Poul Sander 2018-06-20 16:48 94
	}
72383a9e sago007 2016-10-30 11:56 95
	if (globalData.verboseLevel) {
b1f06489 Poul Sander 2020-08-08 17:19 96
		std::cout << key << " translated to " << keyname << "\n";
acd79baf sago007 2015-11-22 19:37 97
	}
c53e6443 sago007 2012-04-17 11:04 98
	return keyname;
593aeae4 sago007 2011-06-25 22:42 99
}
593aeae4 sago007 2011-06-25 22:42 100
ecef5838 sago007 2015-11-24 20:01 101
class Button_changekey : public Button {
593aeae4 sago007 2011-06-25 22:42 102
private:
1d2e2129 sago007 2015-12-23 15:41 103
	SDL_Keycode* m_key2change;
97546fef Poul Sander 2020-08-08 17:21 104
	std::string m_keyname;
593aeae4 sago007 2011-06-25 22:42 105
public:
7192940a Poul Sander 2020-08-08 17:18 106
	Button_changekey(SDL_Keycode* key, const char* keyname);
5f8ce673 Poul Sander 2021-06-05 22:18 107
	virtual void doAction() override;
593aeae4 sago007 2011-06-25 22:42 108
};
593aeae4 sago007 2011-06-25 22:42 109
6710d462 sago007 2012-05-12 17:23 110
7192940a Poul Sander 2020-08-08 17:18 111
Button_changekey::Button_changekey(SDL_Keycode* key, const char* keyname)
3674f7f0 sago007 2020-07-12 12:16 112
	: m_key2change{key}, m_keyname{keyname} {
c53e6443 sago007 2012-04-17 11:04 113
	setLabel(m_keyname+" : "+getKeyName(*m_key2change));
593aeae4 sago007 2011-06-25 22:42 114
}
593aeae4 sago007 2011-06-25 22:42 115
ecef5838 sago007 2015-11-24 20:01 116
void Button_changekey::doAction() {
c53e6443 sago007 2012-04-17 11:04 117
	SDL_Event event;
c53e6443 sago007 2012-04-17 11:04 118
c53e6443 sago007 2012-04-17 11:04 119
	bool finnish = false;
ecef5838 sago007 2015-11-24 20:01 120
	while (!finnish) {
c53e6443 sago007 2012-04-17 11:04 121
		SDL_Delay(10);
ecef5838 sago007 2015-11-24 20:01 122
		while ( SDL_PollEvent(&event) ) {
ecef5838 sago007 2015-11-24 20:01 123
			if (event.type == SDL_KEYDOWN) {
acd79baf sago007 2015-11-22 19:37 124
				if (event.key.keysym.sym != SDLK_ESCAPE) {
c53e6443 sago007 2012-04-17 11:04 125
					*m_key2change = event.key.keysym.sym;
acd79baf sago007 2015-11-22 19:37 126
				}
c53e6443 sago007 2012-04-17 11:04 127
				finnish = true;
c53e6443 sago007 2012-04-17 11:04 128
			}
c53e6443 sago007 2012-04-17 11:04 129
		}
c53e6443 sago007 2012-04-17 11:04 130
	}
c53e6443 sago007 2012-04-17 11:04 131
	setLabel(m_keyname+" : "+getKeyName(*m_key2change));
593aeae4 sago007 2011-06-25 22:42 132
}
26ddb424 sago007 2011-06-09 20:06 133
c99935b0 Poul Sander 2021-08-28 13:13 134
class Button_confirmVolume : public Button {
55e33610 Poul Sander 2022-01-09 11:45 135
private:
c99935b0 Poul Sander 2021-08-28 13:13 136
	std::string cvar="";
c99935b0 Poul Sander 2021-08-28 13:13 137
	mutable std::string volumeLabel; /*used for cache*/
55e33610 Poul Sander 2022-01-09 11:45 138
public:
493079d1 Poul Sander 2021-10-20 21:03 139
	explicit Button_confirmVolume(const char* cvar);
c99935b0 Poul Sander 2021-08-28 13:13 140
	virtual void doAction() override { /*Do nothing. Equal to choose "back". */ };
c99935b0 Poul Sander 2021-08-28 13:13 141
	virtual const std::string& getLabel() const override;
c99935b0 Poul Sander 2021-08-28 13:13 142
};
c99935b0 Poul Sander 2021-08-28 13:13 143
c99935b0 Poul Sander 2021-08-28 13:13 144
Button_confirmVolume::Button_confirmVolume(const char* cvar) : cvar{cvar} {
c99935b0 Poul Sander 2021-08-28 13:13 145
	this->setPopOnRun(true);
c99935b0 Poul Sander 2021-08-28 13:13 146
}
c99935b0 Poul Sander 2021-08-28 13:13 147
c99935b0 Poul Sander 2021-08-28 13:13 148
const std::string& Button_confirmVolume::getLabel() const {
c99935b0 Poul Sander 2021-08-28 13:13 149
	int volumePct = Config::getInstance()->getInt(cvar)*100.0/MIX_MAX_VOLUME;
16476649 Poul Sander 2022-01-09 10:29 150
	this->volumeLabel = fmt::format(_("Volume: {}%"), volumePct); //  std::string(_("Volume: "))+ std::to_string(volumePct)+"%" ;
c99935b0 Poul Sander 2021-08-28 13:13 151
	return volumeLabel;
c99935b0 Poul Sander 2021-08-28 13:13 152
}
5f8ce673 Poul Sander 2021-06-05 22:18 153
c99935b0 Poul Sander 2021-08-28 13:13 154
class Button_increaseVolume : public Button {
55e33610 Poul Sander 2022-01-09 11:45 155
private:
c99935b0 Poul Sander 2021-08-28 13:13 156
	std::string cvar="";
c99935b0 Poul Sander 2021-08-28 13:13 157
	int incrementValue = 1;
c99935b0 Poul Sander 2021-08-28 13:13 158
	int lowerLimit = 0;
c99935b0 Poul Sander 2021-08-28 13:13 159
	int upperLimit = MIX_MAX_VOLUME;
55e33610 Poul Sander 2022-01-09 11:45 160
public:
c99935b0 Poul Sander 2021-08-28 13:13 161
	Button_increaseVolume(const char* cvar, int incrementValue);
5f8ce673 Poul Sander 2021-06-05 22:18 162
	virtual void doAction() override;
5f8ce673 Poul Sander 2021-06-05 22:18 163
};
5f8ce673 Poul Sander 2021-06-05 22:18 164
c99935b0 Poul Sander 2021-08-28 13:13 165
Button_increaseVolume::Button_increaseVolume(const char* cvar, int incrementValue)
c99935b0 Poul Sander 2021-08-28 13:13 166
	: cvar{cvar},incrementValue{incrementValue} {
55e33610 Poul Sander 2022-01-09 11:45 167
	char prefix = '+';
55e33610 Poul Sander 2022-01-09 11:45 168
	double value = incrementValue;
55e33610 Poul Sander 2022-01-09 11:45 169
	if (incrementValue<0) {
55e33610 Poul Sander 2022-01-09 11:45 170
		prefix = '-';
55e33610 Poul Sander 2022-01-09 11:45 171
		value = -incrementValue;
55e33610 Poul Sander 2022-01-09 11:45 172
	}
55e33610 Poul Sander 2022-01-09 11:45 173
	value = value*100.0/MIX_MAX_VOLUME;
55e33610 Poul Sander 2022-01-09 11:45 174
	setLabel(fmt::format("{}{:.2f}", prefix, value));
c99935b0 Poul Sander 2021-08-28 13:13 175
}
c99935b0 Poul Sander 2021-08-28 13:13 176
c99935b0 Poul Sander 2021-08-28 13:13 177
void Button_increaseVolume::doAction() {
c99935b0 Poul Sander 2021-08-28 13:13 178
	int newValue = Config::getInstance()->getInt(cvar)+incrementValue;
c99935b0 Poul Sander 2021-08-28 13:13 179
	if (newValue<lowerLimit) {
c99935b0 Poul Sander 2021-08-28 13:13 180
		newValue = lowerLimit;
5f8ce673 Poul Sander 2021-06-05 22:18 181
	}
c99935b0 Poul Sander 2021-08-28 13:13 182
	if (newValue>upperLimit) {
c99935b0 Poul Sander 2021-08-28 13:13 183
		newValue = upperLimit;
5f8ce673 Poul Sander 2021-06-05 22:18 184
	}
c99935b0 Poul Sander 2021-08-28 13:13 185
	Config::getInstance()->setInt(cvar, newValue);
5f8ce673 Poul Sander 2021-06-05 22:18 186
}
5f8ce673 Poul Sander 2021-06-05 22:18 187
c99935b0 Poul Sander 2021-08-28 13:13 188
class Button_testSound : public Button {
55e33610 Poul Sander 2022-01-09 11:45 189
public:
c99935b0 Poul Sander 2021-08-28 13:13 190
	Button_testSound();
c99935b0 Poul Sander 2021-08-28 13:13 191
	virtual void doAction() override;
c99935b0 Poul Sander 2021-08-28 13:13 192
};
c99935b0 Poul Sander 2021-08-28 13:13 193
c99935b0 Poul Sander 2021-08-28 13:13 194
Button_testSound::Button_testSound() {
c99935b0 Poul Sander 2021-08-28 13:13 195
	setLabel(_("Test sound"));
c99935b0 Poul Sander 2021-08-28 13:13 196
}
c99935b0 Poul Sander 2021-08-28 13:13 197
c99935b0 Poul Sander 2021-08-28 13:13 198
void Button_testSound::doAction() {
c99935b0 Poul Sander 2021-08-28 13:13 199
	sago::SoundHandler testSound = globalData.spriteHolder->GetDataHolder().getSoundHandler("pop");
c99935b0 Poul Sander 2021-08-28 13:13 200
	Mix_VolumeChunk(testSound.get(), Config::getInstance()->getInt("volume_sound"));
c99935b0 Poul Sander 2021-08-28 13:13 201
	Mix_PlayChannel(1, testSound.get(), 0);
c99935b0 Poul Sander 2021-08-28 13:13 202
}
c99935b0 Poul Sander 2021-08-28 13:13 203
c99935b0 Poul Sander 2021-08-28 13:13 204
class Button_testMusic : public Button {
55e33610 Poul Sander 2022-01-09 11:45 205
public:
c99935b0 Poul Sander 2021-08-28 13:13 206
	Button_testMusic();
c99935b0 Poul Sander 2021-08-28 13:13 207
	virtual void doAction() override;
c99935b0 Poul Sander 2021-08-28 13:13 208
};
c99935b0 Poul Sander 2021-08-28 13:13 209
c99935b0 Poul Sander 2021-08-28 13:13 210
Button_testMusic::Button_testMusic() {
c99935b0 Poul Sander 2021-08-28 13:13 211
	setLabel(_("Test music"));
c99935b0 Poul Sander 2021-08-28 13:13 212
}
c99935b0 Poul Sander 2021-08-28 13:13 213
c99935b0 Poul Sander 2021-08-28 13:13 214
void Button_testMusic::doAction() {
c99935b0 Poul Sander 2021-08-28 13:13 215
	Mix_VolumeMusic(Config::getInstance()->getInt("volume_music"));
c99935b0 Poul Sander 2021-08-28 13:13 216
	sago::MusicHandler bgMusic = globalData.spriteHolder->GetDataHolder().getMusicHandler("bgmusic");
c99935b0 Poul Sander 2021-08-28 13:13 217
	Mix_PlayMusic(bgMusic.get(), -1);
5f8ce673 Poul Sander 2021-06-05 22:18 218
}
5f8ce673 Poul Sander 2021-06-05 22:18 219
ecef5838 sago007 2015-11-24 20:01 220
void InitMenues() {
094b2dfe sago007 2016-06-12 10:50 221
	standardButton.setSurfaces();
26ddb424 sago007 2011-06-09 20:06 222
}
26ddb424 sago007 2011-06-09 20:06 223
4379ec19 Poul Sander 2019-01-30 18:27 224
static void runSinglePlayerEndless0() {
de81e07d sago007 2016-07-10 20:22 225
	runGame(Gametype::SinglePlayerEndless, 0);
26ddb424 sago007 2011-06-09 20:06 226
}
26ddb424 sago007 2011-06-09 20:06 227
4379ec19 Poul Sander 2019-01-30 18:27 228
static void runSinglePlayerEndless1() {
4379ec19 Poul Sander 2019-01-30 18:27 229
	runGame(Gametype::SinglePlayerEndless, 1);
4379ec19 Poul Sander 2019-01-30 18:27 230
}
4379ec19 Poul Sander 2019-01-30 18:27 231
4379ec19 Poul Sander 2019-01-30 18:27 232
static void runSinglePlayerEndless2() {
4379ec19 Poul Sander 2019-01-30 18:27 233
	runGame(Gametype::SinglePlayerEndless, 2);
4379ec19 Poul Sander 2019-01-30 18:27 234
}
4379ec19 Poul Sander 2019-01-30 18:27 235
4379ec19 Poul Sander 2019-01-30 18:27 236
static void runSinglePlayerEndless3() {
4379ec19 Poul Sander 2019-01-30 18:27 237
	runGame(Gametype::SinglePlayerEndless, 3);
4379ec19 Poul Sander 2019-01-30 18:27 238
}
4379ec19 Poul Sander 2019-01-30 18:27 239
4379ec19 Poul Sander 2019-01-30 18:27 240
static void runSinglePlayerEndless4() {
4379ec19 Poul Sander 2019-01-30 18:27 241
	runGame(Gametype::SinglePlayerEndless, 4);
4379ec19 Poul Sander 2019-01-30 18:27 242
}
4379ec19 Poul Sander 2019-01-30 18:27 243
4379ec19 Poul Sander 2019-01-30 18:27 244
static void runSinglePlayerEndless() {
4379ec19 Poul Sander 2019-01-30 18:27 245
	Menu sp(globalData.screen,_("Single Player Endless"),true);
4379ec19 Poul Sander 2019-01-30 18:27 246
	Button d0,d1,d2,d3,d4;
4379ec19 Poul Sander 2019-01-30 18:27 247
	d0.setPopOnRun(true);
4379ec19 Poul Sander 2019-01-30 18:27 248
	d1.setPopOnRun(true);
4379ec19 Poul Sander 2019-01-30 18:27 249
	d2.setPopOnRun(true);
4379ec19 Poul Sander 2019-01-30 18:27 250
	d3.setPopOnRun(true);
4379ec19 Poul Sander 2019-01-30 18:27 251
	d4.setPopOnRun(true);
4379ec19 Poul Sander 2019-01-30 18:27 252
	d0.setLabel(_("Slow"));
4379ec19 Poul Sander 2019-01-30 18:27 253
	d1.setLabel(_("Fast"));
4379ec19 Poul Sander 2019-01-30 18:27 254
	d2.setLabel(_("Faster"));
4379ec19 Poul Sander 2019-01-30 18:27 255
	d3.setLabel(_("Even faster"));
4379ec19 Poul Sander 2019-01-30 18:27 256
	d4.setLabel(_("Fastest"));
4379ec19 Poul Sander 2019-01-30 18:27 257
	d0.setAction(runSinglePlayerEndless0);
4379ec19 Poul Sander 2019-01-30 18:27 258
	d1.setAction(runSinglePlayerEndless1);
4379ec19 Poul Sander 2019-01-30 18:27 259
	d2.setAction(runSinglePlayerEndless2);
4379ec19 Poul Sander 2019-01-30 18:27 260
	d3.setAction(runSinglePlayerEndless3);
4379ec19 Poul Sander 2019-01-30 18:27 261
	d4.setAction(runSinglePlayerEndless4);
4379ec19 Poul Sander 2019-01-30 18:27 262
	sp.addButton(&d0);
4379ec19 Poul Sander 2019-01-30 18:27 263
	sp.addButton(&d1);
4379ec19 Poul Sander 2019-01-30 18:27 264
	sp.addButton(&d2);
4379ec19 Poul Sander 2019-01-30 18:27 265
	sp.addButton(&d3);
4379ec19 Poul Sander 2019-01-30 18:27 266
	sp.addButton(&d4);
4379ec19 Poul Sander 2019-01-30 18:27 267
	RunGameState(sp);
4379ec19 Poul Sander 2019-01-30 18:27 268
}
4379ec19 Poul Sander 2019-01-30 18:27 269
29edda2d sago007 2016-10-08 18:06 270
static void runSinglePlayerTimeTrial() {
de81e07d sago007 2016-07-10 20:22 271
	runGame(Gametype::SinglePlayerTimeTrial, 0);
26ddb424 sago007 2011-06-09 20:06 272
}
26ddb424 sago007 2011-06-09 20:06 273
29edda2d sago007 2016-10-08 18:06 274
static void runStageClear() {
de81e07d sago007 2016-07-10 20:22 275
	runGame(Gametype::StageClear, 0);
aede0664 sago007 2012-04-19 19:45 276
}
aede0664 sago007 2012-04-19 19:45 277
29edda2d sago007 2016-10-08 18:06 278
static void runSinglePlayerPuzzle() {
de81e07d sago007 2016-07-10 20:22 279
	runGame(Gametype::Puzzle, 0);
26ddb424 sago007 2011-06-09 20:06 280
}
26ddb424 sago007 2011-06-09 20:06 281
29edda2d sago007 2016-10-08 18:06 282
class RunSinglePlayerVsButton : public Button {
29edda2d sago007 2016-10-08 18:06 283
	virtual void doAction() override {
29edda2d sago007 2016-10-08 18:06 284
		runGame(Gametype::SinglePlayerVs, iGeneric1);
29edda2d sago007 2016-10-08 18:06 285
	}
29edda2d sago007 2016-10-08 18:06 286
};
26ddb424 sago007 2011-06-09 20:06 287
29edda2d sago007 2016-10-08 18:06 288
static void runTwoPlayerTimeTrial() {
de81e07d sago007 2016-07-10 20:22 289
	runGame(Gametype::TwoPlayerTimeTrial, 0);
b0222eff sago007 2012-04-22 15:06 290
}
b0222eff sago007 2012-04-22 15:06 291
29edda2d sago007 2016-10-08 18:06 292
static void runTwoPlayerVs() {
de81e07d sago007 2016-07-10 20:22 293
	runGame(Gametype::TwoPlayerVs, 0);
b0222eff sago007 2012-04-22 15:06 294
}
b0222eff sago007 2012-04-22 15:06 295
1029dfed Poul Sander 2019-03-13 17:22 296
static void SetAlwaysSoftwareLabel(Button* b) {
1029dfed Poul Sander 2019-03-13 17:22 297
	b->setLabel(Config::getInstance()->getInt("always-software")?
9c7fa9a1 sago007 2020-06-27 22:09 298
	            _("Always use software render: On")
9c7fa9a1 sago007 2020-06-27 22:09 299
	            : _("Always use software render: Off"));
1029dfed Poul Sander 2019-03-13 17:22 300
}
1029dfed Poul Sander 2019-03-13 17:22 301
5f8ce673 Poul Sander 2021-06-05 22:18 302
static void runSetMusicVolume(const char* cvar, const char* header) {
5f8ce673 Poul Sander 2021-06-05 22:18 303
	Menu volumeMenu(globalData.screen, header, true);
c99935b0 Poul Sander 2021-08-28 13:13 304
	Button_confirmVolume bConfirm(cvar);
c99935b0 Poul Sander 2021-08-28 13:13 305
	Button_increaseVolume plus5(cvar, 5);
c99935b0 Poul Sander 2021-08-28 13:13 306
	Button_increaseVolume minus5(cvar, -5);
c99935b0 Poul Sander 2021-08-28 13:13 307
	Button_increaseVolume plus1(cvar, 1);
c99935b0 Poul Sander 2021-08-28 13:13 308
	Button_increaseVolume minus1(cvar, -1);
c99935b0 Poul Sander 2021-08-28 13:13 309
	volumeMenu.addButton(&bConfirm);
c99935b0 Poul Sander 2021-08-28 13:13 310
	volumeMenu.addButton(&plus5);
c99935b0 Poul Sander 2021-08-28 13:13 311
	volumeMenu.addButton(&minus5);
c99935b0 Poul Sander 2021-08-28 13:13 312
	volumeMenu.addButton(&plus1);
c99935b0 Poul Sander 2021-08-28 13:13 313
	volumeMenu.addButton(&minus1);
c99935b0 Poul Sander 2021-08-28 13:13 314
	Button_testSound bTestSound;
c99935b0 Poul Sander 2021-08-28 13:13 315
	volumeMenu.addButton(&bTestSound);
c99935b0 Poul Sander 2021-08-28 13:13 316
	Button_testMusic bTestMusic;
c99935b0 Poul Sander 2021-08-28 13:13 317
	volumeMenu.addButton(&bTestMusic);
5f8ce673 Poul Sander 2021-06-05 22:18 318
	RunGameState(volumeMenu);
5f8ce673 Poul Sander 2021-06-05 22:18 319
}
5f8ce673 Poul Sander 2021-06-05 22:18 320
e17d4be2 Poul Sander 2019-03-13 17:29 321
static void SetMusicLabel (Button* b) {
4482071a Poul Sander 2021-06-05 15:07 322
	if (globalData.MusicEnabled) {
4482071a Poul Sander 2021-06-05 15:07 323
		double volume = Config::getInstance()->getInt("volume_music");
4482071a Poul Sander 2021-06-05 15:07 324
		int volumePct = volume*100.0/MIX_MAX_VOLUME;
4482071a Poul Sander 2021-06-05 15:07 325
		b->setLabel(std::string(_("Music: "))+ std::to_string(volumePct)+"%" );
4482071a Poul Sander 2021-06-05 15:07 326
	}
4482071a Poul Sander 2021-06-05 15:07 327
	else {
4482071a Poul Sander 2021-06-05 15:07 328
		b->setLabel(_("Music: Off") );
4482071a Poul Sander 2021-06-05 15:07 329
	}
e17d4be2 Poul Sander 2019-03-13 17:29 330
}
e17d4be2 Poul Sander 2019-03-13 17:29 331
e17d4be2 Poul Sander 2019-03-13 17:29 332
static void SetSoundLabel (Button* b) {
4482071a Poul Sander 2021-06-05 15:07 333
	if (globalData.SoundEnabled) {
4482071a Poul Sander 2021-06-05 15:07 334
		double volume = Config::getInstance()->getInt("volume_sound");
4482071a Poul Sander 2021-06-05 15:07 335
		int volumePct = volume*100.0/MIX_MAX_VOLUME;
4482071a Poul Sander 2021-06-05 15:07 336
		b->setLabel(std::string(_("Sound: "))+ std::to_string(volumePct)+"%" );
4482071a Poul Sander 2021-06-05 15:07 337
	}
4482071a Poul Sander 2021-06-05 15:07 338
	else {
4482071a Poul Sander 2021-06-05 15:07 339
		b->setLabel(_("Sound: Off") );
4482071a Poul Sander 2021-06-05 15:07 340
	}
e17d4be2 Poul Sander 2019-03-13 17:29 341
}
e17d4be2 Poul Sander 2019-03-13 17:29 342
e17d4be2 Poul Sander 2019-03-13 17:29 343
static void SetFullscreenLabel (Button* b) {
e17d4be2 Poul Sander 2019-03-13 17:29 344
	b->setLabel(globalData.bFullscreen? _("Fullscreen: On") : _("Fullscreen: Off") );
e17d4be2 Poul Sander 2019-03-13 17:29 345
}
e17d4be2 Poul Sander 2019-03-13 17:29 346
1029dfed Poul Sander 2019-03-13 17:22 347
class AlwaysSoftwareRenderButton : public Button {
1029dfed Poul Sander 2019-03-13 17:22 348
	virtual void doAction() override {
1029dfed Poul Sander 2019-03-13 17:22 349
		Config::getInstance()->setInt("always-software", !Config::getInstance()->getInt("always-software"));
1029dfed Poul Sander 2019-03-13 17:22 350
		SetAlwaysSoftwareLabel(this);
1029dfed Poul Sander 2019-03-13 17:22 351
	}
1029dfed Poul Sander 2019-03-13 17:22 352
};
1029dfed Poul Sander 2019-03-13 17:22 353
29edda2d sago007 2016-10-08 18:06 354
class MusicButton : public Button {
29edda2d sago007 2016-10-08 18:06 355
	virtual void doAction() override {
5f8ce673 Poul Sander 2021-06-05 22:18 356
		runSetMusicVolume("volume_music", _("Music volume"));
5f8ce673 Poul Sander 2021-06-05 22:18 357
		globalData.MusicEnabled = (Config::getInstance()->getInt("volume_music") != 0);
e17d4be2 Poul Sander 2019-03-13 17:29 358
		SetMusicLabel(this);
29edda2d sago007 2016-10-08 18:06 359
	}
29edda2d sago007 2016-10-08 18:06 360
};
26ddb424 sago007 2011-06-09 20:06 361
29edda2d sago007 2016-10-08 18:06 362
class SoundButton : public Button {
29edda2d sago007 2016-10-08 18:06 363
	virtual void doAction() override {
5f8ce673 Poul Sander 2021-06-05 22:18 364
		runSetMusicVolume("volume_sound", _("Sound volume"));
5f8ce673 Poul Sander 2021-06-05 22:18 365
		globalData.MusicEnabled = (Config::getInstance()->getInt("volume_sound") != 0);
e17d4be2 Poul Sander 2019-03-13 17:29 366
		SetSoundLabel(this);
29edda2d sago007 2016-10-08 18:06 367
	}
29edda2d sago007 2016-10-08 18:06 368
};
29edda2d sago007 2016-10-08 18:06 369
29edda2d sago007 2016-10-08 18:06 370
class FullscreenButton : public Button {
29edda2d sago007 2016-10-08 18:06 371
	virtual void doAction() override {
72383a9e sago007 2016-10-30 11:56 372
		globalData.bFullscreen = !globalData.bFullscreen;
e17d4be2 Poul Sander 2019-03-13 17:29 373
		SetFullscreenLabel(this);
29edda2d sago007 2016-10-08 18:06 374
		ResetFullscreen();
29edda2d sago007 2016-10-08 18:06 375
	}
29edda2d sago007 2016-10-08 18:06 376
};
26ddb424 sago007 2011-06-09 20:06 377
29edda2d sago007 2016-10-08 18:06 378
static void buttonActionPlayer1Name() {
72383a9e sago007 2016-10-30 11:56 379
	if ( OpenDialogbox(200, 100, globalData.player1name, _("Enter player 1 name:")) ) {
acd79baf sago007 2015-11-22 19:37 380
		return;    //must save if true
acd79baf sago007 2015-11-22 19:37 381
	}
26ddb424 sago007 2011-06-09 20:06 382
}
26ddb424 sago007 2011-06-09 20:06 383
29edda2d sago007 2016-10-08 18:06 384
static void buttonActionPlayer2Name() {
72383a9e sago007 2016-10-30 11:56 385
	if ( OpenDialogbox(200, 100, globalData.player2name, _("Enter player 2 name:")) ) {
acd79baf sago007 2015-11-22 19:37 386
		return;    //must save if true
acd79baf sago007 2015-11-22 19:37 387
	}
26ddb424 sago007 2011-06-09 20:06 388
}
26ddb424 sago007 2011-06-09 20:06 389
29edda2d sago007 2016-10-08 18:06 390
static void buttonActionHighscores() {
c53e6443 sago007 2012-04-17 11:04 391
	OpenScoresDisplay();
26ddb424 sago007 2011-06-09 20:06 392
}
26ddb424 sago007 2011-06-09 20:06 393
ecef5838 sago007 2015-11-24 20:01 394
static void ChangeKeysMenu(long playernumber) {
72383a9e sago007 2016-10-30 11:56 395
	Menu km(globalData.screen,_("Change key bindings"),true);
c53e6443 sago007 2012-04-17 11:04 396
	Button_changekey bLeft(&keySettings[playernumber].left,_("Left") );
c53e6443 sago007 2012-04-17 11:04 397
	Button_changekey bRight(&keySettings[playernumber].right,_("Right") );
c53e6443 sago007 2012-04-17 11:04 398
	Button_changekey bUp(&keySettings[playernumber].up,_("Up") );
c53e6443 sago007 2012-04-17 11:04 399
	Button_changekey bDown(&keySettings[playernumber].down,_("Down") );
c53e6443 sago007 2012-04-17 11:04 400
	Button_changekey bPush(&keySettings[playernumber].push,_("Push") );
c53e6443 sago007 2012-04-17 11:04 401
	Button_changekey bSwitch(&keySettings[playernumber].change,_("Change") );
c53e6443 sago007 2012-04-17 11:04 402
	km.addButton(&bLeft);
c53e6443 sago007 2012-04-17 11:04 403
	km.addButton(&bRight);
c53e6443 sago007 2012-04-17 11:04 404
	km.addButton(&bUp);
c53e6443 sago007 2012-04-17 11:04 405
	km.addButton(&bDown);
c53e6443 sago007 2012-04-17 11:04 406
	km.addButton(&bPush);
c53e6443 sago007 2012-04-17 11:04 407
	km.addButton(&bSwitch);
20d77c6e sago007 2016-11-12 16:28 408
	RunGameState(km);
c53e6443 sago007 2012-04-17 11:04 409
}
c53e6443 sago007 2012-04-17 11:04 410
29edda2d sago007 2016-10-08 18:06 411
static void ChangeKeysMenu1() {
c53e6443 sago007 2012-04-17 11:04 412
	ChangeKeysMenu(0);
593aeae4 sago007 2011-06-25 22:42 413
}
593aeae4 sago007 2011-06-25 22:42 414
29edda2d sago007 2016-10-08 18:06 415
static void ChangeKeysMenu2() {
c53e6443 sago007 2012-04-17 11:04 416
	ChangeKeysMenu(2);
593aeae4 sago007 2011-06-25 22:42 417
}
fc8e3d6a sago007 2011-06-25 16:31 418
3affd2d6 Poul Sander 2020-12-27 15:56 419
static void PlayerConfigMenu() {
3affd2d6 Poul Sander 2020-12-27 15:56 420
	Menu pcm(globalData.screen,_("Player configuration"),true);
3affd2d6 Poul Sander 2020-12-27 15:56 421
	Button bPlayer1Name, bPlayer2Name;
3affd2d6 Poul Sander 2020-12-27 15:56 422
	Button bPlayer1Keys, bPlayer2Keys;
3affd2d6 Poul Sander 2020-12-27 15:56 423
	bPlayer1Name.setAction(buttonActionPlayer1Name);
3affd2d6 Poul Sander 2020-12-27 15:56 424
	bPlayer1Name.setLabel(_("Change player 1's name") );
3affd2d6 Poul Sander 2020-12-27 15:56 425
	bPlayer2Name.setAction(buttonActionPlayer2Name);
3affd2d6 Poul Sander 2020-12-27 15:56 426
	bPlayer2Name.setLabel(_("Change player 2's name") );
3affd2d6 Poul Sander 2020-12-27 15:56 427
	bPlayer1Keys.setAction(ChangeKeysMenu1);
3affd2d6 Poul Sander 2020-12-27 15:56 428
	bPlayer1Keys.setLabel(_("Change player 1's keys") );
3affd2d6 Poul Sander 2020-12-27 15:56 429
	bPlayer2Keys.setAction(ChangeKeysMenu2);
3affd2d6 Poul Sander 2020-12-27 15:56 430
	bPlayer2Keys.setLabel(_("Change player 2's keys") );
3affd2d6 Poul Sander 2020-12-27 15:56 431
	pcm.addButton(&bPlayer1Name);
3affd2d6 Poul Sander 2020-12-27 15:56 432
	pcm.addButton(&bPlayer2Name);
3affd2d6 Poul Sander 2020-12-27 15:56 433
	pcm.addButton(&bPlayer1Keys);
3affd2d6 Poul Sander 2020-12-27 15:56 434
	pcm.addButton(&bPlayer2Keys);
3affd2d6 Poul Sander 2020-12-27 15:56 435
	RunGameState(pcm);
3affd2d6 Poul Sander 2020-12-27 15:56 436
}
3affd2d6 Poul Sander 2020-12-27 15:56 437
29edda2d sago007 2016-10-08 18:06 438
static void ConfigureMenu() {
72383a9e sago007 2016-10-30 11:56 439
	Menu cm(globalData.screen,_("Configuration"),true);
1029dfed Poul Sander 2019-03-13 17:22 440
	AlwaysSoftwareRenderButton bSoftware;
29edda2d sago007 2016-10-08 18:06 441
	MusicButton bMusic;
29edda2d sago007 2016-10-08 18:06 442
	SoundButton bSound;
29edda2d sago007 2016-10-08 18:06 443
	FullscreenButton buttonFullscreen;
3affd2d6 Poul Sander 2020-12-27 15:56 444
	Button bPlayerConfig;
3affd2d6 Poul Sander 2020-12-27 15:56 445
	bPlayerConfig.setLabel(_("Player configuration") );
3affd2d6 Poul Sander 2020-12-27 15:56 446
	bPlayerConfig.setAction(PlayerConfigMenu);
1029dfed Poul Sander 2019-03-13 17:22 447
	SetAlwaysSoftwareLabel(&bSoftware);
e17d4be2 Poul Sander 2019-03-13 17:29 448
	SetMusicLabel(&bMusic);
e17d4be2 Poul Sander 2019-03-13 17:29 449
	SetSoundLabel(&bSound);
e17d4be2 Poul Sander 2019-03-13 17:29 450
	SetFullscreenLabel(&buttonFullscreen);
c53e6443 sago007 2012-04-17 11:04 451
	cm.addButton(&bMusic);
c53e6443 sago007 2012-04-17 11:04 452
	cm.addButton(&bSound);
1029dfed Poul Sander 2019-03-13 17:22 453
	cm.addButton(&bSoftware);
c53e6443 sago007 2012-04-17 11:04 454
	cm.addButton(&buttonFullscreen);
3affd2d6 Poul Sander 2020-12-27 15:56 455
	cm.addButton(&bPlayerConfig);
20d77c6e sago007 2016-11-12 16:28 456
	RunGameState(cm);
26ddb424 sago007 2011-06-09 20:06 457
}
26ddb424 sago007 2011-06-09 20:06 458
29edda2d sago007 2016-10-08 18:06 459
static void SinglePlayerVsMenu() {
72383a9e sago007 2016-10-30 11:56 460
	Menu spvs(globalData.screen,_("Single player VS"),true);
29edda2d sago007 2016-10-08 18:06 461
	RunSinglePlayerVsButton d1,d2,d3,d4,d5,d6,d7;
67a32395 sago007 2012-04-19 18:40 462
	d1.setPopOnRun(true);
67a32395 sago007 2012-04-19 18:40 463
	d2.setPopOnRun(true);
67a32395 sago007 2012-04-19 18:40 464
	d3.setPopOnRun(true);
67a32395 sago007 2012-04-19 18:40 465
	d4.setPopOnRun(true);
67a32395 sago007 2012-04-19 18:40 466
	d5.setPopOnRun(true);
67a32395 sago007 2012-04-19 18:40 467
	d6.setPopOnRun(true);
67a32395 sago007 2012-04-19 18:40 468
	d7.setPopOnRun(true);
e68d08eb sago007 2013-11-15 22:33 469
	d1.iGeneric1 = 0;
e68d08eb sago007 2013-11-15 22:33 470
	d2.iGeneric1 = 1;
e68d08eb sago007 2013-11-15 22:33 471
	d3.iGeneric1 = 2;
e68d08eb sago007 2013-11-15 22:33 472
	d4.iGeneric1 = 3;
e68d08eb sago007 2013-11-15 22:33 473
	d5.iGeneric1 = 4;
e68d08eb sago007 2013-11-15 22:33 474
	d6.iGeneric1 = 5;
e68d08eb sago007 2013-11-15 22:33 475
	d7.iGeneric1 = 6;
67a32395 sago007 2012-04-19 18:40 476
	d1.setLabel(_("Very easy"));
67a32395 sago007 2012-04-19 18:40 477
	d2.setLabel(_("Easy"));
67a32395 sago007 2012-04-19 18:40 478
	d3.setLabel(_("Below normal"));
67a32395 sago007 2012-04-19 18:40 479
	d4.setLabel(_("Normal"));
67a32395 sago007 2012-04-19 18:40 480
	d5.setLabel(_("Above normal"));
67a32395 sago007 2012-04-19 18:40 481
	d6.setLabel(_("Hard"));
67a32395 sago007 2012-04-19 18:40 482
	d7.setLabel(_("Hardest"));
67a32395 sago007 2012-04-19 18:40 483
	spvs.addButton(&d1);
67a32395 sago007 2012-04-19 18:40 484
	spvs.addButton(&d2);
67a32395 sago007 2012-04-19 18:40 485
	spvs.addButton(&d3);
67a32395 sago007 2012-04-19 18:40 486
	spvs.addButton(&d4);
67a32395 sago007 2012-04-19 18:40 487
	spvs.addButton(&d5);
67a32395 sago007 2012-04-19 18:40 488
	spvs.addButton(&d6);
67a32395 sago007 2012-04-19 18:40 489
	spvs.addButton(&d7);
20d77c6e sago007 2016-11-12 16:28 490
	RunGameState(spvs);
67a32395 sago007 2012-04-19 18:40 491
}
67a32395 sago007 2012-04-19 18:40 492
29edda2d sago007 2016-10-08 18:06 493
static void MultiplayerMenu() {
72383a9e sago007 2016-10-30 11:56 494
	Menu mm(globalData.screen,_("Multiplayer"),true);
de81e07d sago007 2016-07-10 20:22 495
	Button bTT, bVs;
b0222eff sago007 2012-04-22 15:06 496
	bTT.setLabel(_("Two player - time trial"));
b0222eff sago007 2012-04-22 15:06 497
	bTT.setAction(runTwoPlayerTimeTrial);
b0222eff sago007 2012-04-22 15:06 498
	bVs.setLabel(_("Two player - vs"));
b0222eff sago007 2012-04-22 15:06 499
	bVs.setAction(runTwoPlayerVs);
b0222eff sago007 2012-04-22 15:06 500
	mm.addButton(&bTT);
b0222eff sago007 2012-04-22 15:06 501
	mm.addButton(&bVs);
20d77c6e sago007 2016-11-12 16:28 502
	RunGameState(mm);
b0222eff sago007 2012-04-22 15:06 503
}
b0222eff sago007 2012-04-22 15:06 504
d8fe60bd sago007 2018-04-02 16:15 505
static void runHowto() {
d8fe60bd sago007 2018-04-02 16:15 506
	HelpHowtoState howto;
d8fe60bd sago007 2018-04-02 16:15 507
	RunGameState(howto);
d8fe60bd sago007 2018-04-02 16:15 508
}
d8fe60bd sago007 2018-04-02 16:15 509
bfb4fed7 Poul Sander 2022-02-14 19:35 510
static void runHelpModInfo() {
bfb4fed7 Poul Sander 2022-02-14 19:35 511
	HelpModInfoState modInfo;
bfb4fed7 Poul Sander 2022-02-14 19:35 512
	RunGameState(modInfo);
bfb4fed7 Poul Sander 2022-02-14 19:35 513
}
bfb4fed7 Poul Sander 2022-02-14 19:35 514
54d2d583 sago007 2018-04-05 17:52 515
static void runHelpGamepad() {
54d2d583 sago007 2018-04-05 17:52 516
	HelpGamepadState helpGamepad;
54d2d583 sago007 2018-04-05 17:52 517
	RunGameState(helpGamepad);
54d2d583 sago007 2018-04-05 17:52 518
}
54d2d583 sago007 2018-04-05 17:52 519
5147de4e Poul Sander 2018-05-06 12:59 520
static void runHelpAbout() {
5147de4e Poul Sander 2018-05-06 12:59 521
	HelpAboutState helpAbout;
5147de4e Poul Sander 2018-05-06 12:59 522
	RunGameState(helpAbout);
5147de4e Poul Sander 2018-05-06 12:59 523
}
5147de4e Poul Sander 2018-05-06 12:59 524
0471a1d3 sago007 2018-05-19 10:26 525
static void runCredits() {
0471a1d3 sago007 2018-05-19 10:26 526
	ShowFileState creditsFile;
0471a1d3 sago007 2018-05-19 10:26 527
	creditsFile.SetData("misc/AUTHORS", _("Credits"));
0471a1d3 sago007 2018-05-19 10:26 528
	RunGameState(creditsFile);
0471a1d3 sago007 2018-05-19 10:26 529
}
0471a1d3 sago007 2018-05-19 10:26 530
d8fe60bd sago007 2018-04-02 16:15 531
static void HelpMenu() {
d8fe60bd sago007 2018-04-02 16:15 532
	Menu m(globalData.screen, _("Help"), true);
d8fe60bd sago007 2018-04-02 16:15 533
	Button bHowto;
d8fe60bd sago007 2018-04-02 16:15 534
	bHowto.setLabel(_("How to"));
d8fe60bd sago007 2018-04-02 16:15 535
	bHowto.setAction(runHowto);
d8fe60bd sago007 2018-04-02 16:15 536
	m.addButton(&bHowto);
54d2d583 sago007 2018-04-05 17:52 537
	Button bGamepad;
54d2d583 sago007 2018-04-05 17:52 538
	bGamepad.setLabel(_("Gamepad"));
54d2d583 sago007 2018-04-05 17:52 539
	bGamepad.setAction(runHelpGamepad);
54d2d583 sago007 2018-04-05 17:52 540
	m.addButton(&bGamepad);
bfb4fed7 Poul Sander 2022-02-14 19:35 541
	Button bModInfo;
bfb4fed7 Poul Sander 2022-02-14 19:35 542
	bModInfo.setLabel(_("Mod info"));
bfb4fed7 Poul Sander 2022-02-14 19:35 543
	bModInfo.setAction(runHelpModInfo);
bfb4fed7 Poul Sander 2022-02-14 19:35 544
	m.addButton(&bModInfo);
0471a1d3 sago007 2018-05-19 10:26 545
	Button bCredits;
0471a1d3 sago007 2018-05-19 10:26 546
	bCredits.setLabel(_("Credits"));
0471a1d3 sago007 2018-05-19 10:26 547
	bCredits.setAction(runCredits);
0471a1d3 sago007 2018-05-19 10:26 548
	m.addButton(&bCredits);
5147de4e Poul Sander 2018-05-06 12:59 549
	Button bAbout;
5147de4e Poul Sander 2018-05-06 12:59 550
	bAbout.setLabel(_("About"));
5147de4e Poul Sander 2018-05-06 12:59 551
	bAbout.setAction(runHelpAbout);
5147de4e Poul Sander 2018-05-06 12:59 552
	m.addButton(&bAbout);
d8fe60bd sago007 2018-04-02 16:15 553
	RunGameState(m);
d8fe60bd sago007 2018-04-02 16:15 554
}
d8fe60bd sago007 2018-04-02 16:15 555
2f331f0c sago007 2017-08-19 16:17 556
static void SinglePlayerMenu() {
2f331f0c sago007 2017-08-19 16:17 557
	Menu m(globalData.screen, _("Single player"), true);
2f331f0c sago007 2017-08-19 16:17 558
	Button bHi,bTimetrial1, bStageClear, bPuzzle, bVs1;
c53e6443 sago007 2012-04-17 11:04 559
	bHi.setLabel(_("Single player - endless") );
c53e6443 sago007 2012-04-17 11:04 560
	bHi.setAction(runSinglePlayerEndless);
c53e6443 sago007 2012-04-17 11:04 561
	bTimetrial1.setLabel(_("Single player - time trial") );
c53e6443 sago007 2012-04-17 11:04 562
	bTimetrial1.setAction(runSinglePlayerTimeTrial);
aede0664 sago007 2012-04-19 19:45 563
	bStageClear.setLabel(_("Single player - stage clear") );
aede0664 sago007 2012-04-19 19:45 564
	bStageClear.setAction(runStageClear);
c53e6443 sago007 2012-04-17 11:04 565
	bPuzzle.setLabel(_("Single player - puzzle mode") );
c53e6443 sago007 2012-04-17 11:04 566
	bPuzzle.setAction(runSinglePlayerPuzzle);
c53e6443 sago007 2012-04-17 11:04 567
	bVs1.setLabel(_("Single player - vs") );
67a32395 sago007 2012-04-19 18:40 568
	bVs1.setAction(SinglePlayerVsMenu);
2f331f0c sago007 2017-08-19 16:17 569
	m.addButton(&bHi);
2f331f0c sago007 2017-08-19 16:17 570
	m.addButton(&bTimetrial1);
2f331f0c sago007 2017-08-19 16:17 571
	m.addButton(&bStageClear);
2f331f0c sago007 2017-08-19 16:17 572
	m.addButton(&bPuzzle);
2f331f0c sago007 2017-08-19 16:17 573
	m.addButton(&bVs1);
2f331f0c sago007 2017-08-19 16:17 574
	RunGameState(m);
2f331f0c sago007 2017-08-19 16:17 575
}
2f331f0c sago007 2017-08-19 16:17 576
ccee1ad0 Poul Sander 2019-03-13 18:39 577
void SafeModeMenu() {
ccee1ad0 Poul Sander 2019-03-13 18:39 578
	if (Config::getInstance()->getInt("always-software")) {
ccee1ad0 Poul Sander 2019-03-13 18:39 579
		return;
ccee1ad0 Poul Sander 2019-03-13 18:39 580
	}
ccee1ad0 Poul Sander 2019-03-13 18:39 581
	InitMenues();
ccee1ad0 Poul Sander 2019-03-13 18:39 582
	Menu safeMode(globalData.screen, _("Game did not shutdown as it should"), true);
ccee1ad0 Poul Sander 2019-03-13 18:39 583
	Button bOnce;
ccee1ad0 Poul Sander 2019-03-13 18:39 584
	Button bAlways;
ccee1ad0 Poul Sander 2019-03-13 18:39 585
	bOnce.setLabel(_("Use software renderer this time"));
ccee1ad0 Poul Sander 2019-03-13 18:39 586
	bAlways.setLabel(_("Always use software renderer"));
ccee1ad0 Poul Sander 2019-03-13 18:39 587
	bOnce.setPopOnRun(true);
9c7fa9a1 sago007 2020-06-27 22:09 588
	bAlways.setAction([]() {
9c7fa9a1 sago007 2020-06-27 22:09 589
		Config::getInstance()->setInt("always-software", 1);
9c7fa9a1 sago007 2020-06-27 22:09 590
	});
ccee1ad0 Poul Sander 2019-03-13 18:39 591
	bAlways.setPopOnRun(true);
ccee1ad0 Poul Sander 2019-03-13 18:39 592
	safeMode.addButton(&bOnce);
ccee1ad0 Poul Sander 2019-03-13 18:39 593
	safeMode.addButton(&bAlways);
ccee1ad0 Poul Sander 2019-03-13 18:39 594
	RunGameState(safeMode);
ccee1ad0 Poul Sander 2019-03-13 18:39 595
}
ccee1ad0 Poul Sander 2019-03-13 18:39 596
2f331f0c sago007 2017-08-19 16:17 597
void MainMenu() {
2f331f0c sago007 2017-08-19 16:17 598
	InitMenues();
2f331f0c sago007 2017-08-19 16:17 599
	Menu m(globalData.screen,_("Block Attack - Rise of the blocks"),false);
d8fe60bd sago007 2018-04-02 16:15 600
	Button bHi, bMulti, bConfigure, bHighscore, bHelp;
2f331f0c sago007 2017-08-19 16:17 601
	bHi.setLabel(_("Single player") );
2f331f0c sago007 2017-08-19 16:17 602
	bHi.setAction(SinglePlayerMenu);
b0222eff sago007 2012-04-22 15:06 603
	bMulti.setLabel(_("Multi player") );
b0222eff sago007 2012-04-22 15:06 604
	bMulti.setAction(MultiplayerMenu);
c53e6443 sago007 2012-04-17 11:04 605
	bConfigure.setLabel(_("Configure") );
c53e6443 sago007 2012-04-17 11:04 606
	bConfigure.setAction(ConfigureMenu);
c53e6443 sago007 2012-04-17 11:04 607
	bHighscore.setLabel(_("Highscores") );
c53e6443 sago007 2012-04-17 11:04 608
	bHighscore.setAction(buttonActionHighscores);
d8fe60bd sago007 2018-04-02 16:15 609
	bHelp.setLabel(_("Help"));
d8fe60bd sago007 2018-04-02 16:15 610
	bHelp.setAction(HelpMenu);
c53e6443 sago007 2012-04-17 11:04 611
	m.addButton(&bHi);
b0222eff sago007 2012-04-22 15:06 612
	m.addButton(&bMulti);
c53e6443 sago007 2012-04-17 11:04 613
	m.addButton(&bConfigure);
c53e6443 sago007 2012-04-17 11:04 614
	m.addButton(&bHighscore);
d8fe60bd sago007 2018-04-02 16:15 615
	m.addButton(&bHelp);
95ab6b0d sago007 2016-11-12 16:11 616
	RunGameState(m);
593aeae4 sago007 2011-06-25 22:42 617
}
1970-01-01 00:00 618