preview special item
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "fileio/resmgr/res_dialog.hpp"
|
||||
#include "sounds.hpp"
|
||||
#include "dialogxml/dialogs/choicedlog.hpp"
|
||||
#include "dialogxml/dialogs/strdlog.hpp"
|
||||
#include "dialogxml/widgets/pict.hpp"
|
||||
#include "dialogxml/widgets/button.hpp"
|
||||
#include "dialogxml/widgets/field.hpp"
|
||||
@@ -38,6 +39,7 @@
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include "scenario/scenario.hpp"
|
||||
#include "universe/universe.hpp"
|
||||
#include "item.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace ticpp;
|
||||
@@ -55,7 +57,6 @@ std::function<void(sf::RenderWindow& win)> cDialog::onHandleEvents;
|
||||
extern std::map<std::string,sf::Color> colour_map;
|
||||
|
||||
extern bool check_for_interrupt(std::string);
|
||||
extern void showError(std::string str1, cDialog* parent = nullptr);
|
||||
|
||||
std::string cDialog::generateId(const std::string& explicitId) const {
|
||||
return explicitId.empty() ? cControl::generateRandomString() : explicitId;
|
||||
@@ -1399,3 +1400,10 @@ std::string get_text_response(std::string prompt, pic_num_t pic) {
|
||||
boost::algorithm::to_lower(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void show_spec_item(const cSpecItem& item, const cScenario& scenario, cDialog* parent) {
|
||||
cStrDlog display_strings(item.descr,"",
|
||||
item.name,scenario.intro_pic,PIC_SCEN,parent);
|
||||
display_strings.setSound(57);
|
||||
display_strings.show();
|
||||
}
|
||||
@@ -38,6 +38,8 @@ class cContainer;
|
||||
class cTextField;
|
||||
struct DialogDefn;
|
||||
class cUniverse;
|
||||
class cSpecItem;
|
||||
class cScenario;
|
||||
|
||||
/// Specifies the relative position of a control's labelling text.
|
||||
enum eLabelPos {
|
||||
@@ -399,6 +401,8 @@ void story_dialog(cUniverse& univ, std::string title, str_num_t first, str_num_t
|
||||
void custom_pic_dialog(std::string title, pic_num_t bigpic, pic_num_t icon);
|
||||
std::string get_text_response(std::string prompt = "", pic_num_t pic = 16);
|
||||
|
||||
void show_spec_item(const cSpecItem& item, const cScenario& scenario, cDialog* parent = nullptr);
|
||||
|
||||
// For development/debugging only.
|
||||
void preview_dialog_xml(fs::path dialog_xml);
|
||||
|
||||
|
||||
@@ -703,10 +703,7 @@ void put_quest_info(short which_i) {
|
||||
}
|
||||
|
||||
void put_spec_item_info (short which_i) {
|
||||
cStrDlog display_strings(univ.scenario.special_items[which_i].descr,"",
|
||||
univ.scenario.special_items[which_i].name,univ.scenario.intro_pic,PIC_SCEN);
|
||||
display_strings.setSound(57);
|
||||
display_strings.show();
|
||||
show_spec_item(univ.scenario.special_items[which_i], univ.scenario);
|
||||
}
|
||||
|
||||
// Callback for recording encounter strings
|
||||
|
||||
@@ -2283,7 +2283,13 @@ static bool edit_spec_item_event_filter(cDialog& me, std::string hit, cSpecItem&
|
||||
if(edit_spec_enc(spec,0,&me,is_new))
|
||||
me["spec"].setTextToNum(spec);
|
||||
save_spec_item(me, item, which, is_new);
|
||||
|
||||
} else if(hit == "preview"){
|
||||
// Use dark background that the game uses:
|
||||
short defaultBackground = cDialog::defaultBackground;
|
||||
cDialog::defaultBackground = cDialog::BG_DARK;
|
||||
save_spec_item(me, item, which, is_new);
|
||||
show_spec_item(item, scenario);
|
||||
cDialog::defaultBackground = defaultBackground;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -2302,7 +2308,7 @@ bool edit_spec_item(short which_item) {
|
||||
|
||||
cDialog item_dlg(*ResMgr::dialogs.get("edit-special-item"));
|
||||
item_dlg["spec"].attachFocusHandler(std::bind(check_range_msg, _1, _2, _3, -1, scenario.scen_specials.size(), "Scenario special node called", "-1 for no special"));
|
||||
item_dlg.attachClickHandlers(std::bind(edit_spec_item_event_filter, _1, _2, std::ref(item), std::ref(which_item), std::ref(is_new)), {"okay", "cancel", "clear", "edit-spec", "left", "right"});
|
||||
item_dlg.attachClickHandlers(std::bind(edit_spec_item_event_filter, _1, _2, std::ref(item), std::ref(which_item), std::ref(is_new)), {"okay", "cancel", "clear", "edit-spec", "left", "right", "preview"});
|
||||
|
||||
if(scenario.special_items.size() == 1) {
|
||||
item_dlg["left"].hide();
|
||||
|
||||
Reference in New Issue
Block a user