Пример #1
0
void OptionsDialog::show() {
	OptionsDialog *dlg = new OptionsDialog();
	dlg->draw();

	GfxButton *btn = dlg->execute();

	if (btn == &dlg->_btnQuit) {
		// Quit game
		if (MessageDialog::show(QUIT_CONFIRM_MSG, CANCEL_BTN_STRING, QUIT_BTN_STRING) == 1) {
			_vm->quitGame();
		}
	} else if (btn == &dlg->_btnRestart) {
		// Restart game
		_globals->_game->restartGame();
	} else if (btn == &dlg->_btnSound) {
		// Sound dialog
	} else if (btn == &dlg->_btnSave) {
		// Save button
		_globals->_game->saveGame();
	} else if (btn == &dlg->_btnRestore) {
		// Restore button
		_globals->_game->restoreGame();
	}

	dlg->remove();
	delete dlg;
}
Пример #2
0
void OptionsDialog::show() {
	OptionsDialog *dlg = new OptionsDialog();
	dlg->draw();

	// Show the dialog
	GfxButton *btn = dlg->execute();

	// Get which button was pressed
	int btnIndex = -1;
	if (btn == &dlg->_btnRestore)
		btnIndex = 0;
	else if (btn == &dlg->_btnSave)
		btnIndex = 1;
	else if (btn == &dlg->_btnRestart)
		btnIndex = 2;
	else if (btn == &dlg->_btnQuit)
		btnIndex = 3;
	else if (btn == &dlg->_btnSound)
		btnIndex = 4;

	// Close the dialog
	dlg->remove();
	delete dlg;

	// Execute the given selection
	if (btnIndex == 0) {
		// Restore button
		g_globals->_game->restoreGame();
	} else if (btnIndex == 1) {
		// Save button
		g_globals->_game->saveGame();
	} else if (btnIndex == 2) {
		// Restart game
		g_globals->_game->restartGame();
	} else if (btnIndex == 3) {
		// Quit game
		if (MessageDialog::show(QUIT_CONFIRM_MSG, CANCEL_BTN_STRING, QUIT_BTN_STRING) == 1) {
			g_vm->quitGame();
		}
	} else if (btnIndex == 4) {
		// Sound dialog
		SoundDialog::execute();
	}
}