Skip to content

Commit

Permalink
Fix save game preview
Browse files Browse the repository at this point in the history
See #3
  • Loading branch information
alexbatalov committed May 23, 2022
1 parent 1f8a62f commit 99ddcd3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/loadsave.cc
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,18 @@ int _QuickSnapShot()
gameMouseObjectsShow();
}

unsigned char* windowBuffer = windowGetBuffer(gIsoWindow);
blitBufferToBufferStretch(windowBuffer, 640, 380, 640, _snapshot, LS_PREVIEW_WIDTH, LS_PREVIEW_HEIGHT, LS_PREVIEW_WIDTH);
// For preview take 640x380 area in the center of isometric window.
unsigned char* isoWindowBuffer = windowGetBuffer(gIsoWindow)
+ (screenGetWidth() - ORIGINAL_ISO_WINDOW_WIDTH) / 2 * (screenGetHeight() - ORIGINAL_ISO_WINDOW_HEIGHT) / 2
+ (screenGetWidth() - ORIGINAL_ISO_WINDOW_WIDTH) / 2;
blitBufferToBufferStretch(isoWindowBuffer,
ORIGINAL_ISO_WINDOW_WIDTH,
ORIGINAL_ISO_WINDOW_HEIGHT,
windowGetWidth(gIsoWindow),
_snapshot,
LS_PREVIEW_WIDTH,
LS_PREVIEW_HEIGHT,
LS_PREVIEW_WIDTH);

_snapshotBuf = _snapshot;

Expand Down Expand Up @@ -1094,8 +1104,18 @@ int lsgWindowInit(int windowType)
gameMouseObjectsShow();
}

unsigned char* windowBuf = windowGetBuffer(gIsoWindow);
blitBufferToBufferStretch(windowBuf, 640, 380, 640, _snapshotBuf, LS_PREVIEW_WIDTH, LS_PREVIEW_HEIGHT, LS_PREVIEW_WIDTH);
// For preview take 640x380 area in the center of isometric window.
unsigned char* isoWindowBuffer = windowGetBuffer(gIsoWindow)
+ (screenGetWidth() - ORIGINAL_ISO_WINDOW_WIDTH) / 2 * (screenGetHeight() - ORIGINAL_ISO_WINDOW_HEIGHT) / 2
+ (screenGetWidth() - ORIGINAL_ISO_WINDOW_WIDTH) / 2;
blitBufferToBufferStretch(isoWindowBuffer,
ORIGINAL_ISO_WINDOW_WIDTH,
ORIGINAL_ISO_WINDOW_HEIGHT,
windowGetWidth(gIsoWindow),
_snapshotBuf,
LS_PREVIEW_WIDTH,
LS_PREVIEW_HEIGHT,
LS_PREVIEW_WIDTH);
}

for (int index = 0; index < LOAD_SAVE_FRM_COUNT; index++) {
Expand Down
3 changes: 3 additions & 0 deletions src/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

#define ORIGINAL_ISO_WINDOW_WIDTH 640
#define ORIGINAL_ISO_WINDOW_HEIGHT 380

// TODO: Probably not needed -> replace with array?
typedef struct TileData {
int field_0[SQUARE_GRID_SIZE];
Expand Down

0 comments on commit 99ddcd3

Please sign in to comment.