Skip to content

Commit

Permalink
Fix credits window position (#4)
Browse files Browse the repository at this point in the history
* Rename variables and match coding style
* Fix character selection position
* Fix credits position

See #3
  • Loading branch information
JanSimek authored May 21, 2022
1 parent 44a72c6 commit feaa8f6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
4 changes: 3 additions & 1 deletion src/character_selector.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ bool characterSelectorWindowInit()
return false;
}

gCharacterSelectorWindow = windowCreate(0, 0, CS_WINDOW_WIDTH, CS_WINDOW_HEIGHT, _colorTable[0], 0);
int characterSelectorWindowX = (screenGetWidth() - CS_WINDOW_WIDTH) / 2;
int characterSelectorWindowY = (screenGetHeight() - CS_WINDOW_HEIGHT) / 2;
gCharacterSelectorWindow = windowCreate(characterSelectorWindowX, characterSelectorWindowY, CS_WINDOW_WIDTH, CS_WINDOW_HEIGHT, _colorTable[0], 0);
if (gCharacterSelectorWindow == -1) {
goto err;
}
Expand Down
4 changes: 3 additions & 1 deletion src/credits.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle)
mouseShowCursor();
}

int window = windowCreate(0, 0, CREDITS_WINDOW_WIDTH, CREDITS_WINDOW_HEIGHT, _colorTable[0], 20);
int creditsWindowX = (screenGetWidth() - CREDITS_WINDOW_WIDTH) / 2;
int creditsWindowY = (screenGetHeight() - CREDITS_WINDOW_HEIGHT) / 2;
int window = windowCreate(creditsWindowX, creditsWindowY, CREDITS_WINDOW_WIDTH, CREDITS_WINDOW_HEIGHT, _colorTable[0], 20);
soundContinueAll();
if (window != -1) {
unsigned char* windowBuffer = windowGetBuffer(window);
Expand Down
9 changes: 5 additions & 4 deletions src/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#define INDICATOR_BOX_WIDTH 130
#define INDICATOR_BOX_HEIGHT 21

#define INTERFACE_BAR_WIDTH 640
#define INTERFACE_BAR_HEIGHT 100

// The width of connectors in the indicator box.
Expand Down Expand Up @@ -350,10 +351,10 @@ int interfaceInit()

gInterfaceBarInitialized = 1;

int xPos = (_scr_size.right - 640) / 2;
int yPos = _scr_size.bottom - 99;
int interfaceBarWindowX = (screenGetWidth() - INTERFACE_BAR_WIDTH) / 2;
int interfaceBarWindowY = screenGetHeight() - INTERFACE_BAR_HEIGHT - 1;

gInterfaceBarWindow = windowCreate(xPos, yPos, 640, 100, _colorTable[0], WINDOW_HIDDEN);
gInterfaceBarWindow = windowCreate(interfaceBarWindowX, interfaceBarWindowY, INTERFACE_BAR_WIDTH, INTERFACE_BAR_HEIGHT, _colorTable[0], WINDOW_HIDDEN);
if (gInterfaceBarWindow == -1) {
goto err;
}
Expand All @@ -369,7 +370,7 @@ int interfaceInit()
goto err;
}

blitBufferToBuffer(backgroundFrmData, 640, 99, 640, gInterfaceWindowBuffer, 640);
blitBufferToBuffer(backgroundFrmData, INTERFACE_BAR_WIDTH, INTERFACE_BAR_HEIGHT - 1, INTERFACE_BAR_WIDTH, gInterfaceWindowBuffer, 640);
artUnlock(backgroundFrmHandle);

fid = buildFid(6, 47, 0, 0, 0);
Expand Down
12 changes: 6 additions & 6 deletions src/tile.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,21 +502,21 @@ int tileSetCenter(int tile, int flags)
}
}

int v9 = gHexGridWidth - 1 - tile % gHexGridWidth;
int v10 = tile / gHexGridWidth;
int tile_x = gHexGridWidth - 1 - tile % gHexGridWidth;
int tile_y = tile / gHexGridWidth;

if (_borderInitialized) {
if (v9 <= _tile_border || v9 >= dword_66BBCC || v10 <= dword_66BBC8 || v10 >= dword_66BBD0) {
if (tile_x <= _tile_border || tile_x >= dword_66BBCC || tile_y <= dword_66BBC8 || tile_y >= dword_66BBD0) {
return -1;
}
}

_tile_y = v10;
_tile_y = tile_y;
_tile_offx = (gTileWindowWidth - 32) / 2;
_tile_x = v9;
_tile_x = tile_x;
_tile_offy = (gTileWindowHeight - 16) / 2;

if (v9 & 1) {
if (tile_x & 1) {
_tile_x -= 1;
_tile_offx -= 32;
}
Expand Down

0 comments on commit feaa8f6

Please sign in to comment.