show timers that call special nodes

This commit is contained in:
2025-09-02 15:27:42 -05:00
parent 2d80ac149b
commit b0c436b630
5 changed files with 46 additions and 4 deletions

View File

@@ -150,5 +150,5 @@
<button name='calls2' type='tiny' relative='pos-in pos' rel-anchor='prev' top='4' left='0'/> <button name='calls2' type='tiny' relative='pos-in pos' rel-anchor='prev' top='4' left='0'/>
<button name='calls3' type='tiny' relative='pos-in pos' rel-anchor='prev' top='4' left='0'/> <button name='calls3' type='tiny' relative='pos-in pos' rel-anchor='prev' top='4' left='0'/>
<text name='tooltip' framed='true' ellipsis='true' width='200' height='24' relative='pos-in pos' anchor='calledby13' top='4' left='0'></text> <text name='tooltip' framed='true' ellipsis='true' width='260' height='16' relative='neg pos' anchor='calledby13' top='4' left='20'></text>
</dialog> </dialog>

View File

@@ -793,7 +793,7 @@ void refresh_text_bar() {
mainPtr().setActive(); mainPtr().setActive();
} }
// this is used for determinign whether to round off walkway corners // this is used for determining whether to round off walkway corners
// right now, trying a restrictive rule (just cave floor and grass, mainly) // right now, trying a restrictive rule (just cave floor and grass, mainly)
bool is_nature(short x, short y, unsigned short ground_t) { bool is_nature(short x, short y, unsigned short ground_t) {
ter_num_t ter_type; ter_num_t ter_type;

View File

@@ -51,6 +51,8 @@ cSpecial::cSpecial(){
void cSpecial::writeTo(std::ostream& file, int n) const { void cSpecial::writeTo(std::ostream& file, int n) const {
// TODO: Output only the needed values somehow // TODO: Output only the needed values somehow
// ^ That's possible now that we have the refactored node field system, but I'm not sure it's
// a good idea?
file << '@' << (*type).opcode() << " = " << n << '\n'; file << '@' << (*type).opcode() << " = " << n << '\n';
file << "\tsdf " << sd1 << ", " << sd2 << '\n'; file << "\tsdf " << sd1 << ", " << sd2 << '\n';
file << "\tmsg " << m1 << ", " << m2 << ", " << m3 << '\n'; file << "\tmsg " << m1 << ", " << m2 << ", " << m3 << '\n';
@@ -1201,6 +1203,19 @@ std::vector<graph_node_t> global_node_graph(cScenario& scenario, node_stack_t& s
} }
} }
// Backward connections to global timers
int which = 0;
for(cTimer& timer : scenario.scenario_timers){
if(timer.node >= 0){
node_id_t caller_node;
caller_node.which = which; // this could be linked to a designer name for the caller list tooltip (but timers don't have designer names yet)
caller_node.caller_type = eCallerType::TIMER;
caller_node.out_y = timer.time;
graph_nodes[timer.node].from_nodes.insert(caller_node);
}
++which;
}
return graph_nodes; return graph_nodes;
} }
@@ -1262,5 +1277,21 @@ std::vector<graph_node_t> local_node_graph(cScenario& scenario, node_stack_t& st
} }
} }
// Backward connections to town timers
if(out_y < 0){
int which = 0;
for(cTimer& timer : scenario.towns[town_num_or_out_x]->timers){
if(timer.node >= 0){
node_id_t caller_node;
caller_node.which = which; // this could be linked to a designer name for the caller list tooltip (but timers don't have designer names yet)
caller_node.caller_type = eCallerType::TIMER;
caller_node.town_num_or_out_x = town_num_or_out_x;
caller_node.out_y = timer.time;
graph_nodes[timer.node].from_nodes.insert(caller_node);
}
++which;
}
}
return graph_nodes; return graph_nodes;
} }

View File

@@ -118,9 +118,9 @@ public:
enum eCallerType { enum eCallerType {
NODE, NODE,
SPEC_SPOT SPEC_SPOT,
TIMER // town, global
// TODO more ways to call a node: // TODO more ways to call a node:
// TIMER (town/global)
// TOWNPERSON_DEATH // TOWNPERSON_DEATH
// TOWN_ENTRY (still alive/been abandoned/hostile) // TOWN_ENTRY (still alive/been abandoned/hostile)
// SPECIAL_TERRAIN (use/walk on) // SPECIAL_TERRAIN (use/walk on)

View File

@@ -808,6 +808,8 @@ static std::string label(node_id_t id) {
switch(id.caller_type){ switch(id.caller_type){
case eCallerType::SPEC_SPOT: case eCallerType::SPEC_SPOT:
return "Special Spot"; return "Special Spot";
case eCallerType::TIMER:
return (id.town_num_or_out_x >= 0) ? "Town Timer" : "Global Timer";
case eCallerType::NODE:{ case eCallerType::NODE:{
std::string lbl = std::to_string(id.which); std::string lbl = std::to_string(id.which);
if(id.town_num_or_out_x < 0) lbl = "G" + lbl; if(id.town_num_or_out_x < 0) lbl = "G" + lbl;
@@ -823,6 +825,15 @@ static std::string tooltip_text(cScenario& scenario, node_id_t caller_id) {
case eCallerType::SPEC_SPOT: case eCallerType::SPEC_SPOT:
// TODO use loc_str (make it more customizable for context) // 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); return fmt::format("At ({},{})", caller_id.town_num_or_out_x, caller_id.out_y);
case eCallerType::TIMER:{
std::string timer_type = caller_id.town_num_or_out_x >= 0 ? "town" : "global";
// out_y represents time
if(caller_id.out_y <= 0){
return fmt::format("Would be called by {} timer {}, but its interval time is set to 0", timer_type, caller_id.which);
}else{
return fmt::format("Called every {} turns by {} timer {}", caller_id.out_y, timer_type, caller_id.which);
}
}
default: return ""; default: return "";
} }
} }