Skip to content

Commit

Permalink
Fixed Megashots. This should also make the UI scrolling more responsive.
Browse files Browse the repository at this point in the history
  • Loading branch information
Caldfir authored and RosaryMala committed Dec 15, 2012
1 parent 3f7eb6b commit 28b287b
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ void Block::Drawcreaturetext()
int32_t drawx = x;
int32_t drawy = y;
int32_t drawz = z; //- ownerSegment->sizez + 1;

ownerSegment->CorrectBlockForSegmentOffset( drawx, drawy, drawz);
correctBlockForRotation( drawx, drawy, drawz, ownerSegment->rotation);
pointToScreen((int*)&drawx, (int*)&drawy, drawz);
Expand Down
14 changes: 11 additions & 3 deletions GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1239,8 +1239,12 @@ void saveMegashot(bool tall)
int tempViewz = ssState.DisplayedSegmentZ;
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;
//now make them real big.
ssConfig.show_osd = false;
ssConfig.follow_DFscreen = false;
ssConfig.fogenable = false;
ssConfig.lift_segment_offscreen = 0;
Expand All @@ -1252,9 +1256,10 @@ void saveMegashot(bool tall)
parms.z = ssState.DisplayedSegmentZ;

//make the image
int bigImageWidth = (ssConfig.cellDimX * TILEWIDTH)*ssConfig.scale;
int bigImageHeight = ( ((ssConfig.cellDimX + ssConfig.cellDimY) * TILEHEIGHT / 2) + ((ssConfig.segmentSize.z - 1) * BLOCKHEIGHT) )*ssConfig.scale;
bigFile = al_create_bitmap(bigImageWidth, bigImageHeight);
ssState.ScreenW = (ssConfig.cellDimX * TILEWIDTH)*ssConfig.scale;
ssState.ScreenH = ( ((ssConfig.cellDimX + ssConfig.cellDimY) * TILEHEIGHT / 2) + ((ssConfig.segmentSize.z - 1) * BLOCKHEIGHT) )*ssConfig.scale;

bigFile = al_create_bitmap(ssState.ScreenW, ssState.ScreenH);

//draw and save the image
if(bigFile) {
Expand Down Expand Up @@ -1333,6 +1338,9 @@ void saveMegashot(bool tall)
ssConfig.fogenable = tempfog;
ssConfig.follow_DFscreen = tempFollow;
ssConfig.lift_segment_offscreen = tempLift;
ssConfig.show_osd = temposd;
ssState.ScreenW = tempW;
ssState.ScreenH = tempH;

al_unlock_mutex(ssConfig.readMutex);
}
6 changes: 6 additions & 0 deletions MapLoading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1402,6 +1402,12 @@ void read_segment( void *arg)

if(segment) {
beautify_Segment(segment);

//putting these here to increase responsiveness of the UI and to make megashots work
segment->displayedx = ssState.DisplayedSegmentX;
segment->displayedy = ssState.DisplayedSegmentY;
segment->displayedz = ssState.DisplayedSegmentZ;

segment->AssembleAllBlocks();
}

Expand Down
2 changes: 1 addition & 1 deletion SpriteObjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ void c_sprite::assemble_world_offset_src(int x, int y, int z, int tileoffset, Bl
int32_t drawx = x;
int32_t drawy = y;
int32_t drawz = z; //- ownerSegment->sizez + 1;

b->ownerSegment->CorrectBlockForSegmentOffset( drawx, drawy, drawz);
correctBlockForRotation( drawx, drawy, drawz, b->ownerSegment->rotation);
int32_t viewx = drawx;
Expand Down
44 changes: 11 additions & 33 deletions WorldSegment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ Block* WorldSegment::getBlock(uint32_t index)

void WorldSegment::CorrectBlockForSegmentOffset(int32_t& xin, int32_t& yin, int32_t& zin)
{
xin -= x;
yin -= y; //DisplayedSegmentY;
zin -= z + sizez - 2; //need to remove the offset
xin -= displayedx;
yin -= displayedy; //DisplayedSegmentY;
zin -= displayedz - 1; //need to remove the offset
}

void correctBlockForRotation(int32_t& x, int32_t& y, int32_t& z, unsigned char rot)
Expand Down Expand Up @@ -242,35 +242,6 @@ void WorldSegment::DrawAllBlocks()
return;
}

//TODO bring fog back - figuring out allegro shaders would probably be a good idea

//// x,y,z print pricess
//int32_t vsxmax = sizex-1;
//int32_t vsymax = sizey-1;
//int32_t vszmax = sizez-1; // grabbing one tile +z more than we should for tile rules

//for(int32_t vsz=0; vsz < vszmax; vsz++) {
// if(ssConfig.fogenable) {
// if(!fog) {
// fog = al_create_bitmap(al_get_bitmap_width(temp), al_get_bitmap_height(temp));
// al_set_target_bitmap(fog);
// al_clear_to_color(premultiply(ssConfig.fogcol));
// al_set_target_bitmap(temp);
// }
// if(!((al_get_bitmap_width(fog) == al_get_bitmap_width(temp)) && (al_get_bitmap_height(fog) == al_get_bitmap_height(temp)))) {
// al_destroy_bitmap(fog);
// fog = al_create_bitmap(al_get_bitmap_width(temp), al_get_bitmap_height(temp));
// al_set_target_bitmap(fog);
// al_clear_to_color(premultiply(ssConfig.fogcol));
// al_set_target_bitmap(temp);
// }
// al_draw_bitmap(fog, 0, 0, 0);
// }
// if(vsz == vszmax-1) {
// }

// al_hold_bitmap_drawing(false);
//}
if(ssConfig.fogenable) {
ALLEGRO_BITMAP* temp = al_get_target_bitmap();
if(!fog) {
Expand All @@ -288,6 +259,10 @@ void WorldSegment::DrawAllBlocks()
}
}

if (ssConfig.show_osd) {
DrawCurrentLevelOutline(true);
}

if(todraw.size()>0){
al_hold_bitmap_drawing(true);
for(int i=0; i<todraw.size(); i++) {
Expand All @@ -311,8 +286,11 @@ void WorldSegment::DrawAllBlocks()
}

if (ssConfig.show_osd) {
DrawCurrentLevelOutline(true);
DrawCurrentLevelOutline(false);
}

al_hold_bitmap_drawing(false);
al_hold_bitmap_drawing(true);
}

void WorldSegment::AssembleAllBlocks()
Expand Down
4 changes: 4 additions & 0 deletions WorldSegment.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class WorldSegment
bool loaded;
bool processed;
int x, y, z;
int displayedx, displayedy, displayedz;
int sizex, sizey, sizez;
unsigned char rotation;
Crd3D regionSize;
Expand All @@ -24,6 +25,9 @@ class WorldSegment
this->sizex = sizex;
this->sizey = sizey;
this->sizez = sizez;
this->displayedx = ssState.DisplayedSegmentX;
this->displayedy = ssState.DisplayedSegmentY;
this->displayedz = ssState.DisplayedSegmentZ;

regionSize.x = regionSize.y = regionSize.z = 0;

Expand Down

0 comments on commit 28b287b

Please sign in to comment.