2018-09-05 13:17:07 +08:00
# include "..\e2dmodule.h"
2018-09-06 23:26:32 +08:00
# include "..\e2dobject.h"
2018-08-15 23:30:23 +08:00
# include "..\e2dtransition.h"
2018-04-21 21:24:46 +08:00
# include "..\e2dmanager.h"
2018-07-21 22:57:21 +08:00
# include <thread>
2018-09-30 14:54:43 +08:00
# include <imm.h>
# pragma comment (lib ,"imm32.lib")
2018-07-21 22:57:21 +08:00
2018-09-30 14:54:43 +08:00
# define WINDOW_STYLE WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX & ~WS_THICKFRAME
# define REGISTER_CLASS L"Easy2DApp"
2018-01-30 16:45:38 +08:00
2018-08-28 00:06:10 +08:00
2018-09-30 14:54:43 +08:00
e2d : : Game * e2d : : Game : : instance_ = nullptr ;
2018-08-28 00:06:10 +08:00
2018-07-03 01:49:20 +08:00
e2d : : Game : : Game ( )
2018-09-30 14:54:43 +08:00
: hwnd_ ( nullptr )
, quit_ ( true )
2018-09-04 22:42:34 +08:00
, curr_scene_ ( nullptr )
, next_scene_ ( nullptr )
, transition_ ( nullptr )
2018-07-03 01:49:20 +08:00
{
2018-09-02 14:03:04 +08:00
: : CoInitialize ( nullptr ) ;
2018-07-03 01:49:20 +08:00
}
2018-07-03 18:16:26 +08:00
e2d : : Game : : ~ Game ( )
{
2018-09-07 00:28:54 +08:00
SafeRelease ( transition_ ) ;
SafeRelease ( curr_scene_ ) ;
SafeRelease ( next_scene_ ) ;
2018-09-30 14:54:43 +08:00
if ( hwnd_ )
{
: : DestroyWindow ( hwnd_ ) ;
}
2018-09-02 14:03:04 +08:00
: : CoUninitialize ( ) ;
2018-07-03 18:16:26 +08:00
}
2018-09-30 14:54:43 +08:00
e2d : : Game * e2d : : Game : : New ( const Option & option )
{
static Game game ;
game . title_ = option . title ;
game . width_ = option . width ;
game . height_ = option . height ;
game . icon_ = option . icon ;
game . debug_mode_ = option . debug_mode ;
game . Init ( ) ;
instance_ = & game ;
return instance_ ;
}
e2d : : Game * e2d : : Game : : Get ( )
{
return instance_ ;
}
void e2d : : Game : : Run ( )
2018-01-30 16:45:38 +08:00
{
2018-09-04 22:42:34 +08:00
quit_ = false ;
auto input = Input : : GetInstance ( ) ;
2018-09-30 14:54:43 +08:00
auto graphics = Graphics : : Get ( ) ;
2018-07-29 13:44:53 +08:00
2018-09-30 14:54:43 +08:00
const int min_interval = 5 ;
2018-09-04 22:42:34 +08:00
Time last = Time : : Now ( ) ;
2018-09-30 14:54:43 +08:00
MSG msg = { 0 } ;
2018-08-02 00:27:45 +08:00
2018-09-30 14:54:43 +08:00
: : ShowWindow ( hwnd_ , SW_SHOWNORMAL ) ;
: : UpdateWindow ( hwnd_ ) ;
2018-09-04 22:42:34 +08:00
UpdateScene ( ) ;
2018-07-29 01:43:15 +08:00
2018-09-04 22:42:34 +08:00
while ( ! quit_ )
2018-01-30 16:45:38 +08:00
{
2018-09-04 22:42:34 +08:00
auto now = Time : : Now ( ) ;
2018-08-02 00:27:45 +08:00
auto dur = now - last ;
2018-01-30 16:45:38 +08:00
2018-09-30 14:54:43 +08:00
if ( dur . Milliseconds ( ) > min_interval )
2018-01-30 16:45:38 +08:00
{
2018-08-02 00:27:45 +08:00
last = now ;
2018-09-04 22:42:34 +08:00
input - > Update ( ) ;
2018-08-19 15:11:20 +08:00
2018-09-07 23:47:21 +08:00
UpdateScene ( ) ;
2018-09-04 22:42:34 +08:00
DrawScene ( ) ;
2018-09-07 23:47:21 +08:00
2018-09-30 14:54:43 +08:00
while ( : : PeekMessage ( & msg , nullptr , 0 , 0 , PM_REMOVE ) )
{
: : TranslateMessage ( & msg ) ;
: : DispatchMessage ( & msg ) ;
}
2018-01-30 16:45:38 +08:00
}
else
{
2018-08-12 14:05:12 +08:00
// ID2D1HwndRenderTarget <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ˴ <EFBFBD> ֱͬ<D6B1> <CDAC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ⱦʱ<C8BE> <CAB1> <EFBFBD> ȴ<EFBFBD> <C8B4> <EFBFBD> ʾ <EFBFBD> <CABE> ˢ<EFBFBD> £<EFBFBD>
2018-07-29 13:44:53 +08:00
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ˷dz<CBB7> <C7B3> ȶ<EFBFBD> <C8B6> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> ã<EFBFBD> <C3A3> <EFBFBD> <EFBFBD> Դ<D4B4> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ҫ<EFBFBD> ֶ<EFBFBD> <D6B6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߳̽<DFB3> <CCBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ĵ<EFBFBD> <C4B4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> һ Щ<D2BB> <D0A9> <EFBFBD> <EFBFBD> <EFBFBD> £<EFBFBD> <C2A3> <EFBFBD> <EFBFBD> 細<EFBFBD> <E7B4B0> <EFBFBD> <EFBFBD> С <EFBFBD> <D0A1> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̣߳<DFB3> <CCA3> <EFBFBD> ֹռ <D6B9> ù<EFBFBD> <C3B9> <EFBFBD> CPU <20> <>
2018-09-30 14:54:43 +08:00
int wait = min_interval - dur . Milliseconds ( ) ;
2018-07-29 13:44:53 +08:00
if ( wait > 1 )
{
std : : this_thread : : sleep_for ( std : : chrono : : milliseconds ( wait ) ) ;
}
2018-01-30 16:45:38 +08:00
}
}
}
2018-09-04 22:42:34 +08:00
void e2d : : Game : : Quit ( )
2018-01-30 16:45:38 +08:00
{
2018-09-04 22:42:34 +08:00
quit_ = true ;
2018-01-30 16:45:38 +08:00
}
2018-09-10 15:28:19 +08:00
void e2d : : Game : : EnterScene ( Scene * scene , Transition * transition )
2018-01-30 16:45:38 +08:00
{
2018-09-10 15:28:19 +08:00
if ( scene = = nullptr )
{
WARN ( " Next scene is null pointer! " ) ;
2018-08-15 23:30:23 +08:00
return ;
2018-09-10 15:28:19 +08:00
}
if ( next_scene_ ! = nullptr )
{
WARN ( " Scene is transitioning... " ) ;
return ;
}
2018-08-15 23:30:23 +08:00
2018-09-07 00:28:54 +08:00
if ( next_scene_ )
{
next_scene_ - > Release ( ) ;
}
2018-09-04 22:42:34 +08:00
next_scene_ = scene ;
next_scene_ - > Retain ( ) ;
2018-08-15 23:30:23 +08:00
2018-09-10 15:28:19 +08:00
if ( transition )
2018-08-15 23:30:23 +08:00
{
2018-09-10 15:28:19 +08:00
if ( transition_ )
{
transition_ - > Stop ( ) ;
transition_ - > Release ( ) ;
}
transition_ = transition ;
transition_ - > Retain ( ) ;
2018-08-15 23:30:23 +08:00
2018-09-10 20:22:47 +08:00
transition_ - > Init ( curr_scene_ , next_scene_ ) ;
2018-08-15 23:30:23 +08:00
}
}
2018-09-04 22:42:34 +08:00
e2d : : Scene * e2d : : Game : : GetCurrentScene ( )
2018-08-15 23:30:23 +08:00
{
2018-09-04 22:42:34 +08:00
return curr_scene_ ;
2018-08-15 23:30:23 +08:00
}
2018-09-04 22:42:34 +08:00
bool e2d : : Game : : IsTransitioning ( ) const
2018-08-15 23:30:23 +08:00
{
2018-09-04 22:42:34 +08:00
return transition_ ! = nullptr ;
2018-08-15 23:30:23 +08:00
}
2018-09-04 22:42:34 +08:00
void e2d : : Game : : UpdateScene ( )
2018-08-15 23:30:23 +08:00
{
2018-09-04 22:42:34 +08:00
if ( transition_ )
2018-08-15 23:30:23 +08:00
{
2018-09-04 22:42:34 +08:00
transition_ - > Update ( ) ;
2018-08-15 23:30:23 +08:00
2018-09-04 22:42:34 +08:00
if ( transition_ - > IsDone ( ) )
2018-08-15 23:30:23 +08:00
{
2018-09-04 22:42:34 +08:00
transition_ - > Release ( ) ;
transition_ = nullptr ;
2018-08-15 23:30:23 +08:00
}
else
{
return ;
}
}
2018-09-04 22:42:34 +08:00
if ( next_scene_ )
2018-08-15 23:30:23 +08:00
{
2018-09-04 22:42:34 +08:00
if ( curr_scene_ )
2018-08-15 23:30:23 +08:00
{
2018-09-04 22:42:34 +08:00
curr_scene_ - > OnExit ( ) ;
2018-09-04 23:20:00 +08:00
curr_scene_ - > Release ( ) ;
2018-08-15 23:30:23 +08:00
}
2018-09-04 22:42:34 +08:00
next_scene_ - > OnEnter ( ) ;
2018-08-15 23:30:23 +08:00
2018-09-04 22:42:34 +08:00
curr_scene_ = next_scene_ ;
next_scene_ = nullptr ;
2018-08-15 23:30:23 +08:00
}
}
2018-09-04 22:42:34 +08:00
void e2d : : Game : : DrawScene ( )
2018-08-15 23:30:23 +08:00
{
2018-09-30 14:54:43 +08:00
auto graphics = Graphics : : Get ( ) ;
graphics - > BeginDraw ( ) ;
if ( transition_ )
2018-08-15 23:30:23 +08:00
{
2018-09-30 14:54:43 +08:00
transition_ - > Draw ( ) ;
}
else if ( curr_scene_ )
{
curr_scene_ - > Draw ( ) ;
}
// TODO @Nomango if debug_mode_
/*
{
graphics - > GetRenderTarget ( ) - > SetTransform ( D2D1 : : Matrix3x2F : : Identity ( ) ) ;
graphics - > GetSolidBrush ( ) - > SetOpacity ( 1.f ) ;
root_ - > DrawBorder ( ) ;
}
{
graphics - > GetRenderTarget ( ) - > SetTransform ( D2D1 : : Matrix3x2F : : Identity ( ) ) ;
root_ - > DrawCollider ( ) ;
}
*/
if ( debug_mode_ )
{
graphics - > DrawDebugInfo ( ) ;
}
graphics - > EndDraw ( ) ;
}
void e2d : : Game : : Init ( )
{
WNDCLASSEX wcex = { 0 } ;
wcex . cbSize = sizeof ( WNDCLASSEX ) ;
wcex . lpszClassName = REGISTER_CLASS ;
wcex . style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS ;
wcex . lpfnWndProc = Game : : WndProc ;
wcex . hIcon = nullptr ;
wcex . cbClsExtra = 0 ;
wcex . cbWndExtra = sizeof ( LONG_PTR ) ;
wcex . hInstance = HINST_THISCOMPONENT ;
wcex . hbrBackground = nullptr ;
wcex . lpszMenuName = nullptr ;
wcex . hCursor = : : LoadCursor ( nullptr , IDC_ARROW ) ;
if ( icon_ ! = 0 )
{
wcex . hIcon = ( HICON ) : : LoadImage (
HINST_THISCOMPONENT ,
MAKEINTRESOURCE ( icon_ ) ,
IMAGE_ICON ,
0 ,
0 ,
LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE
) ;
}
// ע<> ᴰ<EFBFBD> <E1B4B0> <EFBFBD> <EFBFBD>
RegisterClassEx ( & wcex ) ;
// <20> <> <EFBFBD> 㴰<EFBFBD> ڴ<EFBFBD> С
Rect client_rect = Locate ( width_ , height_ ) ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
hwnd_ = : : CreateWindowEx (
NULL ,
REGISTER_CLASS ,
( LPCTSTR ) title_ ,
WINDOW_STYLE ,
int ( client_rect . origin . x ) ,
int ( client_rect . origin . y ) ,
int ( client_rect . size . width ) ,
int ( client_rect . size . height ) ,
nullptr ,
nullptr ,
HINST_THISCOMPONENT ,
this
) ;
if ( hwnd_ )
{
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 뷨
: : ImmAssociateContext ( hwnd_ , nullptr ) ;
// <20> <> <EFBFBD> ÿ<EFBFBD> <C3BF> <EFBFBD> ̨<EFBFBD> رհ <D8B1> ť
HWND console_hwnd = : : GetConsoleWindow ( ) ;
if ( console_hwnd )
{
HMENU hmenu = : : GetSystemMenu ( console_hwnd , FALSE ) ;
: : RemoveMenu ( hmenu , SC_CLOSE , MF_BYCOMMAND ) ;
}
}
else
{
: : UnregisterClass ( REGISTER_CLASS , HINST_THISCOMPONENT ) ;
throw RuntimeException ( " Create window failed " ) ;
}
}
e2d : : Rect e2d : : Game : : Locate ( int width , int height )
{
int max_width = : : GetSystemMetrics ( SM_CXSCREEN ) ;
int max_height = : : GetSystemMetrics ( SM_CYSCREEN ) ;
float dpi_x , dpi_y ;
Graphics : : GetFactory ( ) - > GetDesktopDpi ( & dpi_x , & dpi_y ) ;
RECT rect = { 0 , 0 , LONG ( ceil ( width * dpi_x / 96.f ) ) , LONG ( ceil ( height * dpi_y / 96.f ) ) } ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʵĴ<CAB5> <C4B4> ڴ<EFBFBD> С
: : AdjustWindowRectEx ( & rect , WINDOW_STYLE , FALSE , NULL ) ;
width = static_cast < int > ( rect . right - rect . left ) ;
height = static_cast < int > ( rect . bottom - rect . top ) ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ĵ<EFBFBD> <C4B4> ڴ<EFBFBD> С <EFBFBD> ȷֱ<C8B7> <D6B1> ʴ<EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
WARN_IF ( max_width < width | | max_height < height , " The window Is larger than screen! " ) ;
width = std : : min ( width , max_width ) ;
height = std : : min ( height , max_height ) ;
Rect client_rect (
static_cast < float > ( ( max_width - width ) / 2 ) ,
static_cast < float > ( ( max_height - height ) / 2 ) ,
static_cast < float > ( width ) ,
static_cast < float > ( height )
) ;
return std : : move ( client_rect ) ;
}
int e2d : : Game : : GetWidth ( ) const
{
return width_ ;
}
int e2d : : Game : : GetHeight ( ) const
{
return height_ ;
}
e2d : : Size e2d : : Game : : GetSize ( ) const
{
e2d : : Size size (
static_cast < float > ( width_ ) ,
static_cast < float > ( height_ )
) ;
return std : : move ( size ) ;
}
HWND e2d : : Game : : GetHWnd ( ) const
{
return hwnd_ ;
}
const e2d : : String & e2d : : Game : : GetTitle ( ) const
{
return title_ ;
}
void e2d : : Game : : SetSize ( int width , int height )
{
if ( width_ = = width & & height_ = = height )
return ;
width_ = width ;
height_ = height ;
Rect rect = Locate ( width , height ) ;
: : MoveWindow (
hwnd_ ,
int ( rect . origin . x ) ,
int ( rect . origin . y ) ,
int ( rect . size . width ) ,
int ( rect . size . height ) ,
TRUE
) ;
}
void e2d : : Game : : SetTitle ( const String & title )
{
title_ = title ;
: : SetWindowText ( hwnd_ , ( LPCWSTR ) title ) ;
}
void e2d : : Game : : SetIcon ( int resource_id )
{
icon_ = resource_id ;
HICON icon = ( HICON ) : : LoadImage (
HINST_THISCOMPONENT ,
MAKEINTRESOURCE ( resource_id ) ,
IMAGE_ICON ,
0 ,
0 ,
LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE
) ;
: : SendMessage ( hwnd_ , WM_SETICON , ICON_BIG , ( LPARAM ) icon ) ;
: : SendMessage ( hwnd_ , WM_SETICON , ICON_SMALL , ( LPARAM ) icon ) ;
}
LRESULT e2d : : Game : : WndProc ( HWND hwnd , UINT msg , WPARAM w_param , LPARAM l_param )
{
LRESULT result = 0 ;
if ( msg = = WM_CREATE )
{
LPCREATESTRUCT pcs = ( LPCREATESTRUCT ) l_param ;
Game * game = ( Game * ) pcs - > lpCreateParams ;
: : SetWindowLongPtrW (
hwnd ,
GWLP_USERDATA ,
PtrToUlong ( game )
) ;
result = 1 ;
}
else
{
bool has_handled = false ;
Game * game = reinterpret_cast < Game * > (
static_cast < LONG_PTR > (
: : GetWindowLongPtrW ( hwnd , GWLP_USERDATA )
)
) ;
switch ( msg )
2018-08-15 23:30:23 +08:00
{
2018-09-30 14:54:43 +08:00
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
case WM_LBUTTONUP :
case WM_LBUTTONDOWN :
case WM_LBUTTONDBLCLK :
case WM_MBUTTONUP :
case WM_MBUTTONDOWN :
case WM_MBUTTONDBLCLK :
case WM_RBUTTONUP :
case WM_RBUTTONDOWN :
case WM_RBUTTONDBLCLK :
case WM_MOUSEMOVE :
case WM_MOUSEWHEEL :
{
if ( game - > IsTransitioning ( ) )
break ;
auto curr_scene = game - > GetCurrentScene ( ) ;
if ( curr_scene )
{
curr_scene - > Dispatch ( MouseEvent ( msg , w_param , l_param ) ) ;
}
}
result = 0 ;
has_handled = true ;
break ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
case WM_KEYDOWN :
case WM_KEYUP :
{
if ( game - > IsTransitioning ( ) )
break ;
auto curr_scene = game - > GetCurrentScene ( ) ;
if ( curr_scene )
{
curr_scene - > Dispatch ( KeyEvent ( msg , w_param , l_param ) ) ;
}
}
result = 0 ;
has_handled = true ;
break ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڴ<EFBFBD> С <EFBFBD> 仯<EFBFBD> <E4BBAF> Ϣ
case WM_SIZE :
{
UINT width = LOWORD ( l_param ) ;
UINT height = HIWORD ( l_param ) ;
if ( w_param = = SIZE_RESTORED )
{
float dpi_x , dpi_y ;
Graphics : : GetFactory ( ) - > GetDesktopDpi ( & dpi_x , & dpi_y ) ;
game - > width_ = static_cast < int > ( width * 96.f / dpi_x ) ;
game - > height_ = static_cast < int > ( height * 96.f / dpi_y ) ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> յ<EFBFBD> һ <EFBFBD> <D2BB> WM_SIZE <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ⱦ
// Ŀ<> <C4BF> <EFBFBD> Ĵ<EFBFBD> С <EFBFBD> <D0A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ܻ<EFBFBD> <DCBB> <EFBFBD> <EFBFBD> <EFBFBD> ʧ<EFBFBD> ܣ<EFBFBD> <DCA3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ժ<EFBFBD> <D4BA> <EFBFBD> <EFBFBD> п<EFBFBD> <D0BF> ܵ<EFBFBD>
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϊ<EFBFBD> <CEAA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> һ <EFBFBD> ε<EFBFBD> <CEB5> <EFBFBD> EndDraw ʱ<> <CAB1> <EFBFBD> <EFBFBD>
auto render_target = Graphics : : Get ( ) - > GetRenderTarget ( ) ;
if ( render_target )
{
render_target - > Resize ( D2D1 : : SizeU ( width , height ) ) ;
}
2018-08-15 23:30:23 +08:00
}
2018-09-30 14:54:43 +08:00
break ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڱ<EFBFBD> <DAB1> <EFBFBD> <EFBFBD> 仯<EFBFBD> <E4BBAF> Ϣ
case WM_SETTEXT :
{
game - > title_ = ( const wchar_t * ) l_param ;
}
break ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ֱ<EFBFBD> <D6B1> ʱ仯<CAB1> <E4BBAF> Ϣ
case WM_DISPLAYCHANGE :
{
// <20> ػ<EFBFBD> <D8BB> ͻ<EFBFBD> <CDBB> <EFBFBD>
: : InvalidateRect ( hwnd , nullptr , FALSE ) ;
}
result = 0 ;
has_handled = true ;
break ;
// <20> ػ洰<D8BB> <E6B4B0>
case WM_PAINT :
{
game - > DrawScene ( ) ;
: : ValidateRect ( hwnd , nullptr ) ;
}
result = 0 ;
has_handled = true ;
break ;
// <20> <> <EFBFBD> ڹر<DAB9> <D8B1> <EFBFBD> Ϣ
case WM_CLOSE :
{
auto currScene = game - > GetCurrentScene ( ) ;
if ( ! currScene | | currScene - > OnCloseWindow ( ) )
{
game - > Quit ( ) ;
}
}
result = 0 ;
has_handled = true ;
break ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
case WM_DESTROY :
{
: : PostQuitMessage ( 0 ) ;
}
result = 1 ;
has_handled = true ;
break ;
}
if ( ! has_handled )
2018-08-15 23:30:23 +08:00
{
2018-09-30 14:54:43 +08:00
result = : : DefWindowProc ( hwnd , msg , w_param , l_param ) ;
2018-08-15 23:30:23 +08:00
}
}
2018-09-30 14:54:43 +08:00
return result ;
2018-01-30 16:45:38 +08:00
}