@@ -25,7 +25,7 @@ IronFlame0x944::IronFlame0x944()
2525 m_golExport = NULL ;
2626 m_hWnd = 0 ;
2727 m_golBackendType = c_golBackendDP;
28- m_unk0x92c = 0 ;
28+ m_windowMode = c_windowModeNone ;
2929 m_unk0x934 = 0 ;
3030 m_unk0x93c = 0 ;
3131 m_unk0x940 = 0 ;
@@ -108,7 +108,7 @@ void IronFlame0x944::Init(const LegoChar* p_windowName, const LegoChar* p_fileNa
108108 SetWindowLong (m_hWnd, 0 , (LONG ) this );
109109 ShowWindow (m_hWnd, SW_SHOW );
110110 m_lastFrameTimeMs = timeGetTime ();
111- m_unk0x92c = 0 ;
111+ m_windowMode = c_windowModeNone ;
112112 m_flags |= c_flagInitialized;
113113}
114114
@@ -147,7 +147,7 @@ void IronFlame0x944::Destroy()
147147 m_unk0x834.Shutdown ();
148148 UnloadGolLibrary ();
149149
150- m_unk0x92c = 0 ;
150+ m_windowMode = c_windowModeNone ;
151151 m_flags = 0 ;
152152}
153153
@@ -298,7 +298,7 @@ LegoS32 IronFlame0x944::VTable0x24(LegoU32 p_width, LegoU32 p_height, LegoU32 p_
298298 }
299299
300300 if (!(m_flags & c_flagBit3)) {
301- m_unk0x92c = 2 ;
301+ m_windowMode = c_windowModeWindowed ;
302302 SetWindowLong (m_hWnd, GWL_STYLE , (LONG ) m_unk0x940);
303303
304304 RECT rect;
@@ -321,7 +321,7 @@ LegoS32 IronFlame0x944::VTable0x24(LegoU32 p_width, LegoU32 p_height, LegoU32 p_
321321 SetWindowPos (m_hWnd, NULL , 0 , 0 , w, h, SWP_SHOWWINDOW );
322322 }
323323 else {
324- m_unk0x92c = 1 ;
324+ m_windowMode = c_windowModeFullscreen ;
325325 SetWindowLong (m_hWnd, GWL_STYLE , (LONG ) m_unk0x93c);
326326
327327 if (m_flags & c_flagBit8) {
@@ -358,11 +358,11 @@ void IronFlame0x944::VTable0x30()
358358
359359 if (m_flags & c_flagBit3) {
360360 OutputDebugString (" --to windowed\n " );
361- FUN_00417000 ( 2 );
361+ ChangeWindowState (c_windowModeWindowed );
362362 }
363363 else {
364364 OutputDebugString (" --to full screen\n " );
365- FUN_00417000 ( 1 );
365+ ChangeWindowState (c_windowModeFullscreen );
366366 }
367367 }
368368}
@@ -372,7 +372,7 @@ void IronFlame0x944::FUN_00416db0()
372372{
373373 m_unk0x81c->VTable0x28 ();
374374
375- if (m_unk0x92c == 2 ) {
375+ if (m_windowMode == c_windowModeWindowed ) {
376376 RECT rect;
377377 POINT topLeft;
378378 POINT bottomRight;
@@ -438,11 +438,132 @@ LegoS32 IronFlame0x944::Tick(CactusInterface0x4* p_unk0x81c)
438438 return 1 ;
439439}
440440
441- // STUB : LEGORACERS 0x00417000
442- void IronFlame0x944::FUN_00417000 (LegoU32)
441+ // FUNCTION : LEGORACERS 0x00417000
442+ void IronFlame0x944::ChangeWindowState (LegoU32 p_mode )
443443{
444- // TODO
445- STUB (0x417000 );
444+ if (m_unk0x930) {
445+ return ;
446+ }
447+ if (!m_golDrawState) {
448+ return ;
449+ }
450+ if (!(m_golDrawState->GetFlags () & GolDrawState::c_flagBit0)) {
451+ return ;
452+ }
453+ if (p_mode == m_windowMode) {
454+ return ;
455+ }
456+
457+ m_unk0x930 = 1 ;
458+
459+ if (m_unk0x81c) {
460+ m_unk0x81c->VTable0x0c ();
461+ }
462+ m_golDrawState->VTable0x50 ();
463+ LegoU32 drawFlags = VTable0x00 (m_flags) & ~GolDrawState::c_flagBit15;
464+
465+ OutputDebugString (" Changing window state\n " );
466+
467+ if (p_mode == c_windowModeWindowed) {
468+ OutputDebugString (" --to windowed\n " );
469+ m_golDrawState
470+ ->VTable0x54 (m_width, m_height, m_bpp, drawFlags & ~(GolDrawState::c_flagBit9 | GolDrawState::c_flagBit10));
471+
472+ if (m_golDrawState->m_flags & GolDrawState::c_flagBit9) {
473+ OutputDebugString (" --from full screen\n " );
474+ m_flags |= c_flagBit3;
475+ m_windowMode = c_windowModeFullscreen;
476+ SetWindowLong (m_hWnd, GWL_STYLE , (LONG ) m_unk0x93c);
477+ if (m_flags & c_flagBit8) {
478+ SetWindowPos (m_hWnd, NULL , 0 , 0 , 0 , 0 , SWP_SHOWWINDOW );
479+ }
480+ else {
481+ VTable0x38 ()->GetUnk0xa0 ()->VTable0x44 ();
482+ SetWindowPos (
483+ m_hWnd,
484+ NULL ,
485+ 0 ,
486+ 0 ,
487+ GetSystemMetrics (SM_CXSCREEN ),
488+ GetSystemMetrics (SM_CYSCREEN ),
489+ SWP_SHOWWINDOW
490+ );
491+ }
492+ }
493+ else {
494+ m_flags &= ~c_flagBit3;
495+ m_windowMode = c_windowModeWindowed;
496+ SetWindowLong (m_hWnd, GWL_STYLE , (LONG ) m_unk0x940);
497+
498+ RECT rect;
499+ rect.left = 0 ;
500+ rect.right = m_width;
501+ rect.top = 0 ;
502+ rect.bottom = m_height;
503+ AdjustWindowRect (&rect, m_unk0x940, FALSE );
504+
505+ LegoS32 w = rect.right - rect.left ;
506+ LegoS32 h = rect.bottom - rect.top ;
507+ LegoS32 screenW = GetSystemMetrics (SM_CXSCREEN );
508+ LegoS32 screenH = GetSystemMetrics (SM_CYSCREEN );
509+ LegoS32 x, y;
510+ if (w > screenW) {
511+ w = screenW;
512+ x = 0 ;
513+ }
514+ else {
515+ x = (screenW - w) >> 1 ;
516+ }
517+ if (h > screenH) {
518+ h = screenH;
519+ y = 0 ;
520+ }
521+ else {
522+ y = (screenH - h) >> 1 ;
523+ }
524+ SetWindowPos (m_hWnd, NULL , x, y, w, h, SWP_SHOWWINDOW );
525+ }
526+
527+ if (m_unk0x81c) {
528+ m_unk0x81c->VTable0x10 ();
529+ }
530+ }
531+ else if (p_mode == c_windowModeFullscreen) {
532+ OutputDebugString (" --to full screen\n " );
533+ m_flags |= c_flagBit3;
534+ LegoU32 fullscreenFlags = drawFlags | (GolDrawState::c_flagBit9 | GolDrawState::c_flagBit10);
535+ m_windowMode = c_windowModeFullscreen;
536+ SetWindowLong (m_hWnd, GWL_STYLE , (LONG ) m_unk0x93c);
537+ if (m_flags & c_flagBit8) {
538+ SetWindowPos (m_hWnd, NULL , 0 , 0 , 0 , 0 , SWP_SHOWWINDOW );
539+ }
540+ else {
541+ VTable0x38 ()->GetUnk0xa0 ()->VTable0x44 ();
542+ SetWindowPos (
543+ m_hWnd,
544+ NULL ,
545+ 0 ,
546+ 0 ,
547+ GetSystemMetrics (SM_CXSCREEN ),
548+ GetSystemMetrics (SM_CYSCREEN ),
549+ SWP_SHOWWINDOW
550+ );
551+ }
552+ m_golDrawState->VTable0x54 (m_width, m_height, m_bpp, fullscreenFlags);
553+
554+ if (m_unk0x81c) {
555+ m_unk0x81c->VTable0x10 ();
556+ }
557+ }
558+ else if (p_mode == c_windowModeMinimized) {
559+ OutputDebugString (" --to minimized\n " );
560+ ShowWindow (m_hWnd, SW_SHOWMINNOACTIVE );
561+ m_windowMode = c_windowModeMinimized;
562+ }
563+
564+ UpdateWindow (m_hWnd);
565+ SetFocus (m_hWnd);
566+ m_unk0x930 = 0 ;
446567}
447568
448569// STUB: LEGORACERS 0x00417330
0 commit comments