OpenBarnyard
 
Loading...
Searching...
No Matches
TMSWindow Class Reference

#include <TMSWindow.h>

Inheritance diagram for TMSWindow:
TObject

Public Types

using ThisClass = TMSWindow
 
using BaseClass = TObject
 
- Public Types inherited from TObject
enum  { IsTObject = TTRUE }
 

Public Member Functions

virtual Toshi::TClass * GetClass () override
 
 TMSWindow ()
 
 TMSWindow (const TMSWindow &)=default
 
void Update (TFLOAT a_fDeltaTime)
 
TBOOL Create (TRenderInterface *renderer, LPCSTR title)
 
void UnregisterWindowClass ()
 
void SetPosition (UINT x, UINT y, UINT width, UINT height)
 
void SetWindowed ()
 
void SetFullscreen ()
 
TBOOL IsDestroyed () const
 
TBOOL IsWindowed () const
 
HWND GetHWND () const
 
- Public Member Functions inherited from TObject
virtual void Delete ()
 
virtual ~TObject ()
 
TBOOL IsExactly (TClass *a_pClass)
 
TBOOL IsA (TClass *a_pClass)
 

Static Public Member Functions

static Toshi::TObject * CreateTObject ()
 
static Toshi::TObject * CreateTObjectInPlace (void *a_pPtr)
 
static void InitialiseClass ()
 
static void DeinitialiseClass ()
 
static TFORCEINLINE Toshi::TClass * GetClassStatic ()
 
static void SetFocused (TBOOL a_bFocused)
 
- Static Public Member Functions inherited from TObject
static Toshi::TObject * CreateTObject ()
 
static Toshi::TObject * CreateTObjectInPlace (void *a_pPtr)
 
static void InitialiseClass ()
 
static void DeinitialiseClass ()
 
static TFORCEINLINE TClassGetClassStatic ()
 

Static Public Attributes

static constexpr Toshi::TClass * PARENTCLASS = & TObject::ms_oClass
 
static Toshi::TClass ms_oClass = Toshi::TClass( "TMSWindow", TMSWindow::PARENTCLASS, TMSWindow::CreateTObject, TMSWindow::CreateTObjectInPlace, TMSWindow::InitialiseClass, TMSWindow::DeinitialiseClass, 0, 1, sizeof( TMSWindow ), alignof( TMSWindow ) )
 
static constexpr UINT s_PopupStyles = WS_POPUP | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU
 
- Static Public Attributes inherited from TObject
static constexpr Toshi::TClass * PARENTCLASS = TNULL
 
static constinit Toshi::TClass ms_oClass = Toshi::TClass( "TObject", TObject::CreateTObject, TObject::CreateTObjectInPlace, TObject::InitialiseClass, TObject::DeinitialiseClass, 0, 2, sizeof( TObject ), alignof( TObject ) )
 

Static Protected Attributes

static constexpr GUID WceusbshGUID = { 0x25dbce51, 0x6c8f, 0x4a72, 0x8a, 0x6d, 0xb5, 0x4c, 0x2b, 0x4f, 0xc8, 0x35 }
 
static TBOOL ms_bIsFocused
 
static BOOL ms_bIsFullscreen
 
static STICKYKEYS ms_StickyKeys
 
static HDEVNOTIFY ms_hDeviceNotify
 

Detailed Description

Definition at line 11 of file TMSWindow.h.

Member Typedef Documentation

◆ BaseClass

Definition at line 14 of file TMSWindow.h.

◆ ThisClass

Definition at line 14 of file TMSWindow.h.

Constructor & Destructor Documentation

◆ TMSWindow() [1/2]

TMSWindow::TMSWindow ( )

Definition at line 20 of file TMSWindow.cpp.

21{
22 m_HWND = NULL;
23 m_pRenderer = TNULL;
24 m_bWindowed = TTRUE;
25 m_bDestroyed = TFALSE;
26 m_bIsFocused = TFALSE;
27
28 TString8 rendererName = TGetClass( TRenderD3DInterface ).GetName();
30
31 ms_StickyKeys.cbSize = sizeof( STICKYKEYS );
32 SystemParametersInfoA( SPI_GETSTICKYKEYS, sizeof( STICKYKEYS ), &ms_StickyKeys, 0 );
33
34 STICKYKEYS newStickyKeys = { sizeof( STICKYKEYS ) };
35 newStickyKeys.dwFlags = 0;
36 SystemParametersInfoA( SPI_SETSTICKYKEYS, sizeof( STICKYKEYS ), &newStickyKeys, 0 );
37}
#define TGetClass(CLASS)
Definition TObject.h:13
#define TNULL
Definition Typedefs.h:23
#define TFALSE
Definition Typedefs.h:24
#define TTRUE
Definition Typedefs.h:25
void UnregisterWindowClass()
static STICKYKEYS ms_StickyKeys
Definition TMSWindow.h:67

◆ TMSWindow() [2/2]

TMSWindow::TMSWindow ( const TMSWindow & )
default

Member Function Documentation

◆ Create()

TBOOL TMSWindow::Create ( TRenderInterface * renderer,
LPCSTR title )

Definition at line 157 of file TMSWindow.cpp.

158{
159 m_ModuleHandle = GetModuleHandleA( NULL );
161
162 m_pRenderer = renderer;
163
164 WNDCLASSA wndClass = {
165 .style = 3,
166 .lpfnWndProc = WndProc,
167 .cbClsExtra = 0,
168 .cbWndExtra = 0,
169 .hInstance = m_ModuleHandle,
170 .hIcon = NULL,
171 .hCursor = LoadCursorA( NULL, IDC_ARROW ),
172 .hbrBackground = (HBRUSH)GetStockObject( 1 ),
173 .lpszMenuName = NULL,
174 .lpszClassName = TGetClass( TRenderD3DInterface ).GetName()
175 };
176
177 RegisterClassA( &wndClass );
178 m_HWND = CreateWindowExA(
179 0,
180 TGetClass( TRenderD3DInterface ).GetName(),
181 title,
182 0x86c00000,
183 100,
184 100,
185 0,
186 0,
187 NULL,
188 NULL,
189 m_ModuleHandle,
190 this
191 );
192
193 if ( !m_HWND ) return TFALSE;
194
195 EnableWindow( m_HWND, TRUE );
196 ShowWindow( m_HWND, SW_SHOW );
197
198 return TTRUE;
199}

◆ CreateTObject()

Toshi::TObject * TMSWindow::CreateTObject ( )
static

Definition at line 18 of file TMSWindow.cpp.

◆ CreateTObjectInPlace()

Toshi::TObject * TMSWindow::CreateTObjectInPlace ( void * a_pPtr)
static

Definition at line 18 of file TMSWindow.cpp.

◆ DeinitialiseClass()

void TMSWindow::DeinitialiseClass ( )
static

Definition at line 18 of file TMSWindow.cpp.

◆ GetClass()

Toshi::TClass * TMSWindow::GetClass ( )
overridevirtual

Reimplemented from TObject.

Definition at line 18 of file TMSWindow.cpp.

◆ GetClassStatic()

static TFORCEINLINE Toshi::TClass * TMSWindow::GetClassStatic ( )
inlinestatic

Definition at line 14 of file TMSWindow.h.

◆ GetHWND()

HWND TMSWindow::GetHWND ( ) const
inline

Definition at line 52 of file TMSWindow.h.

53 {
54 return m_HWND;
55 }

◆ InitialiseClass()

void TMSWindow::InitialiseClass ( )
static

Definition at line 18 of file TMSWindow.cpp.

◆ IsDestroyed()

TBOOL TMSWindow::IsDestroyed ( ) const
inline

Definition at line 42 of file TMSWindow.h.

43 {
44 return m_bDestroyed;
45 }

◆ IsWindowed()

TBOOL TMSWindow::IsWindowed ( ) const
inline

Definition at line 47 of file TMSWindow.h.

48 {
49 return m_bWindowed;
50 }

◆ SetFocused()

void TMSWindow::SetFocused ( TBOOL a_bFocused)
static

Definition at line 131 of file TMSWindow.cpp.

132{
133 if ( ms_bIsFocused != a_bFocused )
134 {
135 ms_bIsFocused = a_bFocused;
136
137 if ( ms_bIsFocused )
138 {
139 SystemParametersInfoA( SPI_GETSTICKYKEYS, sizeof( STICKYKEYS ), &ms_StickyKeys, 0 );
140
141 STICKYKEYS newStickyKeys = { sizeof( STICKYKEYS ) };
142 newStickyKeys.dwFlags = 0;
143 SystemParametersInfoA( SPI_SETSTICKYKEYS, sizeof( STICKYKEYS ), &newStickyKeys, 0 );
144 }
145 else
146 {
147 SystemParametersInfoA( SPI_SETSTICKYKEYS, sizeof( STICKYKEYS ), &ms_StickyKeys, 0 );
148 }
149 }
150}
static TBOOL ms_bIsFocused
Definition TMSWindow.h:65

◆ SetFullscreen()

void TMSWindow::SetFullscreen ( )
inline

Definition at line 36 of file TMSWindow.h.

37 {
38 TASSERT( GetHWND() != TNULL );
39 m_bWindowed = TFALSE;
40 }
#define TASSERT(X,...)
Definition Defines.h:138
HWND GetHWND() const
Definition TMSWindow.h:52

◆ SetPosition()

void TMSWindow::SetPosition ( UINT x,
UINT y,
UINT width,
UINT height )

Definition at line 152 of file TMSWindow.cpp.

153{
154 SetWindowPos( m_HWND, HWND_TOP, x, y, width, height, 0 );
155}

◆ SetWindowed()

void TMSWindow::SetWindowed ( )
inline

Definition at line 30 of file TMSWindow.h.

31 {
32 TASSERT( GetHWND() != TNULL );
33 m_bWindowed = TTRUE;
34 }

◆ UnregisterWindowClass()

void TMSWindow::UnregisterWindowClass ( )

Definition at line 109 of file TMSWindow.cpp.

110{
111 if ( m_HWND != NULL )
112 {
113 if ( ms_bIsFocused )
114 {
116 SystemParametersInfoA( SPI_SETSTICKYKEYS, sizeof( STICKYKEYS ), &ms_StickyKeys, 0 );
117 }
118
119 DestroyWindow( m_HWND );
120 m_bDestroyed = TTRUE;
121 m_HWND = NULL;
122 }
123
124 if ( m_pRenderer != TNULL )
125 {
126 UnregisterClassA( TGetClass( TRenderD3DInterface ).GetName(), m_ModuleHandle );
127 m_pRenderer = TNULL;
128 }
129}

◆ Update()

void TMSWindow::Update ( TFLOAT a_fDeltaTime)

Definition at line 39 of file TMSWindow.cpp.

40{
41 MSG msg;
42
43 if ( m_bDestroyed ) return;
44
45 if ( !m_bIsFocused )
46 {
48 {
49 if ( FALSE != PeekMessageA( &msg, NULL, 0, 0, 0 ) )
50 {
51 while ( FALSE != GetMessageA( &msg, NULL, 0, 0 ) )
52 {
53 TranslateMessage( &msg );
54 DispatchMessageA( &msg );
55
56 if ( FALSE == PeekMessageA( &msg, NULL, 0, 0, 0 ) )
57 {
58 return;
59 }
60 }
61
62 m_bDestroyed = TTRUE;
63 }
64
65 return;
66 }
67 else
68 {
69 m_bIsFocused = TTRUE;
70 LONG uStyle = GetWindowLongA( m_HWND, GWL_STYLE );
71 SetWindowLongA( m_HWND, GWL_STYLE, uStyle | WS_SYSMENU );
72 return;
73 }
74 }
75
76 while ( g_oSystemManager.IsPaused() )
77 {
78 if ( FALSE == GetMessageA( &msg, NULL, 0, 0 ) )
79 {
80 m_bDestroyed = TTRUE;
81 m_bIsFocused = TFALSE;
82 return;
83 }
84
85 TranslateMessage( &msg );
86 DispatchMessageA( &msg );
87 }
88
89 m_bIsFocused = TFALSE;
90
91 LONG uStyle = GetWindowLongA( m_HWND, GWL_STYLE );
92 SetWindowLongA( m_HWND, GWL_STYLE, uStyle & ( ~WS_SYSMENU ) );
93
94 if ( FALSE != PeekMessageA( &msg, NULL, 0, 0, 0 ) )
95 {
96 while ( FALSE != GetMessageA( &msg, NULL, 0, 0 ) )
97 {
98 TranslateMessage( &msg );
99 DispatchMessageA( &msg );
100
101 if ( FALSE == PeekMessageA( &msg, NULL, 0, 0, 0 ) )
102 {
103 return;
104 }
105 }
106 }
107}
TSystemManager g_oSystemManager
TBOOL IsPaused() const
Definition TSystem.h:160

Member Data Documentation

◆ ms_bIsFocused

TBOOL TMSWindow::ms_bIsFocused
inlinestaticprotected

Definition at line 65 of file TMSWindow.h.

◆ ms_bIsFullscreen

BOOL TMSWindow::ms_bIsFullscreen
inlinestaticprotected

Definition at line 66 of file TMSWindow.h.

◆ ms_hDeviceNotify

HDEVNOTIFY TMSWindow::ms_hDeviceNotify
inlinestaticprotected

Definition at line 68 of file TMSWindow.h.

◆ ms_oClass

Toshi::TClass TMSWindow::ms_oClass = Toshi::TClass( "TMSWindow", TMSWindow::PARENTCLASS, TMSWindow::CreateTObject, TMSWindow::CreateTObjectInPlace, TMSWindow::InitialiseClass, TMSWindow::DeinitialiseClass, 0, 1, sizeof( TMSWindow ), alignof( TMSWindow ) )
static

Definition at line 14 of file TMSWindow.h.

◆ ms_StickyKeys

STICKYKEYS TMSWindow::ms_StickyKeys
inlinestaticprotected

Definition at line 67 of file TMSWindow.h.

◆ PARENTCLASS

Toshi::TClass* TMSWindow::PARENTCLASS = & TObject::ms_oClass
staticconstexpr

Definition at line 14 of file TMSWindow.h.

◆ s_PopupStyles

UINT TMSWindow::s_PopupStyles = WS_POPUP | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU
staticconstexpr

Definition at line 17 of file TMSWindow.h.

◆ WceusbshGUID

GUID TMSWindow::WceusbshGUID = { 0x25dbce51, 0x6c8f, 0x4a72, 0x8a, 0x6d, 0xb5, 0x4c, 0x2b, 0x4f, 0xc8, 0x35 }
staticconstexprprotected

Definition at line 63 of file TMSWindow.h.

63{ 0x25dbce51, 0x6c8f, 0x4a72, 0x8a, 0x6d, 0xb5, 0x4c, 0x2b, 0x4f, 0xc8, 0x35 };

The documentation for this class was generated from the following files: