| 
						
						
						
					 | 
					 | 
					@ -1,31 +1,49 @@
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					#include "Core.h"
 | 
					 | 
					 | 
					 | 
					#include "Core.h"
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					#include "Export.h"
 | 
					 | 
					 | 
					 | 
					#include "Export.h"
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					#include "df/gamest.h"
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					static bool disabled = false;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					// called from the main thread before the simulation thread is started
 | 
					 | 
					 | 
					 | 
					// called from the main thread before the simulation thread is started
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					// and the main event loop is initiated
 | 
					 | 
					 | 
					 | 
					// and the main event loop is initiated
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					DFhackCExport void dfhooks_init() {
 | 
					 | 
					 | 
					 | 
					DFhackCExport void dfhooks_init() {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    // TODO: initialize things we need to do while still in the main thread
 | 
					 | 
					 | 
					 | 
					    if (!DFHack::Core::getInstance().InitMainThread() || !df::global::game)
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        return;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    const std::string & cmdline = df::global::game->command_line.original;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    if (cmdline.find("--disable-dfhack") != std::string::npos) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        fprintf(stdout, "dfhack: --disable-dfhack specified on commandline; disabling\n");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        disabled = true;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					// called from the main thread after the main event loops exits
 | 
					 | 
					 | 
					 | 
					// called from the main thread after the main event loops exits
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					DFhackCExport void dfhooks_shutdown() {
 | 
					 | 
					 | 
					 | 
					DFhackCExport void dfhooks_shutdown() {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    if (disabled)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        return;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    DFHack::Core::getInstance().Shutdown();
 | 
					 | 
					 | 
					 | 
					    DFHack::Core::getInstance().Shutdown();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					// called from the simulation thread in the main event loop
 | 
					 | 
					 | 
					 | 
					// called from the simulation thread in the main event loop
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					DFhackCExport void dfhooks_update() {
 | 
					 | 
					 | 
					 | 
					DFhackCExport void dfhooks_update() {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    if (disabled)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        return;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    DFHack::Core::getInstance().Update();
 | 
					 | 
					 | 
					 | 
					    DFHack::Core::getInstance().Update();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					// called from the simulation thread just before adding the macro
 | 
					 | 
					 | 
					 | 
					// called from the simulation thread just before adding the macro
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					// recording/playback overlay
 | 
					 | 
					 | 
					 | 
					// recording/playback overlay
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					DFhackCExport void dfhooks_prerender() {
 | 
					 | 
					 | 
					 | 
					DFhackCExport void dfhooks_prerender() {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    if (disabled)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        return;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    // TODO: render overlay widgets that are not attached to a viewscreen
 | 
					 | 
					 | 
					 | 
					    // TODO: render overlay widgets that are not attached to a viewscreen
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					// called from the main thread for each SDL event. if true is returned, then
 | 
					 | 
					 | 
					 | 
					// called from the main thread for each SDL event. if true is returned, then
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					// the event has been consumed and further processing shouldn't happen
 | 
					 | 
					 | 
					 | 
					// the event has been consumed and further processing shouldn't happen
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					DFhackCExport bool dfhooks_sdl_event(SDL::Event* event) {
 | 
					 | 
					 | 
					 | 
					DFhackCExport bool dfhooks_sdl_event(SDL::Event* event) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    if (disabled)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        return false;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    return DFHack::Core::getInstance().DFH_SDL_Event(event);
 | 
					 | 
					 | 
					 | 
					    return DFHack::Core::getInstance().DFH_SDL_Event(event);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -34,5 +52,7 @@ DFhackCExport bool dfhooks_sdl_event(SDL::Event* event) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					// if true is returned, then the event has been consumed and further processing
 | 
					 | 
					 | 
					 | 
					// if true is returned, then the event has been consumed and further processing
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					// shouldn't happen
 | 
					 | 
					 | 
					 | 
					// shouldn't happen
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					DFhackCExport bool dfhooks_ncurses_key(int key) {
 | 
					 | 
					 | 
					 | 
					DFhackCExport bool dfhooks_ncurses_key(int key) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    if (disabled)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        return false;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    return DFHack::Core::getInstance().DFH_ncurses_key(key);
 | 
					 | 
					 | 
					 | 
					    return DFHack::Core::getInstance().DFH_ncurses_key(key);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
					 | 
					 | 
					
 
 |