From 70890ad5883972a9e810745da4f6a193944ed4d4 Mon Sep 17 00:00:00 2001 From: Caldfir Date: Tue, 1 May 2012 04:34:35 -0700 Subject: Moved bounds checking into movement code from segment loading code. Added keypress 'Z' to 'zero' the current offset/coordinates. Added quiet logging function for printing non-essential updates to the dfhack console. All ties in to newly revamped large screenshot code. --- MapLoading.cpp | 5 ----- UserInput.cpp | 27 ++++++++++++++++++++++++++- common.h | 1 + main.cpp | 10 ++++++++++ 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/MapLoading.cpp b/MapLoading.cpp index 14e945d..2f825bc 100644 --- a/MapLoading.cpp +++ b/MapLoading.cpp @@ -778,11 +778,6 @@ WorldSegment* ReadMapSegment(int x, int y, int z, int sizex, int sizey, int size config.cellDimX = cellDimX; config.cellDimY = cellDimY; config.cellDimZ = cellDimZ; - //bound view to world - if(x > cellDimX -sizex/2) DisplayedSegmentX = x = cellDimX -sizex/2; - if(y > cellDimY -sizey/2) DisplayedSegmentY = y = cellDimY -sizey/2; - if(x < -sizex/2) DisplayedSegmentX = x = -sizex/2; - if(y < -sizey/2) DisplayedSegmentY = y = -sizey/2; //setup new world segment WorldSegment* segment = new WorldSegment(x,y,z,sizex,sizey,sizez); diff --git a/UserInput.cpp b/UserInput.cpp index 90e9a24..7ba60d8 100644 --- a/UserInput.cpp +++ b/UserInput.cpp @@ -67,10 +67,22 @@ void changeRelativeToRotation( int &inputx, int &inputy, int stepx, int stepy ){ void moveViewRelativeToRotation( int stepx, int stepy ) { + if (config.follow_DFscreen) changeRelativeToRotation(config.viewXoffset, config.viewYoffset, stepx, stepy ); - else + //if we're following the DF screen, we DO NOT bound the view, since we have a simple way to get back + else{ changeRelativeToRotation(DisplayedSegmentX, DisplayedSegmentY, stepx, stepy ); + //bound view to world + if((int)DisplayedSegmentX > (int)config.cellDimX -(int)config.segmentSize.x/2) + DisplayedSegmentX = config.cellDimX -config.segmentSize.x/2; + if((int)DisplayedSegmentY > (int)config.cellDimY -(int)config.segmentSize.y/2) + DisplayedSegmentY = config.cellDimY -config.segmentSize.y/2; + if((int)DisplayedSegmentX < -(int)config.segmentSize.x/2) + DisplayedSegmentX = -config.segmentSize.x/2; + if((int)DisplayedSegmentY < -(int)config.segmentSize.y/2) + DisplayedSegmentY = -config.segmentSize.y/2; + } } @@ -252,6 +264,19 @@ void doKeys(int Key) config.follow_DFscreen = !config.follow_DFscreen; timeToReloadSegment = true; } + if(Key == ALLEGRO_KEY_Z){ + if (config.follow_DFscreen) + { + config.viewXoffset = 0; + config.viewYoffset = 0; + config.viewZoffset = 0; + } + else + { + DisplayedSegmentX = (config.cellDimX -config.segmentSize.x)/2; + DisplayedSegmentY = (config.cellDimY -config.segmentSize.y)/2; + } + } if(Key == ALLEGRO_KEY_1){ config.segmentSize.z--; if(config.segmentSize.z <= 0) config.segmentSize.z = 1; diff --git a/common.h b/common.h index 0ee8145..118ed47 100644 --- a/common.h +++ b/common.h @@ -165,6 +165,7 @@ class SegmentWrap; void correctBlockForSegmetOffset(int32_t& x, int32_t& y, int32_t& z); void LogError(const char* msg, ...); +void PrintMessage(const char* msg, ...); void LogVerbose(const char* msg, ...); void SetTitle(const char *format, ...); diff --git a/main.cpp b/main.cpp index f163d74..63cf86e 100644 --- a/main.cpp +++ b/main.cpp @@ -92,6 +92,16 @@ void LogError(const char* msg, ...){ fclose(fp); } + +void PrintMessage(const char* msg, ...){ + va_list arglist; + va_start(arglist, msg); + char buf[512] = {0}; + vsprintf(buf, msg, arglist); + Core::print(buf); + va_end(arglist); +} + void LogVerbose(const char* msg, ...){ if (!config.verbose_logging) return; -- cgit v1.2.1