79 lines
3.2 KiB
C++
79 lines
3.2 KiB
C++
/*
|
|
* dlogutil.h
|
|
* BoE
|
|
*
|
|
* Created by Celtic Minstrel on 11/05/09.
|
|
*
|
|
*/
|
|
|
|
#ifndef DIALOG_3CHOICE_H
|
|
#define DIALOG_3CHOICE_H
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <array>
|
|
#include <boost/optional.hpp>
|
|
|
|
#include "dialogxml/keycodes.hpp"
|
|
#include "dialogxml/dialogs/choicedlog.hpp"
|
|
#include "dialogxml/widgets/button.hpp"
|
|
#include "dialogxml/widgets/pictypes.hpp"
|
|
|
|
/// Basic button type template
|
|
struct bbtt {
|
|
eBtnType type; ///< The type of the preset button.
|
|
std::string label; ///< The preset button's label, if any.
|
|
cKey defaultKey; ///< The preset button's default key shortcut, if any.
|
|
std::string name; ///< (optional) A more descriptive name for the button.
|
|
};
|
|
|
|
/// Represents a preset button for use with cThreeChoice.
|
|
typedef boost::optional<bbtt> cBasicButtonType;
|
|
|
|
namespace {cBasicButtonType null_btn = boost::none;}
|
|
#ifndef BTNS_DEFINED
|
|
extern bbtt basic_buttons[71];
|
|
#endif
|
|
|
|
/// A choice dialog with several strings and up to three buttons.
|
|
/// This is the class used for dialogs generated by special nodes.
|
|
/// It generates the dialog dynamically from the given input.
|
|
/// Note that the dialog is not limited to six strings.
|
|
class cThreeChoice : public cChoiceDlog {
|
|
cBasicButtonType btns[3];
|
|
unsigned short buttons_right, buttons_top;
|
|
void init_strings(std::vector<std::string>& strings, unsigned short left);
|
|
void init_buttons(cBasicButtonType btn1, cBasicButtonType btn2, cBasicButtonType btn3);
|
|
void init_pict(pic_num_t pic);
|
|
const ePicType type;
|
|
public:
|
|
/// Create a dialog with just one button.
|
|
/// @param strings A list of the strings to place in the dialog.
|
|
/// @param button The specification of the button.
|
|
/// @param pic The icon to show at the top left.
|
|
/// @param t The type of the icon.
|
|
/// @param parent Optionally, a parent dialog.
|
|
cThreeChoice(std::vector<std::string>& strings, cBasicButtonType button, pic_num_t pic, ePicType t, cDialog* parent = nullptr);
|
|
/// Create a dialog with up to three buttons.
|
|
/// @param strings A list of the strings to place in the dialog.
|
|
/// @param buttons A list of the button specifications.
|
|
/// @param pic The icon to show at the top left.
|
|
/// @param t The type of the icon.
|
|
/// @param parent Optionally, a parent dialog.
|
|
cThreeChoice(std::vector<std::string>& strings, std::array<cBasicButtonType, 3>& buttons, pic_num_t pic, ePicType t, cDialog* parent = nullptr);
|
|
/// Create a dialog with up to three buttons.
|
|
/// @param strings A list of the strings to place in the dialog.
|
|
/// @param buttons A list of the index of the button; this is an index into available_btns which is in turn used to index basic_buttons.
|
|
/// @param pic The icon to show at the top left.
|
|
/// @param t The type of the icon.
|
|
/// @param parent Optionally, a parent dialog.
|
|
cThreeChoice(std::vector<std::string>& strings, std::array<short, 3>& buttons, pic_num_t pic, ePicType t, cDialog* parent = nullptr);
|
|
/// @copydoc cChoiceDlog::show()
|
|
/// @note The unique key in this case is the label specified in the button specification.
|
|
std::string show();
|
|
};
|
|
|
|
short custom_choice_dialog(std::array<std::string, 6>& strs,short pic_num,ePicType pic_type,std::array<short, 3>& buttons, bool anim_pict = false, short anim_loops = -1, int anim_fps = -1);
|
|
|
|
#endif
|