Scaffold for dialog previews in the scen editor

This commit is contained in:
2025-04-30 11:07:16 -05:00
parent f83c49d073
commit 203edc46f1
5 changed files with 25 additions and 1 deletions

View File

@@ -107,6 +107,7 @@
<button name='jump-edit' type='large' top='468' left='349'>Create/Edit</button>
<led name='jump-toggle' top='474' left='349'/>
<button name='preview-dialog' type='regular' top='470' left='522'>Preview</button>
<button name='okay' type='regular' top='494' left='522'>OK</button>
<button name='cancel' type='regular' top='494' left='456'>Cancel</button>

View File

@@ -37,7 +37,8 @@ namespace {
.ex1a(STRT_BUTTON)
.ex2a(STRT_BUTTON)
.ex1b(eSpecPicker::NODE)
.ex2b(eSpecPicker::NODE);
.ex2b(eSpecPicker::NODE)
.preview();
node_properties_t S_ITEM_DIALOG = node_builder_t(eSpecType::ONCE_GIVE_ITEM_DIALOG)
.sdf()
.msg()

View File

@@ -575,6 +575,7 @@ bool node_category_info_t::contains(eSpecType spec) const {
node_properties_t::node_properties_t(eSpecType type)
: self(type)
, cat(getNodeCategory(type))
, can_preview(false)
{
set(eSpecField::JUMP, eSpecPicker::NODE);
}
@@ -872,6 +873,11 @@ node_builder_t& node_builder_t::loc(eSpecField a, eSpecField b, eLocType type, e
return *this;
}
node_builder_t& node_builder_t::preview() {
node.can_preview = true;
return *this;
}
node_builder_t::operator node_properties_t() {
std::map<eSpecType, node_properties_t>& allNodeProps = nodeProps();
allNodeProps.emplace(node.self, node);

View File

@@ -213,6 +213,7 @@ struct node_properties_t {
node_function_t ex1a(const cSpecial&) const, ex1b(const cSpecial&) const, ex1c(const cSpecial&) const;
node_function_t ex2a(const cSpecial&) const, ex2b(const cSpecial&) const, ex2c(const cSpecial&) const;
node_properties_t() : node_properties_t(eSpecType::INVALID) {}
bool can_preview;
private:
node_properties_t(eSpecType type);
node_function_t get(const cSpecial& spec, eSpecField fld) const;
@@ -267,6 +268,8 @@ struct node_builder_t {
node_builder_t& loc(eSpecField a, eSpecField b, eLocType type);
// As above, but also notes that the area the location is in will be specified by the indicated field.
node_builder_t& loc(eSpecField a, eSpecField b, eLocType type, eSpecField where);
// Specifies that the node defines a dialog which can be previewed
node_builder_t& preview();
node_condition_builder_t when(node_condition_t cond, int lbl_sub);
operator node_properties_t();
private:

View File

@@ -37,6 +37,11 @@ extern cScenario scenario;
extern cOutdoors* current_terrain;
extern cCustomGraphics spec_scen_g;
static bool preview_spec_enc_dlog(cDialog& me, std::string item_hit, cSpecial& special) {
LOG("Preview clicked!");
return true;
}
std::vector<pic_num_t> field_pics = {0,3,5,6,7,8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31,4};
std::vector<pic_num_t> static_boom_pics = {0,1,2,3,4,5};
std::vector<pic_num_t> boom_pics = {0,1,2,3,4,5,8,9,10,11,12,13};
@@ -795,6 +800,14 @@ static void put_spec_enc_in_dlog(cDialog& me, node_stack_t& edit_stack) {
setup_node_field(me, "x2c", spec.ex2c, info.ex2c(spec));
setup_node_field(me, "jump", spec.jumpto, info.jump(spec));
if(info.can_preview){
using namespace std::placeholders;
me["preview-dialog"].attachClickHandler(std::bind(preview_spec_enc_dlog, _1, _2, std::ref(spec)));
me["preview-dialog"].show();
}else{
me["preview-dialog"].hide();
}
}
static void save_spec_enc(cDialog& me, node_stack_t& edit_stack) {