Add special node step-through mode for debugging

- Also fix debug/ghost mode not being deactivated when you start a new game
This commit is contained in:
2015-06-03 20:58:44 -04:00
parent 3cc12f464f
commit ae0e3cfd0d
5 changed files with 38 additions and 3 deletions

View File

@@ -26,6 +26,7 @@
= - Heal, increase magic skills<br/>
&lt; - Make one day pass<br/>
&gt; - Reset towns (excludes the one you're in, if any)<br/>
! - Toggle Special Node Step-through Mode<br/>
/ - Bring up this list<br/>
</text>
<button name='okay' type='regular' top='280' left='387'>OK</button>

View File

@@ -62,7 +62,7 @@ extern rectangle startup_button[6];
extern bool flushingInput;
extern bool fog_lifted;
extern bool cartoon_happening;
bool ghost_mode;
bool ghost_mode, node_step_through;
rectangle startup_top;
bool item_area_button_active[8][6];
@@ -2016,6 +2016,17 @@ bool handle_keystroke(sf::Event& event){
for(i = 0; i < 4; i++)
univ.party.creature_save[i].which_town = 200;
break;
case '!':
if(!in_scen_debug) break;
if(node_step_through) {
node_step_through = false;
add_string_to_buf("Debug: Step-through disabled");
} else {
node_step_through = true;
add_string_to_buf("Debug: Step-through enabled");
}
print_buf();
break;
case '/':
if(!in_scen_debug) break;
cChoiceDlog("help-debug").show();

View File

@@ -27,7 +27,7 @@
extern eStatMode stat_screen_mode;
extern bool give_delays;
extern eGameMode overall_mode;
extern bool play_sounds,sys_7_avail,save_maps,party_in_memory,in_scen_debug,ghost_mode;
extern bool play_sounds,sys_7_avail,save_maps,party_in_memory,in_scen_debug,ghost_mode,node_step_through;
extern location center;
extern long register_flag;
extern sf::RenderWindow mainPtr;
@@ -69,6 +69,7 @@ void finish_load_party(){
party_in_memory = true;
in_scen_debug = false;
ghost_mode = false;
node_step_through = false;
// now if not in scen, this is it.
if(!in_scen) {

View File

@@ -74,6 +74,7 @@ extern location golem_m_locs[16];
extern cUniverse univ;
extern sf::Texture pc_gworld;
extern std::queue<pending_special_type> special_queue;
extern bool in_scen_debug, ghost_mode, node_step_through;
// First icon is displayed for positive values, second for negative, if -1 no negative icon.
// This omits two special cases - major poison, and normal speed; they are hard-coded.
@@ -232,6 +233,11 @@ void put_party_in_scen(std::string scen_name) {
std::array<short, 3> buttons = {-1,-1,-1};
bool item_took = false;
// Drop debug mode
in_scen_debug = false;
ghost_mode = false;
node_step_through = false;
for(j = 0; j < 6; j++) {
univ.party[j].status.clear();
if(isSplit(univ.party[j].main_status))

View File

@@ -36,7 +36,7 @@ extern sf::RenderWindow mainPtr;
extern eGameMode overall_mode;
extern short which_combat_type,current_pc,stat_window;
extern location center;
extern bool in_scen_debug,belt_present,processing_fields,monsters_going,boom_anim_active;
extern bool in_scen_debug,node_step_through,belt_present,processing_fields,monsters_going,boom_anim_active;
extern effect_pat_type single,t,square,radius2,radius3,small_square,open_square,field[8];
extern effect_pat_type current_pat;
extern cOutdoors::cWandering store_wandering_special;
@@ -2027,6 +2027,22 @@ void run_special(eSpecCtx which_mode,short which_type,short start_spec,location
next_spec = -1;
cur_node = get_node(cur_spec,cur_spec_type);
if(node_step_through) {
give_help(68,69);
std::string debug = "Step: ";
debug += (*cur_node.type).name();
debug += " - ";
debug += std::to_string(cur_spec);
add_string_to_buf(debug);
redraw_screen(REFRESH_TRANS);
sf::Event evt;
while(true) {
if(mainPtr.pollEvent(evt) && (evt.type == sf::Event::KeyPressed || evt.type == sf::Event::MouseButtonPressed))
break;
}
if(evt.type == sf::Event::KeyPressed && evt.key.code == sf::Keyboard::Escape)
node_step_through = false;
}
// Convert pointer values to reference values
// TODO: Might need to make a database of which nodes don't allow pointers in which slots.