Make screensize independent on screen resolution

This commit is contained in:
nukeykt 2019-10-29 23:17:15 +09:00 committed by Christoph Oelckers
parent eea4fa80f1
commit 308f36d0e8
4 changed files with 17 additions and 37 deletions

View file

@ -752,14 +752,15 @@ int MyGetStringWidth(const char *str)
void UpdateScreenSize() void UpdateScreenSize()
{ {
int v0 = ydim * screensize / xdim; int xsize = xdim - scale(screensize*16, xdim, 320);
int y1 = ((ydim >> 1) - (v0 >> 1)); int ysize = scale(ydim, xsize, xdim);
int y1 = ((ydim >> 1) - (ysize >> 1));
MySetView( MySetView(
(xdim >> 1) - (screensize >> 1), (xdim >> 1) - (xsize >> 1),
y1, y1,
(xdim >> 1) - (screensize >> 1) + screensize - 1, (xdim >> 1) - (xsize >> 1) + xsize - 1,
(y1 + v0 - 1)); (y1 + ysize - 1));
RefreshStatus(); RefreshStatus();
} }
@ -894,14 +895,7 @@ void CheckKeys()
if (BUTTON(gamefunc_Enlarge_Screen)) if (BUTTON(gamefunc_Enlarge_Screen))
{ {
if (bHiRes) { if (screensize == 0)
eax = 32;
}
else {
eax = 16;
}
if (screensize == xdim)
{ {
if (!bFullScreen) if (!bFullScreen)
{ {
@ -911,9 +905,9 @@ void CheckKeys()
} }
else else
{ {
screensize += eax; screensize--;
if (screensize > xdim) { if (screensize < 0) {
screensize = xdim; screensize = 0;
} }
UpdateScreenSize(); UpdateScreenSize();
@ -955,19 +949,14 @@ void CheckKeys()
if (BUTTON(gamefunc_Shrink_Screen)) if (BUTTON(gamefunc_Shrink_Screen))
{ {
if (bHiRes)
eax = 32;
else
eax = 16;
if (bFullScreen) if (bFullScreen)
{ {
bFullScreen = kFalse; bFullScreen = kFalse;
} }
else else
{ {
if ((screensize - eax) > (xdim >> 2)) if ((screensize + 1) < 15)
screensize -= eax; screensize++;
} }
UpdateScreenSize(); UpdateScreenSize();

View file

@ -1229,12 +1229,8 @@ int myloadconfig()
fread(&nGamma, sizeof(nGamma), 1, fp); fread(&nGamma, sizeof(nGamma), 1, fp);
fread(&lMouseSens, sizeof(lMouseSens), 1, fp); fread(&lMouseSens, sizeof(lMouseSens), 1, fp);
if (bHiRes) { if (screensize < 0 || screensize > 15) {
screensize *= 2; screensize = 0;
}
if (screensize > xdim || screensize < xdim >> 2) {
screensize = xdim;
} }
fclose(fp); fclose(fp);
@ -1262,11 +1258,6 @@ int mysaveconfig()
short nSize = screensize; short nSize = screensize;
if (bHiRes)
{
nSize = screensize / 2;
}
fwrite(&nSize, sizeof(nSize), 1, fp); fwrite(&nSize, sizeof(nSize), 1, fp);
fwrite(&bFullScreen, sizeof(bFullScreen), 1, fp); fwrite(&bFullScreen, sizeof(bFullScreen), 1, fp);
fwrite(&nGamma, sizeof(nGamma), 1, fp); fwrite(&nGamma, sizeof(nGamma), 1, fp);

View file

@ -473,7 +473,7 @@ void MoveStatus()
message_timer -= 4; message_timer -= 4;
if (message_timer <= 0) if (message_timer <= 0)
{ {
if (screensize < xdim) { if (screensize > 0) {
textpages = numpages; textpages = numpages;
} }
@ -644,7 +644,7 @@ void StatusMessage(int messageTime, const char *fmt, ...)
vsprintf(message_text, fmt, args); vsprintf(message_text, fmt, args);
if (screensize < xdim) { if (screensize > 0) {
textpages = numpages; textpages = numpages;
} }
} }

View file

@ -62,7 +62,7 @@ short nEnemyPal = 0;
void InitView() void InitView()
{ {
screensize = (short)xdim; screensize = 0;
#ifdef USE_OPENGL #ifdef USE_OPENGL
polymostcenterhoriz = 92; polymostcenterhoriz = 92;
#endif #endif