Fix character editor window position

See #3
This commit is contained in:
Alexander Batalov 2022-05-21 13:17:51 +03:00
parent 17cca452bb
commit 44a72c6b2b
1 changed files with 53 additions and 29 deletions

View File

@ -37,8 +37,8 @@
#define RENDER_ALL_STATS 7 #define RENDER_ALL_STATS 7
#define EDITOR_WIN_WIDTH 640 #define EDITOR_WINDOW_WIDTH 640
#define EDITOR_WIN_HEIGHT 480 #define EDITOR_WINDOW_HEIGHT 480
#define NAME_BUTTON_X 9 #define NAME_BUTTON_X 9
#define NAME_BUTTON_Y 0 #define NAME_BUTTON_Y 0
@ -75,6 +75,11 @@
#define PERK_WINDOW_WIDTH 573 #define PERK_WINDOW_WIDTH 573
#define PERK_WINDOW_HEIGHT 230 #define PERK_WINDOW_HEIGHT 230
#define PERK_WINDOW_LIST_X 45
#define PERK_WINDOW_LIST_Y 43
#define PERK_WINDOW_LIST_WIDTH 192
#define PERK_WINDOW_LIST_HEIGHT 129
#define ANIMATE 0x01 #define ANIMATE 0x01
#define RED_NUMBERS 0x02 #define RED_NUMBERS 0x02
#define BIG_NUM_WIDTH 14 #define BIG_NUM_WIDTH 14
@ -1139,7 +1144,14 @@ int characterEditorWindowInit()
return -1; return -1;
} }
characterEditorWindowHandle = windowCreate(0, 0, 640, 480, 256, 18); int editorWindowX = (screenGetWidth() - EDITOR_WINDOW_WIDTH) / 2;
int editorWindowY = (screenGetHeight() - EDITOR_WINDOW_HEIGHT) / 2;
characterEditorWindowHandle = windowCreate(editorWindowX,
editorWindowY,
EDITOR_WINDOW_WIDTH,
EDITOR_WINDOW_HEIGHT,
256,
WINDOW_FLAG_0x10 | WINDOW_FLAG_0x02);
if (characterEditorWindowHandle == -1) { if (characterEditorWindowHandle == -1) {
for (i = 0; i < EDITOR_GRAPHIC_COUNT; i++) { for (i = 0; i < EDITOR_GRAPHIC_COUNT; i++) {
if (_copyflag[i]) { if (_copyflag[i]) {
@ -1270,7 +1282,7 @@ int characterEditorWindowInit()
// PRINT // PRINT
str = getmsg(&editorMessageList, &editorMessageListItem, 103); str = getmsg(&editorMessageList, &editorMessageListItem, 103);
fontDrawText(characterEditorWindowBuf + (EDITOR_WIN_WIDTH * PRINT_BTN_Y) + PRINT_BTN_X, str, EDITOR_WIN_WIDTH, EDITOR_WIN_WIDTH, _colorTable[18979]); fontDrawText(characterEditorWindowBuf + (EDITOR_WINDOW_WIDTH * PRINT_BTN_Y) + PRINT_BTN_X, str, EDITOR_WINDOW_WIDTH, EDITOR_WINDOW_WIDTH, _colorTable[18979]);
editorRenderPcStats(); editorRenderPcStats();
_folder_init(); _folder_init();
@ -1280,11 +1292,11 @@ int characterEditorWindowInit()
// CANCEL // CANCEL
str = getmsg(&editorMessageList, &editorMessageListItem, 102); str = getmsg(&editorMessageList, &editorMessageListItem, 102);
fontDrawText(characterEditorWindowBuf + (EDITOR_WIN_WIDTH * CANCEL_BTN_Y) + CANCEL_BTN_X, str, EDITOR_WIN_WIDTH, EDITOR_WIN_WIDTH, _colorTable[18979]); fontDrawText(characterEditorWindowBuf + (EDITOR_WINDOW_WIDTH * CANCEL_BTN_Y) + CANCEL_BTN_X, str, EDITOR_WINDOW_WIDTH, EDITOR_WINDOW_WIDTH, _colorTable[18979]);
// DONE // DONE
str = getmsg(&editorMessageList, &editorMessageListItem, 100); str = getmsg(&editorMessageList, &editorMessageListItem, 100);
fontDrawText(characterEditorWindowBuf + (EDITOR_WIN_WIDTH * DONE_BTN_Y) + DONE_BTN_X, str, EDITOR_WIN_WIDTH, EDITOR_WIN_WIDTH, _colorTable[18979]); fontDrawText(characterEditorWindowBuf + (EDITOR_WINDOW_WIDTH * DONE_BTN_Y) + DONE_BTN_X, str, EDITOR_WINDOW_WIDTH, EDITOR_WINDOW_WIDTH, _colorTable[18979]);
editorRenderPrimaryStat(RENDER_ALL_STATS, 0, 0); editorRenderPrimaryStat(RENDER_ALL_STATS, 0, 0);
editorRenderSecondaryStats(); editorRenderSecondaryStats();
@ -1454,24 +1466,24 @@ int characterEditorWindowInit()
_GInfo[EDITOR_GRAPHIC_NAME_ON].width, _GInfo[EDITOR_GRAPHIC_NAME_ON].width,
_GInfo[EDITOR_GRAPHIC_NAME_ON].height, _GInfo[EDITOR_GRAPHIC_NAME_ON].height,
_GInfo[EDITOR_GRAPHIC_NAME_ON].width, _GInfo[EDITOR_GRAPHIC_NAME_ON].width,
characterEditorWindowBuf + (EDITOR_WIN_WIDTH * NAME_BUTTON_Y) + x, characterEditorWindowBuf + (EDITOR_WINDOW_WIDTH * NAME_BUTTON_Y) + x,
EDITOR_WIN_WIDTH); EDITOR_WINDOW_WIDTH);
x += _GInfo[EDITOR_GRAPHIC_NAME_ON].width; x += _GInfo[EDITOR_GRAPHIC_NAME_ON].width;
blitBufferToBufferTrans(_grphcpy[EDITOR_GRAPHIC_AGE_OFF], blitBufferToBufferTrans(_grphcpy[EDITOR_GRAPHIC_AGE_OFF],
_GInfo[EDITOR_GRAPHIC_AGE_ON].width, _GInfo[EDITOR_GRAPHIC_AGE_ON].width,
_GInfo[EDITOR_GRAPHIC_AGE_ON].height, _GInfo[EDITOR_GRAPHIC_AGE_ON].height,
_GInfo[EDITOR_GRAPHIC_AGE_ON].width, _GInfo[EDITOR_GRAPHIC_AGE_ON].width,
characterEditorWindowBuf + (EDITOR_WIN_WIDTH * NAME_BUTTON_Y) + x, characterEditorWindowBuf + (EDITOR_WINDOW_WIDTH * NAME_BUTTON_Y) + x,
EDITOR_WIN_WIDTH); EDITOR_WINDOW_WIDTH);
x += _GInfo[EDITOR_GRAPHIC_AGE_ON].width; x += _GInfo[EDITOR_GRAPHIC_AGE_ON].width;
blitBufferToBufferTrans(_grphcpy[EDITOR_GRAPHIC_SEX_OFF], blitBufferToBufferTrans(_grphcpy[EDITOR_GRAPHIC_SEX_OFF],
_GInfo[EDITOR_GRAPHIC_SEX_ON].width, _GInfo[EDITOR_GRAPHIC_SEX_ON].width,
_GInfo[EDITOR_GRAPHIC_SEX_ON].height, _GInfo[EDITOR_GRAPHIC_SEX_ON].height,
_GInfo[EDITOR_GRAPHIC_SEX_ON].width, _GInfo[EDITOR_GRAPHIC_SEX_ON].width,
characterEditorWindowBuf + (EDITOR_WIN_WIDTH * NAME_BUTTON_Y) + x, characterEditorWindowBuf + (EDITOR_WINDOW_WIDTH * NAME_BUTTON_Y) + x,
EDITOR_WIN_WIDTH); EDITOR_WINDOW_WIDTH);
btn = buttonCreate(characterEditorWindowHandle, btn = buttonCreate(characterEditorWindowHandle,
11, 11,
@ -2944,7 +2956,9 @@ int characterEditorEditName()
int windowWidth = _GInfo[EDITOR_GRAPHIC_CHARWIN].width; int windowWidth = _GInfo[EDITOR_GRAPHIC_CHARWIN].width;
int windowHeight = _GInfo[EDITOR_GRAPHIC_CHARWIN].height; int windowHeight = _GInfo[EDITOR_GRAPHIC_CHARWIN].height;
int win = windowCreate(17, 0, windowWidth, windowHeight, 256, WINDOW_FLAG_0x10 | WINDOW_FLAG_0x02); int nameWindowX = (screenGetWidth() - EDITOR_WINDOW_WIDTH) / 2 + 17;
int nameWindowY = (screenGetHeight() - EDITOR_WINDOW_HEIGHT) / 2;
int win = windowCreate(nameWindowX, nameWindowY, windowWidth, windowHeight, 256, WINDOW_FLAG_0x10 | WINDOW_FLAG_0x02);
if (win == -1) { if (win == -1) {
return -1; return -1;
} }
@ -3074,7 +3088,9 @@ int characterEditorRunEditAgeDialog()
windowWidth = _GInfo[EDITOR_GRAPHIC_CHARWIN].width; windowWidth = _GInfo[EDITOR_GRAPHIC_CHARWIN].width;
windowHeight = _GInfo[EDITOR_GRAPHIC_CHARWIN].height; windowHeight = _GInfo[EDITOR_GRAPHIC_CHARWIN].height;
win = windowCreate(_GInfo[EDITOR_GRAPHIC_NAME_ON].width + 9, 0, windowWidth, windowHeight, 256, WINDOW_FLAG_0x10 | WINDOW_FLAG_0x02); int ageWindowX = (screenGetWidth() - EDITOR_WINDOW_WIDTH) / 2 + _GInfo[EDITOR_GRAPHIC_NAME_ON].width + 9;
int ageWindowY = (screenGetHeight() - EDITOR_WINDOW_HEIGHT) / 2;
win = windowCreate(ageWindowX, ageWindowY, windowWidth, windowHeight, 256, WINDOW_FLAG_0x10 | WINDOW_FLAG_0x02);
if (win == -1) { if (win == -1) {
return -1; return -1;
} }
@ -3302,10 +3318,11 @@ void characterEditorEditGender()
int windowWidth = _GInfo[EDITOR_GRAPHIC_CHARWIN].width; int windowWidth = _GInfo[EDITOR_GRAPHIC_CHARWIN].width;
int windowHeight = _GInfo[EDITOR_GRAPHIC_CHARWIN].height; int windowHeight = _GInfo[EDITOR_GRAPHIC_CHARWIN].height;
int x = 9; int genderWindowX = (screenGetWidth() - EDITOR_WINDOW_WIDTH) / 2 + 9
x += _GInfo[EDITOR_GRAPHIC_NAME_ON].width; + _GInfo[EDITOR_GRAPHIC_NAME_ON].width;
x += _GInfo[EDITOR_GRAPHIC_AGE_ON].width; + _GInfo[EDITOR_GRAPHIC_AGE_ON].width;
int win = windowCreate(x, 0, windowWidth, windowHeight, 256, WINDOW_FLAG_0x10 | WINDOW_FLAG_0x02); int genderWindowY = (screenGetHeight() - EDITOR_WINDOW_HEIGHT) / 2;
int win = windowCreate(genderWindowX, genderWindowY, windowWidth, windowHeight, 256, WINDOW_FLAG_0x10 | WINDOW_FLAG_0x02);
if (win == -1) { if (win == -1) {
return; return;
@ -4583,7 +4600,7 @@ int _DrawCard(int graphicId, const char* name, const char* attributes, char* des
// 0x43AE8 // 0x43AE8
void _FldrButton() void _FldrButton()
{ {
mouseGetPosition(&_mouse_xpos, &_mouse_ypos); mouseGetPositionInWindow(characterEditorWindowHandle, &_mouse_xpos, &_mouse_ypos);
soundPlayFile("ib3p1xx1"); soundPlayFile("ib3p1xx1");
if (_mouse_xpos >= 208) { if (_mouse_xpos >= 208) {
@ -4604,7 +4621,7 @@ void _FldrButton()
// 0x43AF40 // 0x43AF40
void _InfoButton(int eventCode) void _InfoButton(int eventCode)
{ {
mouseGetPosition(&_mouse_xpos, &_mouse_ypos); mouseGetPositionInWindow(characterEditorWindowHandle, &_mouse_xpos, &_mouse_ypos);
switch (eventCode) { switch (eventCode) {
case 525: case 525:
@ -5363,7 +5380,14 @@ int editorSelectPerk()
return -1; return -1;
} }
gEditorPerkWindow = windowCreate(PERK_WINDOW_X, PERK_WINDOW_Y, PERK_WINDOW_WIDTH, PERK_WINDOW_HEIGHT, 256, WINDOW_FLAG_0x10 | WINDOW_FLAG_0x02); // Maintain original position in original resolution, otherwise center it.
int perkWindowX = screenGetWidth() != 640
? (screenGetWidth() - PERK_WINDOW_WIDTH) / 2
: PERK_WINDOW_X;
int perkWindowY = screenGetHeight() != 480
? (screenGetHeight() - PERK_WINDOW_HEIGHT) / 2
: PERK_WINDOW_Y;
gEditorPerkWindow = windowCreate(perkWindowX, perkWindowY, PERK_WINDOW_WIDTH, PERK_WINDOW_HEIGHT, 256, WINDOW_FLAG_0x10 | WINDOW_FLAG_0x02);
if (gEditorPerkWindow == -1) { if (gEditorPerkWindow == -1) {
artUnlock(backgroundFrmHandle); artUnlock(backgroundFrmHandle);
debugPrint("\n *** Error running perks dialog window ***\n"); debugPrint("\n *** Error running perks dialog window ***\n");
@ -5444,10 +5468,10 @@ int editorSelectPerk()
} }
buttonCreate(gEditorPerkWindow, buttonCreate(gEditorPerkWindow,
45, PERK_WINDOW_LIST_X,
43, PERK_WINDOW_LIST_Y,
192, PERK_WINDOW_LIST_WIDTH,
129, PERK_WINDOW_LIST_HEIGHT,
-1, -1,
-1, -1,
-1, -1,
@ -5561,10 +5585,10 @@ int _InputPDLoop(int count, void (*refreshProc)())
soundPlayFile("ib1p1xx1"); soundPlayFile("ib1p1xx1");
rc = 1; rc = 1;
} else if (keyCode == 501) { } else if (keyCode == 501) {
mouseGetPosition(&_mouse_xpos, &_mouse_ypos); mouseGetPositionInWindow(gEditorPerkWindow , &_mouse_xpos, &_mouse_ypos);
_cline = (_mouse_ypos - 134) / v16; _cline = (_mouse_ypos - PERK_WINDOW_LIST_Y) / v16;
if ((_mouse_ypos - 134) / v16 >= 0) { if (_cline >= 0) {
if (count - 1 < (_mouse_ypos - 134) / v16) if (count - 1 < _cline)
_cline = count - 1; _cline = count - 1;
} else { } else {
_cline = 0; _cline = 0;