Skip to content

Commit

Permalink
Changed the screen coordinate calculations to account for window resi…
Browse files Browse the repository at this point in the history
…zing better. Fixed how megashots work on rectangular embarks.
  • Loading branch information
Caldfir authored and RosaryMala committed Dec 15, 2012
1 parent 917dc52 commit bff2496
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void parseConfigLine( string line )
}
if( line.find("[LIFTSEGMENT") != -1) {
int value = parseIntFromLine( "LIFTSEGMENT", line);
ssConfig.lift_segment_offscreen = value;
ssConfig.lift_segment_offscreen_y = value;
}
if( line.find("[ANIMATION_RATE") != -1) {
int value = parseIntFromLine( "ANIMATION_RATE", line );
Expand Down
6 changes: 3 additions & 3 deletions DumpInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ void dumpSegment()
int tempViewx = DisplayedSegment.x;
int tempViewy = DisplayedSegment.y;
bool tempFollow = ssConfig.follow_DFscreen;
int tempLift = ssConfig.lift_segment_offscreen;
int tempLift = ssConfig.lift_segment_offscreen_y;
int currentFlags = al_get_new_bitmap_flags();
//now make them real big.
ssConfig.follow_DFscreen = false;
ssConfig.lift_segment_offscreen = 0;
ssConfig.lift_segment_offscreen_y = 0;
parms.x = 0;
parms.y = 0;
parms.z = ssState.RegionDim.z - 1;
Expand Down Expand Up @@ -99,7 +99,7 @@ void dumpSegment()
DisplayedSegment.x = tempViewx;
DisplayedSegment.y = tempViewy;
ssConfig.follow_DFscreen = tempFollow;
ssConfig.lift_segment_offscreen = tempLift;
ssConfig.lift_segment_offscreen_y = tempLift;
al_unlock_mutex(ssConfig.readMutex);
*/
Expand Down
61 changes: 30 additions & 31 deletions GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void ScreenToPoint(int x,int y,int &x1, int &y1, int &z1)
//y-=TILEHEIGHT;
x+=TILEWIDTH>>1;
int offx = ssState.ScreenW /2;
int offy = (-20)-(TILEHEIGHT * ssConfig.lift_segment_offscreen);
int offy = (-20)-(TILEHEIGHT * ssConfig.lift_segment_offscreen_y);
y-=offy;
x-=offx;
y1=y*2-x;
Expand Down Expand Up @@ -273,16 +273,21 @@ void pointToScreen(int *inx, int *iny, int inz)

int x = *inx-*iny;
x = x * TILEWIDTH / 2;
x += (TILEWIDTH/2)*ssConfig.lift_segment_offscreen_x;
x *= ssConfig.scale;
x+=ssState.ScreenW / 2;

int y = *inx+*iny;
y = y*TILETOPHEIGHT / 2;
y -= z*TILEHEIGHT;
y -= TILETOPHEIGHT*5/4;
y -= TILEHEIGHT*ssConfig.lift_segment_offscreen;
y -= TILEHEIGHT*ssConfig.lift_segment_offscreen_y;
y *= ssConfig.scale;

if(ssConfig.track_screen_center) {
x+=ssState.ScreenW / 2;
y+=ssState.ScreenH / 2;
}

*inx=x;
*iny=y;
}
Expand Down Expand Up @@ -1235,25 +1240,18 @@ void saveMegashot(bool tall)
};
int timer = clock();
//back up all the relevant values
Crd3D backupsize = ssState.SegmentSize;
int tempViewx = ssState.DisplayedSegment.x;
int tempViewy = ssState.DisplayedSegment.y;
int tempViewz = ssState.DisplayedSegment.z;
bool tempFollow = ssConfig.follow_DFscreen;
bool tempfog = ssConfig.fogenable;
bool temposd = ssConfig.show_osd;
int tempLift = ssConfig.lift_segment_offscreen;
int tempW = ssState.ScreenW;
int tempH = ssState.ScreenH;
GameConfiguration tempConfig = ssConfig;
GameState tempState = ssState;
int tempflags = al_get_new_bitmap_flags();

//now make them real big.
ssConfig.show_osd = false;
ssConfig.follow_DFscreen = false;
ssConfig.fogenable = false;
ssConfig.lift_segment_offscreen = 0;
ssConfig.track_screen_center = false;

//make the image
ssState.ScreenW = (ssState.RegionDim.x * TILEWIDTH)*ssConfig.scale;
ssState.ScreenW = ((ssState.RegionDim.x + ssState.RegionDim.y) * TILEWIDTH / 2)*ssConfig.scale;
if(tall) {
ssState.ScreenH = ( ((ssState.RegionDim.x + ssState.RegionDim.y) * TILETOPHEIGHT / 2) + (ssState.RegionDim.z * TILEHEIGHT) )*ssConfig.scale;
} else {
Expand All @@ -1269,6 +1267,20 @@ void saveMegashot(bool tall)
if(!ssConfig.transparentScreenshots) {
al_clear_to_color(ssConfig.backcol);
}

//zero out the segment lift
ssConfig.lift_segment_offscreen_y = 0;
//realign the image if the region is rectangular
switch(ssState.DisplayedRotation){
case 0:
case 2:
ssConfig.lift_segment_offscreen_x = ssState.RegionDim.y;
break;
case 1:
case 3:
ssConfig.lift_segment_offscreen_x = ssState.RegionDim.x;
break;
}

//here we deal with the rotations
int startx, incrx, numx;
Expand All @@ -1285,6 +1297,7 @@ void saveMegashot(bool tall)
numy = numy/incry + (numx%incry==0 ? 0 : 1);
numz = tall ? ((ssState.RegionDim.z/(parms.sizez-1)) + 1) : 1;


if(ssState.DisplayedRotation == 1 || ssState.DisplayedRotation == 2) {
starty = (int)ssState.RegionDim.y + 2 - incry;
ssState.DisplayedSegment.y = (int)ssState.RegionDim.y - incry - 1;
Expand Down Expand Up @@ -1338,22 +1351,8 @@ void saveMegashot(bool tall)
}
al_destroy_bitmap(bigFile);
//restore everything that we changed.
ssState.SegmentSize = backupsize;
parms.sizex = backupsize.x;
parms.sizey = backupsize.y;
parms.sizez = backupsize.z;
ssState.DisplayedSegment.x = tempViewx;
ssState.DisplayedSegment.y = tempViewy;
ssState.DisplayedSegment.z = tempViewz;
parms.x = tempViewx;
parms.y = tempViewy;
parms.z = tempViewz;
ssConfig.fogenable = tempfog;
ssConfig.follow_DFscreen = tempFollow;
ssConfig.lift_segment_offscreen = tempLift;
ssConfig.show_osd = temposd;
ssState.ScreenW = tempW;
ssState.ScreenH = tempH;
ssConfig = tempConfig;
ssState = tempState;
al_set_new_bitmap_flags(tempflags);

map_segment.unlockRead();
Expand Down
4 changes: 3 additions & 1 deletion commonTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,15 @@ struct GameConfiguration {
bool hide_outer_tiles;
bool debug_mode;
bool track_center;
int lift_segment_offscreen;
int lift_segment_offscreen_x;
int lift_segment_offscreen_y;
uint8_t truncate_walls;
bool follow_DFscreen;
bool verbose_logging;
int viewXoffset;
int viewYoffset;
int viewZoffset;
bool track_screen_center;
int automatic_reload_time;
int automatic_reload_step;
int animation_step;
Expand Down
4 changes: 3 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ static void * stonesense_thread(ALLEGRO_THREAD * main_thread, void * parms)
ssConfig.load_ground_materials = true;
ssConfig.automatic_reload_time = 0;
ssConfig.automatic_reload_step = 500;
ssConfig.lift_segment_offscreen = 0;
ssConfig.lift_segment_offscreen_x = 0;
ssConfig.lift_segment_offscreen_y = 0;
ssConfig.Fullscreen = FULLSCREEN;
ssState.ScreenH = RESOLUTION_HEIGHT;
ssState.ScreenW = RESOLUTION_WIDTH;
Expand All @@ -381,6 +382,7 @@ static void * stonesense_thread(ALLEGRO_THREAD * main_thread, void * parms)
ssConfig.show_keybinds = false;
ssConfig.show_intro = true;
ssConfig.track_center = false;
ssConfig.track_screen_center = true;
ssConfig.animation_step = 300;
ssConfig.follow_DFscreen = false;
timeToReloadConfig = true;
Expand Down
2 changes: 1 addition & 1 deletion resources/init.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Changes the fontfile to use.
Lifts the segment up to the top off the screen, equivalent to a given
number of z levels.
Use this with a large segment size to get walls covering the entire screen.
[LIFTSEGMENT:12]
[LIFTSEGMENT:35]

Follow DF window is on when Stonesense launches. (Toggle with 'f')
[FOLLOW_DF_SCREEN:YES]
Expand Down

0 comments on commit bff2496

Please sign in to comment.