diff options
| author | Caldfir | 2012-05-01 04:34:35 -0700 |
|---|---|---|
| committer | Caldfir | 2012-05-01 04:34:35 -0700 |
| commit | 70890ad5883972a9e810745da4f6a193944ed4d4 (patch) | |
| tree | c82f39209f70544e6dcf2804dac432103c6030c7 | |
| parent | e8b469af0a3245b25414398a4ea2d163822f2ce6 (diff) | |
| download | stonesense-70890ad5883972a9e810745da4f6a193944ed4d4.tar.gz stonesense-70890ad5883972a9e810745da4f6a193944ed4d4.tar.bz2 stonesense-70890ad5883972a9e810745da4f6a193944ed4d4.tar.xz | |
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.
| -rw-r--r-- | MapLoading.cpp | 5 | ||||
| -rw-r--r-- | UserInput.cpp | 27 | ||||
| -rw-r--r-- | common.h | 1 | ||||
| -rw-r--r-- | 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;
@@ -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, ...);
@@ -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;
|
