mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-22 21:40:42 +00:00
Rewrite some awful code
This commit is contained in:
parent
e9f63270d9
commit
d01f89b153
@ -227,9 +227,6 @@ namespace MWBase
|
|||||||
virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons = std::vector<std::string>(), bool showInDialogueModeOnly = false) = 0;
|
virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons = std::vector<std::string>(), bool showInDialogueModeOnly = false) = 0;
|
||||||
virtual void staticMessageBox(const std::string& message) = 0;
|
virtual void staticMessageBox(const std::string& message) = 0;
|
||||||
virtual void removeStaticMessageBox() = 0;
|
virtual void removeStaticMessageBox() = 0;
|
||||||
|
|
||||||
virtual void enterPressed () = 0;
|
|
||||||
virtual void activateKeyPressed () = 0;
|
|
||||||
virtual int readPressedButton() = 0;
|
virtual int readPressedButton() = 0;
|
||||||
///< returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
|
///< returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
|
||||||
|
|
||||||
|
@ -139,6 +139,7 @@ namespace MWGui
|
|||||||
|
|
||||||
mDisposeCorpseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onDisposeCorpseButtonClicked);
|
mDisposeCorpseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onDisposeCorpseButtonClicked);
|
||||||
mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onCloseButtonClicked);
|
mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onCloseButtonClicked);
|
||||||
|
mCloseButton->eventKeyButtonPressed += MyGUI::newDelegate(this, &ContainerWindow::onKeyPressed);
|
||||||
mTakeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onTakeAllButtonClicked);
|
mTakeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onTakeAllButtonClicked);
|
||||||
|
|
||||||
setCoord(200,0,600,300);
|
setCoord(200,0,600,300);
|
||||||
@ -234,11 +235,21 @@ namespace MWGui
|
|||||||
|
|
||||||
mItemView->setModel (mSortModel);
|
mItemView->setModel (mSortModel);
|
||||||
|
|
||||||
|
MyGUI::InputManager::getInstance().setKeyFocusWidget(mCloseButton);
|
||||||
|
|
||||||
// Careful here. setTitle may cause size updates, causing itemview redraw, so make sure to do it last
|
// Careful here. setTitle may cause size updates, causing itemview redraw, so make sure to do it last
|
||||||
// or we end up using a possibly invalid model.
|
// or we end up using a possibly invalid model.
|
||||||
setTitle(MWWorld::Class::get(container).getName(container));
|
setTitle(MWWorld::Class::get(container).getName(container));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContainerWindow::onKeyPressed(MyGUI::Widget *_sender, MyGUI::KeyCode _key, MyGUI::Char _char)
|
||||||
|
{
|
||||||
|
if (_key == MyGUI::KeyCode::Space)
|
||||||
|
onCloseButtonClicked(mCloseButton);
|
||||||
|
if (_key == MyGUI::KeyCode::Return || _key == MyGUI::KeyCode::NumpadEnter)
|
||||||
|
onTakeAllButtonClicked(mTakeButton);
|
||||||
|
}
|
||||||
|
|
||||||
void ContainerWindow::close()
|
void ContainerWindow::close()
|
||||||
{
|
{
|
||||||
WindowBase::close();
|
WindowBase::close();
|
||||||
|
@ -75,6 +75,7 @@ namespace MWGui
|
|||||||
void onCloseButtonClicked(MyGUI::Widget* _sender);
|
void onCloseButtonClicked(MyGUI::Widget* _sender);
|
||||||
void onTakeAllButtonClicked(MyGUI::Widget* _sender);
|
void onTakeAllButtonClicked(MyGUI::Widget* _sender);
|
||||||
void onDisposeCorpseButtonClicked(MyGUI::Widget* sender);
|
void onDisposeCorpseButtonClicked(MyGUI::Widget* sender);
|
||||||
|
void onKeyPressed(MyGUI::Widget* _sender, MyGUI::KeyCode _key, MyGUI::Char _char);
|
||||||
|
|
||||||
/// @return is taking the item allowed?
|
/// @return is taking the item allowed?
|
||||||
bool onTakeItem(const ItemStack& item, int count);
|
bool onTakeItem(const ItemStack& item, int count);
|
||||||
|
@ -127,12 +127,6 @@ namespace MWGui
|
|||||||
mMessageBoxSpeed = speed;
|
mMessageBoxSpeed = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageBoxManager::okayPressed ()
|
|
||||||
{
|
|
||||||
if(mInterMessageBoxe != NULL)
|
|
||||||
mInterMessageBoxe->okayPressed();
|
|
||||||
}
|
|
||||||
|
|
||||||
int MessageBoxManager::readPressedButton ()
|
int MessageBoxManager::readPressedButton ()
|
||||||
{
|
{
|
||||||
int pressed = mLastButtonPressed;
|
int pressed = mLastButtonPressed;
|
||||||
@ -333,23 +327,25 @@ namespace MWGui
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void InteractiveMessageBox::okayPressed()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
// Set key focus to "Ok" button
|
||||||
std::string ok = Misc::StringUtils::lowerCase(MyGUI::LanguageManager::getInstance().replaceTags("#{sOK}"));
|
std::string ok = Misc::StringUtils::lowerCase(MyGUI::LanguageManager::getInstance().replaceTags("#{sOK}"));
|
||||||
std::vector<MyGUI::Button*>::const_iterator button;
|
std::vector<MyGUI::Button*>::const_iterator button;
|
||||||
for(button = mButtons.begin(); button != mButtons.end(); ++button)
|
for(button = mButtons.begin(); button != mButtons.end(); ++button)
|
||||||
{
|
{
|
||||||
if(Misc::StringUtils::lowerCase((*button)->getCaption()) == ok)
|
if(Misc::StringUtils::lowerCase((*button)->getCaption()) == ok)
|
||||||
{
|
{
|
||||||
buttonActivated(*button);
|
MyGUI::InputManager::getInstance().setKeyFocusWidget(*button);
|
||||||
MWBase::Environment::get().getSoundManager()->playSound("Menu Click", 1.f, 1.f);
|
(*button)->eventKeyButtonPressed += MyGUI::newDelegate(this, &InteractiveMessageBox::onKeyPressed);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void InteractiveMessageBox::onKeyPressed(MyGUI::Widget *_sender, MyGUI::KeyCode _key, MyGUI::Char _char)
|
||||||
|
{
|
||||||
|
if (_key == MyGUI::KeyCode::Return || _key == MyGUI::KeyCode::NumpadEnter || _key == MyGUI::KeyCode::Space)
|
||||||
|
buttonActivated(_sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InteractiveMessageBox::mousePressed (MyGUI::Widget* pressed)
|
void InteractiveMessageBox::mousePressed (MyGUI::Widget* pressed)
|
||||||
|
@ -33,7 +33,6 @@ namespace MWGui
|
|||||||
bool removeMessageBox (MessageBox *msgbox);
|
bool removeMessageBox (MessageBox *msgbox);
|
||||||
void setMessageBoxSpeed (int speed);
|
void setMessageBoxSpeed (int speed);
|
||||||
|
|
||||||
void okayPressed();
|
|
||||||
int readPressedButton ();
|
int readPressedButton ();
|
||||||
|
|
||||||
typedef MyGUI::delegates::CMultiDelegate1<int> EventHandle_Int;
|
typedef MyGUI::delegates::CMultiDelegate1<int> EventHandle_Int;
|
||||||
@ -74,7 +73,6 @@ namespace MWGui
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InteractiveMessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector<std::string>& buttons);
|
InteractiveMessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector<std::string>& buttons);
|
||||||
void okayPressed ();
|
|
||||||
void mousePressed (MyGUI::Widget* _widget);
|
void mousePressed (MyGUI::Widget* _widget);
|
||||||
int readPressedButton ();
|
int readPressedButton ();
|
||||||
|
|
||||||
@ -82,6 +80,7 @@ namespace MWGui
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void buttonActivated (MyGUI::Widget* _widget);
|
void buttonActivated (MyGUI::Widget* _widget);
|
||||||
|
void onKeyPressed(MyGUI::Widget* _sender, MyGUI::KeyCode _key, MyGUI::Char _char);
|
||||||
|
|
||||||
MessageBoxManager& mMessageBoxManager;
|
MessageBoxManager& mMessageBoxManager;
|
||||||
MyGUI::EditBox* mMessageWidget;
|
MyGUI::EditBox* mMessageWidget;
|
||||||
|
@ -677,17 +677,6 @@ namespace MWGui
|
|||||||
mMessageBoxManager->removeStaticMessageBox();
|
mMessageBoxManager->removeStaticMessageBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::enterPressed ()
|
|
||||||
{
|
|
||||||
mMessageBoxManager->okayPressed();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowManager::activateKeyPressed ()
|
|
||||||
{
|
|
||||||
mMessageBoxManager->okayPressed();
|
|
||||||
mCountDialog->cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
int WindowManager::readPressedButton ()
|
int WindowManager::readPressedButton ()
|
||||||
{
|
{
|
||||||
return mMessageBoxManager->readPressedButton();
|
return mMessageBoxManager->readPressedButton();
|
||||||
|
@ -222,8 +222,6 @@ namespace MWGui
|
|||||||
virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons = std::vector<std::string>(), bool showInDialogueModeOnly = false);
|
virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons = std::vector<std::string>(), bool showInDialogueModeOnly = false);
|
||||||
virtual void staticMessageBox(const std::string& message);
|
virtual void staticMessageBox(const std::string& message);
|
||||||
virtual void removeStaticMessageBox();
|
virtual void removeStaticMessageBox();
|
||||||
virtual void enterPressed ();
|
|
||||||
virtual void activateKeyPressed ();
|
|
||||||
virtual int readPressedButton (); ///< returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
|
virtual int readPressedButton (); ///< returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
|
||||||
|
|
||||||
virtual void onFrame (float frameDuration);
|
virtual void onFrame (float frameDuration);
|
||||||
|
@ -195,14 +195,7 @@ namespace MWInput
|
|||||||
case A_Activate:
|
case A_Activate:
|
||||||
resetIdleTime();
|
resetIdleTime();
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->isGuiMode())
|
if (!MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||||
{
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Container)
|
|
||||||
toggleContainer ();
|
|
||||||
else
|
|
||||||
MWBase::Environment::get().getWindowManager()->activateKeyPressed();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
activate();
|
activate();
|
||||||
break;
|
break;
|
||||||
case A_Journal:
|
case A_Journal:
|
||||||
@ -511,13 +504,6 @@ namespace MWInput
|
|||||||
|
|
||||||
mInputBinder->keyPressed (arg);
|
mInputBinder->keyPressed (arg);
|
||||||
|
|
||||||
if((arg.keysym.sym == SDLK_RETURN || arg.keysym.sym == SDLK_KP_ENTER)
|
|
||||||
&& MWBase::Environment::get().getWindowManager()->isGuiMode())
|
|
||||||
{
|
|
||||||
// Pressing enter when a messagebox is prompting for "ok" will activate the ok button
|
|
||||||
MWBase::Environment::get().getWindowManager()->enterPressed();
|
|
||||||
}
|
|
||||||
|
|
||||||
OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym);
|
OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym);
|
||||||
|
|
||||||
if (kc != OIS::KC_UNASSIGNED)
|
if (kc != OIS::KC_UNASSIGNED)
|
||||||
@ -730,21 +716,6 @@ namespace MWInput
|
|||||||
// .. but don't touch any other mode, except container.
|
// .. but don't touch any other mode, except container.
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputManager::toggleContainer()
|
|
||||||
{
|
|
||||||
if (MyGUI::InputManager::getInstance ().isModalAny())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(MWBase::Environment::get().getWindowManager()->isGuiMode())
|
|
||||||
{
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Container)
|
|
||||||
MWBase::Environment::get().getWindowManager()->popGuiMode();
|
|
||||||
else
|
|
||||||
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Container);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputManager::toggleConsole()
|
void InputManager::toggleConsole()
|
||||||
{
|
{
|
||||||
if (MyGUI::InputManager::getInstance ().isModalAny())
|
if (MyGUI::InputManager::getInstance ().isModalAny())
|
||||||
|
@ -173,7 +173,6 @@ namespace MWInput
|
|||||||
void toggleSpell();
|
void toggleSpell();
|
||||||
void toggleWeapon();
|
void toggleWeapon();
|
||||||
void toggleInventory();
|
void toggleInventory();
|
||||||
void toggleContainer();
|
|
||||||
void toggleConsole();
|
void toggleConsole();
|
||||||
void screenshot();
|
void screenshot();
|
||||||
void toggleJournal();
|
void toggleJournal();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user