mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-29 09:32:45 +00:00
28131fd62b
These warnings were always enabled, but we didn't see them due to https://gitlab.com/OpenMW/openmw/-/issues/7882. I do not fully understand the cause of 7822 as I can't repro it in a minimal CMake project. Some of these fixes are thought through. Some are sensible best guesses. Some are kind of a stab in the dark as I don't know whether there was a possible bug the warning was telling me about that I've done nothing to help by introducing a static_cast. Nearly all of these warnings were about some kind of narrowing conversion, so I'm not sure why they weren't firing with GCC and Clang, which have -Wall -Wextra -pedantic set, which should imply -Wnarrowing, and they can't have been affected by 7882. There were also some warnings being triggered from Boost code. The vast majority of library headers that do questionable things weren't firing warnings off, but for some reason, /external:I wasn't putting these Boost headers into external mode. We need these warnings dealt with one way or another so we can switch the default Windows CI from MSBuild (which doesn't do ccache) to Ninja (which does). I have the necessary magic for that on a branch, but the branch won't build because of these warnings.
122 lines
3.3 KiB
C++
122 lines
3.3 KiB
C++
#ifndef MWGUI_MESSAGE_BOX_H
|
|
#define MWGUI_MESSAGE_BOX_H
|
|
|
|
#include <memory>
|
|
|
|
#include "windowbase.hpp"
|
|
|
|
namespace MyGUI
|
|
{
|
|
class Widget;
|
|
class Button;
|
|
class EditBox;
|
|
}
|
|
|
|
namespace MWGui
|
|
{
|
|
class InteractiveMessageBox;
|
|
class MessageBoxManager;
|
|
class MessageBox;
|
|
class MessageBoxManager
|
|
{
|
|
public:
|
|
MessageBoxManager(float timePerChar);
|
|
~MessageBoxManager();
|
|
void onFrame(float frameDuration);
|
|
void createMessageBox(std::string_view message, bool stat = false);
|
|
void removeStaticMessageBox();
|
|
bool createInteractiveMessageBox(std::string_view message, const std::vector<std::string>& buttons,
|
|
bool immediate = false, int defaultFocus = -1);
|
|
bool isInteractiveMessageBox();
|
|
|
|
std::size_t getMessagesCount();
|
|
|
|
const InteractiveMessageBox* getInteractiveMessageBox() const { return mInterMessageBoxe.get(); }
|
|
|
|
/// Remove all message boxes
|
|
void clear();
|
|
|
|
bool removeMessageBox(MessageBox* msgbox);
|
|
|
|
/// @param reset Reset the pressed button to -1 after reading it.
|
|
int readPressedButton(bool reset = true);
|
|
|
|
void resetInteractiveMessageBox();
|
|
|
|
void setLastButtonPressed(int index);
|
|
|
|
typedef MyGUI::delegates::MultiDelegate<int> EventHandle_Int;
|
|
|
|
// Note: this delegate unassigns itself after it was fired, i.e. works once.
|
|
EventHandle_Int eventButtonPressed;
|
|
|
|
void onButtonPressed(int button)
|
|
{
|
|
eventButtonPressed(button);
|
|
eventButtonPressed.clear();
|
|
}
|
|
|
|
void setVisible(bool value);
|
|
|
|
const std::vector<std::unique_ptr<MessageBox>>& getActiveMessageBoxes() const;
|
|
|
|
private:
|
|
std::vector<std::unique_ptr<MessageBox>> mMessageBoxes;
|
|
std::unique_ptr<InteractiveMessageBox> mInterMessageBoxe;
|
|
MessageBox* mStaticMessageBox;
|
|
float mMessageBoxSpeed;
|
|
int mLastButtonPressed;
|
|
bool mVisible = true;
|
|
};
|
|
|
|
class MessageBox : public Layout
|
|
{
|
|
public:
|
|
MessageBox(MessageBoxManager& parMessageBoxManager, std::string_view message);
|
|
const std::string& getMessage() { return mMessage; }
|
|
int getHeight();
|
|
void update(int height);
|
|
void setVisible(bool value);
|
|
|
|
float mCurrentTime;
|
|
float mMaxTime;
|
|
|
|
protected:
|
|
MessageBoxManager& mMessageBoxManager;
|
|
std::string mMessage;
|
|
MyGUI::EditBox* mMessageWidget;
|
|
int mBottomPadding;
|
|
int mNextBoxPadding;
|
|
};
|
|
|
|
class InteractiveMessageBox : public WindowModal
|
|
{
|
|
public:
|
|
InteractiveMessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message,
|
|
const std::vector<std::string>& buttons, bool immediate, int defaultFocus);
|
|
void mousePressed(MyGUI::Widget* _widget);
|
|
int readPressedButton();
|
|
|
|
MyGUI::Widget* getDefaultKeyFocus() override;
|
|
|
|
bool exit() override { return false; }
|
|
|
|
bool mMarkedToDelete;
|
|
|
|
private:
|
|
void buttonActivated(MyGUI::Widget* _widget);
|
|
|
|
MessageBoxManager& mMessageBoxManager;
|
|
MyGUI::EditBox* mMessageWidget;
|
|
MyGUI::Widget* mButtonsWidget;
|
|
std::vector<MyGUI::Button*> mButtons;
|
|
|
|
int mButtonPressed;
|
|
int mDefaultFocus;
|
|
bool mImmediate;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|