hello world

This commit is contained in:
Timothee 'TTimo' Besset
2011-11-22 15:28:15 -06:00
commit fb1609f554
2155 changed files with 1017022 additions and 0 deletions

1384
neo/tools/guied/GEApp.cpp Normal file

File diff suppressed because it is too large Load Diff

191
neo/tools/guied/GEApp.h Normal file
View File

@@ -0,0 +1,191 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GEAPP_H_
#define GEAPP_H_
#include "../../sys/win32/win_local.h"
#include "../../ui/Rectangle.h"
#include "../../ui/Window.h"
#include "../../ui/UserInterfaceLocal.h"
#ifndef GEOPTIONS_H_
#include "GEOptions.h"
#endif // GEOPTIONS_H_
#ifndef GEWINDOWWRAPPER_H_
#include "GEWindowWrapper.h"
#endif // GEWINDOWWRAPPER_H_
#ifndef GEWORKSPACE_H_
#include "GEWorkspace.h"
#endif // GEWORKSPACE_H_
#ifndef GENAVIGATOR_H_
#include "GENavigator.h"
#endif // GENAVIGATOR_H_
#ifndef GEPROPERTIES_H_
#include "GEProperties.h"
#endif // GEPROPERTIES_H_
#ifndef GETRANSFORMER_H_
#include "GETransformer.h"
#endif // GETRANSFORMER_H_
#ifndef GESTATUSBAR_H_
#include "GEStatusBar.h"
#endif // GESTATUSBAR_H_
// Utility functions
const char *StringFromVec4 ( idVec4& vec );
bool IsExpression ( const char* s );
class rvGEViewer;
class rvGEApp
{
public:
rvGEApp ( );
~rvGEApp ( );
bool Initialize ( void );
void RunFrame ( void );
// bool Uninitialize ( void );
bool TranslateAccelerator ( LPMSG msg );
rvGEWorkspace* GetActiveWorkspace ( HWND* retwnd = NULL );
rvGENavigator& GetNavigator ( void );
rvGEProperties& GetProperties ( void );
rvGETransformer& GetTransformer ( void );
rvGEOptions& GetOptions ( void );
HINSTANCE GetInstance ( void );
HWND GetMDIFrame ( void );
HWND GetMDIClient ( void );
rvGEStatusBar& GetStatusBar ( void );
bool OpenFile ( const char* filename );
bool SaveFile ( const char* filename );
bool NewFile ( void );
bool IsActive ( void );
void CloseViewer ( void );
int ToolWindowActivate ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
int MessageBox ( const char* text, int flags );
protected:
int HandleCommand ( WPARAM wParam, LPARAM lParam );
int HandleInitMenu ( WPARAM wParam, LPARAM lParam );
void HandleCommandSave ( rvGEWorkspace* workspace, const char* filename );
bool InitRecentFiles ( void );
void UpdateRecentFiles ( void );
HWND mMDIFrame;
HWND mMDIClient;
HINSTANCE mInstance;
rvGEOptions mOptions;
HACCEL mAccelerators;
rvGENavigator mNavigator;
rvGETransformer mTransformer;
rvGEStatusBar mStatusBar;
rvGEProperties mProperties;
HMENU mRecentFileMenu;
int mRecentFileInsertPos;
rvGEViewer* mViewer;
idList<rvGEWorkspace*> mWorkspaces;
idList<HWND> mToolWindows;
private:
static LRESULT CALLBACK FrameWndProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
static LRESULT CALLBACK MDIChildProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
};
ID_INLINE bool rvGEApp::IsActive ( void )
{
return mMDIFrame ? true : false;
}
ID_INLINE rvGENavigator& rvGEApp::GetNavigator ( void )
{
return mNavigator;
}
ID_INLINE rvGEProperties& rvGEApp::GetProperties ( void )
{
return mProperties;
}
ID_INLINE rvGETransformer& rvGEApp::GetTransformer ( void )
{
return mTransformer;
}
ID_INLINE rvGEOptions& rvGEApp::GetOptions ( void )
{
return mOptions;
}
ID_INLINE HINSTANCE rvGEApp::GetInstance ( void )
{
return mInstance;
}
ID_INLINE rvGEStatusBar& rvGEApp::GetStatusBar ( void )
{
return mStatusBar;
}
ID_INLINE HWND rvGEApp::GetMDIFrame ( void )
{
return mMDIFrame;
}
ID_INLINE HWND rvGEApp::GetMDIClient ( void )
{
return mMDIClient;
}
extern rvGEApp gApp;
#endif // GEAPP_H_

View File

@@ -0,0 +1,114 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/guied_resource.h"
#include "GEApp.h"
typedef struct
{
const char* mFilename;
idStr* mComment;
} GECHECKINDLG;
/*
================
GECheckInDlg_GeneralProc
Dialog procedure for the check in dialog
================
*/
static INT_PTR CALLBACK GECheckInDlg_GeneralProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
GECHECKINDLG* dlg = (GECHECKINDLG*) GetWindowLong ( hwnd, GWL_USERDATA );
switch ( msg )
{
case WM_INITDIALOG:
SetWindowLong ( hwnd, GWL_USERDATA, lParam );
dlg = (GECHECKINDLG*) lParam;
SetWindowText ( GetDlgItem ( hwnd, IDC_GUIED_FILENAME ), dlg->mFilename );
break;
case WM_COMMAND:
switch ( LOWORD ( wParam ) )
{
case IDOK:
{
char* temp;
int tempsize;
tempsize = GetWindowTextLength ( GetDlgItem ( hwnd, IDC_GUIED_COMMENT ) );
temp = new char [ tempsize + 2 ];
GetWindowText ( GetDlgItem ( hwnd, IDC_GUIED_COMMENT ), temp, tempsize + 1 );
*dlg->mComment = temp;
delete[] temp;
EndDialog ( hwnd, 1 );
break;
}
case IDCANCEL:
EndDialog ( hwnd, 0 );
break;
}
break;
}
return FALSE;
}
/*
================
GECheckInDlg_DoModal
Starts the check in dialog
================
*/
bool GECheckInDlg_DoModal ( HWND parent, const char* filename, idStr* comment )
{
GECHECKINDLG dlg;
dlg.mComment = comment;
dlg.mFilename = filename;
if ( !DialogBoxParam ( gApp.GetInstance(), MAKEINTRESOURCE(IDD_GUIED_CHECKIN), parent, GECheckInDlg_GeneralProc, (LPARAM) &dlg ) )
{
return false;
}
return true;
}

View File

@@ -0,0 +1,67 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "GEApp.h"
#include "GEDeleteModifier.h"
rvGEDeleteModifier::rvGEDeleteModifier ( const char* name, idWindow* window ) :
rvGEModifier ( name, window )
{
}
/*
================
rvGEDeleteModifier::Apply
Apply the delete modifier by setting the deleted flag in the wrapper
================
*/
bool rvGEDeleteModifier::Apply ( void )
{
mWrapper->SetDeleted ( true );
return true;
}
/*
================
rvGEDeleteModifier::Undo
Undo the delete modifier by unsetting the deleted flag in the wrapper
================
*/
bool rvGEDeleteModifier::Undo ( void )
{
mWrapper->SetDeleted ( false );
return true;
}

View File

@@ -0,0 +1,45 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GEDELETEMODIFIER_H_
#define GEDELETEMODIFIER_H_
#ifndef GEMODIFIER_H_
#include "GEModifier.h"
#endif
class rvGEDeleteModifier : public rvGEModifier
{
public:
rvGEDeleteModifier ( const char* name, idWindow* window );
virtual bool Apply ( void );
virtual bool Undo ( void );
};
#endif // GEDELETEMODIFIER_H_

View File

@@ -0,0 +1,94 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "GEApp.h"
#include "GEHideModifier.h"
rvGEHideModifier::rvGEHideModifier ( const char* name, idWindow* window, bool hide ) :
rvGEModifier ( name, window )
{
mParent = NULL;
mHide = hide;
mUndoHide = mWrapper->IsHidden ( );
// If unhiding then find any parent window along the way that may be hidden and prevent
// this window from being visible
if ( !hide )
{
mParent = mWindow;
while ( NULL != (mParent = mParent->GetParent ( ) ) )
{
if ( rvGEWindowWrapper::GetWrapper(mParent)->IsHidden ( ) )
{
break;
}
}
}
}
/*
================
rvGEHideModifier::Apply
Apply the hide modifier by setting the visible state of the wrapper window
================
*/
bool rvGEHideModifier::Apply ( void )
{
mWrapper->SetHidden ( mHide );
if ( mParent )
{
rvGEWindowWrapper::GetWrapper ( mParent )->SetHidden ( mHide );
}
return true;
}
/*
================
rvGEHideModifier::Undo
Undo the hide modifier by setting the undo visible state of the wrapper window
================
*/
bool rvGEHideModifier::Undo ( void )
{
mWrapper->SetHidden ( mUndoHide );
if ( mParent )
{
rvGEWindowWrapper::GetWrapper ( mParent )->SetHidden ( mUndoHide );
}
return true;
}

View File

@@ -0,0 +1,51 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GEHIDEMODIFIER_H_
#define GEHIDEMODIFIER_H_
#ifndef GEMODIFIER_H_
#include "GEModifier.h"
#endif
class rvGEHideModifier : public rvGEModifier
{
public:
rvGEHideModifier ( const char* name, idWindow* window, bool hide );
virtual bool Apply ( void );
virtual bool Undo ( void );
protected:
bool mHide;
bool mUndoHide;
idWindow* mParent;
};
#endif // GEHIDEMODIFIER_H_

View File

@@ -0,0 +1,113 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "GEApp.h"
#include "GEInsertModifier.h"
rvGEInsertModifier::rvGEInsertModifier ( const char* name, idWindow* window, idWindow* parent, idWindow* before ) :
rvGEModifier ( name, window )
{
mParent = parent;
mBefore = before;
assert ( mParent );
mUndoParent = window->GetParent ( );
mUndoBefore = NULL;
mUndoRect = mWrapper->GetClientRect ( );
mRect = mWrapper->GetClientRect ( );
// Find the child window the window being inserted is before
if ( mUndoParent )
{
int index;
rvGEWindowWrapper* pwrapper;
pwrapper = rvGEWindowWrapper::GetWrapper ( mUndoParent );
index = mUndoParent->GetChildIndex ( mWindow );
if ( index + 1 < pwrapper->GetChildCount ( ) )
{
mUndoBefore = pwrapper->GetChild ( index + 1 );
}
}
// Since rectangles are relative to the parent rectangle we need to figure
// out the new x and y coordinate as if this window were a child
rvGEWindowWrapper* parentWrapper;
parentWrapper = rvGEWindowWrapper::GetWrapper ( mParent );
mRect.x = mWrapper->GetScreenRect( )[0] - parentWrapper->GetScreenRect()[0];
mRect.y = mWrapper->GetScreenRect( )[1] - parentWrapper->GetScreenRect()[1];
}
/*
================
rvGEInsertModifier::Apply
Apply the insert modifier by removing the child from its original parent and
inserting it as a child of the new parent
================
*/
bool rvGEInsertModifier::Apply ( void )
{
if ( mUndoParent )
{
mUndoParent->RemoveChild ( mWindow );
}
mParent->InsertChild ( mWindow, mBefore );
mWrapper->SetRect ( mRect );
return true;
}
/*
================
rvGEInsertModifier::Undo
Undo the insert modifier by removing the window from the parent it was
added to and re-inserting it back into its original parent
================
*/
bool rvGEInsertModifier::Undo ( void )
{
mParent->RemoveChild ( mWindow );
if ( mUndoParent )
{
mUndoParent->InsertChild ( mWindow, mUndoBefore );
mWrapper->SetRect ( mUndoRect );
}
return true;
}

View File

@@ -0,0 +1,54 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GEINSERTMODIFIER_H_
#define GEINSERTMODIFIER_H_
#ifndef GEMODIFIER_H_
#include "GEModifier.h"
#endif
class rvGEInsertModifier : public rvGEModifier
{
public:
rvGEInsertModifier ( const char* name, idWindow* window, idWindow* parent, idWindow* before );
virtual bool Apply ( void );
virtual bool Undo ( void );
protected:
idWindow* mUndoParent;
idWindow* mUndoBefore;
idWindow* mParent;
idWindow* mBefore;
idRectangle mRect;
idRectangle mUndoRect;
};
#endif // GEINSERTMODIFIER_H_

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,33 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GEITEMPROPSDLG_H_
#define GEITEMPROPSDLG_H_
bool GEItemPropsDlg_DoModal ( HWND parent, idWindow* window, idDict& outDict );
#endif // GEITEMPROPSDLG_H_

View File

@@ -0,0 +1,363 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/guied_resource.h"
#include "GEApp.h"
#include "GEPropertyPage.h"
LRESULT CALLBACK GEScriptEdit_WndProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
WNDPROC wndproc = (WNDPROC) GetWindowLong ( hwnd, GWL_USERDATA );
switch ( msg )
{
case WM_CHAR:
if ( wParam == VK_ESCAPE )
{
SendMessage ( GetParent ( hwnd ), WM_CLOSE, 0, 0 );
}
break;
case WM_GETDLGCODE:
return DLGC_WANTALLKEYS;
}
return CallWindowProc ( wndproc, hwnd, msg, wParam, lParam );
}
bool GEItescriptsDlg_Init ( HWND hwnd )
{
idWindow* window;
rvGEWindowWrapper* wrapper;
HWND script;
// Extract the window pointer from the win32 windows user data long
window = (idWindow*)GetWindowLong ( hwnd, GWL_USERDATA );
assert ( window );
// Get the window wrapper of the script window
wrapper = rvGEWindowWrapper::GetWrapper ( window );
assert ( wrapper );
// Get the edit box used to edit the script
script = GetDlgItem ( hwnd, IDC_GUIED_SCRIPT );
UINT tabsize = 16;
SendMessage ( script, EM_SETTABSTOPS, 1, (LPARAM)&tabsize );
SetWindowLong ( script, GWL_USERDATA, GetWindowLong ( script, GWL_WNDPROC ) );
SetWindowLong ( script, GWL_WNDPROC, (LONG) GEScriptEdit_WndProc );
TEXTMETRIC tm;
HDC dc;
dc = GetDC ( script );
GetTextMetrics ( dc, &tm );
ReleaseDC ( script, dc );
LOGFONT lf;
ZeroMemory ( &lf, sizeof(lf) );
lf.lfHeight = tm.tmHeight;
strcpy ( lf.lfFaceName, "Courier New" );
SendMessage ( script, WM_SETFONT, (WPARAM)CreateFontIndirect ( &lf ), 0 );
SendMessage ( script, EM_SETMARGINS, EC_LEFTMARGIN|EC_RIGHTMARGIN, MAKELONG(10,10) );
int i;
for ( i = 0; i < wrapper->GetVariableDict().GetNumKeyVals ( ); i ++ )
{
const idKeyValue* key = wrapper->GetVariableDict().GetKeyVal ( i );
SendMessage ( script, EM_SETSEL, -1, -1 );
SendMessage ( script, EM_REPLACESEL, FALSE, (LPARAM)key->GetKey().c_str() );
SendMessage ( script, EM_SETSEL, -1, -1 );
SendMessage ( script, EM_REPLACESEL, FALSE, (LPARAM)"\t" );
SendMessage ( script, EM_SETSEL, -1, -1 );
SendMessage ( script, EM_REPLACESEL, FALSE, (LPARAM)key->GetValue().c_str() );
SendMessage ( script, EM_SETSEL, -1, -1 );
SendMessage ( script, EM_REPLACESEL, FALSE, (LPARAM)"\r\n" );
}
if ( i )
{
SendMessage ( script, EM_SETSEL, -1, -1 );
SendMessage ( script, EM_REPLACESEL, FALSE, (LPARAM)"\r\n" );
}
for ( i = 0; i < wrapper->GetScriptDict().GetNumKeyVals ( ); i ++ )
{
const idKeyValue* key = wrapper->GetScriptDict().GetKeyVal ( i );
SendMessage ( script, EM_SETSEL, -1, -1 );
SendMessage ( script, EM_REPLACESEL, FALSE, (LPARAM)va("%s\r\n", key->GetKey().c_str() ) );
SendMessage ( script, EM_SETSEL, -1, -1 );
SendMessage ( script, EM_REPLACESEL, FALSE, (LPARAM)key->GetValue().c_str() );
SendMessage ( script, EM_SETSEL, -1, -1 );
SendMessage ( script, EM_REPLACESEL, FALSE, (LPARAM)"\r\n\r\n" );
}
SendMessage ( script, EM_SETSEL, 0, 0 );
SendMessage ( script, EM_SCROLLCARET, 0, 0 );
return true;
}
bool GEItescriptsDlg_Apply ( HWND hwnd )
{
idWindow* window;
rvGEWindowWrapper* wrapper;
HWND script;
// Extract the window pointer from the win32 windows user data long
window = (idWindow*)GetWindowLong ( hwnd, GWL_USERDATA );
assert ( window );
// Get the window wrapper of the script window
wrapper = rvGEWindowWrapper::GetWrapper ( window );
assert ( wrapper );
// Get the edit box used to edit the script
script = GetDlgItem ( hwnd, IDC_GUIED_SCRIPT );
GETTEXTLENGTHEX textLen;
int chars;
textLen.flags = GTL_DEFAULT|GTL_USECRLF;
textLen.codepage = CP_ACP;
chars = SendMessage ( script, EM_GETTEXTLENGTHEX, (WPARAM)&textLen, 0 );
char* text = new char[chars+1];
GETTEXTEX getText;
getText.cb = chars+1;
getText.codepage = CP_ACP;
getText.flags = GT_DEFAULT|GT_USECRLF;
getText.lpDefaultChar = NULL;
getText.lpUsedDefChar = NULL;
SendMessage ( script, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)text );
idStr parse = text;
delete[] text;
try
{
idParser src ( parse, parse.Length(), "", LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWBACKSLASHSTRINGCONCAT );
idToken token;
wrapper->GetVariableDict().Clear ( );
wrapper->GetScriptDict().Clear ( );
while ( src.ReadToken ( &token ) )
{
idStr scriptName;
idStr out;
if ( !token.Icmp ("definevec4") )
{
idToken token2;
idStr result;
if ( !src.ReadToken ( &token2 ) )
{
src.Error ( "expected define name" );
return false;
}
idWinVec4 var;
idUserInterfaceLocal ui;
idWindow tempwin ( &ui );
idStr out;
int i;
src.SetMarker ( );
for ( i = 0; i < 3; i ++ )
{
tempwin.ParseExpression ( &src, &var );
src.ExpectTokenString(",");
}
tempwin.ParseExpression ( &src, &var );
src.GetStringFromMarker ( out, true );
wrapper->GetVariableDict().Set ( token + "\t\"" + token2 + "\"", out );
continue;
}
else if ( !token.Icmp ( "definefloat" ) || !token.Icmp ( "float" ) )
{
idToken token2;
idStr result;
if ( !src.ReadToken ( &token2 ) )
{
src.Error ( "expected define name" );
return false;
}
idWinFloat var;
idUserInterfaceLocal ui;
idWindow tempwin ( &ui );
idStr out;
src.SetMarker ( );
tempwin.ParseExpression ( &src, &var );
src.GetStringFromMarker ( out, true );
wrapper->GetVariableDict().Set ( token + "\t\"" + token2 + "\"", out );
continue;
}
// If the token is a scriptdef then just parse out the
// braced section and add it to the list. Right now only
// one scriptdef per window is supported
else if ( !token.Icmp ( "scriptdef" ) )
{
scriptName = "scriptDef";
}
else if ( !token.Icmp ( "ontime" ) )
{
if ( !src.ReadToken ( &token ) )
{
src.Error ( "expected time" );
return false;
}
scriptName = "onTime ";
scriptName.Append ( token );
}
else if ( !token.Icmp ( "onevent" ) )
{
if ( !src.ReadToken ( &token ) )
{
src.Error ( "expected time" );
return false;
}
scriptName = "onEvent ";
scriptName.Append ( token );
}
else
{
int i;
for( i = 0; i < idWindow::SCRIPT_COUNT; i ++ )
{
if ( idStr::Icmp ( idWindow::ScriptNames[i], token ) == 0 )
{
scriptName = idWindow::ScriptNames[i];
break;
}
}
if ( i >= idWindow::SCRIPT_COUNT )
{
src.Error ( "expected script name" );
return false;
}
}
if ( !src.ParseBracedSectionExact ( out, 1) )
{
return false;
}
wrapper->GetScriptDict().Set ( scriptName, out );
}
}
catch ( idException &e )
{
MessageBox ( hwnd, e.error, "Script Error", MB_OK|MB_ICONERROR);
return false;
}
return true;
}
INT_PTR CALLBACK GEItescriptsDlg_WndProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch ( msg )
{
case WM_INITDIALOG:
SetWindowLong ( hwnd, GWL_USERDATA, lParam );
GEItescriptsDlg_Init ( hwnd );
gApp.GetOptions().GetWindowPlacement ( "scripts", hwnd );
// Let it fall through so the scripts window gets resized.
case WM_SIZE:
{
RECT rClient;
GetClientRect ( hwnd, &rClient );
MoveWindow ( GetDlgItem ( hwnd, IDC_GUIED_SCRIPT ),
rClient.left, rClient.top,
rClient.right - rClient.left,
rClient.bottom - rClient.top,
FALSE );
break;
}
case WM_ERASEBKGND:
return TRUE;
case WM_CLOSE:
if ( !GEItescriptsDlg_Apply ( hwnd ) )
{
return TRUE;
}
gApp.GetOptions().SetWindowPlacement ( "scripts", hwnd );
EndDialog ( hwnd, 1 );
break;
}
return FALSE;
}
/*
================
GEItemScriptsDlg_DoModal
Starts the item properties dialog
================
*/
bool GEItemScriptsDlg_DoModal ( HWND parent, idWindow* window )
{
LoadLibrary ( "Riched20.dll" );
if ( DialogBoxParam ( gApp.GetInstance(), MAKEINTRESOURCE(IDD_GUIED_SCRIPTS), parent, GEItescriptsDlg_WndProc, (LPARAM) window ) )
{
return true;
}
return false;
}

View File

@@ -0,0 +1,33 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GEITEMSCRIPTSDLG_H_
#define GEITEMSCRIPTSDLG_H_
bool GEItemScriptsDlg_DoModal ( HWND parent, idWindow* window );
#endif // GEITEMSCRIPTSDLG_H_

View File

@@ -0,0 +1,71 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "GEApp.h"
#include "GEKeyValueModifier.h"
rvGEKeyValueModifier::rvGEKeyValueModifier ( const char* name, idWindow* window, const char* key, const char* value ) :
rvGEModifier ( name, window ),
mKey ( key ),
mValue ( value )
{
mUndoValue = mWrapper->GetStateDict().GetString ( mKey );
}
bool rvGEKeyValueModifier::Apply ( void )
{
if ( mValue.Length ( ) )
{
mWrapper->SetStateKey ( mKey, mValue );
}
else
{
mWrapper->DeleteStateKey ( mKey );
}
return true;
}
bool rvGEKeyValueModifier::Undo ( void )
{
mWrapper->SetStateKey ( mKey, mValue );
return true;
}
bool rvGEKeyValueModifier::Merge ( rvGEModifier* mergebase )
{
rvGEKeyValueModifier* merge = (rvGEKeyValueModifier*) mergebase;
mValue = merge->mValue;
return true;
}

View File

@@ -0,0 +1,59 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GEKEYVALUEMODIFIER_H_
#define GEKEYVALUEMODIFIER_H_
#ifndef GEMODIFIER_H_
#include "GEModifier.h"
#endif
class rvGEKeyValueModifier : public rvGEModifier
{
public:
rvGEKeyValueModifier ( const char* name, idWindow* window, const char* key, const char* value );
virtual bool Apply ( void );
virtual bool Undo ( void );
virtual bool CanMerge ( rvGEModifier* merge );
virtual bool Merge ( rvGEModifier* merge );
protected:
idStr mKey;
idStr mValue;
idStr mUndoValue;
};
ID_INLINE bool rvGEKeyValueModifier::CanMerge ( rvGEModifier* merge )
{
return !((rvGEKeyValueModifier*)merge)->mKey.Icmp ( mKey );
}
#endif // GEKEYVALUEMODIFIER_H_

View File

@@ -0,0 +1,44 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "GEApp.h"
rvGEModifier::rvGEModifier ( const char* name, idWindow* window )
{
mWindow = window;
mName = name;
if ( mWindow )
{
mWrapper = rvGEWindowWrapper::GetWrapper ( window );
}
}

View File

@@ -0,0 +1,85 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GEMODIFIER_H_
#define GEMODIFIER_H_
class idWindow;
class rvGEWindowWrapper;
class rvGEModifier
{
public:
rvGEModifier ( const char* name, idWindow* window );
virtual ~rvGEModifier ( ) { }
virtual bool Apply ( void ) = 0;
virtual bool Undo ( void ) = 0;
virtual const char* GetName ( void );
virtual bool CanMerge ( rvGEModifier* merge );
virtual bool IsValid ( void );
virtual bool Merge ( rvGEModifier* merge );
idWindow* GetWindow ( void );
protected:
idWindow* mWindow;
rvGEWindowWrapper* mWrapper;
idStr mName;
};
ID_INLINE bool rvGEModifier::IsValid ( void )
{
return true;
}
ID_INLINE idWindow* rvGEModifier::GetWindow ( void )
{
return mWindow;
}
ID_INLINE const char* rvGEModifier::GetName ( void )
{
return mName;
}
ID_INLINE bool rvGEModifier::CanMerge ( rvGEModifier* merge )
{
return false;
}
ID_INLINE bool rvGEModifier::Merge ( rvGEModifier* merge )
{
return false;
}
#endif // GEMODIFIER_H_

View File

@@ -0,0 +1,148 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "GEModifierGroup.h"
rvGEModifierGroup::rvGEModifierGroup ( ) :
rvGEModifier ( "Group", NULL )
{
}
rvGEModifierGroup::~rvGEModifierGroup ( )
{
int i;
for ( i = 0; i < mModifiers.Num(); i ++ )
{
delete mModifiers[i];
}
mModifiers.Clear ( );
}
bool rvGEModifierGroup::Append ( rvGEModifier* mod )
{
// All modifiers must be the same type
assert ( !mModifiers.Num() || !idStr::Icmp ( mod->GetName ( ), mModifiers[0]->GetName ( ) ) );
if ( !mModifiers.Num ( ) )
{
mName = mod->GetName ( );
}
mModifiers.Append ( mod );
return true;
}
bool rvGEModifierGroup::IsValid ( void )
{
int i;
for ( i = 0; i < mModifiers.Num(); i ++ )
{
if ( !mModifiers[i]->IsValid ( ) )
{
return false;
}
}
return true;
}
bool rvGEModifierGroup::Apply ( void )
{
int i;
for ( i = 0; i < mModifiers.Num(); i ++ )
{
mModifiers[i]->Apply ( );
}
return true;
}
bool rvGEModifierGroup::Undo ( void )
{
int i;
for ( i = 0; i < mModifiers.Num(); i ++ )
{
mModifiers[i]->Undo ( );
}
return true;
}
bool rvGEModifierGroup::CanMerge ( rvGEModifier* mergebase )
{
rvGEModifierGroup* merge = (rvGEModifierGroup*) mergebase;
int i;
if ( mModifiers.Num() != merge->mModifiers.Num ( ) )
{
return false;
}
// Double check the merge is possible
for ( i = 0; i < mModifiers.Num(); i ++ )
{
if ( mModifiers[i]->GetWindow() != merge->mModifiers[i]->GetWindow() )
{
return false;
}
if ( idStr::Icmp ( mModifiers[i]->GetName ( ), merge->mModifiers[i]->GetName ( ) ) )
{
return false;
}
if ( !mModifiers[i]->CanMerge ( merge->mModifiers[i] ) )
{
return false;
}
}
return true;
}
bool rvGEModifierGroup::Merge ( rvGEModifier* mergebase )
{
rvGEModifierGroup* merge = (rvGEModifierGroup*) mergebase;
int i;
// Double check the merge is possible
for ( i = 0; i < mModifiers.Num(); i ++ )
{
mModifiers[i]->Merge ( merge->mModifiers[i] );
}
return true;
}

View File

@@ -0,0 +1,66 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GEMODIFIERGROUP_H_
#define GEMODIFIERGROUP_H_
#ifndef GEMODIFIER_H_
#include "GEModifier.h"
#endif
class rvGEModifierGroup : public rvGEModifier
{
public:
rvGEModifierGroup ( );
~rvGEModifierGroup ( );
virtual bool Apply ( void );
virtual bool Undo ( void );
virtual bool CanMerge ( rvGEModifier* merge );
virtual bool Merge ( rvGEModifier* merge );
virtual bool IsValid ( void );
bool Append ( rvGEModifier* mod );
int GetCount ( void );
protected:
idList<rvGEModifier*> mModifiers;
};
ID_INLINE int rvGEModifierGroup::GetCount( void )
{
return mModifiers.Num ( );
}
#endif

View File

@@ -0,0 +1,137 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "GEApp.h"
#include "GEModifierStack.h"
rvGEModifierStack::rvGEModifierStack ( )
{
mCurrentModifier = -1;
}
rvGEModifierStack::~rvGEModifierStack ( )
{
Reset ( );
}
void rvGEModifierStack::Reset ( void )
{
int i;
for ( i = 0; i < mModifiers.Num ( ); i ++ )
{
delete mModifiers[i];
}
mModifiers.Clear ( );
}
bool rvGEModifierStack::Append ( rvGEModifier* modifier )
{
// TODO: Add the modifier and clear all redo modifiers
if ( !modifier->IsValid ( ) )
{
delete modifier;
return false;
}
while ( mCurrentModifier < mModifiers.Num ( ) - 1 )
{
delete mModifiers[mModifiers.Num()-1];
mModifiers.RemoveIndex ( mModifiers.Num()-1 );
}
if ( !mMergeBlock && mModifiers.Num ( ) )
{
rvGEModifier* top = mModifiers[mModifiers.Num()-1];
// See if the two modifiers can merge
if ( top->GetWindow() == modifier->GetWindow() &&
!idStr::Icmp ( top->GetName ( ), modifier->GetName ( ) ) &&
top->CanMerge ( modifier ) )
{
// Merge the two modifiers
if ( top->Merge ( modifier ) )
{
top->Apply ( );
gApp.GetProperties().Update ( );
gApp.GetTransformer().Update ( );
delete modifier;
return true;
}
}
}
mModifiers.Append ( modifier );
mCurrentModifier = mModifiers.Num ( ) - 1;
modifier->Apply ( );
mMergeBlock = false;
gApp.GetProperties().Update ( );
gApp.GetTransformer().Update ( );
return true;
}
bool rvGEModifierStack::Undo ( void )
{
if ( mCurrentModifier < 0 )
{
return false;
}
mModifiers[mCurrentModifier]->Undo ( );
mCurrentModifier--;
gApp.GetProperties().Update ( );
gApp.GetTransformer().Update ( );
return true;
}
bool rvGEModifierStack::Redo ( void )
{
if ( mCurrentModifier + 1 < mModifiers.Num ( ) )
{
mCurrentModifier++;
mModifiers[mCurrentModifier]->Apply ( );
}
gApp.GetProperties().Update ( );
gApp.GetTransformer().Update ( );
return true;
}

View File

@@ -0,0 +1,90 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GEMODIFIERSTACK_H_
#define GEMODIFIERSTACK_H_
#ifndef GEMODIFIER_H_
#include "GEModifier.h"
#endif
class rvGEModifierStack
{
public:
rvGEModifierStack ( );
~rvGEModifierStack ( );
void BlockNextMerge ( void );
bool Append ( rvGEModifier* modifier );
bool Undo ( void );
bool Redo ( void );
void Reset ( void );
bool CanUndo ( void );
bool CanRedo ( void );
rvGEModifier* GetUndoModifier ( void );
rvGEModifier* GetRedoModifier ( void );
protected:
idList<rvGEModifier*> mModifiers;
int mCurrentModifier;
bool mMergeBlock;
};
ID_INLINE bool rvGEModifierStack::CanRedo ( void )
{
return mCurrentModifier < mModifiers.Num()-1;
}
ID_INLINE bool rvGEModifierStack::CanUndo ( void )
{
return mCurrentModifier >= 0;
}
ID_INLINE void rvGEModifierStack::BlockNextMerge ( void )
{
mMergeBlock = true;
}
ID_INLINE rvGEModifier* rvGEModifierStack::GetUndoModifier ( void )
{
assert ( CanUndo ( ) );
return mModifiers[mCurrentModifier];
}
ID_INLINE rvGEModifier* rvGEModifierStack::GetRedoModifier ( void )
{
assert ( CanRedo ( ) );
return mModifiers[mCurrentModifier+1];
}
#endif

View File

@@ -0,0 +1,77 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "GEApp.h"
#include "GEMoveModifier.h"
rvGEMoveModifier::rvGEMoveModifier ( const char* name, idWindow* window, float x, float y ) :
rvGEModifier ( name, window )
{
mOldRect = mWrapper->GetClientRect ( );
mNewRect[0] = mOldRect[0] + x;
mNewRect[1] = mOldRect[1] + y;
mNewRect[2] = mOldRect[2];
mNewRect[3] = mOldRect[3];
}
bool rvGEMoveModifier::Merge ( rvGEModifier* mergebase )
{
rvGEMoveModifier* merge = (rvGEMoveModifier*) mergebase;
mNewRect = merge->mNewRect;
return true;
}
bool rvGEMoveModifier::Apply ( void )
{
mWrapper->SetRect ( mNewRect );
return true;
}
bool rvGEMoveModifier::Undo ( void )
{
mWrapper->SetRect ( mOldRect );
return true;
}
bool rvGEMoveModifier::IsValid ( void )
{
if ( !mWindow->GetParent ( ) )
{
return false;
}
return true;
}

View File

@@ -0,0 +1,56 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GEMOVEMODIFIER_H_
#define GEMOVEMODIFIER_H_
class rvGEMoveModifier : public rvGEModifier
{
public:
rvGEMoveModifier ( const char* name, idWindow* window, float x, float y );
virtual bool CanMerge ( rvGEModifier* merge );
virtual bool Merge ( rvGEModifier* merge );
virtual bool Apply ( void );
virtual bool Undo ( void );
virtual bool IsValid ( void );
protected:
idRectangle mNewRect;
idRectangle mOldRect;
};
ID_INLINE bool rvGEMoveModifier::CanMerge ( rvGEModifier* merge )
{
return true;
}
#endif // GEMOVEMODIFIER_H_

View File

@@ -0,0 +1,596 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/guied_resource.h"
#include "GEApp.h"
#define GENAV_ITEMHEIGHT 22
rvGENavigator::rvGENavigator ( )
{
mWnd = NULL;
mWorkspace = NULL;
mVisibleIcon = NULL;
mScriptsIcon = NULL;
mVisibleIconDisabled = NULL;
mScriptsLightIcon = NULL;
}
/*
================
rvGENavigator::Create
Creates the navigator window
================
*/
bool rvGENavigator::Create ( HWND parent, bool visible )
{
WNDCLASSEX wndClass;
memset ( &wndClass, 0, sizeof(wndClass) );
wndClass.cbSize = sizeof(WNDCLASSEX);
wndClass.lpszClassName = "GUIEDITOR_NAVIGATOR_CLASS";
wndClass.lpfnWndProc = rvGENavigator::WndProc;
wndClass.hbrBackground = (HBRUSH)GetStockObject( LTGRAY_BRUSH );;
wndClass.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW);
wndClass.lpszMenuName = NULL;
wndClass.hInstance = win32.hInstance;
RegisterClassEx ( &wndClass );
mVisibleIcon = (HICON)LoadImage ( win32.hInstance, MAKEINTRESOURCE(IDI_GUIED_NAV_VISIBLE), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR|LR_LOADMAP3DCOLORS );
mScriptsIcon = (HICON)LoadImage ( win32.hInstance, MAKEINTRESOURCE(IDI_GUIED_NAV_SCRIPTS), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR );
mScriptsLightIcon = (HICON)LoadImage ( win32.hInstance, MAKEINTRESOURCE(IDI_GUIED_NAV_SCRIPTSHI), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR );
mVisibleIconDisabled = (HICON)LoadImage ( win32.hInstance, MAKEINTRESOURCE(IDI_GUIED_NAV_VISIBLEDISABLED), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR|LR_LOADMAP3DCOLORS );
mExpandIcon = (HICON)LoadImage ( win32.hInstance, MAKEINTRESOURCE(IDI_GUIED_NAV_EXPAND), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR|LR_LOADMAP3DCOLORS );
mCollapseIcon = (HICON)LoadImage ( win32.hInstance, MAKEINTRESOURCE(IDI_GUIED_NAV_COLLAPSE), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR|LR_LOADMAP3DCOLORS );
mWnd = CreateWindowEx ( WS_EX_TOOLWINDOW,
"GUIEDITOR_NAVIGATOR_CLASS",
"Navigator",
WS_SYSMENU|WS_THICKFRAME|WS_CAPTION|WS_POPUP|WS_OVERLAPPED|WS_BORDER|WS_CLIPSIBLINGS|WS_CHILD,
0, 0, 200,300,
parent,
NULL,
win32.hInstance,
this );
if ( !mWnd )
{
return false;
}
if ( !gApp.GetOptions().GetWindowPlacement ( "navigator", mWnd ) )
{
RECT rParent;
RECT rNav;
GetWindowRect ( parent, &rParent );
GetWindowRect ( mWnd, &rNav );
SetWindowPos ( mWnd, NULL,
rParent.right - 10 - (rNav.right-rNav.left),
rParent.bottom - 10 - (rNav.bottom-rNav.top),
0,0,
SWP_NOZORDER|SWP_NOSIZE );
}
Show ( visible );
return true;
}
/*
================
Draw3dRect
Draws a 3d rectangle using the given brushes
================
*/
void Draw3dRect ( HDC hDC, RECT* rect, HBRUSH topLeft, HBRUSH bottomRight )
{
RECT rOut;
SetRect ( &rOut, rect->left, rect->top, rect->right - 1, rect->top + 1 );
FillRect ( hDC,&rOut, topLeft );
SetRect ( &rOut, rect->left, rect->top, rect->left + 1, rect->bottom );
FillRect( hDC,&rOut, topLeft );
SetRect ( &rOut, rect->right, rect->top, rect->right -1, rect->bottom );
FillRect( hDC,&rOut, bottomRight );
SetRect ( &rOut, rect->left, rect->bottom, rect->right, rect->bottom - 1 );
FillRect( hDC,&rOut, bottomRight );
}
/*
================
rvGENavigator::WndProc
Window Procedure
================
*/
LRESULT CALLBACK rvGENavigator::WndProc ( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
rvGENavigator* nav = (rvGENavigator*) GetWindowLong ( hWnd, GWL_USERDATA );
switch ( msg )
{
case WM_INITMENUPOPUP:
return SendMessage ( gApp.GetMDIFrame ( ), msg, wParam, lParam );
case WM_ACTIVATE:
common->ActivateTool( LOWORD( wParam ) != WA_INACTIVE );
break;
case WM_ERASEBKGND:
return TRUE;
case WM_DESTROY:
gApp.GetOptions().SetWindowPlacement ( "navigator", hWnd );
break;
case WM_CLOSE:
gApp.GetOptions().SetNavigatorVisible ( false );
nav->Show ( false );
return 0;
case WM_DRAWITEM:
{
DRAWITEMSTRUCT* dis = (DRAWITEMSTRUCT*) lParam;
idWindow* window = (idWindow*)dis->itemData;
if ( window )
{
rvGEWindowWrapper* wrapper = rvGEWindowWrapper::GetWrapper ( window );
idStr name = window->GetName();
RECT rDraw;
float offset;
bool disabled;
idWindow* parent = window;
offset = 1;
disabled = false;
while ( parent = parent->GetParent ( ) )
{
if ( rvGEWindowWrapper::GetWrapper ( parent )->IsHidden ( ) )
{
disabled = true;
}
offset += 10;
}
CopyRect ( &rDraw, &dis->rcItem );
rDraw.right = rDraw.left + GENAV_ITEMHEIGHT;
rDraw.top ++;
rDraw.right ++;
FrameRect ( dis->hDC, &rDraw, (HBRUSH)GetStockObject ( BLACK_BRUSH ) );
rDraw.right --;
FillRect ( dis->hDC, &rDraw, GetSysColorBrush ( COLOR_3DFACE ) );
Draw3dRect ( dis->hDC, &rDraw, GetSysColorBrush ( COLOR_3DHILIGHT ), GetSysColorBrush ( COLOR_3DSHADOW ) );
InflateRect ( &rDraw, -3, -3 );
Draw3dRect ( dis->hDC, &rDraw, GetSysColorBrush ( COLOR_3DSHADOW ), GetSysColorBrush ( COLOR_3DHILIGHT ) );
if ( !wrapper->IsHidden ( ) )
{
DrawIconEx ( dis->hDC, rDraw.left, rDraw.top, disabled?nav->mVisibleIconDisabled:nav->mVisibleIcon, 16, 16,0, NULL, DI_NORMAL );
}
CopyRect ( &rDraw, &dis->rcItem );
rDraw.left += GENAV_ITEMHEIGHT;
rDraw.left += 1;
if ( dis->itemState & ODS_SELECTED )
{
FillRect ( dis->hDC, &rDraw, GetSysColorBrush ( COLOR_HIGHLIGHT ) );
}
else
{
FillRect ( dis->hDC, &rDraw, GetSysColorBrush ( COLOR_WINDOW ) );
}
if ( wrapper->CanHaveChildren ( ) && window->GetChildCount ( ) )
{
if ( wrapper->IsExpanded ( ) )
{
DrawIconEx ( dis->hDC, rDraw.left + offset, rDraw.top + 3, nav->mCollapseIcon, 16, 16,0, NULL, DI_NORMAL );
}
else
{
DrawIconEx ( dis->hDC, rDraw.left + offset, rDraw.top + 3, nav->mExpandIcon, 16, 16,0, NULL, DI_NORMAL );
}
}
HPEN pen = CreatePen ( PS_SOLID, 1, GetSysColor ( COLOR_3DSHADOW ) );
HPEN oldpen = (HPEN)SelectObject ( dis->hDC, pen );
MoveToEx ( dis->hDC, rDraw.left, dis->rcItem.top, NULL );
LineTo ( dis->hDC, dis->rcItem.right, dis->rcItem.top );
MoveToEx ( dis->hDC, rDraw.left, dis->rcItem.bottom, NULL );
LineTo ( dis->hDC, dis->rcItem.right, dis->rcItem.bottom);
SelectObject ( dis->hDC, oldpen );
DeleteObject ( pen );
rDraw.left += offset;
rDraw.left += 20;
int colorIndex = ( (dis->itemState & ODS_SELECTED ) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT );
SetTextColor ( dis->hDC, GetSysColor ( colorIndex ) );
DrawText ( dis->hDC, name, name.Length(), &rDraw, DT_LEFT|DT_VCENTER|DT_SINGLELINE );
if ( wrapper->GetVariableDict().GetNumKeyVals ( ) || wrapper->GetScriptDict().GetNumKeyVals ( ) )
{
DrawIconEx ( dis->hDC, dis->rcItem.right - 16, (dis->rcItem.bottom+dis->rcItem.top)/2-6, (dis->itemState & ODS_SELECTED)?nav->mScriptsLightIcon:nav->mScriptsIcon, 13, 13,0, NULL, DI_NORMAL );
}
}
break;
}
case WM_MEASUREITEM:
{
MEASUREITEMSTRUCT* mis = (MEASUREITEMSTRUCT*) lParam;
mis->itemHeight = 22;
break;
}
case WM_CREATE:
{
LPCREATESTRUCT cs;
LVCOLUMN col;
// Attach the class to the window first
cs = (LPCREATESTRUCT) lParam;
nav = (rvGENavigator*) cs->lpCreateParams;
SetWindowLong ( hWnd, GWL_USERDATA, (LONG)nav );
// Create the List view
nav->mTree = CreateWindowEx ( 0, "SysListView32", "", WS_VSCROLL|WS_CHILD|WS_VISIBLE|LVS_REPORT|LVS_OWNERDRAWFIXED|LVS_NOCOLUMNHEADER|LVS_SHOWSELALWAYS, 0, 0, 0, 0, hWnd, (HMENU)IDC_GUIED_WINDOWTREE, win32.hInstance, 0 );
ListView_SetExtendedListViewStyle ( nav->mTree, LVS_EX_FULLROWSELECT );
ListView_SetBkColor ( nav->mTree, GetSysColor ( COLOR_3DFACE ) );
ListView_SetTextBkColor ( nav->mTree, GetSysColor ( COLOR_3DFACE ) );
nav->mListWndProc = (WNDPROC)GetWindowLong ( nav->mTree, GWL_WNDPROC );
SetWindowLong ( nav->mTree, GWL_USERDATA, (LONG)nav );
SetWindowLong ( nav->mTree, GWL_WNDPROC, (LONG)ListWndProc );
// Insert the only column
col.mask = 0;
ListView_InsertColumn ( nav->mTree, 0, &col );
break;
}
case WM_SIZE:
{
RECT rClient;
MoveWindow ( nav->mTree, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE );
GetClientRect ( nav->mTree, &rClient );
ListView_SetColumnWidth ( nav->mTree, 0, rClient.right-rClient.left-1 );
break;
}
case WM_NCACTIVATE:
return gApp.ToolWindowActivate ( gApp.GetMDIFrame(), msg, wParam, lParam );
case WM_NOTIFY:
{
LPNMHDR nh;
nh = (LPNMHDR) lParam;
switch ( nh->code )
{
case NM_CLICK:
case NM_DBLCLK:
{
DWORD dwpos = GetMessagePos();
LVHITTESTINFO info;
info.pt.x = LOWORD(dwpos);
info.pt.y = HIWORD(dwpos);
MapWindowPoints(HWND_DESKTOP, nh->hwndFrom, &info.pt, 1);
int index = ListView_HitTest ( nav->mTree, &info );
if ( index != -1 )
{
RECT rItem;
int offset;
ListView_GetItemRect ( nav->mTree, index, &rItem, LVIR_BOUNDS );
LVITEM item;
item.mask = LVIF_PARAM;
item.iItem = index;
ListView_GetItem ( nav->mTree, &item );
idWindow* window = (idWindow*)item.lParam;
rvGEWindowWrapper* wrapper = rvGEWindowWrapper::GetWrapper(window);
offset = wrapper->GetDepth ( ) * 10 + 1;
if ( info.pt.x < GENAV_ITEMHEIGHT )
{
if ( !rvGEWindowWrapper::GetWrapper(window)->IsHidden ( ) )
{
nav->mWorkspace->HideWindow ( window );
}
else
{
nav->mWorkspace->UnhideWindow ( window );
}
}
else if ( info.pt.x > GENAV_ITEMHEIGHT + offset && info.pt.x < GENAV_ITEMHEIGHT + offset + 16 )
{
if ( wrapper->CanHaveChildren ( ) && window->GetChildCount ( ) )
{
if ( wrapper->IsExpanded ( ) )
{
wrapper->Collapse ( );
nav->Update ( );
}
else
{
wrapper->Expand ( );
nav->Update ( );
}
}
}
else if ( nh->code == NM_DBLCLK )
{
SendMessage ( gApp.GetMDIFrame ( ), WM_COMMAND, MAKELONG(ID_GUIED_ITEM_PROPERTIES,0), 0 );
}
}
break;
}
case NM_RCLICK:
{
DWORD dwpos = GetMessagePos();
LVHITTESTINFO info;
info.pt.x = LOWORD(dwpos);
info.pt.y = HIWORD(dwpos);
MapWindowPoints(HWND_DESKTOP, nh->hwndFrom, &info.pt, 1);
int index = ListView_HitTest ( nav->mTree, &info );
if ( index != -1 )
{
ClientToScreen ( hWnd, &info.pt );
HMENU menu = GetSubMenu ( LoadMenu ( gApp.GetInstance(), MAKEINTRESOURCE(IDR_GUIED_ITEM_POPUP) ), 0 );
TrackPopupMenu ( menu, TPM_RIGHTBUTTON|TPM_LEFTALIGN, info.pt.x, info.pt.y, 0, gApp.GetMDIFrame ( ), NULL );
DestroyMenu ( menu );
}
break;
}
case LVN_ITEMCHANGED:
{
NMLISTVIEW* nml = (NMLISTVIEW*) nh;
if ( (nml->uNewState & LVIS_SELECTED) != (nml->uOldState & LVIS_SELECTED) )
{
LVITEM item;
item.iItem = nml->iItem;
item.mask = LVIF_PARAM;
ListView_GetItem ( nav->mTree, &item );
if ( nml->uNewState & LVIS_SELECTED )
{
nav->mWorkspace->GetSelectionMgr().Add ( (idWindow*)item.lParam, false );
}
else
{
nav->mWorkspace->GetSelectionMgr().Remove ( (idWindow*)item.lParam );
}
}
break;
}
}
break;
}
}
return DefWindowProc ( hWnd, msg, wParam, lParam );
}
/*
================
rvGENavigator::ListWndProc
Window Procedure for the embedded list control
================
*/
LRESULT CALLBACK rvGENavigator::ListWndProc ( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
rvGENavigator* nav = (rvGENavigator*) GetWindowLong ( hWnd, GWL_USERDATA );
assert ( nav );
switch ( msg )
{
case WM_KEYDOWN:
case WM_KEYUP:
case WM_CHAR:
if ( nav->mWorkspace )
{
return SendMessage ( nav->mWorkspace->GetWindow(), msg, wParam, lParam );
}
break;
}
return CallWindowProc ( nav->mListWndProc, hWnd, msg, wParam, lParam );
}
/*
================
rvGENavigator::AddWindow
Adds a new window to the navigator
================
*/
void rvGENavigator::AddWindow ( idWindow* window )
{
int index;
LVITEM item;
rvGEWindowWrapper* wrapper;
wrapper = rvGEWindowWrapper::GetWrapper ( window );
// Dont add deleted windows
if ( !wrapper || wrapper->IsDeleted ( ) )
{
return;
}
// Insert the window into the tree
ZeroMemory ( &item, sizeof(item) );
item.mask = LVIF_PARAM|LVIF_STATE|LVIF_IMAGE;
item.iItem = ListView_GetItemCount ( mTree );
item.lParam = (LONG) window;
item.iImage = 0;
item.state = rvGEWindowWrapper::GetWrapper(window)->IsSelected ()? LVIS_SELECTED:0;
item.stateMask = LVIS_SELECTED;
ListView_InsertItem ( mTree, &item );
if ( item.state & LVIS_SELECTED )
{
ListView_EnsureVisible ( mTree, item.iItem, false );
}
// Dont continue if not expanded.
if ( !wrapper->IsExpanded ( ) )
{
return;
}
// Insert all the child windows into the tree
for ( index = 0; index < wrapper->GetChildCount(); index ++ )
{
AddWindow ( wrapper->GetChild(index) );
}
}
/*
================
rvGENavigator::SetWorkspace
Sets a new workspace for the navigator window
================
*/
void rvGENavigator::SetWorkspace ( rvGEWorkspace* workspace )
{
mWorkspace = workspace;
Update ( );
}
/*
================
rvGENavigator::Update
Updates the contents of the navigator window from the current workspace
================
*/
void rvGENavigator::Update ( void )
{
// Clear the list first
ListView_DeleteAllItems ( mTree );
// Add starting with the desktop window
if ( mWorkspace )
{
AddWindow ( mWorkspace->GetInterface ( )->GetDesktop ( ) );
}
// For some reason the horizontal scrollbar wants to show up initially after an update
// so this forces it not to
RECT rClient;
GetClientRect ( mTree, &rClient );
ListView_SetColumnWidth ( mTree, 0, rClient.right-rClient.left-1 );
}
/*
================
rvGENavigator::UpdateSelection
Updates the currently selected items
================
*/
void rvGENavigator::UpdateSelections ( void )
{
int count = ListView_GetItemCount ( mTree );
int i;
for ( i = 0; i < count; i++ )
{
LVITEM item;
idWindow* window;
rvGEWindowWrapper* wrapper;
item.iItem = i;
item.mask = LVIF_PARAM;
ListView_GetItem ( mTree, &item );
window = (idWindow*) item.lParam;
wrapper = rvGEWindowWrapper::GetWrapper ( window );
ListView_SetItemState ( mTree, i, wrapper->IsSelected ( )?LVIS_SELECTED:0, LVIS_SELECTED );
if ( wrapper->IsSelected ( ) )
{
ListView_EnsureVisible ( mTree, i, false );
}
}
}
/*
================
rvGENavigator::Refresh
Repaints the navigator window
================
*/
void rvGENavigator::Refresh ( void )
{
InvalidateRect ( mTree, NULL, FALSE );
// UpdateWindow ( mTree );
}
/*
================
rvGENavigator::Show
Shows and hides the navigator window
================
*/
void rvGENavigator::Show ( bool visible )
{
gApp.GetOptions().SetNavigatorVisible ( visible );
ShowWindow ( mWnd, visible?SW_SHOW:SW_HIDE );
}

View File

@@ -0,0 +1,77 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GENAVIGATOR_H_
#define GENAVIGATOR_H_
class rvGEWorkspace;
class idWindow;
class rvGENavigator
{
public:
rvGENavigator ( );
bool Create ( HWND parent, bool visible );
void Show ( bool visibile );
void Refresh ( void );
void SetWorkspace ( rvGEWorkspace* workspace );
void Update ( void );
void UpdateSelections ( void );
HWND GetWindow ( void );
protected:
void AddWindow ( idWindow* window );
static LRESULT CALLBACK WndProc ( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
static LRESULT CALLBACK ListWndProc ( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
static LRESULT FAR PASCAL GetMsgProc ( int nCode, WPARAM wParam, LPARAM lParam );
HWND mWnd;
HWND mTree;
HICON mVisibleIcon;
HICON mVisibleIconDisabled;
HICON mScriptsIcon;
HICON mScriptsLightIcon;
HICON mCollapseIcon;
HICON mExpandIcon;
rvGEWorkspace* mWorkspace;
WNDPROC mListWndProc;
};
ID_INLINE HWND rvGENavigator::GetWindow ( void )
{
return mWnd;
}
#endif // GENAVIGATOR_H_

View File

@@ -0,0 +1,190 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../ui/Window.h"
#include "../../ui/UserInterfaceLocal.h"
#include "GEOptions.h"
rvGEOptions::rvGEOptions() {
// Grid options
mGridColor.Set ( 0.2f, 0.2f, 1.0f, 1.0f );
mGridWidth = 10;
mGridHeight = 10;
mGridSnap = false;
mGridVisible = false;
mNavigatorVisible = true;
mTransformerVisible = true;
mIgnoreDesktopSelect = true;
mStatusBarVisible = true;
mPropertiesVisible = true;
mWorkspaceColor.Set ( 0.0f, 0.0f, 0.0f, 1.0f );
mSelectionColor.Set ( 0.5f, 0.5f, 1.0f, 1.0f );
memset ( mCustomColors, 0, sizeof(mCustomColors) );
}
/*
================
rvGEOptions::Init
================
*/
void rvGEOptions::Init( void ) {
mRegistry.Init( "Software\\id Software\\DOOM3\\Tools\\GUIEditor" );
}
/*
================
rvGEOptions::Save
Writes the options to the registry so they can later be read using the Load method
================
*/
bool rvGEOptions::Save ( void )
{
// Write the last page we visited
mRegistry.SetLong ( "lastOptionsPage", mLastOptionsPage );
// Write the grid settings
mRegistry.SetVec4 ( "gridColor", idVec4(mGridColor[0],mGridColor[1],mGridColor[2],1.0f) );
mRegistry.SetLong ( "gridWidth", mGridWidth );
mRegistry.SetLong ( "gridHeight", mGridHeight );
mRegistry.SetBool ( "gridSnap", mGridSnap );
mRegistry.SetBool ( "gridVisible", mGridVisible );
// Tool window states
mRegistry.SetBool ( "navigatorVisible", mNavigatorVisible );
mRegistry.SetBool ( "PropertiesVisible", mPropertiesVisible );
mRegistry.SetBool ( "transformerVisible", mTransformerVisible );
mRegistry.SetBool ( "statusBarVisible", mStatusBarVisible );
// General stuff
mRegistry.SetVec4 ( "selectionColor", mSelectionColor );
mRegistry.SetBool ( "ignoreDesktopSelect", mIgnoreDesktopSelect );
// Custom colors
int i;
for ( i = 0; i < 16; i ++ )
{
mRegistry.SetLong ( va("customcol%d",i), mCustomColors[i] );
}
return mRegistry.Save ( );
}
/*
================
rvGEOptions::Load
Loads previsouly saved options from the registry
================
*/
bool rvGEOptions::Load ( void )
{
if ( !mRegistry.Load ( ) )
{
return false;
}
// Read the general stuff
mLastOptionsPage = mRegistry.GetLong ( "lastOptionsPage" );
// Read the grid settings
mGridColor = mRegistry.GetVec4 ( "gridColor" );
mGridWidth = mRegistry.GetLong ( "gridWidth" );
mGridHeight = mRegistry.GetLong ( "gridHeight" );
mGridSnap = mRegistry.GetBool ( "gridSnap" );
mGridVisible = mRegistry.GetBool ( "gridVisible" );
// Tool window states
mNavigatorVisible = mRegistry.GetBool ( "navigatorVisible" );
mPropertiesVisible = mRegistry.GetBool ( "PropertiesVisible" );
mTransformerVisible = mRegistry.GetBool ( "transformerVisible" );
mStatusBarVisible = mRegistry.GetBool ( "statusBarVisible" );
// General stuff
mSelectionColor = mRegistry.GetVec4 ( "selectionColor" );
mIgnoreDesktopSelect = mRegistry.GetBool ( "ignoreDesktopSelect" );
// Custom colors
int i;
for ( i = 0; i < 16; i ++ )
{
mCustomColors[i] = mRegistry.GetLong ( va("customcol%d",i) );
}
return true;
}
/*
================
rvGEOptions::SnapRectToGrid
Snap the rectangle to the grid
================
*/
void rvGEOptions::SnapRectToGrid ( idRectangle& rect, bool snapLeft, bool snapTop, bool snapWidth, bool snapHeight )
{
if ( snapLeft )
{
float offset = (int)(rect.x + GetGridWidth() / 2) / GetGridWidth() * GetGridWidth();
offset -= rect.x;
rect.x += offset;
rect.w -= offset;
}
if ( snapWidth )
{
float offset = (int)(rect.x + rect.w + GetGridWidth() / 2) / GetGridWidth() * GetGridWidth();
offset -= rect.x;
offset -= rect.w;
rect.w += offset;
}
if ( snapTop )
{
float offset = (int)(rect.y + GetGridHeight() / 2) / GetGridHeight() * GetGridHeight();
offset -= rect.y;
rect.y += offset;
rect.h -= offset;
}
if ( snapHeight )
{
float offset = (int)(rect.y + rect.h + GetGridHeight() / 2) / GetGridHeight() * GetGridHeight();
offset -= rect.y;
offset -= rect.h;
rect.h += offset;
}
}

314
neo/tools/guied/GEOptions.h Normal file
View File

@@ -0,0 +1,314 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GEOPTIONS_H_
#define GEOPTIONS_H_
#ifndef REGISTRYOPTIONS_H_
#include "../common/registryoptions.h"
#endif
class idRectangle;
class rvGEOptions
{
public:
static const int MAX_MRU_SIZE = rvRegistryOptions::MAX_MRU_SIZE;
rvGEOptions();
void Init( void );
// Write the options to the registery
bool Save ( void );
// Read the options from the registry
bool Load ( void );
void SetSelectionColor ( idVec4& color );
void SetSelectionColor ( COLORREF color );
void SetGridColor ( idVec4& color );
void SetGridColor ( COLORREF color );
void SetGridWidth ( int width );
void SetGridHeight ( int height );
void SetGridVisible ( bool vis );
void SetGridSnap ( bool snap );
void SetLastOptionsPage ( int page );
void SetNavigatorVisible ( bool vis );
void SetPropertiesVisible ( bool vis );
void SetTransformerVisible ( bool vis );
void SetIgnoreDesktopSelect ( bool ignore );
void SetStatusBarVisible ( bool vis );
void AddRecentFile ( const char* filename );
int GetRecentFileCount ( void );
const char* GetRecentFile ( int index );
idVec4& GetGridColor ( void );
int GetGridWidth ( void );
int GetGridHeight ( void );
bool GetGridVisible ( void );
bool GetGridSnap ( void );
int GetLastOptionsPage ( void );
idVec4& GetWorkspaceColor ( void );
bool GetNavigatorVisible ( void );
bool GetTransformerVisible ( void );
bool GetPropertiesVisible ( void );
idVec4& GetSelectionColor ( void );
COLORREF* GetCustomColors ( void );
bool GetIgnoreDesktopSelect ( void );
bool GetStatusBarVisible ( void );
void SetWindowPlacement ( const char* name, HWND hwnd );
bool GetWindowPlacement ( const char* name, HWND hwnd );
void SnapRectToGrid ( idRectangle& rect, bool snapLeft = true, bool snapTop = true, bool snapWidth = true, bool snapHeight = true );
protected:
void ConvertColor ( COLORREF src, idVec4& dest );
void SetModified ( bool mod );
bool mModified;
int mLastOptionsPage;
idVec4 mGridColor;
int mGridWidth;
int mGridHeight;
bool mGridSnap;
bool mGridVisible;
idVec4 mWorkspaceColor;
idVec4 mSelectionColor;
bool mNavigatorVisible;
bool mPropertiesVisible;
bool mTransformerVisible;
bool mStatusBarVisible;
bool mIgnoreDesktopSelect;
idList<idStr> mRecentFiles;
COLORREF mCustomColors[16];
rvRegistryOptions mRegistry;
};
ID_INLINE void rvGEOptions::SetModified ( bool mod )
{
mModified = mod;
}
ID_INLINE void rvGEOptions::ConvertColor ( COLORREF src, idVec4& dest )
{
dest[0] = (float)GetRValue ( src ) / 255.0f;
dest[1] = (float)GetGValue ( src ) / 255.0f;
dest[2] = (float)GetBValue ( src ) / 255.0f;
dest[3] = 1.0f;
}
ID_INLINE void rvGEOptions::SetGridWidth ( int width )
{
mGridWidth = width;
SetModified ( true );
}
ID_INLINE void rvGEOptions::SetGridHeight ( int height )
{
mGridHeight = height;
SetModified ( true );
}
ID_INLINE void rvGEOptions::SetGridSnap ( bool snap )
{
mGridSnap = snap;
SetModified ( true );
}
ID_INLINE void rvGEOptions::SetGridVisible ( bool vis )
{
mGridVisible = vis;
SetModified ( true );
}
ID_INLINE void rvGEOptions::SetStatusBarVisible ( bool vis )
{
mStatusBarVisible = vis;
SetModified ( true );
}
ID_INLINE void rvGEOptions::SetGridColor ( COLORREF color )
{
ConvertColor ( color, mGridColor );
SetModified ( true );
}
ID_INLINE void rvGEOptions::SetSelectionColor ( idVec4& color )
{
VectorCopy ( color, mSelectionColor );
SetModified ( true );
}
ID_INLINE void rvGEOptions::SetSelectionColor ( COLORREF color )
{
ConvertColor ( color, mSelectionColor );
SetModified ( true );
}
ID_INLINE void rvGEOptions::SetGridColor ( idVec4& color )
{
VectorCopy ( color, mGridColor );
SetModified ( true );
}
ID_INLINE void rvGEOptions::SetNavigatorVisible ( bool vis )
{
mNavigatorVisible = vis;
SetModified ( true );
}
ID_INLINE void rvGEOptions::SetPropertiesVisible ( bool vis )
{
mPropertiesVisible = vis;
SetModified ( true );
}
ID_INLINE void rvGEOptions::SetTransformerVisible ( bool vis )
{
mTransformerVisible = vis;
SetModified ( true );
}
ID_INLINE idVec4& rvGEOptions::GetGridColor ( void )
{
return mGridColor;
}
ID_INLINE int rvGEOptions::GetGridWidth ( void )
{
return mGridWidth;
}
ID_INLINE int rvGEOptions::GetGridHeight ( void )
{
return mGridHeight;
}
ID_INLINE bool rvGEOptions::GetGridVisible ( void )
{
return mGridVisible;
}
ID_INLINE bool rvGEOptions::GetGridSnap ( void )
{
return mGridSnap;
}
ID_INLINE idVec4& rvGEOptions::GetWorkspaceColor ( void )
{
return mWorkspaceColor;
}
ID_INLINE int rvGEOptions::GetLastOptionsPage ( void )
{
return mLastOptionsPage;
}
ID_INLINE void rvGEOptions::SetLastOptionsPage ( int page )
{
mLastOptionsPage = page;
}
ID_INLINE bool rvGEOptions::GetNavigatorVisible ( void )
{
return mNavigatorVisible;
}
ID_INLINE bool rvGEOptions::GetPropertiesVisible ( void )
{
return mPropertiesVisible;
}
ID_INLINE bool rvGEOptions::GetTransformerVisible ( void )
{
return mTransformerVisible;
}
ID_INLINE bool rvGEOptions::GetStatusBarVisible ( void )
{
return mStatusBarVisible;
}
ID_INLINE idVec4& rvGEOptions::GetSelectionColor ( void )
{
return mSelectionColor;
}
ID_INLINE COLORREF* rvGEOptions::GetCustomColors ( void )
{
return mCustomColors;
}
ID_INLINE void rvGEOptions::SetIgnoreDesktopSelect ( bool ignore )
{
mIgnoreDesktopSelect = ignore;
}
ID_INLINE bool rvGEOptions::GetIgnoreDesktopSelect ( void )
{
return mIgnoreDesktopSelect;
}
ID_INLINE void rvGEOptions::SetWindowPlacement ( const char* name, HWND hwnd )
{
mRegistry.SetWindowPlacement ( name, hwnd );
}
ID_INLINE bool rvGEOptions::GetWindowPlacement ( const char* name, HWND hwnd )
{
return mRegistry.GetWindowPlacement ( name, hwnd );
}
ID_INLINE void rvGEOptions::AddRecentFile ( const char* filename )
{
mRegistry.AddRecentFile ( filename );
}
ID_INLINE int rvGEOptions::GetRecentFileCount ( void )
{
return mRegistry.GetRecentFileCount ( );
}
ID_INLINE const char* rvGEOptions::GetRecentFile ( int index )
{
return mRegistry.GetRecentFile ( index );
}
#endif // _GEOPTIONS_H_

View File

@@ -0,0 +1,210 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/guied_resource.h"
#include "../common/ColorButton.h"
#include "GEApp.h"
/*
================
GEOptionsDlg_GeneralProc
Dialog procedure for the general options tab
================
*/
static INT_PTR CALLBACK GEOptionsDlg_GeneralProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch ( msg )
{
case WM_INITDIALOG:
ColorButton_SetColor ( GetDlgItem ( hwnd, IDC_GUIED_SELECTIONCOLOR ),
RGB(gApp.GetOptions().GetSelectionColor()[0]*255,
gApp.GetOptions().GetSelectionColor()[1]*255,
gApp.GetOptions().GetSelectionColor()[2]*255) );
CheckDlgButton ( hwnd, IDC_GUIED_IGNOREDESKTOP, gApp.GetOptions().GetIgnoreDesktopSelect()?BST_CHECKED:BST_UNCHECKED );
break;
case WM_COMMAND:
switch ( LOWORD ( wParam ) )
{
case IDC_GUIED_SELECTIONCOLOR:
{
CHOOSECOLOR col;
ZeroMemory ( &col, sizeof(col) );
col.lStructSize = sizeof(col);
col.lpCustColors = gApp.GetOptions().GetCustomColors ( );
col.hwndOwner = hwnd;
col.hInstance = NULL;
col.Flags = CC_RGBINIT;
col.rgbResult = ColorButton_GetColor ( GetDlgItem ( hwnd, IDC_GUIED_SELECTIONCOLOR ) );
if ( ChooseColor ( &col ) )
{
ColorButton_SetColor ( GetDlgItem ( hwnd, IDC_GUIED_SELECTIONCOLOR ), col.rgbResult );
}
break;
}
}
break;
case WM_DRAWITEM:
ColorButton_DrawItem ( GetDlgItem ( hwnd, wParam ), (LPDRAWITEMSTRUCT)lParam );
return TRUE;
case WM_NOTIFY:
switch (((NMHDR FAR *) lParam)->code)
{
case PSN_APPLY:
gApp.GetOptions().SetLastOptionsPage ( PropSheet_HwndToIndex ( GetParent ( hwnd ), PropSheet_GetCurrentPageHwnd ( GetParent ( hwnd ) ) ) );
gApp.GetOptions().SetSelectionColor ( ColorButton_GetColor ( GetDlgItem ( hwnd, IDC_GUIED_SELECTIONCOLOR ) ) );
gApp.GetOptions().SetIgnoreDesktopSelect ( IsDlgButtonChecked ( hwnd, IDC_GUIED_IGNOREDESKTOP ) != 0 );
break;
}
break;
}
return FALSE;
}
/*
================
GEOptionsDlg_GridProc
Dialog procedure for the grid settings tab
================
*/
static INT_PTR CALLBACK GEOptionsDlg_GridProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch ( msg )
{
case WM_INITDIALOG:
// Copy the options information to the dialog controls
ColorButton_SetColor ( GetDlgItem ( hwnd, IDC_GUIED_GRIDCOLOR ), RGB(gApp.GetOptions().GetGridColor()[0]*255,gApp.GetOptions().GetGridColor()[1]*255,gApp.GetOptions().GetGridColor()[2]*255) );
SetWindowText ( GetDlgItem ( hwnd, IDC_GUIED_SPACINGWIDTH ), va("%d", gApp.GetOptions().GetGridWidth ( ) ) );
SetWindowText ( GetDlgItem ( hwnd, IDC_GUIED_SPACINGHEIGHT ), va("%d", gApp.GetOptions().GetGridHeight ( ) ) );
CheckDlgButton ( hwnd, IDC_GUIED_GRIDVISIBLE, gApp.GetOptions().GetGridVisible()?BST_CHECKED:BST_UNCHECKED );
CheckDlgButton ( hwnd, IDC_GUIED_GRIDSNAP, gApp.GetOptions().GetGridSnap()?BST_CHECKED:BST_UNCHECKED );
return TRUE;
case WM_DRAWITEM:
ColorButton_DrawItem ( GetDlgItem ( hwnd, wParam ), (LPDRAWITEMSTRUCT)lParam );
return TRUE;
case WM_NOTIFY:
switch (((NMHDR FAR *) lParam)->code)
{
case PSN_APPLY:
{
char temp[32];
// Copy the dialog control data back to the options
GetWindowText ( GetDlgItem ( hwnd, IDC_GUIED_SPACINGWIDTH ), temp, 32 );
gApp.GetOptions().SetGridWidth(atol(temp));
GetWindowText ( GetDlgItem ( hwnd, IDC_GUIED_SPACINGHEIGHT ), temp, 32 );
gApp.GetOptions().SetGridHeight(atol(temp));
gApp.GetOptions().SetGridVisible ( IsDlgButtonChecked ( hwnd, IDC_GUIED_GRIDVISIBLE ) != 0 );
gApp.GetOptions().SetGridSnap ( IsDlgButtonChecked ( hwnd, IDC_GUIED_GRIDSNAP ) != 0 );
gApp.GetOptions().SetGridColor ( ColorButton_GetColor ( GetDlgItem ( hwnd, IDC_GUIED_GRIDCOLOR ) ) );
break;
}
}
break;
case WM_COMMAND:
switch ( LOWORD ( wParam ) )
{
case IDC_GUIED_GRIDCOLOR:
{
CHOOSECOLOR col;
ZeroMemory ( &col, sizeof(col) );
col.lStructSize = sizeof(col);
col.lpCustColors = gApp.GetOptions().GetCustomColors ( );
col.hwndOwner = hwnd;
col.hInstance = NULL;
col.Flags = CC_RGBINIT;
col.rgbResult = RGB(gApp.GetOptions().GetGridColor()[0]*255,gApp.GetOptions().GetGridColor()[1]*255,gApp.GetOptions().GetGridColor()[2]*255);
if ( ChooseColor ( &col ) )
{
ColorButton_SetColor ( GetDlgItem ( hwnd, IDC_GUIED_GRIDCOLOR ), col.rgbResult );
}
break;
}
}
return TRUE;
}
return FALSE;
}
/*
================
GEOptionsDlg_DoModal
Starts the options dialog and updates the global options if ok is pressed
================
*/
bool GEOptionsDlg_DoModal ( HWND parent )
{
PROPSHEETHEADER propsh;
PROPSHEETPAGE propsp[2];
propsp[0].dwSize = sizeof(PROPSHEETPAGE);
propsp[0].dwFlags = PSP_USETITLE;
propsp[0].hInstance = win32.hInstance;
propsp[0].pszTemplate = MAKEINTRESOURCE(IDD_GUIED_OPTIONS_GENERAL);
propsp[0].pfnDlgProc = GEOptionsDlg_GeneralProc;
propsp[0].pszTitle = "General";
propsp[0].lParam = 0;
propsp[1].dwSize = sizeof(PROPSHEETPAGE);
propsp[1].dwFlags = PSP_USETITLE;
propsp[1].hInstance = win32.hInstance;
propsp[1].pszTemplate = MAKEINTRESOURCE(IDD_GUIED_OPTIONS_GRID);
propsp[1].pfnDlgProc = GEOptionsDlg_GridProc;
propsp[1].pszTitle = "Grid";
propsp[1].lParam = 0;
propsh.dwSize = sizeof(PROPSHEETHEADER);
propsh.nStartPage = gApp.GetOptions().GetLastOptionsPage ( );
propsh.dwFlags = PSH_PROPSHEETPAGE|PSH_NOAPPLYNOW|PSH_NOCONTEXTHELP;
propsh.hwndParent = parent;
propsh.pszCaption = "Options";
propsh.nPages = 2;
propsh.ppsp = (LPCPROPSHEETPAGE)&propsp;
if ( PropertySheet ( &propsh ) )
{
gApp.GetOptions().Save ( );
return true;
}
return false;
}

View File

@@ -0,0 +1,33 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GEOPTIONSDLG_H_
#define GEOPTIONSDLG_H_
bool GEOptionsDlg_DoModal ( HWND parent );
#endif // GEOPTIONSDLG_H_

View File

@@ -0,0 +1,311 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/guied_resource.h"
#include "GEApp.h"
#include "GEProperties.h"
#include "GEWindowWrapper.h"
#include "GEStateModifier.h"
/*
================
rvGEProperties::rvGEProperties
constructor
================
*/
rvGEProperties::rvGEProperties( void )
{
mWrapper = NULL;
mWnd = NULL;
mWorkspace = NULL;
}
/*
================
rvGEProperties::Create
Create the property window as a child of the given window
================
*/
bool rvGEProperties::Create ( HWND parent, bool visible )
{
WNDCLASSEX wndClass;
memset ( &wndClass, 0, sizeof(wndClass) );
wndClass.cbSize = sizeof(WNDCLASSEX);
wndClass.lpszClassName = "GUIEDITOR_PROPERTIES_CLASS";
wndClass.lpfnWndProc = WndProc;
wndClass.hbrBackground = (HBRUSH)GetSysColorBrush ( COLOR_3DFACE );
wndClass.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW);
wndClass.lpszMenuName = NULL;
wndClass.hInstance = win32.hInstance;
RegisterClassEx ( &wndClass );
mWnd = CreateWindowEx ( WS_EX_TOOLWINDOW,
"GUIEDITOR_PROPERTIES_CLASS",
"Properties",
WS_SYSMENU|WS_THICKFRAME|WS_CAPTION|WS_POPUP|WS_OVERLAPPED|WS_BORDER|WS_CLIPSIBLINGS|WS_CHILD,
0, 0, 200,300,
parent,
NULL,
win32.hInstance,
this );
if ( !mWnd )
{
return false;
}
if ( !gApp.GetOptions().GetWindowPlacement ( "properties", mWnd ) )
{
RECT rParent;
RECT rClient;
GetWindowRect ( parent, &rParent );
GetWindowRect ( mWnd, &rClient );
SetWindowPos ( mWnd, NULL,
rParent.right - 10 - (rClient.right-rClient.left),
rParent.bottom - 10 - (rClient.bottom-rClient.top),
0,0,
SWP_NOZORDER|SWP_NOSIZE );
}
Show ( visible );
return true;
}
/*
================
rvGEProperties::Show
Show/Hide the properties window
================
*/
void rvGEProperties::Show ( bool visible )
{
gApp.GetOptions().SetPropertiesVisible ( visible );
ShowWindow ( mWnd, visible?SW_SHOW:SW_HIDE );
}
/*
================
rvGEProperties::Update
Update the properties in the window
================
*/
void rvGEProperties::Update ( void )
{
int i;
if ( mWorkspace && mWorkspace->GetSelectionMgr ( ).Num ( ) == 1 )
{
mWrapper = rvGEWindowWrapper::GetWrapper ( mWorkspace->GetSelectionMgr()[0] );
}
else
{
mWrapper = NULL;
}
ShowWindow ( mGrid.GetWindow ( ), mWrapper?SW_SHOW:SW_HIDE );
mGrid.RemoveAllItems ( );
if ( mWrapper )
{
for ( i = 0; i < (int)mWrapper->GetStateDict().GetNumKeyVals ( ); i ++ )
{
const idKeyValue* kv = mWrapper->GetStateDict().GetKeyVal ( i );
idStr temp;
temp = kv->GetValue();
temp.StripQuotes ( );
mGrid.AddItem ( kv->GetKey(), temp );
}
}
}
/*
================
rvGEProperties::AddModifier
Add a state modifier for the given key / value pair
================
*/
bool rvGEProperties::AddModifier ( const char* name, const char* value )
{
idDict tempstate;
idStr tempvalue;
tempvalue = value;
if ( !mWrapper->VerfiyStateKey ( name, tempvalue ) )
{
tempvalue = "\"";
tempvalue += value;
tempvalue += "\"";
if ( !mWrapper->VerfiyStateKey ( name, tempvalue ) )
{
gApp.MessageBox ( va("Invalid property value '%s' for property '%s'", value, name), MB_OK );
return false;
}
}
tempstate = mWrapper->GetStateDict ( );
tempstate.Set ( name, tempvalue );
mWorkspace->GetModifierStack().Append ( new rvGEStateModifier ( "Property Change", mWrapper->GetWindow(), tempstate ) );
mWorkspace->SetModified ( true );
gApp.GetNavigator().Update ( );
return true;
}
/*
================
rvGEProperties::WndProc
Window Procedure for the properties window
================
*/
LRESULT CALLBACK rvGEProperties::WndProc ( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
rvGEProperties* kv = (rvGEProperties*) GetWindowLong ( hWnd, GWL_USERDATA );
if ( kv && kv->mGrid.ReflectMessage ( hWnd, msg, wParam, lParam ) )
{
return 0;
}
switch ( msg )
{
case WM_ACTIVATE:
common->ActivateTool( LOWORD( wParam ) != WA_INACTIVE );
break;
case WM_NOTIFY:
{
NMHDR* hdr;
hdr = (NMHDR*)lParam;
if ( hdr->idFrom == 999 )
{
NMPROPGRID* nmpg = (NMPROPGRID*)hdr;
switch ( hdr->code )
{
case PGN_ITEMCHANGED:
return (int)kv->AddModifier ( nmpg->mName, nmpg->mValue );
/*
case NM_KEYDOWN:
{
NMKEY* nmkey = (NMKEY*)hdr;
if ( nmkey->nVKey == VK_DELETE )
{
int sel = kv->mGrid.GetCurSel ( );
if ( sel != -1 )
{
const char* prop;
prop = kv->mGrid.GetItemName(sel);
if ( !idStr::Icmp ( prop, "rect" ) ||
!idStr::Icmp ( prop, "visible" ) ||
!idStr::Icmp ( prop, "name" ) )
{
MessageBeep ( MB_ICONASTERISK );
}
else
{
idDict tempstate;
tempstate = kv->mWrapper->GetStateDict ( );
tempstate.Delete ( prop );
kv->mWorkspace->GetModifierStack().Append ( new rvGEStateModifier ( "Property Change", kv->mWrapper->GetWindow(), tempstate ) );
kv->mWorkspace->SetModified ( true );
kv->mGrid.RemoveItem ( sel );
}
}
}
else
{
SendMessage ( gApp.GetMDIFrame(), WM_KEYDOWN, nmkey->nVKey, nmkey->uFlags );
}
break;
}
*/
}
}
break;
}
case WM_CREATE:
{
LPCREATESTRUCT cs;
// Attach the class to the window first
cs = (LPCREATESTRUCT) lParam;
kv = (rvGEProperties*) cs->lpCreateParams;
SetWindowLong ( hWnd, GWL_USERDATA, (LONG)kv );
kv->mGrid.Create ( hWnd, 999, PGS_ALLOWINSERT );
kv->SetWorkspace ( NULL );
kv->Update ( );
break;
}
case WM_ERASEBKGND:
if ( kv->mWrapper )
{
return FALSE;
}
break;
case WM_SIZE:
kv->mGrid.Move ( 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE );
break;
case WM_CLOSE:
gApp.GetOptions().SetPropertiesVisible ( false );
kv->Show ( false );
return 0;
case WM_NCACTIVATE:
return gApp.ToolWindowActivate ( hWnd, msg, wParam, lParam );
case WM_DESTROY:
gApp.GetOptions().SetWindowPlacement ( "properties", hWnd );
break;
}
return DefWindowProc ( hWnd, msg, wParam, lParam );
}

View File

@@ -0,0 +1,77 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GEPROPERTIES_H_
#define GEPROPERTIES_H_
#ifndef PROPERTYGRID_H_
#include "../common/PropertyGrid.h"
#endif
class rvGEWorkspace;
class rvGEWindowWrapper;
class rvGEProperties
{
public:
rvGEProperties ( );
bool Create ( HWND parent, bool visible );
void Show ( bool visibile );
void SetWorkspace ( rvGEWorkspace* workspace );
void Update ( void );
HWND GetWindow ( void );
protected:
bool AddModifier ( const char* name, const char* value );
static LRESULT CALLBACK WndProc ( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
HWND mWnd;
rvPropertyGrid mGrid;
rvGEWindowWrapper* mWrapper;
rvGEWorkspace* mWorkspace;
};
ID_INLINE HWND rvGEProperties::GetWindow ( void )
{
return mWnd;
}
ID_INLINE void rvGEProperties::SetWorkspace ( rvGEWorkspace* workspace )
{
mWorkspace = workspace;
Update ( );
}
#endif // GEPROPERTIES_H_

View File

@@ -0,0 +1,110 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../common/ColorButton.h"
#include "GEApp.h"
#include "GEPropertyPage.h"
rvGEPropertyPage::rvGEPropertyPage ( )
{
mPage = NULL;
}
/*
================
rvGEPropertyPage::WndProc
Window procedure for the property page class.
================
*/
INT_PTR CALLBACK rvGEPropertyPage::WndProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
rvGEPropertyPage* page = (rvGEPropertyPage*) GetWindowLong ( hwnd, GWL_USERDATA );
// Pages dont get the init dialog since their Init method is called instead
if ( msg == WM_INITDIALOG )
{
PROPSHEETPAGE* psp = (PROPSHEETPAGE*) lParam;
page = (rvGEPropertyPage*) psp->lParam;
SetWindowLong ( hwnd, GWL_USERDATA, (LONG)page );
page->mPage = hwnd;
page->Init ( );
return FALSE;
}
else if ( !page )
{
return FALSE;
}
// See if the derived class wants to handle the message
return page->HandleMessage ( msg, wParam, lParam );
}
/*
================
rvGEPropertyPage::HandleMessage
Handles all messages that the base property page must handle.
================
*/
int rvGEPropertyPage::HandleMessage ( UINT msg, WPARAM wParam, LPARAM lParam )
{
switch ( msg )
{
case WM_NOTIFY:
switch (((NMHDR FAR *) lParam)->code)
{
case PSN_APPLY:
if ( !Apply ( ) )
{
SetWindowLong ( mPage, DWL_MSGRESULT, PSNRET_INVALID );
return TRUE;
}
break;
case PSN_SETACTIVE:
SetActive ( );
break;
case PSN_KILLACTIVE:
KillActive ( );
break;
}
break;
}
return FALSE;
}

View File

@@ -0,0 +1,51 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GEPROPERTYPAGE_H_
#define GEPROPERTYPAGE_H_
class rvGEPropertyPage
{
public:
rvGEPropertyPage ( );
virtual bool Init ( void ) { return true; }
virtual bool Apply ( void ) { return true; }
virtual bool SetActive ( void ) { return true; }
virtual bool KillActive ( void ) { return true; }
virtual int HandleMessage ( UINT msg, WPARAM wParam, LPARAM lParam );
static INT_PTR CALLBACK WndProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
protected:
HWND mPage;
};
#endif // GEPROPERTYPAGE_H_

View File

@@ -0,0 +1,474 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../renderer/tr_local.h"
#include "../../sys/win32/win_local.h"
#include "GEApp.h"
#include "GESelectionMgr.h"
#define GUIED_GRABSIZE 7
#define GUIED_CENTERSIZE 5
rvGESelectionMgr::rvGESelectionMgr ( )
{
mWorkspace = NULL;
}
/*
================
rvGESelectionMgr::SetSelection
Sets the only selection for the workspace to the given window
================
*/
void rvGESelectionMgr::Set ( idWindow* window )
{
// Get rid of any current selections
Clear ( );
// Add this selection now
return Add ( window );
}
/*
================
rvGESelectionMgr::Add
Adds the given window to the selection list
================
*/
void rvGESelectionMgr::Add ( idWindow* window, bool expand )
{
rvGEWindowWrapper* wrapper;
wrapper = rvGEWindowWrapper::GetWrapper ( window );
assert ( wrapper );
// If the window is already selected then dont add the selection
if ( wrapper->IsSelected ( ) )
{
return;
}
wrapper->SetSelected ( true );
mSelections.Append ( window );
if ( expand && wrapper->Expand ( ) )
{
gApp.GetNavigator ( ).Update ( );
}
gApp.GetNavigator ( ).UpdateSelections ( );
gApp.GetNavigator ( ).Refresh ( );
gApp.GetTransformer ( ).Update ( );
gApp.GetProperties().Update ( );
UpdateExpression ( );
}
/*
================
rvGESelectionMgr::RemoveSelection
Removes the selection from the current workspace
================
*/
void rvGESelectionMgr::Remove ( idWindow* window )
{
rvGEWindowWrapper* wrapper;
wrapper = rvGEWindowWrapper::GetWrapper ( window );
assert ( wrapper );
// Dont bother if the window isnt selectd already
if ( !wrapper->IsSelected ( ) )
{
return;
}
wrapper->SetSelected ( false );
mSelections.Remove ( window );
gApp.GetNavigator ( ).UpdateSelections ( );
gApp.GetNavigator ( ).Refresh ( );
gApp.GetTransformer ( ).Update ( );
gApp.GetProperties().Update ( );
UpdateExpression ( );
}
/*
================
rvGESelectionMgr::ClearSelections
Remove all of the current selections
================
*/
void rvGESelectionMgr::Clear ( void )
{
int i;
for ( i = 0; i < mSelections.Num ( ); i ++ )
{
rvGEWindowWrapper::GetWrapper ( mSelections[i] )->SetSelected ( false );
}
mSelections.Clear ( );
gApp.GetNavigator ( ).UpdateSelections ( );
gApp.GetNavigator ( ).Refresh ( );
gApp.GetTransformer ( ).Update ( );
gApp.GetProperties().Update ( );
mExpression = false;
}
/*
================
rvGESelectionMgr::Render
Render the selections including the move/size bars
================
*/
void rvGESelectionMgr::Render ( void )
{
if ( !mSelections.Num ( ) )
{
return;
}
qglEnable(GL_BLEND);
qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
UpdateRectangle ( );
qglPolygonMode(GL_FRONT_AND_BACK, GL_LINE );
idVec4& color = gApp.GetOptions().GetSelectionColor ( );
qglColor4f ( color[0],color[1],color[2], 1.0f );
qglBegin(GL_LINE_LOOP );
qglVertex2f ( mRect.x, mRect.y );
qglVertex2f ( mRect.x + mRect.w, mRect.y );
qglVertex2f ( mRect.x + mRect.w, mRect.y + mRect.h);
qglVertex2f ( mRect.x, mRect.y + mRect.h);
qglEnd ( );
qglColor4f ( color[0],color[1],color[2], 0.75f );
int i;
for ( i = 0; i < mSelections.Num(); i ++ )
{
rvGEWindowWrapper* wrapper;
idRectangle rect;
wrapper = rvGEWindowWrapper::GetWrapper ( mSelections[i] );
assert ( wrapper );
rect = wrapper->GetScreenRect ( );
mWorkspace->WorkspaceToWindow ( rect );
if ( i == 0 )
{
qglPolygonMode(GL_FRONT_AND_BACK, GL_FILL );
qglBegin ( GL_TRIANGLES );
qglVertex2f ( rect.x, rect.y );
qglVertex2f ( rect.x + GUIED_GRABSIZE, rect.y );
qglVertex2f ( rect.x, rect.y + GUIED_GRABSIZE );
qglEnd ( );
}
qglPolygonMode(GL_FRONT_AND_BACK, GL_LINE );
qglBegin(GL_LINE_LOOP );
qglVertex2f ( rect.x, rect.y );
qglVertex2f ( rect.x + rect.w, rect.y );
qglVertex2f ( rect.x + rect.w, rect.y + rect.h);
qglVertex2f ( rect.x, rect.y + rect.h);
qglEnd ( );
qglPolygonMode(GL_FRONT_AND_BACK, GL_FILL );
qglBegin( GL_QUADS );
qglVertex2f ( rect.x + (rect.w - GUIED_CENTERSIZE) / 2, rect.y + (rect.h - GUIED_CENTERSIZE) / 2 );
qglVertex2f ( rect.x + (rect.w + GUIED_CENTERSIZE) / 2, rect.y + (rect.h - GUIED_CENTERSIZE) / 2 );
qglVertex2f ( rect.x + (rect.w + GUIED_CENTERSIZE) / 2, rect.y + (rect.h + GUIED_CENTERSIZE) / 2 );
qglVertex2f ( rect.x + (rect.w - GUIED_CENTERSIZE) / 2, rect.y + (rect.h + GUIED_CENTERSIZE) / 2 );
qglEnd ( );
}
if ( mExpression )
{
return;
}
qglPolygonMode(GL_FRONT_AND_BACK, GL_LINE );
qglColor4f ( color[0],color[1],color[2], 1.0f );
qglBegin(GL_QUADS);
// Top Left
qglVertex2f ( mRect.x - GUIED_GRABSIZE, mRect.y - GUIED_GRABSIZE );
qglVertex2f ( mRect.x - 1, mRect.y - GUIED_GRABSIZE );
qglVertex2f ( mRect.x - 1, mRect.y - 1 );
qglVertex2f ( mRect.x - GUIED_GRABSIZE, mRect.y - 1 );
// Left
qglVertex2f ( mRect.x - GUIED_GRABSIZE, mRect.y + mRect.h / 2 - GUIED_GRABSIZE / 2);
qglVertex2f ( mRect.x - 1, mRect.y + mRect.h / 2 - GUIED_GRABSIZE / 2 );
qglVertex2f ( mRect.x - 1, mRect.y + mRect.h / 2 + GUIED_GRABSIZE / 2 );
qglVertex2f ( mRect.x - GUIED_GRABSIZE, mRect.y + mRect.h / 2 + GUIED_GRABSIZE / 2 );
// Bototm Left
qglVertex2f ( mRect.x - GUIED_GRABSIZE, mRect.y + mRect.h + 1 );
qglVertex2f ( mRect.x - 1, mRect.y + mRect.h + 1 );
qglVertex2f ( mRect.x - 1, mRect.y + mRect.h + GUIED_GRABSIZE );
qglVertex2f ( mRect.x - GUIED_GRABSIZE, mRect.y + mRect.h + GUIED_GRABSIZE );
// Bottom
qglVertex2f ( mRect.x - GUIED_GRABSIZE / 2 + mRect.w / 2, mRect.y + mRect.h + 1 );
qglVertex2f ( mRect.x + GUIED_GRABSIZE / 2 + mRect.w / 2, mRect.y + mRect.h + 1 );
qglVertex2f ( mRect.x + GUIED_GRABSIZE / 2 + mRect.w / 2, mRect.y + mRect.h + GUIED_GRABSIZE );
qglVertex2f ( mRect.x - GUIED_GRABSIZE / 2 + mRect.w / 2, mRect.y + mRect.h + GUIED_GRABSIZE );
// Bottom Right
qglVertex2f ( mRect.x + mRect.w + 1, mRect.y + mRect.h + 1 );
qglVertex2f ( mRect.x + mRect.w + GUIED_GRABSIZE, mRect.y + mRect.h + 1 );
qglVertex2f ( mRect.x + mRect.w + GUIED_GRABSIZE, mRect.y + mRect.h + GUIED_GRABSIZE );
qglVertex2f ( mRect.x + mRect.w + 1, mRect.y + mRect.h + GUIED_GRABSIZE );
// Right
qglVertex2f ( mRect.x + mRect.w + 1, mRect.y + mRect.h / 2 - GUIED_GRABSIZE / 2);
qglVertex2f ( mRect.x + mRect.w + GUIED_GRABSIZE, mRect.y + mRect.h / 2 - GUIED_GRABSIZE / 2 );
qglVertex2f ( mRect.x + mRect.w + GUIED_GRABSIZE, mRect.y + mRect.h / 2 + GUIED_GRABSIZE / 2 );
qglVertex2f ( mRect.x + mRect.w + 1, mRect.y + mRect.h / 2 + GUIED_GRABSIZE / 2 );
// Top Right
qglVertex2f ( mRect.x + mRect.w + 1, mRect.y - GUIED_GRABSIZE );
qglVertex2f ( mRect.x + mRect.w + GUIED_GRABSIZE, mRect.y - GUIED_GRABSIZE );
qglVertex2f ( mRect.x + mRect.w + GUIED_GRABSIZE, mRect.y - 1 );
qglVertex2f ( mRect.x + mRect.w + 1, mRect.y - 1 );
// Top
qglVertex2f ( mRect.x - GUIED_GRABSIZE / 2 + mRect.w / 2, mRect.y - GUIED_GRABSIZE );
qglVertex2f ( mRect.x + GUIED_GRABSIZE / 2 + mRect.w / 2, mRect.y - GUIED_GRABSIZE );
qglVertex2f ( mRect.x + GUIED_GRABSIZE / 2 + mRect.w / 2, mRect.y - 1 );
qglVertex2f ( mRect.x - GUIED_GRABSIZE / 2 + mRect.w / 2, mRect.y - 1 );
qglEnd ( );
qglPolygonMode(GL_FRONT_AND_BACK, GL_FILL );
}
/*
================
rvGESelectionMgr::UpdateRectangle
Update the selection rectangle from all the currently selected items.
================
*/
void rvGESelectionMgr::UpdateRectangle ( void )
{
int i;
idVec2 point;
assert ( mWorkspace );
if ( mSelections.Num ( ) <= 0 )
{
return;
}
// Start with the first selections retangle
mRect = rvGEWindowWrapper::GetWrapper( mSelections[0] )->GetScreenRect ( );
// Its easier to do the calculates with it being top left and bottom right
// so temporarly convert width and height to right and bottom
mRect.w += mRect.x;
mRect.h += mRect.y;
// Merge all the rest of the rectangles to make the actual selection rectangle
for ( i = 1; i < mSelections.Num(); i ++ )
{
idRectangle selRect;
selRect = rvGEWindowWrapper::GetWrapper ( mSelections[i] )->GetScreenRect ( );
mRect.w = max(selRect.x+selRect.w,mRect.w);
mRect.h = max(selRect.y+selRect.h,mRect.h);
mRect.x = min(selRect.x,mRect.x);
mRect.y = min(selRect.y,mRect.y);
}
mRect.w -= mRect.x;
mRect.h -= mRect.y;
mWorkspace->WorkspaceToWindow ( mRect );
}
/*
================
rvGESelectionMgr::UpdateExpression
Update whether or not the selection has an expression in it
================
*/
void rvGESelectionMgr::UpdateExpression ( void )
{
int i;
mExpression = false;
for ( i = 0; i < mSelections.Num(); i ++ )
{
rvGEWindowWrapper* wrapper;
wrapper = rvGEWindowWrapper::GetWrapper ( mSelections[i] );
if ( wrapper && !wrapper->CanMoveAndSize ( ) )
{
mExpression = true;
break;
}
}
}
/*
================
rvGESelectionMgr::HitTest
Test to see if the given coordinate is within the selection rectangle and if it is
see what its over.
================
*/
rvGESelectionMgr::EHitTest rvGESelectionMgr::HitTest ( float x, float y )
{
if ( !mSelections.Num ( ) )
{
return HT_NONE;
}
UpdateRectangle ( );
// Inside the rectangle is moving
if ( mRect.Contains ( x, y ) )
{
return mExpression?HT_SELECT:HT_MOVE;
}
if ( mExpression )
{
return HT_NONE;
}
// Check for top left sizing
if ( idRectangle ( mRect.x - GUIED_GRABSIZE, mRect.y - GUIED_GRABSIZE, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) )
{
return HT_SIZE_TOPLEFT;
}
// Check for left sizing
if ( idRectangle ( mRect.x - GUIED_GRABSIZE, mRect.y + mRect.h / 2 - GUIED_GRABSIZE / 2, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) )
{
return HT_SIZE_LEFT;
}
// Check for bottom left sizing
if ( idRectangle ( mRect.x - GUIED_GRABSIZE, mRect.y + mRect.h, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) )
{
return HT_SIZE_BOTTOMLEFT;
}
// Check for bottom sizing
if ( idRectangle ( mRect.x + mRect.w / 2 - GUIED_GRABSIZE / 2, mRect.y + mRect.h, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) )
{
return HT_SIZE_BOTTOM;
}
// Check for bottom right sizing
if ( idRectangle ( mRect.x + mRect.w, mRect.y + mRect.h, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) )
{
return HT_SIZE_BOTTOMRIGHT;
}
// Check for right sizing
if ( idRectangle ( mRect.x + mRect.w, mRect.y + mRect.h / 2 - GUIED_GRABSIZE / 2, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) )
{
return HT_SIZE_RIGHT;
}
// Check for top right sizing
if ( idRectangle ( mRect.x + mRect.w, mRect.y - GUIED_GRABSIZE, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) )
{
return HT_SIZE_TOPRIGHT;
}
// Check for top sizing
if ( idRectangle ( mRect.x + mRect.w / 2 - GUIED_GRABSIZE / 2, mRect.y - GUIED_GRABSIZE, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) )
{
return HT_SIZE_TOP;
}
return HT_NONE;
}
/*
================
rvGESelectionMgr::GetBottomMost
Returns the bottom most selected window.
================
*/
idWindow* rvGESelectionMgr::GetBottomMost ( void )
{
idWindow* bottom;
int depth;
int i;
depth = 9999;
bottom = NULL;
// Loop through all the selections and find the bottom most window
for ( i = 0; i < mSelections.Num(); i ++ )
{
idWindow* parent;
int tempDepth;
// Calculate the depth of the window by iterating back through the windows parents
for ( tempDepth = 0, parent = mSelections[i]; parent; parent = parent->GetParent ( ), tempDepth++ );
// If the new depth is less than the current depth then this window is below
if ( tempDepth < depth )
{
depth = tempDepth;
bottom = mSelections[i];
}
}
return bottom;
}

View File

@@ -0,0 +1,121 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GESELECTIONMGR_H_
#define GESELECTIONMGR_H_
class rvGEWorkspace;
class rvGESelectionMgr
{
public:
enum EHitTest
{
HT_NONE,
HT_SELECT,
HT_MOVE,
HT_SIZE_TOPLEFT,
HT_SIZE_TOP,
HT_SIZE_TOPRIGHT,
HT_SIZE_RIGHT,
HT_SIZE_BOTTOMRIGHT,
HT_SIZE_BOTTOM,
HT_SIZE_BOTTOMLEFT,
HT_SIZE_LEFT
};
rvGESelectionMgr ( );
void SetWorkspace ( rvGEWorkspace* workspace );
void Set ( idWindow* );
void Add ( idWindow* window, bool expand = true );
void Remove ( idWindow* );
void Clear ( void );
int Num ( void );
void Render ( void );
EHitTest HitTest ( float x, float y );
bool IsSelected ( idWindow* window );
bool IsExpression ( void );
idRectangle& GetRect ( void );
idWindow* GetBottomMost ( void );
idWindow*& operator[]( int index );
protected:
void UpdateRectangle ( void );
void UpdateExpression ( void );
idList<idWindow*> mSelections;
idRectangle mRect;
rvGEWorkspace* mWorkspace;
bool mExpression;
};
ID_INLINE int rvGESelectionMgr::Num ( void )
{
return mSelections.Num ( );
}
ID_INLINE idWindow*& rvGESelectionMgr::operator[]( int index )
{
assert( index >= 0 );
assert( index < mSelections.Num() );
return mSelections[ index ];
}
ID_INLINE void rvGESelectionMgr::SetWorkspace ( rvGEWorkspace* workspace )
{
mWorkspace = workspace;
}
ID_INLINE idRectangle& rvGESelectionMgr::GetRect ( void )
{
UpdateRectangle ( );
return mRect;
}
ID_INLINE bool rvGESelectionMgr::IsSelected ( idWindow* window )
{
return mSelections.FindIndex ( window ) != -1 ? true : false;
}
ID_INLINE bool rvGESelectionMgr::IsExpression ( void )
{
return mExpression;
}
#endif // GESELECTIONMGR_H_

View File

@@ -0,0 +1,77 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "GEApp.h"
#include "GESizeModifier.h"
rvGESizeModifier::rvGESizeModifier ( const char* name, idWindow* window, float l, float t, float r, float b ) :
rvGEModifier ( name, window )
{
mOldRect = mWrapper->GetClientRect ( );
mNewRect[0] = mOldRect[0] + l;
mNewRect[1] = mOldRect[1] + t;
mNewRect[2] = mOldRect[2] + r - l;
mNewRect[3] = mOldRect[3] + b - t;
}
bool rvGESizeModifier::Merge ( rvGEModifier* mergebase )
{
rvGESizeModifier* merge = (rvGESizeModifier*) mergebase;
mNewRect = merge->mNewRect;
return true;
}
bool rvGESizeModifier::Apply ( void )
{
mWrapper->SetRect ( mNewRect );
return true;
}
bool rvGESizeModifier::Undo ( void )
{
mWrapper->SetRect ( mOldRect );
return true;
}
bool rvGESizeModifier::IsValid ( void )
{
if ( !mWindow->GetParent ( ) )
{
return false;
}
return true;
}

View File

@@ -0,0 +1,56 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GESIZEMODIFIER_H_
#define GESIZEMODIFIER_H_
class rvGESizeModifier : public rvGEModifier
{
public:
rvGESizeModifier ( const char* name, idWindow* window, float l, float t, float r, float b );
virtual bool CanMerge ( rvGEModifier* merge );
virtual bool Merge ( rvGEModifier* merge );
virtual bool Apply ( void );
virtual bool Undo ( void );
virtual bool IsValid ( void );
protected:
idRectangle mNewRect;
idRectangle mOldRect;
};
ID_INLINE bool rvGESizeModifier::CanMerge ( rvGEModifier* merge )
{
return true;
}
#endif // GESIZEMODIFIER_H_

View File

@@ -0,0 +1,95 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "GEApp.h"
#include "GEStateModifier.h"
rvGEStateModifier::rvGEStateModifier ( const char* name, idWindow* window, idDict& dict ) :
rvGEModifier ( name, window ),
mDict ( dict )
{
mDict.Copy ( dict );
// Make a copy of the current dictionary
mUndoDict.Copy ( mWrapper->GetStateDict() );
}
/*
================
rvGEStateModifier::Apply
Applys the new state dictionary to the window
================
*/
bool rvGEStateModifier::Apply ( void )
{
return SetState ( mDict );
}
/*
================
rvGEStateModifier::Undo
Applies the undo dictionary to the window
================
*/
bool rvGEStateModifier::Undo ( void )
{
return SetState ( mUndoDict );
}
/*
================
rvGEStateModifier::Apply
Applys the given dictionary to the window
================
*/
bool rvGEStateModifier::SetState ( idDict& dict )
{
const idKeyValue* key;
int i;
// Delete any key thats gone in the new dict
for ( i = 0; i < mWrapper->GetStateDict().GetNumKeyVals(); i ++ )
{
key = mWrapper->GetStateDict().GetKeyVal ( i );
if ( !key )
{
continue;
}
}
mWrapper->SetState ( dict );
return true;
}

View File

@@ -0,0 +1,54 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GESTATEMODIFIER_H_
#define GESTATEMODIFIER_H_
#ifndef GEMODIFIER_H_
#include "GEModifier.h"
#endif
class rvGEStateModifier : public rvGEModifier
{
public:
rvGEStateModifier ( const char* name, idWindow* window, idDict& dict );
virtual bool Apply ( void );
virtual bool Undo ( void );
protected:
bool SetState ( idDict& dict );
rvGEWindowWrapper::EWindowType mWindowType;
rvGEWindowWrapper::EWindowType mUndoWindowType;
idDict mDict;
idDict mUndoDict;
};
#endif // GESTATEMODIFIER_H_

View File

@@ -0,0 +1,128 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "GEApp.h"
rvGEStatusBar::rvGEStatusBar ( )
{
mSimple = true;
mZoom = 0;
mTriangles = 0;
}
/*
================
rvGEStatusBar::Create
Creates a new status bar
================
*/
bool rvGEStatusBar::Create ( HWND parent, UINT id, bool visible )
{
mWnd = CreateStatusWindow ( WS_CHILD|WS_VISIBLE|WS_BORDER, "", parent, id );
if ( !mWnd )
{
return false;
}
Show ( visible );
return true;
}
/*
================
rvGEStatusBar::Resize
Resizes the status bar and updates the content
================
*/
void rvGEStatusBar::Resize ( int width, int height )
{
SendMessage ( mWnd, WM_SIZE, 0, MAKELONG(width,height) );
Update ( );
}
/*
================
rvGEStatusBar::Update
Updates the status bar by setting up each part's width and text
================
*/
void rvGEStatusBar::Update ( void )
{
RECT rStatus;
SIZE zoomSize;
SIZE trisSize;
int parts[5];
GetWindowRect ( mWnd, &rStatus );
if ( mSimple )
{
parts[0] = -1;
SendMessage ( mWnd, SB_SETPARTS, 1, (LONG)parts );
SendMessage ( mWnd, SB_SETTEXT, 1, (LPARAM) "" );
}
else
{
zoomSize.cx = 85;
trisSize.cx = 65;
parts[0] = (rStatus.right - rStatus.left) - zoomSize.cx - trisSize.cx - 40;
parts[1] = parts[0] + trisSize.cx;
parts[2] = parts[1] + zoomSize.cx;
parts[3] = parts[2] + 40;
parts[4] = -1;
SendMessage ( mWnd, SB_SETPARTS, 5, (LONG)parts );
SendMessage ( mWnd, SB_SETTEXT, 0, (LPARAM) "" );
SendMessage ( mWnd, SB_SETTEXT, 1, (LPARAM) va(" Tris: %d", mTriangles ) );
SendMessage ( mWnd, SB_SETTEXT, 2, (LPARAM) va(" Zoom: %d%%", mZoom ) );
}
}
/*
================
rvGEStatusBar::Show
Shows and hides the status bar
================
*/
void rvGEStatusBar::Show ( bool visible )
{
gApp.GetOptions().SetStatusBarVisible ( visible );
ShowWindow ( mWnd, visible?SW_SHOW:SW_HIDE );
}

View File

@@ -0,0 +1,89 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GESTATUSBAR_H_
#define GESTATUSBAR_H_
class rvGEStatusBar
{
public:
rvGEStatusBar ( );
bool Create ( HWND parent, UINT id, bool visible = true );
void Resize ( int width, int height );
HWND GetWindow ( void );
void SetZoom ( int zoom );
void SetTriangles ( int tris );
void SetSimple ( bool simple );
void Show ( bool state );
void Update ( void );
protected:
HWND mWnd;
bool mSimple;
int mZoom;
int mTriangles;
};
ID_INLINE HWND rvGEStatusBar::GetWindow ( void )
{
return mWnd;
}
ID_INLINE void rvGEStatusBar::SetZoom ( int zoom )
{
if ( mZoom != zoom )
{
mZoom = zoom;
Update ( );
}
}
ID_INLINE void rvGEStatusBar::SetTriangles ( int triangles )
{
if ( triangles != mTriangles )
{
mTriangles = triangles;
Update ( );
}
}
ID_INLINE void rvGEStatusBar::SetSimple ( bool simple )
{
if ( mSimple != simple )
{
mSimple = simple;
Update ( );
}
}
#endif // GESTATUSBAR_H_

View File

@@ -0,0 +1,345 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/guied_resource.h"
#include "GEApp.h"
#include "../common/MaskEdit.h"
HHOOK gTransHook = NULL;
HWND gTransDlg = NULL;
rvGETransformer::rvGETransformer ( )
{
mWnd = NULL;
mWorkspace = NULL;
}
bool rvGETransformer::Create ( HWND parent, bool visible )
{
WNDCLASSEX wndClass;
memset ( &wndClass, 0, sizeof(wndClass) );
wndClass.cbSize = sizeof(WNDCLASSEX);
wndClass.lpszClassName = "GUIEDITOR_TRANSFORMER_CLASS";
wndClass.lpfnWndProc = rvGETransformer::WndProc;
wndClass.hbrBackground = (HBRUSH)GetStockObject( LTGRAY_BRUSH );;
wndClass.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW);
wndClass.lpszMenuName = NULL;
wndClass.hInstance = win32.hInstance;
RegisterClassEx ( &wndClass );
mWnd = CreateWindowEx ( WS_EX_TOOLWINDOW,
"GUIEDITOR_TRANSFORMER_CLASS",
"Transformer",
WS_SYSMENU|WS_CAPTION|WS_POPUP|WS_OVERLAPPED|WS_BORDER|WS_CLIPSIBLINGS|WS_CHILD,
0, 0, 200,100,
parent,
NULL,
win32.hInstance,
this );
if ( !mWnd )
{
return false;
}
if ( !gApp.GetOptions().GetWindowPlacement ( "transformer", mWnd ) )
{
RECT rParent;
RECT rTrans;
GetWindowRect ( parent, &rParent );
GetWindowRect ( mWnd, &rTrans );
SetWindowPos ( mWnd, NULL,
rParent.right - 10 - (rTrans.right-rTrans.left),
rParent.bottom - 10 - (rTrans.bottom-rTrans.top),
0,0,
SWP_NOZORDER|SWP_NOSIZE );
}
Show ( visible );
return true;
}
LRESULT CALLBACK rvGETransformer::WndProc ( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
rvGETransformer* trans = (rvGETransformer*) GetWindowLong ( hWnd, GWL_USERDATA );
switch ( msg )
{
case WM_NCACTIVATE:
return gApp.ToolWindowActivate ( hWnd, msg, wParam, lParam );
case WM_ACTIVATE:
common->ActivateTool( LOWORD( wParam ) != WA_INACTIVE );
break;
case WM_DESTROY:
gApp.GetOptions().SetWindowPlacement ( "transformer", hWnd );
break;
case WM_ERASEBKGND:
return TRUE;
case WM_CREATE:
{
LPCREATESTRUCT cs;
// Attach the class to the window first
cs = (LPCREATESTRUCT) lParam;
trans = (rvGETransformer*) cs->lpCreateParams;
SetWindowLong ( hWnd, GWL_USERDATA, (LONG)trans );
trans->mWnd = hWnd;
trans->mDlg = CreateDialogParam ( gApp.GetInstance(), MAKEINTRESOURCE(IDD_GUIED_TRANSFORMER),
hWnd, DlgProc, (LPARAM)trans );
RECT rDlg;
RECT rWindow;
RECT rClient;
GetWindowRect ( trans->mWnd, &rWindow );
GetClientRect ( trans->mWnd, &rClient );
GetWindowRect ( trans->mDlg, &rDlg );
SetWindowPos ( trans->mWnd, NULL, 0, 0,
(rWindow.right-rWindow.left)-(rClient.right-rClient.left) + (rDlg.right-rDlg.left),
(rWindow.bottom-rWindow.top)-(rClient.bottom-rClient.top) + (rDlg.bottom-rDlg.top),
SWP_NOZORDER );
ShowWindow ( trans->mDlg, SW_SHOW );
UpdateWindow ( trans->mDlg );
break;
}
}
return DefWindowProc ( hWnd, msg, wParam, lParam );
}
INT_PTR CALLBACK rvGETransformer::DlgProc ( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
rvGETransformer* trans = (rvGETransformer*) GetWindowLong ( hWnd, GWL_USERDATA );
switch ( msg )
{
case WM_DESTROY:
if ( gTransHook )
{
UnhookWindowsHookEx( gTransHook );
}
gTransDlg = NULL;
break;
case WM_INITDIALOG:
trans = (rvGETransformer*) lParam;
trans->mDlg = hWnd;
SetWindowLong ( hWnd, GWL_USERDATA, lParam );
NumberEdit_Attach ( GetDlgItem ( hWnd, IDC_GUIED_ITEMRECTX ) );
NumberEdit_Attach ( GetDlgItem ( hWnd, IDC_GUIED_ITEMRECTY ) );
NumberEdit_Attach ( GetDlgItem ( hWnd, IDC_GUIED_ITEMRECTW ) );
NumberEdit_Attach ( GetDlgItem ( hWnd, IDC_GUIED_ITEMRECTH ) );
gTransDlg = hWnd;
gTransHook = SetWindowsHookEx( WH_GETMESSAGE, GetMsgProc, NULL, GetCurrentThreadId() );
break;
case WM_COMMAND:
if ( LOWORD ( wParam ) == IDOK )
{
SendMessage ( hWnd, WM_NEXTDLGCTL, 0, 0 );
}
else if ( HIWORD ( wParam ) == EN_KILLFOCUS && trans && trans->mWorkspace )
{
char temp[64];
int value;
GetWindowText ( GetDlgItem ( hWnd, LOWORD(wParam) ), temp, 64 );
value = atoi ( temp );
idRectangle rect = trans->mWorkspace->GetSelectionMgr().GetRect ( );
trans->mWorkspace->WindowToWorkspace ( rect );
// The transformer coords are relative to the botto most selected window's parent so
// adjust the rect accordingly
if ( trans->mRelative )
{
idRectangle& screenRect = rvGEWindowWrapper::GetWrapper ( trans->mRelative )->GetScreenRect ( );
rect.x -= screenRect.x;
rect.y -= screenRect.y;
}
switch ( LOWORD ( wParam ) )
{
case IDC_GUIED_ITEMRECTX:
if ( value - rect[0] )
{
trans->mWorkspace->AddModifierMove ( "Transform Move", value - rect[0], 0, false );
}
break;
case IDC_GUIED_ITEMRECTY:
if ( value - rect[1] )
{
trans->mWorkspace->AddModifierMove ( "Transform Move", 0, value - rect[1], false );
}
break;
case IDC_GUIED_ITEMRECTW:
if ( value - rect[2] )
{
trans->mWorkspace->AddModifierSize ( "Transform Size", 0, 0, value - rect[2], 0, false );
}
break;
case IDC_GUIED_ITEMRECTH:
if ( value - rect[3] )
{
trans->mWorkspace->AddModifierSize ( "Transform Size", 0, 0, 0, value - rect[3], false );
}
break;
}
}
break;
}
return FALSE;
}
/*
================
rvGETransformer::Show
Shows and hides the transformer window
================
*/
void rvGETransformer::Show ( bool visible )
{
gApp.GetOptions().SetTransformerVisible ( visible );
ShowWindow ( mWnd, visible?SW_SHOW:SW_HIDE );
Update ( );
}
/*
================
rvGETransformer::SetWorkspace
Sets a new workspace for the transformer window
================
*/
void rvGETransformer::SetWorkspace ( rvGEWorkspace* workspace )
{
mWorkspace = workspace;
Update ( );
}
/*
================
rvGETransformer::Update
Update the enabled/disabled states based on the selections and update
the rectangle coordinates
================
*/
void rvGETransformer::Update ( void )
{
bool state = false;
mRelative = NULL;
if ( mWorkspace && mWorkspace->GetSelectionMgr ( ).Num ( ) )
{
state = true;
mRelative = mWorkspace->GetSelectionMgr().GetBottomMost ( );
mRelative = mRelative->GetParent ( );
idRectangle rect = mWorkspace->GetSelectionMgr ( ).GetRect ( );
mWorkspace->WindowToWorkspace ( rect );
// Make the rectangle relative to the given parent
if ( mRelative )
{
idRectangle& screenRect = rvGEWindowWrapper::GetWrapper ( mRelative )->GetScreenRect ( );
rect.x -= screenRect.x;
rect.y -= screenRect.y;
}
SetWindowText ( GetDlgItem ( mDlg, IDC_GUIED_ITEMRECTX ), va("%d",(int)rect[0]) );
SetWindowText ( GetDlgItem ( mDlg, IDC_GUIED_ITEMRECTY ), va("%d",(int)rect[1]) );
SetWindowText ( GetDlgItem ( mDlg, IDC_GUIED_ITEMRECTW ), va("%d",(int)rect[2]) );
SetWindowText ( GetDlgItem ( mDlg, IDC_GUIED_ITEMRECTH ), va("%d",(int)rect[3]) );
}
if ( !state )
{
SetWindowText ( GetDlgItem ( mDlg, IDC_GUIED_ITEMRECTX ), "" );
SetWindowText ( GetDlgItem ( mDlg, IDC_GUIED_ITEMRECTY ), "" );
SetWindowText ( GetDlgItem ( mDlg, IDC_GUIED_ITEMRECTW ), "" );
SetWindowText ( GetDlgItem ( mDlg, IDC_GUIED_ITEMRECTH ), "" );
}
EnableWindow ( GetDlgItem ( mDlg, IDC_GUIED_ITEMRECTX ), state );
EnableWindow ( GetDlgItem ( mDlg, IDC_GUIED_ITEMRECTY ), state );
EnableWindow ( GetDlgItem ( mDlg, IDC_GUIED_ITEMRECTW ), state );
EnableWindow ( GetDlgItem ( mDlg, IDC_GUIED_ITEMRECTH ), state );
}
/*
================
rvGETransformer::GetMsgProc
Ensures normal dialog functions work in the transformer dialog
================
*/
LRESULT FAR PASCAL rvGETransformer::GetMsgProc ( int nCode, WPARAM wParam, LPARAM lParam )
{
LPMSG lpMsg = (LPMSG) lParam;
if ( nCode >= 0 && PM_REMOVE == wParam )
{
// Don't translate non-input events.
if ( lpMsg->message != WM_SYSCHAR && (lpMsg->message >= WM_KEYFIRST && lpMsg->message <= WM_KEYLAST) )
{
if ( IsDialogMessage( gTransDlg, lpMsg) )
{
// The value returned from this hookproc is ignored,
// and it cannot be used to tell Windows the message has been handled.
// To avoid further processing, convert the message to WM_NULL
// before returning.
lpMsg->message = WM_NULL;
lpMsg->lParam = 0;
lpMsg->wParam = 0;
}
}
}
return CallNextHookEx(gTransHook, nCode, wParam, lParam);
}

View File

@@ -0,0 +1,65 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GETRANSFORMER_H_
#define GETRANSFORMER_H_
class rvGETransformer
{
public:
rvGETransformer ( );
bool Create ( HWND parent, bool visible );
void Show ( bool show );
void SetWorkspace ( rvGEWorkspace* workspace );
void Update ( void );
HWND GetWindow ( void );
protected:
HWND mWnd;
HWND mDlg;
rvGEWorkspace* mWorkspace;
idWindow* mRelative;
private:
static LRESULT CALLBACK WndProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
static INT_PTR CALLBACK DlgProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
static LRESULT FAR PASCAL GetMsgProc ( int nCode, WPARAM wParam, LPARAM lParam );
};
ID_INLINE HWND rvGETransformer::GetWindow ( void )
{
return mWnd;
}
#endif // GETRANSFORMER_H_

View File

@@ -0,0 +1,551 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/guied_resource.h"
#include "../../renderer/tr_local.h"
#include "GEApp.h"
#include "GEViewer.h"
rvGEViewer::rvGEViewer ( )
{
mInterface = NULL;
mPaused = true;
mTime = 0;
}
bool rvGEViewer::Create ( HWND parent )
{
WNDCLASSEX wndClass;
// Make sure the alpha slider window class is registered
memset ( &wndClass, 0, sizeof(wndClass) );
wndClass.cbSize = sizeof(WNDCLASSEX);
wndClass.lpszClassName = "GUIED_VIEWER";
wndClass.lpfnWndProc = rvGEViewer::WndProc;
wndClass.hInstance = gApp.GetInstance ( );
wndClass.style = CS_OWNDC|CS_BYTEALIGNWINDOW|CS_VREDRAW|CS_HREDRAW;
wndClass.hbrBackground = (HBRUSH) (COLOR_3DFACE + 1);
RegisterClassEx ( &wndClass );
mWnd = CreateWindowEx ( WS_EX_TOOLWINDOW, "GUIED_VIEWER", "GUI Viewer",
WS_SYSMENU|WS_THICKFRAME|WS_CAPTION|WS_POPUP|WS_OVERLAPPED|WS_BORDER|WS_CLIPSIBLINGS|WS_CHILD,
CW_USEDEFAULT, CW_USEDEFAULT, SCREEN_WIDTH/2, SCREEN_HEIGHT/2,
parent, NULL, gApp.GetInstance(), this );
gApp.GetOptions().GetWindowPlacement ( "viewer", mWnd );
ShowWindow ( mWnd, SW_SHOW );
UpdateWindow ( mWnd );
return true;
}
void rvGEViewer::Play ( void )
{
if ( !mPaused )
{
return;
}
mLastTime = eventLoop->Milliseconds();
mPaused = false;
TBBUTTONINFO tbinfo;
tbinfo.cbSize = sizeof(TBBUTTONINFO);
tbinfo.dwMask = TBIF_COMMAND|TBIF_IMAGE;
tbinfo.iImage = 1;
tbinfo.idCommand = ID_GUIED_VIEWER_PAUSE;
SendMessage ( mToolbar, TB_SETBUTTONINFO, ID_GUIED_VIEWER_PLAY, (LPARAM)&tbinfo );
}
void rvGEViewer::Pause ( void )
{
if ( mPaused )
{
return;
}
mPaused = true;
TBBUTTONINFO tbinfo;
tbinfo.cbSize = sizeof(TBBUTTONINFO);
tbinfo.dwMask = TBIF_COMMAND|TBIF_IMAGE;
tbinfo.iImage = 0;
tbinfo.idCommand = ID_GUIED_VIEWER_PLAY;
SendMessage ( mToolbar, TB_SETBUTTONINFO, ID_GUIED_VIEWER_PAUSE, (LPARAM)&tbinfo );
}
bool rvGEViewer::Destroy ( void )
{
gApp.GetOptions().SetWindowPlacement ( "viewer", mWnd );
DestroyWindow ( mWnd );
return true;
}
bool rvGEViewer::OpenFile ( const char* filename )
{
idStr tempfile;
idStr ospath;
delete mInterface;
tempfile = filename;
tempfile.StripPath ();
tempfile.StripFileExtension ( );
tempfile = va("guis/temp.guied", tempfile.c_str() );
ospath = fileSystem->RelativePathToOSPath ( tempfile, "fs_basepath" );
// Make sure the gui directory exists
idStr createDir = ospath;
createDir.StripFilename ( );
CreateDirectory ( createDir, NULL );
SetFileAttributes ( ospath, FILE_ATTRIBUTE_NORMAL );
DeleteFile ( ospath );
CopyFile ( filename, ospath, FALSE );
SetFileAttributes ( ospath, FILE_ATTRIBUTE_NORMAL );
mInterface = reinterpret_cast< idUserInterfaceLocal* >( uiManager->FindGui( tempfile, true, true ) );
mInterface->SetStateString( "guied_item_0", "guied 1" );
mInterface->SetStateString( "guied_item_1", "guied 2" );
mInterface->SetStateString( "guied_item_2", "guied 3" );
mTime = 0;
mInterface->Activate ( true, mTime );
DeleteFile ( ospath );
Play ( );
return true;
}
/*
=======
MapKey
Map from windows to Doom keynums
=======
*/
static int MapKey (int key)
{
int result;
int modified;
bool is_extended;
modified = ( key >> 16 ) & 255;
if ( modified > 127 )
return 0;
if ( key & ( 1 << 24 ) ) {
is_extended = true;
}
else {
is_extended = false;
}
const unsigned char *scanToKey = Sys_GetScanTable();
result = scanToKey[modified];
// common->Printf( "Key: 0x%08x Modified: 0x%02x Extended: %s Result: 0x%02x\n", key, modified, (is_extended?"Y":"N"), result);
if ( is_extended ) {
switch ( result )
{
case K_PAUSE:
return K_KP_NUMLOCK;
case 0x0D:
return K_KP_ENTER;
case 0x2F:
return K_KP_SLASH;
case 0xAF:
return K_KP_PLUS;
}
}
else {
switch ( result )
{
case K_HOME:
return K_KP_HOME;
case K_UPARROW:
return K_KP_UPARROW;
case K_PGUP:
return K_KP_PGUP;
case K_LEFTARROW:
return K_KP_LEFTARROW;
case K_RIGHTARROW:
return K_KP_RIGHTARROW;
case K_END:
return K_KP_END;
case K_DOWNARROW:
return K_KP_DOWNARROW;
case K_PGDN:
return K_KP_PGDN;
case K_INS:
return K_KP_INS;
case K_DEL:
return K_KP_DEL;
}
}
return result;
}
LRESULT CALLBACK rvGEViewer::WndProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
rvGEViewer* viewer = (rvGEViewer*) GetWindowLong ( hwnd, GWL_USERDATA );
switch ( msg )
{
case WM_COMMAND:
switch ( LOWORD(wParam) )
{
case ID_GUIED_VIEWER_PLAY:
viewer->Play ( );
break;
case ID_GUIED_VIEWER_PAUSE:
viewer->Pause ( );
break;
}
break;
case WM_SIZE:
{
RECT rToolbar;
SendMessage ( viewer->mToolbar, TB_AUTOSIZE, 0, 0 );
GetWindowRect ( viewer->mToolbar, &rToolbar );
viewer->mToolbarHeight = rToolbar.bottom - rToolbar.top;
break;
}
case WM_ACTIVATE:
common->ActivateTool( LOWORD( wParam ) != WA_INACTIVE );
break;
case WM_ERASEBKGND:
return TRUE;
case WM_PAINT:
assert ( viewer );
viewer->HandlePaint ( wParam, lParam );
break;
case WM_LBUTTONDOWN:
if ( viewer->mInterface )
{
sysEvent_t event;
bool visuals;
ZeroMemory ( &event, sizeof(event) ) ;
event.evType = SE_KEY;
event.evValue = K_MOUSE1;
event.evValue2 = true;
viewer->mInterface->HandleEvent ( &event, viewer->mTime, &visuals );
}
break;
case WM_LBUTTONUP:
if ( viewer->mInterface )
{
sysEvent_t event;
bool visuals;
ZeroMemory ( &event, sizeof(event) ) ;
event.evType = SE_KEY;
event.evValue = K_MOUSE1;
event.evValue2 = false;
viewer->mInterface->HandleEvent ( &event, viewer->mTime, &visuals );
}
break;
case WM_KEYDOWN:
if ( viewer->mInterface )
{
sysEvent_t event;
bool visuals;
ZeroMemory ( &event, sizeof(event) ) ;
event.evType = SE_KEY;
event.evValue = MapKey( lParam );
event.evValue2 = true;
viewer->mInterface->HandleEvent ( &event, viewer->mTime, &visuals );
}
break;
case WM_SYSKEYUP:
case WM_KEYUP:
if ( viewer->mInterface )
{
sysEvent_t event;
bool visuals;
ZeroMemory ( &event, sizeof(event) ) ;
event.evType = SE_KEY;
event.evValue = MapKey( lParam );
event.evValue2 = false;
viewer->mInterface->HandleEvent ( &event, viewer->mTime, &visuals );
}
break;
case WM_CHAR:
if ( wParam == VK_ESCAPE )
{
SendMessage ( hwnd, WM_CLOSE, 0, 0 );
break;
}
if ( viewer->mInterface )
{
sysEvent_t event;
bool visuals;
ZeroMemory ( &event, sizeof(event) ) ;
event.evType = SE_CHAR;
event.evValue = wParam;
event.evValue2 = false;
viewer->mInterface->HandleEvent ( &event, viewer->mTime, &visuals );
}
break;
case WM_MOUSEMOVE:
if ( viewer->mInterface )
{
float x = (float)(LOWORD(lParam)) / (float)viewer->mWindowWidth * SCREEN_WIDTH;
float y = (float)(HIWORD(lParam)) / (float)(viewer->mWindowHeight - viewer->mToolbarHeight) * SCREEN_HEIGHT;
sysEvent_t event;
bool visuals;
ZeroMemory ( &event, sizeof(event) ) ;
event.evType = SE_MOUSE;
event.evValue = (int)x - viewer->mInterface->CursorX();
event.evValue2 = (int)y - viewer->mInterface->CursorY();
viewer->mInterface->HandleEvent ( &event, viewer->mTime, &visuals );
}
break;
case WM_CLOSE:
viewer->mInterface = NULL;
gApp.CloseViewer ( );
return 0;
case WM_CREATE:
{
CREATESTRUCT* cs = (CREATESTRUCT*) lParam;
SetWindowLong ( hwnd, GWL_USERDATA, (LONG)cs->lpCreateParams );
viewer = (rvGEViewer*)cs->lpCreateParams;
viewer->mWnd = hwnd;
viewer->SetupPixelFormat ( );
viewer->mToolbar = CreateWindowEx ( 0, TOOLBARCLASSNAME, "", CCS_BOTTOM|WS_CHILD|WS_VISIBLE,0,0,0,0, hwnd, (HMENU)IDR_GUIED_VIEWERTOOLBAR, gApp.GetInstance(), NULL );
// Send the TB_BUTTONSTRUCTSIZE message, which is required for backward compatibility.
SendMessage( viewer->mToolbar, TB_BUTTONSTRUCTSIZE, ( WPARAM )sizeof( TBBUTTON ), 0 );
SendMessage ( viewer->mToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(16,15) );
SendMessage ( viewer->mToolbar, TB_SETSTYLE, 0, SendMessage ( viewer->mToolbar, TB_GETSTYLE, 0, 0 ) | TBSTYLE_FLAT );
TBMETRICS tbmet;
tbmet.cbSize = sizeof(TBMETRICS);
SendMessage ( viewer->mToolbar, TB_GETMETRICS, 0, (LPARAM)&tbmet );
tbmet.cyPad = 0;
tbmet.cyBarPad = 0;
SendMessage ( viewer->mToolbar, TB_SETMETRICS, 0, (LPARAM)&tbmet );
// Add the bitmap containing button images to the toolbar.
TBADDBITMAP tbab;
tbab.hInst = win32.hInstance;
tbab.nID = IDR_GUIED_VIEWERTOOLBAR;
SendMessage( viewer->mToolbar, TB_ADDBITMAP, (WPARAM)4, (LPARAM) &tbab );
TBBUTTON tbb[4];
tbb[0].fsStyle = BTNS_SEP;
tbb[0].fsState = 0;
tbb[1].idCommand = ID_GUIED_VIEWER_START;
tbb[1].iBitmap = 2;
tbb[1].fsState = 0;
tbb[1].fsStyle = BTNS_BUTTON;
tbb[1].dwData = 0;
tbb[1].iString = -1;
tbb[2].idCommand = ID_GUIED_VIEWER_PAUSE;
tbb[2].iBitmap = 1;
tbb[2].fsState = TBSTATE_ENABLED;
tbb[2].fsStyle = BTNS_BUTTON;
tbb[2].dwData = 0;
tbb[2].iString = -1;
tbb[3].fsStyle = BTNS_SEP;
tbb[3].fsState = 0;
SendMessage( viewer->mToolbar, TB_ADDBUTTONS, (WPARAM)4, (LPARAM) &tbb );
break;
}
case WM_SETCURSOR:
SetCursor ( NULL );
break;
}
return DefWindowProc ( hwnd, msg, wParam, lParam );
}
LRESULT rvGEViewer::HandlePaint ( WPARAM wParam, LPARAM lParam )
{
HDC dc;
PAINTSTRUCT ps;
dc = BeginPaint ( mWnd, &ps );
Render ( dc );
EndPaint ( mWnd, &ps );
return 1;
}
/*
================
rvGEViewer::SetupPixelFormat
Setup the pixel format for the opengl context
================
*/
bool rvGEViewer::SetupPixelFormat ( void )
{
HDC hDC = GetDC ( mWnd );
bool result = true;
int pixelFormat = ChoosePixelFormat(hDC, &win32.pfd);
if (pixelFormat > 0)
{
if (SetPixelFormat(hDC, pixelFormat, &win32.pfd) == NULL)
{
result = false;
}
}
else
{
result = false;
}
ReleaseDC ( mWnd, hDC );
return result;
}
void rvGEViewer::Render ( HDC dc )
{
int frontEnd;
int backEnd;
// Switch GL contexts to our dc
if (!qwglMakeCurrent( dc, win32.hGLRC ))
{
common->Printf("ERROR: wglMakeCurrent failed.. Error:%i\n", qglGetError());
common->Printf("Please restart Q3Radiant if the Map view is not working\n");
return;
}
if ( !mPaused )
{
mTime += eventLoop->Milliseconds() - mLastTime;
mLastTime = eventLoop->Milliseconds();
}
RECT rClient;
RECT rToolbar;
GetClientRect ( mWnd, &rClient );
GetClientRect ( mToolbar, &rToolbar );
mWindowWidth = rClient.right - rClient.left;
mWindowHeight = rClient.bottom - rClient.top;
qglViewport(0, 0, mWindowWidth, mWindowHeight );
qglScissor(0, 0, mWindowWidth, mWindowHeight );
qglClearColor ( 0, 0, 0, 0 );
qglDisable(GL_DEPTH_TEST);
qglDisable(GL_CULL_FACE);
qglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Render the workspace below
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
qglOrtho(0,mWindowWidth, mWindowHeight, 0, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
if ( mInterface )
{
viewDef_t viewDef;
memset ( &viewDef, 0, sizeof(viewDef) );
tr.viewDef = &viewDef;
viewDef.renderView.x = 0;
viewDef.renderView.y = mToolbarHeight;
viewDef.renderView.width = mWindowWidth;
viewDef.renderView.height = mWindowHeight - mToolbarHeight;
viewDef.scissor.x1 = 0;
viewDef.scissor.y1 = 0; // (rToolbar.bottom-rToolbar.top);
viewDef.scissor.x2 = mWindowWidth;
viewDef.scissor.y2 = mWindowHeight;
viewDef.isEditor = true;
// Prepare the renderSystem view to draw the GUI in
renderSystem->BeginFrame(mWindowWidth, mWindowHeight );
// Draw the gui
mInterface->Redraw ( mTime );
// We are done using the renderSystem now
renderSystem->EndFrame( &frontEnd, &backEnd );
}
qglFinish ( );
qwglSwapBuffers(dc);
}
void rvGEViewer::RunFrame ( void )
{
if ( !mPaused )
{
HDC hDC = GetDC ( mWnd );
Render ( hDC );
ReleaseDC ( mWnd, hDC );
}
}

View File

@@ -0,0 +1,76 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GEVIEWER_H_
#define GEVIEWER_H_
class rvGEViewer
{
public:
rvGEViewer ( );
bool Create ( HWND parent );
bool Destroy ( void );
bool OpenFile ( const char* filename );
void RunFrame ( void );
HWND GetWindow ( void );
protected:
void Render ( HDC dc );
void Play ( void );
void Pause ( void );
HWND mWnd;
int mWindowWidth;
int mWindowHeight;
int mToolbarHeight;
idUserInterfaceLocal* mInterface;
bool mPaused;
HWND mToolbar;
int mLastTime;
int mTime;
LRESULT HandlePaint ( WPARAM wParam, LPARAM lParam );
private:
bool SetupPixelFormat ( void );
static LRESULT CALLBACK WndProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
};
ID_INLINE HWND rvGEViewer::GetWindow ( void )
{
return mWnd;
}
#endif // GEVIEWER_H_

View File

@@ -0,0 +1,590 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../sys/win32/rc/guied_resource.h"
#include "../../renderer/tr_local.h"
#include "../../ui/EditWindow.h"
#include "../../ui/ListWindow.h"
#include "../../ui/BindWindow.h"
#include "../../ui/RenderWindow.h"
#include "../../ui/ChoiceWindow.h"
#include "GEApp.h"
rvGEWindowWrapper::rvGEWindowWrapper( idWindow *window,EWindowType type ) {
assert(window);
mWindow = window;
mFlippedHorz = false;
mFlippedVert = false;
mHidden = false;
mDeleted = false;
mSelected = false;
mType = type;
mExpanded = false;
mOldVisible = false;
mMoveable = true;
if ( dynamic_cast< idEditWindow*>(window) ) {
mType = WT_EDIT;
} else if ( dynamic_cast< idListWindow*>(window) ) {
mType = WT_LIST;
} else if ( dynamic_cast< idBindWindow*>(window) ) {
mType = WT_BIND;
} else if ( dynamic_cast< idRenderWindow*>(window) ) {
mType = WT_RENDER;
} else if ( dynamic_cast< idChoiceWindow*>(window) ) {
mType = WT_CHOICE;
} else {
mType = WT_NORMAL;
}
// Attach the wrapper to the window by adding a defined variable
// with the wrappers pointer stuffed into an integer
idWinInt *var = new idWinInt();
int x = (int)this;
*var = x;
var->SetEval(false);
var->SetName("guied_wrapper");
mWindow->AddDefinedVar(var);
SetStateKey("name", mWindow->GetName(), false);
}
/*
================
rvGEWindowWrapper::GetWrapper
Static method that returns the window wrapper for the given window class
================
*/
rvGEWindowWrapper * rvGEWindowWrapper::GetWrapper( idWindow *window ) {
idWinInt *var;
var = dynamic_cast< idWinInt*>(window->GetWinVarByName("guied_wrapper"));
return var ? ((rvGEWindowWrapper *) (int) (*var)) : NULL;
}
/*
================
rvGEWindowWrapper::UpdateRect
Updates the gui editor's representation of the window rectangle from the
windows rectangle
================
*/
void rvGEWindowWrapper::UpdateRect( void ) {
idVec4 rect;
idWinRectangle *winrect;
winrect = dynamic_cast< idWinRectangle*>(mWindow->GetWinVarByName("rect"));
assert(winrect);
rect = winrect->ToVec4();
mFlippedHorz = false;
mFlippedVert = false;
if ( rect[2] < 0 ) {
mFlippedHorz = true;
rect[2] *= -1;
}
if ( rect[3] < 0 ) {
mFlippedVert = true;
rect[3] *= -1;
}
mClientRect = rect;
CalcScreenRect();
const char *rstr = mState.GetString("rect", "0,0,0,0");
mMoveable = !IsExpression(rstr);
}
/*
================
rvGEWindowWrapper::CalcScreenRect
Calculates the screen rectangle from the client rectangle by running through
the parent windows and adding their offsets
================
*/
void rvGEWindowWrapper::CalcScreenRect( void ) {
idWindow *parent;
mScreenRect = mClientRect;
if ( NULL != (parent = mWindow->GetParent()) ) {
rvGEWindowWrapper *wrapper = GetWrapper(parent);
assert(wrapper);
mScreenRect[0] += wrapper->GetScreenRect()[0];
mScreenRect[1] += wrapper->GetScreenRect()[1];
}
// Since our screen rectangle has changed we need to tell all our our children to update
// their screen rectangles as well.
int i;
int count;
rvGEWindowWrapper *pwrapper;
pwrapper = rvGEWindowWrapper::GetWrapper(mWindow);
for ( count = pwrapper->GetChildCount(), i = 0; i < count; i ++ ) {
rvGEWindowWrapper *wrapper;
wrapper = rvGEWindowWrapper::GetWrapper(pwrapper->GetChild(i));
// Usually we assert if there is no wrapper but since this method is called
// when the wrappers are being attached to the windows there may be no wrappers
// for any of the children.
if ( !wrapper ) {
continue;
}
wrapper->CalcScreenRect();
}
}
/*
================
rvGEWindowWrapper::SetRect
Sets the wrapper's rectangle and the attached windows rectangle as well
================
*/
void rvGEWindowWrapper::SetRect( idRectangle &rect ) {
const char *s;
mClientRect = rect;
CalcScreenRect();
s = va("%d,%d,%d,%d", (int) (rect.x + 0.5f), (int) (rect.y + 0.5f), (int) ((rect.w + 0.5f) * (mFlippedHorz ? -1 : 1)), (int) ((rect.h + 0.5f) * (mFlippedVert ? -1 : 1)));
mState.Set("rect", s);
UpdateWindowState();
}
/*
================
rvGEWindowWrapper::SetHidden
Sets the wrappers hidden state
================
*/
void rvGEWindowWrapper::SetHidden( bool h ) {
mHidden = h;
UpdateWindowState();
}
/*
================
rvGEWindowWrapper::SetDeleted
Sets the deleted state of the wrapper which in turns sets whether or
not the window is visible
================
*/
void rvGEWindowWrapper::SetDeleted( bool del ) {
mDeleted = del;
UpdateWindowState();
}
/*
================
rvGEWindowWrapper::SetState
Sets the window state from the given dictionary
================
*/
void rvGEWindowWrapper::SetState( const idDict &dict ) {
mState.Clear();
mState.Copy(dict);
// Push the window state to the window itself
UpdateWindowState();
// Update the internal rectangle since it may have changed in the state
UpdateRect();
}
/*
================
rvGEWindowWrapper::SetStateKey
Sets the given state key and updates the
================
*/
void rvGEWindowWrapper::SetStateKey( const char *key,const char *value,bool update ) {
mState.Set(key, value);
if ( update ) {
UpdateWindowState();
// Make sure the rectangle gets updated if its changing
if ( !idStr::Icmp(key, "rect") ) {
UpdateRect();
}
}
}
/*
================
rvGEWindowWrapper::DeleteStateKey
Sets the given state key and updates the
================
*/
void rvGEWindowWrapper::DeleteStateKey( const char *key ) {
if ( !idStr::Icmp(key, "rect") || !idStr::Icmp(key, "name") ) {
return;
}
mState.Delete(key);
}
/*
================
rvGEWindowWrapper::UpdateWindowState
Updates the windows real state with wrappers internal state. Visibility is
handled specially
================
*/
void rvGEWindowWrapper::UpdateWindowState( void ) {
idStr realVisible;
bool tempVisible;
// int i;
realVisible = mState.GetString("visible", "1");
tempVisible = atoi(realVisible) ? true : false;
if ( tempVisible != mOldVisible ) {
mHidden = !tempVisible;
mOldVisible = tempVisible;
}
tempVisible = !mDeleted && !mHidden;
// Temporarily change the visible state so we can hide/unhide the window
mState.Set("visible", tempVisible ? "1" : "0");
mWindow->UpdateFromDictionary(mState);
// Put the visible state back to the real value
mState.Set("visible", realVisible);
}
/*
================
rvGEWindowWrapper::WindowFromPoint
Returns the topmost window under the given point
================
*/
idWindow * rvGEWindowWrapper::WindowFromPoint( float x,float y,bool visibleOnly ) {
int count;
int i;
rvGEWindowWrapper *pwrapper;
// If the window isnt visible then skip it
if ( visibleOnly && (mHidden || mDeleted) ) {
return NULL;
}
// Now check our children next
pwrapper = GetWrapper(mWindow);
count = pwrapper->GetChildCount();
for ( i = count - 1; i >= 0; i -- ) {
rvGEWindowWrapper *wrapper;
idWindow *child;
child = pwrapper->GetChild(i);
assert(child);
wrapper = rvGEWindowWrapper::GetWrapper(child);
if ( !wrapper ) {
continue;
}
if ( child = wrapper->WindowFromPoint(x, y) ) {
return child;
}
}
// We have to check this last because a child could be out outside of the parents
// rectangle and we still want it selectable.
if ( !mScreenRect.Contains(x, y) ) {
return NULL;
}
return mWindow;
}
/*
================
rvGEWindowWrapper::StringToWindowType
Converts the given string to a window type
================
*/
rvGEWindowWrapper::EWindowType rvGEWindowWrapper::StringToWindowType( const char *string ) {
if ( !idStr::Icmp(string, "windowDef") ) {
return WT_NORMAL;
} else if ( !idStr::Icmp(string, "editDef") ) {
return WT_EDIT;
} else if ( !idStr::Icmp(string, "choiceDef") ) {
return WT_CHOICE;
} else if ( !idStr::Icmp(string, "sliderDef") ) {
return WT_SLIDER;
} else if ( !idStr::Icmp(string, "bindDef") ) {
return WT_BIND;
} else if ( !idStr::Icmp(string, "listDef") ) {
return WT_LIST;
} else if ( !idStr::Icmp(string, "renderDef") ) {
return WT_RENDER;
} else if ( !idStr::Icmp(string, "htmlDef") ) {
return WT_HTML;
}
return WT_UNKNOWN;
}
/*
================
rvGEWindowWrapper::WindowTypeToString
Converts the given window type to a string
================
*/
const char * rvGEWindowWrapper::WindowTypeToString( EWindowType type ) {
static const char *typeNames[] = {
"Unknown", "windowDef", "editDef", "htmlDef", "choiceDef", "sliderDef", "bindDef", "listDef", "renderDef"
};
return typeNames[(int) type];
}
/*
================
rvGEWindowWrapper::GetChildCount
Returns the number of children the window being wrapped has
================
*/
int rvGEWindowWrapper::GetChildCount( void ) {
if ( !CanHaveChildren() ) {
return 0;
}
return mWindow->GetChildCount();
}
/*
================
rvGEWindowWrapper::EnumChildren
Enumerates over the child windows while properly ignoring any that
are not wrapped.
================
*/
bool rvGEWindowWrapper::EnumChildren( PFNENUMCHILDRENPROC proc,void *data ) {
int count;
int i;
if ( !CanHaveChildren() ) {
return false;
}
for ( count = GetChildCount(), i = 0; i < count; i ++ ) {
if ( !proc(rvGEWindowWrapper::GetWrapper(GetChild(i)), data) ) {
return false;
}
}
return true;
}
/*
================
rvGEWindowWrapper::CanHaveChildren
Returns true if the window is allowed to have child windows
================
*/
bool rvGEWindowWrapper::CanHaveChildren( void ) {
if ( mType == WT_HTML || mType == WT_LIST ) {
return false;
}
return true;
}
/*
================
rvGEWindowWrapper::GetDepth
Returns the depth of the wrapped window
================
*/
int rvGEWindowWrapper::GetDepth( void ) {
idWindow *parent;
int depth;
for ( depth = 0, parent = mWindow->GetParent(); parent; parent = parent->GetParent(), depth++ )
;
return depth;
}
/*
================
rvGEWindowWrapper::Expand
Expand the window in the navigator and all of its parents too
================
*/
bool rvGEWindowWrapper::Expand( void ) {
bool result;
if ( mWindow->GetParent() ) {
result = rvGEWindowWrapper::GetWrapper(mWindow->GetParent())->Expand();
} else {
result = false;
}
if ( mExpanded || !CanHaveChildren() || !GetChildCount() ) {
return result;
}
mExpanded = true;
return true;
}
/*
================
rvGEWindowWrapper::Collapse
Returns the depth of the wrapped window
================
*/
bool rvGEWindowWrapper::Collapse( void ) {
bool result;
if ( mWindow->GetParent() ) {
result = rvGEWindowWrapper::GetWrapper(mWindow->GetParent())->Expand();
} else {
result = false;
}
if ( !mExpanded ) {
return result;
}
mExpanded = false;
return true;
}
/*
================
rvGEWindowWrapper::Finish
After a the windwo wrapper is attached to a window and the window is parsed
the finish method is called to finish up any last details
================
*/
void rvGEWindowWrapper::Finish( void ) {
mOldVisible = ((bool) * dynamic_cast< idWinBool*>(mWindow->GetWinVarByName("visible")));
mHidden = mOldVisible ? false : true;
UpdateRect();
}
/*
================
rvGEWindowWrapper::Finish
After a the windwo wrapper is attached to a window and the window is parsed
the finish method is called to finish up any last details
================
*/
bool rvGEWindowWrapper::VerfiyStateKey( const char *name,const char *value,idStr *result ) {
idStr old;
bool failed;
idParser src(value, strlen(value), "", LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT);
// Save the current value
old = mState.GetString(name);
failed = false;
// Try to parse in the value
try {
if ( !mWindow->ParseInternalVar(name, &src) ) {
// Kill the old register since the parse reg entry will add a new one
if ( !mWindow->ParseRegEntry(name, &src) ) {
failed = true;
}
}
} catch ( idException &) {
failed = true;
}
// Restore the old value
idParser src2(old, old.Length(), "", LEXFL_NOFATALERRORS | LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT);
if ( !mWindow->ParseInternalVar(name, &src2) ) {
if ( !mWindow->ParseRegEntry(name, &src2) ) {
}
}
// Check to see if the old value matches the new value
idStr before;
idStr after;
before = value;
before.StripTrailingWhitespace();
src.GetStringFromMarker(after);
after.StripTrailingWhitespace();
if ( result ) {
*result = after;
}
if ( failed || before.Cmp(after) ) {
return false;
}
return true;
}

View File

@@ -0,0 +1,223 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GEWINDOWWRAPPER_H_
#define GEWINDOWWRAPPER_H_
class idWindow;
class rvGEWindowWrapper;
typedef bool (*PFNENUMCHILDRENPROC) ( rvGEWindowWrapper* wrapper, void* data );
class rvGEWindowWrapper
{
public:
enum EWindowType
{
WT_UNKNOWN,
WT_NORMAL,
WT_EDIT,
WT_HTML,
WT_CHOICE,
WT_SLIDER,
WT_BIND,
WT_LIST,
WT_RENDER,
WT_TRANSITION
};
rvGEWindowWrapper ( idWindow* window, EWindowType type );
static rvGEWindowWrapper* GetWrapper ( idWindow* window );
idWindow* GetWindow ( void );
idDict& GetStateDict ( void );
idDict& GetVariableDict ( void );
idDict& GetScriptDict ( void );
idRectangle& GetClientRect ( void );
idRectangle& GetScreenRect ( void );
EWindowType GetWindowType ( void );
int GetChildCount ( void );
int GetDepth ( void );
idWindow* GetChild ( int index );
void SetRect ( idRectangle& rect );
void SetState ( const idDict& dict );
void SetStateKey ( const char* key, const char* value, bool update = true );
void DeleteStateKey ( const char* key );
bool VerfiyStateKey ( const char* name, const char* value, idStr* result = NULL );
bool IsFlippedHorz ( void );
bool IsFlippedVert ( void );
bool IsHidden ( void );
bool IsDeleted ( void );
bool IsSelected ( void );
bool IsExpanded ( void );
bool CanHaveChildren ( void );
bool CanMoveAndSize ( void );
void SetFlippedHorz ( bool f );
void SetFlippedVert ( bool f );
void SetHidden ( bool v );
void SetDeleted ( bool del );
void SetSelected ( bool sel );
void SetWindowType ( EWindowType type );
bool Expand ( void );
bool Collapse ( void );
bool EnumChildren ( PFNENUMCHILDRENPROC proc, void* data );
idWindow* WindowFromPoint ( float x, float y, bool visibleOnly = true );
void Finish ( void );
static EWindowType StringToWindowType ( const char* string );
static const char* WindowTypeToString ( EWindowType type );
protected:
void CalcScreenRect ( void );
void UpdateRect ( void );
void UpdateWindowState ( void );
idRectangle mClientRect;
idRectangle mScreenRect;
idWindow* mWindow;
idDict mState;
idDict mVariables;
idDict mScripts;
bool mFlippedHorz;
bool mFlippedVert;
bool mHidden;
bool mDeleted;
bool mSelected;
bool mExpanded;
bool mOldVisible;
bool mMoveable;
EWindowType mType;
};
ID_INLINE idDict& rvGEWindowWrapper::GetStateDict ( void )
{
return mState;
}
ID_INLINE idDict& rvGEWindowWrapper::GetVariableDict ( void )
{
return mVariables;
}
ID_INLINE idDict& rvGEWindowWrapper::GetScriptDict ( void )
{
return mScripts;
}
ID_INLINE bool rvGEWindowWrapper::IsFlippedHorz ( void )
{
return mFlippedHorz;
}
ID_INLINE bool rvGEWindowWrapper::IsFlippedVert ( void )
{
return mFlippedVert;
}
ID_INLINE bool rvGEWindowWrapper::IsExpanded ( void )
{
return mExpanded;
}
ID_INLINE void rvGEWindowWrapper::SetFlippedHorz ( bool f )
{
mFlippedHorz = f;
}
ID_INLINE void rvGEWindowWrapper::SetFlippedVert ( bool f )
{
mFlippedVert = f;
}
ID_INLINE idRectangle& rvGEWindowWrapper::GetClientRect ( void )
{
return mClientRect;
}
ID_INLINE idRectangle& rvGEWindowWrapper::GetScreenRect ( void )
{
return mScreenRect;
}
ID_INLINE bool rvGEWindowWrapper::IsHidden ( void )
{
return mHidden;
}
ID_INLINE bool rvGEWindowWrapper::IsDeleted ( void )
{
return mDeleted;
}
ID_INLINE bool rvGEWindowWrapper::IsSelected ( void )
{
return mSelected;
}
ID_INLINE void rvGEWindowWrapper::SetSelected ( bool sel )
{
mSelected = sel;
}
ID_INLINE rvGEWindowWrapper::EWindowType rvGEWindowWrapper::GetWindowType ( void )
{
return mType;
}
ID_INLINE void rvGEWindowWrapper::SetWindowType ( rvGEWindowWrapper::EWindowType type )
{
mType = type;
}
ID_INLINE idWindow* rvGEWindowWrapper::GetChild ( int index )
{
return mWindow->GetChild ( index );
}
ID_INLINE idWindow* rvGEWindowWrapper::GetWindow ( void )
{
return mWindow;
}
ID_INLINE bool rvGEWindowWrapper::CanMoveAndSize ( void )
{
return mMoveable;
}
#endif // GEWINDOWWRAPPER_H_

View File

@@ -0,0 +1,47 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../ui/EditWindow.h"
#include "../../ui/ListWindow.h"
#include "../../ui/BindWindow.h"
#include "../../ui/RenderWindow.h"
#include "../../ui/ChoiceWindow.h"
#include "GEWindowWrapper.h"
static rvGEWindowWrapper stub_wrap( NULL, rvGEWindowWrapper::WT_UNKNOWN );
rvGEWindowWrapper::rvGEWindowWrapper( idWindow* window, EWindowType type ) { }
rvGEWindowWrapper* rvGEWindowWrapper::GetWrapper ( idWindow* window ) { return &stub_wrap; }
void rvGEWindowWrapper::SetStateKey( const char*, const char*, bool ) { }
void rvGEWindowWrapper::Finish() { }

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,338 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef _GEWORKSPACE_H_
#define _GEWORKSPACE_H_
#ifndef GESELECTIONMGR_H_
#include "GESelectionMgr.h"
#endif // GESELECTIONMGR_H_
#ifndef GEMODIFIERSTACK_H_
#include "GEModifierStack.h"
#endif // GEMODIFIERSTACK_H_
class rvGEApp;
class rvGEClipboardItem
{
public:
idDict mStateDict;
idDict mScriptDict;
idDict mVarDict;
};
class rvGEWorkspace
{
public:
enum ESourceControlState
{
SCS_NONE,
SCS_CHECKEDOUT,
SCS_CHECKEDIN,
};
enum EZoomLevel
{
ZOOM_MIN,
ZOOM_25,
ZOOM_33,
ZOOM_50,
ZOOM_66,
ZOOM_100,
ZOOM_150,
ZOOM_200,
ZOOM_300,
ZOOM_MAX
};
enum EItemAlign
{
ALIGN_LEFTS,
ALIGN_CENTERS,
ALIGN_RIGHTS,
ALIGN_TOPS,
ALIGN_MIDDLES,
ALIGN_BOTTOMS,
};
rvGEWorkspace ( rvGEApp* app );
~rvGEWorkspace ( );
// Attach the workspace to a win32 window
bool Attach ( HWND wnd );
// Detach the workspace from the current win32 window
void Detach ( void );
bool NewFile ( void );
bool LoadFile ( const char* filename, idStr* error = NULL );
bool SaveFile ( const char* filename );
const char* GetFilename ( void );
// Source control methods
bool CheckOut ( void );
bool CheckIn ( void );
bool UndoCheckout ( void );
ESourceControlState GetSourceControlState ( void );
void Render ( HDC hDC );
rvGEApp* GetApplication ( void );
void HideSelected ( void );
void UnhideSelected ( void );
void DeleteSelected ( void );
bool EditSelectedProperties ( void );
bool EditSelectedScripts ( void );
void BringSelectedForward ( void );
void BringSelectedToFront ( void );
void SendSelectedBackward ( void );
void SendSelectedToBack ( void );
void AlignSelected ( EItemAlign align );
void MakeSelectedSameSize ( bool width, bool height );
void MakeSelectedAChild ( void );
bool CanHide ( void );
void ShowHidden ( void );
void HideWindow ( idWindow* window );
void UnhideWindow ( idWindow* window );
EZoomLevel ZoomIn ( void );
EZoomLevel ZoomOut ( void );
EZoomLevel GetZoom ( void );
float GetZoomScale ( void );
static rvGEWorkspace* GetWorkspace ( HWND wnd );
rvGEModifierStack& GetModifierStack ( void );
idUserInterfaceLocal* GetInterface ( void );
rvGESelectionMgr& GetSelectionMgr ( void );
idList<rvGEClipboardItem*> GetClipboard ( void );
HWND GetWindow ( void );
void HandleMessage ( UINT msg, WPARAM wParam, LPARAM lParam );
idVec2& WindowToWorkspace ( idVec2& point );
idVec2& WorkspaceToWindow ( idVec2& point );
idRectangle& WindowToWorkspace ( idRectangle& rect );
idRectangle& WorkspaceToWindow ( idRectangle& rect );
bool IsModified ( void );
bool IsNew ( void );
idWindow* AddWindow ( rvGEWindowWrapper::EWindowType type );
// void Cut ( void );
void Copy ( void );
void Paste ( void );
void AddModifierMove ( const char* modName, float x, float y, bool snap );
void AddModifierSize ( const char* modName, float l, float t, float r, float b, bool snap );
void SetModified ( bool mod );
protected:
enum EModifierType
{
MOD_UNKNOWN,
MOD_DELETE,
MOD_HIDE,
MOD_UNHIDE,
MOD_SHOWHIDDEN,
MOD_SEND_BACKWARD,
MOD_BRING_FORWARD,
MOD_SEND_BACK,
MOD_BRING_FRONT,
};
bool SetupPixelFormat ( void );
void UpdateSelections ( void );
// Additional rendering routines
void RenderGrid ( void );
// File related methods
void WriteTabs ( idFile* file, int depth );
bool WriteWindow ( idFile* file, int depth, idWindow* window );
// Message handlers
int HandleRButtonDown ( WPARAM wParam, LPARAM lParam );
int HandleLButtonDown ( WPARAM wParam, LPARAM lParam );
int HandleLButtonUp ( WPARAM wParam, LPARAM lParam );
int HandleLButtonDblClk ( WPARAM wParam, LPARAM lParam );
int HandleMButtonDown ( WPARAM wParam, LPARAM lParam );
int HandleMButtonUp ( WPARAM wParam, LPARAM lParam );
int HandleMouseMove ( WPARAM wParam, LPARAM lParam );
int HandleKeyDown ( WPARAM wParam, LPARAM lParam );
int HandleScroll ( int scrollbar, WPARAM wParam, LPARAM lParam );
int HandleCommand ( WPARAM wParam, LPARAM lParam );
// General protected functions
void UpdateScrollbars ( void );
void UpdateRectangle ( bool useScroll = true );
void UpdateCursor ( void );
void UpdateCursor ( float x, float y );
void UpdateCursor ( rvGESelectionMgr::EHitTest type );
void UpdateTitle ( void );
idWindow* NewWindow ( idDict* state, rvGEWindowWrapper::EWindowType type );
void Scroll ( int scrollbar, int offset );
// Modifier methods
void AddModifierMoveNudge( float x, float y, bool snap );
void AddModifierSizeNudge( float w, float h, bool snap );
void AddModifierShowAll ( void );
void AddModifiers ( EModifierType type, ... );
void AddModifiers ( idWindow* window, EModifierType type, ... );
rvGEModifier* CreateModifier ( EModifierType type, idWindow* window, va_list args );
idUserInterfaceLocal* mInterface;
HWND mWnd;
int mZoom;
idRectangle mRect;
bool mScrollHorz;
bool mScrollVert;
int mWindowWidth;
int mWindowHeight;
idStr mFilename;
rvGEModifierStack mModifiers;
rvGESelectionMgr mSelections;
rvGESelectionMgr::EHitTest mDragType;
idVec2 mDragPoint;
int mDragTime;
bool mDragX;
bool mDragY;
bool mDragScroll;
rvGEApp* mApplication;
static idList<rvGEClipboardItem*> mClipboard;
idList<idWindow*> mSelectMenu;
idVec2 mSelectMenuPos;
private:
static bool CleanupEnumProc ( rvGEWindowWrapper* wrapper, void* data );
static bool ShowAllEnumProc ( rvGEWindowWrapper* wrapper, void* data );
static bool BuildSelectMenuEnumProc ( rvGEWindowWrapper* wrapper, void* data );
// States
bool mModified;
bool mNew;
bool mDontAdd;
ESourceControlState mSourceControlState;
// Resources
HCURSOR mHandCursor;
};
ID_INLINE rvGEWorkspace::EZoomLevel rvGEWorkspace::GetZoom ( void )
{
return (EZoomLevel)mZoom;
}
ID_INLINE rvGEWorkspace* rvGEWorkspace::GetWorkspace ( HWND wnd )
{
return (rvGEWorkspace*) GetWindowLong ( wnd, GWL_USERDATA );
}
ID_INLINE const char* rvGEWorkspace::GetFilename ( void )
{
return mFilename;
}
ID_INLINE bool rvGEWorkspace::IsModified ( void )
{
return mModified;
}
ID_INLINE bool rvGEWorkspace::IsNew ( void )
{
return mNew;
}
ID_INLINE rvGEModifierStack& rvGEWorkspace::GetModifierStack ( void )
{
return mModifiers;
}
ID_INLINE rvGESelectionMgr& rvGEWorkspace::GetSelectionMgr ( void )
{
return mSelections;
}
ID_INLINE void rvGEWorkspace::ShowHidden ( void )
{
AddModifierShowAll ( );
}
ID_INLINE void rvGEWorkspace::AddModifierMoveNudge ( float x, float y, bool snap )
{
AddModifierMove ( "Nudge Move", x, y, snap );
}
ID_INLINE void rvGEWorkspace::AddModifierSizeNudge ( float w, float h, bool snap )
{
AddModifierSize ( "Nudge Size", 0, 0, w, h, snap );
}
ID_INLINE idUserInterfaceLocal* rvGEWorkspace::GetInterface ( void )
{
return mInterface;
}
ID_INLINE rvGEApp* rvGEWorkspace::GetApplication ( void )
{
return mApplication;
}
ID_INLINE HWND rvGEWorkspace::GetWindow ( void )
{
return mWnd;
}
ID_INLINE idList<rvGEClipboardItem*> rvGEWorkspace::GetClipboard ( void )
{
return mClipboard;
}
ID_INLINE rvGEWorkspace::ESourceControlState rvGEWorkspace::GetSourceControlState ( void )
{
return mSourceControlState;
}
#endif // _GEWORKSPACE_H_

View File

@@ -0,0 +1,395 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "GEApp.h"
bool GECheckInDlg_DoModal ( HWND parent, const char* filename, idStr* comment );
/*
================
rvGEWorkspace::SaveFile
Writes the contents of the open gui file to disk
================
*/
bool rvGEWorkspace::SaveFile ( const char* filename )
{
idFile* file;
idWindow* window;
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_WAIT ) ) );
mFilename = filename;
// Since quake can only write to its path we will write a temp file then copy it over
idStr tempfile;
idStr ospath;
tempfile = "guis/temp.guied";
ospath = fileSystem->RelativePathToOSPath ( tempfile, "fs_basepath" );
// Open the output file for write
if ( !(file = fileSystem->OpenFileWrite ( tempfile ) ) )
{
int error = GetLastError ( );
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_ARROW ) ) );
return false;
}
window = mInterface->GetDesktop ( );
WriteWindow ( file, 1, window );
fileSystem->CloseFile ( file );
if ( !CopyFile ( ospath, filename, FALSE ) )
{
DeleteFile ( ospath );
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_ARROW ) ) );
return false;
}
DeleteFile ( ospath );
mFilename = filename;
mModified = false;
mNew = false;
UpdateTitle ( );
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_ARROW ) ) );
return true;
}
/*
================
rvGEWorkspace::WriteTabs
Writes the given number of tabs to the given file
================
*/
void rvGEWorkspace::WriteTabs ( idFile* file, int depth )
{
int i;
for ( i = 0; i < depth; i ++ )
{
file->Write ( "\t", 1 );
}
}
/*
================
rvGEWorkspace::WriteWindow
Writes the contents of the given window to the file
================
*/
bool rvGEWorkspace::WriteWindow ( idFile* file, int depth, idWindow* window )
{
idStr out;
rvGEWindowWrapper* wrapper;
int i;
wrapper = rvGEWindowWrapper::GetWrapper ( window );
if ( !wrapper )
{
return true;
}
if ( wrapper->IsDeleted ( ) )
{
return true;
}
// Window def header
WriteTabs ( file, depth - 1 );
out = wrapper->WindowTypeToString ( wrapper->GetWindowType ( ) );
out.Append ( " " );
file->Write ( out, out.Length() );
out = window->GetName ( );
file->Write ( out, out.Length() );
file->Write ( "\r\n", 2 );
WriteTabs ( file, depth - 1 );
out = "{\r\n";
file->Write ( out, out.Length() );
file->ForceFlush ( );
for ( i = 0; i < wrapper->GetStateDict().GetNumKeyVals(); i ++ )
{
const idKeyValue* key = wrapper->GetStateDict().GetKeyVal ( i );
// Dont write name to the files
if ( !key->GetKey().Icmp ( "name" ) )
{
continue;
}
WriteTabs ( file, depth );
out = key->GetKey();
out.Append ( "\t" );
file->Write ( out, out.Length() );
const char* p;
for ( p = key->GetValue().c_str(); *p; p ++ )
{
switch ( *p )
{
case '\n':
file->Write ( "\\n", 2 );
break;
default:
file->Write ( p, 1 );
break;
}
}
file->Write ( "\r\n", 2 );
}
for ( i = 0; i < wrapper->GetVariableDict().GetNumKeyVals(); i ++ )
{
const idKeyValue* key = wrapper->GetVariableDict().GetKeyVal ( i );
WriteTabs ( file, depth );
out = key->GetKey();
out.Append ( "\t" );
out.Append ( key->GetValue() );
out.Append ( "\r\n" );
file->Write ( out, out.Length() );
}
if ( wrapper->GetScriptDict().GetNumKeyVals() )
{
file->Write ( "\r\n", 2 );
}
for ( i = 0; i < wrapper->GetScriptDict().GetNumKeyVals(); i ++ )
{
const idKeyValue* key = wrapper->GetScriptDict().GetKeyVal ( i );
WriteTabs ( file, depth );
file->Write ( key->GetKey(), key->GetKey().Length() );
file->Write ( " ", 1 );
idLexer src( key->GetValue(), key->GetValue().Length(), "", LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWBACKSLASHSTRINGCONCAT );
src.ParseBracedSectionExact ( out, depth + 1);
file->Write ( out, out.Length() );
file->Write ( "\r\n", 2 );
file->Write ( "\r\n", 2 );
}
for ( i = 0; i < wrapper->GetChildCount(); i ++ )
{
idWindow* child = wrapper->GetChild ( i );
WriteWindow ( file, depth + 1, child );
}
// Window def footer
WriteTabs ( file, depth - 1 );
out = "}\r\n";
file->Write ( out, out.Length() );
file->ForceFlush ( );
return true;
}
/*
================
rvGEWorkspace::NewFile
Opens a new file for editing
================
*/
bool rvGEWorkspace::NewFile ( void )
{
idStr empty;
idStr ospath;
idFile* file;
// Make a temporary file with nothing in it so we can just use
// load to do all the work
ospath = fileSystem->RelativePathToOSPath ( "guis/Untitled.guiednew", "fs_basepath" );
DeleteFile ( ospath );
file = fileSystem->OpenFileWrite ( "guis/Untitled.guiednew" );
if ( NULL == file )
{
return false;
}
empty = "windowDef Desktop { rect 0,0,640,480 }";
file->Write ( empty, empty.Length() );
fileSystem->CloseFile ( file );
// Load the temporary file
if ( !LoadFile ( ospath, NULL ) )
{
// Ensure the temp file doesnt hang around
DeleteFile ( ospath );
return false;
}
mNew = true;
// Ensure the temp file doesnt hang around
DeleteFile ( ospath );
// Go back to using a .gui extensions
ospath.StripFileExtension ( );
ospath.Append ( ".gui" );
mFilename = ospath;
return true;
}
/*
================
rvGEWorkspace::LoadFile
Loads the given gui file.
================
*/
bool rvGEWorkspace::LoadFile ( const char* filename, idStr* error )
{
delete mInterface;
idStr tempfile;
idStr ospath;
bool result;
tempfile = "guis/temp.guied";
ospath = fileSystem->RelativePathToOSPath ( tempfile, "fs_basepath" );
// Make sure the gui directory exists
idStr createDir = ospath;
createDir.StripFilename ( );
CreateDirectory ( createDir, NULL );
SetFileAttributes ( ospath, FILE_ATTRIBUTE_NORMAL );
DeleteFile ( ospath );
if ( !CopyFile ( filename, ospath, FALSE ) )
{
if ( error )
{
*error = "File not found";
}
return false;
}
SetFileAttributes ( ospath, FILE_ATTRIBUTE_NORMAL );
mFilename = filename;
UpdateTitle ( );
// Let the real window system parse it first
mInterface = NULL;
result = true;
try
{
mInterface = reinterpret_cast< idUserInterfaceLocal* >( uiManager->FindGui( tempfile, true, true ) );
if ( !mInterface && error )
{
*error = "File not found";
}
}
catch ( idException& e )
{
result = false;
if ( error )
{
*error = e.error;
}
return false;
}
if ( result )
{
rvGEWindowWrapper::GetWrapper ( mInterface->GetDesktop ( ) )->Expand ( );
}
else
{
DeleteFile ( ospath );
}
return result;
}
/*
================
rvGEWorkspace::CheckIn
Checks in the current workspace file into source control
================
*/
bool rvGEWorkspace::CheckIn ( void )
{
return false;
}
/*
================
rvGEWorkspace::CheckOut
Checks out the current workspace file from source control
================
*/
bool rvGEWorkspace::CheckOut ( void )
{
return false;
}
/*
================
rvGEWorkspace::UndoCheckout
Undoes the checkout of the current file
================
*/
bool rvGEWorkspace::UndoCheckout ( void )
{
return false;
}

View File

@@ -0,0 +1,129 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "GEApp.h"
#include "GEZOrderModifier.h"
rvGEZOrderModifier::rvGEZOrderModifier ( const char* name, idWindow* window, EZOrderChange change ) :
rvGEModifier ( name, window )
{
int count;
int index;
idWindow* parent;
parent = window->GetParent ( );
if ( !parent )
{
return;
}
count = parent->GetChildCount ( );
index = parent->GetChildIndex ( mWindow );
if ( index + 1 >= count )
{
mUndoBefore = NULL;
}
else
{
mUndoBefore = parent->GetChild ( index + 1 );
}
switch ( change )
{
case ZO_FORWARD:
index+=2;
break;
case ZO_BACKWARD:
if ( index == 0 )
{
index = 1;
}
else
{
index-=1;
}
break;
case ZO_BACK:
index = 0;
break;
case ZO_FRONT:
index = count;
break;
}
if ( index >= count )
{
mBefore = NULL;
}
else
{
mBefore = parent->GetChild ( index );
}
}
bool rvGEZOrderModifier::Apply ( void )
{
idWindow* parent;
parent = mWindow->GetParent ( );
parent->RemoveChild ( mWindow );
parent->InsertChild ( mWindow, mBefore );
return true;
}
bool rvGEZOrderModifier::Undo ( void )
{
idWindow* parent;
parent = mWindow->GetParent ( );
parent->RemoveChild ( mWindow );
parent->InsertChild ( mWindow, mUndoBefore );
return true;
}
bool rvGEZOrderModifier::IsValid ( void )
{
if ( !mWindow->GetParent ( ) )
{
return false;
}
return true;
}

View File

@@ -0,0 +1,59 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef GEZORDERMODIFIER_H_
#define GEZORDERMODIFIER_H_
#ifndef GEMODIFIER_H_
#include "GEModifier.h"
#endif
class rvGEZOrderModifier : public rvGEModifier
{
public:
enum EZOrderChange
{
ZO_FORWARD,
ZO_BACKWARD,
ZO_FRONT,
ZO_BACK,
};
rvGEZOrderModifier ( const char* name, idWindow* window, EZOrderChange change );
virtual bool Apply ( void );
virtual bool Undo ( void );
virtual bool IsValid ( void );
protected:
idWindow* mBefore;
idWindow* mUndoBefore;
};
#endif // GEZORDERMODIFIER_H_

199
neo/tools/guied/guied.cpp Normal file
View File

@@ -0,0 +1,199 @@
/*
===========================================================================
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
Doom 3 Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "../../renderer/tr_local.h"
#include "../../sys/win32/win_local.h"
#include <io.h>
#include "../../ui/DeviceContext.h"
#include "../../sys/win32/rc/guied_resource.h"
#include "GEApp.h"
rvGEApp gApp;
/*
================
GUIEditorInit
Start the gui editor
================
*/
void GUIEditorInit( void )
{
gApp.Initialize();
}
/*
================
GUIEditorShutdown
================
*/
void GUIEditorShutdown( void ) {
}
/*
================
GUIEditorHandleMessage
Handle translator messages
================
*/
bool GUIEditorHandleMessage ( void *msg )
{
if ( !gApp.IsActive ( ) )
{
return false;
}
return gApp.TranslateAccelerator( reinterpret_cast<LPMSG>(msg) );
}
/*
================
GUIEditorRun
Run a frame
================
*/
void GUIEditorRun()
{
MSG msg;
// pump the message loop
while (PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE))
{
if ( !GetMessage (&msg, NULL, 0, 0) )
{
common->Quit();
}
// save the msg time, because wndprocs don't have access to the timestamp
if ( win32.sysMsgTime && win32.sysMsgTime > (int)msg.time )
{
}
else
{
win32.sysMsgTime = msg.time;
}
if ( gApp.TranslateAccelerator ( &msg ) )
{
continue;
}
TranslateMessage (&msg);
DispatchMessage (&msg);
}
gApp.RunFrame ( );
// The GUI editor runs too hot so we need to slow it down a bit.
Sleep ( 1 );
}
/*
================
StringFromVec4
Returns a clean string version of the given vec4
================
*/
const char *StringFromVec4 ( idVec4& v )
{
return va( "%s,%s,%s,%s",
idStr::FloatArrayToString( &v[0], 1, 8 ),
idStr::FloatArrayToString( &v[1], 1, 8 ),
idStr::FloatArrayToString( &v[2], 1, 8 ),
idStr::FloatArrayToString( &v[3], 1, 8 ) );
}
/*
================
IsExpression
Returns true if the given string is an expression
================
*/
bool IsExpression ( const char* s )
{
idParser src( s, strlen ( s ), "",
LEXFL_ALLOWMULTICHARLITERALS |
LEXFL_NOSTRINGCONCAT |
LEXFL_ALLOWBACKSLASHSTRINGCONCAT |
LEXFL_NOFATALERRORS );
idToken token;
bool needComma = false;
bool needNumber = false;
while ( src.ReadToken ( &token ) )
{
switch ( token.type )
{
case TT_NUMBER:
needComma = true;
needNumber = false;
break;
case TT_PUNCTUATION:
if ( needNumber )
{
return true;
}
if ( token[0] == ',' )
{
if ( !needComma )
{
return true;
}
needComma = false;
break;
}
if ( needComma )
{
return true;
}
if ( token[0] == '-' )
{
needNumber = true;
}
break;
default:
return true;
}
}
return false;
}