Esempio n. 1
0
void OrionCallbacks::saveLoadCancelFn(DialogView *view, MenuObject *item) {
	OrionMenuView *vw = (OrionMenuView *) view;

	if (view->_selectedSlot != -1) {
		// Pressed cancel with a save selected, so revert back to no selection

		// Re-enable all the other slots

		for (int index = 0; index < SL_NUM_VISIBLE_SLOTS; ++index) {
			if (index != view->_selectedSlot) {
				MenuSaveLoadText *currentItem = (MenuSaveLoadText *) view->getItem(SLTAG_SLOTS_START + index);
				currentItem->setState(OS_NORMAL);
			}
		}

		// Show the previously hidden slot again
		MenuSaveLoadText *slot = (MenuSaveLoadText *) view->getItem(SLTAG_SLOTS_START + view->_selectedSlot);
		slot->setVisible(true);
		slot->setState(OS_NORMAL);

		// Remove the text selection
		MenuTextField *textField = (MenuTextField *) view->getItem(SLTAG_TEXTFIELD);
		delete textField;
		vw->items().remove(textField);

		// Set button enablement
		MenuButton *btn = (MenuButton *) view->getItem(SLTAG_SAVELOAD);
		btn->setState(OS_GREYED);
		btn = (MenuButton *) view->getItem(SLTAG_CANCEL);
		btn->setState(OS_NORMAL);

		// Re-enable the slider

		MenuVertSlider *slider = (MenuVertSlider *) view->getItem(SLTAG_VSLIDER);
		slider->setState(OS_NORMAL);

		view->_selectedSlot = -1;

	} else {
		// Close the dialog
		if (vw->_loadSaveFromHotkey)
			// Since dialog was called from hotkey, return directly to the game
			closeMenuFn(view, item);
		else {
			// Return to the game menu
			view->vm()->loadMenu(GAME_MENU);
			view->close();
		}
	}
}
Esempio n. 2
0
void OrionCallbacks::saveLoadSlotFn(DialogView *view, MenuObject *item) {
	OrionMenuView *vw = (OrionMenuView *) view;
	MenuSaveLoadText *button = (MenuSaveLoadText *) item;

	view->_selectedSlot = button->getIndex();
	view->_deleteSaveDesc = true;

	// Disable all the slots except the selected one
	for (int index = 0; index < SL_NUM_VISIBLE_SLOTS; ++index) {
		MenuSaveLoadText *currentItem = (MenuSaveLoadText *) view->getItem(SLTAG_SLOTS_START + index);
		if (currentItem->getIndex() != button->getIndex()) {
			currentItem->setState(OS_GREYED);
		}
	}

	// Get a copy of the slot bounds
	Common::Rect slotBounds = button->getBounds();

	if (view->getMenuType() == SAVE_MENU) {
		// Add in a text field for entry of the savegame name
		vw->items().push_back(new MenuTextField(view, SLTAG_TEXTFIELD,
			slotBounds.left, slotBounds.top, slotBounds.width(), slotBounds.height(), false,
			saveLoadSaveFn, (button->getText() == EmptySaveString) ? NULL : button->getText(),
			button->getIndex() + 1));

	} else {
		vw->items().push_back(new MenuTextField(view, SLTAG_TEXTFIELD,
			slotBounds.left, slotBounds.top, slotBounds.width(), slotBounds.height(), true,
			saveLoadLoadFn, button->getText(), button->getIndex() + 1));
	}

	// Hide the existing slot
	button->setVisible(false);

	// Disable the slider

	MenuVertSlider *slider = (MenuVertSlider *) view->getItem(SLTAG_VSLIDER);
	slider->setState(OS_GREYED);

	// Enable the save/load button
	MenuButton *btn = (MenuButton *) view->getItem(SLTAG_SAVELOAD);
	btn->setState(OS_NORMAL);
}