Overwriting saves fixes - copy description of overwritten slot, ask for confirmation

actorid
scrawl 11 years ago
parent 6d37cd7e86
commit ec46575671

@ -15,6 +15,8 @@
#include "../mwstate/character.hpp"
#include "confirmationdialog.hpp"
namespace MWGui
{
SaveGameDialog::SaveGameDialog()
@ -36,17 +38,25 @@ namespace MWGui
mSaveList->eventListChangePosition += MyGUI::newDelegate(this, &SaveGameDialog::onSlotSelected);
mSaveList->eventListSelectAccept += MyGUI::newDelegate(this, &SaveGameDialog::onSlotActivated);
mSaveNameEdit->eventEditSelectAccept += MyGUI::newDelegate(this, &SaveGameDialog::onEditSelectAccept);
mSaveNameEdit->eventEditTextChange += MyGUI::newDelegate(this, &SaveGameDialog::onSaveNameChanged);
}
void SaveGameDialog::onSlotActivated(MyGUI::ListBox *sender, size_t pos)
{
onSlotSelected(sender, pos);
onOkButtonClicked(mOkButton);
accept();
}
void SaveGameDialog::onSaveNameChanged(MyGUI::EditBox *sender)
{
// This might have previously been a save slot from the list. If so, that is no longer the case
mSaveList->setIndexSelected(MyGUI::ITEM_NONE);
onSlotSelected(mSaveList, MyGUI::ITEM_NONE);
}
void SaveGameDialog::onEditSelectAccept(MyGUI::EditBox *sender)
{
onOkButtonClicked(mOkButton);
accept();
}
void SaveGameDialog::open()
@ -113,7 +123,12 @@ namespace MWGui
setVisible(false);
}
void SaveGameDialog::onOkButtonClicked(MyGUI::Widget *sender)
void SaveGameDialog::onConfirmationGiven()
{
accept(true);
}
void SaveGameDialog::accept(bool reallySure)
{
MyGUI::InputManager::getInstance().setKeyFocusWidget(NULL);
@ -132,6 +147,16 @@ namespace MWGui
if (mSaving)
{
// If overwriting an existing slot, ask for confirmation first
if (slot != NULL && !reallySure)
{
ConfirmationDialog* dialog = MWBase::Environment::get().getWindowManager()->getConfirmationDialog();
dialog->open("#{sMessage4}");
dialog->eventOkClicked.clear();
dialog->eventOkClicked += MyGUI::newDelegate(this, &SaveGameDialog::onConfirmationGiven);
dialog->eventCancelClicked.clear();
return;
}
if (mSaveNameEdit->getCaption().empty())
{
MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage65}");
@ -154,6 +179,11 @@ namespace MWGui
}
}
void SaveGameDialog::onOkButtonClicked(MyGUI::Widget *sender)
{
accept();
}
void SaveGameDialog::onCharacterSelected(MyGUI::ComboBox *sender, size_t pos)
{
MWBase::StateManager* mgr = MWBase::Environment::get().getStateManager();
@ -192,6 +222,9 @@ namespace MWGui
return;
}
if (mSaving)
mSaveNameEdit->setCaption(sender->getItemNameAt(pos));
const MWState::Slot* slot = NULL;
unsigned int i=0;
for (MWState::Character::SlotIterator it = mCurrentCharacter->begin(); it != mCurrentCharacter->end(); ++it, ++i)

@ -20,17 +20,20 @@ namespace MWGui
void setLoadOrSave(bool load);
private:
void onCancelButtonClicked (MyGUI::Widget* sender);
void onOkButtonClicked (MyGUI::Widget* sender);
void onCharacterSelected (MyGUI::ComboBox* sender, size_t pos);
void onSlotSelected (MyGUI::ListBox* sender, size_t pos);
void onSlotActivated (MyGUI::ListBox* sender, size_t pos);
void onEditSelectAccept (MyGUI::EditBox* sender);
void onSaveNameChanged (MyGUI::EditBox* sender);
void onConfirmationGiven();
void fillSaveList();
void accept(bool reallySure=false);
void fillSaveList();
private:
MyGUI::ImageBox* mScreenshot;
bool mSaving;

Loading…
Cancel
Save