button to preview all dialogs in node list
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include "dialogxml/widgets/field.hpp"
|
||||
#include "dialogxml/widgets/button.hpp"
|
||||
#include "universe/universe.hpp"
|
||||
|
||||
#include "dialogxml/dialogs/dialog.hpp"
|
||||
@@ -58,6 +59,7 @@ extern rectangle right_buttons[NRSONPAGE];
|
||||
extern rectangle right_scrollbar_rect;
|
||||
extern std::shared_ptr<cScrollbar> right_sbar, pal_sbar;
|
||||
extern std::shared_ptr<cTextField> palette_search_field;
|
||||
extern std::shared_ptr<cButton> dialogs_preview_button;
|
||||
extern rectangle search_field_text_rect;
|
||||
extern boost::variant<boost::none_t, std::pair<long,bool>, cTownperson, cTown::cItem, vector2d<ter_num_t>> clipboard;
|
||||
|
||||
@@ -428,6 +430,8 @@ extern size_t num_strs(short mode); // defined in scen.keydlgs.cpp
|
||||
static void apply_mode_buttons() {
|
||||
right_button_status.clear();
|
||||
int num_options;
|
||||
|
||||
dialogs_preview_button->hide();
|
||||
switch(overall_mode){
|
||||
case MODE_EDIT_SPECIAL_ITEMS:
|
||||
num_options = scenario.special_items.size() + 1;
|
||||
@@ -558,6 +562,7 @@ static void apply_mode_buttons() {
|
||||
case 2: set_rb(num_specs, RB_TOWN_SPEC, num_specs, make_new); break;
|
||||
}
|
||||
set_lb(NLS - 3,LB_TEXT,LB_NO_ACTION,"Alt-click to delete",true);
|
||||
dialogs_preview_button->show();
|
||||
}break;
|
||||
case MODE_EDIT_DIALOGUE:{
|
||||
// TODO use stringstream and give more readable info
|
||||
@@ -616,8 +621,6 @@ void draw_main_screen() {
|
||||
}else{
|
||||
palette_search_field->hide();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void draw_lb() {
|
||||
|
||||
@@ -873,7 +873,8 @@ static void save_spec_enc(cDialog& me, node_stack_t& edit_stack) {
|
||||
the_node.jumpto = me["jump"].getTextAsNum();
|
||||
}
|
||||
|
||||
static bool preview_spec_enc_dlog(cDialog& me, std::string, cSpecial& special, short mode) {
|
||||
bool preview_spec_enc_dlog(cDialog* parent, cSpecial& special, short mode) {
|
||||
// TODO pass parent to all the preview dialogs
|
||||
eSpecCtxType cur_type = static_cast<eSpecCtxType>(mode);
|
||||
|
||||
extern cUniverse temp_universe();
|
||||
@@ -943,7 +944,7 @@ static bool preview_spec_enc_dlog(cDialog& me, std::string, cSpecial& special, s
|
||||
break;
|
||||
case eSpecType::ONCE_GIVE_ITEM_DIALOG:
|
||||
buttons = {9, 19, -1};
|
||||
once_dialog(univ, special, cur_type, buttons, &me);
|
||||
once_dialog(univ, special, cur_type, buttons, parent);
|
||||
break;
|
||||
case eSpecType::ONCE_TRAP:
|
||||
buttons = {3, 2, -1};
|
||||
@@ -951,7 +952,7 @@ static bool preview_spec_enc_dlog(cDialog& me, std::string, cSpecial& special, s
|
||||
custom_choice_dialog(strs,special.pic,ePicType(special.pictype),buttons, true, special.ex1c, special.ex2c, &univ);
|
||||
break;
|
||||
case eSpecType::ONCE_DIALOG:
|
||||
once_dialog(univ, special, cur_type, &me);
|
||||
once_dialog(univ, special, cur_type, parent);
|
||||
break;
|
||||
case eSpecType::TITLED_MSG:
|
||||
univ.get_str(title, cur_type, special.m3);
|
||||
@@ -962,7 +963,7 @@ static bool preview_spec_enc_dlog(cDialog& me, std::string, cSpecial& special, s
|
||||
univ.get_strs(strs[0], strs[1], cur_type, special.m1, special.m2);
|
||||
if(strs[0].empty() && strs[1].empty()) break;
|
||||
|
||||
cStrDlog dlog(strs[0], strs[1], title, pic, pic_type, &me);
|
||||
cStrDlog dlog(strs[0], strs[1], title, pic, pic_type, parent);
|
||||
dlog->getControl("record").show();
|
||||
dlog.show();
|
||||
break;
|
||||
@@ -972,6 +973,10 @@ static bool preview_spec_enc_dlog(cDialog& me, std::string, cSpecial& special, s
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool preview_spec_enc_dlog(cDialog& me, std::string, cSpecial& special, short mode) {
|
||||
return preview_spec_enc_dlog(&me, special, mode);
|
||||
}
|
||||
|
||||
static bool preview_spec_enc_dlog_stack(cDialog& me, std::string item_hit, node_stack_t& edit_stack, short mode) {
|
||||
save_spec_enc(me, edit_stack);
|
||||
cSpecial& special = edit_stack.back().node;
|
||||
|
||||
@@ -60,6 +60,7 @@ short cen_x, cen_y;
|
||||
eScenMode overall_mode = MODE_INTRO_SCREEN;
|
||||
std::shared_ptr<cScrollbar> right_sbar, pal_sbar;
|
||||
std::shared_ptr<cTextField> palette_search_field;
|
||||
std::shared_ptr<cButton> dialogs_preview_button;
|
||||
short mode_count = 0;
|
||||
short right_button_hovered = -1;
|
||||
|
||||
@@ -267,6 +268,43 @@ static void init_search_field() {
|
||||
event_listeners["search_field"] = std::dynamic_pointer_cast<iEventListener>(palette_search_field);
|
||||
}
|
||||
|
||||
static void init_preview_button() {
|
||||
static cParentless mainWin(mainPtr());
|
||||
cButton::init();
|
||||
dialogs_preview_button.reset(new cButton(mainWin));
|
||||
dialogs_preview_button->setColour(Colours::BLACK);
|
||||
dialogs_preview_button->relocate({RIGHT_AREA_UL_X + 5, RIGHT_AREA_UL_Y + RIGHT_AREA_HEIGHT + 16});
|
||||
dialogs_preview_button->setBtnType(BTN_TINY);
|
||||
dialogs_preview_button->setText("Preview All Dialogs");
|
||||
dialogs_preview_button->show();
|
||||
dialogs_preview_button->recalcRect();
|
||||
drawable_mgr.add_drawable(UI_LAYER_DEFAULT, "preview_button", dialogs_preview_button);
|
||||
event_listeners["preview_button"] = std::dynamic_pointer_cast<iEventListener>(dialogs_preview_button);
|
||||
|
||||
dialogs_preview_button->attachClickHandler([](cDialog&, std::string, eKeyMod) -> bool {
|
||||
std::vector<cSpecial>* current_specials;
|
||||
switch(scenario.editor_state.special_editing_mode){
|
||||
case 0:
|
||||
current_specials = &scenario.scen_specials;
|
||||
break;
|
||||
case 1:
|
||||
current_specials = ¤t_terrain->specials;
|
||||
break;
|
||||
case 2:
|
||||
current_specials = &town->specials;
|
||||
break;
|
||||
}
|
||||
|
||||
for(cSpecial& special : *current_specials){
|
||||
if((*special.type).can_preview){
|
||||
extern bool preview_spec_enc_dlog(cDialog* parent, cSpecial& special, short mode);
|
||||
preview_spec_enc_dlog(nullptr, special, scenario.editor_state.special_editing_mode);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
sf::FloatRect compute_viewport(const sf::RenderWindow& mainPtr, float ui_scale) {
|
||||
|
||||
// See compute_viewport() in boe.graphics.cpp
|
||||
@@ -384,6 +422,7 @@ void init_scened(int argc, char* argv[]) {
|
||||
Set_up_win();
|
||||
init_scrollbars();
|
||||
init_search_field();
|
||||
init_preview_button();
|
||||
init_lb();
|
||||
init_rb();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user