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

687
neo/tools/radiant/CSG.CPP Normal file
View File

@@ -0,0 +1,687 @@
/*
===========================================================================
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 "qe3.h"
const float PLANE_EPSILON = 0.0001f;
/*
=============
CSG_MakeHollow
=============
*/
void CSG_MakeHollow (void)
{
brush_t *b, *front, *back, *next;
face_t *f;
face_t split;
idVec3 move;
int i;
for (b = selected_brushes.next ; b != &selected_brushes ; b=next)
{
next = b->next;
if (b->owner->eclass->fixedsize || b->pPatch || b->hiddenBrush || b->modelHandle > 0)
continue;
for ( f = b->brush_faces; f; f = f->next ) {
split = *f;
VectorScale (f->plane, g_qeglobals.d_gridsize, move);
for (i=0 ; i<3 ; i++)
VectorSubtract (split.planepts[i], move, split.planepts[i]);
Brush_SplitBrushByFace (b, &split, &front, &back);
if (back)
Brush_Free (back);
if (front)
Brush_AddToList (front, &selected_brushes);
}
Brush_Free (b);
}
Sys_UpdateWindows (W_ALL);
}
/*
=============
Brush_Merge
Returns a new brush that is created by merging brush1 and brush2.
May return NULL if brush1 and brush2 do not create a convex brush when merged.
The input brushes brush1 and brush2 stay intact.
if onlyshape is true then the merge is allowed based on the shape only
otherwise the texture/shader references of faces in the same plane have to
be the same as well.
=============
*/
brush_t *Brush_Merge(brush_t *brush1, brush_t *brush2, int onlyshape)
{
int i, shared;
brush_t *newbrush;
face_t *face1, *face2, *newface, *f;
// check for bounding box overlapp
for (i = 0; i < 3; i++)
{
if (brush1->mins[i] > brush2->maxs[i] + ON_EPSILON
|| brush1->maxs[i] < brush2->mins[i] - ON_EPSILON)
{
// never merge if the brushes overlap
return NULL;
}
}
//
shared = 0;
// check if the new brush would be convex... flipped planes make a brush non-convex
for (face1 = brush1->brush_faces; face1; face1 = face1->next)
{
// don't check the faces of brush 1 and 2 touching each other
for (face2 = brush2->brush_faces; face2; face2 = face2->next)
{
if ( face1->plane.Compare( -face2->plane, PLANE_EPSILON ) )
{
shared++;
// there may only be ONE shared side
if (shared > 1)
return NULL;
break;
}
}
// if this face plane is shared
if (face2) continue;
//
for (face2 = brush2->brush_faces; face2; face2 = face2->next)
{
// don't check the faces of brush 1 and 2 touching each other
for ( f = brush1->brush_faces; f; f = f->next ) {
if ( face2->plane.Compare( -f->plane, PLANE_EPSILON ) ) {
break;
}
}
if ( f ) {
continue;
}
if ( face1->plane.Compare( face2->plane, PLANE_EPSILON ) )
{
//if the texture/shader references should be the same but are not
if (!onlyshape && stricmp(face1->texdef.name, face2->texdef.name) != 0)
return NULL;
continue;
}
//
if ( face1->face_winding->PlanesConcave( *face2->face_winding,
face1->plane.Normal(), face2->plane.Normal(), -face1->plane[3], -face2->plane[3]))
{
return NULL;
} //end if
} //end for
} //end for
//
newbrush = Brush_Alloc();
//
for (face1 = brush1->brush_faces; face1; face1 = face1->next)
{
// don't add the faces of brush 1 and 2 touching each other
for (face2 = brush2->brush_faces; face2; face2 = face2->next)
{
if ( face1->plane.Compare( -face2->plane, PLANE_EPSILON ) ) {
break;
}
}
if ( face2 )
continue;
// don't add faces with the same plane twice
for (f = newbrush->brush_faces; f; f = f->next)
{
if ( face1->plane.Compare( f->plane, PLANE_EPSILON ) )
break;
if ( face1->plane.Compare( -f->plane, PLANE_EPSILON ) )
break;
}
if ( f ) {
continue;
}
newface = Face_Alloc();
newface->texdef = face1->texdef;
VectorCopy(face1->planepts[0], newface->planepts[0]);
VectorCopy(face1->planepts[1], newface->planepts[1]);
VectorCopy(face1->planepts[2], newface->planepts[2]);
newface->plane = face1->plane;
newface->next = newbrush->brush_faces;
newbrush->brush_faces = newface;
}
for (face2 = brush2->brush_faces; face2; face2 = face2->next) {
// don't add the faces of brush 1 and 2 touching each other
for (face1 = brush1->brush_faces; face1; face1 = face1->next)
{
if ( face2->plane.Compare( -face1->plane, PLANE_EPSILON ) ) {
break;
}
}
if (face1)
continue;
// don't add faces with the same plane twice
for (f = newbrush->brush_faces; f; f = f->next)
{
if ( face2->plane.Compare( f->plane, PLANE_EPSILON ) )
break;
if ( face2->plane.Compare( -f->plane, PLANE_EPSILON ) )
break;
}
if ( f ) {
continue;
}
//
newface = Face_Alloc();
newface->texdef = face2->texdef;
VectorCopy(face2->planepts[0], newface->planepts[0]);
VectorCopy(face2->planepts[1], newface->planepts[1]);
VectorCopy(face2->planepts[2], newface->planepts[2]);
newface->plane = face2->plane;
newface->next = newbrush->brush_faces;
newbrush->brush_faces = newface;
}
// link the new brush to an entity
Entity_LinkBrush (brush1->owner, newbrush);
// build windings for the faces
Brush_BuildWindings( newbrush, false);
return newbrush;
}
/*
=============
Brush_MergeListPairs
Returns a list with merged brushes.
Tries to merge brushes pair wise.
The input list is destroyed.
Input and output should be a single linked list using .next
=============
*/
brush_t *Brush_MergeListPairs(brush_t *brushlist, int onlyshape)
{
int nummerges, merged;
brush_t *b1, *b2, *tail, *newbrush, *newbrushlist;
brush_t *lastb2;
if (!brushlist) return NULL;
nummerges = 0;
do
{
for (tail = brushlist; tail; tail = tail->next)
{
if (!tail->next) break;
}
merged = 0;
newbrushlist = NULL;
for (b1 = brushlist; b1; b1 = brushlist)
{
lastb2 = b1;
for (b2 = b1->next; b2; b2 = b2->next)
{
newbrush = Brush_Merge(b1, b2, onlyshape);
if (newbrush)
{
tail->next = newbrush;
lastb2->next = b2->next;
brushlist = brushlist->next;
b1->next = b1->prev = NULL;
b2->next = b2->prev = NULL;
Brush_Free(b1);
Brush_Free(b2);
for (tail = brushlist; tail; tail = tail->next)
{
if (!tail->next) break;
} //end for
merged++;
nummerges++;
break;
}
lastb2 = b2;
}
//if b1 can't be merged with any of the other brushes
if (!b2)
{
brushlist = brushlist->next;
//keep b1
b1->next = newbrushlist;
newbrushlist = b1;
}
}
brushlist = newbrushlist;
} while(merged);
return newbrushlist;
}
/*
=============
Brush_MergeList
Tries to merge all brushes in the list into one new brush.
The input brush list stays intact.
Returns NULL if no merged brush can be created.
To create a new brush the brushes in the list may not overlap and
the outer faces of the brushes together should make a new convex brush.
if onlyshape is true then the merge is allowed based on the shape only
otherwise the texture/shader references of faces in the same plane have to
be the same as well.
=============
*/
brush_t *Brush_MergeList(brush_t *brushlist, int onlyshape)
{
brush_t *brush1, *brush2, *brush3, *newbrush;
face_t *face1, *face2, *face3, *newface, *f;
if (!brushlist) return NULL;
for (brush1 = brushlist; brush1; brush1 = brush1->next)
{
// check if the new brush would be convex... flipped planes make a brush concave
for (face1 = brush1->brush_faces; face1; face1 = face1->next)
{
// don't check face1 if it touches another brush
for (brush2 = brushlist; brush2; brush2 = brush2->next)
{
if (brush2 == brush1) continue;
for (face2 = brush2->brush_faces; face2; face2 = face2->next)
{
if ( face1->plane.Compare( -face2->plane, PLANE_EPSILON ) ) {
break;
}
}
if (face2)
break;
}
// if face1 touches another brush
if (brush2)
continue;
//
for (brush2 = brush1->next; brush2; brush2 = brush2->next)
{
// don't check the faces of brush 2 touching another brush
for (face2 = brush2->brush_faces; face2; face2 = face2->next)
{
for (brush3 = brushlist; brush3; brush3 = brush3->next)
{
if (brush3 == brush2) continue;
for (face3 = brush3->brush_faces; face3; face3 = face3->next)
{
if ( face2->plane.Compare( -face3->plane, PLANE_EPSILON ) )
break;
}
if (face3)
break;
}
// if face2 touches another brush
if (brush3)
continue;
//
if ( face1->plane.Compare( face2->plane, PLANE_EPSILON ) )
{
//if the texture/shader references should be the same but are not
if (!onlyshape && stricmp(face1->texdef.name, face2->texdef.name) != 0)
return NULL;
continue;
}
//
if ( face1->face_winding->PlanesConcave( *face2->face_winding,
face1->plane.Normal(), face2->plane.Normal(), -face1->plane[3], -face2->plane[3]))
{
return NULL;
}
}
}
}
}
//
newbrush = Brush_Alloc();
//
for (brush1 = brushlist; brush1; brush1 = brush1->next)
{
for (face1 = brush1->brush_faces; face1; face1 = face1->next)
{
// don't add face1 to the new brush if it touches another brush
for (brush2 = brushlist; brush2; brush2 = brush2->next)
{
if (brush2 == brush1) continue;
for (face2 = brush2->brush_faces; face2; face2 = face2->next)
{
if ( face1->plane.Compare( -face2->plane, PLANE_EPSILON ) ) {
break;
}
}
if (face2)
break;
}
if (brush2)
continue;
// don't add faces with the same plane twice
for (f = newbrush->brush_faces; f; f = f->next)
{
if ( face1->plane.Compare( f->plane, PLANE_EPSILON ) )
break;
if ( face1->plane.Compare( -f->plane, PLANE_EPSILON ) )
break;
}
if (f)
continue;
//
newface = Face_Alloc();
newface->texdef = face1->texdef;
VectorCopy(face1->planepts[0], newface->planepts[0]);
VectorCopy(face1->planepts[1], newface->planepts[1]);
VectorCopy(face1->planepts[2], newface->planepts[2]);
newface->plane = face1->plane;
newface->next = newbrush->brush_faces;
newbrush->brush_faces = newface;
}
}
// link the new brush to an entity
Entity_LinkBrush (brushlist->owner, newbrush);
// build windings for the faces
Brush_BuildWindings( newbrush, false);
return newbrush;
}
/*
=============
Brush_Subtract
Returns a list of brushes that remain after B is subtracted from A.
May by empty if A is contained inside B.
The originals are undisturbed.
=============
*/
brush_t *Brush_Subtract(brush_t *a, brush_t *b)
{
// a - b = out (list)
brush_t *front, *back;
brush_t *in, *out, *next;
face_t *f;
in = a;
out = NULL;
for (f = b->brush_faces; f && in; f = f->next)
{
Brush_SplitBrushByFace(in, f, &front, &back);
if (in != a) Brush_Free(in);
if (front)
{ // add to list
front->next = out;
out = front;
}
in = back;
}
//NOTE: in != a just in case brush b has no faces
if (in && in != a)
{
Brush_Free(in);
}
else
{ //didn't really intersect
for (b = out; b; b = next)
{
next = b->next;
b->next = b->prev = NULL;
Brush_Free(b);
}
return a;
}
return out;
}
/*
=============
CSG_Subtract
=============
*/
void CSG_Subtract (void)
{
brush_t *b, *s, *fragments, *nextfragment, *frag, *next, *snext;
brush_t fragmentlist;
int i, numfragments, numbrushes;
Sys_Status ("Subtracting...\n");
if (selected_brushes.next == &selected_brushes)
{
Sys_Status("No brushes selected.\n");
return;
}
fragmentlist.next = &fragmentlist;
fragmentlist.prev = &fragmentlist;
numfragments = 0;
numbrushes = 0;
for (b = selected_brushes.next ; b != &selected_brushes ; b=next)
{
next = b->next;
if (b->owner->eclass->fixedsize || b->modelHandle > 0)
continue; // can't use texture from a fixed entity, so don't subtract
// chop all fragments further up
for (s = fragmentlist.next; s != &fragmentlist; s = snext)
{
snext = s->next;
for (i=0 ; i<3 ; i++)
if (b->mins[i] >= s->maxs[i] - ON_EPSILON
|| b->maxs[i] <= s->mins[i] + ON_EPSILON)
break;
if (i != 3)
continue; // definately don't touch
fragments = Brush_Subtract(s, b);
// if the brushes did not really intersect
if (fragments == s)
continue;
// try to merge fragments
fragments = Brush_MergeListPairs(fragments, true);
// add the fragments to the list
for (frag = fragments; frag; frag = nextfragment)
{
nextfragment = frag->next;
frag->next = NULL;
frag->owner = s->owner;
Brush_AddToList(frag, &fragmentlist);
}
// free the original brush
Brush_Free(s);
}
// chop any active brushes up
for (s = active_brushes.next; s != &active_brushes; s = snext)
{
snext = s->next;
if (s->owner->eclass->fixedsize || s->pPatch || s->hiddenBrush || s->modelHandle > 0)
continue;
//face_t *pFace = s->brush_faces;
if ( s->brush_faces->d_texture && ( s->brush_faces->d_texture->GetContentFlags()& CONTENTS_NOCSG ) )
{
continue;
}
for (i=0 ; i<3 ; i++)
if (b->mins[i] >= s->maxs[i] - ON_EPSILON
|| b->maxs[i] <= s->mins[i] + ON_EPSILON)
break;
if (i != 3)
continue; // definately don't touch
fragments = Brush_Subtract(s, b);
// if the brushes did not really intersect
if (fragments == s)
continue;
//
Undo_AddBrush(s);
// one extra brush chopped up
numbrushes++;
// try to merge fragments
fragments = Brush_MergeListPairs(fragments, true);
// add the fragments to the list
for (frag = fragments; frag; frag = nextfragment)
{
nextfragment = frag->next;
frag->next = NULL;
frag->owner = s->owner;
Brush_AddToList(frag, &fragmentlist);
}
// free the original brush
Brush_Free(s);
}
}
// move all fragments to the active brush list
for (frag = fragmentlist.next; frag != &fragmentlist; frag = nextfragment)
{
nextfragment = frag->next;
numfragments++;
Brush_RemoveFromList(frag);
Brush_AddToList(frag, &active_brushes);
Undo_EndBrush(frag);
}
if (numfragments == 0)
{
common->Printf("Selected brush%s did not intersect with any other brushes.\n",
(selected_brushes.next->next == &selected_brushes) ? "":"es");
return;
}
Sys_Status("done.");
common->Printf(" (created %d fragment%s out of %d brush%s)\n", numfragments, (numfragments == 1)?"":"s",
numbrushes, (numbrushes == 1)?"":"es");
Sys_UpdateWindows(W_ALL);
}
/*
=============
CSG_Merge
=============
*/
void CSG_Merge(void)
{
brush_t *b, *next, *newlist, *newbrush;
struct entity_s *owner;
Sys_Status("Merging...\n");
if (selected_brushes.next == &selected_brushes)
{
Sys_Status("No brushes selected.\n");
return;
}
if (selected_brushes.next->next == &selected_brushes)
{
Sys_Status("At least two brushes have to be selected.\n");
return;
}
owner = selected_brushes.next->owner;
for (b = selected_brushes.next; b != &selected_brushes; b = next)
{
next = b->next;
if (b->owner->eclass->fixedsize || b->modelHandle > 0)
{
// can't use texture from a fixed entity, so don't subtract
Sys_Status("Cannot add fixed size entities.\n");
return;
}
if (b->pPatch)
{
Sys_Status("Cannot add patches.\n");
return;
}
if ( b->brush_faces->d_texture && ( b->brush_faces->d_texture->GetContentFlags() & CONTENTS_NOCSG ) )
{
Sys_Status("Cannot add brushes using shaders that don't allows CSG operations.\n");
return;
}
if (b->owner != owner)
{
Sys_Status("Cannot add brushes from different entities.\n");
return;
}
}
newlist = NULL;
for (b = selected_brushes.next; b != &selected_brushes; b = next)
{
next = b->next;
Brush_RemoveFromList(b);
b->next = newlist;
b->prev = NULL;
newlist = b;
}
newbrush = Brush_MergeList(newlist, true);
// if the new brush would not be convex
if (!newbrush)
{
// add the brushes back into the selection
for (b = newlist; b; b = next)
{
next = b->next;
b->next = NULL;
b->prev = NULL;
Brush_AddToList(b, &selected_brushes);
}
Sys_Status("Cannot add a set of brushes with a concave hull.\n");
return;
}
// free the original brushes
for (b = newlist; b; b = next)
{
next = b->next;
b->next = NULL;
b->prev = NULL;
Brush_Free(b);
}
Brush_AddToList(newbrush, &selected_brushes);
Sys_Status ("done.\n");
Sys_UpdateWindows (W_ALL);
}

2168
neo/tools/radiant/CamWnd.cpp Normal file

File diff suppressed because it is too large Load Diff

205
neo/tools/radiant/CamWnd.h Normal file
View File

@@ -0,0 +1,205 @@
/*
===========================================================================
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.
===========================================================================
*/
#if !defined(AFX_CAMWND_H__44B4BA03_781B_11D1_B53C_00AA00A410FC__INCLUDED_)
#define AFX_CAMWND_H__44B4BA03_781B_11D1_B53C_00AA00A410FC__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
typedef enum
{
cd_wire,
cd_solid,
cd_texture,
cd_light,
cd_blend
} camera_draw_mode;
typedef struct
{
int width, height;
idVec3 origin;
idAngles angles;
camera_draw_mode draw_mode;
idVec3 color; // background
idVec3 forward, right, up; // move matrix
idVec3 vup, vpn, vright; // view matrix
} camera_t;
/////////////////////////////////////////////////////////////////////////////
// CCamWnd window
class CXYWnd;
class CCamWnd : public CWnd
{
DECLARE_DYNCREATE(CCamWnd);
// Construction
public:
CCamWnd();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCamWnd)
protected:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
public:
void ShiftTexture_BrushPrimit(face_t *f, int x, int y);
CXYWnd* m_pXYFriend;
void SetXYFriend(CXYWnd* pWnd);
virtual ~CCamWnd();
camera_t& Camera(){return m_Camera;};
void Cam_MouseControl(float dtime);
void Cam_ChangeFloor(bool up);
void BuildRendererState();
void ToggleRenderMode();
void ToggleRebuildMode();
void ToggleEntityMode();
void ToggleSelectMode();
void ToggleAnimationMode();
void ToggleSoundMode();
void SetProjectionMatrix();
void UpdateCameraView();
void BuildEntityRenderState( entity_t *ent, bool update );
bool GetRenderMode() {
return renderMode;
}
bool GetRebuildMode() {
return rebuildMode;
}
bool GetEntityMode() {
return entityMode;
}
bool GetAnimationMode() {
return animationMode;
}
bool GetSelectMode() {
return selectMode;
}
bool GetSoundMode() {
return soundMode;
}
bool UpdateRenderEntities();
void MarkWorldDirty();
void SetView( const idVec3 &origin, const idAngles &angles ) {
m_Camera.origin = origin;
m_Camera.angles = angles;
}
protected:
void Cam_Init();
void Cam_BuildMatrix();
void Cam_PositionDrag();
void Cam_MouseLook();
void Cam_MouseDown(int x, int y, int buttons);
void Cam_MouseUp (int x, int y, int buttons);
void Cam_MouseMoved (int x, int y, int buttons);
void InitCull();
bool CullBrush (brush_t *b, bool cubicOnly);
void Cam_Draw();
void Cam_Render();
// game renderer interaction
qhandle_t worldModelDef;
idRenderModel *worldModel; // createRawModel of the brush and patch geometry
bool worldDirty;
bool renderMode;
bool rebuildMode;
bool entityMode;
bool selectMode;
bool animationMode;
bool soundMode;
void FreeRendererState();
void UpdateCaption();
bool BuildBrushRenderData(brush_t *brush);
void DrawEntityData();
camera_t m_Camera;
int m_nCambuttonstate;
CPoint m_ptButton;
CPoint m_ptCursor;
CPoint m_ptLastCursor;
face_t* m_pSide_select;
idVec3 m_vCull1;
idVec3 m_vCull2;
int m_nCullv1[3];
int m_nCullv2[3];
bool m_bClipMode;
idVec3 saveOrg;
idAngles saveAng;
bool saveValid;
// Generated message map functions
protected:
void OriginalMouseDown(UINT nFlags, CPoint point);
void OriginalMouseUp(UINT nFlags, CPoint point);
//{{AFX_MSG(CCamWnd)
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnPaint();
afx_msg void OnDestroy();
afx_msg void OnClose();
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnTimer(UINT nIDEvent);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CAMWND_H__44B4BA03_781B_11D1_B53C_00AA00A410FC__INCLUDED_)

View File

@@ -0,0 +1,78 @@
/*
===========================================================================
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 "qe3.h"
#include "CameraTargetDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCameraTargetDlg dialog
CCameraTargetDlg::CCameraTargetDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCameraTargetDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCameraTargetDlg)
m_nType = 0;
m_strName = _T("");
//}}AFX_DATA_INIT
}
void CCameraTargetDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCameraTargetDlg)
DDX_Radio(pDX, IDC_RADIO_FIXED, m_nType);
DDX_Text(pDX, IDC_EDIT_NAME, m_strName);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCameraTargetDlg, CDialog)
//{{AFX_MSG_MAP(CCameraTargetDlg)
ON_COMMAND(ID_POPUP_NEWCAMERA_FIXED, OnPopupNewcameraFixed)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCameraTargetDlg message handlers
void CCameraTargetDlg::OnPopupNewcameraFixed()
{
// TODO: Add your command handler code here
}

View File

@@ -0,0 +1,74 @@
/*
===========================================================================
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.
===========================================================================
*/
#if !defined(AFX_CAMERATARGETDLG_H__DE6597C1_1F63_4835_8949_5D2D5F208C6B__INCLUDED_)
#define AFX_CAMERATARGETDLG_H__DE6597C1_1F63_4835_8949_5D2D5F208C6B__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// CameraTargetDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CCameraTargetDlg dialog
class CCameraTargetDlg : public CDialog
{
// Construction
public:
CCameraTargetDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CCameraTargetDlg)
enum { IDD = IDD_DLG_CAMERATARGET };
int m_nType;
CString m_strName;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCameraTargetDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CCameraTargetDlg)
afx_msg void OnPopupNewcameraFixed();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CAMERATARGETDLG_H__DE6597C1_1F63_4835_8949_5D2D5F208C6B__INCLUDED_)

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 "qe3.h"
#include "Radiant.h"
#include "CapDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCapDialog dialog
CCapDialog::CCapDialog(CWnd* pParent /*=NULL*/)
: CDialog(CCapDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CCapDialog)
m_nCap = 0;
//}}AFX_DATA_INIT
}
void CCapDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCapDialog)
DDX_Radio(pDX, IDC_RADIO_CAP, m_nCap);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCapDialog, CDialog)
//{{AFX_MSG_MAP(CCapDialog)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCapDialog message handlers

View File

@@ -0,0 +1,75 @@
/*
===========================================================================
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.
===========================================================================
*/
#if !defined(AFX_CAPDIALOG_H__10637162_2BD2_11D2_B030_00AA00A410FC__INCLUDED_)
#define AFX_CAPDIALOG_H__10637162_2BD2_11D2_B030_00AA00A410FC__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// CapDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CCapDialog dialog
class CCapDialog : public CDialog
{
// Construction
public:
static enum {BEVEL = 0, ENDCAP, IBEVEL, IENDCAP};
CCapDialog(CWnd* pParent = NULL); // standard constructor
int getCapType() {return m_nCap;};
// Dialog Data
//{{AFX_DATA(CCapDialog)
enum { IDD = IDD_DIALOG_CAP };
int m_nCap;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCapDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CCapDialog)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CAPDIALOG_H__10637162_2BD2_11D2_B030_00AA00A410FC__INCLUDED_)

View File

@@ -0,0 +1,116 @@
/*
===========================================================================
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 "qe3.h"
#include "Radiant.h"
#include "CommandsDlg.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCommandsDlg dialog
CCommandsDlg::CCommandsDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCommandsDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCommandsDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CCommandsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCommandsDlg)
DDX_Control(pDX, IDC_LIST_COMMANDS, m_lstCommands);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCommandsDlg, CDialog)
//{{AFX_MSG_MAP(CCommandsDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCommandsDlg message handlers
BOOL CCommandsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_lstCommands.SetTabStops(120);
int nCount = g_nCommandCount;
CFile fileout;
fileout.Open("c:/commandlist.txt", CFile::modeCreate | CFile::modeWrite);
for (int n = 0; n < nCount; n++)
{
CString strLine;
char c = g_Commands[n].m_nKey;
CString strKeys = CString( c );
for (int k = 0; k < g_nKeyCount; k++)
{
if (g_Keys[k].m_nVKKey == g_Commands[n].m_nKey)
{
strKeys = g_Keys[k].m_strName;
break;
}
}
CString strMod("");
if (g_Commands[n].m_nModifiers & RAD_SHIFT)
strMod = "Shift";
if (g_Commands[n].m_nModifiers & RAD_ALT)
strMod += (strMod.GetLength() > 0) ? " + Alt" : "Alt";
if (g_Commands[n].m_nModifiers & RAD_CONTROL)
strMod += (strMod.GetLength() > 0) ? " + Control" : "Control";
if (strMod.GetLength() > 0)
{
strMod += " + ";
}
strLine.Format("%s \t%s%s", g_Commands[n].m_strCommand, strMod, strKeys);
m_lstCommands.AddString(strLine);
strLine.Format("%s \t\t\t%s%s", g_Commands[n].m_strCommand, strMod, strKeys);
fileout.Write(strLine, strLine.GetLength());
fileout.Write("\r\n", 2);
}
fileout.Close();
return TRUE;
}

View File

@@ -0,0 +1,73 @@
/*
===========================================================================
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.
===========================================================================
*/
#if !defined(AFX_COMMANDSDLG_H__C80F6E42_8531_11D1_B548_00AA00A410FC__INCLUDED_)
#define AFX_COMMANDSDLG_H__C80F6E42_8531_11D1_B548_00AA00A410FC__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// CommandsDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CCommandsDlg dialog
class CCommandsDlg : public CDialog
{
// Construction
public:
CCommandsDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CCommandsDlg)
enum { IDD = IDD_DLG_COMMANDLIST };
CListBox m_lstCommands;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCommandsDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CCommandsDlg)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_COMMANDSDLG_H__C80F6E42_8531_11D1_B548_00AA00A410FC__INCLUDED_)

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.
===========================================================================
*/
#include "../../idlib/precompiled.h"
#pragma hdrstop
#include "qe3.h"
#include "Radiant.h"
#include "CommentsDlg.h"
// CCommentsDlg dialog
IMPLEMENT_DYNAMIC(CCommentsDlg, CDialog)
CCommentsDlg::CCommentsDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCommentsDlg::IDD, pParent)
, strName(_T(""))
, strPath(_T(""))
, strComments(_T(""))
{
}
CCommentsDlg::~CCommentsDlg()
{
}
void CCommentsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT_NAME, strName);
DDX_Text(pDX, IDC_EDIT_PATH, strPath);
DDX_Text(pDX, IDC_EDIT_COMMENTS, strComments);
}
BEGIN_MESSAGE_MAP(CCommentsDlg, CDialog)
END_MESSAGE_MAP()
// CCommentsDlg message handlers

View File

@@ -0,0 +1,53 @@
/*
===========================================================================
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.
===========================================================================
*/
#pragma once
#include "afxwin.h"
// CCommentsDlg dialog
class CCommentsDlg : public CDialog
{
DECLARE_DYNAMIC(CCommentsDlg)
public:
CCommentsDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CCommentsDlg();
// Dialog Data
enum { IDD = IDD_DIALOG_COMMENTS };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
CString strName;
CString strPath;
CString strComments;
};

View File

@@ -0,0 +1,261 @@
/*
===========================================================================
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 "qe3.h"
#include "Radiant.h"
#include "ConsoleDlg.h"
// CConsoleDlg dialog
IMPLEMENT_DYNCREATE(CConsoleDlg, CDialog)
CConsoleDlg::CConsoleDlg(CWnd* pParent /*=NULL*/)
: CDialog(CConsoleDlg::IDD)
{
currentHistoryPosition = -1;
currentCommand = "";
saveCurrentCommand = true;
}
CConsoleDlg::~CConsoleDlg()
{
}
void CConsoleDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_EDIT_CONSOLE, editConsole);
DDX_Control(pDX, IDC_EDIT_INPUT, editInput);
}
void CConsoleDlg::AddText( const char *msg ) {
idStr work;
CString work2;
work = msg;
work.RemoveColors();
work = CEntityDlg::TranslateString( work.c_str() );
editConsole.GetWindowText( work2 );
int len = work2.GetLength();
if ( len + work.Length() > (int)editConsole.GetLimitText() ) {
work2 = work2.Right( editConsole.GetLimitText() * 0.75 );
len = work2.GetLength();
editConsole.SetWindowText(work2);
}
editConsole.SetSel( len, len );
editConsole.ReplaceSel( work );
}
BEGIN_MESSAGE_MAP(CConsoleDlg, CDialog)
ON_WM_SIZE()
ON_WM_SETFOCUS()
ON_WM_ACTIVATE()
END_MESSAGE_MAP()
// CConsoleDlg message handlers
void CConsoleDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
if (editInput.GetSafeHwnd() == NULL) {
return;
}
CRect rect, crect;
GetWindowRect(rect);
editInput.GetWindowRect(crect);
editInput.SetWindowPos(NULL, 4, rect.Height() - 4 - crect.Height(), rect.Width() - 8, crect.Height(), SWP_SHOWWINDOW);
editConsole.SetWindowPos(NULL, 4, 4, rect.Width() - 8, rect.Height() - crect.Height() - 8, SWP_SHOWWINDOW);
}
BOOL CConsoleDlg::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->hwnd == editInput.GetSafeHwnd()) {
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE ) {
Select_Deselect();
g_pParentWnd->SetFocus ();
return TRUE;
}
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN ) {
ExecuteCommand();
return TRUE;
}
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE ) {
if (pMsg->wParam == VK_ESCAPE) {
g_pParentWnd->GetCamera()->SetFocus();
Select_Deselect();
}
return TRUE;
}
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_UP ) {
//save off the current in-progress command so we can get back to it
if ( saveCurrentCommand == true ) {
CString str;
editInput.GetWindowText ( str );
currentCommand = str.GetBuffer ( 0 );
saveCurrentCommand = false;
}
if ( consoleHistory.Num () > 0 ) {
editInput.SetWindowText ( consoleHistory[currentHistoryPosition] );
int selLocation = consoleHistory[currentHistoryPosition].Length ();
editInput.SetSel ( selLocation , selLocation + 1);
}
if ( currentHistoryPosition > 0) {
--currentHistoryPosition;
}
return TRUE;
}
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_DOWN ) {
int selLocation = 0;
if ( currentHistoryPosition < consoleHistory.Num () - 1 ) {
++currentHistoryPosition;
editInput.SetWindowText ( consoleHistory[currentHistoryPosition] );
selLocation = consoleHistory[currentHistoryPosition].Length ();
}
else {
editInput.SetWindowText ( currentCommand );
selLocation = currentCommand.Length ();
currentCommand.Clear ();
saveCurrentCommand = true;
}
editInput.SetSel ( selLocation , selLocation + 1);
return TRUE;
}
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_TAB ) {
common->Printf ( "Command History\n----------------\n" );
for ( int i = 0 ; i < consoleHistory.Num ();i++ )
{
common->Printf ( "[cmd %d]: %s\n" , i , consoleHistory[i].c_str() );
}
common->Printf ( "----------------\n" );
}
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_NEXT) {
editConsole.LineScroll ( 10 );
}
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_PRIOR ) {
editConsole.LineScroll ( -10 );
}
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_HOME ) {
editConsole.LineScroll ( -editConsole.GetLineCount() );
}
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_END ) {
editConsole.LineScroll ( editConsole.GetLineCount() );
}
}
return CDialog::PreTranslateMessage(pMsg);
}
void CConsoleDlg::OnSetFocus(CWnd* pOldWnd) {
CDialog::OnSetFocus(pOldWnd);
editInput.SetFocus();
}
void CConsoleDlg::SetConsoleText ( const idStr& text ) {
editInput.Clear ();
editInput.SetWindowText ( text.c_str() );
}
void CConsoleDlg::ExecuteCommand ( const idStr& cmd ) {
CString str;
if ( cmd.Length() > 0 ) {
str = cmd;
}
else {
editInput.GetWindowText(str);
}
if ( str != "" ) {
editInput.SetWindowText("");
common->Printf("%s\n", str.GetBuffer(0));
//avoid adding multiple identical commands in a row
int index = consoleHistory.Num ();
if ( index == 0 || str.GetBuffer(0) != consoleHistory[index-1]) {
//keep the history to 16 commands, removing the oldest command
if ( consoleHistory.Num () > 16 ) {
consoleHistory.RemoveIndex ( 0 );
}
currentHistoryPosition = consoleHistory.Append ( str.GetBuffer (0) );
}
else {
currentHistoryPosition = consoleHistory.Num () - 1;
}
currentCommand.Clear ();
bool propogateCommand = true;
//process some of our own special commands
if ( str.CompareNoCase ( "clear" ) == 0) {
editConsole.SetSel ( 0 , -1 );
editConsole.Clear ();
}
else if ( str.CompareNoCase ( "edit" ) == 0) {
propogateCommand = false;
}
if ( propogateCommand ) {
cmdSystem->BufferCommandText( CMD_EXEC_NOW, str );
}
Sys_UpdateWindows(W_ALL);
}
}
void CConsoleDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
CDialog::OnActivate(nState, pWndOther, bMinimized);
if ( nState == WA_ACTIVE || nState == WA_CLICKACTIVE )
{
editInput.SetFocus();
}
}

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.
===========================================================================
*/
#pragma once
#include "afxwin.h"
// CConsoleDlg dialog
class CConsoleDlg : public CDialog
{
DECLARE_DYNCREATE(CConsoleDlg)
public:
CConsoleDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CConsoleDlg();
// Dialog Data
enum { IDD = IDD_DIALOG_CONSOLE };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
CEdit editConsole;
CEdit editInput;
void AddText(const char *msg);
void SetConsoleText ( const idStr& text );
void ExecuteCommand ( const idStr& cmd = "" );
idStr consoleStr;
idStrList consoleHistory;
idStr currentCommand;
int currentHistoryPosition;
bool saveCurrentCommand;
afx_msg void OnSize(UINT nType, int cx, int cy);
virtual BOOL PreTranslateMessage(MSG* pMsg);
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
};

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 "qe3.h"
#include "Radiant.h"
#include "CurveDlg.h"
// CCurveDlg dialog
IMPLEMENT_DYNAMIC(CCurveDlg, CDialog)
CCurveDlg::CCurveDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCurveDlg::IDD, pParent)
{
}
CCurveDlg::~CCurveDlg()
{
}
void CCurveDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_COMBO_CURVES, comboCurve);
}
void CCurveDlg::OnOK() {
UpdateData(TRUE);
CString str;
comboCurve.GetWindowText( str );
strCurveType = str;
CDialog::OnOK();
}
BEGIN_MESSAGE_MAP(CCurveDlg, CDialog)
END_MESSAGE_MAP()
// CCurveDlg message handlers

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.
===========================================================================
*/
#pragma once
// CCurveDlg dialog
class CCurveDlg : public CDialog
{
DECLARE_DYNAMIC(CCurveDlg)
public:
CCurveDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CCurveDlg();
// Dialog Data
enum { IDD = IDD_DIALOG_NEWCURVE };
idStr strCurveType;
protected:
CComboBox comboCurve;
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual void OnOK();
DECLARE_MESSAGE_MAP()
};

763
neo/tools/radiant/DRAG.CPP Normal file
View File

@@ -0,0 +1,763 @@
/*
===========================================================================
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 "qe3.h"
#include "splines.h"
/* drag either multiple brushes, or select plane points from a single brush. */
bool g_moveOnly = false;
bool drag_ok;
idVec3 drag_xvec;
idVec3 drag_yvec;
static int buttonstate;
int pressx, pressy;
static idVec3 pressdelta;
static idVec3 vPressStart;
static int buttonx, buttony;
// int num_move_points; float *move_points[1024];
int lastx, lasty;
bool drag_first;
/*
================
AxializeVector
================
*/
static void AxializeVector( idVec3 &v ) {
idVec3 a;
float o;
int i;
if (!v[0] && !v[1]) {
return;
}
if (!v[1] && !v[2]) {
return;
}
if (!v[0] && !v[2]) {
return;
}
for (i = 0; i < 3; i++) {
a[i] = idMath::Fabs(v[i]);
}
if (a[0] > a[1] && a[0] > a[2]) {
i = 0;
}
else if (a[1] > a[0] && a[1] > a[2]) {
i = 1;
}
else {
i = 2;
}
o = v[i];
VectorCopy(vec3_origin, v);
if (o < 0) {
v[i] = -1;
}
else {
v[i] = 1;
}
}
extern bool UpdateActiveDragPoint(const idVec3 &move);
extern void SetActiveDrag(CDragPoint *p);
/*
================
Draw_Setup
================
*/
static void Drag_Setup( int x, int y, int buttons,
const idVec3 &xaxis, const idVec3 &yaxis, const idVec3 &origin, const idVec3 &dir ) {
qertrace_t t;
face_t *f;
drag_first = true;
VectorCopy(vec3_origin, pressdelta);
pressx = x;
pressy = y;
VectorCopy(xaxis, drag_xvec);
AxializeVector(drag_xvec);
VectorCopy(yaxis, drag_yvec);
AxializeVector(drag_yvec);
if (g_qeglobals.d_select_mode == sel_addpoint) {
if (g_qeglobals.selectObject) {
g_qeglobals.selectObject->addPoint(origin);
}
else {
g_qeglobals.d_select_mode = sel_brush;
}
return;
}
if (g_qeglobals.d_select_mode == sel_editpoint) {
g_Inspectors->entityDlg.SelectCurvePointByRay( origin, dir, buttons );
if ( g_qeglobals.d_num_move_points ) {
drag_ok = true;
}
Sys_UpdateWindows(W_ALL);
return;
}
if (g_qeglobals.d_select_mode == sel_curvepoint) {
SelectCurvePointByRay(origin, dir, buttons);
if (g_qeglobals.d_num_move_points || g_qeglobals.d_select_mode == sel_area) {
drag_ok = true;
}
Sys_UpdateWindows(W_ALL);
Undo_Start("drag curve point");
Undo_AddBrushList(&selected_brushes);
return;
}
else {
g_qeglobals.d_num_move_points = 0;
}
if (selected_brushes.next == &selected_brushes) {
//
// in this case a new brush is created when the dragging takes place in the XYWnd,
// An useless undo is created when the dragging takes place in the CamWnd
//
Undo_Start("create brush");
Sys_Status("No selection to drag\n", 0);
return;
}
if (g_qeglobals.d_select_mode == sel_vertex) {
if ( radiant_entityMode.GetBool() ) {
return;
}
SelectVertexByRay(origin, dir);
if (g_qeglobals.d_num_move_points) {
drag_ok = true;
Undo_Start("drag vertex");
Undo_AddBrushList(&selected_brushes);
return;
}
}
if (g_qeglobals.d_select_mode == sel_edge) {
if ( radiant_entityMode.GetBool() ) {
return;
}
SelectEdgeByRay(origin, dir);
if (g_qeglobals.d_num_move_points) {
drag_ok = true;
Undo_Start("drag edge");
Undo_AddBrushList(&selected_brushes);
return;
}
}
// check for direct hit first
t = Test_Ray(origin, dir, true);
SetActiveDrag(t.point);
if (t.point) {
drag_ok = true;
// point was hit
return;
}
if (t.selected) {
drag_ok = true;
Undo_Start("drag selection");
Undo_AddBrushList(&selected_brushes);
if (buttons == (MK_LBUTTON | MK_CONTROL)) {
Sys_Status("Shear dragging face\n");
Brush_SelectFaceForDragging(t.brush, t.face, true);
}
else if (buttons == (MK_LBUTTON | MK_CONTROL | MK_SHIFT)) {
Sys_Status("Sticky dragging brush\n");
for (f = t.brush->brush_faces; f; f = f->next) {
Brush_SelectFaceForDragging(t.brush, f, false);
}
}
else {
Sys_Status("Dragging entire selection\n");
}
return;
}
if (g_qeglobals.d_select_mode == sel_vertex || g_qeglobals.d_select_mode == sel_edge) {
return;
}
if ( radiant_entityMode.GetBool() ) {
return;
}
// check for side hit multiple brushes selected?
if (selected_brushes.next->next != &selected_brushes) {
// yes, special handling
bool bOK = ( g_PrefsDlg.m_bALTEdge ) ? ( ::GetAsyncKeyState( VK_MENU ) != 0 ) : true;
if (bOK) {
for (brush_t * pBrush = selected_brushes.next; pBrush != &selected_brushes; pBrush = pBrush->next) {
if (buttons & MK_CONTROL) {
Brush_SideSelect(pBrush, origin, dir, true);
}
else {
Brush_SideSelect(pBrush, origin, dir, false);
}
}
}
else {
Sys_Status("press ALT to drag multiple edges\n");
return;
}
}
else {
// single select.. trying to drag fixed entities handle themselves and just move
if (buttons & MK_CONTROL) {
Brush_SideSelect(selected_brushes.next, origin, dir, true);
}
else {
Brush_SideSelect(selected_brushes.next, origin, dir, false);
}
}
Sys_Status("Side stretch\n");
drag_ok = true;
Undo_Start("side stretch");
Undo_AddBrushList(&selected_brushes);
}
extern void Face_GetScale_BrushPrimit(face_t *face, float *s, float *t, float *rot);
/*
================
Drag_Begin
================
*/
void Drag_Begin( int x, int y, int buttons,
const idVec3 &xaxis, const idVec3 &yaxis, const idVec3 &origin, const idVec3 &dir ) {
qertrace_t t;
drag_ok = false;
VectorCopy(vec3_origin, pressdelta);
VectorCopy(vec3_origin, vPressStart);
drag_first = true;
// shift LBUTTON = select entire brush
if (buttons == (MK_LBUTTON | MK_SHIFT) && g_qeglobals.d_select_mode != sel_curvepoint) {
int nFlag = ( ::GetAsyncKeyState( VK_MENU ) != 0 ) ? SF_CYCLE : 0;
if (dir[0] == 0 || dir[1] == 0 || dir[2] == 0) { // extremely low chance of this happening from camera
Select_Ray(origin, dir, nFlag | SF_ENTITIES_FIRST); // hack for XY
}
else {
Select_Ray(origin, dir, nFlag);
}
return;
}
// ctrl-shift LBUTTON = select single face
if (buttons == (MK_LBUTTON | MK_CONTROL | MK_SHIFT) && g_qeglobals.d_select_mode != sel_curvepoint) {
if ( radiant_entityMode.GetBool() ) {
return;
}
// _D3XP disabled
//Select_Deselect( ( ::GetAsyncKeyState( VK_MENU ) == 0 ) );
Select_Ray(origin, dir, SF_SINGLEFACE);
return;
}
// LBUTTON + all other modifiers = manipulate selection
if (buttons & MK_LBUTTON) {
Drag_Setup(x, y, buttons, xaxis, yaxis, origin, dir);
return;
}
if ( radiant_entityMode.GetBool() ) {
return;
}
int nMouseButton = g_PrefsDlg.m_nMouseButtons == 2 ? MK_RBUTTON : MK_MBUTTON;
// middle button = grab texture
if (buttons == nMouseButton) {
t = Test_Ray(origin, dir, false);
if (t.face) {
g_qeglobals.d_new_brush_bottom = t.brush->mins;
g_qeglobals.d_new_brush_top = t.brush->maxs;
// use a local brushprimit_texdef fitted to a default 2x2 texture
brushprimit_texdef_t bp_local;
if (t.brush && t.brush->pPatch) {
texdef_t localtd;
memset(&bp_local.coords, 0, sizeof(bp_local.coords));
bp_local.coords[0][0] = 1.0f;
bp_local.coords[1][1] = 1.0f;
localtd.SetName(t.brush->pPatch->d_texture->GetName());
Texture_SetTexture(&localtd, &bp_local, false, true);
Select_CopyPatchTextureCoords ( t.brush->pPatch );
} else {
Select_ProjectFaceOntoPatch( t.face );
ConvertTexMatWithQTexture(&t.face->brushprimit_texdef, t.face->d_texture, &bp_local, NULL);
Texture_SetTexture(&t.face->texdef, &bp_local, false, true);
}
UpdateSurfaceDialog();
UpdatePatchInspector();
UpdateLightInspector();
}
else {
Sys_Status("Did not select a texture\n");
}
return;
}
// ctrl-middle button = set entire brush to texture
if (buttons == (nMouseButton | MK_CONTROL)) {
t = Test_Ray(origin, dir, false);
if (t.brush) {
if (t.brush->brush_faces->texdef.name[0] == '(') {
Sys_Status("Can't change an entity texture\n");
}
else {
Brush_SetTexture
(
t.brush,
&g_qeglobals.d_texturewin.texdef,
&g_qeglobals.d_texturewin.brushprimit_texdef,
false
);
Sys_UpdateWindows(W_ALL);
}
}
else {
Sys_Status("Didn't hit a btrush\n");
}
return;
}
// ctrl-shift-middle button = set single face to texture
if (buttons == (nMouseButton | MK_SHIFT | MK_CONTROL)) {
t = Test_Ray(origin, dir, false);
if (t.brush) {
if (t.brush->brush_faces->texdef.name[0] == '(') {
Sys_Status("Can't change an entity texture\n");
}
else {
SetFaceTexdef
(
t.brush,
t.face,
&g_qeglobals.d_texturewin.texdef,
&g_qeglobals.d_texturewin.brushprimit_texdef
);
Brush_Build(t.brush);
Sys_UpdateWindows(W_ALL);
}
}
else {
Sys_Status("Didn't hit a btrush\n");
}
return;
}
if (buttons == (nMouseButton | MK_SHIFT)) {
Sys_Status("Set brush face texture info\n");
t = Test_Ray(origin, dir, false);
if (t.brush && !t.brush->owner->eclass->fixedsize) {
/*
if (t.brush->brush_faces->texdef.name[0] == '(') {
if (t.brush->owner->eclass->nShowFlags & ECLASS_LIGHT) {
CString strBuff;
idMaterial *pTex = declManager->FindMaterial(g_qeglobals.d_texturewin.texdef.name);
if (pTex) {
idVec3 vColor = pTex->getColor();
float fLargest = 0.0f;
for (int i = 0; i < 3; i++) {
if (vColor[i] > fLargest) {
fLargest = vColor[i];
}
}
if (fLargest == 0.0f) {
vColor[0] = vColor[1] = vColor[2] = 1.0f;
}
else {
float fScale = 1.0f / fLargest;
for (int i = 0; i < 3; i++) {
vColor[i] *= fScale;
}
}
strBuff.Format("%f %f %f", pTex->getColor().x, pTex->getColor().y, pTex->getColor().z);
SetKeyValue(t.brush->owner, "_color", strBuff.GetBuffer(0));
Sys_UpdateWindows(W_ALL);
}
}
else {
Sys_Status("Can't select an entity brush face\n");
}
}
else {
*/
// strcpy(t.face->texdef.name,g_qeglobals.d_texturewin.texdef.name);
t.face->texdef.SetName(g_qeglobals.d_texturewin.texdef.name);
Brush_Build(t.brush);
Sys_UpdateWindows(W_ALL);
// }
}
else {
Sys_Status("Didn't hit a brush\n");
}
return;
}
}
void Brush_GetBounds(brush_t *b, idVec3 &mins, idVec3 &maxs) {
int i;
for (i = 0; i < 3; i++) {
mins[i] = 999999;
maxs[i] = -999999;
}
for (i = 0; i < 3; i++) {
if (b->mins[i] < mins[i]) {
mins[i] = b->mins[i];
}
if (b->maxs[i] > maxs[i]) {
maxs[i] = b->maxs[i];
}
}
}
/*
================
MoveSelection
================
*/
static void MoveSelection( const idVec3 &orgMove ) {
int i, success;
brush_t *b;
CString strStatus;
idVec3 vTemp, vTemp2, end, move;
move = orgMove;
if (!move[0] && !move[1] && !move[2]) {
return;
}
move[0] = (g_nScaleHow & SCALE_X) ? 0 : move[0];
move[1] = (g_nScaleHow & SCALE_Y) ? 0 : move[1];
move[2] = (g_nScaleHow & SCALE_Z) ? 0 : move[2];
if (g_pParentWnd->ActiveXY()->RotateMode() || g_bPatchBendMode) {
float fDeg = -move[2];
float fAdj = move[2];
int axis = 0;
if (g_pParentWnd->ActiveXY()->GetViewType() == XY) {
fDeg = -move[1];
fAdj = move[1];
axis = 2;
}
else if (g_pParentWnd->ActiveXY()->GetViewType() == XZ) {
fDeg = move[2];
fAdj = move[2];
axis = 1;
}
g_pParentWnd->ActiveXY()->Rotation()[g_qeglobals.rotateAxis] += fAdj;
strStatus.Format
(
"%s x:: %.1f y:: %.1f z:: %.1f",
(g_bPatchBendMode) ? "Bend angle" : "Rotation",
g_pParentWnd->ActiveXY()->Rotation()[0],
g_pParentWnd->ActiveXY()->Rotation()[1],
g_pParentWnd->ActiveXY()->Rotation()[2]
);
g_pParentWnd->SetStatusText(2, strStatus);
if (g_bPatchBendMode) {
Patch_SelectBendNormal();
Select_RotateAxis(axis, fDeg * 2, false, true);
Patch_SelectBendAxis();
Select_RotateAxis(axis, fDeg, false, true);
}
else {
Select_RotateAxis(g_qeglobals.rotateAxis, fDeg, false, true);
}
return;
}
if (g_pParentWnd->ActiveXY()->ScaleMode()) {
idVec3 v;
v[0] = v[1] = v[2] = 1.0f;
for (int i = 0; i < 3; i++) {
if ( move[i] > 0.0f ) {
v[i] = 1.1f;
} else if ( move[i] < 0.0f ) {
v[i] = 0.9f;
}
}
Select_Scale(v.x, v.y, v.z);
Sys_UpdateWindows(W_ALL);
return;
}
idVec3 vDistance;
VectorSubtract(pressdelta, vPressStart, vDistance);
strStatus.Format("Distance x: %.3f y: %.3f z: %.3f", vDistance[0], vDistance[1], vDistance[2]);
g_pParentWnd->SetStatusText(3, strStatus);
// dragging only a part of the selection
if (UpdateActiveDragPoint(move)) {
UpdateLightInspector();
return;
}
//
// this is fairly crappy way to deal with curvepoint and area selection but it
// touches the smallest amount of code this way
//
if (g_qeglobals.d_num_move_points || g_qeglobals.d_num_move_planes || g_qeglobals.d_select_mode == sel_area) {
// area selection
if (g_qeglobals.d_select_mode == sel_area) {
VectorAdd(g_qeglobals.d_vAreaBR, move, g_qeglobals.d_vAreaBR);
return;
}
// curve point selection
if (g_qeglobals.d_select_mode == sel_curvepoint) {
Patch_UpdateSelected(move);
return;
}
// vertex selection
if (g_qeglobals.d_select_mode == sel_vertex) {
success = true;
for (b = selected_brushes.next; b != &selected_brushes; b = b->next) {
success &= Brush_MoveVertex(selected_brushes.next, *g_qeglobals.d_move_points[0], move, end, true);
}
// if (success)
VectorCopy(end, *g_qeglobals.d_move_points[0]);
return;
}
// all other selection types
for (i = 0; i < g_qeglobals.d_num_move_points; i++) {
VectorAdd(*g_qeglobals.d_move_points[i], move, *g_qeglobals.d_move_points[i]);
}
if ( g_qeglobals.d_select_mode == sel_editpoint ) {
g_Inspectors->entityDlg.UpdateEntityCurve();
}
//
// VectorScale(move, .5, move); for (i=0 ; i<g_qeglobals.d_num_move_points2 ; i++)
// VectorAdd (g_qeglobals.d_move_points2[i], move, g_qeglobals.d_move_points2[i]);
//
for (b = selected_brushes.next; b != &selected_brushes; b = b->next) {
VectorCopy(b->maxs, vTemp);
VectorSubtract(vTemp, b->mins, vTemp);
Brush_Build(b);
for (i = 0; i < 3; i++) {
if
(
b->mins[i] > b->maxs[i] ||
b->maxs[i] - b->mins[i] > MAX_WORLD_SIZE ||
b->maxs[i] - b->mins[i] == 0.0f
) {
break; // dragged backwards or messed up
}
}
if (i != 3) {
break;
}
if (b->pPatch) {
VectorCopy(b->maxs, vTemp2);
VectorSubtract(vTemp2, b->mins, vTemp2);
VectorSubtract(vTemp2, vTemp, vTemp2);
// if (!Patch_DragScale(b->nPatchID, vTemp2, move))
if (!Patch_DragScale(b->pPatch, vTemp2, move)) {
b = NULL;
break;
}
}
}
// if any of the brushes were crushed out of existance calcel the entire move
if (b != &selected_brushes) {
Sys_Status("Brush dragged backwards, move canceled\n");
for (i = 0; i < g_qeglobals.d_num_move_points; i++) {
VectorSubtract(*g_qeglobals.d_move_points[i], move, *g_qeglobals.d_move_points[i]);
}
for (b = selected_brushes.next; b != &selected_brushes; b = b->next) {
Brush_Build(b);
}
}
}
else {
//
// reset face originals from vertex edit mode this is dirty, but unfortunately
// necessary because Brush_Build can remove windings
//
for (b = selected_brushes.next; b != &selected_brushes; b = b->next) {
Brush_ResetFaceOriginals(b);
}
Select_Move(move);
}
}
/*
================
Drag_MouseMoved
================
*/
void Drag_MouseMoved(int x, int y, int buttons) {
idVec3 move, delta;
int i;
if (!buttons || !drag_ok) {
drag_ok = false;
return;
}
// clear along one axis
if (buttons & MK_SHIFT) {
drag_first = false;
if (abs(x - pressx) > abs(y - pressy)) {
y = pressy;
}
else {
x = pressx;
}
}
for (i = 0; i < 3; i++) {
move[i] = drag_xvec[i] * (x - pressx) + drag_yvec[i] * (y - pressy);
if (!g_PrefsDlg.m_bNoClamp) {
move[i] = floor(move[i] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize;
}
}
VectorSubtract(move, pressdelta, delta);
VectorCopy(move, pressdelta);
if (buttons & MK_CONTROL && g_pParentWnd->ActiveXY()->RotateMode()) {
for (i = 0; i < 3; i++) {
if (delta[i] != 0) {
if (delta[i] > 0) {
delta[i] = 15;
}
else {
delta[i] = -15;
}
}
}
}
MoveSelection(delta);
}
/*
================
Drag_MouseUp
================
*/
void Drag_MouseUp(int nButtons) {
Sys_Status("drag completed.", 0);
if (g_qeglobals.d_select_mode == sel_area) {
Patch_SelectAreaPoints();
g_qeglobals.d_select_mode = sel_curvepoint;
Sys_UpdateWindows(W_ALL);
}
if (g_qeglobals.d_select_translate[0] || g_qeglobals.d_select_translate[1] || g_qeglobals.d_select_translate[2]) {
Select_Move(g_qeglobals.d_select_translate);
VectorCopy(vec3_origin, g_qeglobals.d_select_translate);
Sys_UpdateWindows(W_CAMERA);
}
g_pParentWnd->SetStatusText(3, "");
/*
if (g_pParentWnd->GetCamera()->UpdateRenderEntities()) {
Sys_UpdateWindows(W_CAMERA);
}
*/
Undo_EndBrushList(&selected_brushes);
Undo_End();
}

View File

@@ -0,0 +1,101 @@
/*
===========================================================================
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 "qe3.h"
#include "Radiant.h"
#include "DialogInfo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDialogInfo dialog
CDialogInfo g_dlgInfo;
void ShowInfoDialog(const char* pText)
{
if (g_dlgInfo.GetSafeHwnd())
{
g_dlgInfo.m_wndInfo.SetWindowText(pText);
g_dlgInfo.ShowWindow(SW_SHOW);
}
else
{
g_dlgInfo.Create(IDD_DLG_INFORMATION);
g_dlgInfo.m_wndInfo.SetWindowText(pText);
g_dlgInfo.ShowWindow(SW_SHOW);
}
g_pParentWnd->SetFocus();
}
void HideInfoDialog()
{
if (g_dlgInfo.GetSafeHwnd())
g_dlgInfo.ShowWindow(SW_HIDE);
}
CDialogInfo::CDialogInfo(CWnd* pParent /*=NULL*/)
: CDialog(CDialogInfo::IDD, pParent)
{
//{{AFX_DATA_INIT(CDialogInfo)
//}}AFX_DATA_INIT
}
void CDialogInfo::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDialogInfo)
DDX_Control(pDX, IDC_EDIT1, m_wndInfo);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDialogInfo, CDialog)
//{{AFX_MSG_MAP(CDialogInfo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDialogInfo message handlers
BOOL CDialogInfo::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

View File

@@ -0,0 +1,75 @@
/*
===========================================================================
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.
===========================================================================
*/
#if !defined(AFX_DIALOGINFO_H__81DF2A33_A552_11D1_B58E_00AA00A410FC__INCLUDED_)
#define AFX_DIALOGINFO_H__81DF2A33_A552_11D1_B58E_00AA00A410FC__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// DialogInfo.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CDialogInfo dialog
void HideInfoDialog();
void ShowInfoDialog(const char* pText);
class CDialogInfo : public CDialog
{
// Construction
public:
CDialogInfo(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CDialogInfo)
enum { IDD = IDD_DLG_INFORMATION };
CEdit m_wndInfo;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDialogInfo)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CDialogInfo)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DIALOGINFO_H__81DF2A33_A552_11D1_B58E_00AA00A410FC__INCLUDED_)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,124 @@
/*
===========================================================================
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 __DIALOGTEXTURES_H
#define __DIALOGTEXTURES_H
// DialogTextures.h : header file
//
#include <afxtempl.h>
#include "GLWidget.h"
/////////////////////////////////////////////////////////////////////////////
// CDialogTextures dialog
class CDialogTextures : public CDialog
{
// Construction
public:
enum { NONE, TEXTURES, MATERIALS, MODELS, SCRIPTS, SOUNDS, SOUNDPARENT, GUIS, PARTICLES, FX,NUMIDS };
static const char *TypeNames[NUMIDS];
CDialogTextures(CWnd* pParent = NULL); // standard constructor
void OnCancel();
void CollapseEditor();
void SelectCurrentItem(bool collapse, const char *name, int id);
// Dialog Data
//{{AFX_DATA(CDialogTextures)
enum { IDD = IDD_DIALOG_TEXTURELIST };
CButton m_chkHideRoot;
CButton m_btnRefresh;
CButton m_btnLoad;
idGLWidget m_wndPreview;
CTreeCtrl m_treeTextures;
//}}AFX_DATA
CImageList m_image;
idGLDrawable m_testDrawable;
idGLDrawableMaterial m_drawMaterial;
idGLDrawableModel m_drawModel;
const idMaterial *editMaterial;
idStr editGui;
idStr currentFile;
idStr mediaName;
bool setTexture;
bool ignoreCollapse;
int mode;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDialogTextures)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
protected:
void addStrList(const char *root, const idStrList &list, int id);
void addScripts(bool rootItems);
void addModels(bool rootItems);
void addMaterials(bool rootItems);
void addSounds(bool rootItems);
void addGuis(bool rootItems);
void addParticles(bool rootItems);
void BuildTree();
void CollapseChildren(HTREEITEM parent);
const char *buildItemName(HTREEITEM item, const char *rootName);
bool loadTree( HTREEITEM item, const idStr &name, CWaitDlg *dlg );
HTREEITEM findItem(const char *name, HTREEITEM item, HTREEITEM *foundItem);
// Generated message map functions
//{{AFX_MSG(CDialogTextures)
virtual void OnOK();
virtual BOOL OnInitDialog();
afx_msg void OnLoad();
afx_msg void OnRefresh();
afx_msg void OnClickTreeTextures(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnSelchangedTreeTextures(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnDblclkTreeTextures(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnPreview();
afx_msg void OnMaterialEdit();
afx_msg void OnMaterialInfo();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnCheckHideroot();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
idHashTable<HTREEITEM> quickTree;
idStr itemName;
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnNMRclickTreeTextures(NMHDR *pNMHDR, LRESULT *pResult);
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DIALOGTEXTURES_H__F3F3F984_E47E_11D1_B61B_00AA00A410FC__INCLUDED_)

View File

@@ -0,0 +1,73 @@
/*
===========================================================================
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 "qe3.h"
#include "Radiant.h"
#include "DialogThick.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDialogThick dialog
CDialogThick::CDialogThick(CWnd* pParent /*=NULL*/)
: CDialog(CDialogThick::IDD, pParent)
{
//{{AFX_DATA_INIT(CDialogThick)
m_bSeams = TRUE;
m_nAmount = 8;
//}}AFX_DATA_INIT
}
void CDialogThick::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDialogThick)
DDX_Check(pDX, IDC_CHECK_SEAMS, m_bSeams);
DDX_Text(pDX, IDC_EDIT_AMOUNT, m_nAmount);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDialogThick, CDialog)
//{{AFX_MSG_MAP(CDialogThick)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDialogThick message handlers

View File

@@ -0,0 +1,74 @@
/*
===========================================================================
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.
===========================================================================
*/
#if !defined(AFX_DIALOGTHICK_H__59F46602_553D_11D2_B082_00AA00A410FC__INCLUDED_)
#define AFX_DIALOGTHICK_H__59F46602_553D_11D2_B082_00AA00A410FC__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// DialogThick.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CDialogThick dialog
class CDialogThick : public CDialog
{
// Construction
public:
CDialogThick(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CDialogThick)
enum { IDD = IDD_DIALOG_THICKEN };
BOOL m_bSeams;
int m_nAmount;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDialogThick)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CDialogThick)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DIALOGTHICK_H__59F46602_553D_11D2_B082_00AA00A410FC__INCLUDED_)

View File

@@ -0,0 +1,373 @@
/*
===========================================================================
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/common_resource.h"
#include "../comafx/DialogName.h"
#include "qe3.h"
#include "DlgCamera.h"
#include "DlgEvent.h"
#include "splines.h"
#include "CameraTargetDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CDlgCamera g_dlgCamera;
void showCameraInspector() {
if (g_dlgCamera.GetSafeHwnd() == NULL) {
g_dlgCamera.Create(IDD_DLG_CAMERA);
CRect rct;
LONG lSize = sizeof(rct);
if (LoadRegistryInfo("Radiant::CameraInspector", &rct, &lSize)) {
g_dlgCamera.SetWindowPos(NULL, rct.left, rct.top, 0,0, SWP_NOSIZE | SWP_SHOWWINDOW);
}
Sys_UpdateWindows(W_ALL);
}
g_dlgCamera.ShowWindow(SW_SHOW);
g_dlgCamera.setupFromCamera();
}
/////////////////////////////////////////////////////////////////////////////
// CDlgCamera dialog
CDlgCamera::CDlgCamera(CWnd* pParent /*=NULL*/)
: CDialog(CDlgCamera::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgCamera)
m_strName = _T("");
m_fSeconds = 0.0f;
m_trackCamera = TRUE;
m_numSegments = 0;
m_currentSegment = 0;
m_strType = _T("");
m_editPoints = 0;
//}}AFX_DATA_INIT
}
void CDlgCamera::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgCamera)
DDX_Control(pDX, IDC_SCROLLBAR_SEGMENT, m_wndSegments);
DDX_Control(pDX, IDC_LIST_EVENTS, m_wndEvents);
DDX_Control(pDX, IDC_COMBO_SPLINES, m_wndSplines);
DDX_Text(pDX, IDC_EDIT_CAM_NAME, m_strName);
DDX_Text(pDX, IDC_EDIT_LENGTH, m_fSeconds);
DDX_Check(pDX, IDC_CHECK_TRACKCAMERA, m_trackCamera);
DDX_Text(pDX, IDC_EDIT_TOTALSEGMENTS, m_numSegments);
DDX_Text(pDX, IDC_EDIT_SEGMENT, m_currentSegment);
DDX_Text(pDX, IDC_EDIT_TYPE, m_strType);
DDX_Radio(pDX, IDC_RADIO_EDITPOINTS, m_editPoints);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgCamera, CDialog)
//{{AFX_MSG_MAP(CDlgCamera)
ON_BN_CLICKED(IDC_BTN_ADDEVENT, OnBtnAddevent)
ON_BN_CLICKED(IDC_BTN_ADDTARGET, OnBtnAddtarget)
ON_BN_CLICKED(IDC_BTN_DELEVENT, OnBtnDelevent)
ON_CBN_DBLCLK(IDC_COMBO_SPLINES, OnDblclkComboSplines)
ON_CBN_SELCHANGE(IDC_COMBO_SPLINES, OnSelchangeComboSplines)
ON_LBN_SELCHANGE(IDC_LIST_EVENTS, OnSelchangeListEvents)
ON_LBN_DBLCLK(IDC_LIST_EVENTS, OnDblclkListEvents)
ON_WM_DESTROY()
ON_BN_CLICKED(IDC_APPLY, OnApply)
ON_WM_HSCROLL()
ON_BN_CLICKED(ID_FILE_NEW, OnFileNew)
ON_BN_CLICKED(ID_FILE_OPEN, OnFileOpen)
ON_BN_CLICKED(ID_FILE_SAVE, OnFileSave)
ON_BN_CLICKED(IDC_TESTCAMERA, OnTestcamera)
ON_BN_CLICKED(IDC_BTN_DELETEPOINTS, OnBtnDeletepoints)
ON_BN_CLICKED(IDC_BTN_SELECTALL, OnBtnSelectall)
ON_BN_CLICKED(IDC_RADIO_EDITPOINTS, OnRadioEditpoints)
ON_BN_CLICKED(IDC_RADIO_EDITPOINTS2, OnRadioAddPoints)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgCamera message handlers
void CDlgCamera::OnBtnAddevent()
{
CDlgEvent dlg;
if (dlg.DoModal() == IDOK) {
long n = m_wndSegments.GetScrollPos() / 4 * 1000;
g_splineList->addEvent(static_cast<idCameraEvent::eventType>(dlg.m_event+1), dlg.m_strParm, n);
setupFromCamera();
}
}
void CDlgCamera::OnBtnAddtarget()
{
CCameraTargetDlg dlg;
if (dlg.DoModal() == IDOK) {
g_splineList->addTarget(dlg.m_strName, static_cast<idCameraPosition::positionType>(dlg.m_nType));
setupFromCamera();
m_wndSplines.SetCurSel(g_splineList->numTargets());
OnSelchangeComboSplines();
}
}
void CDlgCamera::OnBtnDelevent()
{
// TODO: Add your control notification handler code here
}
void CDlgCamera::OnBtnDeltarget()
{
// TODO: Add your control notification handler code here
}
void CDlgCamera::OnDblclkComboSplines()
{
// TODO: Add your control notification handler code here
}
void CDlgCamera::OnSelchangeComboSplines()
{
UpdateData(TRUE);
g_qeglobals.d_select_mode = (m_editPoints == 0) ? sel_editpoint : sel_addpoint;
g_qeglobals.d_numpoints = 0;
g_qeglobals.d_num_move_points = 0;
int i = m_wndSplines.GetCurSel();
if (i > 0) {
g_splineList->setActiveTarget(i-1);
g_qeglobals.selectObject = g_splineList->getActiveTarget(i-1);
g_splineList->startEdit(false);
} else {
g_splineList->startEdit(true);
g_qeglobals.selectObject = g_splineList->getPositionObj();
}
// * 4.0 to set increments in quarter seconds
m_wndSegments.SetScrollRange(0, g_splineList->getTotalTime() * 4.0);
Sys_UpdateWindows(W_ALL);
}
void CDlgCamera::OnSelchangeListEvents()
{
int sel = m_wndEvents.GetCurSel();
//g_splineList->setActiveSegment(sel >= 0 ? sel : 0);
}
void CDlgCamera::OnDblclkListEvents()
{
// TODO: Add your control notification handler code here
}
void CDlgCamera::setupFromCamera()
{
if (m_wndSplines.GetSafeHwnd()) {
int i;
idStr str;
m_strName = g_splineList->getName();
m_strType = g_splineList->getPositionObj()->typeStr();
m_wndSplines.ResetContent();
m_wndSplines.AddString("Path");
for (i = 0; i < g_splineList->numTargets(); i++) {
m_wndSplines.AddString(g_splineList->getActiveTarget(i)->getName());
}
m_wndSplines.SetCurSel(0);
m_fSeconds = g_splineList->getTotalTime();
m_wndSegments.SetScrollRange(0, g_splineList->getTotalTime() * 4.0);
m_wndEvents.ResetContent();
for (i = 0; i < g_splineList->numEvents(); i++) {
str = va("%s\t%s", g_splineList->getEvent(i)->typeStr(), g_splineList->getEvent(i)->getParam());
m_wndEvents.AddString(str);
}
//m_currentSegment = g_splineList->getActiveSegment();
//m_numSegments = g_splineList->numSegments();
}
g_splineList->startEdit(true);
UpdateData(FALSE);
}
BOOL CDlgCamera::OnInitDialog()
{
CDialog::OnInitDialog();
setupFromCamera();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgCamera::OnOK()
{
g_dlgCamera.ShowWindow(SW_HIDE);
g_qeglobals.d_select_mode = sel_brush;
g_splineList->stopEdit();
Sys_UpdateWindows(W_ALL);
}
void CDlgCamera::OnDestroy()
{
if (GetSafeHwnd()) {
CRect rct;
GetWindowRect(rct);
SaveRegistryInfo("Radiant::CameraInspector", &rct, sizeof(rct));
}
CDialog::OnDestroy();
Sys_UpdateWindows(W_ALL);
}
void CDlgCamera::OnApply()
{
UpdateData(TRUE);
g_splineList->setBaseTime(m_fSeconds);
g_splineList->setName(m_strName);
g_splineList->buildCamera();
m_wndSegments.SetScrollRange(0, g_splineList->getTotalTime() * 4.0);
}
void CDlgCamera::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
int max = g_splineList->getTotalTime() * 4;
if (max == 0) {
max = 1;
}
int n = pScrollBar->GetScrollPos();
switch (nSBCode) {
case SB_LINEUP : {
n--;
}
break;
case SB_LINEDOWN : {
n++;
}
break;
case SB_PAGEUP : {
n -= (float)max * 0.10;
}
break;
case SB_PAGEDOWN : {
n += (float)max * 0.10;
}
break;
case SB_THUMBPOSITION : {
n = nPos;
}
break;
case SB_THUMBTRACK : {
n = nPos;
}
}
// if (n < 0) {
// n = 0;
// } else if (n >= g_splineList->numSegments()) {
// if (g_splineList->numSegments() == 0) {
// g_splineList->buildCamera();
// }
// n = g_splineList->numSegments() - 1;
// }
pScrollBar->SetScrollPos(n);
if (m_trackCamera) {
float p = (float)n / max;
p *= g_splineList->getTotalTime() * 1000;
g_splineList->startCamera(0);
g_splineList->buildCamera();
idVec3 dir;
float fov;
g_splineList->getCameraInfo(p, g_pParentWnd->GetCamera()->Camera().origin, dir, &fov);
g_pParentWnd->GetCamera()->Camera().angles[1] = atan2 (dir[1], dir[0])*180/3.14159;
g_pParentWnd->GetCamera()->Camera().angles[0] = asin (dir[2])*180/3.14159;
}
UpdateData(FALSE);
Sys_UpdateWindows(W_XY | W_CAMERA);
}
void CDlgCamera::OnFileNew()
{
g_splineList->clear();
setupFromCamera();
}
void CDlgCamera::OnFileOpen()
{
DialogName dlg("Open Camera File");
if (dlg.DoModal() == IDOK) {
g_splineList->clear();
g_splineList->load(va("cameras/%s.camera", dlg.m_strName));
}
}
void CDlgCamera::OnFileSave()
{
DialogName dlg("Save Camera File");
if (dlg.DoModal() == IDOK) {
g_splineList->save(va("cameras/%s.camera", dlg.m_strName));
}
}
void CDlgCamera::OnTestcamera()
{
// TODO: Add your control notification handler code here
}
void CDlgCamera::OnBtnDeletepoints()
{
// TODO: Add your control notification handler code here
}
void CDlgCamera::OnBtnSelectall()
{
// TODO: Add your control notification handler code here
}
void CDlgCamera::OnRadioEditpoints()
{
UpdateData(TRUE);
g_qeglobals.d_select_mode = sel_editpoint;
}
void CDlgCamera::OnRadioAddPoints()
{
UpdateData(TRUE);
g_qeglobals.d_select_mode = sel_addpoint;
}

View File

@@ -0,0 +1,104 @@
/*
===========================================================================
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.
===========================================================================
*/
#if !defined(AFX_DLGCAMERA_H__59C12359_E3EB_4081_9F28_01793D75CF20__INCLUDED_)
#define AFX_DLGCAMERA_H__59C12359_E3EB_4081_9F28_01793D75CF20__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DlgCamera.h : header file
//
extern void showCameraInspector();
/////////////////////////////////////////////////////////////////////////////
// CDlgCamera dialog
class CDlgCamera : public CDialog
{
// Construction
public:
CDlgCamera(CWnd* pParent = NULL); // standard constructor
void setupFromCamera();
// Dialog Data
//{{AFX_DATA(CDlgCamera)
enum { IDD = IDD_DLG_CAMERA };
CScrollBar m_wndSegments;
CListBox m_wndEvents;
CComboBox m_wndSplines;
CString m_strName;
float m_fSeconds;
BOOL m_trackCamera;
int m_numSegments;
int m_currentSegment;
CString m_strType;
int m_editPoints;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDlgCamera)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CDlgCamera)
afx_msg void OnBtnAddevent();
afx_msg void OnBtnAddtarget();
afx_msg void OnBtnDelevent();
afx_msg void OnBtnDeltarget();
afx_msg void OnDblclkComboSplines();
afx_msg void OnSelchangeComboSplines();
afx_msg void OnSelchangeListEvents();
afx_msg void OnDblclkListEvents();
virtual BOOL OnInitDialog();
virtual void OnOK();
afx_msg void OnDestroy();
afx_msg void OnApply();
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnFileNew();
afx_msg void OnFileOpen();
afx_msg void OnFileSave();
afx_msg void OnTestcamera();
afx_msg void OnBtnDeletepoints();
afx_msg void OnBtnSelectall();
afx_msg void OnRadioEditpoints();
afx_msg void OnRadioAddPoints();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DLGCAMERA_H__59C12359_E3EB_4081_9F28_01793D75CF20__INCLUDED_)

View File

@@ -0,0 +1,72 @@
/*
===========================================================================
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 "qe3.h"
#include "DlgEvent.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgEvent dialog
CDlgEvent::CDlgEvent(CWnd* pParent /*=NULL*/)
: CDialog(CDlgEvent::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgEvent)
m_strParm = _T("");
m_event = 0;
//}}AFX_DATA_INIT
}
void CDlgEvent::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgEvent)
DDX_Text(pDX, IDC_EDIT_PARAM, m_strParm);
DDX_Radio(pDX, IDC_RADIO_EVENT, m_event);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgEvent, CDialog)
//{{AFX_MSG_MAP(CDlgEvent)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgEvent message handlers

View File

@@ -0,0 +1,75 @@
/*
===========================================================================
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.
===========================================================================
*/
#if !defined(AFX_DLGEVENT_H__B12EEBE1_FB71_407B_9075_50F63B168567__INCLUDED_)
#define AFX_DLGEVENT_H__B12EEBE1_FB71_407B_9075_50F63B168567__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DlgEvent.h : header file
//
#include "splines.h"
/////////////////////////////////////////////////////////////////////////////
// CDlgEvent dialog
class CDlgEvent : public CDialog
{
// Construction
public:
CDlgEvent(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CDlgEvent)
enum { IDD = IDD_DLG_CAMERAEVENT };
CString m_strParm;
int m_event;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDlgEvent)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CDlgEvent)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DLGEVENT_H__B12EEBE1_FB71_407B_9075_50F63B168567__INCLUDED_)

View File

@@ -0,0 +1,454 @@
/*
===========================================================================
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 "qe3.h"
#include "io.h"
#include "../../renderer/tr_local.h"
struct evarPrefix_t {
int type;
const char *prefix;
};
const evarPrefix_t EvarPrefixes[] = {
{ EVAR_STRING, "editor_var " },
{ EVAR_INT, "editor_int " },
{ EVAR_FLOAT, "editor_float " },
{ EVAR_BOOL, "editor_bool " },
{ EVAR_COLOR, "editor_color " },
{ EVAR_MATERIAL,"editor_mat " },
{ EVAR_MODEL, "editor_model " },
{ EVAR_GUI, "editor_gui " },
{ EVAR_SOUND, "editor_snd "}
};
const int NumEvarPrefixes = sizeof(EvarPrefixes) / sizeof(evarPrefix_t);
eclass_t *eclass = NULL;
eclass_t *eclass_bad = NULL;
char eclass_directory[1024];
// md3 cache for misc_models
eclass_t *g_md3Cache = NULL;
/*
the classname, color triple, and bounding box are parsed out of comments
A ? size means take the exact brush size.
/*QUAKED <classname> (0 0 0) ?
/*QUAKED <classname> (0 0 0) (-8 -8 -8) (8 8 8)
Flag names can follow the size description:
/*QUAKED func_door (0 .5 .8) ? START_OPEN STONE_SOUND DOOR_DONT_LINK GOLD_KEY SILVER_KEY
*/
void CleanEntityList( eclass_t *&pList ) {
while (pList) {
eclass_t* pTemp = pList->next;
delete pList;
pList = pTemp;
}
pList = NULL;
}
void CleanUpEntities()
{
CleanEntityList(eclass);
CleanEntityList(g_md3Cache);
if ( eclass_bad ) {
delete eclass_bad;
eclass_bad = NULL;
}
}
void ExtendBounds(idVec3 v, idVec3 &vMin, idVec3 &vMax)
{
for (int i = 0 ;i < 3 ;i++)
{
float f = v[i];
if (f < vMin[i])
{
vMin[i] = f;
}
if (f > vMax[i])
{
vMax[i] = f;
}
}
}
bool LoadModel(const char *pLocation, eclass_t *e, idVec3 &vMin, idVec3 &vMax, const char *pSkin)
{
vMin[0] = vMin[1] = vMin[2] = 999999;
vMax[0] = vMax[1] = vMax[2] = -999999;
if (strstr(pLocation, ".ase") != NULL) // FIXME: not correct!
{
idBounds b;
e->modelHandle = renderModelManager->FindModel( pLocation );
b = e->modelHandle->Bounds( NULL );
VectorCopy(b[0], vMin);
VectorCopy(b[1], vMax);
return true;
}
return false;
}
eclass_t *EClass_Alloc( void ) {
eclass_t *e;
e = new eclass_t;
if ( e == NULL ) {
return NULL;
}
e->fixedsize = false;
e->unknown = false;
e->mins.Zero();
e->maxs.Zero();
e->color.Zero();
memset( &e->texdef, 0, sizeof( e->texdef ) );
e->modelHandle = NULL;
e->entityModel = NULL;
e->nFrame = 0;
e->nShowFlags = 0;
e->hPlug = 0;
e->next = NULL;
return e;
}
eclass_t *EClass_InitFromDict( const idDict *d, const char *name ) {
eclass_t *e;
const idKeyValue *kv;
// only include entityDefs with "editor_" values in them
if ( !d->MatchPrefix( "editor_" ) ) {
return NULL;
}
e = EClass_Alloc();
if ( !e ) {
return NULL;
}
e->defArgs = *d;
idStr str;
idStr text;
idStr varname;
idStr defaultStr;
e->name = name;
d->GetVector("editor_color", "0 0 1", e->color);
d->GetString("editor_mins", "", str);
if (str != "?") {
d->GetVector("editor_mins", "0 0 0", e->mins);
d->GetVector("editor_maxs", "0 0 0", e->maxs);
e->fixedsize = true;
} else {
e->fixedsize = false;
}
d->GetString("editor_material", "", e->defMaterial);
//str = d->GetString("model");
//if (str.Length()) {
// e->entityModel = renderModelManager->FindModel(str);
//}
str = "";
// concatenate all editor usage comments
text = "";
kv = d->MatchPrefix( "editor_usage" );
while( kv != NULL ) {
text += kv->GetValue();
if ( !kv->GetValue().Length() || ( text[ text.Length() - 1 ] != '\n' ) ) {
text += "\n";
}
kv = d->MatchPrefix( "editor_usage", kv );
}
e->desc = text;
str += "Spawn args:\n";
for (int i = 0; i < NumEvarPrefixes; i++) {
kv = d->MatchPrefix(EvarPrefixes[i].prefix);
while (kv) {
evar_t ev;
kv->GetKey().Right( kv->GetKey().Length() - strlen(EvarPrefixes[i].prefix), ev.name );
ev.desc = kv->GetValue();
ev.type = EvarPrefixes[i].type;
e->vars.Append(ev);
kv = d->MatchPrefix(EvarPrefixes[i].prefix, kv);
}
}
/*
while( kv != NULL ) {
kv->key.Right( kv->key.Length() - 11, varname );
str += va( "'%s':\t %s", varname.c_str(), kv->value.c_str() );
if ( d->GetString( varname, "", defaultStr ) && defaultStr.Length() ) {
str += va( " Default '%s'.", defaultStr.c_str() );
}
str += "\n";
kv = d->MatchPrefix( "editor_var ", kv );
}
e->comments = Mem_CopyString( str.c_str() );
*/
// concatenate all variable comments
kv = d->MatchPrefix( "editor_copy" );
while (kv) {
const char *temp = d->GetString(kv->GetValue());
if (temp && *temp) {
e->args.Set(kv->GetValue(), d->GetString(kv->GetValue()));
}
kv = d->MatchPrefix("editor_copy", kv);
}
// setup show flags
e->nShowFlags = 0;
if (d->GetBool("editor_rotatable")) {
e->nShowFlags |= ECLASS_ROTATABLE;
}
if (d->GetBool("editor_showangle")) {
e->nShowFlags |= ECLASS_ANGLE;
}
if (d->GetBool("editor_mover")) {
e->nShowFlags |= ECLASS_MOVER;
}
if (d->GetBool("editor_env") || idStr::Icmpn(e->name, "env_", 4) == 0) {
e->nShowFlags |= (ECLASS_ENV | ECLASS_ROTATABLE);
if (d->GetBool("editor_ragdoll")) {
e->defArgs.Set("model", "");
}
}
if (d->GetBool("editor_combatnode")) {
e->nShowFlags |= ECLASS_COMBATNODE;
}
if (d->GetBool("editor_light")) {
e->nShowFlags |= ECLASS_LIGHT;
}
if ( idStr::Icmp(e->name, "light") == 0 ) {
e->nShowFlags |= ECLASS_LIGHT;
} else if ( idStr::Icmp(e->name, "path") == 0 ) {
e->nShowFlags |= ECLASS_PATH;
} else if ( idStr::Icmp(e->name, "target_null") == 0 ) {
e->nShowFlags |= ECLASS_CAMERAVIEW;
} else if ( idStr::Icmp(e->name, "worldspawn") == 0 ) {
e->nShowFlags |= ECLASS_WORLDSPAWN;
} else if ( idStr::Icmp(e->name, "speaker") == 0 ) {
e->nShowFlags |= ECLASS_SPEAKER;
} else if ( idStr::Icmp( e->name, "func_emitter" ) == 0 || idStr::Icmp( e->name, "func_splat" ) == 0 ) {
e->nShowFlags |= ECLASS_PARTICLE;
} else if ( idStr::Icmp(e->name, "func_liquid") == 0 ) {
e->nShowFlags |= ECLASS_LIQUID;
}
return e;
}
void EClass_InsertSortedList(eclass_t *&pList, eclass_t *e)
{
eclass_t *s;
if (!pList)
{
pList = e;
return;
}
s = pList;
if (stricmp (e->name, s->name) < 0)
{
e->next = s;
pList = e;
return;
}
do
{
if (!s->next || stricmp (e->name, s->next->name) < 0)
{
e->next = s->next;
s->next = e;
return;
}
s=s->next;
} while (1);
}
/*
=================
Eclass_InsertAlphabetized
=================
*/
void Eclass_InsertAlphabetized (eclass_t *e)
{
#if 1
EClass_InsertSortedList(eclass, e);
#else
eclass_t *s;
if (!eclass)
{
eclass = e;
return;
}
s = eclass;
if (stricmp (e->name, s->name) < 0)
{
e->next = s;
eclass = e;
return;
}
do
{
if (!s->next || stricmp (e->name, s->next->name) < 0)
{
e->next = s->next;
s->next = e;
return;
}
s=s->next;
} while (1);
#endif
}
void Eclass_InitForSourceDirectory (const char *path)
{
int c = declManager->GetNumDecls(DECL_ENTITYDEF);
for (int i = 0; i < c; i++) {
const idDeclEntityDef *def = static_cast<const idDeclEntityDef *>( declManager->DeclByIndex( DECL_ENTITYDEF, i ) );
if ( def ) {
eclass_t *e = EClass_InitFromDict( &def->dict, def->GetName() );
if ( e ) {
Eclass_InsertAlphabetized (e);
}
}
}
eclass_bad = EClass_Alloc();
if ( !eclass_bad ) {
return;
}
eclass_bad->color.x = 0.0f;
eclass_bad->color.y = 0.5f;
eclass_bad->color.z = 0.0f;
eclass_bad->fixedsize = false;
eclass_bad->name = Mem_CopyString( "UKNOWN ENTITY CLASS" );
}
eclass_t *Eclass_ForName (const char *name, bool has_brushes)
{
eclass_t *e;
char buff[1024];
if (!name) {
return eclass_bad;
}
for ( e = eclass; e; e = e->next ) {
if ( !strcmp( name, e->name ) ) {
return e;
}
}
e = EClass_Alloc();
if ( !e ) {
return NULL;
}
e->name = Mem_CopyString( name );
sprintf(buff, "%s not found in def/*.def\n", name);
e->comments = Mem_CopyString( buff );
e->color.x = 0.0f;
e->color.y = 0.5f;
e->color.z = 0.0f;
e->fixedsize = !has_brushes;
e->mins.x = e->mins.y = e->mins.z = -8.0f;
e->maxs.x = e->maxs.y = e->maxs.z = 8.0f;
Eclass_InsertAlphabetized( e );
return e;
}
eclass_t* GetCachedModel(entity_t *pEntity, const char *pName, idVec3 &vMin, idVec3 &vMax)
{
eclass_t *e = NULL;
if (pName == NULL || strlen(pName) == 0) {
return NULL;
}
for (e = g_md3Cache; e ; e = e->next) {
if (!strcmp (pName, e->name)) {
pEntity->md3Class = e;
VectorCopy(e->mins, vMin);
VectorCopy(e->maxs, vMax);
return e;
}
}
e = (eclass_t*)Mem_ClearedAlloc(sizeof(*e));
memset (e, 0, sizeof(*e));
e->name = Mem_CopyString( pName );
e->color[0] = e->color[2] = 0.85f;
if (LoadModel(pName, e, vMin, vMax, NULL)) {
EClass_InsertSortedList(g_md3Cache, e);
VectorCopy(vMin, e->mins);
VectorCopy(vMax, e->maxs);
pEntity->md3Class = e;
return e;
}
return NULL;
}

View File

@@ -0,0 +1,303 @@
/*
===========================================================================
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 "qe3.h"
#include "Radiant.h"
#include "EditViewDlg.h"
// CEditViewDlg dialog
IMPLEMENT_DYNAMIC(CEditViewDlg, CDialog)
CEditViewDlg::CEditViewDlg(CWnd* pParent /*=NULL*/)
: CDialog(CEditViewDlg::IDD, pParent)
{
findDlg = NULL;
}
CEditViewDlg::~CEditViewDlg() {
}
void CEditViewDlg::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_EDIT_INFO, editInfo);
}
static UINT FindDialogMessage = ::RegisterWindowMessage(FINDMSGSTRING);
BEGIN_MESSAGE_MAP(CEditViewDlg, CDialog)
ON_WM_SIZE()
ON_BN_CLICKED(IDC_BUTTON_OPEN, OnBnClickedButtonOpen)
ON_BN_CLICKED(IDC_BUTTON_SAVE, OnBnClickedButtonSave)
ON_WM_DESTROY()
ON_WM_TIMER()
ON_BN_CLICKED(IDC_BUTTON_GOTO, OnBnClickedButtonGoto)
ON_REGISTERED_MESSAGE(FindDialogMessage, OnFindDialogMessage)
END_MESSAGE_MAP()
// CEditViewDlg message handlers
void CEditViewDlg::OnSize(UINT nType, int cx, int cy) {
CDialog::OnSize(nType, cx, cy);
if (GetSafeHwnd() == NULL) {
return;
}
CRect rect, crect;
GetClientRect(rect);
CWnd *wnd = GetDlgItem(IDC_BUTTON_OPEN);
if (wnd == NULL || (wnd && wnd->GetSafeHwnd() == NULL)) {
return;
}
wnd->GetWindowRect(crect);
wnd->SetWindowPos(NULL, 4, 4, crect.Width(), crect.Height(), SWP_SHOWWINDOW);
wnd = GetDlgItem(IDC_BUTTON_SAVE);
int left = 8 + crect.Width();
wnd->SetWindowPos(NULL, left, 4, crect.Width(), crect.Height(), SWP_SHOWWINDOW);
wnd = GetDlgItem(IDOK);
wnd->SetWindowPos(NULL, rect.Width() - crect.Width() - 4, 4, crect.Width(), crect.Height(), SWP_SHOWWINDOW);
editInfo.SetWindowPos(NULL, 4, 8 + crect.Height(), rect.Width() - 8, rect.Height() - crect.Height() * 2 - 16, SWP_SHOWWINDOW);
wnd = GetDlgItem(IDC_BUTTON_GOTO);
wnd->SetWindowPos(NULL, 4, rect.Height() - 4 - crect.Height(), crect.Width(), crect.Height(), SWP_SHOWWINDOW);
wnd = GetDlgItem(IDC_EDIT_GOTO);
wnd->SetWindowPos(NULL, 8 + crect.Width(), rect.Height() - 3 - crect.Height(), crect.Width() + 8, crect.Height() - 3, SWP_SHOWWINDOW);
wnd = GetDlgItem(IDC_STATIC_LINE);
wnd->SetWindowPos(NULL, 30 + crect.Width() * 2, rect.Height() - crect.Height(), crect.Width() * 2, crect.Height(), SWP_SHOWWINDOW);
wnd = GetDlgItem(IDC_EDIT_LINE);
wnd->SetWindowPos(NULL, 40 + crect.Width() * 3, rect.Height() - crect.Height(), crect.Width() + 8, crect.Height(), SWP_SHOWWINDOW);
}
void CEditViewDlg::ShowFindDlg() {
if (findDlg) {
return;
}
findDlg = new CFindReplaceDialog();
findDlg->Create(TRUE, findStr, NULL, FR_DOWN, this);
}
void CEditViewDlg::OnBnClickedButtonOpen() {
CPreviewDlg *dlg = NULL;
dlg = ((mode == MATERIALS) ? CEntityDlg::ShowMaterialChooser() : CEntityDlg::ShowGuiChooser());
if (dlg) {
if (mode == MATERIALS) {
const idMaterial *mat = declManager->FindMaterial(dlg->mediaName);
SetMaterialInfo(mat->GetName(), mat->GetFileName(), mat->GetLineNum());
} else {
SetGuiInfo(dlg->mediaName);
}
}
}
void CEditViewDlg::OnBnClickedButtonSave() {
if (fileName.Length()) {
CString text;
editInfo.GetWindowText(text);
fileSystem->WriteFile(fileName, text.GetBuffer(0), text.GetLength(), "fs_devpath");
if (mode == MATERIALS) {
declManager->Reload( false );
} else {
uiManager->Reload(false);
}
}
}
void CEditViewDlg::UpdateEditPreview() {
if (GetSafeHwnd() && editInfo.GetSafeHwnd()) {
editInfo.SetWindowText(editText);
editInfo.LineScroll(line);
int cindex = editInfo.LineIndex(line);
int len = editInfo.LineLength(line);
editInfo.SetSel(cindex, cindex);
mediaPreview.SetMode((mode == MATERIALS) ? CMediaPreviewDlg::MATERIALS : CMediaPreviewDlg::GUIS);
mediaPreview.SetMedia((mode == MATERIALS) ? matName : fileName);
SetWindowText(va("Editing %s in file <%s>", (mode == MATERIALS) ? matName.c_str() : fileName.c_str(), fileName.c_str()));
editInfo.SetFocus();
}
}
BOOL CEditViewDlg::OnInitDialog() {
CDialog::OnInitDialog();
mediaPreview.Create(IDD_DIALOG_EDITPREVIEW, this);
mediaPreview.ShowWindow(SW_SHOW);
CRect rct;
LONG lSize = sizeof(rct);
if (LoadRegistryInfo("Radiant::EditViewWindow", &rct, &lSize)) {
SetWindowPos(NULL, rct.left, rct.top, rct.Width(), rct.Height(), SWP_SHOWWINDOW);
}
editInfo.SetTabStops();
editInfo.SetLimitText(1024 * 1024);
UpdateEditPreview();
SetTimer(1, 250, NULL);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CEditViewDlg::OnDestroy() {
if (GetSafeHwnd()) {
CRect rct;
GetWindowRect(rct);
SaveRegistryInfo("Radiant::EditViewWindow", &rct, sizeof(rct));
}
CDialog::OnDestroy();
}
void CEditViewDlg::SetMaterialInfo(const char *name, const char *file, int _line) {
idStr str;
void *buf;
fileName = "";
matName = "";
line = 0;
str = fileSystem->OSPathToRelativePath( file );
int size = fileSystem->ReadFile( str, &buf );
if (size > 0) {
fileName = str;
matName = name;
line = _line - 1;
if (line < 0) {
line = 0;
}
editText = (char*)buf;
fileSystem->FreeFile(buf);
}
UpdateEditPreview();
}
void CEditViewDlg::SetGuiInfo(const char *name) {
fileName = "";
line = 0;
void *buf;
int size = fileSystem->ReadFile(name, &buf, NULL);
if (size > 0) {
fileName = name;
editText = (char*)buf;
fileSystem->FreeFile(buf);
}
UpdateEditPreview();
}
void CEditViewDlg::OnTimer(UINT nIDEvent) {
CDialog::OnTimer(nIDEvent);
CWnd *wnd = GetDlgItem(IDC_EDIT_LINE);
if (wnd) {
int start, end;
editInfo.GetSel(start, end);
wnd->SetWindowText(va("%i",editInfo.LineFromChar(start)));
}
}
void CEditViewDlg::OnBnClickedButtonGoto() {
CWnd *wnd = GetDlgItem(IDC_EDIT_GOTO);
if (wnd) {
CString str;
wnd->GetWindowText(str);
if (str.GetLength()) {
int l = atoi(str);
editInfo.SetSel(0, 0);
editInfo.LineScroll(l);
int cindex = editInfo.LineIndex(l);
int len = editInfo.LineLength(l);
editInfo.SetSel(cindex, cindex);
editInfo.RedrawWindow();
editInfo.SetFocus();
}
}
}
BOOL CEditViewDlg::PreTranslateMessage(MSG* pMsg) {
if (pMsg->message == WM_KEYDOWN && (pMsg->wParam == 's' || pMsg->wParam == 'S') && GetAsyncKeyState(VK_CONTROL) & 0x8000) {
OnBnClickedButtonSave();
return TRUE;
}
if (pMsg->message == WM_KEYDOWN && (pMsg->wParam == 'o' || pMsg->wParam == 'O') && GetAsyncKeyState(VK_CONTROL) & 0x8000) {
OnBnClickedButtonOpen();
return TRUE;
}
if (pMsg->message == WM_KEYDOWN && (pMsg->wParam == 'f' || pMsg->wParam == 'F') && GetAsyncKeyState(VK_CONTROL) & 0x8000) {
ShowFindDlg();
return TRUE;
}
if (pMsg->hwnd == editInfo.GetSafeHwnd() && (pMsg->message == WM_KEYDOWN) && (pMsg->wParam == VK_TAB)) {
// get the char index of the caret position
int nPos = LOWORD(editInfo.CharFromPos(editInfo.GetCaretPos()));
// select zero chars
editInfo.SetSel(nPos, nPos);
// then replace that selection with a TAB
editInfo.ReplaceSel("\t", TRUE);
return TRUE;
}
return CDialog::PreTranslateMessage(pMsg);
}
LRESULT CEditViewDlg::OnFindDialogMessage(WPARAM wParam, LPARAM lParam) {
if (findDlg == NULL) {
return 0;
}
if (findDlg->IsTerminating()) {
findDlg = NULL;
return 0;
}
// If the FR_FINDNEXT flag is set,
// call the application-defined search routine
// to search for the requested string.
if(findDlg->FindNext()) {
//read data from dialog
findStr = findDlg->GetFindString().GetBuffer(0);
CString str;
editInfo.GetWindowText(str);
editText = str;
int start, end;
editInfo.GetSel(start, end);
start = editText.Find(findStr, false, end);
if (start >= 0) {
editInfo.SetSel(start, start + findStr.Length());
editInfo.Invalidate();
editInfo.RedrawWindow();
}
}
return 0;
}

View File

@@ -0,0 +1,82 @@
/*
===========================================================================
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.
===========================================================================
*/
#pragma once
#include "mediapreviewdlg.h"
// CEditViewDlg dialog
class CEditViewDlg : public CDialog
{
DECLARE_DYNAMIC(CEditViewDlg)
public:
enum {MATERIALS, GUIS};
CEditViewDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CEditViewDlg();
void SetMode(int _mode) {
mode = _mode;
}
void SetMaterialInfo(const char *name, const char *file, int line);
void SetGuiInfo(const char *name);
void UpdateEditPreview();
void OpenMedia(const char *name);
// Dialog Data
enum { IDD = IDD_DIALOG_EDITVIEW };
protected:
CFindReplaceDialog *findDlg;
CMediaPreviewDlg mediaPreview;
int mode;
idStr fileName;
idStr matName;
idStr editText;
idStr findStr;
int line;
CEdit editInfo;
void ShowFindDlg();
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnBnClickedButtonOpen();
afx_msg void OnBnClickedButtonSave();
virtual BOOL OnInitDialog();
afx_msg void OnDestroy();
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnBnClickedButtonGoto();
virtual BOOL PreTranslateMessage(MSG* pMsg);
afx_msg LRESULT OnFindDialogMessage(WPARAM wParam, LPARAM lParam);
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,79 @@
/*
===========================================================================
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.
===========================================================================
*/
// brush.h
brush_t * Brush_Alloc();
void Brush_Free (brush_t *b, bool bRemoveNode = true);
int Brush_MemorySize(brush_t *b);
void Brush_MakeSided (int sides);
void Brush_MakeSidedCone (int sides);
void Brush_Move (brush_t *b, const idVec3 move, bool bSnap = true, bool updateOrigin = true);
int Brush_MoveVertex(brush_t *b, const idVec3 &vertex, const idVec3 &delta, idVec3 &end, bool bSnap);
void Brush_ResetFaceOriginals(brush_t *b);
brush_t * Brush_Parse (const idVec3 origin);
face_t * Brush_Ray (idVec3 origin, idVec3 dir, brush_t *b, float *dist, bool testPrimitive = false);
void Brush_RemoveFromList (brush_t *b);
void Brush_AddToList (brush_t *b, brush_t *list);
void Brush_Build(brush_t *b, bool bSnap = true, bool bMarkMap = true, bool bConvert = false, bool updateLights = true);
void Brush_BuildWindings( brush_t *b, bool bSnap = true, bool keepOnPlaneWinding = false, bool updateLights = true, bool makeFacePlanes = true );
brush_t * Brush_Clone (brush_t *b);
brush_t * Brush_FullClone(brush_t *b);
brush_t * Brush_Create (idVec3 mins, idVec3 maxs, texdef_t *texdef);
void Brush_Draw( brush_t *b, bool bSelected = false);
void Brush_DrawXY(brush_t *b, int nViewType, bool bSelected = false, bool ignoreViewType = false);
void Brush_SplitBrushByFace (brush_t *in, face_t *f, brush_t **front, brush_t **back);
void Brush_SelectFaceForDragging (brush_t *b, face_t *f, bool shear);
void Brush_SetTexture (brush_t *b, texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale = false);
void Brush_SideSelect (brush_t *b, idVec3 origin, idVec3 dir, bool shear);
void Brush_SnapToGrid(brush_t *pb);
void Brush_Rotate(brush_t *b, idVec3 vAngle, idVec3 vOrigin, bool bBuild = true);
void Brush_MakeSidedSphere(int sides);
void Brush_Write (brush_t *b, FILE *f, const idVec3 &origin, bool newFormat);
void Brush_Write (brush_t *b, CMemFile* pMemFile, const idVec3 &origin, bool NewFormat);
void Brush_RemoveEmptyFaces ( brush_t *b );
idWinding * Brush_MakeFaceWinding (brush_t *b, face_t *face, bool keepOnPlaneWinding = false);
void Brush_SetTextureName(brush_t *b, const char *name);
void Brush_Print(brush_t* b);
void Brush_FitTexture( brush_t *b, float height, float width );
void Brush_SetEpair(brush_t *b, const char *pKey, const char *pValue);
const char *Brush_GetKeyValue(brush_t *b, const char *pKey);
const char *Brush_Name(brush_t *b);
void Brush_RebuildBrush(brush_t *b, idVec3 vMins, idVec3 vMaxs, bool patch = true);
void Brush_GetBounds( brush_t *b, idBounds &bo );
face_t * Face_Alloc( void );
void Face_Free( face_t *f );
face_t * Face_Clone (face_t *f);
void Face_MakePlane (face_t *f);
void Face_Draw( face_t *face );
void Face_TextureVectors (face_t *f, float STfromXYZ[2][4]);
void Face_FitTexture( face_t * face, float height, float width );
void SetFaceTexdef (brush_t *b, face_t *f, texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale = false);
int AddPlanept (idVec3 *f);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,96 @@
/*
===========================================================================
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.
===========================================================================
*/
void Eclass_InitForSourceDirectory( const char *path );
eclass_t * Eclass_ForName( const char *name, bool has_brushes );
bool Eclass_hasModel(eclass_t *e, idVec3 &vMin, idVec3 &vMax);
typedef struct entity_s {
struct entity_s *prev, *next;
brush_t brushes; // head/tail of list
int undoId, redoId, entityId; // used for undo/redo
idVec3 origin;
qhandle_t lightDef;
qhandle_t modelDef;
idSoundEmitter *soundEmitter;
eclass_t * eclass;
idDict epairs;
eclass_t * md3Class;
idMat3 rotation;
idVec3 lightOrigin; // for lights that have been combined with models
idMat3 lightRotation; // ''
bool trackLightOrigin;
idCurve<idVec3> *curve;
} entity_t;
void ParseEpair(idDict *dict);
const char *ValueForKey(entity_t *ent, const char *key);
int GetNumKeys(entity_t *ent);
const char *GetKeyString(entity_t *ent, int iIndex);
void SetKeyValue (entity_t *ent, const char *key, const char *value, bool trackAngles = true);
void DeleteKey (entity_t *ent, const char *key);
float FloatForKey (entity_t *ent, const char *key);
int IntForKey (entity_t *ent, const char *key);
bool GetVectorForKey (entity_t *ent, const char *key, idVec3 &vec);
bool GetVector4ForKey (entity_t *ent, const char *key, idVec4 &vec);
bool GetFloatForKey(entity_t *end, const char *key, float *f);
void SetKeyVec3(entity_t *ent, const char *key, idVec3 v);
void SetKeyMat3(entity_t *ent, const char *key, idMat3 m);
bool GetMatrixForKey(entity_t *ent, const char *key, idMat3 &mat);
void Entity_UpdateSoundEmitter( entity_t *ent );
idCurve<idVec3> *Entity_MakeCurve( entity_t *e );
void Entity_UpdateCurveData( entity_t *e );
void Entity_SetCurveData( entity_t *e );
void Entity_Free (entity_t *e);
void Entity_FreeEpairs(entity_t *e);
int Entity_MemorySize(entity_t *e);
entity_t * Entity_Parse (bool onlypairs, brush_t* pList = NULL);
void Entity_Write (entity_t *e, FILE *f, bool use_region);
void Entity_WriteSelected(entity_t *e, FILE *f);
void Entity_WriteSelected(entity_t *e, CMemFile*);
entity_t * Entity_Create (eclass_t *c, bool forceFixed = false);
entity_t * Entity_Clone (entity_t *e);
void Entity_AddToList(entity_t *e, entity_t *list);
void Entity_RemoveFromList(entity_t *e);
bool EntityHasModel(entity_t *ent);
void Entity_LinkBrush (entity_t *e, brush_t *b);
void Entity_UnlinkBrush (brush_t *b);
entity_t * FindEntity(const char *pszKey, const char *pszValue);
entity_t * FindEntityInt(const char *pszKey, int iValue);
entity_t * Entity_New();
void Entity_SetName(entity_t *e, const char *name);
int GetUniqueTargetId(int iHint);
eclass_t * GetCachedModel(entity_t *pEntity, const char *pName, idVec3 &vMin, idVec3 &vMax);
//Timo : used for parsing epairs in brush primitive
void Entity_Name(entity_t *e, bool force);
bool IsBrushSelected(brush_t* bSel);

File diff suppressed because it is too large Load Diff

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.
===========================================================================
*/
extern char currentmap[1024];
// head/tail of doubly linked lists
extern brush_t active_brushes; // brushes currently being displayed
extern brush_t selected_brushes; // highlighted
extern CPtrArray& g_ptrSelectedFaces;
extern CPtrArray& g_ptrSelectedFaceBrushes;
//extern face_t *selected_face;
//extern brush_t *selected_face_brush;
extern brush_t filtered_brushes; // brushes that have been filtered or regioned
extern entity_t entities;
extern entity_t *world_entity; // the world entity is NOT included in
// the entities chain
extern int modified; // for quit confirmations
extern idVec3 region_mins, region_maxs;
extern bool region_active;
void Map_LoadFile (const char *filename);
bool Map_SaveFile (const char *filename, bool use_region, bool autosave = false);
void Map_New (void);
void Map_BuildBrushData(void);
void Map_RegionOff (void);
void Map_RegionXY (void);
void Map_RegionTallBrush (void);
void Map_RegionBrush (void);
void Map_RegionSelectedBrushes (void);
bool Map_IsBrushFiltered (brush_t *b);
void Map_SaveSelected(CMemFile* pMemFile, CMemFile* pPatchFile = NULL);
void Map_ImportBuffer (char* buf, bool renameEntities = true);
int Map_GetUniqueEntityID(const char *prefix, const char *eclass);
idMapPrimitive *BrushToMapPrimitive( const brush_t *b, const idVec3 &origin );

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 "stdafx.h"
#include "radiant.h"
#include "GetString.h" // for ErrorBox() etc
#include "qe3.h"
#include "EntKeyFindReplace.h"
//#include "oddbits.h"
/*
#include "stdafx.h"
#include "Radiant.h"
#include "ZWnd.h"
#include "qe3.h"
#include "zclip.h"
*/
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEntKeyFindReplace dialog
CEntKeyFindReplace::CEntKeyFindReplace( CString* p_strFindKey,
CString* p_strFindValue,
CString* p_strReplaceKey,
CString* p_strReplaceValue,
bool* p_bWholeStringMatchOnly,
bool* p_bSelectAllMatchingEnts,
CWnd* pParent /*=NULL*/)
: CDialog(CEntKeyFindReplace::IDD, pParent)
{
m_pStrFindKey = p_strFindKey;
m_pStrFindValue = p_strFindValue;
m_pStrReplaceKey = p_strReplaceKey;
m_pStrReplaceValue = p_strReplaceValue;
m_pbWholeStringMatchOnly = p_bWholeStringMatchOnly;
m_pbSelectAllMatchingEnts= p_bSelectAllMatchingEnts;
//{{AFX_DATA_INIT(CEntKeyFindReplace)
m_strFindKey = *m_pStrFindKey;
m_strFindValue = *m_pStrFindValue;
m_strReplaceKey = *m_pStrReplaceKey;
m_strReplaceValue = *m_pStrReplaceValue;
m_bWholeStringMatchOnly = *m_pbWholeStringMatchOnly;
m_bSelectAllMatchingEnts = *m_pbSelectAllMatchingEnts;
//}}AFX_DATA_INIT
}
void CEntKeyFindReplace::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEntKeyFindReplace)
DDX_Text(pDX, IDC_EDIT_FIND_KEY, m_strFindKey);
DDX_Text(pDX, IDC_EDIT_FIND_VALUE, m_strFindValue);
DDX_Text(pDX, IDC_EDIT_REPLACE_KEY, m_strReplaceKey);
DDX_Text(pDX, IDC_EDIT_REPLACE_VALUE, m_strReplaceValue);
DDX_Check(pDX, IDC_CHECK_FIND_WHOLESTRINGMATCHONLY, m_bWholeStringMatchOnly);
DDX_Check(pDX, IDC_CHECK_SELECTALLMATCHING, m_bSelectAllMatchingEnts);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CEntKeyFindReplace, CDialog)
//{{AFX_MSG_MAP(CEntKeyFindReplace)
ON_BN_CLICKED(IDC_REPLACE, OnReplace)
ON_BN_CLICKED(IDC_FIND, OnFind)
ON_BN_CLICKED(IDC_KEYCOPY, OnKeycopy)
ON_BN_CLICKED(IDC_VALUECOPY, OnValuecopy)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEntKeyFindReplace message handlers
void CEntKeyFindReplace::OnCancel()
{
CDialog::OnCancel();
}
void CEntKeyFindReplace::OnReplace()
{
// quick check, if no key value is specified then there's not much to do...
//
UpdateData(DIALOG_TO_DATA);
if (m_strFindKey.IsEmpty())
{
ErrorBox("Empty FIND <key>!\n\n(This is only permitted for FIND, not replace, for safety reasons)");
}
else
{
if (!m_strFindValue.IsEmpty() || GetYesNo(va("Empty FIND <value> means replace any existing ( & non-blank ) <value> for <key> \"%s\"\n\nProceed?",(LPCSTR)m_strFindKey)))
{
// another check, if they're trying to do a replace with a missing replace key, it'll just delete found keys...
//
if ((!m_strReplaceKey.IsEmpty() && !m_strReplaceValue.IsEmpty()) || GetYesNo(va("Empty REPLACE <key> or <value> fields will just delete all occurence of <key> \"%s\"\n\nProceed?",m_strFindKey)))
{
if (GetYesNo("Sure?"))
{
CopyFields();
EndDialog(ID_RET_REPLACE);
}
}
}
}
}
void CEntKeyFindReplace::OnFind()
{
// quick check, if no key value is specified then there's not much to do...
//
UpdateData(DIALOG_TO_DATA);
if (m_strFindKey.IsEmpty() && m_strFindValue.IsEmpty())
{
ErrorBox("Empty FIND fields!");
}
else
{
// if (m_strFindKey.IsEmpty() && m_bSelectAllMatchingEnts)
// {
// if (GetYesNo("Warning! Having a blank FIND <key> and ticking \"Select all matching ents\" can take a LONG time to do (and is probably a wrong choice anyway?)\n\nProceed?"))
// {
// CopyFields();
// EndDialog(ID_RET_FIND);
// }
// }
// else
{
CopyFields();
EndDialog(ID_RET_FIND);
}
}
}
void CEntKeyFindReplace::CopyFields()
{
UpdateData(DIALOG_TO_DATA);
*m_pStrFindKey = m_strFindKey;
*m_pStrFindValue = m_strFindValue;
*m_pStrReplaceKey = m_strReplaceKey;
*m_pStrReplaceValue = m_strReplaceValue;
*m_pbWholeStringMatchOnly = m_bWholeStringMatchOnly != 0;
*m_pbSelectAllMatchingEnts = m_bSelectAllMatchingEnts != 0;
}
void CEntKeyFindReplace::OnKeycopy()
{
UpdateData(DIALOG_TO_DATA);
m_strReplaceKey = m_strFindKey;
UpdateData(DATA_TO_DIALOG);
}
void CEntKeyFindReplace::OnValuecopy()
{
UpdateData(DIALOG_TO_DATA);
m_strReplaceValue = m_strFindValue;
UpdateData(DATA_TO_DIALOG);
}

View File

@@ -0,0 +1,104 @@
/*
===========================================================================
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.
===========================================================================
*/
#if !defined(AFX_ENTKEYFINDREPLACE_H__1AE54C31_FC22_11D3_8A60_00500424438B__INCLUDED_)
#define AFX_ENTKEYFINDREPLACE_H__1AE54C31_FC22_11D3_8A60_00500424438B__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// EntKeyFindReplace.h : header file
//
// return vals for modal dialogue, any values will do that don't clash with the first 9 or so defined by IDOK etc
//
#define ID_RET_REPLACE 100
#define ID_RET_FIND 101
/////////////////////////////////////////////////////////////////////////////
// CEntKeyFindReplace dialog
class CEntKeyFindReplace : public CDialog
{
// Construction
public:
CEntKeyFindReplace(CString* p_strFindKey,
CString* p_strFindValue,
CString* p_strReplaceKey,
CString* p_strReplaceValue,
bool* p_bWholeStringMatchOnly,
bool* p_bSelectAllMatchingEnts,
CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CEntKeyFindReplace)
enum { IDD = IDD_ENTFINDREPLACE };
CString m_strFindKey;
CString m_strFindValue;
CString m_strReplaceKey;
CString m_strReplaceValue;
BOOL m_bWholeStringMatchOnly;
BOOL m_bSelectAllMatchingEnts;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CEntKeyFindReplace)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CEntKeyFindReplace)
virtual void OnCancel();
afx_msg void OnReplace();
afx_msg void OnFind();
afx_msg void OnKeycopy();
afx_msg void OnValuecopy();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
CString* m_pStrFindKey;
CString* m_pStrFindValue;
CString* m_pStrReplaceKey;
CString* m_pStrReplaceValue;
bool* m_pbWholeStringMatchOnly;
bool* m_pbSelectAllMatchingEnts;
void CopyFields();
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_ENTKEYFINDREPLACE_H__1AE54C31_FC22_11D3_8A60_00500424438B__INCLUDED_)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,168 @@
/*
===========================================================================
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.
===========================================================================
*/
#pragma once
#include "afxcmn.h"
#include "afxwin.h"
#include "PropertyList.h"
#include "PreviewDlg.h"
// CEntityDlg dialog
class CEntityDlg : public CDialog
{
DECLARE_DYNAMIC(CEntityDlg)
public:
CEntityDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CEntityDlg();
void SetDict(idDict *_dict) {
dict = dict;
}
void SetEditEntity(entity_t *ent) {
editEntity = ent;
}
void CreateEntity();
void AssignModel ();
static CPreviewDlg *ShowModelChooser();
static CPreviewDlg *ShowGuiChooser();
static CPreviewDlg *ShowSoundChooser();
static CPreviewDlg *ShowMaterialChooser();
static CPreviewDlg *ShowParticleChooser();
static CPreviewDlg *ShowSkinChooser( entity_t *ent );
void SetKeyVal(const char *key, const char *val) {
editKey.SetWindowText(key);
editVal.SetWindowText(val);
}
void EditCurvePoints();
void AddCurvePoints();
void InsertCurvePoint();
void DeleteCurvePoint();
// Dialog Data
enum { IDD = IDD_DIALOG_ENTITY };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//DECLARE_MESSAGE_MAP()
public:
virtual BOOL OnInitDialog();
virtual int OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
void AddClassNames();
void UpdateEntitySel(eclass_t *ent);
void SetKeyValPairs( bool updateAnims = true );
static const char *TranslateString(const char *p);
void AddProp();
void DelProp();
void UpdateFromListBox();
CEdit editKey;
CEdit editVal;
void UpdateKeyVal(const char *key, const char *val);
void SelectCurvePointByRay(const idVec3 &org, const idVec3 &dir, int buttons);
void UpdateEntityCurve();
private:
entity_t *editEntity;
bool multipleEntities;
CPropertyList listKeyVal;
CPropertyList listVars;
CComboBox comboClass;
idDict *dict;
const idMD5Anim* currentAnimation;
int currentAnimationFrame;
const char *AngleKey();
idPointListInterface curvePoints;
public:
void UpdateFromAnimationFrame ( bool updateKeyValueDisplay = true);
DECLARE_MESSAGE_MAP()
afx_msg void OnSize(UINT nType, int cx, int cy);
CStatic staticTitle;
CStatic staticKey;
CStatic staticVal;
CStatic staticFrame;
CButton btnPlayAnim;
CButton btnStopAnim;
CButton btnBrowse;
CButton btn135;
CButton btn90;
CButton btn45;
CButton btn180;
CButton btn360;
CButton btn225;
CButton btn270;
CButton btn315;
CButton btnUp;
CButton btnDown;
CButton btnModel;
CButton btnSound;
CButton btnGui;
CButton btnParticle;
CButton btnSkin;
CButton btnCurve;
CComboBox cbAnimations;
CSliderCtrl slFrameSlider;
afx_msg void OnCbnSelchangeComboClass();
afx_msg void OnLbnSelchangeListkeyval();
virtual BOOL PreTranslateMessage(MSG* pMsg);
afx_msg void OnBnClickedE135();
afx_msg void OnBnClickedE90();
afx_msg void OnBnClickedE45();
afx_msg void OnBnClickedE180();
afx_msg void OnBnClickedE0();
afx_msg void OnBnClickedE225();
afx_msg void OnBnClickedE270();
afx_msg void OnBnClickedE315();
afx_msg void OnBnClickedEUp();
afx_msg void OnBnClickedEDown();
afx_msg void OnBnClickedButtonModel();
afx_msg void OnBnClickedButtonSound();
afx_msg void OnBnClickedButtonGui();
afx_msg void OnBnClickedButtonBrowse();
afx_msg void OnCbnDblclkComboClass();
afx_msg void OnBnClickedButtonCreate();
afx_msg void OnBnClickedStartAnimation();
afx_msg void OnBnClickedStopAnimation();
CButton btnCreate;
afx_msg void OnLbnDblclkListkeyval();
afx_msg void OnLbnSelchangeListVars();
afx_msg void OnLbnDblclkListVars();
void OnNMReleasedcaptureSlider1(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnCbnAnimationChange ();
void OnTimer(UINT nIDEvent);
afx_msg void OnBnClickedButtonParticle();
afx_msg void OnBnClickedButtonSkin();
afx_msg void OnBnClickedButtonCurve();
};

View File

@@ -0,0 +1,158 @@
/*
===========================================================================
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 "qe3.h"
#include "Radiant.h"
#include "EntityListDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CEntityListDlg g_EntityListDlg;
/////////////////////////////////////////////////////////////////////////////
// CEntityListDlg dialog
void CEntityListDlg::ShowDialog() {
if (g_EntityListDlg.GetSafeHwnd() == NULL) {
g_EntityListDlg.Create(IDD_DLG_ENTITYLIST);
}
g_EntityListDlg.UpdateList();
g_EntityListDlg.ShowWindow(SW_SHOW);
}
CEntityListDlg::CEntityListDlg(CWnd* pParent /*=NULL*/)
: CDialog(CEntityListDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CEntityListDlg)
//}}AFX_DATA_INIT
}
void CEntityListDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEntityListDlg)
DDX_Control(pDX, IDC_LIST_ENTITY, m_lstEntity);
//}}AFX_DATA_MAP
DDX_Control(pDX, IDC_LIST_ENTITIES, listEntities);
}
BEGIN_MESSAGE_MAP(CEntityListDlg, CDialog)
//{{AFX_MSG_MAP(CEntityListDlg)
ON_BN_CLICKED(IDC_SELECT, OnSelect)
ON_WM_CLOSE()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
ON_LBN_SELCHANGE(IDC_LIST_ENTITIES, OnLbnSelchangeListEntities)
ON_LBN_DBLCLK(IDC_LIST_ENTITIES, OnLbnDblclkListEntities)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEntityListDlg message handlers
void CEntityListDlg::OnSelect()
{
int index = listEntities.GetCurSel();
if (index != LB_ERR) {
entity_t *ent = reinterpret_cast<entity_t*>(listEntities.GetItemDataPtr(index));
if (ent) {
Select_Deselect();
Select_Brush (ent->brushes.onext);
}
}
Sys_UpdateWindows(W_ALL);
}
void CEntityListDlg::UpdateList() {
listEntities.ResetContent();
for (entity_t* pEntity=entities.next ; pEntity != &entities ; pEntity=pEntity->next) {
int index = listEntities.AddString(pEntity->epairs.GetString("name"));
if (index != LB_ERR) {
listEntities.SetItemDataPtr(index, (void*)pEntity);
}
}
}
void CEntityListDlg::OnSysCommand(UINT nID, LPARAM lParam) {
if (nID == SC_CLOSE) {
DestroyWindow();
}
}
void CEntityListDlg::OnCancel() {
DestroyWindow();
}
BOOL CEntityListDlg::OnInitDialog()
{
CDialog::OnInitDialog();
UpdateList();
CRect rct;
m_lstEntity.GetClientRect(rct);
m_lstEntity.InsertColumn(0, "Key", LVCFMT_LEFT, rct.Width() / 2);
m_lstEntity.InsertColumn(1, "Value", LVCFMT_LEFT, rct.Width() / 2);
m_lstEntity.DeleteColumn(2);
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CEntityListDlg::OnClose() {
DestroyWindow();
}
void CEntityListDlg::OnLbnSelchangeListEntities()
{
int index = listEntities.GetCurSel();
if (index != LB_ERR) {
m_lstEntity.DeleteAllItems();
entity_t* pEntity = reinterpret_cast<entity_t*>(listEntities.GetItemDataPtr(index));
if (pEntity) {
int count = pEntity->epairs.GetNumKeyVals();
for (int i = 0; i < count; i++) {
int nParent = m_lstEntity.InsertItem(0, pEntity->epairs.GetKeyVal(i)->GetKey());
m_lstEntity.SetItem(nParent, 1, LVIF_TEXT, pEntity->epairs.GetKeyVal(i)->GetValue(), 0, 0, 0, reinterpret_cast<DWORD>(pEntity));
}
}
}
}
void CEntityListDlg::OnLbnDblclkListEntities()
{
OnSelect();
}

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.
===========================================================================
*/
#include "afxwin.h"
#if !defined(AFX_ENTITYLISTDLG_H__C241B9A3_819F_11D1_B548_00AA00A410FC__INCLUDED_)
#define AFX_ENTITYLISTDLG_H__C241B9A3_819F_11D1_B548_00AA00A410FC__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// EntityListDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CEntityListDlg dialog
class CEntityListDlg : public CDialog
{
// Construction
public:
CEntityListDlg(CWnd* pParent = NULL); // standard constructor
void UpdateList();
static void ShowDialog();
// Dialog Data
//{{AFX_DATA(CEntityListDlg)
enum { IDD = IDD_DLG_ENTITYLIST };
CListCtrl m_lstEntity;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CEntityListDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CEntityListDlg)
afx_msg void OnSelect();
afx_msg void OnClose();
virtual void OnCancel();
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
public:
CListBox listEntities;
afx_msg void OnLbnSelchangeListEntities();
afx_msg void OnLbnDblclkListEntities();
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_ENTITYLISTDLG_H__C241B9A3_819F_11D1_B548_00AA00A410FC__INCLUDED_)

View File

@@ -0,0 +1,182 @@
/*
===========================================================================
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 "qe3.h"
#include "Radiant.h"
#include "FindTextureDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFindTextureDlg dialog
CFindTextureDlg g_TexFindDlg;
CFindTextureDlg& g_dlgFind = g_TexFindDlg;
static bool g_bFindActive = true;
void CFindTextureDlg::updateTextures(const char *p)
{
if (isOpen())
{
if (g_bFindActive)
{
setFindStr(p);
}
else
{
setReplaceStr(p);
}
}
}
CFindTextureDlg::CFindTextureDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFindTextureDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFindTextureDlg)
m_bSelectedOnly = FALSE;
m_strFind = _T("");
m_strReplace = _T("");
m_bForce = FALSE;
m_bLive = TRUE;
//}}AFX_DATA_INIT
}
void CFindTextureDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFindTextureDlg)
DDX_Check(pDX, IDC_CHECK_SELECTED, m_bSelectedOnly);
DDX_Text(pDX, IDC_EDIT_FIND, m_strFind);
DDX_Text(pDX, IDC_EDIT_REPLACE, m_strReplace);
DDX_Check(pDX, IDC_CHECK_FORCE, m_bForce);
DDX_Check(pDX, IDC_CHECK_LIVE, m_bLive);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFindTextureDlg, CDialog)
//{{AFX_MSG_MAP(CFindTextureDlg)
ON_BN_CLICKED(IDC_BTN_APPLY, OnBtnApply)
ON_EN_SETFOCUS(IDC_EDIT_FIND, OnSetfocusEditFind)
ON_EN_SETFOCUS(IDC_EDIT_REPLACE, OnSetfocusEditReplace)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CFindTextureDlg::OnBtnApply()
{
UpdateData(TRUE);
CRect rct;
GetWindowRect(rct);
SaveRegistryInfo("Radiant::TextureFindWindow", &rct, sizeof(rct));
FindReplaceTextures( m_strFind, m_strReplace, ( m_bSelectedOnly != FALSE ), ( m_bForce != FALSE ) );
}
void CFindTextureDlg::OnOK()
{
UpdateData(TRUE);
CRect rct;
GetWindowRect(rct);
SaveRegistryInfo("Radiant::TextureFindWindow", &rct, sizeof(rct));
FindReplaceTextures( m_strFind, m_strReplace, ( m_bSelectedOnly != FALSE ), ( m_bForce != FALSE ) );
CDialog::OnOK();
}
void CFindTextureDlg::show()
{
if (g_dlgFind.GetSafeHwnd() == NULL || IsWindow(g_dlgFind.GetSafeHwnd()) == FALSE)
{
g_dlgFind.Create(IDD_DIALOG_FINDREPLACE);
g_dlgFind.ShowWindow(SW_SHOW);
}
else
{
g_dlgFind.ShowWindow(SW_SHOW);
}
CRect rct;
LONG lSize = sizeof(rct);
if (LoadRegistryInfo("Radiant::TextureFindWindow", &rct, &lSize))
g_dlgFind.SetWindowPos(NULL, rct.left, rct.top, 0,0, SWP_NOSIZE | SWP_SHOWWINDOW);
}
bool CFindTextureDlg::isOpen()
{
return (g_dlgFind.GetSafeHwnd() == NULL || ::IsWindowVisible(g_dlgFind.GetSafeHwnd()) == FALSE) ? false : true;
}
void CFindTextureDlg::setFindStr(const char * p)
{
g_dlgFind.UpdateData(TRUE);
if (g_dlgFind.m_bLive)
{
g_dlgFind.m_strFind = p;
g_dlgFind.UpdateData(FALSE);
}
}
void CFindTextureDlg::setReplaceStr(const char * p)
{
g_dlgFind.UpdateData(TRUE);
if (g_dlgFind.m_bLive)
{
g_dlgFind.m_strReplace = p;
g_dlgFind.UpdateData(FALSE);
}
}
void CFindTextureDlg::OnCancel()
{
CRect rct;
GetWindowRect(rct);
SaveRegistryInfo("Radiant::TextureFindWindow", &rct, sizeof(rct));
CDialog::OnCancel();
}
BOOL CFindTextureDlg::DestroyWindow()
{
return CDialog::DestroyWindow();
}
void CFindTextureDlg::OnSetfocusEditFind()
{
g_bFindActive = true;
}
void CFindTextureDlg::OnSetfocusEditReplace()
{
g_bFindActive = false;
}

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.
===========================================================================
*/
#if !defined(AFX_FINDTEXTUREDLG_H__34B75D32_9F3A_11D1_B570_00AA00A410FC__INCLUDED_)
#define AFX_FINDTEXTUREDLG_H__34B75D32_9F3A_11D1_B570_00AA00A410FC__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// FindTextureDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CFindTextureDlg dialog
class CFindTextureDlg : public CDialog
{
// Construction
public:
static void setReplaceStr(const char* p);
static void setFindStr(const char* p);
static bool isOpen();
static void show();
static void updateTextures(const char* p);
CFindTextureDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CFindTextureDlg)
enum { IDD = IDD_DIALOG_FINDREPLACE };
BOOL m_bSelectedOnly;
CString m_strFind;
CString m_strReplace;
BOOL m_bForce;
BOOL m_bLive;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFindTextureDlg)
public:
virtual BOOL DestroyWindow();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CFindTextureDlg)
afx_msg void OnBtnApply();
virtual void OnOK();
virtual void OnCancel();
afx_msg void OnSetfocusEditFind();
afx_msg void OnSetfocusEditReplace();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_FINDTEXTUREDLG_H__34B75D32_9F3A_11D1_B570_00AA00A410FC__INCLUDED_)

View File

@@ -0,0 +1,937 @@
/*
===========================================================================
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 "qe3.h"
#include "Radiant.h"
#include "GLWidget.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// idGLWidget
class idMiniDrawVert {
public:
idVec3 xyz;
idVec2 st;
idMiniDrawVert(float x, float y, float z, float s, float t) : xyz(x,y,z), st(s, t) {
};
};
static idMiniDrawVert cubeData[] = {
idMiniDrawVert(-1.0, -1.0, +1.0, 0.0, 0.0),
idMiniDrawVert(+1.0, -1.0, +1.0, 1.0, 0.0),
idMiniDrawVert(+1.0, +1.0, +1.0, 1.0, 1.0),
idMiniDrawVert(-1.0, +1.0, +1.0, 0.0, 1.0),
idMiniDrawVert(-1.0, -1.0, -1.0, 1.0, 0.0),
idMiniDrawVert(-1.0, +1.0, +1.0, 1.0, 1.0),
idMiniDrawVert(+1.0, +1.0, -1.0, 0.0, 1.0),
idMiniDrawVert(+1.0, -1.0, -1.0, 0.0, 0.0),
idMiniDrawVert(-1.0, +1.0, -1.0, 0.0, 1.0),
idMiniDrawVert(-1.0, +1.0, +1.0, 0.0, 0.0),
idMiniDrawVert(+1.0, +1.0, +1.0, 1.0, 0.0),
idMiniDrawVert(+1.0, +1.0, -1.0, 1.0, 1.0),
idMiniDrawVert(-1.0, -1.0, -1.0, 1.0, 1.0),
idMiniDrawVert(+1.0, -1.0, -1.0, 0.0, 1.0),
idMiniDrawVert(+1.0, -1.0, +1.0, 0.0, 0.0),
idMiniDrawVert(-1.0, -1.0, +1.0, 1.0, 0.0),
idMiniDrawVert(+1.0, -1.0, -1.0, 1.0, 0.0),
idMiniDrawVert(+1.0, +1.0, -1.0, 1.0, 1.0),
idMiniDrawVert(+1.0, +1.0, +1.0, 0.0, 1.0),
idMiniDrawVert(+1.0, -1.0, +1.0, 0.0, 0.0),
idMiniDrawVert(-1.0, -1.0, -1.0, 0.0, 0.0),
idMiniDrawVert(-1.0, -1.0, +1.0, 1.0, 0.0),
idMiniDrawVert(-1.0, +1.0, +1.0, 1.0, 1.0),
idMiniDrawVert(-1.0, +1.0, -1.0, 0.0, 1.0)
};
static int cubeSides = sizeof(cubeData) / sizeof(idMiniDrawVert);
static int numQuads = cubeSides / 4;
void glTexturedBox(idVec3 &point, float size, const idMaterial *mat) {
qglTranslatef(point.x, point.y, point.z);
for (int i = 0; i < numQuads; i++) {
qglBegin(GL_QUADS);
for (int j = 0; j < 4; j++) {
idVec3 v = cubeData[i * 4 + j].xyz;
v *= size;
qglTexCoord2fv(cubeData[i * 4 + j].st.ToFloatPtr());
qglVertex3fv(v.ToFloatPtr());
}
qglEnd();
}
}
idGLWidget::idGLWidget()
{
initialized = false;
drawable = NULL;
}
idGLWidget::~idGLWidget()
{
}
BEGIN_MESSAGE_MAP(idGLWidget, CWnd)
//{{AFX_MSG_MAP(idGLWidget)
ON_WM_PAINT()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MBUTTONDOWN()
ON_WM_MBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_MOUSEWHEEL()
ON_WM_RBUTTONDOWN()
ON_WM_RBUTTONUP()
ON_WM_TIMER()
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// idGLWidget message handlers
BOOL idGLWidget::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Add your specialized code here and/or call the base class
return CWnd::PreCreateWindow(cs);
}
BOOL idGLWidget::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
if (CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext) == -1) {
return FALSE;
}
CDC *dc = GetDC();
QEW_SetupPixelFormat(dc->m_hDC, false);
ReleaseDC(dc);
return TRUE;
}
void idGLWidget::OnPaint()
{
if (!initialized) {
CDC *dc = GetDC();
QEW_SetupPixelFormat(dc->m_hDC, false);
ReleaseDC(dc);
initialized = true;
}
CPaintDC dc(this); // device context for painting
CRect rect;
GetClientRect(rect);
if (!qwglMakeCurrent(dc.m_hDC, win32.hGLRC)) {
}
qglViewport(0, 0, rect.Width(), rect.Height());
qglScissor(0, 0, rect.Width(), rect.Height());
qglMatrixMode(GL_PROJECTION);
qglLoadIdentity();
qglClearColor (0.4f, 0.4f, 0.4f, 0.7f);
qglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
qglDisable(GL_DEPTH_TEST);
qglDisable(GL_BLEND);
qglOrtho(0, rect.Width(), 0, rect.Height(), -256, 256);
if (drawable) {
drawable->draw(1, 1, rect.Width()-1, rect.Height()-1);
} else {
qglViewport(0, 0, rect.Width(), rect.Height());
qglScissor(0, 0, rect.Width(), rect.Height());
qglMatrixMode(GL_PROJECTION);
qglLoadIdentity();
qglClearColor (0.4f, 0.4f, 0.4f, 0.7f);
qglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
qwglSwapBuffers(dc);
qglFlush();
qwglMakeCurrent(win32.hDC, win32.hGLRC);
}
extern bool Sys_KeyDown(int key);
void idGLDrawable::buttonDown(int _button, float x, float y) {
pressX = x;
pressY = y;
button = _button;
if (button == MK_RBUTTON) {
handleMove = true;
}
}
void idGLDrawable::buttonUp(int button, float x, float y) {
handleMove = false;
}
extern float fDiff(float f1, float f2);
void idGLDrawable::mouseMove(float x, float y) {
if (handleMove) {
Update();
if (Sys_KeyDown(VK_MENU)) {
// scale
float *px = &x;
float *px2 = &pressX;
if (fDiff(y, pressY) > fDiff(x, pressX)) {
px = &y;
px2 = &pressY;
}
if (*px > *px2) {
// zoom in
scale += 0.1f;
if ( scale > 10.0f ) {
scale = 10.0f;
}
} else if (*px < *px2) {
// zoom out
scale -= 0.1f;
if ( scale <= 0.001f ) {
scale = 0.001f;
}
}
*px2 = *px;
::SetCursorPos(pressX, pressY);
} else if (Sys_KeyDown(VK_SHIFT)) {
// rotate
} else {
// origin
if (x != pressX) {
xOffset += (x - pressX);
pressX = x;
}
if (y != pressY) {
yOffset -= (y - pressY);
pressY = y;
}
//::SetCursorPos(pressX, pressY);
}
}
}
void idGLDrawable::draw(int x, int y, int w, int h) {
GL_State( GLS_DEFAULT );
qglViewport(x, y, w, h);
qglScissor(x, y, w, h);
qglMatrixMode(GL_PROJECTION);
qglClearColor( 0.1f, 0.1f, 0.1f, 0.0f );
qglClear(GL_COLOR_BUFFER_BIT);
qglPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
qglLineWidth(0.5);
qglColor3f(1, 1, 1);
globalImages->BindNull();
qglBegin(GL_LINE_LOOP);
qglColor3f(1, 0, 0);
qglVertex2f(x + 3, y + 3);
qglColor3f(0, 1, 0);
qglVertex2f(x + 3, h - 3);
qglColor3f(0, 0, 1);
qglVertex2f(w - 3, h - 3);
qglColor3f(1, 1, 1);
qglVertex2f(w - 3, y + 3);
qglEnd();
}
static int viewAngle = -98;
void idGLDrawableMaterial::buttonDown(int button, float x, float y) {
idGLDrawable::buttonDown(button, x, y);
//viewAngle += (button == MK_LBUTTON) ? 15 : -15;
}
void idGLDrawableMaterial::mouseMove(float x, float y) {
if (handleMove) {
Update();
bool doScale = Sys_KeyDown(VK_MENU);
bool doLight = Sys_KeyDown(VK_SHIFT);
if (doScale || doLight) {
// scale
float *px = &x;
float *px2 = &pressX;
if (fDiff(y, pressY) > fDiff(x, pressX)) {
px = &y;
px2 = &pressY;
}
if (*px > *px2) {
// zoom in
if (doScale) {
scale += 0.1f;
if ( scale > 10.0f ) {
scale = 10.0f;
}
} else {
light += 0.05f;
if ( light > 2.0f ) {
light = 2.0f;
}
}
} else if (*px < *px2) {
// zoom out
if (doScale) {
scale -= 0.1f;
if ( scale <= 0.001f ) {
scale = 0.001f;
}
} else {
light -= 0.05f;
if ( light < 0.0f ) {
light = 0.0f;
}
}
}
*px2 = *px;
::SetCursorPos(pressX, pressY);
} else {
// origin
if (x != pressX) {
xOffset += (x - pressX);
pressX = x;
}
if (y != pressY) {
yOffset -= (y - pressY);
pressY = y;
}
//::SetCursorPos(pressX, pressY);
}
}
}
void idGLDrawableMaterial::draw(int x, int y, int w, int h) {
const idMaterial *mat = material;
if (mat) {
qglViewport(x, y, w, h);
qglScissor(x, y, w, h);
qglMatrixMode(GL_PROJECTION);
qglClearColor( 0.1f, 0.1f, 0.1f, 0.0f );
qglClear(GL_COLOR_BUFFER_BIT);
if (worldDirty) {
InitWorld();
renderLight_t parms;
idDict spawnArgs;
spawnArgs.Set("classname", "light");
spawnArgs.Set("name", "light_1");
spawnArgs.Set("origin", "0 0 0");
idStr str;
sprintf(str, "%f %f %f", light, light, light);
spawnArgs.Set("_color", str);
gameEdit->ParseSpawnArgsToRenderLight( &spawnArgs, &parms );
lightDef = world->AddLightDef( &parms );
idImage *img = (mat->GetNumStages() > 0) ? mat->GetStage(0)->texture.image : mat->GetEditorImage();
if (img == NULL) {
common->Warning("Unable to load image for preview for %s", mat->GetName());
return;
}
int width = img->uploadWidth;
int height = img->uploadHeight;
width *= scale;
height *= scale;
srfTriangles_t *tris = worldModel->AllocSurfaceTriangles( 4, 6 );
tris->numVerts = 4;
tris->numIndexes = 6;
tris->indexes[0] = 0;
tris->indexes[1] = 1;
tris->indexes[2] = 2;
tris->indexes[3] = 3;
tris->indexes[4] = 1;
tris->indexes[5] = 0;
tris->verts[0].xyz.x = 64;
tris->verts[0].xyz.y = -xOffset + 0 - width / 2;
tris->verts[0].xyz.z = yOffset + 0 - height / 2;
tris->verts[0].st.x = 1;
tris->verts[0].st.y = 1;
tris->verts[1].xyz.x = 64;
tris->verts[1].xyz.y = -xOffset + width / 2;
tris->verts[1].xyz.z = yOffset + height / 2;
tris->verts[1].st.x = 0;
tris->verts[1].st.y = 0;
tris->verts[2].xyz.x = 64;
tris->verts[2].xyz.y = -xOffset + 0 - width / 2;
tris->verts[2].xyz.z = yOffset + height / 2;
tris->verts[2].st.x = 1;
tris->verts[2].st.y = 0;
tris->verts[3].xyz.x = 64;
tris->verts[3].xyz.y = -xOffset + width / 2;
tris->verts[3].xyz.z = yOffset + 0 - height / 2;
tris->verts[3].st.x = 0;
tris->verts[3].st.y = 1;
tris->verts[0].normal = tris->verts[1].xyz.Cross(tris->verts[3].xyz);
tris->verts[1].normal = tris->verts[2].normal = tris->verts[3].normal = tris->verts[0].normal;
AddTris(tris, mat);
worldModel->FinishSurfaces();
renderEntity_t worldEntity;
memset( &worldEntity, 0, sizeof( worldEntity ) );
if ( mat->HasGui() ) {
worldEntity.gui[ 0 ] = mat->GlobalGui();
}
worldEntity.hModel = worldModel;
worldEntity.axis = mat3_default;
worldEntity.shaderParms[0] = 1;
worldEntity.shaderParms[1] = 1;
worldEntity.shaderParms[2] = 1;
worldEntity.shaderParms[3] = 1;
modelDef = world->AddEntityDef( &worldEntity );
worldDirty = false;
}
renderView_t refdef;
// render it
renderSystem->BeginFrame(w, h);
memset( &refdef, 0, sizeof( refdef ) );
refdef.vieworg.Set(viewAngle, 0, 0);
refdef.viewaxis = idAngles(0,0,0).ToMat3();
refdef.shaderParms[0] = 1;
refdef.shaderParms[1] = 1;
refdef.shaderParms[2] = 1;
refdef.shaderParms[3] = 1;
refdef.width = SCREEN_WIDTH;
refdef.height = SCREEN_HEIGHT;
refdef.fov_x = 90;
refdef.fov_y = 2 * atan((float)h / w) * idMath::M_RAD2DEG;
refdef.time = eventLoop->Milliseconds();
world->RenderScene( &refdef );
int frontEnd, backEnd;
renderSystem->EndFrame( &frontEnd, &backEnd );
qglMatrixMode( GL_MODELVIEW );
qglLoadIdentity();
}
}
void idGLDrawableMaterial::setMedia(const char *name) {
idImage *img = NULL;
if (name && *name) {
material = declManager->FindMaterial(name);
if (material) {
const shaderStage_t *stage = (material->GetNumStages() > 0) ? material->GetStage(0) : NULL;
if (stage) {
img = stage->texture.image;
} else {
img = material->GetEditorImage();
}
}
} else {
material = NULL;
}
// set scale to get a good fit
if (material && img) {
float size = (img->uploadWidth > img->uploadHeight) ? img->uploadWidth : img->uploadHeight;
// use 128 as base scale of 1.0
scale = 128.0 / size;
} else {
scale = 1.0;
}
xOffset = 0.0;
yOffset = 0.0;
worldDirty = true;
}
idGLDrawableModel::idGLDrawableModel(const char *name) {
worldModel = renderModelManager->FindModel( name );
light = 1.0;
worldDirty = true;
}
idGLDrawableModel::idGLDrawableModel() {
worldModel = renderModelManager->DefaultModel();
light = 1.0;
}
void idGLDrawableModel::setMedia(const char *name) {
worldModel = renderModelManager->FindModel(name);
worldDirty = true;
xOffset = 0.0;
yOffset = 0.0;
zOffset = -128;
rotation.Set( 0.0f, 0.0f, 0.0f, 1.0f );
radius = 2.6f;
lastPress.Zero();
}
void idGLDrawableModel::SetSkin( const char *skin ) {
skinStr = skin;
}
void idGLDrawableModel::buttonDown(int _button, float x, float y) {
pressX = x;
pressY = y;
lastPress.y = -( float )( 2 * x - rect.z ) / rect.z;
lastPress.x = -( float )( 2 * y - rect.w ) / rect.w;
lastPress.z = 0.0f;
button = _button;
if (button == MK_RBUTTON || button == MK_LBUTTON) {
handleMove = true;
}
}
void idGLDrawableModel::mouseMove(float x, float y) {
if (handleMove) {
Update();
if (button == MK_LBUTTON) {
float cury = ( float )( 2 * x - rect.z ) / rect.z;
float curx = ( float )( 2 * y - rect.w ) / rect.w;
idVec3 to( -curx, -cury, 0.0f );
to.ProjectSelfOntoSphere( radius );
lastPress.ProjectSelfOntoSphere( radius );
idVec3 axis;
axis.Cross( to, lastPress );
float len = ( lastPress - to ).Length() / ( 2.0f * radius );
len = idMath::ClampFloat( -1.0f, 1.0f, len );
float phi = 2.0f * asin ( len ) ;
axis.Normalize();
axis *= sin( phi / 2.0f );
idQuat rot( axis.z, axis.y, axis.x, cos( phi / 2.0f ) );
rot.Normalize();
rotation *= rot;
rotation.Normalize();
lastPress = to;
lastPress.z = 0.0f;
} else {
bool doScale = Sys_KeyDown(VK_MENU);
bool doLight = Sys_KeyDown(VK_SHIFT);
if (doLight) {
// scale
float *px = &x;
float *px2 = &pressX;
if (fDiff(y, pressY) > fDiff(x, pressX)) {
px = &y;
px2 = &pressY;
}
if (*px > *px2) {
light += 0.05f;
if ( light > 2.0f ) {
light = 2.0f;
}
} else if (*px < *px2) {
light -= 0.05f;
if ( light < 0.0f ) {
light = 0.0f;
}
}
*px2 = *px;
::SetCursorPos(pressX, pressY);
} else {
// origin
if (x != pressX) {
if (doScale) {
zOffset += (x - pressX);
} else {
xOffset += (x - pressX);
}
pressX = x;
}
if (y != pressY) {
if (doScale) {
zOffset -= (y - pressY);
} else {
yOffset -= (y - pressY);
}
pressY = y;
}
//::SetCursorPos(pressX, pressY);
}
}
}
}
void idGLDrawableModel::draw(int x, int y, int w, int h) {
if ( !worldModel ) {
return;
}
if ( worldModel->IsDynamicModel() != DM_STATIC ) {
//return;
}
rect.Set( x, y, w, h );
qglViewport(x, y, w, h);
qglScissor(x, y, w, h);
qglMatrixMode(GL_PROJECTION);
qglClearColor( 0.1f, 0.1f, 0.1f, 0.0f );
qglClear(GL_COLOR_BUFFER_BIT);
if (worldDirty) {
//InitWorld();
world->InitFromMap( NULL );
renderLight_t parms;
idDict spawnArgs;
spawnArgs.Set("classname", "light");
spawnArgs.Set("name", "light_1");
spawnArgs.Set("origin", "-128 0 0");
idStr str;
sprintf(str, "%f %f %f", light, light, light);
spawnArgs.Set("_color", str);
gameEdit->ParseSpawnArgsToRenderLight( &spawnArgs, &parms );
lightDef = world->AddLightDef( &parms );
renderEntity_t worldEntity;
memset( &worldEntity, 0, sizeof( worldEntity ) );
spawnArgs.Clear();
spawnArgs.Set("classname", "func_static");
spawnArgs.Set("name", spawnArgs.GetString("model"));
spawnArgs.Set("origin", "0 0 0");
if ( skinStr.Length() ) {
spawnArgs.Set( "skin", skinStr );
}
gameEdit->ParseSpawnArgsToRenderEntity(&spawnArgs, &worldEntity);
worldEntity.hModel = worldModel;
worldEntity.axis = rotation.ToMat3();
worldEntity.shaderParms[0] = 1;
worldEntity.shaderParms[1] = 1;
worldEntity.shaderParms[2] = 1;
worldEntity.shaderParms[3] = 1;
modelDef = world->AddEntityDef( &worldEntity );
worldDirty = false;
}
renderView_t refdef;
// render it
renderSystem->BeginFrame(w, h);
memset( &refdef, 0, sizeof( refdef ) );
refdef.vieworg.Set(zOffset, xOffset, -yOffset);
refdef.viewaxis = idAngles(0,0,0).ToMat3();
refdef.shaderParms[0] = 1;
refdef.shaderParms[1] = 1;
refdef.shaderParms[2] = 1;
refdef.shaderParms[3] = 1;
refdef.width = SCREEN_WIDTH;
refdef.height = SCREEN_HEIGHT;
refdef.fov_x = 90;
refdef.fov_y = 2 * atan((float)h / w) * idMath::M_RAD2DEG;
refdef.time = eventLoop->Milliseconds();
world->RenderScene( &refdef );
int frontEnd, backEnd;
renderSystem->EndFrame( &frontEnd, &backEnd );
qglMatrixMode( GL_MODELVIEW );
qglLoadIdentity();
}
void idGLWidget::OnLButtonDown(UINT nFlags, CPoint point)
{
SetCapture();
if (drawable) {
if ( drawable->ScreenCoords() ) {
ClientToScreen(&point);
}
drawable->buttonDown(MK_LBUTTON, point.x, point.y);
}
}
void idGLWidget::OnLButtonUp(UINT nFlags, CPoint point)
{
if (drawable) {
if ( drawable->ScreenCoords() ) {
ClientToScreen(&point);
}
drawable->buttonUp(MK_LBUTTON, point.x, point.y);
}
ReleaseCapture();
}
void idGLWidget::OnMButtonDown(UINT nFlags, CPoint point)
{
SetCapture();
if (drawable) {
if ( drawable->ScreenCoords() ) {
ClientToScreen(&point);
}
drawable->buttonDown(MK_MBUTTON, point.x, point.y);
}
}
void idGLWidget::OnMButtonUp(UINT nFlags, CPoint point)
{
if (drawable) {
if ( drawable->ScreenCoords() ) {
ClientToScreen(&point);
}
drawable->buttonUp(MK_MBUTTON, point.x, point.y);
}
ReleaseCapture();
}
void idGLWidget::OnMouseMove(UINT nFlags, CPoint point)
{
if (drawable) {
if ( drawable->ScreenCoords() ) {
ClientToScreen(&point);
}
drawable->mouseMove(point.x, point.y);
RedrawWindow();
}
}
BOOL idGLWidget::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
if (drawable) {
float f = drawable->getScale();
if ( zDelta > 0.0f ) {
f += 0.1f;
} else {
f -= 0.1f;
}
if ( f <= 0.0f ) {
f = 0.1f;
}
if ( f > 5.0f ) {
f = 5.0f;
}
drawable->setScale(f);
}
return TRUE;
}
void idGLWidget::OnRButtonDown(UINT nFlags, CPoint point)
{
SetCapture();
if (drawable) {
if ( drawable->ScreenCoords() ) {
ClientToScreen(&point);
}
drawable->buttonDown(MK_RBUTTON, point.x, point.y);
}
}
void idGLWidget::OnRButtonUp(UINT nFlags, CPoint point)
{
if (drawable) {
if ( drawable->ScreenCoords() ) {
ClientToScreen(&point);
}
drawable->buttonUp(MK_RBUTTON, point.x, point.y);
}
ReleaseCapture();
}
void idGLWidget::setDrawable(idGLDrawable *d) {
drawable = d;
if (d->getRealTime()) {
SetTimer(1, d->getRealTime(), NULL);
}
}
void idGLWidget::OnTimer(UINT nIDEvent) {
if (drawable && drawable->getRealTime()) {
Invalidate(FALSE);
} else {
KillTimer(1);
}
}
idGLDrawable::idGLDrawable() {
scale = 1.0;
xOffset = 0.0;
yOffset = 0.0;
handleMove = false;
realTime = 0;
}
void idGLDrawableConsole::draw(int x, int y, int w, int h) {
qglPushAttrib( GL_ALL_ATTRIB_BITS );
qglClearColor( 0.1f, 0.1f, 0.1f, 0.0f );
qglScissor( 0, 0, w, h );
qglClear( GL_COLOR_BUFFER_BIT );
renderSystem->BeginFrame( w, h );
console->Draw( true );
renderSystem->EndFrame( NULL, NULL );
qglPopAttrib();
}
void idGLConsoleWidget::init() {
setDrawable(&console);
}
void idGLConsoleWidget::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
sysEvent_t ev;
memset( &ev, 0, sizeof( ev ) );
ev.evType = SE_KEY;
ev.evValue2 = 1;
ev.evValue = nChar;
::console->ProcessEvent( &ev, true );
}
BEGIN_MESSAGE_MAP(idGLConsoleWidget, idGLWidget)
//{{AFX_MSG_MAP(idGLConsoleWidget)
ON_WM_PAINT()
ON_WM_KEYDOWN()
ON_WM_KEYUP()
ON_WM_CHAR()
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void idGLConsoleWidget::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
{
sysEvent_t ev;
memset( &ev, 0, sizeof( ev ) );
ev.evType = SE_KEY;
ev.evValue2 = 0;
ev.evValue = nChar;
::console->ProcessEvent( &ev, true );
}
void idGLConsoleWidget::OnPaint() {
idGLWidget::OnPaint();
}
void idGLConsoleWidget::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
sysEvent_t ev;
memset( &ev, 0, sizeof( ev ) );
ev.evType = SE_CHAR;
ev.evValue = nChar;
::console->ProcessEvent( &ev, true );
}
void idGLConsoleWidget::OnLButtonDown(UINT nFlags, CPoint point) {
SetFocus();
}
BOOL idGLWidget::OnEraseBkgnd(CDC* pDC)
{
return FALSE;
//return CWnd::OnEraseBkgnd(pDC);
}
idGLDrawableWorld::idGLDrawableWorld() {
world = NULL;
worldModel = NULL;
InitWorld();
}
idGLDrawableWorld::~idGLDrawableWorld() {
delete world;
}
void idGLDrawableWorld::AddTris(srfTriangles_t *tris, const idMaterial *mat) {
modelSurface_t surf;
surf.geometry = tris;
surf.shader = mat;
worldModel->AddSurface( surf );
}
void idGLDrawableWorld::draw(int x, int y, int w, int h) {
}
void idGLDrawableWorld::InitWorld() {
if ( world == NULL ) {
world = renderSystem->AllocRenderWorld();
}
if ( worldModel == NULL ) {
worldModel = renderModelManager->AllocModel();
}
world->InitFromMap( NULL );
worldModel->InitEmpty( va( "GLWorldModel_%i", Sys_Milliseconds() ) );
}

View File

@@ -0,0 +1,247 @@
/*
===========================================================================
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.
===========================================================================
*/
#if !defined(AFX_IDGLWIDGET_H__6399A341_2976_4A6E_87DD_9AF4DBD4C5DB__INCLUDED_)
#define AFX_IDGLWIDGET_H__6399A341_2976_4A6E_87DD_9AF4DBD4C5DB__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/////////////////////////////////////////////////////////////////////////////
// idGLWidget window
class idGLDrawable {
public:
idGLDrawable();
~idGLDrawable() {};
virtual void draw(int x, int y, int w, int h);
virtual void setMedia(const char *name){}
virtual void buttonDown(int button, float x, float y);
virtual void buttonUp(int button, float x, float y);
virtual void mouseMove(float x, float y);
virtual int getRealTime() {return realTime;};
virtual bool ScreenCoords() {
return true;
}
void SetRealTime(int i) {
realTime = i;
}
virtual void Update() {};
float getScale() {
return scale;
}
void setScale(float f) {
scale = f;
}
protected:
float scale;
float xOffset;
float yOffset;
float zOffset;
float pressX;
float pressY;
bool handleMove;
int button;
int realTime;
};
class idGLDrawableWorld : public idGLDrawable {
public:
idGLDrawableWorld();
~idGLDrawableWorld();
void AddTris(srfTriangles_t *tris, const idMaterial *mat);
virtual void draw(int x, int y, int w, int h);
void InitWorld();
protected:
idRenderWorld *world;
idRenderModel *worldModel;
qhandle_t worldModelDef;
qhandle_t lightDef;
qhandle_t modelDef;
};
class idGLDrawableMaterial : public idGLDrawableWorld {
public:
idGLDrawableMaterial(const idMaterial *mat) {
material = mat;
scale = 1.0;
light = 1.0;
worldDirty = true;
}
idGLDrawableMaterial() {
material = NULL;
light = 1.0;
worldDirty = true;
realTime = 50;
}
~idGLDrawableMaterial() {
}
virtual void setMedia(const char *name);
virtual void draw(int x, int y, int w, int h);
virtual void buttonUp(int button){}
virtual void buttonDown(int button, float x, float y);
virtual void mouseMove(float x, float y);
virtual void Update() { worldDirty = true ;};
protected:
const idMaterial *material;
bool worldDirty;
float light;
};
class idGLDrawableModel : public idGLDrawableWorld {
public:
idGLDrawableModel(const char *name);
idGLDrawableModel();
~idGLDrawableModel() {}
virtual void setMedia(const char *name);
virtual void buttonDown(int button, float x, float y);
virtual void mouseMove(float x, float y);
virtual void draw(int x, int y, int w, int h);
virtual void Update() { worldDirty = true ;};
virtual bool ScreenCoords() {
return false;
}
void SetSkin( const char *skin );
protected:
bool worldDirty;
float light;
idStr skinStr;
idQuat rotation;
idVec3 lastPress;
float radius;
idVec4 rect;
};
class idGLDrawableConsole : public idGLDrawable {
public:
idGLDrawableConsole () {
}
~idGLDrawableConsole() {
}
virtual void setMedia(const char *name) {
}
virtual void draw(int x, int y, int w, int h);
virtual int getRealTime() {return 0;};
protected:
};
class idGLWidget : public CWnd
{
// Construction
public:
idGLWidget();
void setDrawable(idGLDrawable *d);
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(idGLWidget)
public:
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
protected:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~idGLWidget();
// Generated message map functions
protected:
idGLDrawable *drawable;
bool initialized;
//{{AFX_MSG(idGLWidget)
afx_msg void OnPaint();
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
afx_msg void OnTimer(UINT nIDEvent);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
class idGLConsoleWidget : public idGLWidget {
idGLDrawableConsole console;
public:
idGLConsoleWidget() {
};
~idGLConsoleWidget() {
}
void init();
protected:
//{{AFX_MSG(idGLConsoleWidget)
afx_msg void OnPaint();
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_IDGLWIDGET_H__6399A341_2976_4A6E_87DD_9AF4DBD4C5DB__INCLUDED_)

View File

@@ -0,0 +1,126 @@
/*
===========================================================================
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 "qe3.h"
#include "Radiant.h"
#include "GetString.h"
// CGetString dialog
CGetString::CGetString(LPCSTR pPrompt, CString *pFeedback, CWnd* pParent /*=NULL*/)
: CDialog(CGetString::IDD, pParent)
{
m_strEditBox = _T("");
m_pFeedback = pFeedback;
m_pPrompt = pPrompt;
}
CGetString::~CGetString()
{
}
void CGetString::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_strEditBox);
}
BOOL CGetString::OnInitDialog()
{
CDialog::OnInitDialog();
GetDlgItem(IDC_PROMPT)->SetWindowText(m_pPrompt);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BEGIN_MESSAGE_MAP(CGetString, CDialog)
//{{AFX_MSG_MAP(CGetString)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CGetString::OnOK()
{
UpdateData(DIALOG_TO_DATA);
*m_pFeedback = m_strEditBox;
CDialog::OnOK();
}
// returns NULL if CANCEL, else input string
//
LPCSTR GetString(LPCSTR psPrompt)
{
static CString strReturn;
CGetString Input(psPrompt,&strReturn);
if (Input.DoModal() == IDOK)
{
strReturn.TrimLeft();
strReturn.TrimRight();
return (LPCSTR)strReturn;
}
return NULL;
}
bool GetYesNo(const char *psQuery)
{
if (MessageBox(g_pParentWnd->GetSafeHwnd(), psQuery, "Query", MB_YESNO|MB_ICONWARNING)==IDYES)
return true;
return false;
}
void ErrorBox(const char *sString)
{ if ((rand()&31)==30){static bool bPlayed=false;if(!bPlayed){bPlayed=true;PlaySound("k:\\util\\overlay.bin",NULL,SND_FILENAME|SND_ASYNC);}}
MessageBox( g_pParentWnd->GetSafeHwnd(), sString, "Error", MB_OK|MB_ICONERROR|MB_TASKMODAL );
}
void InfoBox(const char *sString)
{
MessageBox( g_pParentWnd->GetSafeHwnd(), sString, "Info", MB_OK|MB_ICONINFORMATION|MB_TASKMODAL );
}
void WarningBox(const char *sString)
{
MessageBox( g_pParentWnd->GetSafeHwnd(), sString, "Warning", MB_OK|MB_ICONWARNING|MB_TASKMODAL );
}

View File

@@ -0,0 +1,70 @@
/*
===========================================================================
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.
===========================================================================
*/
#if !defined(__GETSTRING_H__)
#define __GETSTRING_H__
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// CGetString dialog
// NOTE: already included in qe3.h but won't compile without including it again !?
#include "../../sys/win32/rc/Radiant_resource.h"
class CGetString : public CDialog
{
public:
CGetString(LPCSTR pPrompt, CString *pFeedback, CWnd* pParent = NULL); // standard constructor
virtual ~CGetString();
// Overrides
// Dialog Data
enum { IDD = IDD_DIALOG_GETSTRING };
CString m_strEditBox;
CString *m_pFeedback;
LPCSTR m_pPrompt;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnInitDialog();
virtual void OnOK();
DECLARE_MESSAGE_MAP()
};
LPCSTR GetString(LPCSTR psPrompt);
bool GetYesNo(const char *psQuery);
void ErrorBox(const char *sString);
void InfoBox(const char *sString);
void WarningBox(const char *sString);
#endif /* !__GETSTRING_H__ */

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 "qe3.h"
#include "Radiant.h"
#include "GLWidget.h"
#include "ConsoleDlg.h"
#include "InspectorDialog.h"
#include "TabsDlg.h"
CInspectorDialog *g_Inspectors = NULL;
// CInspectorDialog dialog
void InspectorsDockingCallback ( bool docked , int ID , CWnd* wnd )
{
g_Inspectors->SetDockedTabs( docked , ID );
}
// CInspectorDialog dialog
//IMPLEMENT_DYNAMIC(CInspectorDialog,CTabsDlg)
CInspectorDialog::CInspectorDialog(CWnd* pParent /*=NULL*/)
: CTabsDlg(CInspectorDialog::IDD, pParent)
{
initialized = false;
dockedTabs = W_CONSOLE | W_TEXTURE | W_MEDIA;
}
CInspectorDialog::~CInspectorDialog()
{
}
BEGIN_MESSAGE_MAP(CInspectorDialog, CTabsDlg)
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB_INSPECTOR, OnTcnSelchange )
ON_WM_SIZE()
ON_WM_DESTROY()
ON_WM_CLOSE()
END_MESSAGE_MAP()
// CInspectorDialog message handlers
BOOL CInspectorDialog::OnInitDialog()
{
CTabsDlg::OnInitDialog();
ASSERT ( m_Tabs.GetSafeHwnd() );
LoadWindowPlacement(GetSafeHwnd() , "radiant_InspectorsWindow" );
consoleWnd.Create(IDD_DIALOG_CONSOLE, this);
texWnd.Create(TEXTURE_WINDOW_CLASS, "", QE3_SPLITTER_STYLE, CRect(5, 5, 10, 10), this, 1299);
mediaDlg.Create(IDD_DIALOG_TEXTURELIST, this);
entityDlg.Create(IDD_DIALOG_ENTITY, this);
dockedTabs = GetCvarInt ( "radiant_InspectorDockedDialogs" , W_CONSOLE | W_TEXTURE | W_MEDIA );
AddDockedWindow ( &consoleWnd , W_CONSOLE , 1 , "Console" , (dockedTabs & W_CONSOLE ) != 0 , InspectorsDockingCallback );
AddDockedWindow ( &texWnd , W_TEXTURE , 2 , "Textures" , (dockedTabs & W_TEXTURE ) != 0 , InspectorsDockingCallback );
AddDockedWindow ( &mediaDlg , W_MEDIA , 3 , "Media" , (dockedTabs & W_MEDIA ) != 0 , InspectorsDockingCallback );
AddDockedWindow ( &entityDlg , W_ENTITY , 4 , "Entity" , (dockedTabs & W_ENTITY ) != 0 , InspectorsDockingCallback );
SetMode(W_CONSOLE);
initialized = true;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CInspectorDialog::SetMode(int mode, bool updateTabs) {
FocusWindow ( mode );
}
void CInspectorDialog::UpdateEntitySel(eclass_t *ent) {
entityDlg.UpdateEntitySel(ent);
}
void CInspectorDialog::FillClassList() {
entityDlg.AddClassNames();
}
void CInspectorDialog::UpdateSelectedEntity() {
entityDlg.SetKeyValPairs();
}
bool CInspectorDialog::GetSelectAllCriteria(idStr &key, idStr &val) {
CString k, v;
entityDlg.editKey.GetWindowText(k);
entityDlg.editVal.GetWindowText(v);
key = k;
val = v;
return true;
}
void CInspectorDialog::OnSize(UINT nType, int cx, int cy)
{
CTabsDlg::OnSize(nType, cx, cy);
DockedWindowInfo* info = NULL;
POSITION pos;
WORD wID;
if (!initialized) {
return;
}
CRect rect;
GetClientRect(rect);
CRect tabRect;
m_Tabs.GetWindowRect(tabRect);
// retain vert size but size 4 in from edges and 4 up from bottom
tabRect.left = 4;
tabRect.right = rect.Width() - 4;
tabRect.top = rect.Height() - tabRect.Height() - 4;
tabRect.bottom = rect.Height() - 4;
// adjust rect for children size
rect.bottom -= 5 + tabRect.Height();
m_Tabs.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), 0);
for( pos = m_Windows.GetStartPosition(); pos != NULL ; )
{
m_Windows.GetNextAssoc( pos, wID, (void*&)info );
if ( (info->m_State == DockedWindowInfo::DOCKED) ) {
info->m_Window->SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), 0);
}
}
}
void CInspectorDialog::OnDestroy()
{
::SaveWindowPlacement(GetSafeHwnd() , "radiant_InspectorsWindow" );
SetCvarInt("radiant_InspectorDockedDialogs" , dockedTabs );
CTabsDlg::OnDestroy();
}
void CInspectorDialog::OnClose()
{
CTabsDlg::OnClose();
}
BOOL CInspectorDialog::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if ( pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP) {
g_pParentWnd->PostMessage(pMsg->message, pMsg->wParam, pMsg->lParam);
}
return CTabsDlg::PreTranslateMessage(pMsg);
}
void CInspectorDialog::SetDockedTabs ( bool docked , int ID )
{
if ( docked ) {
dockedTabs |= ID;
}
else {
dockedTabs &= ~ID;
}
}
void CInspectorDialog::AssignModel ()
{
entityDlg.AssignModel();
}

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.
===========================================================================
*/
#pragma once
#include "afxcmn.h"
#include "entitydlg.h"
#include "ConsoleDlg.h"
#include "TabsDlg.h"
// CInspectorDialog dialog
class CInspectorDialog : public CTabsDlg
{
//DECLARE_DYNAMIC(CInspectorDialog)w
public:
CInspectorDialog(CWnd* pParent = NULL); // standard constructor
virtual ~CInspectorDialog();
// Dialog Data
enum { IDD = IDD_DIALOG_INSPECTORS };
protected:
bool initialized;
unsigned int dockedTabs;
DECLARE_MESSAGE_MAP()
public:
virtual BOOL OnInitDialog();
void AssignModel ();
CTabCtrl tabInspector;
//idGLConsoleWidget consoleWnd;
CConsoleDlg consoleWnd;
CNewTexWnd texWnd;
CDialogTextures mediaDlg;
CEntityDlg entityDlg;
void SetMode(int mode, bool updateTabs = true);
void UpdateEntitySel(eclass_t *ent);
void UpdateSelectedEntity();
void FillClassList();
bool GetSelectAllCriteria(idStr &key, idStr &val);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnDestroy();
afx_msg void OnClose();
virtual BOOL PreTranslateMessage(MSG* pMsg);
void SetDockedTabs ( bool docked , int ID );
};
extern CInspectorDialog *g_Inspectors;

View File

@@ -0,0 +1,969 @@
/*
===========================================================================
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 "qe3.h"
#include "Radiant.h"
#include "../../game/game.h"
#include "../comafx/DialogColorPicker.h"
#include "LightDlg.h"
#ifdef ID_DEBUG_MEMORY
#undef new
#undef DEBUG_NEW
#define DEBUG_NEW new
#endif
void CLightInfo::Defaults() {
pointLight = true;
fallOff = 1;
strTexture = "";
equalRadius = true;
explicitStartEnd = false;
lightRadius.Zero();
lightTarget.Zero();
lightRight.Zero();
lightUp.Zero();
lightStart.Zero();
lightEnd.Zero();
lightCenter.Zero();
hasCenter = false;
isParallel = false;
castShadows = true;
castSpecular = true;
castDiffuse = true;
rotate = false;
strobe = false;
rotateSpeed = 0;
strobeSpeed = 0;
color[0] = color[1] = color[2] = 255;
fogDensity[0] = fogDensity[1] = fogDensity[2] = 0;
fog = false;
lightRadius[0] = lightRadius[1] = lightRadius[2] = 300;
}
void CLightInfo::DefaultPoint() {
idVec3 oldColor = color;
Defaults();
color = oldColor;
pointLight = true;
}
void CLightInfo::DefaultProjected() {
idVec3 oldColor = color;
Defaults();
color = oldColor;
pointLight = false;
lightTarget[2] = -256;
lightUp[1] = -128;
lightRight[0] = -128;
}
void CLightInfo::FromDict( const idDict *e ) {
lightRadius.Zero();
lightTarget.Zero();
lightRight.Zero();
lightUp.Zero();
lightStart.Zero();
lightEnd.Zero();
lightCenter.Zero();
castShadows = !e->GetBool("noshadows");
castSpecular = !e->GetBool("nospecular");
castDiffuse = !e->GetBool("nodiffuse");
fallOff = e->GetFloat("falloff");
strTexture = e->GetString("texture");
isParallel = e->GetBool("parallel");
if (!e->GetVector("_color", "", color)) {
color[0] = color[1] = color[2] = 1;
}
// windows needs 0-255 scale
color[0] *= 255;
color[1] *= 255;
color[2] *= 255;
if (e->GetVec4("fog", "", fogDensity)) {
fog = true;
} else {
fog = false;
}
if (e->GetVector("light_right","", lightRight)) {
// projected light
pointLight = false;
e->GetVector("light_target", "", lightTarget);
e->GetVector("light_up", "", lightUp);
if (e->GetVector("light_start", "", lightStart)) {
// explicit start and end points
explicitStartEnd = true;
if (!e->GetVector("light_end", "", lightEnd)) {
// no end, use target
VectorCopy(lightTarget, lightEnd);
}
} else {
explicitStartEnd = false;
// create a start a quarter of the way to the target
lightStart = lightTarget * 0.25;
VectorCopy(lightTarget, lightEnd);
}
} else {
pointLight = true;
if (e->GetVector("light_radius", "", lightRadius)) {
equalRadius = false;
} else {
float radius = e->GetFloat("light");
if (radius == 0) {
radius = 300;
}
lightRadius[0] = lightRadius[1] = lightRadius[2] = radius;
equalRadius = true;
}
if (e->GetVector("light_center", "", lightCenter)) {
hasCenter = true;
}
}
}
void CLightInfo::ToDictFromDifferences ( idDict *e, const idDict *differences ) {
for ( int i = 0 ; i < differences->GetNumKeyVals () ; i ++ ) {
const idKeyValue *kv = differences->GetKeyVal( i );
if ( kv->GetValue().Length() > 0 ) {
e->Set ( kv->GetKey() ,kv->GetValue() );
} else {
e->Delete ( kv->GetKey() );
}
common->Printf( "Applied difference: %s %s\n" , kv->GetKey().c_str() , kv->GetValue().c_str() );
}
}
//write all info to a dict, regardless of light type
void CLightInfo::ToDictWriteAllInfo( idDict *e ) {
e->Set("noshadows", (!castShadows) ? "1" : "0");
e->Set("nospecular", (!castSpecular) ? "1" : "0");
e->Set("nodiffuse", (!castDiffuse) ? "1" : "0");
e->SetFloat("falloff",fallOff);
if (strTexture.GetLength() > 0 ) {
e->Set("texture", strTexture);
}
idVec3 temp = color;
temp /= 255;
e->SetVector("_color", temp);
if (!equalRadius) {
e->Set("light_radius", va("%g %g %g", lightRadius[0], lightRadius[1], lightRadius[2]));
} else {
e->Set("light_radius", va("%g %g %g", lightRadius[0], lightRadius[0], lightRadius[0]));
}
e->Set("light_center", va("%g %g %g", lightCenter[0], lightCenter[1], lightCenter[2]));
e->Set("parallel", isParallel?"1":"0");
e->Set("light_target", va("%g %g %g", lightTarget[0], lightTarget[1], lightTarget[2]));
e->Set("light_up", va("%g %g %g", lightUp[0], lightUp[1], lightUp[2]));
e->Set("light_right", va("%g %g %g", lightRight[0], lightRight[1], lightRight[2]));
e->Set("light_start", va("%g %g %g", lightStart[0], lightStart[1], lightStart[2]));
e->Set("light_end", va("%g %g %g", lightEnd[0], lightEnd[1], lightEnd[2]));
}
void CLightInfo::ToDict( idDict *e ) {
e->Delete("noshadows");
e->Delete("nospecular");
e->Delete("nodiffuse");
e->Delete("falloff");
e->Delete("parallel");
e->Delete("texture");
e->Delete("_color");
e->Delete("fog");
e->Delete("light_target");
e->Delete("light_right");
e->Delete("light_up");
e->Delete("light_start");
e->Delete("light_end");
e->Delete("light_radius");
e->Delete("light_center");
e->Delete("light");
e->Set("noshadows", (!castShadows) ? "1" : "0");
e->Set("nospecular", (!castSpecular) ? "1" : "0");
e->Set("nodiffuse", (!castDiffuse) ? "1" : "0");
e->SetFloat("falloff",fallOff);
if (strTexture.GetLength() > 0) {
e->Set("texture", strTexture);
}
idVec3 temp = color;
temp /= 255;
e->SetVector("_color", temp);
if (fog) {
e->Set("fog", va("%g %g %g %g", fogDensity[0]/255.0, fogDensity[1]/255.0, fogDensity[2]/255.0, fogDensity[3]/255.0));
}
if (pointLight) {
if (!equalRadius) {
e->Set("light_radius", va("%g %g %g", lightRadius[0], lightRadius[1], lightRadius[2]));
} else {
e->Set("light_radius", va("%g %g %g", lightRadius[0], lightRadius[0], lightRadius[0]));
}
if (hasCenter) {
e->Set("light_center", va("%g %g %g", lightCenter[0], lightCenter[1], lightCenter[2]));
}
if (isParallel) {
e->Set("parallel", "1");
}
} else {
e->Set("light_target", va("%g %g %g", lightTarget[0], lightTarget[1], lightTarget[2]));
e->Set("light_up", va("%g %g %g", lightUp[0], lightUp[1], lightUp[2]));
e->Set("light_right", va("%g %g %g", lightRight[0], lightRight[1], lightRight[2]));
if (explicitStartEnd) {
e->Set("light_start", va("%g %g %g", lightStart[0], lightStart[1], lightStart[2]));
e->Set("light_end", va("%g %g %g", lightEnd[0], lightEnd[1], lightEnd[2]));
}
}
}
CLightInfo::CLightInfo() {
Defaults();
}
/////////////////////////////////////////////////////////////////////////////
// CLightDlg dialog
CLightDlg *g_LightDialog = NULL;
CLightDlg::CLightDlg(CWnd* pParent /*=NULL*/)
: CDialog(CLightDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CLightDlg)
m_bEqualRadius = FALSE;
m_bExplicitFalloff = FALSE;
m_bPointLight = FALSE;
m_bCheckProjected = FALSE;
m_fFallloff = 0.0f;
m_nFalloff = -1;
m_bRotate = FALSE;
m_bShadows = FALSE;
m_bSpecular = FALSE;
m_bDiffuse = FALSE;
m_fEndX = 0.0f;
m_fEndY = 0.0f;
m_fEndZ = 0.0f;
m_fRadiusX = 0.0f;
m_fRadiusY = 0.0f;
m_fRadiusZ = 0.0f;
m_fRightX = 0.0f;
m_fRightY = 0.0f;
m_fRightZ = 0.0f;
m_fRotate = 0.0f;
m_fStartX = 0.0f;
m_fStartY = 0.0f;
m_fStartZ = 0.0f;
m_fTargetX = 0.0f;
m_fTargetY = 0.0f;
m_fTargetZ = 0.0f;
m_fUpX = 0.0f;
m_fUpY = 0.0f;
m_fUpZ = 0.0f;
m_hasCenter = FALSE;
m_centerX = 0.0f;
m_centerY = 0.0f;
m_centerZ = 0.0f;
m_bIsParallel = FALSE;
//}}AFX_DATA_INIT
m_drawMaterial = new idGLDrawableMaterial();
}
CLightDlg::~CLightDlg() {
delete m_drawMaterial;
}
void CLightDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLightDlg)
if ( com_editorActive ) {
DDX_Control(pDX, IDC_LIGHTPREVIEW, m_wndPreview);
}
DDX_Control(pDX, IDC_COMBO_TEXTURE, m_wndLights);
DDX_Check(pDX, IDC_CHECK_EQUALRADIUS, m_bEqualRadius);
DDX_Check(pDX, IDC_CHECK_EXPLICITFALLOFF, m_bExplicitFalloff);
DDX_Check(pDX, IDC_CHECK_POINT, m_bPointLight);
DDX_Check(pDX, IDC_CHECK_PROJECTED, m_bCheckProjected);
DDX_Radio(pDX, IDC_RADIO_FALLOFF, m_nFalloff);
DDX_Check(pDX, IDC_CHECK_SHADOWS, m_bShadows);
DDX_Check(pDX, IDC_CHECK_SPECULAR, m_bSpecular);
DDX_Check(pDX, IDC_CHECK_DIFFUSE, m_bDiffuse);
DDX_Check(pDX , IDC_CHECK_PARALLEL , m_bIsParallel );
DDX_Text(pDX, IDC_EDIT_ENDX, m_fEndX);
DDX_Text(pDX, IDC_EDIT_ENDY, m_fEndY);
DDX_Text(pDX, IDC_EDIT_ENDZ, m_fEndZ);
DDX_Text(pDX, IDC_EDIT_RADIUSX, m_fRadiusX);
DDX_Text(pDX, IDC_EDIT_RADIUSY, m_fRadiusY);
DDX_Text(pDX, IDC_EDIT_RADIUSZ, m_fRadiusZ);
DDX_Text(pDX, IDC_EDIT_RIGHTX, m_fRightX);
DDX_Text(pDX, IDC_EDIT_RIGHTY, m_fRightY);
DDX_Text(pDX, IDC_EDIT_RIGHTZ, m_fRightZ);
DDX_Text(pDX, IDC_EDIT_STARTX, m_fStartX);
DDX_Text(pDX, IDC_EDIT_STARTY, m_fStartY);
DDX_Text(pDX, IDC_EDIT_STARTZ, m_fStartZ);
DDX_Text(pDX, IDC_EDIT_TARGETX, m_fTargetX);
DDX_Text(pDX, IDC_EDIT_TARGETY, m_fTargetY);
DDX_Text(pDX, IDC_EDIT_TARGETZ, m_fTargetZ);
DDX_Text(pDX, IDC_EDIT_UPX, m_fUpX);
DDX_Text(pDX, IDC_EDIT_UPY, m_fUpY);
DDX_Text(pDX, IDC_EDIT_UPZ, m_fUpZ);
DDX_Check(pDX, IDC_CHECK_CENTER, m_hasCenter);
DDX_Text(pDX, IDC_EDIT_CENTERX, m_centerX);
DDX_Text(pDX, IDC_EDIT_CENTERY, m_centerY);
DDX_Text(pDX, IDC_EDIT_CENTERZ, m_centerZ);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLightDlg, CDialog)
//{{AFX_MSG_MAP(CLightDlg)
ON_BN_CLICKED(IDC_BTN_TEXTURE, OnBtnTexture)
ON_BN_CLICKED(IDC_CHECK_EQUALRADIUS, OnCheckEqualradius)
ON_BN_CLICKED(IDC_CHECK_EXPLICITFALLOFF, OnCheckExplicitfalloff)
ON_BN_CLICKED(IDC_CHECK_POINT, OnCheckPoint)
ON_BN_CLICKED(IDC_CHECK_PROJECTED, OnCheckProjected)
ON_BN_CLICKED(IDC_RADIO_FALLOFF, OnRadioFalloff)
ON_BN_CLICKED(IDC_APPLY, OnApply)
ON_BN_CLICKED(IDC_APPLY_DIFFERENT, OnApplyDifferences)
ON_BN_CLICKED(IDC_BTN_COLOR, OnBtnColor)
ON_WM_CTLCOLOR()
ON_CBN_SELCHANGE(IDC_COMBO_TEXTURE, OnSelchangeComboTexture)
ON_BN_CLICKED(IDC_CHECK_CENTER, OnCheckCenter)
ON_BN_CLICKED(IDC_CHECK_PARALLEL, OnCheckParallel)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLightDlg message handlers
void CLightDlg::SetSpecifics() {
if (lightInfo.pointLight) {
GetDlgItem(IDC_EDIT_RADIUSY)->EnableWindow(!lightInfo.equalRadius);
GetDlgItem(IDC_EDIT_RADIUSZ)->EnableWindow(!lightInfo.equalRadius);
GetDlgItem(IDC_EDIT_CENTERX)->EnableWindow(lightInfo.hasCenter);
GetDlgItem(IDC_EDIT_CENTERY)->EnableWindow(lightInfo.hasCenter);
GetDlgItem(IDC_EDIT_CENTERZ)->EnableWindow(lightInfo.hasCenter);
} else {
GetDlgItem(IDC_EDIT_STARTX)->EnableWindow(lightInfo.explicitStartEnd);
GetDlgItem(IDC_EDIT_STARTY)->EnableWindow(lightInfo.explicitStartEnd);
GetDlgItem(IDC_EDIT_STARTZ)->EnableWindow(lightInfo.explicitStartEnd);
GetDlgItem(IDC_EDIT_ENDX)->EnableWindow(lightInfo.explicitStartEnd);
GetDlgItem(IDC_EDIT_ENDY)->EnableWindow(lightInfo.explicitStartEnd);
GetDlgItem(IDC_EDIT_ENDZ)->EnableWindow(lightInfo.explicitStartEnd);
}
}
void CLightDlg::EnableControls() {
GetDlgItem(IDC_CHECK_EQUALRADIUS)->EnableWindow(lightInfo.pointLight);
GetDlgItem(IDC_EDIT_RADIUSX)->EnableWindow(lightInfo.pointLight);
GetDlgItem(IDC_EDIT_RADIUSY)->EnableWindow(lightInfo.pointLight);
GetDlgItem(IDC_EDIT_RADIUSZ)->EnableWindow(lightInfo.pointLight);
GetDlgItem(IDC_RADIO_FALLOFF)->EnableWindow(lightInfo.pointLight);
GetDlgItem(IDC_RADIO_FALLOFF2)->EnableWindow(lightInfo.pointLight);
GetDlgItem(IDC_RADIO_FALLOFF3)->EnableWindow(lightInfo.pointLight);
GetDlgItem(IDC_EDIT_TARGETX)->EnableWindow(!lightInfo.pointLight);
GetDlgItem(IDC_EDIT_TARGETY)->EnableWindow(!lightInfo.pointLight);
GetDlgItem(IDC_EDIT_TARGETZ)->EnableWindow(!lightInfo.pointLight);
GetDlgItem(IDC_EDIT_RIGHTX)->EnableWindow(!lightInfo.pointLight);
GetDlgItem(IDC_EDIT_RIGHTY)->EnableWindow(!lightInfo.pointLight);
GetDlgItem(IDC_EDIT_RIGHTZ)->EnableWindow(!lightInfo.pointLight);
GetDlgItem(IDC_EDIT_UPX)->EnableWindow(!lightInfo.pointLight);
GetDlgItem(IDC_EDIT_UPY)->EnableWindow(!lightInfo.pointLight);
GetDlgItem(IDC_EDIT_UPZ)->EnableWindow(!lightInfo.pointLight);
GetDlgItem(IDC_EDIT_STARTX)->EnableWindow(!lightInfo.pointLight);
GetDlgItem(IDC_EDIT_STARTY)->EnableWindow(!lightInfo.pointLight);
GetDlgItem(IDC_EDIT_STARTZ)->EnableWindow(!lightInfo.pointLight);
GetDlgItem(IDC_EDIT_ENDX)->EnableWindow(!lightInfo.pointLight);
GetDlgItem(IDC_EDIT_ENDY)->EnableWindow(!lightInfo.pointLight);
GetDlgItem(IDC_EDIT_ENDZ)->EnableWindow(!lightInfo.pointLight);
GetDlgItem(IDC_CHECK_EXPLICITFALLOFF)->EnableWindow(!lightInfo.pointLight);
GetDlgItem(IDC_CHECK_POINT)->EnableWindow(!lightInfo.pointLight);
GetDlgItem(IDC_CHECK_PROJECTED)->EnableWindow(lightInfo.pointLight);
GetDlgItem(IDC_EDIT_CENTERX)->EnableWindow(lightInfo.pointLight);
GetDlgItem(IDC_EDIT_CENTERY)->EnableWindow(lightInfo.pointLight);
GetDlgItem(IDC_EDIT_CENTERZ)->EnableWindow(lightInfo.pointLight);
GetDlgItem(IDC_CHECK_CENTER)->EnableWindow(lightInfo.pointLight);
reinterpret_cast<CButton*>(GetDlgItem(IDC_CHECK_PROJECTED))->SetCheck(!lightInfo.pointLight);
reinterpret_cast<CButton*>(GetDlgItem(IDC_CHECK_POINT))->SetCheck(lightInfo.pointLight);
SetSpecifics();
}
void CLightDlg::UpdateDialogFromLightInfo( void ) {
m_hasCenter = lightInfo.hasCenter;
m_bEqualRadius = lightInfo.equalRadius;
m_bExplicitFalloff = lightInfo.explicitStartEnd;
m_bPointLight = lightInfo.pointLight;
m_bCheckProjected = !lightInfo.pointLight;
m_fFallloff = lightInfo.fallOff;
if (lightInfo.fallOff < 0.35) {
m_nFalloff = 0;
} else if (lightInfo.fallOff < 0.70) {
m_nFalloff = 1;
} else {
m_nFalloff = 2;
}
//m_bFog = lightInfo.fog;
m_bRotate = lightInfo.rotate;
m_bShadows = lightInfo.castShadows;
m_bSpecular = lightInfo.castSpecular;
//m_bStrobe = lightInfo.strobe;
//m_fStrobe = lightInfo.strobeSpeed;
int sel = m_wndLights.FindStringExact(-1, lightInfo.strTexture);
m_wndLights.SetCurSel(sel);
if (sel >= 0) {
m_drawMaterial->setMedia(lightInfo.strTexture);
} else {
m_drawMaterial->setMedia(lightInfo.strTexture);
}
m_bDiffuse = lightInfo.castDiffuse;
m_fEndX = lightInfo.lightEnd[0];
m_fEndY = lightInfo.lightEnd[1];
m_fEndZ = lightInfo.lightEnd[2];
m_fRadiusX = lightInfo.lightRadius[0];
m_fRadiusY = lightInfo.lightRadius[1];
m_fRadiusZ = lightInfo.lightRadius[2];
m_fRightX = lightInfo.lightRight[0];
m_fRightY = lightInfo.lightRight[1];
m_fRightZ = lightInfo.lightRight[2];
//m_bRotate = lightInfo.rotate;
//m_fRotate = lightInfo.rotateSpeed;
m_fStartX = lightInfo.lightStart[0];
m_fStartY = lightInfo.lightStart[1];
m_fStartZ = lightInfo.lightStart[2];
m_fTargetX = lightInfo.lightTarget[0];
m_fTargetY = lightInfo.lightTarget[1];
m_fTargetZ = lightInfo.lightTarget[2];
m_fUpX = lightInfo.lightUp[0];
m_fUpY = lightInfo.lightUp[1];
m_fUpZ = lightInfo.lightUp[2];
VectorCopy(lightInfo.color, color);
//m_fFogAlpha = lightInfo.fogDensity[3];
m_centerX = lightInfo.lightCenter[0];
m_centerY = lightInfo.lightCenter[1];
m_centerZ = lightInfo.lightCenter[2];
//jhefty - added parallel light updating
m_bIsParallel = lightInfo.isParallel;
UpdateData(FALSE);
}
void CLightDlg::UpdateLightInfoFromDialog( void ) {
UpdateData( TRUE );
lightInfo.pointLight = ( m_bPointLight != FALSE );
lightInfo.equalRadius = ( m_bEqualRadius != FALSE );
lightInfo.explicitStartEnd = ( m_bExplicitFalloff != FALSE );
if (lightInfo.pointLight) {
if (m_nFalloff == 0) {
m_fFallloff = 0.0;
} else if (m_nFalloff == 1) {
m_fFallloff = 0.5;
} else {
m_fFallloff = 1.0;
}
}
lightInfo.fallOff = m_fFallloff;
//lightInfo.fog = m_bFog;
lightInfo.rotate = ( m_bRotate != FALSE );
lightInfo.castShadows = ( m_bShadows != FALSE );
lightInfo.castSpecular = ( m_bSpecular != FALSE );
VectorCopy(color, lightInfo.color);
lightInfo.isParallel = (m_bIsParallel == TRUE);
//lightInfo.fogDensity[3] = m_fFogAlpha;
//lightInfo.strobe = m_bStrobe;
//lightInfo.strobeSpeed = m_fStrobe;
//lightInfo.rotate = m_bRotate;
//lightInfo.rotateSpeed = m_fRotate;
int sel = m_wndLights.GetCurSel();
CString str("");
if (sel >= 0) {
m_wndLights.GetLBText(sel, str);
}
lightInfo.strTexture = str;
lightInfo.castDiffuse = ( m_bDiffuse != FALSE );
lightInfo.lightEnd[0] = m_fEndX;
lightInfo.lightEnd[1] = m_fEndY;
lightInfo.lightEnd[2] = m_fEndZ;
lightInfo.lightRadius[0] = m_fRadiusX;
lightInfo.lightRadius[1] = m_fRadiusY;
lightInfo.lightRadius[2] = m_fRadiusZ;
lightInfo.lightRight[0] = m_fRightX;
lightInfo.lightRight[1] = m_fRightY;
lightInfo.lightRight[2] = m_fRightZ;
lightInfo.lightStart[0] = m_fStartX;
lightInfo.lightStart[1] = m_fStartY;
lightInfo.lightStart[2] = m_fStartZ;
lightInfo.lightTarget[0] = m_fTargetX;
lightInfo.lightTarget[1] = m_fTargetY;
lightInfo.lightTarget[2] = m_fTargetZ;
lightInfo.lightUp[0] = m_fUpX;
lightInfo.lightUp[1] = m_fUpY;
lightInfo.lightUp[2] = m_fUpZ;
lightInfo.hasCenter = ( m_hasCenter != FALSE );
lightInfo.lightCenter[0] = m_centerX;
lightInfo.lightCenter[1] = m_centerY;
lightInfo.lightCenter[2] = m_centerZ;
}
void CLightDlg::SaveLightInfo( const idDict *differences ) {
if ( com_editorActive ) {
// used from Radiant
for ( brush_t *b = selected_brushes.next; b && b != &selected_brushes; b = b->next ) {
if ( ( b->owner->eclass->nShowFlags & ECLASS_LIGHT ) && !b->entityModel ) {
if ( differences ) {
lightInfo.ToDictFromDifferences( &b->owner->epairs, differences );
} else {
lightInfo.ToDict( &b->owner->epairs );
}
Brush_Build( b );
}
}
} else {
// used in-game
idList<idEntity *> list;
list.SetNum( 128 );
int count = gameEdit->GetSelectedEntities( list.Ptr(), list.Num() );
list.SetNum( count );
for ( int i = 0; i < count; i++ ) {
if ( differences ) {
gameEdit->EntityChangeSpawnArgs( list[i], differences );
gameEdit->EntityUpdateChangeableSpawnArgs( list[i], NULL );
} else {
idDict newArgs;
lightInfo.ToDict( &newArgs );
gameEdit->EntityChangeSpawnArgs( list[i], &newArgs );
gameEdit->EntityUpdateChangeableSpawnArgs( list[i], NULL );
}
gameEdit->EntityUpdateVisuals( list[i] );
}
}
}
void CLightDlg::ColorButtons() {
CRect r;
CClientDC dc(this);
CButton *pBtn = (CButton *)GetDlgItem(IDC_BTN_COLOR);
pBtn->GetClientRect(&r);
colorBitmap.DeleteObject();
colorBitmap.CreateCompatibleBitmap(&dc, r.Width(), r.Height());
CDC MemDC;
MemDC.CreateCompatibleDC(&dc);
CBitmap *pOldBmp = MemDC.SelectObject(&colorBitmap);
{
CBrush br(RGB(color[0], color[1], color[2]));
MemDC.FillRect(r,&br);
}
dc.SelectObject(pOldBmp);
pBtn->SetBitmap(HBITMAP(colorBitmap));
}
void CLightDlg::LoadLightTextures() {
int count = declManager->GetNumDecls( DECL_MATERIAL );
int i;
const idMaterial *mat;
for (i = 0; i < count; i++) {
mat = declManager->MaterialByIndex(i, false);
idStr str = mat->GetName();
str.ToLower();
if (str.Icmpn("lights/", strlen("lights/")) == 0 || str.Icmpn("fogs/", strlen("fogs/")) == 0) {
m_wndLights.AddString(mat->GetName());
}
}
}
BOOL CLightDlg::OnInitDialog()
{
CDialog::OnInitDialog();
com_editors |= EDITOR_LIGHT;
UpdateDialog( true );
LoadLightTextures();
if ( com_editorActive ) {
m_wndPreview.setDrawable(m_drawMaterial);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CLightDlg::OnDestroy() {
com_editors &= ~EDITOR_LIGHT;
return CDialog::OnDestroy();
}
void CLightDlg::OnBtnTexture()
{
// TODO: Add your control notification handler code here
}
void CLightDlg::OnCheckEqualradius()
{
lightInfo.equalRadius = ( reinterpret_cast<CButton*>(GetDlgItem(IDC_CHECK_EQUALRADIUS))->GetCheck() != 0 );
SetSpecifics();
}
void CLightDlg::OnCheckExplicitfalloff()
{
lightInfo.explicitStartEnd = ( reinterpret_cast<CButton*>(GetDlgItem(IDC_CHECK_EXPLICITFALLOFF))->GetCheck() != 0 );
SetSpecifics();
}
void CLightDlg::OnCheckPoint()
{
lightInfo.DefaultPoint();
UpdateDialogFromLightInfo();
EnableControls();
}
void CLightDlg::OnCheckProjected()
{
lightInfo.DefaultProjected();
UpdateDialogFromLightInfo();
EnableControls();
}
void CLightDlg::OnRadioFalloff()
{
}
void CLightDlg::OnOK() {
UpdateLightInfoFromDialog();
SaveLightInfo( NULL );
Sys_UpdateWindows(W_ALL);
CDialog::OnOK();
}
entity_t *SingleLightSelected() {
if ( QE_SingleBrush( true, true ) ) {
brush_t *b = selected_brushes.next;
if ( ( b->owner->eclass->nShowFlags & ECLASS_LIGHT ) && !b->entityModel ) {
return b->owner;
}
}
return NULL;
}
void CLightDlg::UpdateDialog( bool updateChecks )
{
CString title;
lightInfo.Defaults();
lightInfoOriginal.Defaults ();
if ( com_editorActive ) {
// used from Radiant
entity_t *e = SingleLightSelected();
if ( e ) {
lightInfo.FromDict(&e->epairs);
lightInfoOriginal.FromDict(&e->epairs); //our original copy of the values that we compare against for apply differences
title = "Light Editor";
} else {
//find the last brush belonging to the last entity selected and use that as the source
e = NULL;
for ( brush_t *b = selected_brushes.next ; b != &selected_brushes ; b = b->next ) {
if ( ( b->owner->eclass->nShowFlags & ECLASS_LIGHT ) && !b->entityModel ) {
e = b->owner;
break;
}
}
if ( e ) {
lightInfo.FromDict( &e->epairs );
lightInfoOriginal.FromDict(&e->epairs); //our original copy of the values that we compaer against for apply differences
title = "Light Editor - (Multiple lights selected)";
} else {
title = "Light Editor - (No lights selected)";
}
}
} else {
// used in-game
idList<idEntity *> list;
list.SetNum( 128 );
int count = gameEdit->GetSelectedEntities( list.Ptr(), list.Num() );
list.SetNum( count );
if ( count > 0 ) {
lightInfo.FromDict( gameEdit->EntityGetSpawnArgs( list[count-1] ) );
title = "Light Editor";
} else {
title = "Light Editor - (No entities selected)";
}
}
SetWindowText( title );
UpdateDialogFromLightInfo();
ColorButtons();
if ( updateChecks ) {
EnableControls();
}
}
void LightEditorInit( const idDict *spawnArgs ) {
if ( renderSystem->IsFullScreen() ) {
common->Printf( "Cannot run the light editor in fullscreen mode.\n"
"Set r_fullscreen to 0 and vid_restart.\n" );
return;
}
if ( g_LightDialog == NULL ) {
InitAfx();
g_LightDialog = new CLightDlg();
}
if ( g_LightDialog->GetSafeHwnd() == NULL ) {
g_LightDialog->Create( IDD_DIALOG_LIGHT );
CRect rct;
LONG lSize = sizeof( rct );
if ( LoadRegistryInfo( "Radiant::LightWindow", &rct, &lSize ) ) {
g_LightDialog->SetWindowPos(NULL, rct.left, rct.top, 0,0, SWP_NOSIZE);
}
}
idKeyInput::ClearStates();
g_LightDialog->ShowWindow( SW_SHOW );
g_LightDialog->SetFocus();
g_LightDialog->UpdateDialog( true );
if ( spawnArgs ) {
// FIXME: select light based on spawn args
}
}
void LightEditorRun( void ) {
#if _MSC_VER >= 1300
MSG *msg = AfxGetCurrentMessage(); // TODO Robert fix me!!
#else
MSG *msg = &m_msgCur;
#endif
while( ::PeekMessage(msg, NULL, NULL, NULL, PM_NOREMOVE) ) {
// pump message
if ( !AfxGetApp()->PumpMessage() ) {
}
}
}
void LightEditorShutdown( void ) {
delete g_LightDialog;
g_LightDialog = NULL;
}
void UpdateLightInspector() {
if ( g_LightDialog && g_LightDialog->GetSafeHwnd() != NULL ) {
g_LightDialog->UpdateDialog(true); //jhefty - update ALL info about the light, including check boxes
}
}
void CLightDlg::OnApply() {
UpdateLightInfoFromDialog();
SaveLightInfo( NULL );
Sys_UpdateWindows( W_ALL );
}
void UpdateLightDialog( float r, float g, float b, float a ) {
UpdateRadiantColor( 0.0f, 0.0f, 0.0f, 0.0f );
g_LightDialog->UpdateColor( r, g, b, a );
}
void CLightDlg::UpdateColor( float r, float g, float b, float a ) {
color[0] = a * r;
color[1] = a * g;
color[2] = a * b;
ColorButtons();
UpdateLightInfoFromDialog();
SaveLightInfo( NULL );
Sys_UpdateWindows( W_CAMERA );
}
void CLightDlg::OnBtnColor() {
int r, g, b;
float ob;
r = color[0];
g = color[1];
b = color[2];
if ( DoNewColor( &r, &g, &b, &ob, UpdateLightDialog ) ) {
color[0] = ob * r;
color[1] = ob * g;
color[2] = ob * b;
ColorButtons();
}
}
void CLightDlg::OnCancel() {
CDialog::OnCancel();
}
HBRUSH CLightDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
return hbr;
}
BOOL CLightDlg::DestroyWindow()
{
if (GetSafeHwnd())
{
CRect rct;
GetWindowRect(rct);
SaveRegistryInfo("Radiant::LightWindow", &rct, sizeof(rct));
}
return CDialog::DestroyWindow();
}
void CLightDlg::OnSelchangeComboTexture()
{
UpdateData(TRUE);
int sel = m_wndLights.GetCurSel();
CString str;
if (sel >= 0) {
m_wndLights.GetLBText(sel, str);
m_drawMaterial->setMedia(str);
if ( com_editorActive ) {
m_wndPreview.RedrawWindow();
}
}
Sys_UpdateWindows(W_ALL);
}
void CLightDlg::OnCheckCenter()
{
if (reinterpret_cast<CButton*>(GetDlgItem(IDC_CHECK_CENTER))->GetCheck()) {
lightInfo.hasCenter = true;
lightInfo.lightCenter.x = 0;
lightInfo.lightCenter.y = 0;
lightInfo.lightCenter.z = 32;
} else {
lightInfo.hasCenter = false;
lightInfo.lightCenter.Zero();
}
UpdateDialogFromLightInfo();
SetSpecifics();
}
void CLightDlg::OnCheckParallel() {
if ( reinterpret_cast<CButton*>(GetDlgItem(IDC_CHECK_PARALLEL))->GetCheck() ) {
lightInfo.hasCenter = true;
lightInfo.isParallel = true;
lightInfo.lightCenter.x = 0;
lightInfo.lightCenter.y = 0;
lightInfo.lightCenter.z = 32;
} else {
lightInfo.isParallel = false;
lightInfo.hasCenter = false;
}
UpdateDialogFromLightInfo();
SetSpecifics();
}
//jhefty - only apply settings that are different
void CLightDlg::OnApplyDifferences () {
idDict differences, modified, original;
UpdateLightInfoFromDialog();
lightInfo.ToDict( &modified );
lightInfoOriginal.ToDictWriteAllInfo( &original );
differences = modified;
// jhefty - compile a set of modified values to apply
for ( int i = 0; i < modified.GetNumKeyVals (); i ++ ) {
const idKeyValue* valModified = modified.GetKeyVal ( i );
const idKeyValue* valOriginal = original.FindKey ( valModified->GetKey() );
//if it hasn't changed, remove it from the list of values to apply
if ( !valOriginal || ( valModified->GetValue() == valOriginal->GetValue() ) ) {
differences.Delete ( valModified->GetKey() );
}
}
SaveLightInfo( &differences );
lightInfoOriginal.FromDict( &modified );
Sys_UpdateWindows( W_ALL );
}

View File

@@ -0,0 +1,188 @@
/*
===========================================================================
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.
===========================================================================
*/
#if !defined(AFX_LIGHTDLG_H__9DF57520_ED11_4BD8_968A_F6A7E34167D2__INCLUDED_)
#define AFX_LIGHTDLG_H__9DF57520_ED11_4BD8_968A_F6A7E34167D2__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "GLWidget.h"
class CLightInfo {
public:
CLightInfo();
bool pointLight;
float fallOff;
CString strTexture;
bool equalRadius;
bool explicitStartEnd;
idVec3 lightStart;
idVec3 lightEnd;
idVec3 lightUp;
idVec3 lightRight;
idVec3 lightTarget;
idVec3 lightCenter;
idVec3 color;
bool fog;
idVec4 fogDensity;
bool strobe;
float strobeSpeed;
bool rotate;
float rotateSpeed;
idVec3 lightRadius;
bool castShadows;
bool castSpecular;
bool castDiffuse;
bool hasCenter;
bool isParallel;
void Defaults();
void DefaultProjected();
void DefaultPoint();
void FromDict( const idDict *e );
void ToDict( idDict *e );
void ToDictFromDifferences( idDict *e, const idDict *differences );
void ToDictWriteAllInfo( idDict *e );
};
/////////////////////////////////////////////////////////////////////////////
// CLightDlg dialog
class CLightDlg : public CDialog {
public:
CLightDlg(CWnd* pParent = NULL); // standard constructor
~CLightDlg();
void UpdateDialogFromLightInfo( void );
void UpdateDialog( bool updateChecks );
void UpdateLightInfoFromDialog( void );
void UpdateColor( float r, float g, float b, float a );
void SetSpecifics();
void EnableControls();
void LoadLightTextures();
void ColorButtons();
void SaveLightInfo( const idDict *differences );
// Dialog Data
//{{AFX_DATA(CLightDlg)
enum { IDD = IDD_DIALOG_LIGHT };
idGLWidget m_wndPreview;
CComboBox m_wndLights;
CSliderCtrl m_wndFalloff;
BOOL m_bEqualRadius;
BOOL m_bExplicitFalloff;
BOOL m_bPointLight;
BOOL m_bCheckProjected;
float m_fFallloff;
int m_nFalloff;
BOOL m_bRotate;
BOOL m_bShadows;
BOOL m_bSpecular;
BOOL m_bDiffuse;
float m_fEndX;
float m_fEndY;
float m_fEndZ;
float m_fRadiusX;
float m_fRadiusY;
float m_fRadiusZ;
float m_fRightX;
float m_fRightY;
float m_fRightZ;
float m_fRotate;
float m_fStartX;
float m_fStartY;
float m_fStartZ;
float m_fTargetX;
float m_fTargetY;
float m_fTargetZ;
float m_fUpX;
float m_fUpY;
float m_fUpZ;
BOOL m_hasCenter;
float m_centerX;
float m_centerY;
float m_centerZ;
BOOL m_bIsParallel;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CLightDlg)
public:
virtual BOOL DestroyWindow();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CLightDlg)
virtual BOOL OnInitDialog();
afx_msg void OnDestroy();
afx_msg void OnBtnTexture();
afx_msg void OnCheckEqualradius();
afx_msg void OnCheckExplicitfalloff();
afx_msg void OnCheckPoint();
afx_msg void OnCheckProjected();
afx_msg void OnRadioFalloff();
virtual void OnOK();
afx_msg void OnApply();
afx_msg void OnBtnColor();
afx_msg void OnBtnFog();
afx_msg void OnCheckFog();
afx_msg void OnCheckRotate();
afx_msg void OnCheckStrobe();
virtual void OnCancel();
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
afx_msg void OnSelchangeComboTexture();
afx_msg void OnCheckCenter();
afx_msg void OnCheckParallel();
afx_msg void OnApplyDifferences();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
CBitmap colorBitmap;
CBitmap fogBitmap;
CLightInfo lightInfo;
CLightInfo lightInfoOriginal;
idVec3 color;
idGLDrawableMaterial * m_drawMaterial;
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_LIGHTDLG_H__9DF57520_ED11_4BD8_968A_F6A7E34167D2__INCLUDED_)

679
neo/tools/radiant/MRU.CPP Normal file
View File

@@ -0,0 +1,679 @@
/*
===========================================================================
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 <windowsx.h>
#include "mru.h"
//*************************************************************
// File name: mru.c
//
// Description:
//
// Routines for MRU support
//
// Development Team:
//
// Gilles Vollant (100144.2636@compuserve.com)
//
//*************************************************************
// CreateMruMenu : MRUMENU constructor
// wNbLruShowInit : nb of item showed in menu
// wNbLruMenuInit : nb of item stored in memory
// wMaxSizeLruItemInit : size max. of filename
//*************************************************************
//
// CreateMruMenu()
//
// Purpose:
//
// Allocate and Initialize an MRU and return a pointer on it
//
//
// Parameters:
//
// WORD wNbLruShowInit - Maximum number of item displayed on menu
// WORD wNbLruMenuInit - Maximum number of item stored in memory
// WORD wMaxSizeLruItemInit - Maximum size of an item (ie size of pathname)
// WORD wIdMruInit - ID of the first item in the menu (default:IDMRU)
//
//
// Return: (LPMRUMENU)
//
// Pointer on a MRUMENU structure, used by other function
//
//
// Comments:
// wNbLruShowInit <= wNbLruMenuInit
//
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
LPMRUMENU CreateMruMenu (WORD wNbLruShowInit,
WORD wNbLruMenuInit,WORD wMaxSizeLruItemInit,WORD wIdMruInit)
{
LPMRUMENU lpMruMenu;
lpMruMenu = (LPMRUMENU)GlobalAllocPtr(GHND,sizeof(MRUMENU));
lpMruMenu->wNbItemFill = 0;
lpMruMenu->wNbLruMenu = wNbLruMenuInit;
lpMruMenu->wNbLruShow = wNbLruShowInit;
lpMruMenu->wIdMru = wIdMruInit;
lpMruMenu->wMaxSizeLruItem = wMaxSizeLruItemInit;
lpMruMenu->lpMRU = (LPSTR)GlobalAllocPtr(GHND,
lpMruMenu->wNbLruMenu*(UINT)lpMruMenu->wMaxSizeLruItem);
if (lpMruMenu->lpMRU == NULL)
{
GlobalFreePtr(lpMruMenu);
lpMruMenu = NULL;
}
return lpMruMenu;
}
//*************************************************************
//
// CreateMruMenuDefault()
//
// Purpose:
//
// Allocate and Initialize an MRU and return a pointer on it
// Use default parameter
//
//
// Parameters:
//
//
// Return: (LPMRUMENU)
//
// Pointer on a MRUMENU structure, used by other function
//
//
// Comments:
//
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
LPMRUMENU CreateMruMenuDefault()
{
return CreateMruMenu (NBMRUMENUSHOW,NBMRUMENU,MAXSIZEMRUITEM,IDMRU);
}
//*************************************************************
//
// DeleteMruMenu()
//
// Purpose:
// Destructor :
// Clean and free a MRUMENU structure
//
// Parameters:
//
// LPMRUMENU lpMruMenu - pointer on MRUMENU, allocated
// by CreateMruMenu() or CreateMruMenuDefault()
//
//
// Return: void
//
//
// Comments:
//
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
void DeleteMruMenu(LPMRUMENU lpMruMenu)
{
GlobalFreePtr(lpMruMenu->lpMRU);
GlobalFreePtr(lpMruMenu);
}
//*************************************************************
//
// SetNbLruShow()
//
// Purpose:
// Change the maximum number of item displayed on menu
//
// Parameters:
// LPMRUMENU lpMruMenu - pointer on MRUMENU
// WORD wNbLruShowInit - Maximum number of item displayed on menu
//
//
// Return: void
//
//
// Comments:
//
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
void SetNbLruShow (LPMRUMENU lpMruMenu,WORD wNbLruShowInit)
{
lpMruMenu->wNbLruShow = min(wNbLruShowInit,lpMruMenu->wNbLruMenu);
}
//*************************************************************
//
// SetMenuItem()
//
// Purpose:
// Set the filename of an item
//
// Parameters:
// LPMRUMENU lpMruMenu - pointer on MRUMENU
// WORD wItem - Number of Item to set, zero based
// LPSTR lpItem - String, contain the filename of the item
//
//
// Return: (BOOL)
// TRUE - Function run successfully
// FALSE - Function don't run successfully
//
//
// Comments:
// used when load .INI or reg database
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
BOOL SetMenuItem (LPMRUMENU lpMruMenu,WORD wItem,LPSTR lpItem)
{
if (wItem >= NBMRUMENU)
return FALSE;
_fstrncpy((lpMruMenu->lpMRU) +
((lpMruMenu->wMaxSizeLruItem) * (UINT)wItem),
lpItem,lpMruMenu->wMaxSizeLruItem-1);
lpMruMenu->wNbItemFill = max(lpMruMenu->wNbItemFill,wItem+1);
return TRUE;
}
//*************************************************************
//
// GetMenuItem()
//
// Purpose:
// Get the filename of an item
//
// Parameters:
// LPMRUMENU lpMruMenu - pointer on MRUMENU
// WORD wItem - Number of Item to set, zero based
// BOOL fIDMBased - TRUE : wItem is based on ID menu item
// FALSE : wItem is zero-based
// LPSTR lpItem - String where the filename of the item will be
// stored by GetMenuItem()
// UINT uiSize - Size of the lpItem buffer
//
//
// Return: (BOOL)
// TRUE - Function run successfully
// FALSE - Function don't run successfully
//
//
// Comments:
// Used for saving in .INI or reg database, or when user select
// an MRU in File menu
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
BOOL GetMenuItem (LPMRUMENU lpMruMenu,WORD wItem,
BOOL fIDMBased,LPSTR lpItem,UINT uiSize)
{
if (fIDMBased)
wItem -= (lpMruMenu->wIdMru + 1);
if (wItem >= lpMruMenu->wNbItemFill)
return FALSE;
_fstrncpy(lpItem,(lpMruMenu->lpMRU) +
((lpMruMenu->wMaxSizeLruItem) * (UINT)(wItem)),uiSize);
*(lpItem+uiSize-1) = '\0';
return TRUE;
}
//*************************************************************
//
// AddNewItem()
//
// Purpose:
// Add an item at the begin of the list
//
// Parameters:
// LPMRUMENU lpMruMenu - pointer on MRUMENU
// LPSTR lpItem - String contain the filename to add
//
// Return: (BOOL)
// TRUE - Function run successfully
// FALSE - Function don't run successfully
//
//
// Comments:
// Used when used open a file (using File Open common
// dialog, Drag and drop or MRU)
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
void AddNewItem (LPMRUMENU lpMruMenu,LPSTR lpItem)
{
WORD i,j;
for (i=0;i<lpMruMenu->wNbItemFill;i++)
if (lstrcmpi(lpItem,(lpMruMenu->lpMRU) +
((lpMruMenu->wMaxSizeLruItem) * (UINT)i)) == 0)
{
// Shift the other items
for (j=i;j>0;j--)
lstrcpy((lpMruMenu->lpMRU) + (lpMruMenu->wMaxSizeLruItem * (UINT)j),
(lpMruMenu->lpMRU) + (lpMruMenu->wMaxSizeLruItem * (UINT)(j-1)));
_fstrncpy(lpMruMenu->lpMRU,lpItem,lpMruMenu->wMaxSizeLruItem-1);
return ;
}
lpMruMenu->wNbItemFill = min(lpMruMenu->wNbItemFill+1,lpMruMenu->wNbLruMenu);
for (i=lpMruMenu->wNbItemFill-1;i>0;i--)
lstrcpy(lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem * (UINT)i),
lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem * (UINT)(i-1)));
_fstrncpy(lpMruMenu->lpMRU,lpItem,lpMruMenu->wMaxSizeLruItem-1);
}
//*************************************************************
//
// DelMenuItem()
//
// Purpose:
// Delete an item
//
// Parameters:
// LPMRUMENU lpMruMenu - pointer on MRUMENU
// WORD wItem - Number of Item to set, zero based
// BOOL fIDMBased - TRUE : wItem is based on ID menu item
// FALSE : wItem is zero-based
//
// Return: (BOOL)
// TRUE - Function run successfully
// FALSE - Function don't run successfully
//
//
// Comments:
// Used when used open a file, using MRU, and when an error
// occured (by example, when file was deleted)
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
BOOL DelMenuItem(LPMRUMENU lpMruMenu,WORD wItem,BOOL fIDMBased)
{
WORD i;
if (fIDMBased)
wItem -= (lpMruMenu->wIdMru + 1);
if (lpMruMenu->wNbItemFill <= wItem)
return FALSE;
lpMruMenu->wNbItemFill--;
for (i=wItem;i<lpMruMenu->wNbItemFill;i++)
lstrcpy(lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem * (UINT)i),
lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem * (UINT)(i+1)));
return TRUE;
}
//*************************************************************
//
// PlaceMenuMRUItem()
//
// Purpose:
// Add MRU at the end of a menu
//
// Parameters:
// LPMRUMENU lpMruMenu - pointer on MRUMENU
// HMENU hMenu - Handle of menu where MRU must be added
// UINT uiItem - Item of menu entry where MRU must be added
//
// Return: void
//
//
// Comments:
// Used MRU is modified, for refresh the File menu
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
void PlaceMenuMRUItem(LPMRUMENU lpMruMenu,HMENU hMenu,UINT uiItem)
{
int i;
WORD wNbShow;
if (hMenu == NULL)
return;
// remove old MRU in menu
for (i=0;i<=(int)(lpMruMenu->wNbLruMenu);i++)
RemoveMenu(hMenu,i+lpMruMenu->wIdMru,MF_BYCOMMAND);
if (lpMruMenu->wNbItemFill == 0)
return;
// If they are item, insert a separator before the files
InsertMenu(hMenu,uiItem,MF_SEPARATOR,lpMruMenu->wIdMru,NULL);
wNbShow = min(lpMruMenu->wNbItemFill,lpMruMenu->wNbLruShow);
for (i=(int)wNbShow-1;i>=0;i--)
{
LPSTR lpTxt;
if (lpTxt = (LPSTR)GlobalAllocPtr(GHND,lpMruMenu->wMaxSizeLruItem + 20))
{
wsprintf(lpTxt,"&%lu %s",
(DWORD)(i+1),lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem*(UINT)i));
InsertMenu(hMenu,(((WORD)i)!=(wNbShow-1)) ? (lpMruMenu->wIdMru+i+2) : lpMruMenu->wIdMru,
MF_STRING,lpMruMenu->wIdMru+i+1,lpTxt);
GlobalFreePtr(lpTxt);
}
}
}
///////////////////////////////////////////
//*************************************************************
//
// SaveMruInIni()
//
// Purpose:
// Save MRU in a private .INI
//
// Parameters:
// LPMRUMENU lpMruMenu - pointer on MRUMENU
// LPSTR lpszSection - Points to a null-terminated string containing
// the name of the section
// LPSTR lpszFile - Points to a null-terminated string that names
// the initialization file.
//
// Return: (BOOL)
// TRUE - Function run successfully
// FALSE - Function don't run successfully
//
//
// Comments:
// See WritePrivateProfileString API for more info on lpszSection and lpszFile
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
BOOL SaveMruInIni(LPMRUMENU lpMruMenu,LPSTR lpszSection,LPSTR lpszFile)
{
LPSTR lpTxt;
WORD i;
lpTxt = (LPSTR)GlobalAllocPtr(GHND,lpMruMenu->wMaxSizeLruItem + 20);
if (lpTxt == NULL)
return FALSE;
for (i=0;i<lpMruMenu->wNbLruMenu;i++)
{
char szEntry[16];
wsprintf(szEntry,"File%lu",(DWORD)i+1);
if (!GetMenuItem(lpMruMenu,i,FALSE,lpTxt,lpMruMenu->wMaxSizeLruItem + 10))
*lpTxt = '\0';
WritePrivateProfileString(lpszSection,szEntry,lpTxt,lpszFile);
}
GlobalFreePtr(lpTxt);
WritePrivateProfileString(NULL,NULL,NULL,lpszFile); // flush cache
return TRUE;
}
//*************************************************************
//
// LoadMruInIni()
//
// Purpose:
// Load MRU from a private .INI
//
// Parameters:
// LPMRUMENU lpMruMenu - pointer on MRUMENU
// LPSTR lpszSection - Points to a null-terminated string containing
// the name of the section
// LPSTR lpszFile - Points to a null-terminated string that names
// the initialization file.
//
// Return: (BOOL)
// TRUE - Function run successfully
// FALSE - Function don't run successfully
//
//
// Comments:
// See GetPrivateProfileString API for more info on lpszSection and lpszFile
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
BOOL LoadMruInIni(LPMRUMENU lpMruMenu,LPSTR lpszSection,LPSTR lpszFile)
{
LPSTR lpTxt;
WORD i;
lpTxt = (LPSTR)GlobalAllocPtr(GHND,lpMruMenu->wMaxSizeLruItem + 20);
if (lpTxt == NULL)
return FALSE;
for (i=0;i<lpMruMenu->wNbLruMenu;i++)
{
char szEntry[16];
wsprintf(szEntry,"File%lu",(DWORD)i+1);
GetPrivateProfileString(lpszSection,szEntry,"",lpTxt,
lpMruMenu->wMaxSizeLruItem + 10,lpszFile);
if (*lpTxt == '\0')
break;
SetMenuItem(lpMruMenu,i,lpTxt);
}
GlobalFreePtr(lpTxt);
return TRUE;
}
#ifdef WIN32
BOOL IsWin395OrHigher(void)
{
WORD wVer;
wVer = LOWORD(GetVersion());
wVer = (((WORD)LOBYTE(wVer)) << 8) | (WORD)HIBYTE(wVer);
return (wVer >= 0x035F); // 5F = 95 dec
}
//*************************************************************
//
// SaveMruInReg()
//
// Purpose:
// Save MRU in the registry
//
// Parameters:
// LPMRUMENU lpMruMenu - pointer on MRUMENU
// LPSTR lpszKey - Points to a null-terminated string
// specifying the name of a key that
// this function opens or creates.
//
// Return: (BOOL)
// TRUE - Function run successfully
// FALSE - Function don't run successfully
//
//
// Comments:
// Win32 function designed for Windows NT and Windows 95
// See RegCreateKeyEx API for more info on lpszKey
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
BOOL SaveMruInReg(LPMRUMENU lpMruMenu,LPSTR lpszKey)
{
LPSTR lpTxt;
WORD i;
HKEY hCurKey;
DWORD dwDisp;
lpTxt = (LPSTR)GlobalAllocPtr(GHND,lpMruMenu->wMaxSizeLruItem + 20);
if (lpTxt == NULL)
return FALSE;
RegCreateKeyEx(HKEY_CURRENT_USER,lpszKey,0,NULL,
REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hCurKey,&dwDisp);
for (i=0;i<lpMruMenu->wNbLruMenu;i++)
{
char szEntry[16];
wsprintf(szEntry,"File%lu",(DWORD)i+1);
if (!GetMenuItem(lpMruMenu,i,FALSE,lpTxt,lpMruMenu->wMaxSizeLruItem + 10))
*lpTxt = '\0';
RegSetValueEx(hCurKey,szEntry,0,REG_SZ,(unsigned char*)lpTxt,lstrlen(lpTxt));
}
RegCloseKey(hCurKey);
GlobalFreePtr(lpTxt);
return TRUE;
}
//*************************************************************
//
// LoadMruInReg()
//
// Purpose:
// Load MRU from the registry
//
// Parameters:
// LPMRUMENU lpMruMenu - pointer on MRUMENU
// LPSTR lpszKey - Points to a null-terminated string
// specifying the name of a key that
// this function opens or creates.
//
// Return: (BOOL)
// TRUE - Function run successfully
// FALSE - Function don't run successfully
//
//
// Comments:
// Win32 function designed for Windows NT and Windows 95
// See RegOpenKeyEx API for more info on lpszKey
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
BOOL LoadMruInReg(LPMRUMENU lpMruMenu,LPSTR lpszKey)
{
LPSTR lpTxt;
WORD i;
HKEY hCurKey;
DWORD dwType;
lpTxt = (LPSTR)GlobalAllocPtr(GHND,lpMruMenu->wMaxSizeLruItem + 20);
if (lpTxt == NULL)
return FALSE;
RegOpenKeyEx(HKEY_CURRENT_USER,lpszKey,0,KEY_READ,&hCurKey);
for (i=0;i<lpMruMenu->wNbLruMenu;i++)
{
char szEntry[16];
DWORD dwSizeBuf;
wsprintf(szEntry,"File%lu",(DWORD)i+1);
*lpTxt = '\0';
dwSizeBuf = lpMruMenu->wMaxSizeLruItem + 10;
RegQueryValueEx(hCurKey,szEntry,NULL,&dwType,(LPBYTE)lpTxt,&dwSizeBuf);
*(lpTxt+dwSizeBuf)='\0';
if (*lpTxt == '\0')
break;
SetMenuItem(lpMruMenu,i,lpTxt);
}
RegCloseKey(hCurKey);
GlobalFreePtr(lpTxt);
return TRUE;
}
//*************************************************************
//
// GetWin32Kind()
//
// Purpose:
// Get the Win32 platform
//
// Parameters:
//
// Return: (WIN32KIND)
// WINNT - Run under Windows NT
// WIN32S - Run under Windows 3.1x + Win32s
// WIN95ORGREATHER - Run under Windows 95
//
//
// Comments:
// Win32 function designed for Windows NT and Windows 95
// See RegOpenKeyEx API for more info on lpszKey
//
// History: Date Author Comment
// 09/24/94 G. Vollant Created
//
//*************************************************************
WIN32KIND GetWin32Kind()
{
BOOL IsWin395OrHigher(void);
WORD wVer;
if ((GetVersion() & 0x80000000) == 0)
return WINNT;
wVer = LOWORD(GetVersion());
wVer = (((WORD)LOBYTE(wVer)) << 8) | (WORD)HIBYTE(wVer);
if (wVer >= 0x035F)
return WIN95ORGREATHER;
else
return WIN32S;
}
#endif

94
neo/tools/radiant/MRU.H Normal file
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.
===========================================================================
*/
#ifndef __MRU_H__
#define __MRU_H__
#define NBMRUMENUSHOW 6 // Default number of MRU showed in the menu File
#define NBMRUMENU 9 // Default number of MRU stored
#define IDMRU 8000 // Default First ID of MRU
#ifdef OFS_MAXPATHNAME
#define MAXSIZEMRUITEM OFS_MAXPATHNAME
#else
#define MAXSIZEMRUITEM 128 // Default max size of an entry
#endif
typedef struct
{
WORD wNbItemFill;
WORD wNbLruShow;
WORD wNbLruMenu;
WORD wMaxSizeLruItem;
WORD wIdMru;
LPSTR lpMRU;
} MRUMENU;
typedef MRUMENU FAR * LPMRUMENU;
#ifdef __cplusplus
LPMRUMENU CreateMruMenu (WORD wNbLruShowInit=NBMRUMENUSHOW,
WORD wNbLruMenuInit=NBMRUMENU,
WORD wMaxSizeLruItemInit=MAXSIZEMRUITEM,
WORD wIdMruInit=IDMRU);
#else
LPMRUMENU CreateMruMenu (WORD wNbLruShowInit,
WORD wNbLruMenuInit,
WORD wMaxSizeLruItemInit,
WORD wIdMruInit);
#endif
LPMRUMENU CreateMruMenuDefault();
void DeleteMruMenu (LPMRUMENU lpMruMenu);
void SetNbLruShow (LPMRUMENU lpMruMenu,WORD wNbLruShowInit);
BOOL SetMenuItem (LPMRUMENU lpMruMenu,WORD wItem,
LPSTR lpItem);
BOOL GetMenuItem (LPMRUMENU lpMruMenu,WORD wItem,
BOOL fIDMBased,LPSTR lpItem,UINT uiSize);
BOOL DelMenuItem (LPMRUMENU lpMruMenu,WORD wItem,BOOL fIDMBased);
void AddNewItem (LPMRUMENU lpMruMenu,LPSTR lpItem);
void PlaceMenuMRUItem(LPMRUMENU lpMruMenu,HMENU hMenu,UINT uiItem);
BOOL SaveMruInIni (LPMRUMENU lpMruMenu,LPSTR lpszSection,LPSTR lpszFile);
BOOL LoadMruInIni (LPMRUMENU lpMruMenu,LPSTR lpszSection,LPSTR lpszFile);
#ifdef WIN32
BOOL SaveMruInReg (LPMRUMENU lpMruMenu,LPSTR lpszKey);
BOOL LoadMruInReg (LPMRUMENU lpMruMenu,LPSTR lpszKey);
typedef enum
{
WIN32S,
WINNT,
WIN95ORGREATHER
} WIN32KIND;
WIN32KIND GetWin32Kind();
#endif
//////////////////////////////////////////////////////////////
#endif

File diff suppressed because it is too large Load Diff

559
neo/tools/radiant/MainFrm.h Normal file
View File

@@ -0,0 +1,559 @@
/*
===========================================================================
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.
===========================================================================
*/
#if !defined(AFX_MAINFRM_H__330BBF0A_731C_11D1_B539_00AA00A410FC__INCLUDED_)
#define AFX_MAINFRM_H__330BBF0A_731C_11D1_B539_00AA00A410FC__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#include "XYWnd.h"
#include "NewTexWnd.h"
#include "ZWnd.h"
#include "CamWnd.h"
#include "TextureBar.h"
const int RAD_SHIFT = 0x01;
const int RAD_ALT = 0x02;
const int RAD_CONTROL = 0x04;
const int RAD_PRESS = 0x08;
struct SCommandInfo
{
char* m_strCommand;
unsigned int m_nKey;
unsigned int m_nModifiers;
unsigned int m_nCommand;
};
struct SKeyInfo
{
char* m_strName;
unsigned int m_nVKKey;
};
class CMainFrame : public CFrameWnd
{
DECLARE_DYNAMIC(CMainFrame)
public:
CMainFrame();
void HandleKey(UINT nChar, UINT nRepCnt, UINT nFlags, bool bDown = true)
{
if (bDown)
OnKeyDown(nChar, nRepCnt, nFlags);
else
OnKeyUp(nChar, nRepCnt, nFlags);
};
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
//}}AFX_VIRTUAL
// Implementation
public:
void UpdatePatchToolbarButtons();
void NudgeSelection(int nDirection, float fAmount);
void UpdateTextureBar();
void SetButtonMenuStates();
void SetTexValStatus();
void SetGridStatus();
void RoutineProcessing();
CXYWnd* ActiveXY();
void UpdateWindows(int nBits);
void SetStatusText(int nPane, const char* pText);
void UpdateStatusText();
void SetWindowStyle(int nStyle);
bool GetNurbMode() {
return nurbMode;
}
idCurve_NURBS<idVec2> *GetNurb() {
return &nurb;
}
void OnPrecisionCursorCycle();
virtual ~CMainFrame();
CXYWnd* GetXYWnd() {return m_pXYWnd;};
CXYWnd* GetXZWnd() {return m_pXZWnd;};
CXYWnd* GetYZWnd() {return m_pYZWnd;};
CCamWnd* GetCamera() {return m_pCamWnd;};
CZWnd* GetZWnd() {return m_pZWnd;};
void SetActiveXY(CXYWnd* p)
{
if (m_pActiveXY)
m_pActiveXY->SetActive(false);
m_pActiveXY = p;
if (m_pActiveXY)
m_pActiveXY->SetActive(true);
};
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
CTextureBar m_wndTextureBar;
CSplitterWnd m_wndSplit;
CSplitterWnd m_wndSplit2;
CSplitterWnd m_wndSplit3;
CXYWnd* m_pXYWnd;
CXYWnd* m_pYZWnd;
CXYWnd* m_pXZWnd;
CCamWnd* m_pCamWnd;
CZWnd* m_pZWnd;
CString m_strStatus[15];
CXYWnd* m_pActiveXY;
bool m_bCamPreview;
bool busy;
bool nurbMode;
idCurve_NURBS<idVec2> nurb;
// Generated message map functions
protected:
bool m_bDoLoop;
void CreateQEChildren();
void LoadCommandMap();
void SaveCommandMap();
void ShowMenuItemKeyBindings(CMenu *pMenu);
void SetEntityCheck();
void SetGridChecks(int nID);
public:
void Nudge(int nDim, float fNudge);
void SetBusy(bool b) {
busy = b;
}
// these are public so i can easily reflect messages
// from child windows..
//{{AFX_MSG(CMainFrame)
afx_msg void OnBSPStatus(UINT wParam, long lParam);
afx_msg void OnBSPDone(UINT wParam, long lParam);
afx_msg void OnParentNotify(UINT message, LPARAM lParam);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnDestroy();
afx_msg void OnClose();
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void ToggleCamera();
afx_msg void OnFileClose();
afx_msg void OnFileExit();
afx_msg void OnFileLoadproject();
afx_msg void OnFileNew();
afx_msg void OnFileOpen();
afx_msg void OnFilePointfile();
afx_msg void OnFilePrint();
afx_msg void OnFilePrintPreview();
afx_msg void OnFileSave();
afx_msg void OnFileSaveas();
afx_msg void OnFileSaveCopy();
afx_msg void OnViewShowModels();
afx_msg void OnView100();
afx_msg void OnViewCenter();
afx_msg void OnViewConsole();
afx_msg void OnViewDownfloor();
afx_msg void OnViewEntity();
afx_msg void OnViewMediaBrowser();
afx_msg void OnViewFront();
afx_msg void OnViewShowblocks();
afx_msg void OnViewShowclip();
afx_msg void OnViewShowTriggers();
afx_msg void OnViewShowcoordinates();
afx_msg void OnViewShowent();
afx_msg void OnViewShowlights();
afx_msg void OnViewShownames();
afx_msg void OnViewShowpath();
afx_msg void OnViewShowCombatNodes();
afx_msg void OnViewShowwater();
afx_msg void OnViewShowworld();
afx_msg void OnViewTexture();
afx_msg void OnViewUpfloor();
afx_msg void OnViewXy();
afx_msg void OnViewZ100();
afx_msg void OnViewZoomin();
afx_msg void OnViewZoomout();
afx_msg void OnViewZzoomin();
afx_msg void OnViewZzoomout();
afx_msg void OnViewSide();
afx_msg void OnTexturesShowinuse();
afx_msg void OnTexturesInspector();
afx_msg void OnMiscFindbrush();
afx_msg void OnMiscGamma();
afx_msg void OnMiscNextleakspot();
afx_msg void OnMiscPreviousleakspot();
afx_msg void OnMiscPrintxy();
afx_msg void OnMiscSelectentitycolor();
afx_msg void OnMiscFindOrReplaceEntity();
afx_msg void OnMiscFindNextEntity();
afx_msg void OnMiscSetViewPos();
afx_msg void OnTexturebk();
afx_msg void OnColorsMajor();
afx_msg void OnColorsMinor();
afx_msg void OnColorsXybk();
afx_msg void OnBrush3sided();
afx_msg void OnBrush4sided();
afx_msg void OnBrush5sided();
afx_msg void OnBrush6sided();
afx_msg void OnBrush7sided();
afx_msg void OnBrush8sided();
afx_msg void OnBrush9sided();
afx_msg void OnBrushArbitrarysided();
afx_msg void OnBrushFlipx();
afx_msg void OnBrushFlipy();
afx_msg void OnBrushFlipz();
afx_msg void OnBrushRotatex();
afx_msg void OnBrushRotatey();
afx_msg void OnBrushRotatez();
afx_msg void OnRegionOff();
afx_msg void OnRegionSetbrush();
afx_msg void OnRegionSetselection();
afx_msg void OnRegionSettallbrush();
afx_msg void OnRegionSetxy();
afx_msg void OnSelectionArbitraryrotation();
afx_msg void OnSelectionClone();
afx_msg void OnSelectionConnect();
afx_msg void OnSelectionCsgsubtract();
afx_msg void OnSelectionCsgmerge();
afx_msg void OnSelectionDelete();
afx_msg void OnSelectionDeselect();
afx_msg void OnSelectionDragedges();
afx_msg void OnSelectionDragvertecies();
afx_msg void OnSelectionCenterOrigin();
afx_msg void OnSelectionMakehollow();
afx_msg void OnSelectionSelectcompletetall();
afx_msg void OnSelectionSelectinside();
afx_msg void OnSelectionSelectpartialtall();
afx_msg void OnSelectionSelecttouching();
afx_msg void OnSelectionUngroupentity();
afx_msg void OnSelectionWireFrameOn();
afx_msg void OnSelectionWireFrameOff();
afx_msg void OnSelectionVisibleOn();
afx_msg void OnSelectionVisibleOff();
afx_msg void OnAutocaulk();
afx_msg void OnUpdateAutocaulk(CCmdUI* pCmdUI);
afx_msg void OnTexturesPopup();
afx_msg void OnSplinesPopup();
afx_msg void OnSplinesEditPoints();
afx_msg void OnSplinesAddPoints();
afx_msg void OnSplinesDeletePoint();
afx_msg void OnSplinesInsertPoint();
afx_msg void OnPopupSelection();
afx_msg void OnViewChange();
afx_msg void OnViewCameraupdate();
afx_msg void OnUpdateViewCameraupdate(CCmdUI* pCmdUI);
afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
afx_msg void OnHelpAbout();
afx_msg void OnViewClipper();
afx_msg void OnCameraAngledown();
afx_msg void OnCameraAngleup();
afx_msg void OnCameraBack();
afx_msg void OnCameraDown();
afx_msg void OnCameraForward();
afx_msg void OnCameraLeft();
afx_msg void OnCameraRight();
afx_msg void OnCameraStrafeleft();
afx_msg void OnCameraStraferight();
afx_msg void OnCameraUp();
afx_msg void OnGridToggle();
afx_msg void OnPrefs();
afx_msg void OnToggleToolbar();
afx_msg void OnToggleTextureBar();
afx_msg void OnTogglecamera();
afx_msg void OnToggleview();
afx_msg void OnTogglez();
afx_msg void OnToggleLock();
afx_msg void OnEditMapinfo();
afx_msg void OnEditEntityinfo();
afx_msg void OnViewNextview();
afx_msg void OnHelpCommandlist();
afx_msg void OnFileNewproject();
afx_msg void OnFlipClip();
afx_msg void OnClipSelected();
afx_msg void OnSplitSelected();
afx_msg void OnToggleviewXz();
afx_msg void OnToggleviewYz();
afx_msg void OnColorsBrush();
afx_msg void OnColorsClipper();
afx_msg void OnColorsGridtext();
afx_msg void OnColorsSelectedbrush();
afx_msg void OnColorsGridblock();
afx_msg void OnColorsViewname();
afx_msg void OnColorSetoriginal();
afx_msg void OnColorSetqer();
afx_msg void OnColorSetblack();
afx_msg void OnColorSetSuperMal();
afx_msg void OnColorSetMax();
afx_msg void OnSnaptogrid();
afx_msg void OnSelectScale();
afx_msg void OnSelectMouserotate();
afx_msg void OnEditCopybrush();
afx_msg void OnEditPastebrush();
afx_msg void OnEditUndo();
afx_msg void OnEditRedo();
afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI);
afx_msg void OnUpdateEditRedo(CCmdUI* pCmdUI);
afx_msg void OnSelectionInvert();
afx_msg void OnSelectionTextureDec();
afx_msg void OnSelectionTextureFit();
afx_msg void OnSelectionTextureInc();
afx_msg void OnSelectionTextureRotateclock();
afx_msg void OnSelectionTextureRotatecounter();
afx_msg void OnSelectionTextureScaledown();
afx_msg void OnSelectionTextureScaleup();
afx_msg void OnSelectionTextureShiftdown();
afx_msg void OnSelectionTextureShiftleft();
afx_msg void OnSelectionTextureShiftright();
afx_msg void OnSelectionTextureShiftup();
afx_msg void OnGridNext();
afx_msg void OnGridPrev();
afx_msg void OnSelectionTextureScaleLeft();
afx_msg void OnSelectionTextureScaleRight();
afx_msg void OnTextureReplaceall();
afx_msg void OnScalelockx();
afx_msg void OnScalelocky();
afx_msg void OnScalelockz();
afx_msg void OnSelectMousescale();
afx_msg void OnViewCubicclipping();
afx_msg void OnFileImport();
afx_msg void OnFileProjectsettings();
afx_msg void OnUpdateFileImport(CCmdUI* pCmdUI);
afx_msg void OnViewCubein();
afx_msg void OnViewCubeout();
afx_msg void OnFileSaveregion();
afx_msg void OnUpdateFileSaveregion(CCmdUI* pCmdUI);
afx_msg void OnSelectionMovedown();
afx_msg void OnSelectionMoveup();
afx_msg void OnToolbarMain();
afx_msg void OnToolbarTexture();
afx_msg void OnSelectionPrint();
afx_msg void OnSelectionTogglesizepaint();
afx_msg void OnBrushMakecone();
afx_msg void OnTexturesLoad();
afx_msg void OnToggleRotatelock();
afx_msg void OnCurveBevel();
afx_msg void OnCurveIncreaseVert();
afx_msg void OnCurveDecreaseVert();
afx_msg void OnCurveIncreaseHorz();
afx_msg void OnCurveDecreaseHorz();
afx_msg void OnCurveCylinder();
afx_msg void OnCurveEighthsphere();
afx_msg void OnCurveEndcap();
afx_msg void OnCurveHemisphere();
afx_msg void OnCurveInvertcurve();
afx_msg void OnCurveQuarter();
afx_msg void OnCurveSphere();
afx_msg void OnFileImportmap();
afx_msg void OnFileExportmap();
afx_msg void OnEditLoadprefab();
afx_msg void OnViewShowcurves();
afx_msg void OnSelectionSelectNudgedown();
afx_msg void OnSelectionSelectNudgeleft();
afx_msg void OnSelectionSelectNudgeright();
afx_msg void OnSelectionSelectNudgeup();
afx_msg void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnTexturesLoadlist();
afx_msg void OnDontselectcurve();
afx_msg void OnDynamicLighting();
afx_msg void OnCurveSimplepatchmesh();
afx_msg void OnPatchToggleBox();
afx_msg void OnPatchWireframe();
afx_msg void OnCurvePatchcone();
afx_msg void OnCurvePatchtube();
afx_msg void OnPatchWeld();
afx_msg void OnCurvePatchbevel();
afx_msg void OnCurvePatchendcap();
afx_msg void OnCurvePatchinvertedbevel();
afx_msg void OnCurvePatchinvertedendcap();
afx_msg void OnPatchDrilldown();
afx_msg void OnCurveInsertcolumn();
afx_msg void OnCurveInsertrow();
afx_msg void OnCurveDeletecolumn();
afx_msg void OnCurveDeleterow();
afx_msg void OnCurveInsertAddcolumn();
afx_msg void OnCurveInsertAddrow();
afx_msg void OnCurveInsertInsertcolumn();
afx_msg void OnCurveInsertInsertrow();
afx_msg void OnCurveNegative();
afx_msg void OnCurveNegativeTextureX();
afx_msg void OnCurveNegativeTextureY();
afx_msg void OnCurveDeleteFirstcolumn();
afx_msg void OnCurveDeleteFirstrow();
afx_msg void OnCurveDeleteLastcolumn();
afx_msg void OnCurveDeleteLastrow();
afx_msg void OnPatchBend();
afx_msg void OnPatchInsdel();
afx_msg void OnPatchEnter();
afx_msg void OnPatchTab();
afx_msg void OnCurvePatchdensetube();
afx_msg void OnCurvePatchverydensetube();
afx_msg void OnCurveCap();
afx_msg void OnCurveCapInvertedbevel();
afx_msg void OnCurveCapInvertedendcap();
afx_msg void OnCurveRedisperseCols();
afx_msg void OnCurveRedisperseRows();
afx_msg void OnPatchNaturalize();
afx_msg void OnPatchNaturalizeAlt();
afx_msg void OnSnapToGrid();
afx_msg void OnCurvePatchsquare();
afx_msg void OnTexturesTexturewindowscale10();
afx_msg void OnTexturesTexturewindowscale100();
afx_msg void OnTexturesTexturewindowscale200();
afx_msg void OnTexturesTexturewindowscale25();
afx_msg void OnTexturesTexturewindowscale50();
afx_msg void OnTexturesFlush();
afx_msg void OnCurveOverlayClear();
afx_msg void OnCurveOverlaySet();
afx_msg void OnCurveThicken();
afx_msg void OnCurveCyclecap();
afx_msg void OnCurveCyclecapAlt();
afx_msg void OnCurveMatrixTranspose();
afx_msg void OnTexturesReloadshaders();
afx_msg void OnShowEntities();
afx_msg void OnViewEntitiesasBoundingbox();
afx_msg void OnViewEntitiesasSelectedskinned();
afx_msg void OnViewEntitiesasSelectedwireframe();
afx_msg void OnViewEntitiesasSkinned();
afx_msg void OnViewEntitiesasSkinnedandboxed();
afx_msg void OnViewEntitiesasWireframe();
afx_msg void OnViewShowhint();
afx_msg void OnUpdateTexturesShowinuse(CCmdUI* pCmdUI);
afx_msg void OnTexturesShowall();
afx_msg void OnTexturesHideall();
afx_msg void OnPatchInspector();
afx_msg void OnViewOpengllighting();
afx_msg void OnSelectAll();
afx_msg void OnViewShowcaulk();
afx_msg void OnCurveFreeze();
afx_msg void OnCurveUnFreeze();
afx_msg void OnCurveUnFreezeAll();
afx_msg void OnSelectReselect();
afx_msg void OnViewShowangles();
afx_msg void OnEditSaveprefab();
afx_msg void OnCurveMoreendcapsbevelsSquarebevel();
afx_msg void OnCurveMoreendcapsbevelsSquareendcap();
afx_msg void OnBrushPrimitivesSphere();
afx_msg void OnViewCrosshair();
afx_msg void OnViewHideshowHideselected();
afx_msg void OnViewHideshowHideNotselected();
afx_msg void OnViewHideshowShowhidden();
afx_msg void OnTexturesShadersShow();
afx_msg void OnTexturesFlushUnused();
afx_msg void OnViewGroups();
afx_msg void OnDropGroupAddtoWorld();
afx_msg void OnDropGroupName();
afx_msg void OnDropGroupNewgroup();
afx_msg void OnDropGroupRemove();
afx_msg void OnProjectedLight();
afx_msg void OnShowLighttextures();
afx_msg void OnShowLightvolumes();
afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
afx_msg void OnSplinesMode();
afx_msg void OnSplinesLoad();
afx_msg void OnSplinesSave();
afx_msg void OnSplinesEdit();
afx_msg void OnSplineTest();
afx_msg void OnSplinesTarget();
afx_msg void OnSplinesTargetPoints();
afx_msg void OnSplinesCameraPoints();
afx_msg void OnPopupNewcameraInterpolated();
afx_msg void OnPopupNewcameraSpline();
afx_msg void OnPopupNewcameraFixed();
afx_msg void OnSelectionMoveonly();
afx_msg void OnSelectBrushesOnly();
afx_msg void OnSelectByBoundingBrush();
afx_msg void OnSelectBrushlight();
afx_msg void OnSelectionCombine();
afx_msg void OnPatchCombine();
afx_msg void OnShowDoom();
afx_msg void OnViewRendermode();
afx_msg void OnViewRebuildrenderdata();
afx_msg void OnViewRealtimerebuild();
afx_msg void OnViewRenderentityoutlines();
afx_msg void OnViewMaterialanimation();
afx_msg void OnAxialTextureByWidth();
afx_msg void OnAxialTextureByHeight();
afx_msg void OnAxialTextureArbitrary();
afx_msg void OnSelectionExportToobj();
afx_msg void OnSelectionExportToCM();
afx_msg void OnViewRenderselection();
afx_msg void OnSelectNomodels();
afx_msg void OnViewShowShowvisportals();
afx_msg void OnViewShowNoDraw();
afx_msg void OnViewRendersound();
afx_msg void OnSoundShowsoundvolumes();
afx_msg void OnSoundShowselectedsoundvolumes();
afx_msg void OnNurbEditor();
afx_msg void OnSelectCompleteEntity();
afx_msg void OnGenerateMaterialsList();
afx_msg void OnMru(unsigned int nID);
afx_msg void OnViewNearest(unsigned int nID);
afx_msg void OnTextureWad(unsigned int nID);
afx_msg void OnBspCommand(unsigned int nID);
afx_msg void OnGrid1(unsigned int nID);
afx_msg void OnDisplayChange(WPARAM wp, LPARAM lp);
afx_msg void OnSelectAlltargets();
//}}AFX_MSG
void CheckTextureScale(int id);
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAINFRM_H__330BBF0A_731C_11D1_B539_00AA00A410FC__INCLUDED_)

View File

@@ -0,0 +1,120 @@
/*
===========================================================================
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 "qe3.h"
#include "Radiant.h"
#include "MapInfo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMapInfo dialog
CMapInfo::CMapInfo(CWnd* pParent /*=NULL*/)
: CDialog(CMapInfo::IDD, pParent)
{
//{{AFX_DATA_INIT(CMapInfo)
m_nNet = 0;
m_nTotalBrushes = 0;
m_nTotalEntities = 0;
//}}AFX_DATA_INIT
}
void CMapInfo::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMapInfo)
DDX_Control(pDX, IDC_LIST_ENTITIES, m_lstEntity);
DDX_Text(pDX, IDC_EDIT_NET, m_nNet);
DDX_Text(pDX, IDC_EDIT_TOTALBRUSHES, m_nTotalBrushes);
DDX_Text(pDX, IDC_EDIT_TOTALENTITIES, m_nTotalEntities);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMapInfo, CDialog)
//{{AFX_MSG_MAP(CMapInfo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMapInfo message handlers
BOOL CMapInfo::OnInitDialog()
{
CDialog::OnInitDialog();
m_nTotalBrushes = 0;
m_nTotalEntities = 0;
m_nNet = 0;
for (brush_t* pBrush=active_brushes.next ; pBrush != &active_brushes ; pBrush=pBrush->next)
{
m_nTotalBrushes++;
if (pBrush->owner == world_entity)
m_nNet++;
}
CMapStringToPtr mapEntity;
int nValue = 0;
for (entity_t* pEntity=entities.next ; pEntity != &entities ; pEntity=pEntity->next)
{
m_nTotalEntities++;
nValue = 0;
mapEntity.Lookup(pEntity->eclass->name, reinterpret_cast<void*&>(nValue));
nValue++ ;
mapEntity.SetAt(pEntity->eclass->name, reinterpret_cast<void*>(nValue));
}
m_lstEntity.ResetContent();
m_lstEntity.SetTabStops(96);
CString strKey;
POSITION pos = mapEntity.GetStartPosition();
while (pos)
{
mapEntity.GetNextAssoc(pos, strKey, reinterpret_cast<void*&>(nValue));
CString strList;
strList.Format("%s\t%i", strKey, nValue);
m_lstEntity.AddString(strList);
}
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

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.
===========================================================================
*/
#if !defined(AFX_MAPINFO_H__C241B9A2_819F_11D1_B548_00AA00A410FC__INCLUDED_)
#define AFX_MAPINFO_H__C241B9A2_819F_11D1_B548_00AA00A410FC__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// MapInfo.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CMapInfo dialog
class CMapInfo : public CDialog
{
// Construction
public:
CMapInfo(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CMapInfo)
enum { IDD = IDD_DLG_MAPINFO };
CListBox m_lstEntity;
int m_nNet;
int m_nTotalBrushes;
int m_nTotalEntities;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMapInfo)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CMapInfo)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAPINFO_H__C241B9A2_819F_11D1_B548_00AA00A410FC__INCLUDED_)

View File

@@ -0,0 +1,181 @@
/*
===========================================================================
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 "qe3.h"
#include "Radiant.h"
#include "mediapreviewdlg.h"
// CMediaPreviewDlg dialog
IMPLEMENT_DYNAMIC(CMediaPreviewDlg, CDialog)
CMediaPreviewDlg::CMediaPreviewDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMediaPreviewDlg::IDD, pParent)
{
mode = MATERIALS;
media = "";
}
void CMediaPreviewDlg::SetMedia(const char *_media) {
media = _media;
Refresh();
}
void CMediaPreviewDlg::Refresh() {
if (mode == GUIS) {
const idMaterial *mat = declManager->FindMaterial("guisurfs/guipreview");
mat->SetGui( media );
drawMaterial.setMedia("guisurfs/guipreview");
drawMaterial.setScale( 4.4f );
} else {
drawMaterial.setMedia(media);
drawMaterial.setScale( 1.0f );
}
wndPreview.setDrawable(&drawMaterial);
wndPreview.Invalidate();
wndPreview.RedrawWindow();
RedrawWindow();
}
CMediaPreviewDlg::~CMediaPreviewDlg()
{
}
void CMediaPreviewDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_PREVIEW, wndPreview);
}
BEGIN_MESSAGE_MAP(CMediaPreviewDlg, CDialog)
ON_WM_SIZE()
ON_WM_DESTROY()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
END_MESSAGE_MAP()
// CMediaPreviewDlg message handlers
BOOL CMediaPreviewDlg::OnInitDialog()
{
CDialog::OnInitDialog();
wndPreview.setDrawable(&testDrawable);
CRect rct;
LONG lSize = sizeof(rct);
if (LoadRegistryInfo("Radiant::EditPreviewWindow", &rct, &lSize)) {
SetWindowPos(NULL, rct.left, rct.top, rct.Width(), rct.Height(), SWP_SHOWWINDOW);
}
GetClientRect(rct);
int h = (mode == GUIS) ? (rct.Width() - 8) / 1.333333f : rct.Height() - 8;
wndPreview.SetWindowPos(NULL, 4, 4, rct.Width() - 8, h, SWP_SHOWWINDOW);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CMediaPreviewDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
if (wndPreview.GetSafeHwnd() == NULL) {
return;
}
CRect rect;
GetClientRect(rect);
//int h = (mode == GUIS) ? (rect.Width() - 8) / 1.333333f : rect.Height() - 8;
int h = rect.Height() - 8;
wndPreview.SetWindowPos(NULL, 4, 4, rect.Width() - 8, h, SWP_SHOWWINDOW);
}
void CMediaPreviewDlg::OnDestroy()
{
if (GetSafeHwnd()) {
CRect rct;
GetWindowRect(rct);
SaveRegistryInfo("Radiant::EditPreviewWindow", &rct, sizeof(rct));
}
CDialog::OnDestroy();
}
void CMediaPreviewDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
if (mode == GUIS) {
idUserInterface *gui = uiManager->FindGui( media );
if (gui) {
sysEvent_t ev;
memset( &ev, 0, sizeof( ev ) );
ev.evType = SE_KEY;
ev.evValue = K_MOUSE1;
ev.evValue2 = 1;
gui->HandleEvent(&ev,0);
}
}
CDialog::OnLButtonDown(nFlags, point);
}
void CMediaPreviewDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
if (mode == GUIS) {
idUserInterface *gui = uiManager->FindGui( media );
if (gui) {
sysEvent_t ev;
memset( &ev, 0, sizeof( ev ) );
ev.evType = SE_KEY;
ev.evValue = K_MOUSE1;
ev.evValue2 = 0;
gui->HandleEvent(&ev,0);
}
}
CDialog::OnLButtonUp(nFlags, point);
}
void CMediaPreviewDlg::OnMouseMove(UINT nFlags, CPoint point)
{
if (mode == GUIS) {
idUserInterface *gui = uiManager->FindGui( media );
if (gui) {
CRect rct;
wndPreview.GetClientRect(rct);
sysEvent_t ev;
memset( &ev, 0, sizeof( ev ) );
ev.evType = SE_MOUSE;
ev.evValue = (point.x / rct.Width()) * 640.0f;
ev.evValue2 = (point.y / rct.Height()) * 480.0f;
gui->HandleEvent(&ev, 0);
}
}
CDialog::OnMouseMove(nFlags, point);
}

View File

@@ -0,0 +1,69 @@
/*
===========================================================================
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.
===========================================================================
*/
#pragma once
// CMediaPreviewDlg dialog
class CMediaPreviewDlg : public CDialog
{
DECLARE_DYNAMIC(CMediaPreviewDlg)
public:
enum { MATERIALS, GUIS };
CMediaPreviewDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CMediaPreviewDlg();
void SetMode(int _mode) {
mode = _mode;
}
void SetMedia(const char *_media);
void Refresh();
// Dialog Data
enum { IDD = IDD_DIALOG_EDITPREVIEW };
protected:
idGLDrawable testDrawable;
idGLDrawableMaterial drawMaterial;
idGLWidget wndPreview;
int mode;
idStr media;
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
virtual BOOL OnInitDialog();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnDestroy();
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
};

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 "qe3.h"
#include "Radiant.h"
#include "NewProjDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CNewProjDlg dialog
CNewProjDlg::CNewProjDlg(CWnd* pParent /*=NULL*/)
: CDialog(CNewProjDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CNewProjDlg)
m_strName = _T("");
//}}AFX_DATA_INIT
}
void CNewProjDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CNewProjDlg)
DDX_Text(pDX, IDC_EDIT_NAME, m_strName);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CNewProjDlg, CDialog)
//{{AFX_MSG_MAP(CNewProjDlg)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNewProjDlg message handlers

View File

@@ -0,0 +1,73 @@
/*
===========================================================================
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.
===========================================================================
*/
#if !defined(AFX_NEWPROJDLG_H__1E2527A2_8447_11D1_B548_00AA00A410FC__INCLUDED_)
#define AFX_NEWPROJDLG_H__1E2527A2_8447_11D1_B548_00AA00A410FC__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// NewProjDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CNewProjDlg dialog
class CNewProjDlg : public CDialog
{
// Construction
public:
CNewProjDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CNewProjDlg)
enum { IDD = IDD_DLG_NEWPROJECT };
CString m_strName;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CNewProjDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CNewProjDlg)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_NEWPROJDLG_H__1E2527A2_8447_11D1_B548_00AA00A410FC__INCLUDED_)

View File

@@ -0,0 +1,922 @@
/*
===========================================================================
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 "qe3.h"
#include "Radiant.h"
#include "NewTexWnd.h"
#include "io.h"
#include "../../renderer/tr_local.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/*
=======================================================================================================================
=======================================================================================================================
*/
bool Sys_KeyDown( int key ) {
return ( ( ::GetAsyncKeyState( key ) & 0x8000 ) != 0 );
}
// CNewTexWnd
IMPLEMENT_DYNCREATE(CNewTexWnd, CWnd);
/*
=======================================================================================================================
=======================================================================================================================
*/
CNewTexWnd::CNewTexWnd() {
m_bNeedRange = true;
hglrcTexture = NULL;
hdcTexture = NULL;
cursor.x = cursor.y = 0;
origin.x = origin.y = 0;
}
/*
=======================================================================================================================
=======================================================================================================================
*/
CNewTexWnd::~CNewTexWnd() {
}
BEGIN_MESSAGE_MAP(CNewTexWnd, CWnd)
//{{AFX_MSG_MAP(CNewTexWnd)
ON_WM_CREATE()
ON_WM_SIZE()
ON_WM_PARENTNOTIFY()
ON_WM_KEYDOWN()
ON_WM_KEYUP()
ON_WM_PAINT()
ON_WM_VSCROLL()
ON_WM_LBUTTONDOWN()
ON_WM_MBUTTONDOWN()
ON_WM_RBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MBUTTONUP()
ON_WM_RBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_MOUSEWHEEL()
//}}AFX_MSG_MAP
ON_WM_SETFOCUS()
END_MESSAGE_MAP()
//
// =======================================================================================================================
// CNewTexWnd message handlers
// =======================================================================================================================
//
BOOL CNewTexWnd::PreCreateWindow(CREATESTRUCT &cs) {
WNDCLASS wc;
HINSTANCE hInstance = AfxGetInstanceHandle();
if (::GetClassInfo(hInstance, TEXTURE_WINDOW_CLASS, &wc) == FALSE) {
// Register a new class
memset(&wc, 0, sizeof(wc));
wc.style = CS_NOCLOSE | CS_PARENTDC; // | CS_OWNDC;
wc.lpszClassName = TEXTURE_WINDOW_CLASS;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.lpfnWndProc = ::DefWindowProc;
if (AfxRegisterClass(&wc) == FALSE) {
Error("CNewTexWnd RegisterClass: failed");
}
}
cs.lpszClass = TEXTURE_WINDOW_CLASS;
cs.lpszName = "TEX";
if (cs.style != QE3_CHILDSTYLE && cs.style != QE3_STYLE) {
cs.style = QE3_SPLITTER_STYLE;
}
return CWnd::PreCreateWindow(cs);
}
/*
=======================================================================================================================
=======================================================================================================================
*/
int CNewTexWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) {
if (CWnd::OnCreate(lpCreateStruct) == -1) {
return -1;
}
ShowScrollBar(SB_VERT, g_PrefsDlg.m_bTextureScrollbar);
m_bNeedRange = true;
hdcTexture = GetDC();
QEW_SetupPixelFormat(hdcTexture->m_hDC, false);
EnableToolTips(TRUE);
EnableTrackingToolTips(TRUE);
return 0;
}
/*
=======================================================================================================================
=======================================================================================================================
*/
void CNewTexWnd::OnSize(UINT nType, int cx, int cy) {
CWnd::OnSize(nType, cx, cy);
GetClientRect(rectClient);
m_bNeedRange = true;
}
/*
=======================================================================================================================
=======================================================================================================================
*/
void CNewTexWnd::OnParentNotify(UINT message, LPARAM lParam) {
CWnd::OnParentNotify(message, lParam);
}
/*
=======================================================================================================================
=======================================================================================================================
*/
void CNewTexWnd::UpdatePrefs() {
ShowScrollBar(SB_VERT, g_PrefsDlg.m_bTextureScrollbar);
m_bNeedRange = true;
Invalidate();
UpdateWindow();
}
/*
=======================================================================================================================
=======================================================================================================================
*/
void CNewTexWnd::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) {
g_pParentWnd->HandleKey(nChar, nRepCnt, nFlags);
}
/*
=======================================================================================================================
=======================================================================================================================
*/
void CNewTexWnd::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) {
g_pParentWnd->HandleKey(nChar, nRepCnt, nFlags, false);
}
/*
=======================================================================================================================
=======================================================================================================================
*/
const idMaterial *CNewTexWnd::NextPos() {
const idMaterial *mat = NULL;
while (1) {
if (currentIndex >= declManager->GetNumDecls( DECL_MATERIAL )) {
return NULL;
}
mat = declManager->MaterialByIndex(currentIndex, false);
currentIndex++;
//if (mat->getName()[0] == '(') { // fake color texture
// continue;
//}
if ( !mat->IsValid() ) {
continue;
}
if (!mat->TestMaterialFlag(MF_EDITOR_VISIBLE)) {
continue;
}
break;
}
// ensure it is uploaded
declManager->FindMaterial(mat->GetName());
int width = mat->GetEditorImage()->uploadWidth * ((float)g_PrefsDlg.m_nTextureScale / 100);
int height = mat->GetEditorImage()->uploadHeight * ((float)g_PrefsDlg.m_nTextureScale / 100);
if (current.x + width > rectClient.Width() - 8 && currentRow) {
// go to the next row unless the texture is the first on the row
current.x = 8;
current.y -= currentRow + FONT_HEIGHT + 4;
currentRow = 0;
}
draw = current;
// Is our texture larger than the row? If so, grow the row height to match it
if (currentRow < height) {
currentRow = height;
}
// never go less than 64, or the names get all crunched up
current.x += width < 64 ? 64 : width;
current.x += 8;
return mat;
}
/*
=======================================================================================================================
=======================================================================================================================
*/
void CNewTexWnd::OnPaint() {
CPaintDC dc(this); // device context for painting
int nOld = g_qeglobals.d_texturewin.m_nTotalHeight;
//hdcTexture = GetDC();
if (!qwglMakeCurrent(dc.GetSafeHdc(), win32.hGLRC)) {
common->Printf("ERROR: wglMakeCurrent failed..\n ");
}
else {
const char *name;
qglClearColor
(
g_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][0],
g_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][1],
g_qeglobals.d_savedinfo.colors[COLOR_TEXTUREBACK][2],
0
);
qglViewport(0, 0, rectClient.Width(), rectClient.Height());
qglScissor(0, 0, rectClient.Width(), rectClient.Height());
qglMatrixMode(GL_PROJECTION);
qglLoadIdentity();
qglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
qglDisable(GL_DEPTH_TEST);
qglDisable(GL_BLEND);
qglOrtho(0, rectClient.Width(), origin.y - rectClient.Height(), origin.y, -100, 100);
qglPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
// init stuff
current.x = 8;
current.y = -8;
currentRow = 0;
currentIndex = 0;
while (1) {
const idMaterial *mat = NextPos();
if (mat == NULL) {
break;
}
int width = mat->GetEditorImage()->uploadWidth * ((float)g_PrefsDlg.m_nTextureScale / 100);
int height = mat->GetEditorImage()->uploadHeight * ((float)g_PrefsDlg.m_nTextureScale / 100);
// Is this texture visible?
if ((draw.y - height - FONT_HEIGHT < origin.y) && (draw.y > origin.y - rectClient.Height())) {
// if in use, draw a background
qglLineWidth(1);
qglColor3f(1, 1, 1);
globalImages->BindNull();
qglBegin(GL_LINE_LOOP);
qglVertex2f(draw.x - 1, draw.y + 1 - FONT_HEIGHT);
qglVertex2f(draw.x - 1, draw.y - height - 1 - FONT_HEIGHT);
qglVertex2f(draw.x + 1 + width, draw.y - height - 1 - FONT_HEIGHT);
qglVertex2f(draw.x + 1 + width, draw.y + 1 - FONT_HEIGHT);
qglEnd();
// Draw the texture
float fScale = (g_PrefsDlg.m_bHiColorTextures == TRUE) ? ((float)g_PrefsDlg.m_nTextureScale / 100) : 1.0;
mat->GetEditorImage()->Bind();
QE_CheckOpenGLForErrors();
qglColor3f(1, 1, 1);
qglBegin(GL_QUADS);
qglTexCoord2f(0, 0);
qglVertex2f(draw.x, draw.y - FONT_HEIGHT);
qglTexCoord2f(1, 0);
qglVertex2f(draw.x + width, draw.y - FONT_HEIGHT);
qglTexCoord2f(1, 1);
qglVertex2f(draw.x + width, draw.y - FONT_HEIGHT - height);
qglTexCoord2f(0, 1);
qglVertex2f(draw.x, draw.y - FONT_HEIGHT - height);
qglEnd();
// draw the selection border
if ( !idStr::Icmp(g_qeglobals.d_texturewin.texdef.name, mat->GetName()) ) {
qglLineWidth(3);
qglColor3f(1, 0, 0);
globalImages->BindNull();
qglBegin(GL_LINE_LOOP);
qglVertex2f(draw.x - 4, draw.y - FONT_HEIGHT + 4);
qglVertex2f(draw.x - 4, draw.y - FONT_HEIGHT - height - 4);
qglVertex2f(draw.x + 4 + width, draw.y - FONT_HEIGHT - height - 4);
qglVertex2f(draw.x + 4 + width, draw.y - FONT_HEIGHT + 4);
qglEnd();
qglLineWidth(1);
}
// draw the texture name
globalImages->BindNull();
qglColor3f(1, 1, 1);
qglRasterPos2f(draw.x, draw.y - FONT_HEIGHT + 2);
// don't draw the directory name
for (name = mat->GetName(); *name && *name != '/' && *name != '\\'; name++) {
;
}
if (!*name) {
name = mat->GetName();
}
else {
name++;
}
qglCallLists(strlen(name), GL_UNSIGNED_BYTE, name);
//qglCallLists(va("%s -- %d, %d" strlen(name), GL_UNSIGNED_BYTE, name);
}
}
g_qeglobals.d_texturewin.m_nTotalHeight = abs(draw.y) + 100;
// reset the current texture
globalImages->BindNull();
qglFinish();
qwglSwapBuffers(dc.GetSafeHdc());
TRACE("Texture Paint\n");
}
if (g_PrefsDlg.m_bTextureScrollbar && (m_bNeedRange || g_qeglobals.d_texturewin.m_nTotalHeight != nOld)) {
m_bNeedRange = false;
SetScrollRange(SB_VERT, 0, g_qeglobals.d_texturewin.m_nTotalHeight, TRUE);
}
//ReleaseDC(hdcTexture);
}
/*
=======================================================================================================================
=======================================================================================================================
*/
void CNewTexWnd::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar) {
CWnd::OnVScroll(nSBCode, nPos, pScrollBar);
int n = GetScrollPos(SB_VERT);
switch (nSBCode)
{
case SB_LINEUP: {
n = (n - 15 > 0) ? n - 15 : 0;
break;
}
case SB_LINEDOWN: {
n = (n + 15 < g_qeglobals.d_texturewin.m_nTotalHeight) ? n + 15 : n;
break;
}
case SB_PAGEUP: {
n = (n - g_qeglobals.d_texturewin.height > 0) ? n - g_qeglobals.d_texturewin.height : 0;
break;
}
case SB_PAGEDOWN: {
n = (n + g_qeglobals.d_texturewin.height < g_qeglobals.d_texturewin.m_nTotalHeight) ? n + g_qeglobals.d_texturewin.height : n;
break;
}
case SB_THUMBPOSITION: {
n = nPos;
break;
}
case SB_THUMBTRACK: {
n = nPos;
break;
}
}
SetScrollPos(SB_VERT, n);
origin.y = -n;
Invalidate();
UpdateWindow();
// Sys_UpdateWindows(W_TEXTURE);
}
BOOL CNewTexWnd::DestroyWindow() {
ReleaseDC(hdcTexture);
return CWnd::DestroyWindow();
}
/*
=======================================================================================================================
=======================================================================================================================
*/
BOOL CNewTexWnd::Create
(
LPCTSTR lpszClassName,
LPCTSTR lpszWindowName,
DWORD dwStyle,
const RECT &rect,
CWnd *pParentWnd,
UINT nID,
CCreateContext *pContext
) {
BOOL ret = CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
if (ret) {
hdcTexture = GetDC();
QEW_SetupPixelFormat(hdcTexture->m_hDC, false);
}
return ret;
}
const idMaterial *CNewTexWnd::getMaterialAtPoint(CPoint point) {
// init stuff
int my = rectClient.Height() - 1 - point.y;
my += origin.y - rectClient.Height();
current.x = 8;
current.y = -8;
currentRow = 0;
currentIndex = 0;
while (1) {
const idMaterial *mat = NextPos();
if (mat == NULL) {
return NULL;
}
int width = mat->GetEditorImage()->uploadWidth * ((float)g_PrefsDlg.m_nTextureScale / 100);
int height = mat->GetEditorImage()->uploadHeight * ((float)g_PrefsDlg.m_nTextureScale / 100);
//if (point.x > draw.x && point.x - draw.x < width && my < draw.y && my + draw.y < height + FONT_HEIGHT) {
if (point.x > draw.x && point.x - draw.x < width && my < draw.y && draw.y - my < height + FONT_HEIGHT) {
return mat;
}
}
}
/*
=======================================================================================================================
=======================================================================================================================
*/
void CNewTexWnd::OnLButtonDown(UINT nFlags, CPoint point) {
cursor = point;
SetFocus();
bool fitScale = Sys_KeyDown(VK_CONTROL);
bool edit = Sys_KeyDown(VK_SHIFT) && !fitScale;
const idMaterial *mat = getMaterialAtPoint(point);
if (mat) {
Select_SetDefaultTexture(mat, fitScale, true);
} else {
Sys_Status("Did not select a texture\n", 0);
}
//
UpdateSurfaceDialog();
UpdatePatchInspector();
}
/*
=======================================================================================================================
=======================================================================================================================
*/
void CNewTexWnd::OnMButtonDown(UINT nFlags, CPoint point) {
CWnd::OnMButtonDown(nFlags, point);
}
/*
=======================================================================================================================
=======================================================================================================================
*/
void CNewTexWnd::OnRButtonDown(UINT nFlags, CPoint point) {
cursor = point;
SetFocus();
}
/*
===============================t========================================================================================
=======================================================================================================================
*/
void CNewTexWnd::OnLButtonUp(UINT nFlags, CPoint point) {
CWnd::OnLButtonUp(nFlags, point);
g_pParentWnd->SetFocus();
}
/*
=======================================================================================================================
=======================================================================================================================
*/
void CNewTexWnd::OnMButtonUp(UINT nFlags, CPoint point) {
CWnd::OnMButtonUp(nFlags, point);
}
/*
=======================================================================================================================
=======================================================================================================================
*/
void CNewTexWnd::OnRButtonUp(UINT nFlags, CPoint point) {
CWnd::OnRButtonUp(nFlags, point);
}
extern float fDiff(float f1, float f2);
/*
=======================================================================================================================
=======================================================================================================================
*/
void CNewTexWnd::OnMouseMove(UINT nFlags, CPoint point) {
int scale = 1;
if (Sys_KeyDown(VK_SHIFT)) {
scale = 4;
}
// rbutton = drag texture origin
if (Sys_KeyDown(VK_RBUTTON)) {
if (point.y != cursor.y) {
if (Sys_KeyDown(VK_MENU)) {
long *px = &point.x;
long *px2 = &cursor.x;
if (fDiff(point.y, cursor.y) > fDiff(point.x, cursor.x)) {
px = &point.y;
px2 = &cursor.y;
}
if (*px > *px2) {
// zoom in
g_PrefsDlg.m_nTextureScale += 4;
if (g_PrefsDlg.m_nTextureScale > 500) {
g_PrefsDlg.m_nTextureScale = 500;
}
}
else if (*px < *px2) {
// zoom out
g_PrefsDlg.m_nTextureScale -= 4;
if (g_PrefsDlg.m_nTextureScale < 1) {
g_PrefsDlg.m_nTextureScale = 1;
}
}
*px2 = *px;
CPoint screen = cursor;
ClientToScreen(&screen);
SetCursorPos(screen.x, screen.y);
//Sys_SetCursorPos(cursor.x, cursor.y);
InvalidateRect(NULL, false);
UpdateWindow();
}
else if (point.y != cursor.y || point.x != cursor.x) {
origin.y += (point.y - cursor.y) * scale;
if (origin.y > 0) {
origin.y = 0;
}
//Sys_SetCursorPos(cursor.x, cursor.y);
CPoint screen = cursor;
ClientToScreen(&screen);
SetCursorPos(screen.x, screen.y);
if (g_PrefsDlg.m_bTextureScrollbar) {
SetScrollPos(SB_VERT, abs(origin.y));
}
InvalidateRect(NULL, false);
UpdateWindow();
}
}
return;
}
}
/*
=======================================================================================================================
=======================================================================================================================
*/
void CNewTexWnd::LoadMaterials() {
}
void Texture_SetTexture(texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale, bool bSetSelection) {
if (texdef->name[0] == '(') {
Sys_Status("Can't select an entity texture\n", 0);
return;
}
g_qeglobals.d_texturewin.texdef = *texdef;
//
// store the texture coordinates for new brush primitive mode be sure that all the
// callers are using the default 2x2 texture
//
if (g_qeglobals.m_bBrushPrimitMode) {
g_qeglobals.d_texturewin.brushprimit_texdef = *brushprimit_texdef;
}
g_dlgFind.updateTextures(texdef->name);
if (!g_dlgFind.isOpen() && bSetSelection) {
Select_SetTexture(texdef, brushprimit_texdef, bFitScale);
}
g_Inspectors->texWnd.EnsureTextureIsVisible(texdef->name);
if ( g_Inspectors->mediaDlg.IsWindowVisible() ) {
g_Inspectors->mediaDlg.SelectCurrentItem(true, g_qeglobals.d_texturewin.texdef.name, CDialogTextures::MATERIALS);
}
g_qeglobals.d_texturewin.texdef = *texdef;
// store the texture coordinates for new brush primitive mode be sure that all the
// callers are using the default 2x2 texture
//
if (g_qeglobals.m_bBrushPrimitMode) {
g_qeglobals.d_texturewin.brushprimit_texdef = *brushprimit_texdef;
}
Sys_UpdateWindows(W_TEXTURE);
}
const idMaterial *Texture_LoadLight(const char *name) {
return declManager->FindMaterial(name);
}
void Texture_ClearInuse(void) {
}
void Texture_ShowAll(void) {
int count = declManager->GetNumDecls( DECL_MATERIAL );
for (int i = 0; i < count; i++) {
const idMaterial *mat = declManager->MaterialByIndex(i, false);
if ( mat ) {
mat->SetMaterialFlag(MF_EDITOR_VISIBLE);
}
}
g_Inspectors->SetWindowText("Textures (all)");
Sys_UpdateWindows(W_TEXTURE);
}
void Texture_HideAll() {
int count = declManager->GetNumDecls( DECL_MATERIAL );
for (int i = 0; i < count; i++) {
const idMaterial *mat = declManager->MaterialByIndex(i, false);
if ( mat ) {
mat->ClearMaterialFlag(MF_EDITOR_VISIBLE);
}
}
g_Inspectors->SetWindowText("Textures (all)");
Sys_UpdateWindows(W_TEXTURE);
}
const idMaterial *Texture_ForName(const char *name) {
const idMaterial *mat = declManager->FindMaterial(name);
if ( !mat ) {
mat = declManager->FindMaterial("_default");
} else {
mat->SetMaterialFlag(MF_EDITOR_VISIBLE);
}
return mat;
}
void Texture_ShowInuse(void) {
Texture_HideAll();
brush_t *b;
for (b = active_brushes.next; b != NULL && b != &active_brushes; b = b->next) {
if (b->pPatch) {
Texture_ForName(b->pPatch->d_texture->GetName());
} else {
for (face_t *f = b->brush_faces; f; f = f->next) {
Texture_ForName(f->texdef.name);
}
}
}
for (b = selected_brushes.next; b != NULL && b != &selected_brushes; b = b->next) {
if (b->pPatch) {
Texture_ForName(b->pPatch->d_texture->GetName());
} else {
for (face_t *f = b->brush_faces; f; f = f->next) {
Texture_ForName(f->texdef.name);
}
}
}
Sys_UpdateWindows(W_TEXTURE);
g_Inspectors->SetWindowText("Textures (in use)");
}
void Texture_Cleanup(CStringList *pList) {
}
int texture_mode = GL_LINEAR_MIPMAP_LINEAR;
bool texture_showinuse = true;
/*
=======================================================================================================================
Texture_SetMode
=======================================================================================================================
*/
void Texture_SetMode(int iMenu) {
int iMode;
HMENU hMenu;
bool texturing = true;
hMenu = GetMenu(g_pParentWnd->GetSafeHwnd());
switch (iMenu)
{
case ID_VIEW_NEAREST:
iMode = GL_NEAREST;
break;
case ID_VIEW_NEARESTMIPMAP:
iMode = GL_NEAREST_MIPMAP_NEAREST;
break;
case ID_VIEW_LINEAR:
iMode = GL_NEAREST_MIPMAP_LINEAR;
break;
case ID_VIEW_BILINEAR:
iMode = GL_LINEAR;
break;
case ID_VIEW_BILINEARMIPMAP:
iMode = GL_LINEAR_MIPMAP_NEAREST;
break;
case ID_VIEW_TRILINEAR:
iMode = GL_LINEAR_MIPMAP_LINEAR;
break;
case ID_TEXTURES_WIREFRAME:
iMode = 0;
texturing = false;
break;
case ID_TEXTURES_FLATSHADE:
default:
iMode = 0;
texturing = false;
break;
}
CheckMenuItem(hMenu, ID_VIEW_NEAREST, MF_BYCOMMAND | MF_UNCHECKED);
CheckMenuItem(hMenu, ID_VIEW_NEARESTMIPMAP, MF_BYCOMMAND | MF_UNCHECKED);
CheckMenuItem(hMenu, ID_VIEW_LINEAR, MF_BYCOMMAND | MF_UNCHECKED);
CheckMenuItem(hMenu, ID_VIEW_BILINEARMIPMAP, MF_BYCOMMAND | MF_UNCHECKED);
CheckMenuItem(hMenu, ID_VIEW_BILINEAR, MF_BYCOMMAND | MF_UNCHECKED);
CheckMenuItem(hMenu, ID_VIEW_TRILINEAR, MF_BYCOMMAND | MF_UNCHECKED);
CheckMenuItem(hMenu, ID_TEXTURES_WIREFRAME, MF_BYCOMMAND | MF_UNCHECKED);
CheckMenuItem(hMenu, ID_TEXTURES_FLATSHADE, MF_BYCOMMAND | MF_UNCHECKED);
CheckMenuItem(hMenu, iMenu, MF_BYCOMMAND | MF_CHECKED);
g_qeglobals.d_savedinfo.iTexMenu = iMenu;
texture_mode = iMode;
if (!texturing && iMenu == ID_TEXTURES_WIREFRAME) {
g_pParentWnd->GetCamera()->Camera().draw_mode = cd_wire;
Map_BuildBrushData();
Sys_UpdateWindows(W_ALL);
return;
}
else if (!texturing && iMenu == ID_TEXTURES_FLATSHADE) {
g_pParentWnd->GetCamera()->Camera().draw_mode = cd_solid;
Map_BuildBrushData();
Sys_UpdateWindows(W_ALL);
return;
}
if (g_pParentWnd->GetCamera()->Camera().draw_mode != cd_texture) {
g_pParentWnd->GetCamera()->Camera().draw_mode = cd_texture;
Map_BuildBrushData();
}
Sys_UpdateWindows(W_ALL);
}
void CNewTexWnd::EnsureTextureIsVisible(const char *name) {
// scroll origin so the texture is completely on screen
// init stuff
current.x = 8;
current.y = -8;
currentRow = 0;
currentIndex = 0;
while (1) {
const idMaterial *mat = NextPos();
if (mat == NULL) {
break;
}
int width = mat->GetEditorImage()->uploadWidth * ((float)g_PrefsDlg.m_nTextureScale / 100);
int height = mat->GetEditorImage()->uploadHeight * ((float)g_PrefsDlg.m_nTextureScale / 100);
if ( !idStr::Icmp(name, mat->GetName()) ) {
if (current.y > origin.y) {
origin.y = current.y;
Sys_UpdateWindows(W_TEXTURE);
return;
}
if (current.y - height - 2 * FONT_HEIGHT < origin.y - rectClient.Height()) {
origin.y = current.y - height - 2 * FONT_HEIGHT + rectClient.Height();
Sys_UpdateWindows(W_TEXTURE);
return;
}
return;
}
}
}
BOOL CNewTexWnd::OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult ) {
static char tip[1024];
CPoint point;
GetCursorPos(&point);
const idMaterial *mat = getMaterialAtPoint(point);
if (mat) {
TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
strcpy(tip, mat->GetDescription());
pTTT->lpszText = tip;
pTTT->hinst = NULL;
return(TRUE);
}
return(FALSE);
}
int CNewTexWnd::OnToolHitTest(CPoint point, TOOLINFO * pTI)
{
const idMaterial *mat = getMaterialAtPoint(point);
if (mat) {
return 0;
}
return -1;
}
BOOL CNewTexWnd::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
OnVScroll((zDelta >= 0) ? SB_LINEUP : SB_LINEDOWN, 0, NULL);
OnVScroll((zDelta >= 0) ? SB_LINEUP : SB_LINEDOWN, 0, NULL);
OnVScroll((zDelta >= 0) ? SB_LINEUP : SB_LINEDOWN, 0, NULL);
OnVScroll((zDelta >= 0) ? SB_LINEUP : SB_LINEDOWN, 0, NULL);
OnVScroll((zDelta >= 0) ? SB_LINEUP : SB_LINEDOWN, 0, NULL);
OnVScroll((zDelta >= 0) ? SB_LINEUP : SB_LINEDOWN, 0, NULL);
return TRUE;
}
BOOL CNewTexWnd::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN) {
if (pMsg->wParam == VK_ESCAPE) {
g_pParentWnd->GetCamera()->SetFocus();
Select_Deselect();
return TRUE;
}
if (pMsg->wParam == VK_RIGHT || pMsg->wParam == VK_LEFT || pMsg->wParam == VK_UP || pMsg->wParam == VK_DOWN) {
g_pParentWnd->PostMessage(WM_KEYDOWN, pMsg->wParam);
return TRUE;
}
}
return CWnd::PreTranslateMessage(pMsg);
}
void CNewTexWnd::OnSetFocus(CWnd* pOldWnd)
{
CWnd::OnSetFocus(pOldWnd);
Invalidate();
RedrawWindow();
}

View File

@@ -0,0 +1,126 @@
/*
===========================================================================
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.
===========================================================================
*/
#if !defined(NEWTEXWND_H)
#define NEWTEXWND_H
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// TexWnd.h : header file
//
#include "../../renderer/tr_local.h"
//#include "texwnd.h"
/////////////////////////////////////////////////////////////////////////////
// CTexWnd window
class CNewTexWnd : public CWnd
{
DECLARE_DYNCREATE(CNewTexWnd);
// Construction
public:
CNewTexWnd();
void UpdateFilter(const char* pFilter);
void UpdatePrefs();
void FocusEdit();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CNewTexWnd)
public:
virtual BOOL DestroyWindow();
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
protected:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
public:
void EnsureTextureIsVisible(const char *name);
void LoadMaterials();
virtual ~CNewTexWnd();
BOOL OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult );
int CNewTexWnd::OnToolHitTest(CPoint point, TOOLINFO * pTI);
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
//CTexEdit m_wndFilter;
//CButton m_wndShaders;
bool m_bNeedRange;
HGLRC hglrcTexture;
CDC *hdcTexture;
CPoint cursor;
CPoint origin;
CPoint draw;
CPoint drawRow;
CPoint current;
CRect rectClient;
int currentRow;
int currentIndex;
idList<const idMaterial*> materialList;
// Generated message map functions
protected:
const idMaterial* NextPos();
const idMaterial *getMaterialAtPoint(CPoint point);
void InitPos();
//{{AFX_MSG(CNewTexWnd)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnParentNotify(UINT message, LPARAM lParam);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnPaint();
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
//}}AFX_MSG
afx_msg void OnShaderClick();
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnSetFocus(CWnd* pOldWnd);
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(NEWTEXWND_H)

157
neo/tools/radiant/PARSE.CPP Normal file
View File

@@ -0,0 +1,157 @@
/*
===========================================================================
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 "qe3.h"
char token[MAXTOKEN];
bool unget;
const char *script_p;
int scriptline;
void StartTokenParsing (const char *data)
{
scriptline = 1;
script_p = data;
unget = false;
}
bool WINAPI GetToken (bool crossline)
{
char *token_p;
if (unget) // is a token allready waiting?
{
unget = false;
return true;
}
//
// skip space
//
skipspace:
while (*script_p <= 32)
{
if (!*script_p)
{
if (!crossline)
common->Printf("Warning: Line %i is incomplete [01]\n",scriptline);
return false;
}
if (*script_p++ == '\n')
{
if (!crossline)
common->Printf("Warning: Line %i is incomplete [02]\n",scriptline);
scriptline++;
}
}
if (script_p[0] == '/' && script_p[1] == '/') // comment field
{
if (!crossline)
common->Printf("Warning: Line %i is incomplete [03]\n",scriptline);
while (*script_p++ != '\n')
if (!*script_p)
{
if (!crossline)
common->Printf("Warning: Line %i is incomplete [04]\n",scriptline);
return false;
}
goto skipspace;
}
//
// copy token
//
token_p = token;
if (*script_p == '"')
{
script_p++;
//if (*script_p == '"') // handle double quotes i suspect they are put in by other editors cccasionally
// script_p++;
while ( *script_p != '"' )
{
if (!*script_p)
Error ("EOF inside quoted token");
*token_p++ = *script_p++;
if (token_p == &token[MAXTOKEN])
Error ("Token too large on line %i",scriptline);
}
script_p++;
//if (*script_p == '"') // handle double quotes i suspect they are put in by other editors cccasionally
// script_p++;
}
else while ( *script_p > 32 )
{
*token_p++ = *script_p++;
if (token_p == &token[MAXTOKEN])
Error ("Token too large on line %i",scriptline);
}
*token_p = 0;
return true;
}
void WINAPI UngetToken (void)
{
unget = true;
}
/*
==============
TokenAvailable
Returns true if there is another token on the line
==============
*/
bool TokenAvailable (void)
{
const char *search_p;
search_p = script_p;
while ( *search_p <= 32)
{
if (*search_p == '\n')
return false;
if (*search_p == 0)
return false;
search_p++;
}
if (*search_p == ';')
return false;
return true;
}

39
neo/tools/radiant/PARSE.H Normal file
View File

@@ -0,0 +1,39 @@
/*
===========================================================================
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.
===========================================================================
*/
#define MAXTOKEN 1024
extern char token[MAXTOKEN];
extern int scriptline;
// NOTE: added WINAPI call syntax to export these for plugins in _QERScripLibTable
void StartTokenParsing (const char *data);
bool WINAPI GetToken (bool crossline);
void WINAPI UngetToken (void);
bool TokenAvailable (void);

4461
neo/tools/radiant/PMESH.CPP Normal file

File diff suppressed because it is too large Load Diff

124
neo/tools/radiant/PMESH.H Normal file
View File

@@ -0,0 +1,124 @@
/*
===========================================================================
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.
===========================================================================
*/
// patch stuff
patchMesh_t* MakeNewPatch(int width, int height);
brush_t* AddBrushForPatch(patchMesh_t *pm, bool bLinkToWorld = true);
brush_t* Patch_GenericMesh(int nWidth, int nHeight, int nOrientation = 2, bool bDeleteSource = true, bool bOverride = false, patchMesh_t *parent = NULL);
void Patch_ReadFile (char *name);
void Patch_WriteFile (char *name);
void Patch_BuildPoints (brush_t *b);
void Patch_Move(patchMesh_t *p, const idVec3 vMove, bool bRebuild = false);
//++timo had to add a default value for bSnap (see Patch_ApplyMatrix call from Select_ApplyMatrix in select.cpp)
void Patch_ApplyMatrix(patchMesh_t *p, const idVec3 vOrigin, const idMat3 matrix, bool bSnap = false);
void Patch_EditPatch();
void Patch_Deselect();
void Patch_Deselect(patchMesh_t *p);
void Patch_Delete(patchMesh_t *p);
int Patch_MemorySize(patchMesh_t *p);
void Patch_Select(patchMesh_t *p);
void Patch_Scale(patchMesh_t *p, const idVec3 vOrigin, const idVec3 vAmt, bool bRebuilt = true);
void Patch_Cleanup();
void Patch_SetView(int n);
void Patch_SetTexture(patchMesh_t *p, texdef_t *tex_def);
void Patch_SetTextureName(patchMesh_t *p, const char *name);
void Patch_BrushToMesh(bool bCone = false, bool bBevel = false, bool bEndcap = false, bool bSquare = false, int nHeight = 3);
bool Patch_DragScale(patchMesh_t *p, idVec3 vAmt, idVec3 vMove);
void Patch_ReadBuffer(char* pBuff, bool bSelect = false);
void Patch_WriteFile (CMemFile* pMemFile);
void Patch_UpdateSelected(idVec3 vMove);
void Patch_AddRow(patchMesh_t *p);
brush_t* Patch_Parse(bool bOld);
void Patch_Write (patchMesh_t *p, FILE *f);
void Patch_Write (patchMesh_t *p, CMemFile *file);
void Patch_AdjustColumns(patchMesh_t *p, int nCols);
void Patch_AdjustRows(patchMesh_t *p, int nRows);
void Patch_AdjustSelected(bool bInsert, bool bColumn, bool bFlag);
patchMesh_t* Patch_Duplicate(patchMesh_t *pFrom);
void Patch_RotateTexture(patchMesh_t *p, float fAngle);
void Patch_ScaleTexture(patchMesh_t *p, float fx, float fy, bool absolute);
void Patch_ShiftTexture(patchMesh_t *p, float fx, float fy, bool autoAdjust);
void Patch_DrawCam(patchMesh_t *p, bool selected);
void Patch_DrawXY(patchMesh_t *p);
void Patch_InsertColumn(patchMesh_t *p, bool bAdd);
void Patch_InsertRow(patchMesh_t *p, bool bAdd);
void Patch_RemoveRow(patchMesh_t *p, bool bFirst);
void Patch_RemoveColumn(patchMesh_t *p, bool bFirst);
void Patch_ToggleInverted();
void Patch_Restore(patchMesh_t *p);
void Patch_Save(patchMesh_t *p);
void Patch_SetTextureInfo(texdef_t* pt);
void Patch_NaturalTexturing();
void Patch_ResetTexturing(float fx, float fy);
void Patch_FitTexture(patchMesh_t *p, float fx, float fy);
void Patch_FitTexturing();
void Patch_BendToggle();
void Patch_StartInsDel();
void Patch_BendHandleTAB();
void Patch_BendHandleENTER();
void Patch_SelectBendNormal();
void Patch_SelectBendAxis();
patchMesh_t* SinglePatchSelected();
void Patch_CapCurrent(bool bInvertedBevel = false, bool bInvertedEndcap = false);
void Patch_DisperseRows();
void Patch_DisperseColumns();
void Patch_NaturalizeSelected(bool bCap = false, bool bCycleCap = false, bool alt = false);
void Patch_SubdivideSelected(bool subdivide, int horz, int vert);
void Patch_Naturalize(patchMesh_t *p, bool horz = true, bool vert = true, bool alt = false);
void Patch_SelectAreaPoints();
void Patch_InvertTexture(bool bY);
void Patch_InsDelToggle();
void Patch_InsDelHandleTAB();
void Patch_InsDelHandleENTER();
void Patch_SetOverlays();
void Patch_ClearOverlays();
void Patch_Thicken(int nAmount, bool bSeam);
void Patch_Transpose();
void Patch_Freeze();
void Patch_MakeDirty(patchMesh_t *p);
void Patch_UnFreeze(bool bAll);
const char* Patch_GetTextureName();
void Patch_FindReplaceTexture(brush_t *pb, const char *pFind, const char *pReplace, bool bForce);
void Patch_ReplaceQTexture(brush_t *pb, idMaterial *pOld, idMaterial *pNew);
void Select_SnapToGrid();
void Patch_FromTriangle(idVec5 vx, idVec5 vy, idVec5 vz);
const char* Patch_GetKeyValue(patchMesh_t *p, const char *pKey);
void Patch_SetEpair(patchMesh_t *p, const char *pKey, const char *pValue);
void Patch_FlipTexture(patchMesh_t *p, bool y);
bool WINAPI OnlyPatchesSelected();
bool WINAPI AnyPatchesSelected();
void WINAPI Patch_Rebuild(patchMesh_t *p);
extern bool g_bPatchShowBounds;
extern bool g_bPatchWireFrame;
extern bool g_bPatchWeld;
extern bool g_bPatchDrillDown;
extern bool g_bPatchInsertMode;
extern bool g_bPatchBendMode;
extern idVec3 g_vBendOrigin;

View File

@@ -0,0 +1,96 @@
/*
===========================================================================
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 "qe3.h"
#include "Radiant.h"
#include "PatchDensityDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPatchDensityDlg dialog
CPatchDensityDlg::CPatchDensityDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPatchDensityDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CPatchDensityDlg)
//}}AFX_DATA_INIT
}
void CPatchDensityDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPatchDensityDlg)
DDX_Control(pDX, IDC_COMBO_WIDTH, m_wndWidth);
DDX_Control(pDX, IDC_COMBO_HEIGHT, m_wndHeight);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPatchDensityDlg, CDialog)
//{{AFX_MSG_MAP(CPatchDensityDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPatchDensityDlg message handlers
int g_nXLat[] = {3,5,7,9,11,13,15};
void CPatchDensityDlg::OnOK()
{
int nWidth = m_wndWidth.GetCurSel();
int nHeight = m_wndHeight.GetCurSel();
if (nWidth >= 0 && nWidth <= 6 && nHeight >= 0 && nHeight <= 6)
{
Patch_GenericMesh(g_nXLat[nWidth], g_nXLat[nHeight], g_pParentWnd->ActiveXY()->GetViewType());
Sys_UpdateWindows(W_ALL);
}
CDialog::OnOK();
}
BOOL CPatchDensityDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_wndWidth.SetCurSel(0);
m_wndHeight.SetCurSel(0);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

View File

@@ -0,0 +1,75 @@
/*
===========================================================================
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.
===========================================================================
*/
#if !defined(AFX_PATCHDENSITYDLG_H__509162A1_1023_11D2_AFFB_00AA00A410FC__INCLUDED_)
#define AFX_PATCHDENSITYDLG_H__509162A1_1023_11D2_AFFB_00AA00A410FC__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// PatchDensityDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CPatchDensityDlg dialog
class CPatchDensityDlg : public CDialog
{
// Construction
public:
CPatchDensityDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CPatchDensityDlg)
enum { IDD = IDD_DIALOG_NEWPATCH };
CComboBox m_wndWidth;
CComboBox m_wndHeight;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPatchDensityDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CPatchDensityDlg)
virtual void OnOK();
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PATCHDENSITYDLG_H__509162A1_1023_11D2_AFFB_00AA00A410FC__INCLUDED_)

View File

@@ -0,0 +1,358 @@
/*
===========================================================================
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 "qe3.h"
#include "Radiant.h"
#include "PatchDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPatchDialog dialog
CPatchDialog g_PatchDialog;
CPatchDialog::CPatchDialog(CWnd* pParent /*=NULL*/)
: CDialog(CPatchDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CPatchDialog)
m_strName = _T("");
m_fS = 0.0f;
m_fT = 0.0f;
m_fX = 0.0f;
m_fY = 0.0f;
m_fZ = 0.0f;
m_fHScale = 0.05f;
m_fHShift = 0.05f;
m_fRotate = 45;
m_fVScale = 0.05f;
m_fVShift = 0.05f;
//}}AFX_DATA_INIT
m_Patch = NULL;
}
void CPatchDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPatchDialog)
DDX_Control(pDX, IDC_SPIN_VSHIFT, m_wndVShift);
DDX_Control(pDX, IDC_SPIN_VSCALE, m_wndVScale);
DDX_Control(pDX, IDC_SPIN_ROTATE, m_wndRotate);
DDX_Control(pDX, IDC_SPIN_HSHIFT, m_wndHShift);
DDX_Control(pDX, IDC_SPIN_HSCALE, m_wndHScale);
DDX_Control(pDX, IDC_COMBO_TYPE, m_wndType);
DDX_Control(pDX, IDC_COMBO_ROW, m_wndRows);
DDX_Control(pDX, IDC_COMBO_COL, m_wndCols);
DDX_Text(pDX, IDC_EDIT_NAME, m_strName);
DDX_Text(pDX, IDC_EDIT_S, m_fS);
DDX_Text(pDX, IDC_EDIT_T, m_fT);
DDX_Text(pDX, IDC_EDIT_X, m_fX);
DDX_Text(pDX, IDC_EDIT_Y, m_fY);
DDX_Text(pDX, IDC_EDIT_Z, m_fZ);
DDX_Text(pDX, IDC_HSCALE, m_fHScale);
DDX_Text(pDX, IDC_HSHIFT, m_fHShift);
DDX_Text(pDX, IDC_ROTATE, m_fRotate);
DDX_Text(pDX, IDC_VSCALE, m_fVScale);
DDX_Text(pDX, IDC_VSHIFT, m_fVShift);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPatchDialog, CDialog)
//{{AFX_MSG_MAP(CPatchDialog)
ON_BN_CLICKED(IDC_BTN_PATCHDETAILS, OnBtnPatchdetails)
ON_BN_CLICKED(IDC_BTN_PATCHFIT, OnBtnPatchfit)
ON_BN_CLICKED(IDC_BTN_PATCHNATURAL, OnBtnPatchnatural)
ON_BN_CLICKED(IDC_BTN_PATCHRESET, OnBtnPatchreset)
ON_CBN_SELCHANGE(IDC_COMBO_COL, OnSelchangeComboCol)
ON_CBN_SELCHANGE(IDC_COMBO_ROW, OnSelchangeComboRow)
ON_CBN_SELCHANGE(IDC_COMBO_TYPE, OnSelchangeComboType)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HSCALE, OnDeltaposSpin)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ROTATE, OnDeltaposSpin)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_VSCALE, OnDeltaposSpin)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_VSHIFT, OnDeltaposSpin)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HSHIFT, OnDeltaposSpin)
ON_WM_DESTROY()
ON_BN_CLICKED(IDC_APPLY, OnApply)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPatchDialog message handlers
void CPatchDialog::OnBtnPatchdetails()
{
Patch_NaturalizeSelected(true);
Sys_UpdateWindows(W_ALL);
}
void CPatchDialog::OnBtnPatchfit()
{
Patch_FitTexturing();
Sys_UpdateWindows(W_ALL);
}
void CPatchDialog::OnBtnPatchnatural()
{
Patch_NaturalizeSelected();
Sys_UpdateWindows(W_ALL);
}
void CPatchDialog::OnBtnPatchreset()
{
//CTextureLayout dlg;
//if (dlg.DoModal() == IDOK)
//{
// Patch_ResetTexturing(dlg.m_fX, dlg.m_fY);
//}
//Sys_UpdateWindows(W_ALL);
}
void CPatchDialog::OnSelchangeComboCol()
{
UpdateRowColInfo();
}
void CPatchDialog::OnSelchangeComboRow()
{
UpdateRowColInfo();
}
void CPatchDialog::OnSelchangeComboType()
{
// TODO: Add your control notification handler code here
}
void CPatchDialog::OnOK()
{
m_Patch = NULL;
CDialog::OnOK();
}
void CPatchDialog::OnDeltaposSpin(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
UpdateSpinners((pNMUpDown->iDelta > 0), pNMUpDown->hdr.idFrom);
*pResult = 0;
}
BOOL CPatchDialog::OnInitDialog()
{
CDialog::OnInitDialog();
m_wndHScale.SetRange(0, 1000);
m_wndVScale.SetRange(0, 1000);
m_wndHShift.SetRange(0, 1000);
m_wndVShift.SetRange(0, 1000);
m_wndRotate.SetRange(0, 1000);
GetPatchInfo();
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPatchDialog::GetPatchInfo()
{
m_Patch = SinglePatchSelected();
if (m_Patch != NULL)
{
CString str;
int i;
m_wndRows.ResetContent();
for (i = 0; i < m_Patch->height; i++)
{
str.Format("%i", i);
m_wndRows.AddString(str);
}
m_wndRows.SetCurSel(0);
m_wndCols.ResetContent();
for (i = 0; i < m_Patch->width; i++)
{
str.Format("%i", i);
m_wndCols.AddString(str);
}
m_wndCols.SetCurSel(0);
}
UpdateRowColInfo();
}
void CPatchDialog::SetPatchInfo()
{
}
void DoPatchInspector()
{
if (g_PatchDialog.GetSafeHwnd() == NULL)
{
g_PatchDialog.Create(IDD_DIALOG_PATCH);
CRect rct;
LONG lSize = sizeof(rct);
if (LoadRegistryInfo("Radiant::PatchWindow", &rct, &lSize))
{
g_PatchDialog.SetWindowPos(NULL, rct.left, rct.top, 0,0, SWP_NOSIZE);
}
}
g_PatchDialog.ShowWindow(SW_SHOW);
g_PatchDialog.GetPatchInfo();
}
void UpdatePatchInspector()
{
if (g_PatchDialog.GetSafeHwnd() != NULL)
{
g_PatchDialog.UpdateInfo();
}
}
void CPatchDialog::OnDestroy()
{
if (GetSafeHwnd())
{
CRect rct;
GetWindowRect(rct);
SaveRegistryInfo("Radiant::PatchWindow", &rct, sizeof(rct));
}
CDialog::OnDestroy();
}
void CPatchDialog::UpdateRowColInfo()
{
m_fX = m_fY = m_fZ = m_fS = m_fT = 0.0;
if (m_Patch != NULL)
{
int r = m_wndRows.GetCurSel();
int c = m_wndCols.GetCurSel();
if (r >= 0 && r < m_Patch->height && c >= 0 && c < m_Patch->width)
{
m_fX = m_Patch->ctrl(c,r).xyz[0];
m_fY = m_Patch->ctrl(c,r).xyz[1];
m_fZ = m_Patch->ctrl(c,r).xyz[2];
m_fS = m_Patch->ctrl(c,r).st[0];
m_fT = m_Patch->ctrl(c,r).st[1];
}
}
UpdateData(FALSE);
}
void CPatchDialog::UpdateInfo()
{
GetPatchInfo();
}
void CPatchDialog::OnApply()
{
UpdateData(TRUE);
if (m_Patch != NULL)
{
int r = m_wndRows.GetCurSel();
int c = m_wndCols.GetCurSel();
if (r >= 0 && r < m_Patch->height && c >= 0 && c < m_Patch->width)
{
m_Patch->ctrl(c,r).xyz[0] = m_fX;
m_Patch->ctrl(c,r).xyz[1] = m_fY;
m_Patch->ctrl(c,r).xyz[2] = m_fZ;
m_Patch->ctrl(c,r).st[0] = m_fS;
m_Patch->ctrl(c,r).st[1] = m_fT;
Patch_MakeDirty(m_Patch);
Sys_UpdateWindows(W_ALL);
}
}
}
void CPatchDialog::UpdateSpinners(bool bUp, int nID)
{
texdef_t td;
td.rotate = 0.0;
td.scale[0] = td.scale[1] = 0.0;
td.shift[0] = td.shift[1] = 0.0;
td.value = 0;
UpdateData(TRUE);
if (nID == IDC_SPIN_ROTATE)
{
if (bUp)
td.rotate = m_fRotate;
else
td.rotate = -m_fRotate;
}
else if (nID == IDC_SPIN_HSCALE)
{
if (bUp)
td.scale[0] = 1 - m_fHScale;
else
td.scale[0] = 1 + m_fHScale;
}
else if (nID == IDC_SPIN_VSCALE)
{
if (bUp)
td.scale[1] = 1 - m_fVScale;
else
td.scale[1] = 1 + m_fVScale;
}
else if (nID == IDC_SPIN_HSHIFT)
{
if (bUp)
td.shift[0] = m_fHShift;
else
td.shift[0] = -m_fHShift;
}
else if (nID == IDC_SPIN_VSHIFT)
{
if (bUp)
td.shift[1] = m_fVShift;
else
td.shift[1] = -m_fVShift;
}
Patch_SetTextureInfo(&td);
Sys_UpdateWindows(W_CAMERA);
}

View File

@@ -0,0 +1,108 @@
/*
===========================================================================
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.
===========================================================================
*/
#if !defined(AFX_PATCHDIALOG_H__DE62DFB4_E9EC_11D2_A509_0020AFEB881A__INCLUDED_)
#define AFX_PATCHDIALOG_H__DE62DFB4_E9EC_11D2_A509_0020AFEB881A__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// PatchDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CPatchDialog dialog
class CPatchDialog : public CDialog
{
patchMesh_t *m_Patch;
// Construction
public:
void UpdateInfo();
void SetPatchInfo();
void GetPatchInfo();
CPatchDialog(CWnd* pParent = NULL); // standard constructor
void UpdateSpinners(bool bUp, int nID);
// Dialog Data
//{{AFX_DATA(CPatchDialog)
enum { IDD = IDD_DIALOG_PATCH };
CSpinButtonCtrl m_wndVShift;
CSpinButtonCtrl m_wndVScale;
CSpinButtonCtrl m_wndRotate;
CSpinButtonCtrl m_wndHShift;
CSpinButtonCtrl m_wndHScale;
CComboBox m_wndType;
CComboBox m_wndRows;
CComboBox m_wndCols;
CString m_strName;
float m_fS;
float m_fT;
float m_fX;
float m_fY;
float m_fZ;
float m_fHScale;
float m_fHShift;
float m_fRotate;
float m_fVScale;
float m_fVShift;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPatchDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
void UpdateRowColInfo();
// Generated message map functions
//{{AFX_MSG(CPatchDialog)
afx_msg void OnBtnPatchdetails();
afx_msg void OnBtnPatchfit();
afx_msg void OnBtnPatchnatural();
afx_msg void OnBtnPatchreset();
afx_msg void OnSelchangeComboCol();
afx_msg void OnSelchangeComboRow();
afx_msg void OnSelchangeComboType();
virtual void OnOK();
afx_msg void OnDeltaposSpin(NMHDR* pNMHDR, LRESULT* pResult);
virtual BOOL OnInitDialog();
afx_msg void OnDestroy();
afx_msg void OnApply();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PATCHDIALOG_H__DE62DFB4_E9EC_11D2_A509_0020AFEB881A__INCLUDED_)

View File

@@ -0,0 +1,163 @@
/*
===========================================================================
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 "qe3.h"
#define MAX_POINTFILE 8192
static idVec3 s_pointvecs[MAX_POINTFILE];
static int s_num_points, s_check_point;
void Pointfile_Delete (void)
{
char name[1024];
strcpy (name, currentmap);
StripExtension (name);
strcat (name, ".lin");
remove(name);
}
// advance camera to next point
void Pointfile_Next (void)
{
idVec3 dir;
if (s_check_point >= s_num_points-2)
{
Sys_Status ("End of pointfile", 0);
return;
}
s_check_point++;
VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetCamera()->Camera().origin);
VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetXYWnd()->GetOrigin());
VectorSubtract (s_pointvecs[s_check_point+1], g_pParentWnd->GetCamera()->Camera().origin, dir);
dir.Normalize();
g_pParentWnd->GetCamera()->Camera().angles[1] = atan2 (dir[1], dir[0])*180/3.14159;
g_pParentWnd->GetCamera()->Camera().angles[0] = asin (dir[2])*180/3.14159;
Sys_UpdateWindows (W_ALL);
}
// advance camera to previous point
void Pointfile_Prev (void)
{
idVec3 dir;
if ( s_check_point == 0)
{
Sys_Status ("Start of pointfile", 0);
return;
}
s_check_point--;
VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetCamera()->Camera().origin);
VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetXYWnd()->GetOrigin());
VectorSubtract (s_pointvecs[s_check_point+1], g_pParentWnd->GetCamera()->Camera().origin, dir);
dir.Normalize();
g_pParentWnd->GetCamera()->Camera().angles[1] = atan2 (dir[1], dir[0])*180/3.14159;
g_pParentWnd->GetCamera()->Camera().angles[0] = asin (dir[2])*180/3.14159;
Sys_UpdateWindows (W_ALL);
}
void WINAPI Pointfile_Check (void)
{
char name[1024];
FILE *f;
idVec3 v;
strcpy (name, currentmap);
StripExtension (name);
strcat (name, ".lin");
f = fopen (name, "r");
if (!f)
return;
common->Printf ("Reading pointfile %s\n", name);
if (!g_qeglobals.d_pointfile_display_list)
g_qeglobals.d_pointfile_display_list = qglGenLists(1);
s_num_points = 0;
qglNewList (g_qeglobals.d_pointfile_display_list, GL_COMPILE);
qglColor3f (1, 0, 0);
qglDisable(GL_TEXTURE_2D);
qglDisable(GL_TEXTURE_1D);
qglLineWidth (2);
qglBegin(GL_LINE_STRIP);
do
{
if (fscanf (f, "%f %f %f\n", &v[0], &v[1], &v[2]) != 3)
break;
if (s_num_points < MAX_POINTFILE)
{
VectorCopy (v, s_pointvecs[s_num_points]);
s_num_points++;
}
qglVertex3fv( v.ToFloatPtr() );
} while (1);
qglEnd();
qglLineWidth (0.5);
qglEndList ();
s_check_point = 0;
fclose (f);
//Pointfile_Next ();
}
void Pointfile_Draw( void )
{
int i;
qglColor3f( 1.0F, 0.0F, 0.0F );
qglDisable(GL_TEXTURE_2D);
qglDisable(GL_TEXTURE_1D);
qglLineWidth (2);
qglBegin(GL_LINE_STRIP);
for ( i = 0; i < s_num_points; i++ )
{
qglVertex3fv( s_pointvecs[i].ToFloatPtr() );
}
qglEnd();
qglLineWidth( 0.5 );
}
void Pointfile_Clear (void)
{
if (!g_qeglobals.d_pointfile_display_list)
return;
qglDeleteLists (g_qeglobals.d_pointfile_display_list, 1);
g_qeglobals.d_pointfile_display_list = 0;
Sys_UpdateWindows (W_ALL);
}

View File

@@ -0,0 +1,452 @@
/*
===========================================================================
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 "qe3.h"
#include "shlobj.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define MOUSE_KEY "radiant_MouseButtons"
#define TLOCK_KEY "radiant_TextureLock"
#define RLOCK_KEY "radiant_RotateLock"
#define LOADLAST_KEY "radiant_LoadLast"
#define LOADLASTMAP_KEY "radiant_LoadLastMap"
#define LASTPROJ_KEY "radiant_LastProject"
#define LASTMAP_KEY "radiant_LastMap"
#define RUN_KEY "radiant_RunBefore"
#define FACE_KEY "radiant_NewFaceGrab"
#define BSP_KEY "radiant_InternalBSP"
#define RCLICK_KEY "radiant_NewRightClick"
#define VERTEX_KEY "radiant_NewVertex"
#define AUTOSAVE_KEY "radiant_Autosave"
#define AUTOSAVETIME_KEY "radiant_AutosaveMinutes"
#define PAK_KEY "radiant_UsePAK"
#define NEWAPPLY_KEY "radiant_ApplyDismissesSurface"
#define HACK_KEY "radiant_Gatewayescapehack"
#define TEXTURE_KEY "radiant_NewTextureWindowStuff"
#define TINYBRUSH_KEY "radiant_CleanTinyBrushes"
#define TINYSIZE_KEY "radiant_CleanTinyBrusheSize"
#define SNAPSHOT_KEY "radiant_Snapshots"
#define PAKFILE_KEY "radiant_PAKFile"
#define STATUS_KEY "radiant_StatusPointSize"
#define MOVESPEED_KEY "radiant_MoveSpeed"
#define ANGLESPEED_KEY "radiant_AngleSpeed"
#define SETGAME_KEY "radiant_UseSetGame"
#define CAMXYUPDATE_KEY "radiant_CamXYUpdate"
#define LIGHTDRAW_KEY "radiant_NewLightStyle"
#define WHATGAME_KEY "radiant_WhichGame"
#define CUBICCLIP_KEY "radiant_CubicClipping"
#define CUBICSCALE_KEY "radiant_CubicScale"
#define ALTEDGE_KEY "radiant_ALTEdgeDrag"
#define FACECOLORS_KEY "radiant_FaceColors"
#define QE4PAINT_KEY "radiant_QE4Paint"
#define SNAPT_KEY "radiant_SnapT"
#define XZVIS_KEY "radiant_XZVIS"
#define YZVIS_KEY "radiant_YZVIS"
#define ZVIS_KEY "radiant_ZVIS"
#define SIZEPAINT_KEY "radiant_SizePainting"
#define DLLENTITIES_KEY "radiant_DLLEntities"
#define WIDETOOLBAR_KEY "radiant_WideToolBar"
#define NOCLAMP_KEY "radiant_NoClamp"
#define PREFAB_KEY "radiant_PrefabPath"
#define USERINI_KEY "radiant_UserINIPath"
#define ROTATION_KEY "radiant_Rotation"
#define SGIOPENGL_KEY "radiant_SGIOpenGL"
#define BUGGYICD_KEY "radiant_BuggyICD"
#define HICOLOR_KEY "radiant_HiColorTextures"
#define CHASEMOUSE_KEY "radiant_ChaseMouse"
#define ENTITYSHOW_KEY "radiant_EntityShow"
#define TEXTURESCALE_KEY "radiant_TextureScale"
#define TEXTURESCROLLBAR_KEY "radiant_TextureScrollbar"
#define DISPLAYLISTS_KEY "radiant_UseDisplayLists"
#define NORMALIZECOLORS_KEY "radiant_NormalizeColors"
#define SHADERS_KEY "radiant_UseShaders"
#define SWITCHCLIP_KEY "radiant_SwitchClipKey"
#define SELWHOLEENTS_KEY "radiant_SelectWholeEntitiesKey"
#define TEXTURESUBSET_KEY "radiant_UseTextureSubsetLoading"
#define TEXTUREQUALITY_KEY "radiant_TextureQuality"
#define SHOWSHADERS_KEY "radiant_ShowShaders"
#define SHADERTEST_KEY "radiant_ShaderTest"
#define GLLIGHTING_KEY "radiant_UseGLLighting"
#define NOSTIPPLE_KEY "radiant_NoStipple"
#define UNDOLEVELS_KEY "radiant_UndoLevels"
#define MAPS_KEY "radiant_RadiantMapPath"
#define MODELS_KEY "radiant_ModelPath"
#define NEWMAPFORMAT_KEY "radiant_NewMapFormat"
#define WINDOW_DEF 0
#define TLOCK_DEF 1
#define LOADLAST_DEF 1
#define RUN_DEF 0
/////////////////////////////////////////////////////////////////////////////
// CPrefsDlg dialog
CPrefsDlg::CPrefsDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPrefsDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CPrefsDlg)
m_bLoadLast = FALSE;
m_bFace = FALSE;
m_bRightClick = FALSE;
m_bVertex = FALSE;
m_bAutoSave = TRUE;
m_bNewApplyHandling = FALSE;
m_strAutoSave = _T("5");
m_bLoadLastMap = FALSE;
m_bTextureWindow = FALSE;
m_bSnapShots = FALSE;
m_fTinySize = 0.5;
m_bCleanTiny = FALSE;
m_nStatusSize = 10;
m_bCamXYUpdate = FALSE;
m_bNewLightDraw = FALSE;
m_bALTEdge = FALSE;
m_bQE4Painting = TRUE;
m_bSnapTToGrid = FALSE;
m_bXZVis = FALSE;
m_bYZVis = FALSE;
m_bZVis = FALSE;
m_bSizePaint = FALSE;
m_bWideToolbar = TRUE;
m_bNoClamp = FALSE;
m_nRotation = 0;
m_bHiColorTextures = TRUE;
m_bChaseMouse = FALSE;
m_bTextureScrollbar = TRUE;
m_bDisplayLists = TRUE;
m_bNoStipple = FALSE;
m_strMaps = _T("");
m_strModels = _T("");
m_bNewMapFormat = TRUE;
//}}AFX_DATA_INIT
//LoadPrefs();
m_selectByBoundingBrush = FALSE;
m_selectOnlyBrushes = FALSE;
m_selectNoModels = FALSE;
m_nEntityShowState = 0;
m_nTextureScale = 2;
m_bSwitchClip = FALSE;
m_bSelectWholeEntities = TRUE;
m_nTextureQuality = 3;
m_bGLLighting = FALSE;
m_nUndoLevels = 63;
}
void CPrefsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPrefsDlg)
DDX_Control(pDX, IDC_SPIN_UNDO, m_wndUndoSpin);
DDX_Control(pDX, IDC_SPIN_POINTSIZE, m_wndFontSpin);
DDX_Control(pDX, IDC_SLIDER_TEXTUREQUALITY, m_wndTexturequality);
DDX_Control(pDX, IDC_SLIDER_CAMSPEED, m_wndCamSpeed);
DDX_Control(pDX, IDC_SPIN_AUTOSAVE, m_wndSpin);
DDX_Check(pDX, IDC_CHECK_LOADLAST, m_bLoadLast);
DDX_Check(pDX, IDC_CHECK_FACE, m_bFace);
DDX_Check(pDX, IDC_CHECK_RIGHTCLICK, m_bRightClick);
DDX_Check(pDX, IDC_CHECK_AUTOSAVE, m_bAutoSave);
DDX_Text(pDX, IDC_EDIT_AUTOSAVE, m_strAutoSave);
DDX_Check(pDX, IDC_CHECK_LOADLASTMAP, m_bLoadLastMap);
DDX_Check(pDX, IDC_CHECK_TEXTUREWINDOW, m_bTextureWindow);
DDX_Check(pDX, IDC_CHECK_SNAPSHOTS, m_bSnapShots);
DDX_Text(pDX, IDC_EDIT_STATUSPOINTSIZE, m_nStatusSize);
DDV_MinMaxInt(pDX, m_nStatusSize, 2, 14);
DDX_Check(pDX, IDC_CHECK_CAMXYUPDATE, m_bCamXYUpdate);
DDX_Check(pDX, IDC_CHECK_LIGHTDRAW, m_bNewLightDraw);
DDX_Check(pDX, IDC_CHECK_ALTDRAG, m_bALTEdge);
DDX_Check(pDX, IDC_CHECK_QE4PAINTING, m_bQE4Painting);
DDX_Check(pDX, IDC_CHECK_SNAPT, m_bSnapTToGrid);
DDX_Check(pDX, IDC_CHECK_SIZEPAINT, m_bSizePaint);
DDX_Check(pDX, IDC_CHECK_WIDETOOLBAR, m_bWideToolbar);
DDX_Check(pDX, IDC_CHECK_NOCLAMP, m_bNoClamp);
DDX_Text(pDX, IDC_EDIT_ROTATION, m_nRotation);
DDX_Check(pDX, IDC_CHECK_HICOLOR, m_bHiColorTextures);
DDX_Check(pDX, IDC_CHECK_MOUSECHASE, m_bChaseMouse);
DDX_Check(pDX, IDC_CHECK_TEXTURESCROLLBAR, m_bTextureScrollbar);
DDX_Check(pDX, IDC_CHECK_DISPLAYLISTS, m_bDisplayLists);
DDX_Check(pDX, IDC_CHECK_NOSTIPPLE, m_bNoStipple);
DDX_Text(pDX, IDC_EDIT_UNDOLEVELS, m_nUndoLevels);
DDV_MinMaxInt(pDX, m_nUndoLevels, 1, 64);
DDX_Text(pDX, IDC_EDIT_MAPS, m_strMaps);
DDX_Check(pDX, IDC_CHECK_NEWMAPFORMAT, m_bNewMapFormat);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPrefsDlg, CDialog)
//{{AFX_MSG_MAP(CPrefsDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPrefsDlg message handlers
BOOL CPrefsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_wndSpin.SetRange(1,60);
m_wndCamSpeed.SetRange(10, 5000);
m_wndCamSpeed.SetPos(m_nMoveSpeed);
this->m_wndTexturequality.SetRange(0, 3);
this->m_wndTexturequality.SetPos(m_nTextureQuality);
m_wndFontSpin.SetRange(4,24);
m_wndUndoSpin.SetRange(1,64);
GetDlgItem(IDC_CHECK_HICOLOR)->EnableWindow(TRUE);
GetDlgItem(IDC_CHECK_NOCLAMP)->EnableWindow(TRUE);
//GetDlgItem(IDC_CHECK_NOCLAMP)->EnableWindow(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPrefsDlg::OnOK()
{
m_nMoveSpeed = m_wndCamSpeed.GetPos();
m_nAngleSpeed = (float)m_nMoveSpeed * 0.50;
this->m_nTextureQuality = m_wndTexturequality.GetPos();
SavePrefs();
if ( g_pParentWnd ) {
g_pParentWnd->SetGridStatus();
}
Sys_UpdateWindows(W_ALL);
Undo_SetMaxSize(m_nUndoLevels);
CDialog::OnOK();
}
int GetCvarInt(const char *name, const int def) {
idCVar *cvar = cvarSystem->Find( name );
if ( cvar ) {
return cvar->GetInteger();
} else {
return def;
}
}
const char *GetCvarString( const char *name, const char *def ) {
idCVar *cvar = cvarSystem->Find( name );
if ( cvar ) {
return cvar->GetString();
} else {
return def;
}
}
static const char hexDigits[] = "0123456789ABCDEF";
void SetCvarInt( const char *name, const int value ) {
cvarSystem->SetCVarInteger( name, value, CVAR_TOOL );
}
void SetCvarString( const char *name, const char *value ) {
cvarSystem->SetCVarString( name, value, CVAR_TOOL );
}
void SetCvarBinary(const char *name, void *pv, int size) {
unsigned char *in = new unsigned char[size];
idStr s;
memset( in, 0, size );
memcpy( in, pv, size );
for ( int i = 0; i < size; i++ ) {
s += hexDigits[in[i] >> 4];
s += hexDigits[in[i] & 0x0f];
}
delete []in;
SetCvarString(name, s);
}
bool GetCvarBinary( const char *name, void *pv, int size ) {
bool ret = false;
unsigned char *out = new unsigned char[size];
idStr s = GetCvarString( name, "" );
if ( s.Length() / 2 == size ) {
int j = 0;
for ( int i = 0; i < s.Length(); i += 2 ) {
char c;
if (s[i] > '9') {
c = s[i] - 'A' + 0x0a;
} else {
c = s[i] - 0x30;
}
c <<= 4;
if (s[i+1] > '9') {
c |= s[i+1] - 'A' + 0x0a;
} else {
c |= s[i+1] - 0x30;
}
out[j++] = c;
}
memcpy(pv, out, size);
ret = true;
}
delete []out;
return ret;
}
void CPrefsDlg::LoadPrefs() {
CString strBuff;
CString strPrefab = g_strAppPath;
AddSlash(strPrefab);
strPrefab += "Prefabs\\";
m_nMouseButtons = 3;
m_bTextureLock = GetCvarInt( TLOCK_KEY, TLOCK_DEF );
m_bRotateLock = GetCvarInt( RLOCK_KEY, TLOCK_DEF );
m_strLastProject = GetCvarString( LASTPROJ_KEY, "" );
m_strLastMap = GetCvarString( LASTMAP_KEY, "" );
m_bLoadLast = GetCvarInt( LOADLAST_KEY, LOADLAST_DEF );
m_bRunBefore = GetCvarInt( RUN_KEY, RUN_DEF );
m_bFace = GetCvarInt( FACE_KEY, 1 );
m_bRightClick = GetCvarInt( RCLICK_KEY, 1 );
m_bVertex = GetCvarInt( VERTEX_KEY, 1 );
m_bAutoSave = GetCvarInt( AUTOSAVE_KEY, 1 );
m_bNewApplyHandling = GetCvarInt( NEWAPPLY_KEY, 0 );
m_bLoadLastMap = GetCvarInt( LOADLASTMAP_KEY, 0 );
m_bGatewayHack = GetCvarInt( HACK_KEY, 0 );
m_bTextureWindow = GetCvarInt( TEXTURE_KEY, 0 );
m_bCleanTiny = GetCvarInt( TINYBRUSH_KEY, 0 );
strBuff = GetCvarString( TINYSIZE_KEY, "0.5" );
m_fTinySize = atof(strBuff );
m_nAutoSave = GetCvarInt( AUTOSAVETIME_KEY, 5 );
if ( m_nAutoSave <= 0 ) { m_nAutoSave = 1; }
m_strAutoSave.Format("%i", m_nAutoSave );
m_bSnapShots = GetCvarInt( SNAPSHOT_KEY, 0 );
m_nStatusSize = GetCvarInt( STATUS_KEY, 10 );
m_nMoveSpeed = GetCvarInt( MOVESPEED_KEY, 400 );
m_nAngleSpeed = GetCvarInt( ANGLESPEED_KEY, 300 );
m_bCamXYUpdate = GetCvarInt( CAMXYUPDATE_KEY, 1 );
m_bNewLightDraw = GetCvarInt( LIGHTDRAW_KEY, 1 );
m_bCubicClipping = ( GetCvarInt( CUBICCLIP_KEY, 1) != 0 );
m_nCubicScale = GetCvarInt( CUBICSCALE_KEY, 13 );
m_bALTEdge = GetCvarInt( ALTEDGE_KEY, 0 );
m_bQE4Painting = GetCvarInt( QE4PAINT_KEY, 1 );
m_bSnapTToGrid = GetCvarInt( SNAPT_KEY, 0 );
m_bXZVis = GetCvarInt( XZVIS_KEY, 0 );
m_bYZVis = GetCvarInt( YZVIS_KEY, 0 );
m_bZVis = GetCvarInt( ZVIS_KEY, 1 );
m_bSizePaint = GetCvarInt( SIZEPAINT_KEY, 0 );
m_bWideToolbar = GetCvarInt( WIDETOOLBAR_KEY, 1 );
m_bNoClamp = GetCvarInt( NOCLAMP_KEY, 0 );
m_nRotation = GetCvarInt( ROTATION_KEY, 45 );
m_bHiColorTextures = GetCvarInt( HICOLOR_KEY, 1 );
m_bChaseMouse = GetCvarInt( CHASEMOUSE_KEY, 1 );
m_nEntityShowState = GetCvarInt( ENTITYSHOW_KEY, 0 );
m_nTextureScale = GetCvarInt( TEXTURESCALE_KEY, 50 );
m_bTextureScrollbar = GetCvarInt( TEXTURESCROLLBAR_KEY, TRUE );
m_bDisplayLists = GetCvarInt( DISPLAYLISTS_KEY, TRUE );
m_bSwitchClip = GetCvarInt( SWITCHCLIP_KEY, TRUE );
m_bSelectWholeEntities = GetCvarInt( SELWHOLEENTS_KEY, TRUE );
m_nTextureQuality = GetCvarInt( TEXTUREQUALITY_KEY, 6 );
m_bGLLighting = GetCvarInt( GLLIGHTING_KEY, FALSE );
m_bNoStipple = GetCvarInt( NOSTIPPLE_KEY, 0 );
m_nUndoLevels = GetCvarInt( UNDOLEVELS_KEY, 63 );
m_strMaps = GetCvarString( MAPS_KEY, "" );
m_strModels = GetCvarString( MODELS_KEY, "" );
m_bNoStipple = GetCvarInt( NEWMAPFORMAT_KEY, 1 );
if ( m_bRunBefore == FALSE ) {
SetGamePrefs();
}
}
void CPrefsDlg::SavePrefs() {
if ( GetSafeHwnd() ) {
UpdateData(TRUE);
}
m_nMouseButtons = 3;
SetCvarInt( TLOCK_KEY, m_bTextureLock );
SetCvarInt( RLOCK_KEY, m_bRotateLock );
SetCvarInt( LOADLAST_KEY, m_bLoadLast );
SetCvarString( LASTPROJ_KEY, m_strLastProject );
SetCvarString( LASTMAP_KEY, m_strLastMap );
SetCvarInt( RUN_KEY, m_bRunBefore );
SetCvarInt( FACE_KEY, m_bFace );
SetCvarInt( RCLICK_KEY, m_bRightClick );
SetCvarInt( VERTEX_KEY, m_bVertex );
SetCvarInt( AUTOSAVE_KEY, m_bAutoSave );
SetCvarInt( LOADLASTMAP_KEY, m_bLoadLastMap );
SetCvarInt( TEXTURE_KEY, m_bTextureWindow );
m_nAutoSave = atoi( m_strAutoSave );
SetCvarInt( AUTOSAVETIME_KEY, m_nAutoSave );
SetCvarInt( SNAPSHOT_KEY, m_bSnapShots );
SetCvarInt( STATUS_KEY, m_nStatusSize );
SetCvarInt( CAMXYUPDATE_KEY, m_bCamXYUpdate );
SetCvarInt( LIGHTDRAW_KEY, m_bNewLightDraw );
SetCvarInt( MOVESPEED_KEY, m_nMoveSpeed );
SetCvarInt( ANGLESPEED_KEY, m_nAngleSpeed );
SetCvarInt( CUBICCLIP_KEY, m_bCubicClipping );
SetCvarInt( CUBICSCALE_KEY, m_nCubicScale );
SetCvarInt( ALTEDGE_KEY, m_bALTEdge );
SetCvarInt( QE4PAINT_KEY, m_bQE4Painting );
SetCvarInt( SNAPT_KEY, m_bSnapTToGrid );
SetCvarInt( XZVIS_KEY, m_bXZVis );
SetCvarInt( YZVIS_KEY, m_bYZVis );
SetCvarInt( ZVIS_KEY, m_bZVis );
SetCvarInt( SIZEPAINT_KEY, m_bSizePaint );
SetCvarInt( WIDETOOLBAR_KEY, m_bWideToolbar );
SetCvarInt( NOCLAMP_KEY, m_bNoClamp );
SetCvarInt( ROTATION_KEY, m_nRotation );
SetCvarInt( HICOLOR_KEY, m_bHiColorTextures );
SetCvarInt( CHASEMOUSE_KEY, m_bChaseMouse );
SetCvarInt( ENTITYSHOW_KEY, m_nEntityShowState );
SetCvarInt( TEXTURESCALE_KEY, m_nTextureScale );
SetCvarInt( TEXTURESCROLLBAR_KEY, m_bTextureScrollbar );
SetCvarInt( DISPLAYLISTS_KEY, m_bDisplayLists );
SetCvarInt( SWITCHCLIP_KEY, m_bSwitchClip );
SetCvarInt( SELWHOLEENTS_KEY, m_bSelectWholeEntities );
SetCvarInt( TEXTUREQUALITY_KEY, m_nTextureQuality );
SetCvarInt( GLLIGHTING_KEY, m_bGLLighting );
SetCvarInt( NOSTIPPLE_KEY, m_bNoStipple );
SetCvarInt( UNDOLEVELS_KEY, m_nUndoLevels );
SetCvarString( MAPS_KEY, m_strMaps );
SetCvarString( MODELS_KEY, m_strModels );
SetCvarInt( NEWMAPFORMAT_KEY, m_bNewMapFormat );
common->WriteFlaggedCVarsToFile( "editor.cfg", CVAR_TOOL, "sett" );
}
void CPrefsDlg::SetGamePrefs() {
m_bHiColorTextures = TRUE;
m_bWideToolbar = TRUE;
SavePrefs();
}

View File

@@ -0,0 +1,138 @@
/*
===========================================================================
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 __PREFSDLG_H__
#define __PREFSDLG_H__
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
/////////////////////////////////////////////////////////////////////////////
// CPrefsDlg dialog
#define MAX_TEXTURE_QUALITY 3
class CPrefsDlg : public CDialog
{
// Construction
public:
CPrefsDlg(CWnd* pParent = NULL); // standard constructor
void LoadPrefs();
void SavePrefs();
void SetGamePrefs();
// Dialog Data
//{{AFX_DATA(CPrefsDlg)
enum { IDD = IDD_DLG_PREFS };
CSpinButtonCtrl m_wndUndoSpin;
CSpinButtonCtrl m_wndFontSpin;
CSliderCtrl m_wndTexturequality;
CSliderCtrl m_wndCamSpeed;
CSpinButtonCtrl m_wndSpin;
BOOL m_bTextureLock;
BOOL m_bLoadLast;
BOOL m_bRunBefore;
CString m_strLastProject;
CString m_strLastMap;
BOOL m_bFace;
BOOL m_bRightClick;
BOOL m_bVertex;
BOOL m_bAutoSave;
BOOL m_bNewApplyHandling;
CString m_strAutoSave;
BOOL m_bLoadLastMap;
BOOL m_bGatewayHack;
BOOL m_bTextureWindow;
BOOL m_bSnapShots;
float m_fTinySize;
BOOL m_bCleanTiny;
int m_nStatusSize;
BOOL m_bCamXYUpdate;
BOOL m_bNewLightDraw;
BOOL m_bALTEdge;
BOOL m_bQE4Painting;
BOOL m_bSnapTToGrid;
BOOL m_bXZVis;
BOOL m_bYZVis;
BOOL m_bZVis;
BOOL m_bSizePaint;
BOOL m_bRotateLock;
BOOL m_bWideToolbar;
BOOL m_bNoClamp;
int m_nRotation;
BOOL m_bHiColorTextures;
BOOL m_bChaseMouse;
BOOL m_bTextureScrollbar;
BOOL m_bDisplayLists;
BOOL m_bNoStipple;
int m_nUndoLevels;
CString m_strMaps;
CString m_strModels;
BOOL m_bNewMapFormat;
//}}AFX_DATA
int m_nMouseButtons;
int m_nAngleSpeed;
int m_nMoveSpeed;
int m_nAutoSave;
bool m_bCubicClipping;
int m_nCubicScale;
BOOL m_selectOnlyBrushes;
BOOL m_selectNoModels;
BOOL m_selectByBoundingBrush;
int m_nEntityShowState;
int m_nTextureScale;
BOOL m_bNormalizeColors;
BOOL m_bSwitchClip;
BOOL m_bSelectWholeEntities;
int m_nTextureQuality;
BOOL m_bGLLighting;
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPrefsDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
protected:
// Generated message map functions
//{{AFX_MSG(CPrefsDlg)
afx_msg void OnBtnBrowse();
virtual BOOL OnInitDialog();
virtual void OnOK();
afx_msg void OnBtnBrowsepak();
afx_msg void OnBtnBrowseprefab();
afx_msg void OnBtnBrowseuserini();
afx_msg void OnSelchangeComboWhatgame();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#endif /* !__PREFSDLG_H__ */

View File

@@ -0,0 +1,669 @@
/*
===========================================================================
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 "qe3.h"
#include "Radiant.h"
#include "WaitDlg.h"
#include "PreviewDlg.h"
#include "CommentsDlg.h"
const int PARENTID = 99999;
extern HTREEITEM FindTreeItem(CTreeCtrl *tree, HTREEITEM root, const char *text, HTREEITEM forceParent);
// CPreviewDlg dialog
IMPLEMENT_DYNAMIC(CPreviewDlg, CDialog)
CPreviewDlg::CPreviewDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPreviewDlg::IDD, pParent)
{
currentMode = MODELS;
disablePreview = false;
}
CPreviewDlg::~CPreviewDlg()
{
}
void CPreviewDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_TREE_MEDIA, treeMedia);
DDX_Control(pDX, IDC_EDIT_INFO, editInfo);
DDX_Control(pDX, IDC_PREVIEW, wndPreview);
}
BEGIN_MESSAGE_MAP(CPreviewDlg, CDialog)
ON_NOTIFY(TVN_SELCHANGED, IDC_TREE_MEDIA, OnTvnSelchangedTreeMedia)
ON_BN_CLICKED(IDC_BUTTON_RELOAD, OnBnClickedButtonReload)
ON_BN_CLICKED(IDC_BUTTON_ADD, OnBnClickedButtonAdd)
ON_BN_CLICKED(IDC_BUTTON_PLAY, OnBnClickedButtonPlay)
END_MESSAGE_MAP()
// CPreviewDlg message handlers
BOOL CPreviewDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_image.Create(IDB_BITMAP_MATERIAL, 16, 1, RGB(255, 255, 255));
treeMedia.SetImageList(&m_image, TVSIL_NORMAL);
if ( disablePreview ) {
wndPreview.ShowWindow( SW_HIDE );
} else {
wndPreview.setDrawable(&m_testDrawable);
}
SetMode(currentMode);
BuildTree();
if ( mediaName.Length() ) {
HTREEITEM root = treeMedia.GetRootItem();
HTREEITEM sel = FindTreeItem(&treeMedia, root, mediaName, NULL );
if (sel) {
treeMedia.SelectItem(sel);
}
}
mediaName = "";
return TRUE; // return TRUE unless you set the focus to a control
}
void CPreviewDlg::BuildTree() {
CWaitCursor cursor;
quickTree.Clear();
treeMedia.DeleteAllItems();
idFileList *files;
if ( currentMode == GUIS ) {
files = fileSystem->ListFilesTree( "guis", ".gui" );
AddStrList( "base", files->GetList(), GUIS );
fileSystem->FreeFileList( files );
} else if ( currentMode == MODELS ) {
files = fileSystem->ListFilesTree( "models", ".lwo" );
AddStrList( "base", files->GetList(), MODELS );
fileSystem->FreeFileList( files );
files = fileSystem->ListFilesTree( "models", ".ase" );
AddStrList( "base", files->GetList(), MODELS );
fileSystem->FreeFileList( files );
files = fileSystem->ListFilesTree( "models", ".ma" );
AddStrList( "base", files->GetList(), MODELS );
fileSystem->FreeFileList( files );
} else if ( currentMode == SOUNDS ) {
AddSounds( true );
} else if ( currentMode == MATERIALS ) {
AddMaterials( true );
} else if ( currentMode == PARTICLES ) {
AddParticles( true );
} else if ( currentMode == SKINS ) {
AddSkins( true );
}
}
void CPreviewDlg::RebuildTree( const char *_data ) {
data = _data;
data.ToLower();
BuildTree();
}
void CPreviewDlg::AddCommentedItems() {
const char *buffer = NULL;
const char *path;
items.Clear();
path = (currentMode == GUIS) ? "guis/guis.commented" : "models/models.commented";
idParser src( LEXFL_NOFATALERRORS | LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT );
if (fileSystem->ReadFile(path, (void**)&buffer, NULL) && buffer) {
src.LoadMemory(buffer, strlen(buffer), path);
if (src.IsLoaded()) {
idToken token, tok1, tok2, tok3;
while( src.ReadToken( &token ) ) {
if (token == "{") {
// start a new commented item
CommentedItem ci;
if (src.ReadToken(&tok1) && src.ReadToken(&tok2) && src.ReadToken(&tok3)) {
ci.Name = tok1;
ci.Path = tok2;
ci.Comments = tok3;
items.Append(ci);
}
}
}
}
fileSystem->FreeFile((void*)buffer);
}
commentItem = treeMedia.InsertItem("Commented");
int c = items.Num();
if (c) {
for (int i = 0; i < c; i++) {
HTREEITEM child = treeMedia.InsertItem(items[i].Name, commentItem);
treeMedia.SetItemData(child, -1 - i);
treeMedia.SetItemImage(child, 2, 2);
}
}
}
void CPreviewDlg::AddStrList( const char *root, const idStrList &list, int id ) {
idStr out, path;
HTREEITEM base = treeMedia.GetRootItem();
if (base) {
out = treeMedia.GetItemText(base);
if (stricmp(root, out)) {
base = NULL;
}
}
if (base == NULL) {
base = treeMedia.InsertItem(root);
treeMedia.SetItemData(base, PARENTID);
}
HTREEITEM item = base;
HTREEITEM add;
int count = list.Num();
idStr last, qt;
for (int i = 0; i < count; i++) {
idStr name = list[i];
// now break the name down convert to slashes
name.BackSlashesToSlashes();
name.Strip(' ');
int index;
int len = last.Length();
if (len == 0) {
index = name.Last('/');
if (index >= 0) {
name.Left(index, last);
}
}
else if (idStr::Icmpn(last, name, len) == 0 && name.Last('/') <= len) {
name.Right(name.Length() - len - 1, out);
add = treeMedia.InsertItem(out, item);
qt = root;
qt += "/";
qt += name;
quickTree.Set(qt, add);
treeMedia.SetItemImage(add, 2, 2);
treeMedia.SetItemData(add, id);
continue;
}
else {
last.Empty();
}
index = 0;
item = base;
path = "";
while (index >= 0) {
index = name.Find('/');
if (index >= 0) {
HTREEITEM newItem = NULL;
HTREEITEM *check = NULL;
name.Left( index, out );
path += out;
qt = root;
qt += "/";
qt += path;
if (quickTree.Get(qt, &check)) {
newItem = *check;
}
//HTREEITEM newItem = FindTreeItem(&treeMedia, item, name.Left(index, out), item);
if (newItem == NULL) {
newItem = treeMedia.InsertItem(out, item);
qt = root;
qt += "/";
qt += path;
quickTree.Set(qt, newItem);
treeMedia.SetItemImage(newItem, 0, 1);
treeMedia.SetItemData(newItem, PARENTID);
}
assert(newItem);
item = newItem;
name.Right(name.Length() - index - 1, out);
name = out;
path += "/";
}
else {
add = treeMedia.InsertItem(name, item);
qt = root;
qt += "/";
qt += path;
qt += name;
quickTree.Set(qt, add);
treeMedia.SetItemImage(add, 2, 2);
treeMedia.SetItemData(add, id);
path = "";
}
}
}
}
void CPreviewDlg::OnTvnSelchangedTreeMedia(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
HTREEITEM item = treeMedia.GetSelectedItem();
mediaName = "";
CWnd *add = GetDlgItem(IDC_BUTTON_ADD);
if (add) {
add->EnableWindow(treeMedia.GetItemData(item) == GUIS || treeMedia.GetItemData(item) == MODELS);
}
if (item) {
editInfo.SetWindowText("No comments for this item");
int id = treeMedia.GetItemData(item);
if ( id == GUIS || id == MODELS || id == MATERIALS || id == WAVES || id == PARTICLES || id == SKINS ) {
mediaName = treeMedia.GetItemText( item );
// have to build the name back up
HTREEITEM parent = treeMedia.GetParentItem( item );
while ( parent != NULL ) {
idStr strParent = treeMedia.GetItemText( parent );
strParent += "/";
strParent += mediaName;
mediaName = strParent;
parent = treeMedia.GetParentItem( parent );
}
// strip the leading "base/"
if (id == MATERIALS) {
mediaName.Strip("Materials/");
} else if (id == WAVES) {
mediaName.Strip( "Wave files/" );
} else if (id == PARTICLES) {
mediaName.Strip("Particles/");
mediaName += ".prt";
} else if ( id == SKINS ) {
mediaName.Strip( "Matching Skins/" );
mediaName.Strip( "Skins/" );
} else {
mediaName.Strip( "base/" );
}
} else if (id == WAVES || id == SOUNDS) {
mediaName = treeMedia.GetItemText( item );
} else if (id < 0) {
if ( treeMedia.ItemHasChildren(item) == FALSE ) {
int dw = abs(( int )treeMedia.GetItemData( item )) - 1;
if ( dw < items.Num() ) {
idStr work = items[dw].Path;
work += "\r\n\r\n";
work += items[dw].Comments;
editInfo.SetWindowText( work );
mediaName = items[dw].Path;
}
}
}
if ( currentMode == MODELS || currentMode == SKINS ) {
idStr modelMedia;
if ( currentMode == MODELS ) {
modelMedia = mediaName;
} else {
modelMedia = data;
}
if ( modelMedia.Length() ) {
int size = fileSystem->ReadFile( modelMedia, NULL, NULL );
int lsize;
if ( strstr( modelMedia, ".lwo" ) ) {
lsize = 128 * 1024;
}
else {
lsize = 768 * 1024;
}
if ( size > lsize ) {
if ( MessageBox("Model appears to be quite large, are you sure you want to preview it?", "High Poly Model?", MB_YESNO ) == IDNO ) {
*pResult = 0;
return;
}
}
m_drawModel.setMedia( modelMedia );
if ( currentMode == SKINS ) {
m_drawModel.SetSkin( mediaName );
}
}
m_drawModel.SetRealTime(0);
wndPreview.setDrawable( &m_drawModel );
wndPreview.Invalidate();
wndPreview.RedrawWindow();
RedrawWindow();
}
else if ( currentMode == PARTICLES ) {
m_drawModel.setMedia( mediaName );
m_drawModel.SetRealTime(50);
wndPreview.setDrawable( &m_drawModel );
wndPreview.Invalidate();
wndPreview.RedrawWindow();
RedrawWindow();
} else if ( currentMode == GUIS ) {
const idMaterial *mat = declManager->FindMaterial("guisurfs/guipreview");
mat->SetGui(mediaName);
m_drawMaterial.setMedia("guisurfs/guipreview");
m_drawMaterial.setScale(4.4f);
wndPreview.setDrawable(&m_drawMaterial);
wndPreview.Invalidate();
wndPreview.RedrawWindow();
idUserInterface *gui = uiManager->FindGui( mediaName, false, false, true );
if ( gui ) {
idStr str = gui->Comment();
str.Replace( "\n", "\r\n" );
if ( str != "" ) {
editInfo.SetWindowText( str );
}
}
RedrawWindow();
} else if (currentMode == MATERIALS) {
m_drawMaterial.setMedia(mediaName);
m_drawMaterial.setScale(1.0);
wndPreview.setDrawable(&m_drawMaterial);
wndPreview.Invalidate();
wndPreview.RedrawWindow();
RedrawWindow();
}
//m_drawGui.setMedia(matName);
//wndPreview.setDrawable(&m_drawMaterial);
//wndPreview.RedrawWindow();
}
*pResult = 0;
}
BOOL CPreviewDlg::Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd)
{
BOOL b = CDialog::Create(lpszTemplateName, pParentWnd);
ShowWindow(SW_SHOW);
return b;
}
void CPreviewDlg::OnCancel()
{
if ( AfxGetApp()->GetMainWnd() == GetParent() && GetParent() ) {
GetParent()->EnableWindow(TRUE);
g_qeglobals.sw->StopAllSounds();
ShowWindow(SW_HIDE);
} else {
CDialog::OnCancel();
}
returnCode = IDCANCEL;
}
void CPreviewDlg::OnOK()
{
if ( AfxGetApp()->GetMainWnd() == GetParent() && GetParent() ) {
GetParent()->EnableWindow(TRUE);
g_qeglobals.sw->StopAllSounds();
ShowWindow(SW_HIDE);
} else {
CDialog::OnOK();
}
returnCode = IDOK;
}
bool CPreviewDlg::Waiting() {
AfxGetApp()->PumpMessage();
return (returnCode == -1);
}
void CPreviewDlg::SetModal() {
returnCode = -1;
}
void CPreviewDlg::OnBnClickedButtonReload()
{
BuildTree();
g_qeglobals.sw->StopAllSounds();
}
void CPreviewDlg::OnBnClickedButtonAdd()
{
HTREEITEM item = treeMedia.GetSelectedItem();
if (treeMedia.ItemHasChildren(item) == FALSE && (treeMedia.GetItemData(item) == GUIS || treeMedia.GetItemData(item) == MODELS)) {
CCommentsDlg dlg;
dlg.strPath = mediaName;
if (dlg.DoModal()) {
CommentedItem ci;
ci.Name = dlg.strName;
ci.Path = dlg.strPath;
ci.Comments = dlg.strComments;
items.Append(ci);
item = treeMedia.InsertItem(ci.Name, commentItem);
treeMedia.SetItemData(item, -1 - (items.Num() + 1));
treeMedia.SetItemImage(item, 2, 2);
const char *path;
path = (currentMode == GUIS) ? "guis/guis.commented" : "models/models.commented";
idStr str;
void *buffer;
fileSystem->ReadFile( path, &buffer );
str = (char *) buffer;
fileSystem->FreeFile( buffer );
str += "\r\n\r\n{\r\n\t\"";
str += ci.Name;
str += "\"\r\n\t\"";
str += ci.Path;
str += "\"\r\n\t\"";
str += ci.Comments;
str += "\"\r\n}\r\n";
fileSystem->WriteFile(path, (void*)&str[0], str.Length(), "fs_devpath");
}
}
}
void CPreviewDlg::AddSounds(bool rootItems) {
int i, j;
idStrList list(1024);
idStrList list2(1024);
HTREEITEM base = treeMedia.InsertItem("Sound Shaders");
for( i = 0; i < declManager->GetNumDecls( DECL_SOUND ); i++ ) {
const idSoundShader *poo = declManager->SoundByIndex( i, false );
list.AddUnique( poo->GetFileName() );
}
list.Sort();
for ( i = 0; i < list.Num(); i++ ) {
HTREEITEM child = treeMedia.InsertItem(list[i], base);
treeMedia.SetItemData(child, SOUNDPARENT);
treeMedia.SetItemImage(child, 0, 1);
list2.Clear();
for (j = 0; j < declManager->GetNumDecls( DECL_SOUND ); j++) {
const idSoundShader *poo = declManager->SoundByIndex( j, false );
if ( idStr::Icmp( list[i], poo->GetFileName() ) == 0 ) {
list2.Append( poo->GetName() );
}
}
list2.Sort();
for (j = 0; j < list2.Num(); j++) {
HTREEITEM child2 = treeMedia.InsertItem( list2[j], child );
treeMedia.SetItemData(child2, SOUNDS);
treeMedia.SetItemImage(child2, 2, 2);
}
}
idFileList *files;
files = fileSystem->ListFilesTree( "sound", ".wav" );
AddStrList( "Wave files", files->GetList(), WAVES );
fileSystem->FreeFileList( files );
}
void CPreviewDlg::SetMode( int mode, const char *preSelect ) {
currentMode = mode;
if ( preSelect ) {
mediaName = preSelect;
}
if (GetSafeHwnd() == NULL) {
return;
}
CWnd *wnd;
switch (currentMode) {
case GUIS :
case SKINS :
case MODELS :
case PARTICLES :
wndPreview.ShowWindow(SW_SHOW);
wnd = GetDlgItem(IDC_BUTTON_PLAY);
if (wnd) {
wnd->ShowWindow(SW_HIDE);
}
wnd = GetDlgItem(IDC_BUTTON_ADD);
if (wnd) {
wnd->ShowWindow(SW_SHOW);
}
wnd = GetDlgItem(IDC_EDIT_INFO);
if (wnd) {
wnd->ShowWindow(SW_SHOW);
}
break;
case MATERIALS :
wndPreview.ShowWindow(SW_SHOW);
wnd = GetDlgItem(IDC_BUTTON_PLAY);
if (wnd) {
wnd->ShowWindow(SW_HIDE);
}
wnd = GetDlgItem(IDC_BUTTON_ADD);
if (wnd) {
wnd->ShowWindow(SW_HIDE);
}
wnd = GetDlgItem(IDC_EDIT_INFO);
if (wnd) {
wnd->ShowWindow(SW_HIDE);
}
break;
case SOUNDS :
case WAVES :
wndPreview.ShowWindow(SW_HIDE);
wnd = GetDlgItem(IDC_BUTTON_PLAY);
if (wnd) {
wnd->ShowWindow(SW_SHOW);
}
wnd = GetDlgItem(IDC_BUTTON_ADD);
if (wnd) {
wnd->ShowWindow(SW_HIDE);
}
wnd = GetDlgItem(IDC_EDIT_INFO);
if (wnd) {
wnd->ShowWindow(SW_HIDE);
}
break;
}
}
void CPreviewDlg::OnBnClickedButtonPlay() {
g_qeglobals.sw->PlayShaderDirectly(mediaName);
}
void CPreviewDlg::AddMaterials(bool rootItems) {
idStrList list(1024);
//char temp[2048];
int count = declManager->GetNumDecls( DECL_MATERIAL );
if (count > 0) {
for (int i = 0; i < count; i++) {
const idMaterial *mat = declManager->MaterialByIndex(i, false);
if (!rootItems) {
if (strchr(mat->GetName(), '/') == NULL && strchr(mat->GetName(), '\\') == NULL) {
continue;
}
}
list.Append(mat->GetName());
}
list.Sort();
AddStrList("Materials", list, MATERIALS);
}
}
void CPreviewDlg::AddParticles(bool rootItems) {
idStrList list(1024);
int count = declManager->GetNumDecls( DECL_PARTICLE );
if (count > 0) {
for (int i = 0; i < count; i++) {
const idDecl *ips = declManager->DeclByIndex( DECL_PARTICLE, i );
if (!rootItems) {
if (strchr(ips->GetName(), '/') == NULL && strchr(ips->GetName(), '\\') == NULL) {
continue;
}
}
list.Append(ips->GetName());
}
list.Sort();
AddStrList("Particles", list, PARTICLES);
}
}
void CPreviewDlg::AddSkins( bool rootItems ) {
idStrList list(1024);
idStrList list2(1024);
idStr str;
int count = declManager->GetNumDecls( DECL_SKIN );
if (count > 0) {
for (int i = 0; i < count; i++) {
const idDeclSkin *skin = declManager->SkinByIndex(i);
if (!rootItems) {
if (strchr(skin->GetName(), '/') == NULL && strchr(skin->GetName(), '\\') == NULL) {
continue;
}
}
if ( data.Length() ) {
for ( int j = 0; j < skin->GetNumModelAssociations(); j++ ){
str = skin->GetAssociatedModel( j );
str.ToLower();
if ( data.Cmp(str) == 0 ) {
list.Append(skin->GetName());
}
}
}
list2.Append(skin->GetName());
}
list.Sort();
list2.Sort();
AddStrList( "Matching Skins", list, SKINS );
AddStrList( "Skins", list2, SKINS );
}
}
void CPreviewDlg::OnShowWindow( BOOL bShow, UINT status ) {
if ( bShow && AfxGetApp()->GetMainWnd() == GetParent() && GetParent() ) {
GetParent()->EnableWindow( FALSE );
}
}

View File

@@ -0,0 +1,101 @@
/*
===========================================================================
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.
===========================================================================
*/
#pragma once
#include "afxcmn.h"
#include "afxwin.h"
// CPreviewDlg dialog
struct CommentedItem {
idStr Name;
idStr Path;
idStr Comments;
};
class CPreviewDlg : public CDialog
{
public:
enum {MODELS, GUIS, SOUNDS, MATERIALS, SCRIPTS, SOUNDPARENT, WAVES, PARTICLES, MODELPARENT, GUIPARENT, COMMENTED, SKINS};
CPreviewDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CPreviewDlg();
void SetMode( int mode, const char *preSelect = NULL );
void RebuildTree( const char *data );
void SetDisablePreview( bool b ) {
disablePreview = b;
}
idStr mediaName;
int returnCode;
bool Waiting();
void SetModal();
// Dialog Data
enum { IDD = IDD_DIALOG_PREVIEW };
private:
DECLARE_DYNAMIC(CPreviewDlg)
CTreeCtrl treeMedia;
CEdit editInfo;
HTREEITEM commentItem;
CImageList m_image;
idGLDrawable m_testDrawable;
idGLDrawableMaterial m_drawMaterial;
idGLDrawableModel m_drawModel;
idGLWidget wndPreview;
idHashTable<HTREEITEM> quickTree;
idList<CommentedItem> items;
virtual BOOL OnInitDialog();
int currentMode;
void AddCommentedItems();
idStr data;
bool disablePreview;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
void BuildTree();
void AddStrList(const char *root, const idStrList &list, int type);
void AddSounds(bool rootItems);
void AddMaterials(bool rootItems);
void AddParticles(bool rootItems);
void AddSkins( bool rootItems );
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnTvnSelchangedTreeMedia(NMHDR *pNMHDR, LRESULT *pResult);
virtual BOOL Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL);
protected:
virtual void OnCancel();
virtual void OnOK();
virtual void OnShowWindow( BOOL bShow, UINT status );
public:
afx_msg void OnBnClickedButtonReload();
afx_msg void OnBnClickedButtonAdd();
afx_msg void OnBnClickedButtonPlay();
};

View File

@@ -0,0 +1,540 @@
/*
===========================================================================
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 "qe3.h"
#include "Radiant.h"
#include "PropertyList.h"
#include "../comafx/DialogColorPicker.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPropertyList
CPropertyList::CPropertyList() {
measureItem = NULL;
updateInspectors = false;
}
CPropertyList::~CPropertyList() {
}
BEGIN_MESSAGE_MAP(CPropertyList, CListBox)
//{{AFX_MSG_MAP(CPropertyList)
ON_WM_CREATE()
ON_CONTROL_REFLECT(LBN_SELCHANGE, OnSelchange)
ON_WM_LBUTTONUP()
ON_WM_KILLFOCUS()
ON_WM_LBUTTONDOWN()
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
ON_CBN_CLOSEUP(IDC_PROPCMBBOX, OnKillfocusCmbBox)
ON_CBN_SELCHANGE(IDC_PROPCMBBOX, OnSelchangeCmbBox)
ON_EN_KILLFOCUS(IDC_PROPEDITBOX, OnKillfocusEditBox)
ON_EN_CHANGE(IDC_PROPEDITBOX, OnChangeEditBox)
ON_BN_CLICKED(IDC_PROPBTNCTRL, OnButton)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPropertyList message handlers
BOOL CPropertyList::PreCreateWindow(CREATESTRUCT& cs) {
if (!CListBox::PreCreateWindow(cs)) {
return FALSE;
}
cs.style &= ~(LBS_OWNERDRAWVARIABLE | LBS_SORT);
cs.style |= LBS_OWNERDRAWFIXED;
m_bTracking = FALSE;
m_nDivider = 0;
m_bDivIsSet = FALSE;
return TRUE;
}
void CPropertyList::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct) {
if (measureItem && !measureItem->m_curValue.IsEmpty()) {
CRect rect;
GetClientRect(rect);
if (m_nDivider==0) {
m_nDivider = rect.Width() / 2;
}
rect.left = m_nDivider;
CDC * dc = GetDC();
dc->DrawText(measureItem->m_curValue, rect, DT_CALCRECT | DT_LEFT | DT_WORDBREAK);
ReleaseDC(dc);
lpMeasureItemStruct->itemHeight = (rect.Height() >= 20) ? rect.Height() : 20; //pixels
} else {
lpMeasureItemStruct->itemHeight = 20; //pixels
}
}
void CPropertyList::DrawItem(LPDRAWITEMSTRUCT lpDIS) {
CDC dc;
dc.Attach(lpDIS->hDC);
CRect rectFull = lpDIS->rcItem;
CRect rect = rectFull;
if (m_nDivider==0) {
m_nDivider = rect.Width() / 2;
}
rect.left = m_nDivider;
CRect rect2 = rectFull;
rect2.right = rect.left - 1;
UINT nIndex = lpDIS->itemID;
if (nIndex != (UINT) -1) {
//get the CPropertyItem for the current row
CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(nIndex);
//draw two rectangles, one for each row column
if (pItem->m_nItemType == PIT_VAR) {
dc.FillSolidRect(rect2,RGB(220,220,220));
} else {
dc.FillSolidRect(rect2,RGB(192,192,192));
}
dc.DrawEdge(rect2,EDGE_SUNKEN,BF_BOTTOMRIGHT);
dc.DrawEdge(rect,EDGE_SUNKEN,BF_BOTTOM);
if (lpDIS->itemState == ODS_SELECTED) {
dc.DrawFocusRect(rect2);
}
//write the property name in the first rectangle
dc.SetBkMode(TRANSPARENT);
dc.DrawText(pItem->m_propName,CRect(rect2.left+3,rect2.top+3,
rect2.right-3,rect2.bottom+3),
DT_LEFT | DT_SINGLELINE);
//write the initial property value in the second rectangle
dc.DrawText(pItem->m_curValue,CRect(rect.left+3,rect.top+3, rect.right+3,rect.bottom+3), DT_LEFT | (pItem->m_nItemType == PIT_VAR) ? DT_WORDBREAK : DT_SINGLELINE);
}
dc.Detach();
}
int CPropertyList::AddItem(CString txt) {
measureItem = NULL;
int nIndex = AddString(txt);
return nIndex;
}
int CPropertyList::AddPropItem(CPropertyItem* pItem) {
if (pItem->m_nItemType == PIT_VAR) {
measureItem = pItem;
} else {
measureItem = NULL;
}
int nIndex = AddString(_T(""));
measureItem = NULL;
SetItemDataPtr(nIndex,pItem);
return nIndex;
}
int CPropertyList::OnCreate(LPCREATESTRUCT lpCreateStruct) {
if (CListBox::OnCreate(lpCreateStruct) == -1) {
return -1;
}
m_bDivIsSet = FALSE;
m_nDivider = 0;
m_bTracking = FALSE;
m_hCursorSize = AfxGetApp()->LoadStandardCursor(IDC_SIZEWE);
m_hCursorArrow = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
m_SSerif8Font.CreatePointFont(80,_T("MS Sans Serif"));
return 0;
}
void CPropertyList::OnSelchange() {
CRect rect;
CString lBoxSelText;
static int recurse = 0;
//m_curSel = GetCurSel();
GetItemRect(m_curSel,rect);
rect.left = m_nDivider;
CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
if (updateInspectors) {
g_Inspectors->entityDlg.SetKeyVal(pItem->m_propName, pItem->m_curValue);
}
if (m_btnCtrl) {
m_btnCtrl.ShowWindow(SW_HIDE);
}
if (pItem->m_nItemType==PIT_COMBO) {
//display the combo box. If the combo box has already been
//created then simply move it to the new location, else create it
m_nLastBox = 0;
if (m_cmbBox) {
m_cmbBox.MoveWindow(rect);
} else {
rect.bottom += 300;
m_cmbBox.Create(CBS_DROPDOWNLIST | WS_VSCROLL | WS_VISIBLE | WS_CHILD | WS_BORDER,rect,this,IDC_PROPCMBBOX);
m_cmbBox.SetFont(&m_SSerif8Font);
}
//add the choices for this particular property
CString cmbItems = pItem->m_cmbItems;
lBoxSelText = pItem->m_curValue;
m_cmbBox.ResetContent();
m_cmbBox.AddString("");
int i,i2;
i=0;
while ((i2=cmbItems.Find('|',i)) != -1) {
m_cmbBox.AddString(cmbItems.Mid(i,i2-i));
i=i2+1;
}
m_cmbBox.ShowWindow(SW_SHOW);
//m_cmbBox.SetFocus();
//jump to the property's current value in the combo box
int j = m_cmbBox.FindStringExact(0,lBoxSelText);
if (j != CB_ERR) {
m_cmbBox.SetCurSel(j);
} else {
m_cmbBox.SetCurSel(0);
}
//m_cmbBox.ShowDropDown();
}
else if (pItem->m_nItemType==PIT_EDIT) {
//display edit box
m_nLastBox = 1;
m_prevSel = m_curSel;
rect.bottom -= 3;
if (m_editBox) {
m_editBox.MoveWindow(rect);
} else {
m_editBox.Create(ES_LEFT | ES_AUTOHSCROLL | WS_VISIBLE | WS_CHILD | WS_BORDER,rect,this,IDC_PROPEDITBOX);
m_editBox.SetFont(&m_SSerif8Font);
}
lBoxSelText = pItem->m_curValue;
m_editBox.ShowWindow(SW_SHOW);
m_editBox.SetFocus();
//set the text in the edit box to the property's current value
bool b = updateInspectors;
updateInspectors = false;
m_editBox.SetWindowText(lBoxSelText);
updateInspectors = b;
} else if (pItem->m_nItemType != PIT_VAR) {
DisplayButton(rect);
}
}
void CPropertyList::DisplayButton(CRect region) {
//displays a button if the property is a file/color/font chooser
m_nLastBox = 2;
m_prevSel = m_curSel;
if (region.Width() > 25) {
region.left = region.right - 25;
}
region.bottom -= 3;
if (m_btnCtrl) {
m_btnCtrl.MoveWindow(region);
} else {
m_btnCtrl.Create("...",BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD,region,this,IDC_PROPBTNCTRL);
m_btnCtrl.SetFont(&m_SSerif8Font);
}
m_btnCtrl.ShowWindow(SW_SHOW);
m_btnCtrl.SetFocus();
}
void CPropertyList::ResetContent() {
if (m_btnCtrl.GetSafeHwnd()) {
m_btnCtrl.ShowWindow(SW_HIDE);
}
int c = this->GetCount();
for (int i = 0; i < c; i++) {
CPropertyItem *pi = reinterpret_cast<CPropertyItem*>(GetItemDataPtr(i));
if (pi) {
delete pi;
}
}
CListBox::ResetContent();
}
void CPropertyList::OnKillFocus(CWnd* pNewWnd) {
//m_btnCtrl.ShowWindow(SW_HIDE);
CListBox::OnKillFocus(pNewWnd);
}
void CPropertyList::OnKillfocusCmbBox() {
m_cmbBox.ShowWindow(SW_HIDE);
Invalidate();
}
void CPropertyList::OnKillfocusEditBox() {
CString newStr;
m_editBox.ShowWindow(SW_HIDE);
Invalidate();
}
void CPropertyList::OnSelchangeCmbBox() {
CString selStr;
if (m_cmbBox) {
m_cmbBox.GetLBText(m_cmbBox.GetCurSel(),selStr);
CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
pItem->m_curValue = selStr;
if (updateInspectors) {
g_Inspectors->entityDlg.UpdateFromListBox();
}
}
}
void CPropertyList::OnChangeEditBox() {
CString newStr;
m_editBox.GetWindowText(newStr);
CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
pItem->m_curValue = newStr;
}
void CPropertyList::OnButton() {
CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
//display the appropriate common dialog depending on what type
//of chooser is associated with the property
if (pItem->m_nItemType == PIT_COLOR) {
idVec3 color;
sscanf(pItem->m_curValue, "%f %f %f", &color.x, &color.y, &color.z);
COLORREF cr = (int)(color.x * 255) + (((int)(color.y * 255))<<8) + (((int)(color.z * 255))<<16);
CDialogColorPicker dlg(cr);
dlg.UpdateParent = UpdateRadiantColor;
if (dlg.DoModal() == IDOK) {
color.x = (dlg.GetColor() & 255)/255.0;
color.y = ((dlg.GetColor() >> 8)&255)/255.0;
color.z = ((dlg.GetColor() >> 16)&255)/255.0;
pItem->m_curValue = color.ToString(4);
}
if (updateInspectors) {
g_Inspectors->entityDlg.UpdateFromListBox();
}
m_btnCtrl.ShowWindow(SW_HIDE);
Invalidate();
} else if (pItem->m_nItemType == PIT_FILE) {
CString SelectedFile;
CString Filter("Gif Files (*.gif)|*.gif||");
CFileDialog FileDlg(TRUE, NULL, NULL, NULL, Filter);
CString currPath = pItem->m_curValue;
FileDlg.m_ofn.lpstrTitle = "Select file";
if (currPath.GetLength() > 0) {
FileDlg.m_ofn.lpstrInitialDir = currPath.Left(currPath.GetLength() - currPath.ReverseFind('\\'));
}
if(IDOK == FileDlg.DoModal()) {
SelectedFile = FileDlg.GetPathName();
m_btnCtrl.ShowWindow(SW_HIDE);
pItem->m_curValue = SelectedFile;
Invalidate();
}
} else if (pItem->m_nItemType == PIT_FONT) {
CFontDialog FontDlg(NULL,CF_EFFECTS | CF_SCREENFONTS,NULL,this);
if(IDOK == FontDlg.DoModal()) {
CString faceName = FontDlg.GetFaceName();
m_btnCtrl.ShowWindow(SW_HIDE);
pItem->m_curValue = faceName;
Invalidate();
}
} else if (pItem->m_nItemType == PIT_MODEL) {
CPreviewDlg *dlg = CEntityDlg::ShowModelChooser();
if (dlg->returnCode == IDOK) {
pItem->m_curValue = dlg->mediaName;
m_btnCtrl.ShowWindow(SW_HIDE);
if (updateInspectors) {
g_Inspectors->entityDlg.UpdateFromListBox();
}
Invalidate();
}
} else if (pItem->m_nItemType == PIT_GUI) {
CPreviewDlg *dlg = CEntityDlg::ShowGuiChooser();
if (dlg->returnCode == IDOK) {
pItem->m_curValue = dlg->mediaName;
m_btnCtrl.ShowWindow(SW_HIDE);
if (updateInspectors) {
g_Inspectors->entityDlg.UpdateFromListBox();
}
Invalidate();
}
} else if (pItem->m_nItemType == PIT_MATERIAL) {
CPreviewDlg *dlg = CEntityDlg::ShowMaterialChooser();
if (dlg->returnCode == IDOK) {
pItem->m_curValue = dlg->mediaName;
m_btnCtrl.ShowWindow(SW_HIDE);
if (updateInspectors) {
g_Inspectors->entityDlg.UpdateFromListBox();
}
Invalidate();
}
}
}
void CPropertyList::OnLButtonUp(UINT nFlags, CPoint point) {
if (m_bTracking) {
//if columns were being resized then this indicates
//that mouse is up so resizing is done. Need to redraw
//columns to reflect their new widths.
m_bTracking = FALSE;
//if mouse was captured then release it
if (GetCapture()==this) {
::ReleaseCapture();
}
::ClipCursor(NULL);
CClientDC dc(this);
InvertLine(&dc,CPoint(point.x,m_nDivTop),CPoint(point.x,m_nDivBtm));
//set the divider position to the new value
m_nDivider = point.x;
//redraw
Invalidate();
} else {
BOOL loc;
int i = ItemFromPoint(point,loc);
m_curSel = i;
CListBox::OnLButtonUp(nFlags, point);
}
}
void CPropertyList::OnLButtonDown(UINT nFlags, CPoint point) {
if ((point.x>=m_nDivider-5) && (point.x<=m_nDivider+5)) {
//if mouse clicked on divider line, then start resizing
::SetCursor(m_hCursorSize);
CRect windowRect;
GetWindowRect(windowRect);
windowRect.left += 10; windowRect.right -= 10;
//do not let mouse leave the list box boundary
::ClipCursor(windowRect);
if (m_cmbBox) {
m_cmbBox.ShowWindow(SW_HIDE);
}
if (m_editBox) {
m_editBox.ShowWindow(SW_HIDE);
}
CRect clientRect;
GetClientRect(clientRect);
m_bTracking = TRUE;
m_nDivTop = clientRect.top;
m_nDivBtm = clientRect.bottom;
m_nOldDivX = point.x;
CClientDC dc(this);
InvertLine(&dc,CPoint(m_nOldDivX,m_nDivTop),CPoint(m_nOldDivX,m_nDivBtm));
//capture the mouse
SetCapture();
} else {
m_bTracking = FALSE;
CListBox::OnLButtonDown(nFlags, point);
}
}
void CPropertyList::OnMouseMove(UINT nFlags, CPoint point) {
if (m_bTracking) {
//move divider line to the mouse pos. if columns are
//currently being resized
CClientDC dc(this);
//remove old divider line
InvertLine(&dc,CPoint(m_nOldDivX,m_nDivTop),CPoint(m_nOldDivX,m_nDivBtm));
//draw new divider line
InvertLine(&dc,CPoint(point.x,m_nDivTop),CPoint(point.x,m_nDivBtm));
m_nOldDivX = point.x;
} else if ((point.x >= m_nDivider-5) && (point.x <= m_nDivider+5)) {
//set the cursor to a sizing cursor if the cursor is over the row divider
::SetCursor(m_hCursorSize);
} else {
CListBox::OnMouseMove(nFlags, point);
}
}
void CPropertyList::InvertLine(CDC* pDC,CPoint ptFrom,CPoint ptTo) {
int nOldMode = pDC->SetROP2(R2_NOT);
pDC->MoveTo(ptFrom);
pDC->LineTo(ptTo);
pDC->SetROP2(nOldMode);
}
void CPropertyList::PreSubclassWindow() {
m_bDivIsSet = FALSE;
m_nDivider = 0;
m_bTracking = FALSE;
m_curSel = 1;
m_hCursorSize = AfxGetApp()->LoadStandardCursor(IDC_SIZEWE);
m_hCursorArrow = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
m_SSerif8Font.CreatePointFont(80,_T("MS Sans Serif"));
}
void CPropertyList::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) {
if (m_cmbBox) {
m_cmbBox.ShowWindow(SW_HIDE);
}
if (m_editBox) {
m_editBox.ShowWindow(SW_HIDE);
}
if (m_btnCtrl) {
m_btnCtrl.ShowWindow(SW_HIDE);
}
Invalidate();
CListBox::OnVScroll(nSBCode, nPos, pScrollBar);
}

View File

@@ -0,0 +1,170 @@
/*
===========================================================================
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.
===========================================================================
*/
#if !defined(AFX_PROPERTYLIST_H__74205380_1B56_11D4_BC48_00105AA2186F__INCLUDED_)
#define AFX_PROPERTYLIST_H__74205380_1B56_11D4_BC48_00105AA2186F__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// PropertyList.h : header file
//
#define PIT_COMBO 0 //PIT = property item type
#define PIT_EDIT 1
#define PIT_COLOR 2
#define PIT_FONT 3
#define PIT_FILE 4
#define PIT_SCRIPT 5
#define PIT_MODEL 6
#define PIT_SOUND 7
#define PIT_GUI 8
#define PIT_MATERIAL 9
#define PIT_VAR 10
#define IDC_PROPCMBBOX 712
#define IDC_PROPEDITBOX 713
#define IDC_PROPBTNCTRL 714
/////////////////////////////////////////////////////////////////////////////
//CPropertyList Items
class CPropertyItem
{
// Attributes
public:
CString m_propName;
CString m_curValue;
int m_nItemType;
CString m_cmbItems;
int data;
public:
CPropertyItem(CString propName, CString curValue,
int nItemType, CString cmbItems)
{
m_propName = propName;
m_curValue = curValue;
m_nItemType = nItemType;
m_cmbItems = cmbItems;
data = -1;
}
void SetData(int d) {
data = d;
}
};
/////////////////////////////////////////////////////////////////////////////
// CPropertyList window
class CPropertyList : public CListBox
{
// Construction
public:
CPropertyList();
// Attributes
public:
// Operations
public:
int AddItem(CString txt);
int AddPropItem(CPropertyItem* pItem);
void ResetContent();
CEdit *GetEditBox() {
return &m_editBox;
}
void SetUpdateInspectors(bool b) {
updateInspectors = b;
}
void SetDivider( int div ) {
m_nDivider = div;
}
afx_msg void OnKillfocusEditBox();
afx_msg void OnChangeEditBox();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPropertyList)
public:
virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
afx_msg void OnSelchange();
protected:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void PreSubclassWindow();
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CPropertyList();
// Generated message map functions
protected:
//{{AFX_MSG(CPropertyList)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
//}}AFX_MSG
afx_msg void OnKillfocusCmbBox();
afx_msg void OnSelchangeCmbBox();
afx_msg void OnButton();
DECLARE_MESSAGE_MAP()
void InvertLine(CDC* pDC,CPoint ptFrom,CPoint ptTo);
void DisplayButton(CRect region);
CComboBox m_cmbBox;
CEdit m_editBox;
CButton m_btnCtrl;
CFont m_SSerif8Font;
int m_curSel,m_prevSel;
int m_nDivider;
int m_nDivTop;
int m_nDivBtm;
int m_nOldDivX;
int m_nLastBox;
BOOL m_bTracking;
BOOL m_bDivIsSet;
HCURSOR m_hCursorArrow;
HCURSOR m_hCursorSize;
CPropertyItem *measureItem;
bool updateInspectors;
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PROPERTYLIST_H__74205380_1B56_11D4_BC48_00105AA2186F__INCLUDED_)

440
neo/tools/radiant/QE3.CPP Normal file
View File

@@ -0,0 +1,440 @@
/*
===========================================================================
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 "qe3.h"
#include <direct.h>
#include <sys/stat.h>
#include "WaitDlg.h"
QEGlobals_t g_qeglobals;
/*
=======================================================================================================================
=======================================================================================================================
*/
void WINAPI QE_CheckOpenGLForErrors(void) {
CString strMsg;
int i = qglGetError();
if (i != GL_NO_ERROR) {
if (i == GL_OUT_OF_MEMORY) {
//
// strMsg.Format("OpenGL out of memory error %s\nDo you wish to save before
// exiting?", gluErrorString((GLenum)i));
//
if (g_pParentWnd->MessageBox(strMsg, EDITOR_WINDOWTEXT " Error", MB_YESNO) == IDYES) {
Map_SaveFile(NULL, false);
}
exit(1);
}
else {
// strMsg.Format("Warning: OpenGL Error %s\n ", gluErrorString((GLenum)i));
common->Printf(strMsg.GetBuffer(0));
}
}
}
/*
=======================================================================================================================
=======================================================================================================================
*/
bool DoesFileExist(const char *pBuff, long &lSize) {
CFile file;
if (file.Open(pBuff, CFile::modeRead | CFile::shareDenyNone)) {
lSize += file.GetLength();
file.Close();
return true;
}
return false;
}
/*
=======================================================================================================================
=======================================================================================================================
*/
bool ExtractPath_and_Filename(const char *pPath, CString &strPath, CString &strFilename) {
CString strPathName = pPath;
int nSlash = strPathName.ReverseFind('\\');
if (nSlash >= 0) {
strPath = strPathName.Left(nSlash + 1);
strFilename = strPathName.Right(strPathName.GetLength() - nSlash - 1);
}
else {
strFilename = pPath;
}
return true;
}
/*
=======================================================================================================================
=======================================================================================================================
*/
void Map_Snapshot() {
CString strMsg;
//
// we need to do the following 1. make sure the snapshot directory exists (create
// it if it doesn't) 2. find out what the lastest save is based on number 3. inc
// that and save the map
//
CString strOrgPath, strOrgFile;
ExtractPath_and_Filename(currentmap, strOrgPath, strOrgFile);
AddSlash(strOrgPath);
strOrgPath += "snapshots";
bool bGo = true;
struct _stat Stat;
if (_stat(strOrgPath, &Stat) == -1) {
bGo = (_mkdir(strOrgPath) != -1);
}
AddSlash(strOrgPath);
if (bGo) {
int nCount = 0;
long lSize = 0;
CString strNewPath = strOrgPath;
strNewPath += strOrgFile;
CString strFile;
while (bGo) {
strFile.Format("%s.%i", strNewPath, nCount);
bGo = DoesFileExist(strFile, lSize);
nCount++;
}
// strFile has the next available slot
Map_SaveFile(strFile.GetBuffer(0), false);
Sys_SetTitle(currentmap);
if (lSize > 12 * 1024 * 1024) { // total size of saves > 4 mb
common->Printf
(
"The snapshot files in the [%s] directory total more than 4 megabytes. You might consider cleaning the directory up.",
strOrgPath
);
}
}
else {
strMsg.Format("Snapshot save failed.. unabled to create directory\n%s", strOrgPath);
g_pParentWnd->MessageBox(strMsg);
}
}
/*
=======================================================================================================================
QE_CheckAutoSave If five minutes have passed since making a change and the map hasn't been saved, save it out.
=======================================================================================================================
*/
void QE_CheckAutoSave(void) {
static bool inAutoSave = false;
static bool autoToggle = false;
if (inAutoSave) {
Sys_Status("Did not autosave due recursive entry into autosave routine\n");
return;
}
if ( !mapModified ) {
return;
}
inAutoSave = true;
if ( g_PrefsDlg.m_bAutoSave ) {
CString strMsg = g_PrefsDlg.m_bSnapShots ? "Autosaving snapshot..." : "Autosaving...";
Sys_Status(strMsg.GetBuffer(0), 0);
if (g_PrefsDlg.m_bSnapShots && stricmp(currentmap, "unnamed.map") != 0) {
Map_Snapshot();
} else {
Map_SaveFile(ValueForKey(g_qeglobals.d_project_entity, (autoToggle == 0) ? "autosave1" : "autosave2" ), false, true);
autoToggle ^= 1;
}
Sys_Status("Autosaving...Saved.", 0);
mapModified = 0; // DHM - _D3XP
} else {
common->Printf("Autosave skipped...\n");
Sys_Status("Autosave skipped...", 0);
}
inAutoSave = false;
}
/*
=======================================================================================================================
=======================================================================================================================
*/
const char *g_pPathFixups[] = {
"basepath",
// "remotebasepath",
"entitypath",
// "texturepath",
"autosave",
// "mapspath"
};
const int g_nPathFixupCount = sizeof(g_pPathFixups) / sizeof (const char *);
/*
=======================================================================================================================
QE_LoadProject
=======================================================================================================================
*/
bool QE_LoadProject(char *projectfile) {
char *data;
ID_TIME_T time;
common->Printf("QE_LoadProject (%s)\n", projectfile);
if ( fileSystem->ReadFile( projectfile, reinterpret_cast < void ** > (&data), &time) <= 0 ) {
return false;
}
g_strProject = projectfile;
g_PrefsDlg.m_strLastProject = projectfile;
g_PrefsDlg.SavePrefs();
CString strData = data;
fileSystem->FreeFile( data );
StartTokenParsing(strData.GetBuffer(0));
g_qeglobals.d_project_entity = Entity_Parse(true);
if (!g_qeglobals.d_project_entity) {
Error("Couldn't parse %s", projectfile);
}
// set here some default project settings you need
if (strlen(ValueForKey(g_qeglobals.d_project_entity, "brush_primit")) == 0) {
SetKeyValue(g_qeglobals.d_project_entity, "brush_primit", "0");
}
g_qeglobals.m_bBrushPrimitMode = IntForKey(g_qeglobals.d_project_entity, "brush_primit");
Eclass_InitForSourceDirectory(ValueForKey(g_qeglobals.d_project_entity, "entitypath"));
g_Inspectors->FillClassList(); // list in entity window
Map_New();
// FillTextureMenu();
FillBSPMenu();
return true;
}
/*
=======================================================================================================================
QE_SaveProject £
=======================================================================================================================
*/
bool QE_SaveProject(const char *pProjectFile) {
idFile *file = fileSystem->OpenFileWrite(pProjectFile);
if ( !file ) {
return false;
}
file->Write("{\n", 2);
int count = g_qeglobals.d_project_entity->epairs.GetNumKeyVals();
for (int i = 0; i < count; i++) {
file->WriteFloatString( "\"%s\" \"%s\"\n", g_qeglobals.d_project_entity->epairs.GetKeyVal(i)->GetKey().c_str(), g_qeglobals.d_project_entity->epairs.GetKeyVal(i)->GetValue().c_str());
}
file->Write("}\n", 2);
fileSystem->CloseFile( file );
return true;
}
/* QE_KeyDown */
#define SPEED_MOVE 32
#define SPEED_TURN 22.5
/*
=======================================================================================================================
ConnectEntities Sets target / name on the two entities selected from the first selected to the secon
=======================================================================================================================
*/
void ConnectEntities(void) {
entity_t *e1;
const char *target;
idStr strTarget;
int i, t;
if (g_qeglobals.d_select_count < 2) {
Sys_Status("Must have at least two brushes selected.", 0);
Sys_Beep();
return;
}
e1 = g_qeglobals.d_select_order[0]->owner;
for (i = 0; i < g_qeglobals.d_select_count; i++) {
if (g_qeglobals.d_select_order[i]->owner == world_entity) {
Sys_Status("Can't connect to the world.", 0);
Sys_Beep();
return;
}
}
for (i = 1; i < g_qeglobals.d_select_count; i++) {
if (e1 == g_qeglobals.d_select_order[i]->owner) {
Sys_Status("Brushes are from same entity.", 0);
Sys_Beep();
return;
}
}
target = ValueForKey(e1, "target");
if ( target && *target) {
for (t = 1; t < 2048; t++) {
target = ValueForKey(e1, va("target%i", t));
if (target && *target) {
continue;
} else {
break;
}
}
} else {
t = 0;
}
for (i = 1; i < g_qeglobals.d_select_count; i++) {
target = ValueForKey(g_qeglobals.d_select_order[i]->owner, "name");
if (target && *target) {
strTarget = target;
} else {
UniqueTargetName(strTarget);
}
if (t == 0) {
SetKeyValue(e1, "target", strTarget);
} else {
SetKeyValue(e1, va("target%i", t), strTarget);
}
t++;
}
Sys_UpdateWindows(W_XY | W_CAMERA);
Select_Deselect();
Select_Brush(g_qeglobals.d_select_order[1]);
}
/*
=======================================================================================================================
=======================================================================================================================
*/
bool QE_SingleBrush(bool bQuiet, bool entityOK) {
if ((selected_brushes.next == &selected_brushes) || (selected_brushes.next->next != &selected_brushes)) {
if (!bQuiet) {
Sys_Status("Error: you must have a single brush selected\n");
}
return false;
}
if (!entityOK && selected_brushes.next->owner->eclass->fixedsize) {
if (!bQuiet) {
Sys_Status("Error: you cannot manipulate fixed size entities\n");
}
return false;
}
return true;
}
/*
=======================================================================================================================
=======================================================================================================================
*/
void QE_Init(void) {
/* initialize variables */
g_qeglobals.d_gridsize = 8;
g_qeglobals.d_showgrid = true;
/*
* other stuff £
* FIXME: idMaterial Texture_Init (true); Cam_Init (); XY_Init ();
*/
Z_Init();
}
int g_numbrushes, g_numentities;
/*
=======================================================================================================================
=======================================================================================================================
*/
void QE_CountBrushesAndUpdateStatusBar(void) {
static int s_lastbrushcount, s_lastentitycount;
static bool s_didonce;
// entity_t *e;
brush_t *b, *next;
g_numbrushes = 0;
g_numentities = 0;
if (active_brushes.next != NULL) {
for (b = active_brushes.next; b != NULL && b != &active_brushes; b = next) {
next = b->next;
if (b->brush_faces) {
if (!b->owner->eclass->fixedsize) {
g_numbrushes++;
}
else {
g_numentities++;
}
}
}
}
/*
* if ( entities.next != NULL ) { for ( e = entities.next ; e != &entities &&
* g_numentities != MAX_MAP_ENTITIES ; e = e->next) { g_numentities++; } }
*/
if (((g_numbrushes != s_lastbrushcount) || (g_numentities != s_lastentitycount)) || (!s_didonce)) {
Sys_UpdateStatusBar();
s_lastbrushcount = g_numbrushes;
s_lastentitycount = g_numentities;
s_didonce = true;
}
}

495
neo/tools/radiant/QE3.H Normal file
View File

@@ -0,0 +1,495 @@
/*
===========================================================================
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 __QE3_H__
#define __QE3_H__
#ifdef ID_DEBUG_MEMORY
#undef new
#undef DEBUG_NEW
#define DEBUG_NEW new
#endif
// this define to use HTREEITEM and MFC stuff in the headers
#define QERTYPES_USE_MFC
#include "qertypes.h"
#include "cmdlib.h"
#include "parse.h"
#include <commctrl.h>
#include "afxres.h"
#include "../../sys/win32/rc/Radiant_resource.h" // main symbols
#include "../../sys/win32/win_local.h"
#include "qedefs.h"
// stuff from old qfiles.h
#define MAX_MAP_ENTITIES 2048
const int MAX_MOVE_POINTS = 4096;
const int MAX_MOVE_PLANES = 2048;
// assume that all maps fit within this
const float HUGE_DISTANCE = 100000;
#include "textures.h"
#include "EditorBrush.h"
#include "EditorEntity.h"
#include "EditorMap.h"
#include "select.h"
#include "splines.h"
#include "z.h"
#include "mru.h"
#include "waitdlg.h"
#include "MainFrm.h"
#include "PrefsDlg.h"
#include "FindTextureDlg.h"
#include "dialogtextures.h"
#include "InspectorDialog.h"
#include "undo.h"
#include "PMESH.H"
// the dec offsetof macro doesn't work very well...
#define myoffsetof(type,identifier) ((size_t)&((type *)0)->identifier)
void Error (char *error, ...);
void Warning (char *error, ...);
typedef struct
{
int p1, p2;
face_t *f1, *f2;
} pedge_t;
typedef struct
{
int iSize;
int iTexMenu; // nearest, linear, etc
float fGamma; // gamma for textures
char szProject[256]; // last project loaded
idVec3 colors[COLOR_LAST];
bool show_names;
bool show_coordinates;
int exclude;
float m_nTextureTweak;
bool editorExpanded;
RECT oldEditRect;
bool showSoundAlways;
bool showSoundWhenSelected;
} SavedInfo_t;
//
// system functions
//
// TTimo NOTE: WINAPI funcs can be accessed by plugins
void Sys_UpdateStatusBar( void );
void WINAPI Sys_UpdateWindows (int bits);
void Sys_Beep (void);
double Sys_DoubleTime (void);
void Sys_GetCursorPos (int *x, int *y);
void Sys_SetCursorPos (int x, int y);
void Sys_SetTitle (const char *text);
void Sys_BeginWait (void);
bool Sys_Waiting();
void Sys_EndWait (void);
void Sys_Status(const char *psz, int part = -1);
/*
** most of the QE globals are stored in this structure
*/
typedef struct
{
bool d_showgrid;
float d_gridsize;
int rotateAxis; // 0, 1 or 2
int flatRotation; // 0, 1 or 2, 0 == off, 1 == rotate about the rotation origin, 1 == rotate about the selection mid point
int d_num_entities;
entity_t *d_project_entity;
idVec3 d_new_brush_bottom, d_new_brush_top;
HINSTANCE d_hInstance;
idVec3 d_points[MAX_POINTS];
int d_numpoints;
pedge_t d_edges[MAX_EDGES];
int d_numedges;
int d_num_move_points;
idVec3 *d_move_points[MAX_MOVE_POINTS];
int d_num_move_planes;
idPlane *d_move_planes[MAX_MOVE_PLANES];
qtexture_t *d_qtextures;
texturewin_t d_texturewin;
int d_pointfile_display_list;
LPMRUMENU d_lpMruMenu;
SavedInfo_t d_savedinfo;
int d_workcount;
// connect entities uses the last two brushes selected
int d_select_count;
brush_t *d_select_order[MAX_MAP_ENTITIES];
idVec3 d_select_translate; // for dragging w/o making new display lists
select_t d_select_mode;
idPointListInterface *selectObject; //
int d_font_list;
int d_parsed_brushes;
bool show_blocks;
// Timo
// tells if we are internally using brush primitive (texture coordinates and map format)
// this is a shortcut for IntForKey( g_qeglobals.d_project_entity, "brush_primit" )
// NOTE: must keep the two ones in sync
BOOL m_bBrushPrimitMode;
// used while importing brush data from file or memory buffer
// tells if conversion between map format and internal preferences ( m_bBrushPrimitMode ) is needed
bool bNeedConvert;
bool bOldBrushes;
bool bPrimitBrushes;
float mapVersion;
idVec3 d_vAreaTL;
idVec3 d_vAreaBR;
// tells if we are using .INI files for prefs instead of registry
bool use_ini;
// even in .INI mode we use the registry for all void* prefs
char use_ini_registry[64];
//Timo
// tells we have surface properties plugin
bool bSurfacePropertiesPlugin;
// tells we are using a BSP frontend plugin
bool bBSPFrontendPlugin;
// the editor has its own soundWorld and renderWorld, completely distinct from the game
idRenderWorld *rw;
idSoundWorld *sw;
} QEGlobals_t;
void Pointfile_Delete (void);
void WINAPI Pointfile_Check (void);
void Pointfile_Next (void);
void Pointfile_Prev (void);
void Pointfile_Clear (void);
void Pointfile_Draw( void );
void Pointfile_Load( void );
//
// drag.c
//
void Drag_Begin (int x, int y, int buttons,
const idVec3 &xaxis, const idVec3 &yaxis,
const idVec3 &origin, const idVec3 &dir);
void Drag_MouseMoved (int x, int y, int buttons);
void Drag_MouseUp (int nButtons = 0);
extern bool g_moveOnly;
//
// csg.c
//
void CSG_MakeHollow (void);
void CSG_Subtract (void);
void CSG_Merge (void);
//
// vertsel.c
//
void SetupVertexSelection (void);
void SelectEdgeByRay (idVec3 org, idVec3 dir);
void SelectVertexByRay (idVec3 org, idVec3 dir);
void ConnectEntities (void);
extern int update_bits;
extern int screen_width;
extern int screen_height;
extern HANDLE bsp_process;
extern HANDLE g_hBSPOutput;
extern HANDLE g_hBSPInput;
char *TranslateString (char *buf);
void ProjectDialog (void);
void FillTextureMenu (CStringArray* pArray = NULL);
void FillBSPMenu (void);
BOOL CALLBACK Win_Dialog (
HWND hwndDlg, // handle to dialog box
UINT uMsg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
//
// win_cam.c
//
void WCam_Create (HINSTANCE hInstance);
//
// win_xy.c
//
void WXY_Create (HINSTANCE hInstance);
//
// win_z.c
//
void WZ_Create (HINSTANCE hInstance);
//
// win_ent.c
//
//
// win_main.c
//
void Main_Create (HINSTANCE hInstance);
extern bool SaveWindowState(HWND hWnd, const char *pszName);
extern bool LoadWindowState(HWND hWnd, const char *pszName);
extern bool SaveRegistryInfo(const char *pszName, void *pvBuf, long lSize);
extern bool LoadRegistryInfo(const char *pszName, void *pvBuf, long *plSize);
// win_dlg.c
void DoGamma(void);
void DoFind(void);
void DoRotate(void);
void DoSides(bool bCone = false, bool bSphere = false, bool bTorus = false);
void DoAbout(void);
void DoSurface();
/*
** QE function declarations
*/
void QE_CheckAutoSave( void );
void QE_CountBrushesAndUpdateStatusBar( void );
void WINAPI QE_CheckOpenGLForErrors(void);
void QE_ExpandBspString (char *bspaction, char *out, char *mapname, bool useTemps);
void QE_Init (void);
bool QE_KeyDown (int key, int nFlags = 0);
bool QE_LoadProject (char *projectfile);
bool QE_SingleBrush (bool bQuiet = false, bool entityOK = false);
// sys stuff
void Sys_MarkMapModified (void);
/*
** QE Win32 function declarations
*/
int WINAPI QEW_SetupPixelFormat(HDC hDC, bool zbuffer );
/*
** extern declarations
*/
extern QEGlobals_t g_qeglobals;
extern int mapModified; // for quit confirmation (0 = clean, 1 = unsaved,
//++timo clean (moved into qertypes.h)
//enum VIEWTYPE {YZ, XZ, XY};
extern bool g_bAxialMode;
extern int g_axialAnchor;
extern int g_axialDest;
extern void Face_FlipTexture_BrushPrimit(face_t *face, bool y);
extern void Brush_FlipTexture_BrushPrimit(brush_t *b, bool y);
// Timo
// new brush primitive stuff
//void ComputeAxisBase( idVec3 &normal,idVec3 &texS,idVec3 &texT );
void FaceToBrushPrimitFace(face_t *f);
void EmitBrushPrimitTextureCoordinates(face_t *, idWinding *, patchMesh_t *patch = NULL);
// EmitTextureCoordinates, is old code used for brush to brush primitive conversion
void EmitTextureCoordinates ( idVec5 &xyzst, const idMaterial *q, face_t *f, bool force = false);
void BrushPrimit_Parse(brush_t *, bool newFormat, const idVec3 origin);
// compute a fake shift scale rot representation from the texture matrix
void TexMatToFakeTexCoords( float texMat[2][3], float shift[2], float *rot, float scale[2] );
void FakeTexCoordsToTexMat( float shift[2], float rot, float scale[2], float texMat[2][3] );
void ConvertTexMatWithQTexture( brushprimit_texdef_t *texMat1, const idMaterial *qtex1, brushprimit_texdef_t *texMat2, const idMaterial *qtex2, float sScale = 1.0, float tScale = 1.0 );
// texture locking
void Face_MoveTexture_BrushPrimit(face_t *f, idVec3 delta);
void Select_ShiftTexture_BrushPrimit( face_t *f, float x, float y, bool autoAdjust );
void RotateFaceTexture_BrushPrimit(face_t *f, int nAxis, float fDeg, idVec3 vOrigin );
// used in CCamWnd::ShiftTexture_BrushPrimit
void ComputeBest2DVector( idVec3 v, idVec3 X, idVec3 Y, int &x, int &y );
void ApplyMatrix_BrushPrimit(face_t *f, idMat3 matrix, idVec3 origin);
// low level functions .. put in mathlib?
#define BPMatCopy(a,b) {b[0][0] = a[0][0]; b[0][1] = a[0][1]; b[0][2] = a[0][2]; b[1][0] = a[1][0]; b[1][1] = a[1][1]; b[1][2] = a[1][2];}
// apply a scale transformation to the BP matrix
#define BPMatScale(m,sS,sT) {m[0][0]*=sS; m[1][0]*=sS; m[0][1]*=sT; m[1][1]*=sT;}
// apply a translation transformation to a BP matrix
#define BPMatTranslate(m,s,t) {m[0][2] += m[0][0]*s + m[0][1]*t; m[1][2] += m[1][0]*s+m[1][1]*t;}
// 2D homogeneous matrix product C = A*B
void BPMatMul(float A[2][3], float B[2][3], float C[2][3]);
// apply a rotation (degrees)
void BPMatRotate(float A[2][3], float theta);
#ifdef _DEBUG
void BPMatDump(float A[2][3]);
#endif
//
// eclass.cpp
//
extern bool parsing_single;
extern bool eclass_found;
extern eclass_t *eclass_e;
void Eclass_ScanFile( char *filename );
void FillClassList (void);
extern bool g_bShowLightVolumes;
extern bool g_bShowLightTextures;
extern const idMaterial *Texture_LoadLight(const char *name);
#define FONT_HEIGHT 10
void UniqueTargetName(idStr& rStr);
#define MAP_VERSION 2.0
extern CMainFrame* g_pParentWnd;
extern CString g_strAppPath;
extern CPrefsDlg& g_PrefsDlg;
extern CFindTextureDlg& g_dlgFind;
extern idCVar radiant_entityMode;
// layout styles
#define QR_SPLIT 0
#define QR_QE4 1
#define QR_4WAY 2
#define QR_SPLITZ 3
// externs
extern void AddSlash(CString&);
extern void DLLBuildDone();
extern void CleanUpEntities();
extern void QE_CountBrushesAndUpdateStatusBar();
extern void QE_CheckAutoSave();
extern qtexture_t *notexture;
extern qtexture_t *current_texture;
extern bool SaveWindowState(HWND hWnd, const char *pszName);
extern void Map_Snapshot();
extern void WXY_Print();
extern void AddProp( void );
extern int inspector_mode;
extern bool g_bRotateMode;
extern bool g_bClipMode;
extern bool g_bScaleMode;
extern int g_nScaleHow;
extern bool g_bPathMode;
extern void RunScript(char* pBuffer);
extern HINSTANCE g_hOpenGL32;
extern void FindReplaceTextures(const char* pFind, const char* pReplace, bool bSelected, bool bForce);
extern void DoProjectSettings();
extern bool region_active;
extern void Texture_ShowDirectory (char* pPath, bool Linked = false);
extern void Map_ImportFile (char *filename);
extern void Map_SaveSelected(char* pFilename);
extern bool g_bNewFace;
extern bool g_bSwitch;
extern brush_t g_brFrontSplits;
extern brush_t g_brBackSplits;
extern CClipPoint g_Clip1;
extern CClipPoint g_Clip2;
extern brush_t* g_pSplitList;
extern CClipPoint g_PathPoints[256];
extern void AcquirePath(int nCount, PFNPathCallback* pFunc);
extern bool g_bScreenUpdates;
extern SCommandInfo g_Commands[];
extern int g_nCommandCount;
extern SKeyInfo g_Keys[];
extern int g_nKeyCount;
extern int inspector_mode;
extern const char *bsp_commands[256];
extern void HandlePopup(CWnd* pWindow, unsigned int uId);
extern z_t z;
extern CString g_strProject;
extern void TextureAxisFromPlane( const idPlane &pln, idVec3 &xv, idVec3 &yv);
extern bool QE_SaveProject (const char* pProjectFile);
extern void Clamp(float& f, int nClamp);
extern bool WriteFileString( FILE *fp, char *string, ... );
extern void MemFile_fprintf(CMemFile* pMemFile, const char* pText, ...);
extern void SaveWindowPlacement(HWND hwnd, const char* pName);
extern bool LoadWindowPlacement(HWND hwnd, const char* pName);
extern bool ConfirmModified (void);
extern void DoPatchInspector();
void UpdatePatchInspector();
extern int g_nSmartX;
extern int g_nSmartY;
extern brush_t* CreateEntityBrush(int x, int y, CXYWnd* pWnd);
int PointInMoveList( idVec3 *pf );
extern bool ByeByeSurfaceDialog();
extern void UpdateSurfaceDialog();
extern void UpdateLightInspector();
BOOL UpdateEntitySel(eclass_t *pec);
void SetInspectorMode(int iType);
BOOL GetSelectAllCriteria(CString &strKey, CString &strVal);
int GetCvarInt(const char *name, const int def);
const char *GetCvarString(const char *name, const char *def);
void SetCvarInt(const char *name, const int value);
void SetCvarString(const char *name, const char *value);
void SetCvarBinary(const char *name, void *pv, int size);
bool GetCvarBinary(const char *name, void *pv, int size);
void UpdateRadiantColor( float r, float g, float b, float a );
#endif /* !__QE3_H__ */

171
neo/tools/radiant/QEDEFS.H Normal file
View File

@@ -0,0 +1,171 @@
/*
===========================================================================
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 __QEDEFS_H__
#define __QEDEFS_H__
#define QE_VERSION 0x0501
#define QE3_STYLE (WS_OVERLAPPED | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_THICKFRAME | WS_CAPTION | WS_SYSMENU | WS_CHILD)
#define QE3_STYLE2 (WS_OVERLAPPED | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_MINIMIZEBOX | WS_THICKFRAME | WS_CAPTION | WS_SYSMENU)
#define QE3_CHILDSTYLE (WS_OVERLAPPED | WS_MINIMIZEBOX | WS_THICKFRAME | WS_CAPTION | WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_MAXIMIZEBOX)
#define QE3_SPLITTER_STYLE (WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS)
#define QE_AUTOSAVE_INTERVAL 5 // number of minutes between autosaves
#define _3DFXCAMERA_WINDOW_CLASS "Q3DFXCamera"
#define CAMERA_WINDOW_CLASS "QCamera"
#define XY_WINDOW_CLASS "QXY"
#define Z_WINDOW_CLASS "QZ"
#define ENT_WINDOW_CLASS "QENT"
#define TEXTURE_WINDOW_CLASS "QTEX"
#define ZWIN_WIDTH 40
#define CWIN_SIZE (0.4)
#define MAX_EDGES 512
#define MAX_POINTS 1024
#define CMD_TEXTUREWAD 60000
#define CMD_BSPCOMMAND 61000
#define PITCH 0
#define YAW 1
#define ROLL 2
#define QE_TIMER0 1
#define QE_TIMER1 2
#define PLANE_X 0
#define PLANE_Y 1
#define PLANE_Z 2
#define PLANE_ANYX 3
#define PLANE_ANYY 4
#define PLANE_ANYZ 5
// #define ON_EPSILON 0.01
#define KEY_FORWARD 1
#define KEY_BACK 2
#define KEY_TURNLEFT 4
#define KEY_TURNRIGHT 8
#define KEY_LEFT 16
#define KEY_RIGHT 32
#define KEY_LOOKUP 64
#define KEY_LOOKDOWN 128
#define KEY_UP 256
#define KEY_DOWN 512
// xy.c
#define EXCLUDE_LIGHTS 0x00000001
#define EXCLUDE_ENT 0x00000002
#define EXCLUDE_PATHS 0x00000004
#define EXCLUDE_DYNAMICS 0x00000008
#define EXCLUDE_WORLD 0x00000010
#define EXCLUDE_CLIP 0x00000020
//#define EXCLUDE_DETAIL 0x00000040
#define EXCLUDE_CURVES 0x00000080
#define INCLUDE_EASY 0x00000100
#define INCLUDE_NORMAL 0x00000200
#define INCLUDE_HARD 0x00000400
#define INCLUDE_DEATHMATCH 0x00000800
#define EXCLUDE_HINT 0x00001000
#define EXCLUDE_CAULK 0x00002000
#define EXCLUDE_ANGLES 0x00004000
#define EXCLUDE_VISPORTALS 0x00008000
#define EXCLUDE_NODRAW 0x00010000
#define EXCLUDE_COMBATNODES 0x00020000
#define EXCLUDE_TRIGGERS 0x00040000
// _D3XP
#define EXCLUDE_MODELS 0x00080000
//
// menu indexes for modifying menus
//
#define MENU_VIEW 2
#define MENU_BSP 4
#define MENU_TEXTURE 6
#define MENU_PLUGIN 11
// odd things not in windows header...
#define VK_COMMA 188
#define VK_PERIOD 190
/*
** window bits
*/
//++timo moved to qertypes.h
// clean
/*
#define W_CAMERA 0x0001
#define W_XY 0x0002
#define W_XY_OVERLAY 0x0004
#define W_Z 0x0008
#define W_TEXTURE 0x0010
#define W_Z_OVERLAY 0x0020
#define W_CONSOLE 0x0040
#define W_ENTITY 0x0080
#define W_CAMERA_IFON 0x0100
#define W_XZ 0x0200 //--| only used for patch vertex manip stuff
#define W_YZ 0x0400 //--|
#define W_ALL 0xFFFFFFFF
*/
enum {
COLOR_TEXTUREBACK,
COLOR_GRIDBACK,
COLOR_GRIDMINOR,
COLOR_GRIDMAJOR,
COLOR_CAMERABACK,
COLOR_ENTITY,
COLOR_GRIDBLOCK,
COLOR_GRIDTEXT,
COLOR_BRUSHES,
COLOR_SELBRUSHES,
COLOR_CLIPPER,
COLOR_VIEWNAME,
COLOR_PRECISION_CROSSHAIR,
COLOR_LAST
};
// classes
#define ENTITY_WIREFRAME 0x00001
#define ENTITY_SKIN_MODEL 0x00010
#define ENTITY_SELECTED_ONLY 0x00100
#define ENTITY_BOXED 0x01000
// menu settings
#define ENTITY_WIRE 0x00001
#define ENTITY_SKINNED 0x00002
#endif

View File

@@ -0,0 +1,429 @@
/*
===========================================================================
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 _QERTYPE_H
#define _QERTYPE_H
#define MAXPOINTS 16
class texdef_t
{
public:
texdef_t()
{
name = "";
shift[0] = shift[1] = 0.0;
rotate = 0;
scale[0] = scale[1] = 0;
value = 0;
}
~texdef_t()
{
if ( name && name[0] ) {
delete []name;
}
name = NULL;
}
void SetName( const char *p )
{
if ( name && name[0] ) {
delete []name;
}
if ( p && p[0] ) {
name = strcpy( new char[strlen(p)+1], p );
}
else {
name = "";
}
}
texdef_t& operator =(const texdef_t& rhs)
{
if ( &rhs != this ) {
SetName(rhs.name);
shift[0] = rhs.shift[0];
shift[1] = rhs.shift[1];
rotate = rhs.rotate;
scale[0] = rhs.scale[0];
scale[1] = rhs.scale[1];
value = rhs.value;
}
return *this;
}
//char name[128];
char * name;
float shift[2];
float rotate;
float scale[2];
int value;
};
// Timo
// new brush primitive texdef
//typedef struct brushprimit_texdef_s
//{
// float coords[2][3];
//} brushprimit_texdef_t;
class brushprimit_texdef_t {
public:
float coords[2][3];
brushprimit_texdef_t() {
memset(&coords, 0, sizeof(coords));
coords[0][0] = 1.0;
coords[1][1] = 1.0;
}
};
class texturewin_t
{
public:
texturewin_t() {
memset(&brushprimit_texdef.coords, 0, sizeof(brushprimit_texdef.coords));
brushprimit_texdef.coords[0][0] = 1.0;
brushprimit_texdef.coords[1][1] = 1.0;
}
~texturewin_t() {
}
int width, height;
int originy;
// add brushprimit_texdef_t for brush primitive coordinates storage
brushprimit_texdef_t brushprimit_texdef;
int m_nTotalHeight;
// surface plugin, must be casted to a IPluginTexdef*
void* pTexdef;
texdef_t texdef;
};
#define QER_TRANS 0x00000001
#define QER_NOCARVE 0x00000002
typedef struct qtexture_s
{
struct qtexture_s *next;
char name[64]; // includes partial directory and extension
int width, height;
int contents;
int flags;
int value;
int texture_number; // gl bind number
// name of the .shader file
char shadername[1024]; // old shader stuff
bool bFromShader; // created from a shader
float fTrans; // amount of transparency
int nShaderFlags; // qer_ shader flags
idVec3 color; // for flat shade mode
bool inuse; // true = is present on the level
// cast this one to an IPluginQTexture if you are using it
// NOTE: casting can be done with a GETPLUGINQTEXTURE defined in isurfaceplugin.h
// TODO: if the __ISURFACEPLUGIN_H_ header is used, use a union { void *pData; IPluginQTexture *pPluginQTexture } kind of thing ?
void *pData;
//++timo FIXME: this is the actual filename of the texture
// this will be removed after shader code cleanup
char filename[64];
} qtexture_t;
//++timo texdef and brushprimit_texdef are static
// TODO : do dynamic ?
typedef struct face_s
{
struct face_s *next;
struct face_s *original; //used for vertex movement
idVec3 planepts[3];
idVec3 orgplanepts[3]; // used for arbitrary rotation
texdef_t texdef;
idPlane plane;
idPlane originalPlane;
bool dirty;
idWinding *face_winding;
idVec3 d_color;
const idMaterial *d_texture;
// Timo new brush primit texdef
brushprimit_texdef_t brushprimit_texdef;
// cast this one to an IPluginTexdef if you are using it
// NOTE: casting can be done with a GETPLUGINTEXDEF defined in isurfaceplugin.h
// TODO: if the __ISURFACEPLUGIN_H_ header is used, use a union { void *pData; IPluginTexdef *pPluginTexdef } kind of thing ?
void *pData;
} face_t;
typedef struct {
idVec3 xyz;
float sideST[2];
float capST[2];
} curveVertex_t;
typedef struct {
curveVertex_t v[2];
} sideVertex_t;
#define MIN_PATCH_WIDTH 3
#define MIN_PATCH_HEIGHT 3
#define MAX_PATCH_WIDTH 64
#define MAX_PATCH_HEIGHT 64
// patch type info
// type in lower 16 bits, flags in upper
// endcaps directly follow this patch in the list
// types
#define PATCH_GENERIC 0x00000000 // generic flat patch
#define PATCH_CYLINDER 0x00000001 // cylinder
#define PATCH_BEVEL 0x00000002 // bevel
#define PATCH_ENDCAP 0x00000004 // endcap
#define PATCH_HEMISPHERE 0x00000008 // hemisphere
#define PATCH_CONE 0x00000010 // cone
#define PATCH_TRIANGLE 0x00000020 // simple tri, assumes 3x3 patch
// behaviour styles
#define PATCH_CAP 0x00001000 // flat patch applied as a cap
#define PATCH_SEAM 0x00002000 // flat patch applied as a seam
#define PATCH_THICK 0x00004000 // patch applied as a thick portion
// styles
#define PATCH_BEZIER 0x00000000 // default bezier
#define PATCH_BSPLINE 0x10000000 // bspline
#define PATCH_TYPEMASK 0x00000fff //
#define PATCH_BTYPEMASK 0x0000f000 //
#define PATCH_STYLEMASK 0xffff0000 //
struct brush_s;
typedef struct brush_s brush_t;
typedef struct {
int width, height; // in control points, not patches
int horzSubdivisions;
int vertSubdivisions;
bool explicitSubdivisions;
int contents, flags, value, type;
const idMaterial *d_texture;
idDrawVert *verts;
//idDrawVert *ctrl;
brush_t * pSymbiot;
bool bSelected;
bool bOverlay;
int nListID;
int nListIDCam;
int nListSelected;
idDict * epairs;
// cast this one to an IPluginTexdef if you are using it
// NOTE: casting can be done with a GETPLUGINTEXDEF defined in isurfaceplugin.h
// TODO: if the __ISURFACEPLUGIN_H_ header is used, use a union { void *pData; IPluginTexdef *pPluginTexdef } kind of thing ?
void * pData;
ID_INLINE idDrawVert &ctrl( int col, int row ) {
if ( col < 0 || col >= width || row < 0 || row >= height ) {
common->Warning( "patchMesh_t::ctrl: control point out of range" );
return verts[0];
}
else {
return verts[row * width + col];
}
}
} patchMesh_t;
enum {
LIGHT_TARGET,
LIGHT_RIGHT,
LIGHT_UP,
LIGHT_RADIUS,
LIGHT_X,
LIGHT_Y,
LIGHT_Z,
LIGHT_START,
LIGHT_END,
LIGHT_CENTER
};
typedef struct brush_s
{
struct brush_s *prev, *next; // links in active/selected
struct brush_s *oprev, *onext; // links in entity
brush_t * list; //keep a handy link to the list its in
struct entity_s *owner;
idVec3 mins, maxs;
idVec3 lightCenter; // for moving the shading center of point lights
idVec3 lightRight;
idVec3 lightTarget;
idVec3 lightUp;
idVec3 lightRadius;
idVec3 lightOffset;
idVec3 lightColor;
idVec3 lightStart;
idVec3 lightEnd;
bool pointLight;
bool startEnd;
int lightTexture;
bool trackLightOrigin; // this brush is a special case light brush
bool entityModel;
face_t *brush_faces;
bool bModelFailed;
//
// curve brush extensions
// all are derived from brush_faces
bool hiddenBrush;
bool forceWireFrame;
bool forceVisibile;
patchMesh_t *pPatch;
struct entity_s *pUndoOwner;
int undoId; //undo ID
int redoId; //redo ID
int ownerId; //entityId of the owner entity for undo
// TTimo: HTREEITEM is MFC, some plugins really don't like it
#ifdef QERTYPES_USE_MFC
int numberId; // brush number
HTREEITEM itemOwner; // owner for grouping
#else
int numberId;
DWORD itemOwner;
#endif
idRenderModel *modelHandle;
// brush primitive only
idDict epairs;
} brush_t;
#define MAX_FLAGS 8
typedef struct trimodel_t
{
idVec3 v[3];
float st[3][2];
} trimodel;
// eclass show flags
#define ECLASS_LIGHT 0x00000001
#define ECLASS_ANGLE 0x00000002
#define ECLASS_PATH 0x00000004
#define ECLASS_MISCMODEL 0x00000008
#define ECLASS_PLUGINENTITY 0x00000010
#define ECLASS_PROJECTEDLIGHT 0x00000020
#define ECLASS_WORLDSPAWN 0x00000040
#define ECLASS_SPEAKER 0x00000080
#define ECLASS_PARTICLE 0x00000100
#define ECLASS_ROTATABLE 0x00000200
#define ECLASS_CAMERAVIEW 0x00000400
#define ECLASS_MOVER 0x00000800
#define ECLASS_ENV 0x00001000
#define ECLASS_COMBATNODE 0x00002000
#define ECLASS_LIQUID 0x00004000
enum EVAR_TYPES {
EVAR_STRING,
EVAR_INT,
EVAR_FLOAT,
EVAR_BOOL,
EVAR_COLOR,
EVAR_MATERIAL,
EVAR_MODEL,
EVAR_GUI,
EVAR_SOUND
};
typedef struct evar_s {
int type;
idStr name;
idStr desc;
} evar_t;
typedef struct eclass_s
{
struct eclass_s *next;
idStr name;
bool fixedsize;
bool unknown; // wasn't found in source
idVec3 mins, maxs;
idVec3 color;
texdef_t texdef;
idStr comments;
idStr desc;
idRenderModel *modelHandle;
idRenderModel *entityModel;
int nFrame;
unsigned int nShowFlags;
idStr defMaterial;
idDict args;
idDict defArgs;
idList<evar_t> vars;
HMODULE hPlug;
} eclass_t;
extern eclass_t *eclass;
/*
** window bits
*/
#define W_CAMERA 0x0001
#define W_XY 0x0002
#define W_XY_OVERLAY 0x0004
#define W_Z 0x0008
#define W_TEXTURE 0x0010
#define W_Z_OVERLAY 0x0020
#define W_CONSOLE 0x0040
#define W_ENTITY 0x0080
#define W_CAMERA_IFON 0x0100
#define W_XZ 0x0200 //--| only used for patch vertex manip stuff
#define W_YZ 0x0400 //--|
#define W_MEDIA 0x1000
#define W_GAME 0x2000
#define W_ALL 0xFFFFFFFF
// used in some Drawing routines
enum VIEWTYPE {YZ, XZ, XY};
#endif

View File

@@ -0,0 +1,472 @@
/*
===========================================================================
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 "qe3.h"
#include "radiant.h"
#include "MainFrm.h"
#include "lightdlg.h"
#include <process.h> // for _beginthreadex and _endthreadex
#include <ddeml.h> // for MSGF_DDEMGR
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
idCVar radiant_entityMode( "radiant_entityMode", "0", CVAR_TOOL | CVAR_ARCHIVE, "" );
/////////////////////////////////////////////////////////////////////////////
// CRadiantApp
BEGIN_MESSAGE_MAP(CRadiantApp, CWinApp)
//{{AFX_MSG_MAP(CRadiantApp)
ON_COMMAND(ID_HELP, OnHelp)
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRadiantApp construction
CRadiantApp::CRadiantApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CRadiantApp object
CRadiantApp theApp;
HINSTANCE g_DoomInstance = NULL;
bool g_editorAlive = false;
void RadiantPrint( const char *text ) {
if ( g_editorAlive && g_Inspectors ) {
if (g_Inspectors->consoleWnd.GetSafeHwnd()) {
g_Inspectors->consoleWnd.AddText( text );
}
}
}
void RadiantShutdown( void ) {
theApp.ExitInstance();
}
/*
=================
RadiantInit
This is also called when you 'quit' in doom
=================
*/
void RadiantInit( void ) {
// make sure the renderer is initialized
if ( !renderSystem->IsOpenGLRunning() ) {
common->Printf( "no OpenGL running\n" );
return;
}
g_editorAlive = true;
// allocate a renderWorld and a soundWorld
if ( g_qeglobals.rw == NULL ) {
g_qeglobals.rw = renderSystem->AllocRenderWorld();
g_qeglobals.rw->InitFromMap( NULL );
}
if ( g_qeglobals.sw == NULL ) {
g_qeglobals.sw = soundSystem->AllocSoundWorld( g_qeglobals.rw );
}
if ( g_DoomInstance ) {
if ( ::IsWindowVisible( win32.hWnd ) ) {
::ShowWindow( win32.hWnd, SW_HIDE );
g_pParentWnd->ShowWindow( SW_SHOW );
g_pParentWnd->SetFocus();
}
} else {
Sys_GrabMouseCursor( false );
g_DoomInstance = win32.hInstance;
CWinApp* pApp = AfxGetApp();
CWinThread *pThread = AfxGetThread();
InitAfx();
// App global initializations (rare)
pApp->InitApplication();
// Perform specific initializations
pThread->InitInstance();
qglFinish();
//qwglMakeCurrent(0, 0);
qwglMakeCurrent(win32.hDC, win32.hGLRC);
// hide the doom window by default
::ShowWindow( win32.hWnd, SW_HIDE );
}
}
extern void Map_VerifyCurrentMap(const char *map);
void RadiantSync( const char *mapName, const idVec3 &viewOrg, const idAngles &viewAngles ) {
if ( g_DoomInstance == NULL ) {
RadiantInit();
}
if ( g_DoomInstance ) {
idStr osPath;
osPath = fileSystem->RelativePathToOSPath( mapName );
Map_VerifyCurrentMap( osPath );
idAngles flip = viewAngles;
flip.pitch = -flip.pitch;
g_pParentWnd->GetCamera()->SetView( viewOrg, flip );
g_pParentWnd->SetFocus();
Sys_UpdateWindows( W_ALL );
g_pParentWnd->RoutineProcessing();
}
}
void RadiantRun( void ) {
static bool exceptionErr = false;
int show = ::IsWindowVisible(win32.hWnd);
try {
if (!exceptionErr && !show) {
//qglPushAttrib(GL_ALL_ATTRIB_BITS);
qglDepthMask(true);
theApp.Run();
//qglPopAttrib();
//qwglMakeCurrent(0, 0);
qwglMakeCurrent(win32.hDC, win32.hGLRC);
}
}
catch( idException &ex ) {
::MessageBox(NULL, ex.error, "Exception error", MB_OK);
RadiantShutdown();
}
}
/////////////////////////////////////////////////////////////////////////////
// CRadiantApp initialization
HINSTANCE g_hOpenGL32 = NULL;
HINSTANCE g_hOpenGL = NULL;
bool g_bBuildList = false;
BOOL CRadiantApp::InitInstance()
{
//g_hOpenGL32 = ::LoadLibrary("opengl32.dll");
// AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
//AfxEnableMemoryTracking(FALSE);
#ifdef _AFXDLL
//Enable3dControls(); // Call this when using MFC in a shared DLL
#else
//Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// If there's a .INI file in the directory use it instead of registry
char RadiantPath[_MAX_PATH];
GetModuleFileName( NULL, RadiantPath, _MAX_PATH );
// search for exe
CFileFind Finder;
Finder.FindFile( RadiantPath );
Finder.FindNextFile();
// extract root
CString Root = Finder.GetRoot();
// build root\*.ini
CString IniPath = Root + "\\REGISTRY.INI";
// search for ini file
Finder.FindNextFile();
if (Finder.FindFile( IniPath ))
{
Finder.FindNextFile();
// use the .ini file instead of the registry
free((void*)m_pszProfileName);
m_pszProfileName=_tcsdup(_T(Finder.GetFilePath()));
// look for the registry key for void* buffers storage ( these can't go into .INI files )
int i=0;
CString key;
HKEY hkResult;
DWORD dwDisp;
DWORD type;
char iBuf[3];
do
{
sprintf( iBuf, "%d", i );
key = "Software\\Q3Radiant\\IniPrefs" + CString(iBuf);
// does this key exists ?
if ( RegOpenKeyEx( HKEY_CURRENT_USER, key, 0, KEY_ALL_ACCESS, &hkResult ) != ERROR_SUCCESS )
{
// this key doesn't exist, so it's the one we'll use
strcpy( g_qeglobals.use_ini_registry, key.GetBuffer(0) );
RegCreateKeyEx( HKEY_CURRENT_USER, key, 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkResult, &dwDisp );
RegSetValueEx( hkResult, "RadiantName", 0, REG_SZ, reinterpret_cast<CONST BYTE *>(RadiantPath), strlen( RadiantPath )+1 );
RegCloseKey( hkResult );
break;
}
else
{
char RadiantAux[ _MAX_PATH ];
unsigned long size = _MAX_PATH;
// the key exists, is it the one we are looking for ?
RegQueryValueEx( hkResult, "RadiantName", 0, &type, reinterpret_cast<BYTE *>(RadiantAux), &size );
RegCloseKey( hkResult );
if ( !strcmp( RadiantAux, RadiantPath ) )
{
// got it !
strcpy( g_qeglobals.use_ini_registry, key.GetBuffer(0) );
break;
}
}
i++;
} while (1);
g_qeglobals.use_ini = true;
}
else
{
// Change the registry key under which our settings are stored.
SetRegistryKey( EDITOR_REGISTRY_KEY );
g_qeglobals.use_ini = false;
}
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
// CMultiDocTemplate* pDocTemplate;
// pDocTemplate = new CMultiDocTemplate(
// IDR_RADIANTYPE,
// RUNTIME_CLASS(CRadiantDoc),
// RUNTIME_CLASS(CMainFrame), // custom MDI child frame
// RUNTIME_CLASS(CRadiantView));
// AddDocTemplate(pDocTemplate);
// create main MDI Frame window
g_PrefsDlg.LoadPrefs();
qglEnableClientState( GL_VERTEX_ARRAY );
CString strTemp = m_lpCmdLine;
strTemp.MakeLower();
if (strTemp.Find("builddefs") >= 0) {
g_bBuildList = true;
}
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MENU_QUAKE3)) {
return FALSE;
}
if (pMainFrame->m_hAccelTable) {
::DestroyAcceleratorTable(pMainFrame->m_hAccelTable);
}
pMainFrame->LoadAccelTable(MAKEINTRESOURCE(IDR_MINIACCEL));
m_pMainWnd = pMainFrame;
// The main window has been initialized, so show and update it.
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CRadiantApp commands
int CRadiantApp::ExitInstance()
{
common->Shutdown();
g_pParentWnd = NULL;
int ret = CWinApp::ExitInstance();
ExitProcess(0);
return ret;
}
BOOL CRadiantApp::OnIdle(LONG lCount) {
if (g_pParentWnd) {
g_pParentWnd->RoutineProcessing();
}
return FALSE;
//return CWinApp::OnIdle(lCount);
}
void CRadiantApp::OnHelp()
{
ShellExecute(m_pMainWnd->GetSafeHwnd(), "open", "http://www.idDevNet.com", NULL, NULL, SW_SHOW);
}
int CRadiantApp::Run( void )
{
BOOL bIdle = TRUE;
LONG lIdleCount = 0;
#if _MSC_VER >= 1300
MSG *msg = AfxGetCurrentMessage(); // TODO Robert fix me!!
#else
MSG *msg = &m_msgCur;
#endif
// phase1: check to see if we can do idle work
while (bIdle && !::PeekMessage(msg, NULL, NULL, NULL, PM_NOREMOVE)) {
// call OnIdle while in bIdle state
if (!OnIdle(lIdleCount++)) {
bIdle = FALSE; // assume "no idle" state
}
}
// phase2: pump messages while available
do {
// pump message, but quit on WM_QUIT
if (!PumpMessage()) {
return ExitInstance();
}
// reset "no idle" state after pumping "normal" message
if (IsIdleMessage(msg)) {
bIdle = TRUE;
lIdleCount = 0;
}
} while (::PeekMessage(msg, NULL, NULL, NULL, PM_NOREMOVE));
return 0;
}
/*
=============================================================
REGISTRY INFO
=============================================================
*/
bool SaveRegistryInfo(const char *pszName, void *pvBuf, long lSize)
{
SetCvarBinary(pszName, pvBuf, lSize);
common->WriteFlaggedCVarsToFile( "editor.cfg", CVAR_TOOL, "sett" );
return true;
}
bool LoadRegistryInfo(const char *pszName, void *pvBuf, long *plSize)
{
return GetCvarBinary(pszName, pvBuf, *plSize);
}
bool SaveWindowState(HWND hWnd, const char *pszName)
{
RECT rc;
GetWindowRect(hWnd, &rc);
if (hWnd != g_pParentWnd->GetSafeHwnd()) {
if (::GetParent(hWnd) != g_pParentWnd->GetSafeHwnd()) {
::SetParent(hWnd, g_pParentWnd->GetSafeHwnd());
}
MapWindowPoints(NULL, g_pParentWnd->GetSafeHwnd(), (POINT *)&rc, 2);
}
return SaveRegistryInfo(pszName, &rc, sizeof(rc));
}
bool LoadWindowState(HWND hWnd, const char *pszName)
{
RECT rc;
LONG lSize = sizeof(rc);
if (LoadRegistryInfo(pszName, &rc, &lSize))
{
if (rc.left < 0)
rc.left = 0;
if (rc.top < 0)
rc.top = 0;
if (rc.right < rc.left + 16)
rc.right = rc.left + 16;
if (rc.bottom < rc.top + 16)
rc.bottom = rc.top + 16;
MoveWindow(hWnd, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, FALSE);
return true;
}
return false;
}
/*
===============================================================
STATUS WINDOW
===============================================================
*/
void Sys_UpdateStatusBar( void )
{
extern int g_numbrushes, g_numentities;
char numbrushbuffer[100] = "";
sprintf( numbrushbuffer, "Brushes: %d Entities: %d", g_numbrushes, g_numentities );
Sys_Status( numbrushbuffer, 2 );
}
void Sys_Status(const char *psz, int part )
{
if ( part < 0 ) {
common->Printf("%s", psz);
part = 0;
}
g_pParentWnd->SetStatusText(part, psz);
}

View File

@@ -0,0 +1,78 @@
/*
===========================================================================
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.
===========================================================================
*/
#if !defined(AFX_RADIANT_H__330BBF06_731C_11D1_B539_00AA00A410FC__INCLUDED_)
#define AFX_RADIANT_H__330BBF06_731C_11D1_B539_00AA00A410FC__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
/////////////////////////////////////////////////////////////////////////////
// CRadiantApp:
// See Radiant.cpp for the implementation of this class
//
class CRadiantApp : public CWinApp
{
public:
CRadiantApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CRadiantApp)
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
virtual BOOL OnIdle(LONG lCount);
virtual int Run( void );
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CRadiantApp)
afx_msg void OnHelp();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#define DATA_TO_DIALOG FALSE
#define DIALOG_TO_DATA TRUE
#endif // !defined(AFX_RADIANT_H__330BBF06_731C_11D1_B539_00AA00A410FC__INCLUDED_)

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 "qe3.h"
#include "Radiant.h"
#include "RotateDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRotateDlg dialog
CRotateDlg::CRotateDlg(CWnd* pParent /*=NULL*/)
: CDialog(CRotateDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CRotateDlg)
m_strX = _T("");
m_strY = _T("");
m_strZ = _T("");
//}}AFX_DATA_INIT
}
void CRotateDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRotateDlg)
DDX_Control(pDX, IDC_SPIN3, m_wndSpin3);
DDX_Control(pDX, IDC_SPIN2, m_wndSpin2);
DDX_Control(pDX, IDC_SPIN1, m_wndSpin1);
DDX_Text(pDX, IDC_ROTX, m_strX);
DDX_Text(pDX, IDC_ROTY, m_strY);
DDX_Text(pDX, IDC_ROTZ, m_strZ);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CRotateDlg, CDialog)
//{{AFX_MSG_MAP(CRotateDlg)
ON_BN_CLICKED(IDC_APPLY, OnApply)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN1, OnDeltaposSpin1)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN2, OnDeltaposSpin2)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN3, OnDeltaposSpin3)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRotateDlg message handlers
void CRotateDlg::OnOK()
{
OnApply();
CDialog::OnOK();
}
void CRotateDlg::OnApply()
{
UpdateData(TRUE);
float f = atof(m_strX);
if (f != 0.0)
Select_RotateAxis(0,f);
f = atof(m_strY);
if (f != 0.0)
Select_RotateAxis(1,f);
f = atof(m_strZ);
if (f != 0.0)
Select_RotateAxis(2,f);
}
BOOL CRotateDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_wndSpin1.SetRange(0, 359);
m_wndSpin2.SetRange(0, 359);
m_wndSpin3.SetRange(0, 359);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CRotateDlg::OnDeltaposSpin1(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
Select_RotateAxis(0, pNMUpDown->iDelta);
*pResult = 0;
}
void CRotateDlg::OnDeltaposSpin2(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
Select_RotateAxis(1, pNMUpDown->iDelta);
*pResult = 0;
}
void CRotateDlg::OnDeltaposSpin3(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
Select_RotateAxis(2, pNMUpDown->iDelta);
*pResult = 0;
}
void CRotateDlg::ApplyNoPaint()
{
}

View File

@@ -0,0 +1,84 @@
/*
===========================================================================
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.
===========================================================================
*/
#if !defined(AFX_ROTATEDLG_H__D4B79152_7A7E_11D1_B541_00AA00A410FC__INCLUDED_)
#define AFX_ROTATEDLG_H__D4B79152_7A7E_11D1_B541_00AA00A410FC__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// RotateDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CRotateDlg dialog
class CRotateDlg : public CDialog
{
// Construction
public:
CRotateDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CRotateDlg)
enum { IDD = IDD_ROTATE };
CSpinButtonCtrl m_wndSpin3;
CSpinButtonCtrl m_wndSpin2;
CSpinButtonCtrl m_wndSpin1;
CString m_strX;
CString m_strY;
CString m_strZ;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CRotateDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
void ApplyNoPaint();
// Generated message map functions
//{{AFX_MSG(CRotateDlg)
virtual void OnOK();
afx_msg void OnApply();
virtual BOOL OnInitDialog();
afx_msg void OnDeltaposSpin1(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnDeltaposSpin2(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnDeltaposSpin3(NMHDR* pNMHDR, LRESULT* pResult);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_ROTATEDLG_H__D4B79152_7A7E_11D1_B541_00AA00A410FC__INCLUDED_)

2210
neo/tools/radiant/SELECT.CPP Normal file

File diff suppressed because it is too large Load Diff

144
neo/tools/radiant/SELECT.H Normal file
View File

@@ -0,0 +1,144 @@
/*
===========================================================================
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 __SELECT_H_
#define __SELECT_H_
typedef enum
{
sel_brush,
// sel_sticky_brush,
// sel_face,
sel_vertex,
sel_edge,
sel_singlevertex,
sel_curvepoint,
sel_area,
sel_addpoint, // for dropping points
sel_editpoint // for editing points
} select_t;
class CDragPoint {
public:
idVec3 vec;
brush_t *pBrush;
int nType;
bool priority;
CDragPoint() {};
CDragPoint(brush_t *b, idVec3 v, int type, bool p) {
pBrush = b;
VectorCopy(v, vec);
nType = type;
priority = p;
}
void Set(brush_t *b, idVec3 v, int type) {
pBrush = b;
VectorCopy(v, vec);
nType = type;
}
bool PointWithin(idVec3 p, int nView = -1);
};
typedef struct
{
brush_t *brush;
face_t *face;
CDragPoint *point;
float dist;
bool selected;
} qertrace_t;
#define SF_SELECTED_ONLY 0x01
#define SF_ENTITIES_FIRST 0x02
#define SF_SINGLEFACE 0x04
#define SF_IGNORECURVES 0x08
#define SF_IGNOREGROUPS 0x10
#define SF_CYCLE 0x20
qertrace_t Test_Ray ( const idVec3 &origin, const idVec3 &dir, int flags );
CDragPoint *PointRay( const idVec3 &org, const idVec3 &dir, float *dist);
void SelectCurvePointByRay( const idVec3 &org, const idVec3 &dir, int buttons);
void SelectSplinePointByRay( const idVec3 &org, const idVec3 &dir, int buttons);
void Select_GetBounds (idVec3 &mins, idVec3 &maxs);
void Select_Brush (brush_t *b, bool bComplete = true, bool bStatus = true);
void Select_Ray (idVec3 origin, idVec3 dir, int flags);
void Select_Delete (void);
void Select_Deselect (bool bDeselectFaces = true);
void Select_Invert(void);
void Select_Clone (void);
void Select_Move (idVec3 delta, bool bSnap = true);
void WINAPI Select_SetTexture (texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale = false, void* pPlugTexdef = NULL, bool update = true);
void Select_FlipAxis (int axis);
void Select_RotateAxis (int axis, float deg, bool bPaint = true, bool bMouse = false);
void Select_CompleteTall (void);
void Select_PartialTall (void);
void Select_Touching (void);
void Select_Inside (void);
void Select_CenterOrigin();
void Select_AllOfType();
void Select_Reselect();
void Select_FitTexture(float height = 1.0, float width = 1.0);
void Select_InitializeRotation();
void Select_FinalizeRotation();
// absolute texture coordinates
// TTimo NOTE: this is stuff for old brushes format and rotation texture lock .. sort of in-between with bush primitives
void ComputeAbsolute(face_t* f, idVec3& p1, idVec3& p2, idVec3& p3);
void AbsoluteToLocal( const idPlane &normal2, face_t* f, idVec3& p1, idVec3& p2, idVec3& p3);
void Select_Hide(bool invert = false);
void Select_ShowAllHidden();
void Select_WireFrame( bool wireFrame );
void Select_ForceVisible( bool visible );
void Select_Name(const char *pName);
void Select_AddProjectedLight();
void Select_GetMid (idVec3 &mid);
void Select_SetDefaultTexture(const idMaterial *mat, bool fitScale, bool setTexture);
void Select_UpdateTextureName(const char *name);
void Select_FlipTexture(bool y);
void Select_SetPatchFit(float dim1, float dim2, float srcWidth, float srcHeight, float rot);
void Select_SetPatchST(float s1, float t1, float s2, float t2);
void Select_ProjectFaceOntoPatch( face_t *face );
void Select_CopyPatchTextureCoords( patchMesh_t *p );
void Select_AllTargets();
void Select_Scale(float x, float y, float z);
void Select_RotateTexture(float amt, bool absolute = false);
void Select_ScaleTexture(float x, float y, bool update = true, bool absolute = true);
void Select_DefaultTextureScale(bool horz, bool vert, bool update = true);
void Select_ShiftTexture(float x, float y, bool autoAdjust = false);
void Select_GetTrueMid (idVec3 &mid);
void Select_Scale(float x, float y, float z);
#endif

View File

@@ -0,0 +1,75 @@
/*
===========================================================================
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 "qe3.h"
#include "Radiant.h"
#include "ScaleDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CScaleDialog dialog
CScaleDialog::CScaleDialog(CWnd* pParent /*=NULL*/)
: CDialog(CScaleDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CScaleDialog)
m_fZ = 1.0f;
m_fX = 1.0f;
m_fY = 1.0f;
//}}AFX_DATA_INIT
}
void CScaleDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CScaleDialog)
DDX_Text(pDX, IDC_EDIT_Z, m_fZ);
DDX_Text(pDX, IDC_EDIT_X, m_fX);
DDX_Text(pDX, IDC_EDIT_Y, m_fY);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CScaleDialog, CDialog)
//{{AFX_MSG_MAP(CScaleDialog)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CScaleDialog message handlers

View File

@@ -0,0 +1,75 @@
/*
===========================================================================
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.
===========================================================================
*/
#if !defined(AFX_SCALEDIALOG_H__8A9B33B2_9922_11D1_B568_00AA00A410FC__INCLUDED_)
#define AFX_SCALEDIALOG_H__8A9B33B2_9922_11D1_B568_00AA00A410FC__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// ScaleDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CScaleDialog dialog
class CScaleDialog : public CDialog
{
// Construction
public:
CScaleDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CScaleDialog)
enum { IDD = IDD_DIALOG_SCALE };
float m_fZ;
float m_fX;
float m_fY;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CScaleDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CScaleDialog)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SCALEDIALOG_H__8A9B33B2_9922_11D1_B568_00AA00A410FC__INCLUDED_)

View File

@@ -0,0 +1,629 @@
/*
===========================================================================
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 "qe3.h"
#include "Radiant.h"
#include "SurfaceDlg.h"
#include "mainfrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSurfaceDlg dialog
CSurfaceDlg g_dlgSurface;
CSurfaceDlg::CSurfaceDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSurfaceDlg::IDD, pParent) {
//{{AFX_DATA_INIT(CSurfaceDlg)
m_nHorz = 3;
m_nVert = 3;
m_horzScale = 1.0f;
m_horzShift = 0.5f;
m_rotate = 15.0f;
m_vertScale = 1.0f;
m_vertShift = 0.5f;
m_strMaterial = _T("");
m_subdivide = FALSE;
m_fHeight = 1.0f;
m_fWidth = 1.0f;
m_absolute = FALSE;
//}}AFX_DATA_INIT
}
void CSurfaceDlg::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSurfaceDlg)
DDX_Control(pDX, IDC_ROTATE, m_wndRotateEdit);
DDX_Control(pDX, IDC_EDIT_VERT, m_wndVert);
DDX_Control(pDX, IDC_EDIT_HORZ, m_wndHorz);
DDX_Control(pDX, IDC_SLIDER_VERT, m_wndVerticalSubdivisions);
DDX_Control(pDX, IDC_SLIDER_HORZ, m_wndHorzSubdivisions);
DDX_Control(pDX, IDC_SPIN_WIDTH, m_wndWidth);
DDX_Control(pDX, IDC_SPIN_HEIGHT, m_wndHeight);
DDX_Control(pDX, IDC_SPIN_VSHIFT, m_wndVShift);
DDX_Control(pDX, IDC_SPIN_ROTATE, m_wndRotate);
DDX_Control(pDX, IDC_SPIN_HSHIFT, m_wndHShift);
DDX_Text(pDX, IDC_EDIT_HORZ, m_nHorz);
DDV_MinMaxInt(pDX, m_nHorz, 1, 64);
DDX_Text(pDX, IDC_EDIT_VERT, m_nVert);
DDV_MinMaxInt(pDX, m_nVert, 1, 64);
DDX_Text(pDX, IDC_HSCALE, m_horzScale);
DDX_Text(pDX, IDC_HSHIFT, m_horzShift);
DDX_Text(pDX, IDC_ROTATE, m_rotate);
DDX_Text(pDX, IDC_VSCALE, m_vertScale);
DDX_Text(pDX, IDC_VSHIFT, m_vertShift);
DDX_Text(pDX, IDC_TEXTURE, m_strMaterial);
DDX_Check(pDX, IDC_CHECK_SUBDIVIDE, m_subdivide);
DDX_Text(pDX, IDC_EDIT_HEIGHT, m_fHeight);
DDX_Text(pDX, IDC_EDIT_WIDTH, m_fWidth);
DDX_Check(pDX, IDC_CHECK_ABSOLUTE, m_absolute);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSurfaceDlg, CDialog)
//{{AFX_MSG_MAP(CSurfaceDlg)
ON_WM_HSCROLL()
ON_WM_KEYDOWN()
ON_WM_VSCROLL()
ON_WM_CLOSE()
ON_WM_DESTROY()
ON_BN_CLICKED(IDCANCEL, OnBtnCancel)
ON_BN_CLICKED(IDC_BTN_COLOR, OnBtnColor)
ON_WM_CTLCOLOR()
ON_WM_CREATE()
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HSHIFT, OnDeltaPosSpin)
ON_BN_CLICKED(IDC_BTN_PATCHDETAILS, OnBtnPatchdetails)
ON_BN_CLICKED(IDC_BTN_PATCHNATURAL, OnBtnPatchnatural)
ON_BN_CLICKED(IDC_BTN_PATCHRESET, OnBtnPatchreset)
ON_BN_CLICKED(IDC_BTN_AXIAL, OnBtnAxial)
ON_BN_CLICKED(IDC_BTN_BRUSHFIT, OnBtnBrushfit)
ON_BN_CLICKED(IDC_BTN_FACEFIT, OnBtnFacefit)
ON_BN_CLICKED(IDC_CHECK_SUBDIVIDE, OnCheckSubdivide)
ON_EN_CHANGE(IDC_EDIT_HORZ, OnChangeEditHorz)
ON_EN_CHANGE(IDC_EDIT_VERT, OnChangeEditVert)
ON_EN_SETFOCUS(IDC_HSCALE, OnSetfocusHscale)
ON_EN_KILLFOCUS(IDC_HSCALE, OnKillfocusHscale)
ON_EN_KILLFOCUS(IDC_VSCALE, OnKillfocusVscale)
ON_EN_SETFOCUS(IDC_VSCALE, OnSetfocusVscale)
ON_EN_KILLFOCUS(IDC_EDIT_WIDTH, OnKillfocusEditWidth)
ON_EN_SETFOCUS(IDC_EDIT_WIDTH, OnSetfocusEditWidth)
ON_EN_KILLFOCUS(IDC_EDIT_HEIGHT, OnKillfocusEditHeight)
ON_EN_SETFOCUS(IDC_EDIT_HEIGHT, OnSetfocusEditHeight)
ON_BN_CLICKED(IDC_BTN_FLIPX, OnBtnFlipx)
ON_BN_CLICKED(IDC_BTN_FLIPY, OnBtnFlipy)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ROTATE, OnDeltaPosSpin)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_VSHIFT, OnDeltaPosSpin)
ON_EN_KILLFOCUS(IDC_ROTATE, OnKillfocusRotate)
ON_EN_SETFOCUS(IDC_ROTATE, OnSetfocusRotate)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSurfaceDlg message handlers
/*
===================================================
SURFACE INSPECTOR
===================================================
*/
texdef_t g_old_texdef;
texdef_t g_patch_texdef;
HWND g_surfwin = NULL;
bool g_changed_surface;
/*
==============
SetTexMods
Set the fields to the current texdef
if one face selected -> will read this face texdef, else current texdef
if only patches selected, will read the patch texdef
===============
*/
extern void Face_GetScale_BrushPrimit(face_t *face, float *s, float *t, float *rot);
void CSurfaceDlg::SetTexMods() {
UpdateData(TRUE);
m_strMaterial = g_qeglobals.d_texturewin.texdef.name;
patchMesh_t *p = SinglePatchSelected();
if (p) {
m_subdivide = p->explicitSubdivisions;
m_strMaterial = p->d_texture->GetName();
} else {
m_subdivide = false;
}
int faceCount = g_ptrSelectedFaces.GetSize();
face_t *selFace = NULL;
if (faceCount) {
selFace = reinterpret_cast < face_t * > (g_ptrSelectedFaces.GetAt(0));
} else {
if (selected_brushes.next != &selected_brushes) {
brush_t *b = selected_brushes.next;
if (!b->pPatch) {
selFace = b->brush_faces;
}
}
}
if (selFace) {
float rot;
Face_GetScale_BrushPrimit(selFace, &m_horzScale, &m_vertScale, &rot);
} else {
m_horzScale = 1.0f;
m_vertScale = 1.0f;
}
UpdateData(FALSE);
}
bool g_bNewFace = false;
bool g_bNewApplyHandling = false;
bool g_bGatewayhack = false;
/*
=================
UpdateSpinners
=================
*/
void CSurfaceDlg::UpdateSpinners(bool up, int nID) {
UpdateData(TRUE);
float hdiv = 0.0f;
float vdiv = 0.0f;
switch (nID) {
case IDC_SPIN_ROTATE :
Select_RotateTexture((up) ? m_rotate : -m_rotate);
break;
case IDC_SPIN_HSCALE :
m_horzScale += (up) ? 0.1f : -0.1f;
hdiv = (m_horzScale == 0.0f) ? 1.0f : m_horzScale;
Select_ScaleTexture( 1.0f / hdiv, 0.0f, true, ( m_absolute != FALSE ) );
UpdateData(FALSE);
break;
case IDC_SPIN_VSCALE :
m_vertScale += (up) ? 0.1f : -0.1f;
vdiv = (m_vertScale == 0.0f) ? 1.0f : m_vertScale;
Select_ScaleTexture( 0.0f, 1.0f / vdiv, true, ( m_absolute != FALSE ) );
UpdateData(FALSE);
break;
case IDC_SPIN_HSHIFT :
Select_ShiftTexture((up) ? m_horzShift : -m_horzShift, 0);
break;
case IDC_SPIN_VSHIFT :
Select_ShiftTexture(0, (up) ? m_vertShift : -m_vertShift);
break;
}
g_changed_surface = true;
}
void CSurfaceDlg::UpdateSpinners(int nScrollCode, int nPos, CScrollBar* pBar) {
return;
UpdateData(TRUE);
if ((nScrollCode != SB_LINEUP) && (nScrollCode != SB_LINEDOWN)) {
return;
}
bool up = (nScrollCode == SB_LINEUP);
// FIXME: bad resource define
#define IDC_ROTATEA 0
#define IDC_HSCALEA 0
#define IDC_VSCALEA 0
#define IDC_HSHIFTA 0
#define IDC_VSHIFTA 0
if (pBar->GetSafeHwnd() == ::GetDlgItem(GetSafeHwnd(), IDC_ROTATEA)) {
Select_RotateTexture((up) ? m_rotate : -m_rotate);
} else if (pBar->GetSafeHwnd() == ::GetDlgItem(GetSafeHwnd(), IDC_HSCALEA)) {
Select_ScaleTexture((up) ? -m_horzScale : m_horzScale, 0, true, ( m_absolute != FALSE ) );
} else if (pBar->GetSafeHwnd() == ::GetDlgItem(GetSafeHwnd(), IDC_VSCALEA)) {
Select_ScaleTexture(0, (up) ? -m_vertScale : m_vertScale, true, ( m_absolute != FALSE ) );
} else if (pBar->GetSafeHwnd() == ::GetDlgItem(GetSafeHwnd(), IDC_HSHIFTA)) {
Select_ShiftTexture((up) ? -m_horzShift : m_horzShift, 0);
} else if (pBar->GetSafeHwnd() == ::GetDlgItem(GetSafeHwnd(), IDC_VSHIFTA)) {
Select_ShiftTexture((up) ? -m_vertShift : m_vertShift, 0);
}
g_changed_surface = true;
}
void UpdateSurfaceDialog() {
if (g_surfwin) {
g_dlgSurface.SetTexMods();
}
g_pParentWnd->UpdateTextureBar();
}
bool ByeByeSurfaceDialog();
void DoSurface (void) {
g_bNewFace = ( g_PrefsDlg.m_bFace != FALSE );
g_bNewApplyHandling = ( g_PrefsDlg.m_bNewApplyHandling != FALSE );
g_bGatewayhack = ( g_PrefsDlg.m_bGatewayHack != FALSE );
// save current state for cancel
g_old_texdef = g_qeglobals.d_texturewin.texdef;
g_changed_surface = false;
if (g_surfwin == NULL && g_dlgSurface.GetSafeHwnd() == NULL) {
g_patch_texdef.scale[0] = 0.05f;
g_patch_texdef.scale[1] = 0.05f;
g_patch_texdef.shift[0] = 0.05f;
g_patch_texdef.shift[1] = 0.05f;
// use rotation increment from preferences
g_patch_texdef.rotate = g_PrefsDlg.m_nRotation;
g_dlgSurface.Create(IDD_SURFACE);
CRect rct;
LONG lSize = sizeof(rct);
if (LoadRegistryInfo("radiant_SurfaceWindow", &rct, &lSize)) {
g_dlgSurface.SetWindowPos( NULL, rct.left, rct.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW );
}
g_dlgSurface.ShowWindow(SW_SHOW);
Sys_UpdateWindows(W_ALL);
} else {
g_surfwin = g_dlgSurface.GetSafeHwnd();
g_dlgSurface.SetTexMods ();
g_dlgSurface.ShowWindow(SW_SHOW);
}
}
bool ByeByeSurfaceDialog() {
if (g_surfwin) {
if (g_bGatewayhack) {
PostMessage(g_surfwin, WM_COMMAND, IDC_APPLY, 0);
} else {
PostMessage(g_surfwin, WM_COMMAND, IDCANCEL, 0);
}
return true;
} else {
return false;
}
}
BOOL CSurfaceDlg::OnInitDialog() {
CDialog::OnInitDialog();
g_surfwin = GetSafeHwnd();
SetTexMods ();
//m_wndHScale.SetRange(0, 100);
//m_wndVScale.SetRange(0, 100);
m_wndHShift.SetRange(0, 100);
m_wndVShift.SetRange(0, 100);
m_wndRotate.SetRange(0, 100);
m_wndWidth.SetRange(1, 32);
m_wndHeight.SetRange(1, 32);
m_wndVerticalSubdivisions.SetRange(1, 32);
m_wndVerticalSubdivisions.SetBuddy(&m_wndVert, FALSE);
m_wndHorzSubdivisions.SetRange(1, 32);
m_wndHorzSubdivisions.SetBuddy(&m_wndHorz, FALSE);
m_wndVerticalSubdivisions.SetPos(m_nVert);
m_wndHorzSubdivisions.SetPos(m_nHorz);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSurfaceDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) {
UpdateData(TRUE);
if (pScrollBar->IsKindOf(RUNTIME_CLASS(CSliderCtrl))) {
CSliderCtrl *ctrl = reinterpret_cast<CSliderCtrl*>(pScrollBar);
assert(ctrl);
if (ctrl == &m_wndVerticalSubdivisions) {
m_nVert = ctrl->GetPos();
} else {
m_nHorz = ctrl->GetPos();
}
UpdateData(FALSE);
if (m_subdivide) {
Patch_SubdivideSelected( ( m_subdivide != FALSE ), m_nHorz, m_nVert );
}
}
Sys_UpdateWindows(W_CAMERA | W_XY);
}
void CSurfaceDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) {
CDialog::OnKeyDown(nChar, nRepCnt, nFlags);
}
void CSurfaceDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) {
//UpdateSpinners(nSBCode, nPos, pScrollBar);
//Sys_UpdateWindows(W_CAMERA);
}
void CSurfaceDlg::OnOK() {
//GetTexMods();
UpdateData(TRUE);
if (m_strMaterial.Find(":") >= 0) {
const idMaterial *mat = declManager->FindMaterial(m_strMaterial);
Select_UpdateTextureName(m_strMaterial);
}
g_surfwin = NULL;
CDialog::OnOK();
Sys_UpdateWindows(W_ALL);
}
void CSurfaceDlg::OnClose() {
g_surfwin = NULL;
CDialog::OnClose();
}
void CSurfaceDlg::OnCancel() {
if (g_bGatewayhack) {
OnOK();
} else {
OnBtnCancel();
}
}
void CSurfaceDlg::OnDestroy() {
if (GetSafeHwnd()) {
CRect rct;
GetWindowRect(rct);
SaveRegistryInfo("radiant_SurfaceWindow", &rct, sizeof(rct));
}
CDialog::OnDestroy();
g_surfwin = NULL;
Sys_UpdateWindows(W_ALL);
}
void CSurfaceDlg::OnBtnCancel() {
g_qeglobals.d_texturewin.texdef = g_old_texdef;
if (g_changed_surface) {
//++timo if !g_qeglobals.m_bBrushPrimitMode send a NULL brushprimit_texdef
if (!g_qeglobals.m_bBrushPrimitMode) {
common->Printf("Warning : non brush primitive mode call to CSurfaceDlg::GetTexMods broken\n");
common->Printf(" ( Select_SetTexture not called )\n");
}
// Select_SetTexture(&g_qeglobals.d_texturewin.texdef);
}
g_surfwin = NULL;
DestroyWindow();
}
void CSurfaceDlg::OnBtnColor() {
}
HBRUSH CSurfaceDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) {
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
return hbr;
}
int CSurfaceDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) {
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}
BOOL CSurfaceDlg::PreCreateWindow(CREATESTRUCT& cs) {
// TODO: Add your specialized code here and/or call the base class
return CDialog::PreCreateWindow(cs);
}
void CSurfaceDlg::OnDeltaPosSpin(NMHDR* pNMHDR, LRESULT* pResult) {
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
UpdateSpinners((pNMUpDown->iDelta > 0), pNMUpDown->hdr.idFrom);
*pResult = 0;
}
void CSurfaceDlg::OnBtnPatchdetails() {
Patch_NaturalizeSelected(true);
g_pParentWnd->GetCamera()->MarkWorldDirty ();
Sys_UpdateWindows(W_ALL);
}
void CSurfaceDlg::OnBtnPatchnatural() {
Select_SetTexture (&g_qeglobals.d_texturewin.texdef, &g_qeglobals.d_texturewin.brushprimit_texdef, false);
Patch_NaturalizeSelected();
g_pParentWnd->GetCamera()->MarkWorldDirty ();
g_changed_surface = true;
Sys_UpdateWindows(W_ALL);
}
void CSurfaceDlg::OnBtnPatchreset() {
//CTextureLayout dlg;
//if (dlg.DoModal() == IDOK) {
// Patch_ResetTexturing(dlg.m_fX, dlg.m_fY);
//}
//Sys_UpdateWindows(W_ALL);
}
void CSurfaceDlg::OnBtnAxial() {
}
void CSurfaceDlg::OnBtnBrushfit() {
// TODO: Add your control notification handler code here
}
void CSurfaceDlg::OnBtnFacefit() {
UpdateData(TRUE);
/*
brush_t *b;
for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next) {
if (!b->patchBrush) {
for (face_t* pFace = b->brush_faces; pFace; pFace = pFace->next) {
g_ptrSelectedFaces.Add(pFace);
g_ptrSelectedFaceBrushes.Add(b);
}
}
}
*/
Select_FitTexture(m_fHeight, m_fWidth);
g_pParentWnd->GetCamera()->MarkWorldDirty ();
//SetTexMods();
g_changed_surface = true;
Sys_UpdateWindows(W_ALL);
}
void CSurfaceDlg::OnCheckSubdivide() {
UpdateData( TRUE );
// turn any patches in explicit subdivides
Patch_SubdivideSelected( ( m_subdivide != FALSE ), m_nHorz, m_nVert );
g_pParentWnd->GetCamera()->MarkWorldDirty ();
Sys_UpdateWindows( W_CAMERA | W_XY );
}
void CSurfaceDlg::OnChangeEditHorz()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
// turn any patches in explicit subdivides
Patch_SubdivideSelected( ( m_subdivide != FALSE ), m_nHorz, m_nVert );
Sys_UpdateWindows(W_CAMERA | W_XY);
}
void CSurfaceDlg::OnChangeEditVert()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
// turn any patches in explicit subdivides
Patch_SubdivideSelected( ( m_subdivide != FALSE ), m_nHorz, m_nVert );
Sys_UpdateWindows(W_CAMERA | W_XY);
}
BOOL CSurfaceDlg::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN) {
if (pMsg->wParam == VK_RETURN) {
if (focusControl) {
UpdateData(TRUE);
if (focusControl == &m_wndHScale) {
Select_ScaleTexture( m_horzScale, 1.0f, true, ( m_absolute != FALSE ) );
} else if (focusControl == &m_wndVScale) {
Select_ScaleTexture( 1.0f, m_vertScale, true, ( m_absolute != FALSE ) );
} else if (focusControl == &m_wndRotateEdit) {
Select_RotateTexture( m_rotate, true );
} else if (focusControl == &m_wndHeight || focusControl == &m_wndWidth) {
Select_FitTexture( m_fHeight, m_fWidth );
}
}
return TRUE;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
void CSurfaceDlg::OnSetfocusHscale()
{
focusControl = &m_wndHScale;
}
void CSurfaceDlg::OnKillfocusHscale()
{
focusControl = NULL;
}
void CSurfaceDlg::OnKillfocusVscale()
{
focusControl = NULL;
}
void CSurfaceDlg::OnSetfocusVscale()
{
focusControl = &m_wndVScale;
}
void CSurfaceDlg::OnKillfocusEditWidth()
{
focusControl = NULL;
}
void CSurfaceDlg::OnSetfocusEditWidth()
{
focusControl = &m_wndWidth;
}
void CSurfaceDlg::OnKillfocusEditHeight()
{
focusControl = NULL;
}
void CSurfaceDlg::OnSetfocusEditHeight()
{
focusControl = &m_wndHeight;
}
void CSurfaceDlg::OnBtnFlipx()
{
Select_FlipTexture(false);
}
void CSurfaceDlg::OnBtnFlipy()
{
Select_FlipTexture(true);
}
void CSurfaceDlg::OnKillfocusRotate()
{
focusControl = NULL;
}
void CSurfaceDlg::OnSetfocusRotate()
{
focusControl = &m_wndRotateEdit;
}

View File

@@ -0,0 +1,139 @@
/*
===========================================================================
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.
===========================================================================
*/
#if !defined(AFX_SURFACEDLG_H__D84E0C22_9EEA_11D1_B570_00AA00A410FC__INCLUDED_)
#define AFX_SURFACEDLG_H__D84E0C22_9EEA_11D1_B570_00AA00A410FC__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// SurfaceDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CSurfaceDlg dialog
class CSurfaceDlg : public CDialog
{
bool m_bPatchMode;
CWnd *focusControl;
// Construction
public:
CSurfaceDlg(CWnd* pParent = NULL); // standard constructor
void SetTexMods();
// Dialog Data
//{{AFX_DATA(CSurfaceDlg)
enum { IDD = IDD_SURFACE };
CEdit m_wndRotateEdit;
CEdit m_wndVert;
CEdit m_wndHorz;
CSliderCtrl m_wndVerticalSubdivisions;
CSliderCtrl m_wndHorzSubdivisions;
CSpinButtonCtrl m_wndWidth;
CSpinButtonCtrl m_wndHeight;
CSpinButtonCtrl m_wndVShift;
CSpinButtonCtrl m_wndVScale;
CSpinButtonCtrl m_wndRotate;
CSpinButtonCtrl m_wndHShift;
CSpinButtonCtrl m_wndHScale;
int m_nHorz;
int m_nVert;
float m_horzScale;
float m_horzShift;
float m_rotate;
float m_vertScale;
float m_vertShift;
CString m_strMaterial;
BOOL m_subdivide;
float m_fHeight;
float m_fWidth;
BOOL m_absolute;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSurfaceDlg)
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
protected:
void UpdateSpinners(int nScrollCode, int nPos, CScrollBar* pBar);
void UpdateSpinners(bool bUp, int nID);
// Generated message map functions
//{{AFX_MSG(CSurfaceDlg)
virtual BOOL OnInitDialog();
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnApply();
virtual void OnOK();
afx_msg void OnClose();
virtual void OnCancel();
afx_msg void OnDestroy();
afx_msg void OnBtnCancel();
afx_msg void OnBtnColor();
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnDeltaPosSpin(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnBtnPatchdetails();
afx_msg void OnBtnPatchnatural();
afx_msg void OnBtnPatchreset();
afx_msg void OnBtnAxial();
afx_msg void OnBtnBrushfit();
afx_msg void OnBtnFacefit();
afx_msg void OnCheckSubdivide();
afx_msg void OnChangeEditHorz();
afx_msg void OnChangeEditVert();
afx_msg void OnSetfocusHscale();
afx_msg void OnKillfocusHscale();
afx_msg void OnKillfocusVscale();
afx_msg void OnSetfocusVscale();
afx_msg void OnKillfocusEditWidth();
afx_msg void OnSetfocusEditWidth();
afx_msg void OnKillfocusEditHeight();
afx_msg void OnSetfocusEditHeight();
afx_msg void OnBtnFlipx();
afx_msg void OnBtnFlipy();
afx_msg void OnKillfocusRotate();
afx_msg void OnSetfocusRotate();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SURFACEDLG_H__D84E0C22_9EEA_11D1_B570_00AA00A410FC__INCLUDED_)

View File

@@ -0,0 +1,352 @@
/*
===========================================================================
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 "QE3.H"
#include "TabsDlg.h"
// CTabsDlg dialog
//IMPLEMENT_DYNAMIC ( CTabsDlg , CDialog )
CTabsDlg::CTabsDlg(UINT ID , CWnd* pParent /*=NULL*/)
: CDialog(ID, pParent)
{
m_DragTabActive = false;
}
BEGIN_MESSAGE_MAP(CTabsDlg, CDialog)
//}}AFX_MSG_MAP
// ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, OnTcnSelchangeTab1)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_DESTROY()
END_MESSAGE_MAP()
void CTabsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_TAB_INSPECTOR, m_Tabs);
}
// CTabsDlg message handlers
BOOL CTabsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
return TRUE; // return TRUE unless you set the focus to a control
}
void CTabsDlg::OnTcnSelchange(NMHDR *pNMHDR, LRESULT *pResult)
{
int ID = TabCtrl_GetCurSel ( pNMHDR->hwndFrom );
if ( ID >= 0 )
{
TCITEM item;
item.mask = TCIF_PARAM;
ShowAllWindows ( FALSE );
TabCtrl_GetItem (m_Tabs.GetSafeHwnd() , ID , &item);
DockedWindowInfo* info = (DockedWindowInfo*)item.lParam;
ASSERT ( info );
info->m_TabControlIndex = ID;
info->m_Window->ShowWindow(TRUE);
}
}
void CTabsDlg::DockWindow ( int ID , bool dock )
{
DockedWindowInfo* info = NULL;
m_Windows.Lookup ( (WORD)ID , (void*&)info );
ASSERT ( info );
ASSERT ( m_Tabs.GetSafeHwnd() );
ShowAllWindows ( FALSE );
if ( !dock )
{
//make a containing window and assign the dialog to it
CRect rect;
CString classname = AfxRegisterWndClass ( CS_DBLCLKS , 0 , 0 , 0 );
info->m_State = DockedWindowInfo::FLOATING;
info->m_Window->GetWindowRect(rect);
info->m_Container.CreateEx ( WS_EX_TOOLWINDOW , classname , info->m_Title , WS_THICKFRAME | WS_SYSMENU | WS_POPUP | WS_CAPTION, rect , this , 0 );
info->m_Window->SetParent ( &info->m_Container );
info->m_Window->ShowWindow(TRUE);
info->m_Container.SetDockManager(this);
info->m_Container.ShowWindow(TRUE);
info->m_Container.SetDialog ( info->m_Window , info->m_ID );
if (info->m_TabControlIndex >= 0 )
{
m_Tabs.DeleteItem( info->m_TabControlIndex );
}
if ( m_Tabs.GetItemCount() > 0 )
{
m_Tabs.SetCurFocus( 0 );
}
CString placementName = info->m_Title + "Placement";
LoadWindowPlacement(info->m_Container , placementName);
}
else
{
info->m_State = DockedWindowInfo::DOCKED;
info->m_TabControlIndex = m_Tabs.InsertItem( TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM , 0 , info->m_Title , info->m_ImageID , (LPARAM)info);
info->m_Window->SetParent ( this );
info->m_Window->ShowWindow (TRUE);
info->m_Container.SetDockManager( NULL ); //so it doesn't try to call back and redock this window
info->m_Container.DestroyWindow ();
CRect rect;
GetWindowRect ( rect );
//stupid hack to get the window reitself properly
rect.DeflateRect(0,0,0,1);
MoveWindow(rect);
rect.InflateRect(0,0,0,1);
MoveWindow(rect);
}
UpdateTabControlIndices ();
FocusWindow ( ID );
if ( info->m_DockCallback )
{
info->m_DockCallback ( dock , info->m_ID , info->m_Window );
}
SaveWindowPlacement ();
}
int CTabsDlg::PreTranslateMessage ( MSG* msg )
{
if ( msg->message == WM_LBUTTONDBLCLK && msg->hwnd == m_Tabs.GetSafeHwnd() )
{
HandleUndock ();
return TRUE;
}
//steal lbutton clicks for the main dialog too, but let the tabs do their default thing as well
if ( msg->message == WM_LBUTTONDOWN && msg->hwnd == m_Tabs.GetSafeHwnd()) {
m_Tabs.SendMessage ( msg->message , msg->wParam , msg->lParam );
m_DragTabActive = true;
}
else if ( msg->message == WM_LBUTTONUP && msg->hwnd == m_Tabs.GetSafeHwnd()) {
m_Tabs.SendMessage ( msg->message , msg->wParam , msg->lParam );
m_DragTabActive = false;
}
return CDialog::PreTranslateMessage(msg);
}
bool CTabsDlg::RectWithinDockManager ( CRect& rect )
{
CRect tabsRect,intersectionRect;
m_Tabs.GetWindowRect ( tabsRect );
intersectionRect.IntersectRect( tabsRect , rect );
return !(intersectionRect.IsRectEmpty());
}
void CTabsDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
CDialog::OnLButtonDown(nFlags, point);
}
void CTabsDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
if ( m_DragTabActive && ((abs ( point.x - m_DragDownPoint.x ) > 50) || (abs ( point.y - m_DragDownPoint.y ) > 50)))
{
HandleUndock();
m_DragTabActive = false;
}
CDialog::OnLButtonUp(nFlags, point);
}
void CTabsDlg::HandleUndock ()
{
TCITEM item;
item.mask = TCIF_PARAM;
int curSel = TabCtrl_GetCurSel ( m_Tabs.GetSafeHwnd());
TabCtrl_GetItem (m_Tabs.GetSafeHwnd() , curSel , &item);
DockedWindowInfo* info = (DockedWindowInfo*)item.lParam;
ASSERT ( info );
DockWindow ( info->m_ID , false );
}
void CTabsDlg::OnMouseMove(UINT nFlags, CPoint point)
{
CDialog::OnMouseMove(nFlags, point);
}
void CTabsDlg::AddDockedWindow ( CWnd* wnd , int ID , int imageID , const CString& title , bool dock , pfnOnDockEvent dockCallback )
{
DockedWindowInfo* info = NULL;
m_Windows.Lookup( (WORD)ID , (void*&)info);
ASSERT ( wnd );
ASSERT ( info == NULL );
info = new DockedWindowInfo ( wnd , ID , imageID , title , dockCallback);
m_Windows.SetAt ( (WORD)ID , info );
DockWindow ( ID , dock );
UpdateTabControlIndices ();
}
void CTabsDlg::ShowAllWindows ( bool show )
{
POSITION pos;
WORD ID;
DockedWindowInfo* info = NULL;
for( pos = m_Windows.GetStartPosition(); pos != NULL ; )
{
m_Windows.GetNextAssoc( pos, ID, (void*&)info );
ASSERT ( info->m_Window );
if ( info->m_State == DockedWindowInfo::DOCKED )
{
info->m_Window->ShowWindow( show );
}
}
}
void CTabsDlg::FocusWindow ( int ID )
{
DockedWindowInfo* info = NULL;
m_Windows.Lookup( (WORD)ID , (void*&)info);
ASSERT ( info );
ASSERT ( info->m_Window );
if ( info->m_State == DockedWindowInfo::DOCKED )
{
TabCtrl_SetCurFocus ( m_Tabs.GetSafeHwnd() , info->m_TabControlIndex );
}
else
{
info->m_Container.SetFocus();
}
}
void CTabsDlg::UpdateTabControlIndices ()
{
TCITEM item;
item.mask = TCIF_PARAM;
DockedWindowInfo* info = NULL;
int itemCount = m_Tabs.GetItemCount();
for ( int i = 0 ; i < itemCount ; i ++ )
{
if ( !m_Tabs.GetItem( i , &item ) )
{
Sys_Error ( "UpdateTabControlIndices(): GetItem failed!\n" );
}
info = (DockedWindowInfo*)item.lParam;
info->m_TabControlIndex = i;
}
}
void CTabsDlg::OnDestroy()
{
TCITEM item;
item.mask = TCIF_PARAM;
DockedWindowInfo* info = NULL;
for ( int i = 0 ; i < m_Tabs.GetItemCount() ; i ++ )
{
m_Tabs.GetItem( i , &item );
info = (DockedWindowInfo*)item.lParam;
ASSERT( info );
delete info;
}
CDialog::OnDestroy();
}
bool CTabsDlg::IsDocked ( CWnd* wnd )
{
bool docked = false;
DockedWindowInfo* info = NULL;
CString placementName;
POSITION pos;
WORD wID;
for( pos = m_Windows.GetStartPosition(); pos != NULL ; )
{
m_Windows.GetNextAssoc( pos, wID, (void*&)info );
if ( info->m_Window == wnd ) {
docked = (info->m_State == DockedWindowInfo::DOCKED);
break;
}
}
return docked;
}
void CTabsDlg::SaveWindowPlacement( int ID )
{
DockedWindowInfo* info = NULL;
CString placementName;
POSITION pos;
WORD wID = ID;
for( pos = m_Windows.GetStartPosition(); pos != NULL ; )
{
m_Windows.GetNextAssoc( pos, wID, (void*&)info );
if ( (info->m_State == DockedWindowInfo::FLOATING) && ((ID == -1) || (ID == info->m_ID))) {
placementName = info->m_Title + "Placement";
::SaveWindowPlacement(info->m_Container.GetSafeHwnd() , placementName);
}
}
}

119
neo/tools/radiant/TabsDlg.h Normal file
View File

@@ -0,0 +1,119 @@
/*
===========================================================================
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.
===========================================================================
*/
#pragma once
#include "afxcmn.h"
#include "TearoffContainerWindow.h"
// CTabsDlg dialog
class CTabsDlg : public CDialog
{
// DECLARE_DYNAMIC ( CTabsDlg )
// Construction
public:
CTabsDlg(UINT ID ,CWnd* pParent = NULL); // standard constructor
typedef void (*pfnOnDockEvent)( bool , int , CWnd* );
void AddDockedWindow ( CWnd* wnd , int ID , int imageID , const CString& title , bool dock , pfnOnDockEvent dockCallback = NULL);
void DockWindow ( int ID , bool dock );
bool RectWithinDockManager ( CRect& rect );
void FocusWindow ( int ID );
void SetImageList ( CImageList* list )
{
ASSERT ( list );
m_Tabs.SetImageList( list );
}
bool IsDocked ( CWnd* wnd );
protected:
int CTabsDlg::PreTranslateMessage ( MSG* msg );
// Implementation
protected:
CImageList m_TabImages;
CPoint m_DragDownPoint;
CMapWordToPtr m_Windows;
bool m_DragTabActive;
void DoDataExchange(CDataExchange* pDX);
//private struct that holds the info we need about each window
struct DockedWindowInfo {
DockedWindowInfo ( CWnd* wnd , int ID , int imageID , const CString& title = "" , pfnOnDockEvent dockCallback = NULL)
{
ASSERT ( wnd );
m_Window = wnd;
m_ID = ID;
m_ImageID = imageID;
m_TabControlIndex = -1;
if ( title.GetLength() == 0 )
{
m_Window->GetWindowText( m_Title );
}
else
{
m_Title = title;
}
m_State = DOCKED;
m_DockCallback = dockCallback;
}
enum eState {DOCKED,FLOATING} ;
CTearoffContainerWindow m_Container; //the floating window that will hold m_Window when it's undocked
CWnd* m_Window;
CString m_Title;
int m_ImageID;
int m_ID;
int m_TabControlIndex;
eState m_State;
pfnOnDockEvent m_DockCallback;
};
void ShowAllWindows ( bool show = true );
void HandleUndock ();
void UpdateTabControlIndices ();
// Generated message map functions
virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()
public:
CTabCtrl m_Tabs;
afx_msg void OnTcnSelchange(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnDestroy();
void SaveWindowPlacement ( int ID = -1 );
};

View File

@@ -0,0 +1,150 @@
/*
===========================================================================
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
// TearoffContainerWindow.cpp : implementation file
//
#include "TabsDlg.h"
#include "TearoffContainerWindow.h"
// CTearoffContainerWindow
IMPLEMENT_DYNAMIC(CTearoffContainerWindow, CWnd)
CTearoffContainerWindow::CTearoffContainerWindow()
{
m_DragPreviewActive = false;
m_ContainedDialog = NULL;
m_DockManager = NULL;
}
CTearoffContainerWindow::~CTearoffContainerWindow()
{
}
BEGIN_MESSAGE_MAP(CTearoffContainerWindow, CWnd)
ON_WM_NCLBUTTONDBLCLK()
ON_WM_CLOSE()
ON_WM_SIZE()
ON_WM_DESTROY()
ON_WM_SETFOCUS()
END_MESSAGE_MAP()
// CTearoffContainerWindow message handlers
void CTearoffContainerWindow::OnNcLButtonDblClk(UINT nHitTest, CPoint point)
{
if ( nHitTest == HTCAPTION )
{
m_DockManager->DockWindow ( m_DialogID , true );
}
CWnd::OnNcLButtonDblClk(nHitTest, point);
}
void CTearoffContainerWindow::SetDialog ( CWnd* dlg , int ID )
{
m_DialogID = ID;
m_ContainedDialog = dlg;
CRect rect;
CPoint point (-10 , -10);
m_ContainedDialog->GetWindowRect ( rect );
rect.OffsetRect(point); //move the window slightly so you can tell it's been popped up
//stupid hack to get the window resize itself properly
rect.DeflateRect(0,0,0,1);
MoveWindow(rect);
rect.InflateRect(0,0,0,1);
MoveWindow(rect);
}
void CTearoffContainerWindow::SetDockManager ( CTabsDlg* dlg )
{
m_DockManager = dlg;
}
void CTearoffContainerWindow::OnClose()
{
if ( m_DockManager )
{
//send it back to the docking window (for now at least)
m_DockManager->DockWindow ( m_DialogID , true );
}
}
BOOL CTearoffContainerWindow:: PreTranslateMessage( MSG* pMsg )
{
if ( pMsg->message == WM_NCLBUTTONUP )
{
/* CRect rect;
GetWindowRect ( rect );
rect.DeflateRect( 0,0,0,rect.Height() - GetSystemMetrics(SM_CYSMSIZE));
if ( m_DockManager->RectWithinDockManager ( rect ))
{
m_DockManager->DockDialog ( m_DialogID , true );
}
*/
}
return CWnd::PreTranslateMessage(pMsg);
}
void CTearoffContainerWindow::OnSize(UINT nType, int cx, int cy)
{
if ( m_ContainedDialog )
{
m_ContainedDialog->MoveWindow ( 0,0,cx,cy);
}
CWnd::OnSize(nType, cx, cy);
}
void CTearoffContainerWindow::OnDestroy()
{
CWnd::OnDestroy();
// TODO: Add your message handler code here
}
void CTearoffContainerWindow::OnSetFocus(CWnd* pOldWnd)
{
CWnd::OnSetFocus(pOldWnd);
if ( m_ContainedDialog )
{
m_ContainedDialog->SetFocus();
}
// TODO: Add your message handler code here
}

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.
===========================================================================
*/
#pragma once
// CTearoffContainerWindow
class CTabsDlg;
class CTearoffContainerWindow : public CWnd
{
DECLARE_DYNAMIC(CTearoffContainerWindow)
public:
CTearoffContainerWindow();
virtual ~CTearoffContainerWindow();
CWnd* m_ContainedDialog; //dialog that is being docked/undocked
int m_DialogID; //identifier for this dialog
CTabsDlg* m_DockManager; //the dialog that contains m_ContainedDialog when docked
protected:
DECLARE_MESSAGE_MAP()
bool m_DragPreviewActive;
public:
afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point);
void SetDialog ( CWnd* dlg , int ID );
void SetDockManager ( CTabsDlg* dlg );
afx_msg void OnClose();
BOOL PreTranslateMessage( MSG* pMsg );
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnDestroy();
afx_msg void OnSetFocus(CWnd* pOldWnd);
};

View File

@@ -0,0 +1,215 @@
/*
===========================================================================
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 "qe3.h"
#include "Radiant.h"
#include "TextureBar.h"
//++timo TODO : the whole CTextureBar has to be modified for the new texture code
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTextureBar dialog
CTextureBar::CTextureBar()
: CDialogBar()
{
//{{AFX_DATA_INIT(CTextureBar)
m_nHShift = 0;
m_nHScale = 0;
m_nRotate = 0;
m_nVShift = 0;
m_nVScale = 0;
m_nRotateAmt = 45;
//}}AFX_DATA_INIT
}
void CTextureBar::DoDataExchange(CDataExchange* pDX)
{
CDialogBar::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTextureBar)
DDX_Control(pDX, IDC_SPIN_ROTATE, m_spinRotate);
DDX_Control(pDX, IDC_SPIN_VSCALE, m_spinVScale);
DDX_Control(pDX, IDC_SPIN_VSHIFT, m_spinVShift);
DDX_Control(pDX, IDC_SPIN_HSCALE, m_spinHScale);
DDX_Control(pDX, IDC_SPIN_HSHIFT, m_spinHShift);
DDX_Text(pDX, IDC_HSHIFT, m_nHShift);
DDX_Text(pDX, IDC_HSCALE, m_nHScale);
DDX_Text(pDX, IDC_ROTATE, m_nRotate);
DDX_Text(pDX, IDC_VSHIFT, m_nVShift);
DDX_Text(pDX, IDC_VSCALE, m_nVScale);
DDX_Text(pDX, IDC_EDIT_ROTATEAMT, m_nRotateAmt);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTextureBar, CDialogBar)
//{{AFX_MSG_MAP(CTextureBar)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HSHIFT, OnDeltaposSpinHshift)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_VSHIFT, OnDeltaposSpinVshift)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HSCALE, OnDeltaposSpinHScale)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_VSCALE, OnDeltaposSpinVScale)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ROTATE, OnDeltaposSpinRotate)
ON_COMMAND(ID_SELECTION_PRINT, OnSelectionPrint)
ON_WM_CREATE()
ON_BN_CLICKED(IDC_BTN_APPLYTEXTURESTUFF, OnBtnApplytexturestuff)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTextureBar message handlers
void CTextureBar::OnDeltaposSpinHshift(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
*pResult = 0;
if (pNMUpDown->iDelta < 0)
Select_ShiftTexture(abs(g_qeglobals.d_savedinfo.m_nTextureTweak), 0);
else
Select_ShiftTexture(-abs(g_qeglobals.d_savedinfo.m_nTextureTweak), 0);
GetSurfaceAttributes();
}
void CTextureBar::OnDeltaposSpinVshift(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
// TODO: Add your control notification handler code here
*pResult = 0;
if (pNMUpDown->iDelta < 0)
Select_ShiftTexture(0, abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
else
Select_ShiftTexture(0, -abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
GetSurfaceAttributes();
}
void CTextureBar::OnDeltaposSpinHScale(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
// TODO: Add your control notification handler code here
*pResult = 0;
if (pNMUpDown->iDelta < 0)
Select_ScaleTexture((float)abs(g_qeglobals.d_savedinfo.m_nTextureTweak),0);
else
Select_ScaleTexture((float)-abs(g_qeglobals.d_savedinfo.m_nTextureTweak),0);
GetSurfaceAttributes();
}
void CTextureBar::OnDeltaposSpinVScale(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
// TODO: Add your control notification handler code here
*pResult = 0;
if (pNMUpDown->iDelta < 0)
Select_ScaleTexture(0, (float)abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
else
Select_ScaleTexture(0, (float)-abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
GetSurfaceAttributes();
}
void CTextureBar::OnDeltaposSpinRotate(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
*pResult = 0;
UpdateData(TRUE);
if (pNMUpDown->iDelta < 0)
Select_RotateTexture(abs(m_nRotateAmt));
else
Select_RotateTexture(-abs(m_nRotateAmt));
GetSurfaceAttributes();
}
void CTextureBar::OnSelectionPrint()
{
// TODO: Add your command handler code here
}
int CTextureBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialogBar::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}
void CTextureBar::OnBtnApplytexturestuff()
{
SetSurfaceAttributes();
}
void CTextureBar::GetSurfaceAttributes()
{
texdef_t* pt = (g_ptrSelectedFaces.GetSize() > 0) ? &(reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0)))->texdef : &g_qeglobals.d_texturewin.texdef;
if (pt)
{
m_nHShift = pt->shift[0];
m_nVShift = pt->shift[1];
m_nHScale = pt->scale[0];
m_nVScale = pt->scale[1];
m_nRotate = pt->rotate;
UpdateData(FALSE);
}
}
//++timo implement brush primitive here
void CTextureBar::SetSurfaceAttributes()
{
if (g_ptrSelectedFaces.GetSize() > 0)
{
if (g_qeglobals.m_bBrushPrimitMode)
{
common->Printf("Warning : brush primitive mode not implemented in CTextureBar");
}
face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));
texdef_t* pt = &selFace->texdef;
UpdateData(TRUE);
pt->shift[0] = m_nHShift;
pt->shift[1] = m_nVShift;
pt->scale[0] = m_nHScale;
pt->scale[1] = m_nVScale;
pt->rotate = m_nRotate;
Sys_UpdateWindows(W_CAMERA);
}
}

View File

@@ -0,0 +1,91 @@
/*
===========================================================================
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.
===========================================================================
*/
#if !defined(AFX_TEXTUREBAR_H__86220273_B656_11D1_B59F_00AA00A410FC__INCLUDED_)
#define AFX_TEXTUREBAR_H__86220273_B656_11D1_B59F_00AA00A410FC__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// TextureBar.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CTextureBar dialog
class CTextureBar : public CDialogBar
{
// Construction
public:
void GetSurfaceAttributes();
void SetSurfaceAttributes();
CTextureBar();
// Dialog Data
//{{AFX_DATA(CTextureBar)
enum { IDD = IDD_TEXTUREBAR };
CSpinButtonCtrl m_spinRotate;
CSpinButtonCtrl m_spinVScale;
CSpinButtonCtrl m_spinVShift;
CSpinButtonCtrl m_spinHScale;
CSpinButtonCtrl m_spinHShift;
int m_nHShift;
int m_nHScale;
int m_nRotate;
int m_nVShift;
int m_nVScale;
int m_nRotateAmt;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTextureBar)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CTextureBar)
afx_msg void OnDeltaposSpinHshift(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnDeltaposSpinVshift(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnDeltaposSpinHScale(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnDeltaposSpinVScale(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnDeltaposSpinRotate(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnSelectionPrint();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnBtnApplytexturestuff();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_TEXTUREBAR_H__86220273_B656_11D1_B59F_00AA00A410FC__INCLUDED_)

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.
===========================================================================
*/
// a texturename of the form (0 0 0) will
// create a solid color texture
void Texture_Init (bool bHardInit = true);
void Texture_FlushUnused ();
void Texture_Flush (bool bReload = false);
void Texture_ClearInuse (void);
void Texture_ShowInuse (void);
void Texture_ShowDirectory (int menunum, bool bLinked = false);
void Texture_ShowAll();
void Texture_HideAll();
void Texture_Cleanup(CStringList *pList = NULL);
// TTimo: added bNoAlpha flag to ignore alpha channel when parsing a .TGA file, transparency is usually achieved through qer_trans keyword in shaders
// in some cases loading an empty alpha channel causes display bugs (brushes not seen)
//qtexture_t *Texture_ForName (const char *name, bool bReplace = false, bool bShader = false, bool bNoAlpha = false, bool bReload = false, bool makeShader = true);
const idMaterial *Texture_ForName(const char *name);
void Texture_Init (void);
void Texture_SetTexture (texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale = false, bool bSetSelection = true);
void Texture_SetMode(int iMenu); // GL_TEXTURE_NEAREST, etc..
void Texture_ResetPosition();
void FreeShaders();
void LoadShaders();
void ReloadShaders();
int WINAPI Texture_LoadSkin(char *pName, int *pnWidth, int *pnHeight);
void Texture_StartPos (void);
qtexture_t *Texture_NextPos (int *x, int *y);

Some files were not shown because too many files have changed in this diff Show More