start adding other caller types to list

This commit is contained in:
2025-09-01 11:32:22 -05:00
parent f309e77101
commit f02fd69e8d
3 changed files with 62 additions and 11 deletions

View File

@@ -1249,5 +1249,18 @@ std::vector<graph_node_t> local_node_graph(cScenario& scenario, node_stack_t& st
}
}
// Backward connections to special spots
std::vector<spec_loc_t>& special_locs = (out_y < 0 ? scenario.towns[town_num_or_out_x]->special_locs : (scenario.outdoors[town_num_or_out_x][out_y]->special_locs));
for(spec_loc_t loc : special_locs){
if(loc.spec >= 0){
node_id_t caller_node;
caller_node.caller_type = eCallerType::SPEC_SPOT;
// I think the 'which' is irrelevant
caller_node.town_num_or_out_x = loc.x;
caller_node.out_y = loc.y;
graph_nodes[loc.spec].from_nodes.insert(caller_node);
}
}
return graph_nodes;
}

View File

@@ -116,10 +116,27 @@ public:
std::string editor_hint(cUniverse& univ) const;
};
enum eCallerType {
NODE,
SPEC_SPOT
// TODO more ways to call a node:
// TIMER (town/global)
// TOWNPERSON_DEATH
// TOWN_ENTRY (still alive/been abandoned/hostile)
// SPECIAL_TERRAIN (use/walk on)
// TALKING (call town/call global)
// ITEM_ABILITY
// MONSTER_ABILITY
// SCENARIO_START
// and probably more!
};
// I am expanding this to include other types of node callers for the graph!
struct node_id_t {
int which;
int town_num_or_out_x = -1;
int out_y = -1;
eCallerType caller_type = eCallerType::NODE;
};
struct node_compare {

View File

@@ -805,11 +805,26 @@ static void setup_node_field(cDialog& me, std::string field, short value, const
}
static std::string label(node_id_t id) {
std::string lbl = std::to_string(id.which);
if(id.town_num_or_out_x < 0) lbl = "G" + lbl;
else if(id.out_y < 0) lbl = "T" + lbl;
else lbl = "O" + lbl;
return lbl;
switch(id.caller_type){
case eCallerType::SPEC_SPOT:
return "Special Spot";
case eCallerType::NODE:{
std::string lbl = std::to_string(id.which);
if(id.town_num_or_out_x < 0) lbl = "G" + lbl;
else if(id.out_y < 0) lbl = "T" + lbl;
else lbl = "O" + lbl;
return lbl;
}
}
}
static std::string tooltip_text(cScenario& scenario, node_id_t caller_id) {
switch(caller_id.caller_type){
case eCallerType::SPEC_SPOT:
// TODO use loc_str (make it more customizable for context)
return fmt::format("At ({},{})", caller_id.town_num_or_out_x, caller_id.out_y);
default: return "";
}
}
static void put_spec_enc_in_dlog(cDialog& me, node_stack_t& edit_stack);
@@ -854,12 +869,18 @@ static void put_spec_enc_in_dlog(cDialog& me, node_stack_t& edit_stack) {
me[fmt::format("calledby{}", i)].setText(label(from_id));
me[fmt::format("calledby{}", i)].recalcRect();
me[fmt::format("calledby{}", i)].show();
// TODO null check get_spec_ref
me[fmt::format("calledby{}", i)].setTooltipText(get_spec_ref(scenario, edit_stack, from_id.which, from_id.town_num_or_out_x, from_id.out_y)->editor_hint(univ));
me[fmt::format("calledby{}", i)].attachClickHandler([from_id, &edit_stack](cDialog& me, std::string, eKeyMod) -> bool {
push_spec_enc_in_stack(me, edit_stack, from_id);
return true;
});
if(from_id.caller_type == eCallerType::NODE){
// TODO null check get_spec_ref
me[fmt::format("calledby{}", i)].setTooltipText(get_spec_ref(scenario, edit_stack, from_id.which, from_id.town_num_or_out_x, from_id.out_y)->editor_hint(univ));
me[fmt::format("calledby{}", i)].attachClickHandler([from_id, &edit_stack](cDialog& me, std::string, eKeyMod) -> bool {
push_spec_enc_in_stack(me, edit_stack, from_id);
return true;
});
}else{
me[fmt::format("calledby{}", i)].setTooltipText(tooltip_text(scenario, from_id));
// No-op for now!
me[fmt::format("calledby{}", i)].attachClickHandler([](cDialog&, std::string, eKeyMod) -> bool { return true; });
}
}else{
LOG("Warning! Ran out of buttons to show callers!");
break;