1
1
#include " pch.h"
2
2
#include " fullscrn.h"
3
3
4
+
5
+ #include " options.h"
4
6
#include " pb.h"
5
7
#include " render.h"
6
8
#include " winmain.h"
@@ -24,6 +26,10 @@ const resolution_info fullscrn::resolution_array[3] =
24
26
{800 , 600 , 752 , 520 , 502 },
25
27
{1024 , 768 , 960 , 666 , 503 },
26
28
};
29
+ float fullscrn::ScaleX = 1 ;
30
+ float fullscrn::ScaleY = 1 ;
31
+ float fullscrn::OffsetX = 0 ;
32
+ float fullscrn::OffsetY = 0 ;
27
33
28
34
void fullscrn::init (int width, int height, int isFullscreen, HWND winHandle, HMENU menuHandle, int changeDisplay)
29
35
{
@@ -46,15 +52,21 @@ void fullscrn::init(int width, int height, int isFullscreen, HWND winHandle, HME
46
52
WindowRect2.right = (WindowRect1.right - WindowRect1.left - widht2) / 2 - 2 + widht2 + 4 ;
47
53
WindowRect2.left = (WindowRect1.right - WindowRect1.left - widht2) / 2 - 2 ;
48
54
WindowRect2.top = borderHeight / 2 - (captionHeight + menuHeight) - 2 ;
55
+
56
+ /* RECT client{0,0,width,height};
57
+ AdjustWindowRect(&client, winmain::WndStyle, true);*/
49
58
MoveWindow (
50
59
hWnd,
51
60
(WindowRect1.right - WindowRect1.left - widht2) / 2 - 2 ,
52
61
WindowRect2.top ,
53
- widht2 + 4 + 10 ,
62
+ WindowRect2. right - WindowRect2. left + 10 ,
54
63
WindowRect2.bottom - WindowRect2.top + 10 ,
55
64
0 );
56
65
// Todo: WH + 10 hack: original request 640x480 window but somehow receives 650x490, even thought spyxx says it is 640x480
57
66
fullscrn_flag1 = 0 ;
67
+
68
+ window_size_changed ();
69
+ assertm (ScaleX == 1 && ScaleY == 1 , " Wrong default client size" );
58
70
}
59
71
60
72
void fullscrn::shutdown ()
@@ -94,13 +106,13 @@ int fullscrn::set_screen_mode(int isFullscreen)
94
106
int fullscrn::disableWindowFlagsDisDlg ()
95
107
{
96
108
long style = GetWindowLongA (hWnd, -16 );
97
- return SetWindowLongA (hWnd, -16 , style & 0xFF3FFFFF );
109
+ return SetWindowLongA (hWnd, -16 , style & ~(WS_CAPTION | WS_THICKFRAME) );
98
110
}
99
111
100
112
int fullscrn::setWindowFlagsDisDlg ()
101
113
{
102
114
int style = GetWindowLongA (hWnd, -16 );
103
- return SetWindowLongA (hWnd, -16 , style | 0xC00000 );
115
+ return SetWindowLongA (hWnd, -16 , style | WS_CAPTION | WS_THICKFRAME );
104
116
}
105
117
106
118
int fullscrn::enableFullscreen ()
@@ -339,10 +351,12 @@ unsigned fullscrn::convert_mouse_pos(unsigned int mouseXY)
339
351
340
352
void fullscrn::getminmaxinfo (MINMAXINFO* maxMin)
341
353
{
342
- maxMin->ptMaxSize .x = WindowRect2.right - WindowRect2.left ;
343
- maxMin->ptMaxSize .y = WindowRect2.bottom - WindowRect2.top ;
344
- maxMin->ptMaxPosition .x = WindowRect2.left ;
345
- maxMin->ptMaxPosition .y = WindowRect2.top ;
354
+ /* Block down-scaling lower than min resolution*/
355
+ maxMin->ptMinTrackSize = POINT
356
+ {
357
+ resolution_array[0 ].ScreenWidth / 2 ,
358
+ resolution_array[0 ].ScreenHeight / 2
359
+ };
346
360
}
347
361
348
362
void fullscrn::paint ()
@@ -419,3 +433,34 @@ int fullscrn::get_screen_resolution()
419
433
auto height = static_cast <unsigned __int16>(GetSystemMetrics (SM_CYSCREEN));
420
434
return static_cast <unsigned __int16>(GetSystemMetrics (SM_CXSCREEN)) | (height << 16 );
421
435
}
436
+
437
+ void fullscrn::window_size_changed ()
438
+ {
439
+ /* No scaling in fullscreen mode*/
440
+ if (display_changed)
441
+ {
442
+ ScaleY = ScaleX = 1 ;
443
+ OffsetX = OffsetY = 0 ;
444
+ return ;
445
+ }
446
+
447
+ RECT client{};
448
+ GetClientRect (hWnd, &client);
449
+ auto res = &resolution_array[resolution];
450
+ ScaleX = static_cast <float >(client.right ) / res->TableWidth ;
451
+ ScaleY = static_cast <float >(client.bottom ) / res->TableHeight ;
452
+ OffsetX = OffsetY = 0 ;
453
+
454
+ if (options::Options.UniformScaling )
455
+ {
456
+ ScaleY = ScaleX = min (ScaleX, ScaleY);
457
+ OffsetX = floor ((client.right - res->TableWidth * ScaleX) / 2 );
458
+ OffsetY = floor ((client.bottom - res->TableHeight * ScaleY) / 2 );
459
+ auto dc = GetDC (hWnd);
460
+ if (dc)
461
+ {
462
+ BitBlt (dc, 0 , 0 , client.right , client.bottom , dc, 0 , 0 , BLACKNESS);
463
+ ReleaseDC (hWnd, dc);
464
+ }
465
+ }
466
+ }
0 commit comments