29 #include "../../idlib/precompiled.h"
36 #include "entitydlg.h"
40 #include "../../renderer/model_local.h"
51 multipleEntities =
false;
52 currentAnimation =
NULL;
61 CDialog::DoDataExchange(pDX);
99 CDialog::OnInitDialog();
113 return CDialog::OnToolHitTest(point, pTI);
119 for (eclass_t *pec = eclass; pec; pec = pec->next) {
129 ON_BN_CLICKED(
IDC_E_135, OnBnClickedE135)
130 ON_BN_CLICKED(
IDC_E_90, OnBnClickedE90)
131 ON_BN_CLICKED(
IDC_E_45, OnBnClickedE45)
132 ON_BN_CLICKED(
IDC_E_180, OnBnClickedE180)
133 ON_BN_CLICKED(
IDC_E_0, OnBnClickedE0)
134 ON_BN_CLICKED(
IDC_E_225, OnBnClickedE225)
135 ON_BN_CLICKED(
IDC_E_270, OnBnClickedE270)
136 ON_BN_CLICKED(
IDC_E_315, OnBnClickedE315)
137 ON_BN_CLICKED(
IDC_E_UP, OnBnClickedEUp)
143 ON_CBN_DBLCLK(IDC_COMBO_CLASS, OnCbnDblclkComboClass)
145 ON_LBN_DBLCLK(IDC_LIST_KEYVAL, OnLbnDblclkListkeyval)
147 ON_LBN_DBLCLK(IDC_LIST_VARS, OnLbnDblclkListVars)
156 ON_BN_CLICKED(IDOK, OnOK)
161 if (staticTitle.GetSafeHwnd() ==
NULL) {
164 CDialog::OnSize(nType, cx, cy);
165 CRect rect, crect, crect2;
167 int bh = (
float)rect.Height() * (rect.Height() - 210) / rect.Height() / 2;
168 staticTitle.GetWindowRect(crect);
169 staticTitle.SetWindowPos(
NULL, 4, 4, rect.Width() -8, crect.Height(), SWP_SHOWWINDOW);
170 int top = 4 + crect.Height() + 4;
171 comboClass.GetWindowRect(crect);
172 btnCreate.GetWindowRect(crect2);
173 comboClass.SetWindowPos(
NULL, 4, top, rect.Width() - 12 - crect2.Width(), crect.Height(), SWP_SHOWWINDOW);
174 btnCreate.SetWindowPos(
NULL, rect.Width() - crect2.Width() - 4,
top, crect2.Width(), crect.Height(), SWP_SHOWWINDOW);
175 top += crect.Height() + 4;
176 listVars.SetWindowPos(
NULL, 4, top, rect.Width() - 8, bh, SWP_SHOWWINDOW);
178 listKeyVal.SetWindowPos(
NULL, 4, top, rect.Width() - 8, bh, SWP_SHOWWINDOW);
180 staticKey.GetWindowRect(crect);
181 staticKey.SetWindowPos(
NULL, 4, top + 2, crect.Width(), crect.Height(), SWP_SHOWWINDOW);
182 int left = 4 + crect.Width() + 4;
183 int pad = crect.Width();
184 editKey.GetWindowRect(crect);
185 editKey.SetWindowPos(
NULL, left, top, rect.Width() - 12 - pad, crect.Height(), SWP_SHOWWINDOW);
186 top += crect.Height() + 4;
187 staticVal.GetWindowRect(crect);
188 staticVal.SetWindowPos(
NULL, 4, top + 2, crect.Width(), crect.Height(), SWP_SHOWWINDOW);
189 editVal.GetWindowRect(crect);
191 editVal.SetWindowPos(
NULL, left, top, rect.Width() - 16 - bh - pad, crect.Height(), SWP_SHOWWINDOW);
192 btnBrowse.SetWindowPos(
NULL, rect.right - 4 - bh, top, bh, bh, SWP_SHOWWINDOW);
193 top += crect.Height() + 8;
194 btnModel.GetWindowRect(crect);
195 btnModel.SetWindowPos(
NULL, rect.right - 4 - crect.Width(), top + 8, crect.Width(), crect.Height(), SWP_SHOWWINDOW);
196 btnSound.SetWindowPos(
NULL, rect.right - 4 - crect.Width(), top + 12 + crect.Height(), crect.Width(), crect.Height(), SWP_SHOWWINDOW);
197 btnGui.SetWindowPos(
NULL, rect.right - 4 - crect.Width(), top + 16 + crect.Height() * 2, crect.Width(), crect.Height(), SWP_SHOWWINDOW);
198 btnParticle.SetWindowPos(
NULL, rect.right - 8 - (crect.Width() * 2), top + 16 + crect.Height() * 2, crect.Width(), crect.Height(), SWP_SHOWWINDOW);
199 btnSkin.SetWindowPos(
NULL, rect.right - 8 - ( crect.Width() * 2 ), top + 12 + crect.Height(), crect.Width(), crect.Height(), SWP_SHOWWINDOW );
200 btnCurve.SetWindowPos(
NULL, rect.right - 8 - ( crect.Width() * 2 ), top + 8, crect.Width(), crect.Height(), SWP_SHOWWINDOW );
205 int rightAnimAreaBorder = rect.right - 75 - crect.Width ();
207 btnStopAnim.GetWindowRect(crect);
208 btnStopAnim.SetWindowPos(
NULL,rightAnimAreaBorder - crect.Width (),
209 top + 8 ,crect.Width(),crect.Height(),SWP_SHOWWINDOW);
211 left = rightAnimAreaBorder - crect.Width() - 4;
212 btnPlayAnim.GetWindowRect(crect);
213 btnPlayAnim.SetWindowPos(
NULL,left-crect.Width () ,top + 8 , crect.Width(),crect.Height(),SWP_SHOWWINDOW);
215 left -= crect.Width() + 4;
216 cbAnimations.GetWindowRect(crect);
217 cbAnimations.SetWindowPos(
NULL,left-crect.Width (),top + 8 ,crect.Width(),crect.Height(),SWP_SHOWWINDOW);
219 staticFrame.GetWindowRect(crect);
220 staticFrame.SetWindowPos(
NULL,rightAnimAreaBorder - crect.Width (),
221 top + 34 ,crect.Width(),crect.Height(),SWP_SHOWWINDOW);
223 left = rightAnimAreaBorder - crect.Width () - 4;
225 slFrameSlider.GetWindowRect(crect);
226 slFrameSlider.SetWindowPos(
NULL,left - crect.Width (),
227 top + 32 ,crect.Width(),crect.Height(),SWP_SHOWWINDOW);
232 btn135.GetWindowRect(crect);
234 btn135.SetWindowPos(
NULL, 4, top, bh, bh, SWP_SHOWWINDOW);
235 btn90.SetWindowPos(
NULL, 4 + 2 + bh, top, bh, bh, SWP_SHOWWINDOW);
236 btn45.SetWindowPos(
NULL, 4 + 2 + 2 + bh * 2, top, bh, bh, SWP_SHOWWINDOW);
237 btnUp.SetWindowPos(
NULL, 4 + 2 + 2 + 6 + bh * 3, top + bh / 2,bh,bh, SWP_SHOWWINDOW);
238 btnDown.SetWindowPos(
NULL, 4 + 2 + 2 + 6 + bh *3, top + bh / 2 + bh + 2,bh,bh, SWP_SHOWWINDOW);
240 btn180.SetWindowPos(
NULL, 4, top, bh, bh, SWP_SHOWWINDOW);
241 btn360.SetWindowPos(
NULL, 4 + 2 + 2 + bh * 2, top, bh, bh, SWP_SHOWWINDOW);
243 btn225.SetWindowPos(
NULL, 4, top, bh, bh, SWP_SHOWWINDOW);
244 btn270.SetWindowPos(
NULL, 4 + 2 + bh, top, bh, bh, SWP_SHOWWINDOW);
245 btn315.SetWindowPos(
NULL, 4 + 2 + 2 + bh * 2, top, bh, bh, SWP_SHOWWINDOW);
252 if (index != LB_ERR) {
273 int c = ent->vars.Num();
274 for (
int i = 0;
i <
c;
i++) {
286 static char buf2[32768];
292 for (i = 0; i <
l; i++) {
293 if (buf[i] ==
'\n') {
313 for (
int i = 0 ;
i <
c;
i++) {
326 for (
int i = 0;
i <
c;
i++) {
331 for (
int j = 0;
j < vc;
j++) {
391 for( i = 0; i <
num; i++ ) {
398 if ( selIndex != -1 ) {
411 if (index != LB_ERR) {
420 if (index != LB_ERR) {
424 for (i = 0; str[
i] !=
'\t' && str[
i] !=
'\0'; i++) {
428 while (str[i] ==
'\t' && str[i] !=
'\0') {
439 static int TabOrder[] = {
492 if (pMsg->hwnd ==
editVal.GetSafeHwnd()) {
493 if (pMsg->message == WM_LBUTTONDOWN) {
499 if (pMsg->hwnd ==
editKey.GetSafeHwnd()) {
500 if (pMsg->message == WM_LBUTTONDOWN) {
507 if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN ) {
515 if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN ) {
526 if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_DELETE &&
editEntity) {
532 if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE) {
533 if (pMsg->wParam == VK_ESCAPE) {
540 if ( pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN ) {
545 if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_TAB) {
547 int id = GetFocus()->GetDlgCtrlID();
549 if (TabOrder[
i] ==
id) {
554 CWnd *next = GetDlgItem(TabOrder[
i]);
567 if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RIGHT && pMsg->hwnd ==
slFrameSlider.GetSafeHwnd()) {
575 if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_LEFT && pMsg->hwnd ==
slFrameSlider.GetSafeHwnd()) {
587 return CDialog::PreTranslateMessage(pMsg);
606 bool isName = (
stricmp(Key,
"name") == 0);
607 bool isModel =
static_cast<bool>((
stricmp(Key,
"model") == 0 && Value.GetLength() > 0));
608 bool isOrigin = (
idStr::Icmp( Key,
"origin" ) == 0 );
616 if ( ! ( ( isModel || isOrigin ) && ( b->owner->eclass->nShowFlags & ECLASS_WORLDSPAWN ) ) ) {
626 if ( ! ( ( isModel || isOrigin ) && (
editEntity->
eclass->nShowFlags & ECLASS_WORLDSPAWN ) ) ) {
775 if (modelDlg.GetSafeHwnd() ==
NULL) {
778 modelDlg.ShowWindow( SW_SHOW );
779 modelDlg.BringWindowToTop();
789 if (modelDlg.GetSafeHwnd() ==
NULL) {
792 modelDlg.ShowWindow(SW_SHOW);
793 modelDlg.BringWindowToTop();
803 if (modelDlg.GetSafeHwnd() ==
NULL) {
807 modelDlg.ShowWindow(SW_SHOW);
808 modelDlg.BringWindowToTop();
818 if (guiDlg.GetSafeHwnd() ==
NULL) {
821 guiDlg.ShowWindow(SW_SHOW);
822 guiDlg.BringWindowToTop();
832 if (soundDlg.GetSafeHwnd() ==
NULL) {
835 soundDlg.ShowWindow(SW_SHOW);
845 if (matDlg.GetSafeHwnd() ==
NULL) {
848 matDlg.ShowWindow(SW_SHOW);
849 matDlg.BringWindowToTop();
862 editKey.SetWindowText(
"model");
871 editKey.SetWindowText(
"s_shader");
889 editKey.SetWindowText(
"model");
907 if ( dlg.DoModal() == IDOK ) {
944 bool forceFixed =
false;
950 pWnd->GetClientRect(rctZ);
960 MessageBox(
"You must have a selected brush to create an entity",
"info", 0);
966 if (index == LB_ERR) {
967 MessageBox(
"You must have a selected class to create an entity",
"info", 0);
974 if (!
stricmp(str,
"worldspawn")) {
975 MessageBox(
"Can't create an entity with worldspawn.",
"info", 0);
982 if ((GetAsyncKeyState(VK_CONTROL) & 0x8000)) {
985 brush_t temp_brushes;
986 temp_brushes.next = &temp_brushes;
989 brush_t *pBrush = temp_brushes.next;
990 while (pBrush !=
NULL && pBrush != &temp_brushes) {
991 brush_t *pNext = pBrush->next;
998 }
else if ((GetAsyncKeyState(VK_SHIFT) & 0x8000)) {
1005 if (petNew ==
NULL) {
1006 MessageBox(
"Failed to create entity.",
"info", 0);
1033 editVal.GetWindowText( Value );
1034 if (
stricmp( Key,
"script" ) == 0 ) {
1036 Value =
"script/" + Key;
1042 WinExec(
va(
"notepad.exe %s", work.
c_str() ), SW_SHOW );
1093 if ( updateKeyValueDisplay ) {
1116 if ( animName.GetLength() > 0 ) {
1143 SetTimer ( 0 , 1000/24 ,
NULL );
1182 start = end + 64 * dir;
1183 }
else if ( c > 0 ) {
1193 if ( g_qeglobals.d_select_mode == sel_editpoint ) {
1194 g_qeglobals.d_select_mode = sel_brush;
1208 if ( g_qeglobals.d_select_mode == sel_editpoint ) {
1209 g_qeglobals.d_select_mode = sel_brush;
1213 g_qeglobals.d_select_mode = sel_editpoint;
1215 g_qeglobals.d_numpoints = 0;
1216 g_qeglobals.d_num_move_points = 0;
1218 for (
int i = 0;
i <
c;
i++ ) {
1219 if ( g_qeglobals.d_numpoints <
MAX_POINTS - 1 ) {
1232 if ( g_qeglobals.d_select_mode != sel_editpoint ) {
1236 if ( g_qeglobals.d_num_move_points == 0 ) {
1248 if ( newCurve ==
NULL ) {
1268 start = end + 64 * dir;
1282 g_qeglobals.d_num_move_points = 0;
1298 if ( g_qeglobals.d_select_mode != sel_editpoint ) {
1303 if ( g_qeglobals.d_num_move_points == 0 ) {
1310 g_qeglobals.d_num_move_points = 0;
1329 if ( g_qeglobals.d_select_mode == sel_editpoint ) {
1330 g_qeglobals.d_numpoints = 0;
1332 for (
int i = 0;
i <
c;
i++ ) {
1333 if ( g_qeglobals.d_numpoints <
MAX_POINTS - 1 ) {
1354 bestd = 8 / scale / 2;
1357 for (i = 0; i < g_qeglobals.d_numpoints; i++) {
1358 temp = g_qeglobals.d_points[
i] - org;
1360 temp = org + d * dir;
1361 temp = g_qeglobals.d_points[
i] - temp;
1373 g_qeglobals.d_num_move_points = 0;
1374 assert ( besti < editEntity->curve->GetNumValues() );
CMainFrame * g_pParentWnd
afx_msg void OnBnClickedButtonGui()
void WINAPI Sys_UpdateWindows(int nBits)
type GetValue(const int index) const
int GetInt(const char *key, const char *defaultString="0") const
idCurve< idVec3 > * Entity_MakeCurve(entity_t *ent)
assert(prefInfo.fullscreenBtn)
virtual BOOL PreTranslateMessage(MSG *pMsg)
afx_msg void OnBnClickedE315()
virtual void DoDataExchange(CDataExchange *pDX)
void UpdateFromAnimationFrame(bool updateKeyValueDisplay=true)
afx_msg void OnLbnDblclkListVars()
afx_msg void OnCbnSelchangeComboClass()
static const char * TranslateString(const char *p)
CONST PIXELFORMATDESCRIPTOR UINT
virtual int ANIM_GetNumAnimsFromEntityDef(const idDict *args)
const idStr & GetKey(void) const
virtual int ReadFile(const char *relativePath, void **buffer, ID_TIME_T *timestamp=NULL)=0
GLenum GLenum GLenum GLenum GLenum scale
#define IDC_ENTITY_ANIMATIONS
static CPreviewDlg * ShowSoundChooser()
virtual int OnToolHitTest(CPoint point, TOOLINFO *pTI) const
void Entity_SetCurveData(entity_t *ent)
afx_msg void OnCbnDblclkComboClass()
void BuildEntityRenderState(entity_t *ent, bool update)
idFileSystem * fileSystem
afx_msg void OnBnClickedButtonModel()
void Brush_RebuildBrush(brush_t *b, idVec3 vMins, idVec3 vMaxs, bool patch=true)
#define IDC_ENTITY_STOP_ANIM
type * GetValueAddress(const int index)
afx_msg void OnSelchange()
const char * Left(int len, idStr &result) const
afx_msg void OnBnClickedButtonSkin()
#define VectorAdd(a, b, c)
afx_msg void OnLbnDblclkListkeyval()
void UpdateKeyVal(const char *key, const char *val)
brush_t * CreateEntityBrush(int x, int y, CXYWnd *pWnd)
afx_msg void OnBnClickedButtonCurve()
void SetMode(int mode, const char *preSelect=NULL)
void Set(const char *key, const char *value)
afx_msg void OnKillfocusEditBox()
static CPreviewDlg * ShowParticleChooser()
afx_msg void OnBnClickedE45()
void Brush_Build(brush_t *b, bool bSnap, bool bMarkMap, bool bConvert, bool updateLights)
void SetKeyValPairs(bool updateAnims=true)
int Icmp(const char *text) const
virtual int WriteFile(const char *relativePath, const void *buffer, int size, const char *basePath="fs_savepath")=0
afx_msg void OnCbnAnimationChange()
virtual const char * ANIM_GetAnimNameFromEntityDef(const idDict *args, int animNum)
void SetKeyValue(entity_t *ent, const char *key, const char *value, bool trackAngles)
void RebuildTree(const char *data)
afx_msg void OnBnClickedE270()
afx_msg void OnBnClickedEDown()
void Entity_UpdateSoundEmitter(entity_t *ent)
virtual BOOL OnInitDialog()
afx_msg void OnBnClickedE0()
void Entity_UpdateCurveData(entity_t *ent)
afx_msg void OnBnClickedE135()
afx_msg void OnBnClickedE90()
const char * GetString(const char *key, const char *defaultString="") const
void Brush_AddToList(brush_t *b, brush_t *list)
static CPreviewDlg * ShowModelChooser()
void Brush_CopyList(brush_t *pFrom, brush_t *pTo)
virtual idRenderModel * FindModel(const char *modelName)=0
virtual BOOL Create(LPCTSTR lpszTemplateName, CWnd *pParentWnd=NULL)
afx_msg void OnChangeEditBox()
#define IDC_ENTITY_PLAY_ANIM
const idStr & GetValue(void) const
virtual int ANIM_GetNumFrames(const idMD5Anim *anim)
const char * Right(int len, idStr &result) const
void Brush_RemoveFromList(brush_t *b)
#define IDC_BUTTON_BROWSE
#define IDC_ANIMATION_SLIDER
int AddPropItem(CPropertyItem *pItem)
const idKeyValue * FindKey(const char *key) const
void DeleteKey(entity_t *ent, const char *key)
void Entity_SetName(entity_t *e, const char *name)
virtual const idMD5Anim * ANIM_GetAnimFromEntityDef(const char *classname, const char *animname)
GLdouble GLdouble GLdouble top
const char * ToString(int precision=2) const
afx_msg void OnBnClickedStopAnimation()
afx_msg void OnLbnSelchangeListVars()
virtual const char * RelativePathToOSPath(const char *relativePath, const char *basePath="fs_devpath")=0
idCurve< idVec3 > * curve
void SetUpdateInspectors(bool b)
virtual void RemoveIndex(const int index)
afx_msg void OnLbnSelchangeListkeyval()
static CPreviewDlg * ShowMaterialChooser()
void UpdateEntitySel(eclass_t *ent)
afx_msg void OnBnClickedButtonParticle()
void SetInt(const char *key, int val)
idRenderModelManager * renderModelManager
static CPreviewDlg * ShowGuiChooser()
void OnTimer(UINT nIDEvent)
static CPreviewDlg * ShowSkinChooser(entity_t *ent)
const idMD5Anim * currentAnimation
virtual int AddValue(const float time, const type &value)
afx_msg void OnBnClickedStartAnimation()
const char * c_str(void) const
int currentAnimationFrame
const idKeyValue * GetKeyVal(int index) const
entity_t * Entity_Create(eclass_t *c, bool forceFixed)
#define IDC_BUTTON_CREATE
afx_msg void OnBnClickedEUp()
afx_msg void OnBnClickedButtonSound()
idBounds & ExpandSelf(const float d)
void OnNMReleasedcaptureSlider1(NMHDR *pNMHDR, LRESULT *pResult)
afx_msg void OnBnClickedButtonBrowse()
afx_msg void OnBnClickedButtonCreate()
#define IDC_ENTITY_CURRENT_ANIM
char * va(const char *fmt,...)
int GetNumValues(void) const
afx_msg void OnBnClickedE225()
int GetNumKeyVals(void) const
CSliderCtrl slFrameSlider
afx_msg void OnBnClickedE180()
int sprintf(idStr &string, const char *fmt,...)
#define IDD_DIALOG_PREVIEW
void SelectCurvePointByRay(const idVec3 &org, const idVec3 &dir, int buttons)
#define IDC_BUTTON_PARTICLE
eclass_t * Eclass_ForName(const char *name, bool has_brushes)