preview quest
This commit is contained in:
@@ -27,8 +27,10 @@
|
|||||||
<button name='choose-bank1' type='regular' anchor='bank1' relative='pos pos-in' top='-4' left='8'>Choose</button>
|
<button name='choose-bank1' type='regular' anchor='bank1' relative='pos pos-in' top='-4' left='8'>Choose</button>
|
||||||
<field name='bank2' type='int' top='332' left='359' width='110' height='16'/>
|
<field name='bank2' type='int' top='332' left='359' width='110' height='16'/>
|
||||||
<button name='choose-bank2' type='regular' anchor='bank2' relative='pos pos-in' top='-4' left='8'>Choose</button>
|
<button name='choose-bank2' type='regular' anchor='bank2' relative='pos pos-in' top='-4' left='8'>Choose</button>
|
||||||
<button name='left' type='left' def-key='left' top='358' left='50'/>
|
|
||||||
<button name='right' type='right' def-key='right' top='358' left='115'/>
|
<button name='preview' type='regular' top='358' left='387'>Preview</button>
|
||||||
<button name='cancel' type='regular' top='358' left='322'>Cancel</button>
|
<button name='left' type='left' def-key='left' top='382' left='50'/>
|
||||||
<button name='okay' type='regular' top='358' left='387'>OK</button>
|
<button name='right' type='right' def-key='right' top='382' left='115'/>
|
||||||
|
<button name='cancel' type='regular' top='382' left='322'>Cancel</button>
|
||||||
|
<button name='okay' type='regular' top='382' left='387'>OK</button>
|
||||||
</dialog>
|
</dialog>
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
#include "scenario/scenario.hpp"
|
#include "scenario/scenario.hpp"
|
||||||
#include "universe/universe.hpp"
|
#include "universe/universe.hpp"
|
||||||
#include "item.hpp"
|
#include "item.hpp"
|
||||||
|
#include "quest.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace ticpp;
|
using namespace ticpp;
|
||||||
@@ -1406,4 +1407,19 @@ void show_spec_item(const cSpecItem& item, const cScenario& scenario, cDialog* p
|
|||||||
item.name,scenario.intro_pic,PIC_SCEN,parent);
|
item.name,scenario.intro_pic,PIC_SCEN,parent);
|
||||||
display_strings.setSound(57);
|
display_strings.setSound(57);
|
||||||
display_strings.show();
|
display_strings.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void show_quest(const cQuest& quest, int start, cDialog* parent) {
|
||||||
|
cDialog quest_dlg(*ResMgr::dialogs.get("quest-info"), parent);
|
||||||
|
quest_dlg["name"].setText(quest.name);
|
||||||
|
quest_dlg["descr"].setText(quest.descr);
|
||||||
|
quest_dlg["start"].setText(fmt::format("Day {}", start));
|
||||||
|
if(quest.deadline > 0)
|
||||||
|
quest_dlg["chop"].setText(fmt::format("Day {}", quest.deadline + int(quest.deadline_is_relative) * start));
|
||||||
|
else quest_dlg["chop"].setText("None");
|
||||||
|
if(quest.gold > 0)
|
||||||
|
quest_dlg["pay"].setText(fmt::format("{} gold", quest.gold));
|
||||||
|
else quest_dlg["pay"].setText("Unknown");
|
||||||
|
quest_dlg["done"].attachClickHandler(std::bind(&cDialog::toast, &quest_dlg, false));
|
||||||
|
quest_dlg.run();
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,7 @@ struct DialogDefn;
|
|||||||
class cUniverse;
|
class cUniverse;
|
||||||
class cSpecItem;
|
class cSpecItem;
|
||||||
class cScenario;
|
class cScenario;
|
||||||
|
class cQuest;
|
||||||
|
|
||||||
/// Specifies the relative position of a control's labelling text.
|
/// Specifies the relative position of a control's labelling text.
|
||||||
enum eLabelPos {
|
enum eLabelPos {
|
||||||
@@ -402,6 +403,7 @@ 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);
|
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);
|
void show_spec_item(const cSpecItem& item, const cScenario& scenario, cDialog* parent = nullptr);
|
||||||
|
void show_quest(const cQuest& quest, int start, cDialog* parent = nullptr);
|
||||||
|
|
||||||
// For development/debugging only.
|
// For development/debugging only.
|
||||||
void preview_dialog_xml(fs::path dialog_xml);
|
void preview_dialog_xml(fs::path dialog_xml);
|
||||||
|
|||||||
@@ -687,19 +687,7 @@ void add_to_journal(short event) {
|
|||||||
|
|
||||||
void put_quest_info(short which_i) {
|
void put_quest_info(short which_i) {
|
||||||
cQuest& quest = univ.scenario.quests[which_i];
|
cQuest& quest = univ.scenario.quests[which_i];
|
||||||
cDialog quest_dlg(*ResMgr::dialogs.get("quest-info"));
|
show_quest(quest, univ.party.active_quests[which_i].start);
|
||||||
quest_dlg["name"].setText(quest.name);
|
|
||||||
quest_dlg["descr"].setText(quest.descr);
|
|
||||||
int start = univ.party.active_quests[which_i].start;
|
|
||||||
quest_dlg["start"].setText(fmt::format("Day {}", start));
|
|
||||||
if(quest.deadline > 0)
|
|
||||||
quest_dlg["chop"].setText(fmt::format("Day {}", quest.deadline + int(quest.deadline_is_relative) * start));
|
|
||||||
else quest_dlg["chop"].setText("None");
|
|
||||||
if(quest.gold > 0)
|
|
||||||
quest_dlg["pay"].setText(fmt::format("{} gold", quest.gold));
|
|
||||||
else quest_dlg["pay"].setText("Unknown");
|
|
||||||
quest_dlg["done"].attachClickHandler(std::bind(&cDialog::toast, &quest_dlg, false));
|
|
||||||
quest_dlg.run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void put_spec_item_info (short which_i) {
|
void put_spec_item_info (short which_i) {
|
||||||
|
|||||||
@@ -2354,8 +2354,9 @@ static void put_quest_in_dlog(cDialog& me, const cQuest& quest, size_t which_que
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool save_quest_from_dlog(cDialog& me, cQuest& quest, size_t which_quest, bool& is_new, bool need_confirm, bool close) {
|
static bool save_quest_from_dlog(cDialog& me, cQuest& quest, size_t which_quest, bool& is_new, bool need_confirm, bool close, bool commit) {
|
||||||
if(!me.toast(true)) return false;
|
if(!me.toast(true)) return false;
|
||||||
|
if(!close) me.untoast();
|
||||||
|
|
||||||
quest.name = me["name"].getText();
|
quest.name = me["name"].getText();
|
||||||
quest.descr = me["descr"].getText();
|
quest.descr = me["descr"].getText();
|
||||||
@@ -2371,6 +2372,8 @@ static bool save_quest_from_dlog(cDialog& me, cQuest& quest, size_t which_quest,
|
|||||||
quest.bank2 = me["bank2"].getTextAsNum();
|
quest.bank2 = me["bank2"].getTextAsNum();
|
||||||
} else quest.bank1 = quest.bank2 = -1;
|
} else quest.bank1 = quest.bank2 = -1;
|
||||||
|
|
||||||
|
if(!commit) return true;
|
||||||
|
|
||||||
// Edit confirmed and real changes made:
|
// Edit confirmed and real changes made:
|
||||||
if(scenario.quests[which_quest] != quest || is_new){
|
if(scenario.quests[which_quest] != quest || is_new){
|
||||||
if(need_confirm){
|
if(need_confirm){
|
||||||
@@ -2395,12 +2398,11 @@ static bool save_quest_from_dlog(cDialog& me, cQuest& quest, size_t which_quest,
|
|||||||
is_new = false;
|
is_new = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!close) me.untoast();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool change_quest_dlog_page(cDialog& me, std::string dir, cQuest& quest, size_t& which_quest, bool& is_new) {
|
static bool change_quest_dlog_page(cDialog& me, std::string dir, cQuest& quest, size_t& which_quest, bool& is_new) {
|
||||||
if(!save_quest_from_dlog(me, quest, which_quest, is_new, true, false))
|
if(!save_quest_from_dlog(me, quest, which_quest, is_new, true, false, true))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(dir == "left") {
|
if(dir == "left") {
|
||||||
@@ -2431,7 +2433,7 @@ bool edit_quest(size_t which_quest) {
|
|||||||
|
|
||||||
cDialog quest_dlg(*ResMgr::dialogs.get("edit-quest"));
|
cDialog quest_dlg(*ResMgr::dialogs.get("edit-quest"));
|
||||||
quest_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, _1, false));
|
quest_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, _1, false));
|
||||||
quest_dlg["okay"].attachClickHandler(std::bind(save_quest_from_dlog, _1, std::ref(quest), std::ref(which_quest), std::ref(is_new), false, true));
|
quest_dlg["okay"].attachClickHandler(std::bind(save_quest_from_dlog, _1, std::ref(quest), std::ref(which_quest), std::ref(is_new), false, true, true));
|
||||||
quest_dlg.attachClickHandlers([](cDialog& me, std::string item_hit, eKeyMod) {
|
quest_dlg.attachClickHandlers([](cDialog& me, std::string item_hit, eKeyMod) {
|
||||||
std::string field_id = item_hit.substr(7);
|
std::string field_id = item_hit.substr(7);
|
||||||
std::string title = field_id == "evt" ? "Select an event:" : "Select a job board:";
|
std::string title = field_id == "evt" ? "Select an event:" : "Select a job board:";
|
||||||
@@ -2455,6 +2457,18 @@ bool edit_quest(size_t which_quest) {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
quest_dlg["preview"].attachClickHandler([&quest, &which_quest](cDialog& me, std::string, eKeyMod) -> bool {
|
||||||
|
bool is_new;
|
||||||
|
save_quest_from_dlog(me, quest, which_quest, is_new, false, false, false);
|
||||||
|
// Use dark background that the game uses:
|
||||||
|
short defaultBackground = cDialog::defaultBackground;
|
||||||
|
cDialog::defaultBackground = cDialog::BG_DARK;
|
||||||
|
show_quest(quest, 0, &me);
|
||||||
|
cDialog::defaultBackground = defaultBackground;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
// TODO: Some focus handlers
|
// TODO: Some focus handlers
|
||||||
// Should quests be able to award negative XP or negative gold? I typed the text fields as 'uint' for now.
|
// Should quests be able to award negative XP or negative gold? I typed the text fields as 'uint' for now.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user