29 #include "../../idlib/precompiled.h"
32 #include "../../sys/win32/rc/guied_resource.h"
33 #include "../../renderer/tr_local.h"
50 memset ( &wndClass, 0,
sizeof(wndClass) );
51 wndClass.cbSize =
sizeof(WNDCLASSEX);
52 wndClass.lpszClassName =
"GUIED_VIEWER";
55 wndClass.style = CS_OWNDC|CS_BYTEALIGNWINDOW|CS_VREDRAW|CS_HREDRAW;
56 wndClass.hbrBackground = (HBRUSH) (COLOR_3DFACE + 1);
57 RegisterClassEx ( &wndClass );
59 mWnd = CreateWindowEx ( WS_EX_TOOLWINDOW,
"GUIED_VIEWER",
"GUI Viewer",
60 WS_SYSMENU|WS_THICKFRAME|WS_CAPTION|WS_POPUP|WS_OVERLAPPED|WS_BORDER|WS_CLIPSIBLINGS|WS_CHILD,
67 ShowWindow (
mWnd, SW_SHOW );
68 UpdateWindow (
mWnd );
84 tbinfo.cbSize =
sizeof(TBBUTTONINFO);
85 tbinfo.dwMask = TBIF_COMMAND|TBIF_IMAGE;
101 tbinfo.cbSize =
sizeof(TBBUTTONINFO);
102 tbinfo.dwMask = TBIF_COMMAND|TBIF_IMAGE;
113 DestroyWindow (
mWnd );
127 tempfile =
va(
"guis/temp.guied", tempfile.
c_str() );
131 idStr createDir = ospath;
133 CreateDirectory ( createDir,
NULL );
135 SetFileAttributes ( ospath, FILE_ATTRIBUTE_NORMAL );
136 DeleteFile ( ospath );
137 CopyFile ( filename, ospath,
FALSE );
138 SetFileAttributes ( ospath, FILE_ATTRIBUTE_NORMAL );
150 DeleteFile ( ospath );
164 static int MapKey (
int key)
170 modified = ( key >> 16 ) & 255;
172 if ( modified > 127 )
175 if ( key & ( 1 << 24 ) ) {
237 switch ( LOWORD(wParam) )
252 SendMessage ( viewer->
mToolbar, TB_AUTOSIZE, 0, 0 );
253 GetWindowRect ( viewer->
mToolbar, &rToolbar );
275 ZeroMemory ( &event,
sizeof(event) ) ;
278 event.evValue2 =
true;
288 ZeroMemory ( &event,
sizeof(event) ) ;
291 event.evValue2 =
false;
301 ZeroMemory ( &event,
sizeof(event) ) ;
303 event.evValue =
MapKey( lParam );
304 event.evValue2 =
true;
315 ZeroMemory ( &event,
sizeof(event) ) ;
317 event.evValue =
MapKey( lParam );
318 event.evValue2 =
false;
325 if ( wParam == VK_ESCAPE )
327 SendMessage ( hwnd, WM_CLOSE, 0, 0 );
335 ZeroMemory ( &event,
sizeof(event) ) ;
337 event.evValue = wParam;
338 event.evValue2 =
false;
351 ZeroMemory ( &event,
sizeof(event) ) ;
366 CREATESTRUCT* cs = (CREATESTRUCT*) lParam;
367 SetWindowLong ( hwnd, GWL_USERDATA, (
LONG)cs->lpCreateParams );
373 viewer->
mToolbar = CreateWindowEx ( 0, TOOLBARCLASSNAME,
"", CCS_BOTTOM|WS_CHILD|WS_VISIBLE,0,0,0,0, hwnd, (HMENU)
IDR_GUIED_VIEWERTOOLBAR,
gApp.
GetInstance(),
NULL );
376 SendMessage( viewer->
mToolbar, TB_BUTTONSTRUCTSIZE, ( WPARAM )
sizeof( TBBUTTON ), 0 );
378 SendMessage ( viewer->
mToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(16,15) );
380 SendMessage ( viewer->
mToolbar, TB_SETSTYLE, 0, SendMessage ( viewer->
mToolbar, TB_GETSTYLE, 0, 0 ) | TBSTYLE_FLAT );
383 tbmet.cbSize =
sizeof(TBMETRICS);
384 SendMessage ( viewer->
mToolbar, TB_GETMETRICS, 0, (
LPARAM)&tbmet );
387 SendMessage ( viewer->
mToolbar, TB_SETMETRICS, 0, (
LPARAM)&tbmet );
393 SendMessage( viewer->
mToolbar, TB_ADDBITMAP, (WPARAM)4, (
LPARAM) &tbab );
396 tbb[0].fsStyle = BTNS_SEP;
402 tbb[1].fsStyle = BTNS_BUTTON;
408 tbb[2].fsState = TBSTATE_ENABLED;
409 tbb[2].fsStyle = BTNS_BUTTON;
413 tbb[3].fsStyle = BTNS_SEP;
416 SendMessage( viewer->
mToolbar, TB_ADDBUTTONS, (WPARAM)4, (
LPARAM) &tbb );
426 return DefWindowProc ( hwnd, msg, wParam, lParam );
434 dc = BeginPaint (
mWnd, &ps );
438 EndPaint (
mWnd, &ps );
455 int pixelFormat = ChoosePixelFormat(hDC, &
win32.
pfd);
458 if (SetPixelFormat(hDC, pixelFormat, &
win32.
pfd) ==
NULL)
468 ReleaseDC (
mWnd, hDC );
482 common->
Printf(
"Please restart Q3Radiant if the Map view is not working\n");
494 GetClientRect (
mWnd, &rClient );
495 GetClientRect (
mToolbar, &rToolbar );
505 qglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
517 memset ( &viewDef, 0,
sizeof(viewDef) );
549 ReleaseDC (
mWnd, hDC );
virtual void SetStateString(const char *varName, const char *value)
virtual void EndFrame(int *frontEndMsec, int *backEndMsec)=0
assert(prefInfo.fullscreenBtn)
#define IDR_GUIED_VIEWERTOOLBAR
CONST PIXELFORMATDESCRIPTOR UINT
LRESULT HandlePaint(WPARAM wParam, LPARAM lParam)
virtual void Redraw(int time)
void SetWindowPlacement(const char *name, HWND hwnd)
idRenderSystem * renderSystem
virtual const char * Activate(bool activate, int time)
idFileSystem * fileSystem
#define ID_GUIED_VIEWER_PAUSE
bool GetWindowPlacement(const char *name, HWND hwnd)
idUserInterfaceManager * uiManager
virtual void BeginFrame(int windowWidth, int windowHeight)=0
HINSTANCE GetInstance(void)
#define ID_GUIED_VIEWER_START
virtual idUserInterface * FindGui(const char *qpath, bool autoLoad=false, bool needUnique=false, bool forceUnique=false)=0
bool SetupPixelFormat(void)
rvGEOptions & GetOptions(void)
idStr & StripFileExtension(void)
void glLoadIdentity(void)
typedef HDC(WINAPI *PFNWGLGETCURRENTREADDCARBPROC)(void)
virtual void Printf(const char *fmt,...) id_attribute((format(printf
static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
virtual const char * RelativePathToOSPath(const char *relativePath, const char *basePath="fs_devpath")=0
bool OpenFile(const char *filename)
#define ID_GUIED_VIEWER_PLAY
PIXELFORMATDESCRIPTOR pfd
idUserInterfaceLocal * mInterface
virtual const char * HandleEvent(const sysEvent_t *event, int time, bool *updateVisuals)
const unsigned char * Sys_GetScanTable(void)
const char * c_str(void) const
char * va(const char *fmt,...)
void glMatrixMode(GLenum mode)
idStr & StripFilename(void)
virtual void ActivateTool(bool active)=0