WIN_DLG.CPP 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. 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.
  17. 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.
  18. ===========================================================================
  19. */
  20. #include "../../idlib/precompiled.h"
  21. #pragma hdrstop
  22. #include "qe3.h"
  23. BOOL CALLBACK EditCommandDlgProc (
  24. HWND hwndDlg, // handle to dialog box
  25. UINT uMsg, // message
  26. WPARAM wParam, // first message parameter
  27. LPARAM lParam // second message parameter
  28. )
  29. {
  30. char key[1024];
  31. char value[1024];
  32. const char *temp;
  33. int index;
  34. HWND hOwner;
  35. hOwner = GetParent (hwndDlg);
  36. switch (uMsg)
  37. {
  38. case WM_INITDIALOG:
  39. index = SendDlgItemMessage (hOwner, IDC_CMD_LIST, LB_GETCURSEL, 0, 0);
  40. if (index >= 0)
  41. {
  42. SendDlgItemMessage(hOwner, IDC_CMD_LIST, LB_GETTEXT, index, (LPARAM) (LPCTSTR) key);
  43. temp = ValueForKey (g_qeglobals.d_project_entity, key);
  44. strcpy (value, temp);
  45. SetDlgItemText(hwndDlg, IDC_CMDMENUTEXT, key);
  46. SetDlgItemText(hwndDlg, IDC_CMDCOMMAND, value);
  47. }
  48. return FALSE;
  49. break;
  50. case WM_COMMAND:
  51. switch (LOWORD(wParam))
  52. {
  53. case IDOK:
  54. if (!GetDlgItemText(hwndDlg, IDC_CMDMENUTEXT, key, 64))
  55. {
  56. common->Printf ("Command not added\n");
  57. return FALSE;
  58. }
  59. if (!GetDlgItemText(hwndDlg, IDC_CMDCOMMAND, value, 64))
  60. {
  61. common->Printf ("Command not added\n");
  62. return FALSE;
  63. }
  64. //if (key[0] == 'b' && key[1] == 's' && key[2] == 'p')
  65. //{
  66. SetKeyValue (g_qeglobals.d_project_entity, key, value);
  67. FillBSPMenu ();
  68. //}
  69. //else
  70. // common->Printf ("BSP commands must be preceded by \"bsp\"");
  71. EndDialog(hwndDlg, 1);
  72. return TRUE;
  73. case IDCANCEL:
  74. EndDialog(hwndDlg, 0);
  75. return TRUE;
  76. }
  77. }
  78. return FALSE;
  79. }
  80. BOOL CALLBACK AddCommandDlgProc (
  81. HWND hwndDlg, // handle to dialog box
  82. UINT uMsg, // message
  83. WPARAM wParam, // first message parameter
  84. LPARAM lParam // second message parameter
  85. )
  86. {
  87. char key[64];
  88. char value[128];
  89. switch (uMsg)
  90. {
  91. case WM_COMMAND:
  92. switch (LOWORD(wParam))
  93. {
  94. case IDOK:
  95. if (!GetDlgItemText(hwndDlg, IDC_CMDMENUTEXT, key, 64))
  96. {
  97. common->Printf ("Command not added\n");
  98. return FALSE;
  99. }
  100. if (!GetDlgItemText(hwndDlg, IDC_CMDCOMMAND, value, 64))
  101. {
  102. common->Printf ("Command not added\n");
  103. return FALSE;
  104. }
  105. if (key[0] == 'b' && key[1] == 's' && key[2] == 'p')
  106. {
  107. SetKeyValue (g_qeglobals.d_project_entity, key, value);
  108. FillBSPMenu ();
  109. }
  110. else
  111. common->Printf ("BSP commands must be preceded by \"bsp\"");
  112. EndDialog(hwndDlg, 1);
  113. return TRUE;
  114. case IDCANCEL:
  115. EndDialog(hwndDlg, 0);
  116. return TRUE;
  117. }
  118. }
  119. return FALSE;
  120. }
  121. void UpdateBSPCommandList (HWND hwndDlg)
  122. {
  123. int i;
  124. SendDlgItemMessage(hwndDlg, IDC_CMD_LIST, LB_RESETCONTENT, 0 , 0);
  125. i = 0;
  126. int count = g_qeglobals.d_project_entity->epairs.GetNumKeyVals();
  127. for (int j = 0; j < count; j++) {
  128. if (g_qeglobals.d_project_entity->epairs.GetKeyVal(j)->GetKey()[0] == 'b' && g_qeglobals.d_project_entity->epairs.GetKeyVal(j)->GetKey()[1] == 's' && g_qeglobals.d_project_entity->epairs.GetKeyVal(j)->GetKey()[2] == 'p') {
  129. SendDlgItemMessage(hwndDlg, IDC_CMD_LIST, LB_ADDSTRING, i , (LPARAM) g_qeglobals.d_project_entity->epairs.GetKeyVal(j)->GetKey().c_str());
  130. i++;
  131. }
  132. }
  133. }
  134. // FIXME: turn this into an MFC dialog
  135. BOOL CALLBACK ProjectDlgProc (
  136. HWND hwndDlg, // handle to dialog box
  137. UINT uMsg, // message
  138. WPARAM wParam, // first message parameter
  139. LPARAM lParam // second message parameter
  140. )
  141. {
  142. char key[1024];
  143. char value[1024];
  144. int index;
  145. switch (uMsg)
  146. {
  147. case WM_INITDIALOG:
  148. SetDlgItemText(hwndDlg, IDC_PRJBASEPATH, ValueForKey (g_qeglobals.d_project_entity, "basepath"));
  149. SetDlgItemText(hwndDlg, IDC_PRJMAPSPATH, ValueForKey (g_qeglobals.d_project_entity, "mapspath"));
  150. SetDlgItemText(hwndDlg, IDC_PRJRSHCMD, ValueForKey (g_qeglobals.d_project_entity, "rshcmd"));
  151. SetDlgItemText(hwndDlg, IDC_PRJREMOTEBASE, ValueForKey (g_qeglobals.d_project_entity, "remotebasepath"));
  152. SetDlgItemText(hwndDlg, IDC_PRJENTITYPATH, ValueForKey (g_qeglobals.d_project_entity, "entitypath"));
  153. SetDlgItemText(hwndDlg, IDC_PRJTEXPATH, ValueForKey (g_qeglobals.d_project_entity, "texturepath"));
  154. UpdateBSPCommandList (hwndDlg);
  155. // Timo
  156. // additional fields
  157. CheckDlgButton( hwndDlg, IDC_CHECK_BPRIMIT, (g_qeglobals.m_bBrushPrimitMode) ? BST_CHECKED : BST_UNCHECKED );
  158. // SendMessage( ::GetDlgItem( hwndDlg, IDC_CHECK_BPRIMIT ), BM_SETCHECK, (WPARAM) g_qeglobals.m_bBrushPrimitMode, 0 );
  159. return TRUE;
  160. case WM_COMMAND:
  161. switch (LOWORD(wParam))
  162. {
  163. case IDC_ADDCMD:
  164. // DialogBox(g_qeglobals.d_hInstance, (char *)IDD_ADDCMD, g_qeglobals.d_hwndMain, AddCommandDlgProc);
  165. DialogBox(g_qeglobals.d_hInstance, (char *)IDD_ADDCMD, hwndDlg, AddCommandDlgProc);
  166. UpdateBSPCommandList (hwndDlg);
  167. break;
  168. case IDC_EDITCMD:
  169. // DialogBox(g_qeglobals.d_hInstance, (char *)IDD_ADDCMD, g_qeglobals.d_hwndMain, EditCommandDlgProc);
  170. DialogBox(g_qeglobals.d_hInstance, (char *)IDD_ADDCMD, hwndDlg, EditCommandDlgProc);
  171. UpdateBSPCommandList (hwndDlg);
  172. break;
  173. case IDC_REMCMD:
  174. index = SendDlgItemMessage (hwndDlg, IDC_CMD_LIST, LB_GETCURSEL, 0, 0);
  175. SendDlgItemMessage(hwndDlg, IDC_CMD_LIST, LB_GETTEXT, index, (LPARAM) (LPCTSTR) key);
  176. DeleteKey (g_qeglobals.d_project_entity, key);
  177. common->Printf ("Selected %d\n", index);
  178. UpdateBSPCommandList (hwndDlg);
  179. break;
  180. case IDOK:
  181. GetDlgItemText(hwndDlg, IDC_PRJBASEPATH, value, 1024);
  182. SetKeyValue (g_qeglobals.d_project_entity, "basepath", value);
  183. GetDlgItemText(hwndDlg, IDC_PRJMAPSPATH, value, 1024);
  184. SetKeyValue (g_qeglobals.d_project_entity, "mapspath", value);
  185. GetDlgItemText(hwndDlg, IDC_PRJRSHCMD, value, 1024);
  186. SetKeyValue (g_qeglobals.d_project_entity, "rshcmd", value);
  187. GetDlgItemText(hwndDlg, IDC_PRJREMOTEBASE, value, 1024);
  188. SetKeyValue (g_qeglobals.d_project_entity, "remotebasepath", value);
  189. GetDlgItemText(hwndDlg, IDC_PRJENTITYPATH, value, 1024);
  190. SetKeyValue (g_qeglobals.d_project_entity, "entitypath", value);
  191. GetDlgItemText(hwndDlg, IDC_PRJTEXPATH, value, 1024);
  192. SetKeyValue (g_qeglobals.d_project_entity, "texturepath", value);
  193. // Timo
  194. // read additional fields
  195. if ( IsDlgButtonChecked( hwndDlg, IDC_CHECK_BPRIMIT ) )
  196. {
  197. g_qeglobals.m_bBrushPrimitMode = TRUE;
  198. }
  199. else
  200. {
  201. g_qeglobals.m_bBrushPrimitMode = FALSE;
  202. }
  203. SetKeyValue ( g_qeglobals.d_project_entity, "brush_primit", ( g_qeglobals.m_bBrushPrimitMode ? "1" : "0" ) );
  204. EndDialog(hwndDlg, 1);
  205. QE_SaveProject(g_strProject);
  206. return TRUE;
  207. case IDCANCEL:
  208. EndDialog(hwndDlg, 0);
  209. return TRUE;
  210. }
  211. }
  212. return FALSE;
  213. }
  214. void DoProjectSettings()
  215. {
  216. DialogBox(g_qeglobals.d_hInstance, (char *)IDD_PROJECT, g_pParentWnd->GetSafeHwnd(), ProjectDlgProc);
  217. }
  218. BOOL CALLBACK GammaDlgProc (
  219. HWND hwndDlg, // handle to dialog box
  220. UINT uMsg, // message
  221. WPARAM wParam, // first message parameter
  222. LPARAM lParam // second message parameter
  223. )
  224. {
  225. char sz[256];
  226. switch (uMsg)
  227. {
  228. case WM_INITDIALOG:
  229. sprintf(sz, "%1.1f", g_qeglobals.d_savedinfo.fGamma);
  230. SetWindowText(GetDlgItem(hwndDlg, IDC_G_EDIT), sz);
  231. return TRUE;
  232. case WM_COMMAND:
  233. switch (LOWORD(wParam))
  234. {
  235. case IDOK:
  236. GetWindowText(GetDlgItem(hwndDlg, IDC_G_EDIT), sz, 255);
  237. g_qeglobals.d_savedinfo.fGamma = atof(sz);
  238. EndDialog(hwndDlg, 1);
  239. return TRUE;
  240. case IDCANCEL:
  241. EndDialog(hwndDlg, 0);
  242. return TRUE;
  243. }
  244. }
  245. return FALSE;
  246. }
  247. void DoGamma(void)
  248. {
  249. if ( DialogBox(g_qeglobals.d_hInstance, (char *)IDD_GAMMA, g_pParentWnd->GetSafeHwnd(), GammaDlgProc))
  250. {
  251. }
  252. }
  253. //================================================
  254. void SelectBrush (int entitynum, int brushnum)
  255. {
  256. entity_t *e;
  257. brush_t *b;
  258. int i;
  259. if (entitynum == 0)
  260. e = world_entity;
  261. else
  262. {
  263. e = entities.next;
  264. while (--entitynum)
  265. {
  266. e=e->next;
  267. if (e == &entities)
  268. {
  269. Sys_Status ("No such entity.", 0);
  270. return;
  271. }
  272. }
  273. }
  274. b = e->brushes.onext;
  275. if (b == &e->brushes)
  276. {
  277. Sys_Status ("No such brush.", 0);
  278. return;
  279. }
  280. while (brushnum--)
  281. {
  282. b=b->onext;
  283. if (b == &e->brushes)
  284. {
  285. Sys_Status ("No such brush.", 0);
  286. return;
  287. }
  288. }
  289. Brush_RemoveFromList (b);
  290. Brush_AddToList (b, &selected_brushes);
  291. Sys_UpdateWindows (W_ALL);
  292. for (i=0 ; i<3 ; i++)
  293. {
  294. if (g_pParentWnd->GetXYWnd())
  295. g_pParentWnd->GetXYWnd()->GetOrigin()[i] = (b->mins[i] + b->maxs[i])/2;
  296. if (g_pParentWnd->GetXZWnd())
  297. g_pParentWnd->GetXZWnd()->GetOrigin()[i] = (b->mins[i] + b->maxs[i])/2;
  298. if (g_pParentWnd->GetYZWnd())
  299. g_pParentWnd->GetYZWnd()->GetOrigin()[i] = (b->mins[i] + b->maxs[i])/2;
  300. }
  301. Sys_Status ("Selected.", 0);
  302. }
  303. /*
  304. =================
  305. GetSelectionIndex
  306. =================
  307. */
  308. void GetSelectionIndex (int *ent, int *brush)
  309. {
  310. brush_t *b, *b2;
  311. entity_t *entity;
  312. *ent = *brush = 0;
  313. b = selected_brushes.next;
  314. if (b == &selected_brushes)
  315. return;
  316. // find entity
  317. if (b->owner != world_entity)
  318. {
  319. (*ent)++;
  320. for (entity = entities.next ; entity != &entities
  321. ; entity=entity->next, (*ent)++)
  322. ;
  323. }
  324. // find brush
  325. for (b2=b->owner->brushes.onext
  326. ; b2 != b && b2 != &b->owner->brushes
  327. ; b2=b2->onext, (*brush)++)
  328. ;
  329. }
  330. BOOL CALLBACK FindBrushDlgProc (
  331. HWND hwndDlg, // handle to dialog box
  332. UINT uMsg, // message
  333. WPARAM wParam, // first message parameter
  334. LPARAM lParam // second message parameter
  335. )
  336. {
  337. char entstr[256];
  338. char brushstr[256];
  339. HWND h;
  340. int ent, brush;
  341. switch (uMsg)
  342. {
  343. case WM_INITDIALOG:
  344. // set entity and brush number
  345. GetSelectionIndex (&ent, &brush);
  346. sprintf (entstr, "%i", ent);
  347. sprintf (brushstr, "%i", brush);
  348. SetWindowText(GetDlgItem(hwndDlg, IDC_FIND_ENTITY), entstr);
  349. SetWindowText(GetDlgItem(hwndDlg, IDC_FIND_BRUSH), brushstr);
  350. h = GetDlgItem(hwndDlg, IDC_FIND_ENTITY);
  351. SetFocus (h);
  352. return FALSE;
  353. case WM_COMMAND:
  354. switch (LOWORD(wParam))
  355. {
  356. case IDOK:
  357. GetWindowText(GetDlgItem(hwndDlg, IDC_FIND_ENTITY), entstr, 255);
  358. GetWindowText(GetDlgItem(hwndDlg, IDC_FIND_BRUSH), brushstr, 255);
  359. SelectBrush (atoi(entstr), atoi(brushstr));
  360. EndDialog(hwndDlg, 1);
  361. return TRUE;
  362. case IDCANCEL:
  363. EndDialog(hwndDlg, 0);
  364. return TRUE;
  365. }
  366. }
  367. return FALSE;
  368. }
  369. void DoFind(void)
  370. {
  371. DialogBox(g_qeglobals.d_hInstance, (char *)IDD_FINDBRUSH, g_pParentWnd->GetSafeHwnd(), FindBrushDlgProc);
  372. }
  373. /*
  374. ===================================================
  375. ARBITRARY ROTATE
  376. ===================================================
  377. */
  378. BOOL CALLBACK RotateDlgProc (
  379. HWND hwndDlg, // handle to dialog box
  380. UINT uMsg, // message
  381. WPARAM wParam, // first message parameter
  382. LPARAM lParam // second message parameter
  383. )
  384. {
  385. char str[256];
  386. HWND h;
  387. float v;
  388. switch (uMsg)
  389. {
  390. case WM_INITDIALOG:
  391. h = GetDlgItem(hwndDlg, IDC_FIND_ENTITY);
  392. SetFocus (h);
  393. return FALSE;
  394. case WM_COMMAND:
  395. switch (LOWORD(wParam))
  396. {
  397. case IDOK:
  398. GetWindowText(GetDlgItem(hwndDlg, IDC_ROTX), str, 255);
  399. v = atof(str);
  400. if (v)
  401. Select_RotateAxis (0, v);
  402. GetWindowText(GetDlgItem(hwndDlg, IDC_ROTY), str, 255);
  403. v = atof(str);
  404. if (v)
  405. Select_RotateAxis (1, v);
  406. GetWindowText(GetDlgItem(hwndDlg, IDC_ROTZ), str, 255);
  407. v = atof(str);
  408. if (v)
  409. Select_RotateAxis (2, v);
  410. EndDialog(hwndDlg, 1);
  411. return TRUE;
  412. case IDCANCEL:
  413. EndDialog(hwndDlg, 0);
  414. return TRUE;
  415. }
  416. }
  417. return FALSE;
  418. }
  419. void DoRotate(void)
  420. {
  421. DialogBox(g_qeglobals.d_hInstance, (char *)IDD_ROTATE, g_pParentWnd->GetSafeHwnd(), RotateDlgProc);
  422. }
  423. /*
  424. ===================================================
  425. ARBITRARY SIDES
  426. ===================================================
  427. */
  428. bool g_bDoCone = false;
  429. bool g_bDoSphere = false;
  430. BOOL CALLBACK SidesDlgProc (
  431. HWND hwndDlg, // handle to dialog box
  432. UINT uMsg, // message
  433. WPARAM wParam, // first message parameter
  434. LPARAM lParam // second message parameter
  435. )
  436. {
  437. char str[256];
  438. HWND h;
  439. switch (uMsg)
  440. {
  441. case WM_INITDIALOG:
  442. h = GetDlgItem(hwndDlg, IDC_SIDES);
  443. SetFocus (h);
  444. return FALSE;
  445. case WM_COMMAND:
  446. switch (LOWORD(wParam)) {
  447. case IDOK:
  448. GetWindowText(GetDlgItem(hwndDlg, IDC_SIDES), str, 255);
  449. if (g_bDoCone)
  450. Brush_MakeSidedCone(atoi(str));
  451. else if (g_bDoSphere)
  452. Brush_MakeSidedSphere(atoi(str));
  453. else
  454. Brush_MakeSided (atoi(str));
  455. EndDialog(hwndDlg, 1);
  456. break;
  457. case IDCANCEL:
  458. EndDialog(hwndDlg, 0);
  459. break;
  460. }
  461. default:
  462. return FALSE;
  463. }
  464. }
  465. void DoSides(bool bCone, bool bSphere, bool bTorus)
  466. {
  467. g_bDoCone = bCone;
  468. g_bDoSphere = bSphere;
  469. //g_bDoTorus = bTorus;
  470. DialogBox(g_qeglobals.d_hInstance, (char *)IDD_SIDES, g_pParentWnd->GetSafeHwnd(), SidesDlgProc);
  471. }
  472. //======================================================================
  473. /*
  474. ===================
  475. DoAbout
  476. ===================
  477. */
  478. BOOL CALLBACK AboutDlgProc( HWND hwndDlg,
  479. UINT uMsg,
  480. WPARAM wParam,
  481. LPARAM lParam )
  482. {
  483. switch (uMsg)
  484. {
  485. case WM_INITDIALOG:
  486. {
  487. char buffer[1024];
  488. idStr::snPrintf(buffer, 1024, "DOOM Radiant Build %d\nCopyright ©1999-2004 Id Software, Inc.\n", BUILD_NUMBER);
  489. // SetDlgItemText( hwndDlg, IDC_ABOUT_INFO, buffer);
  490. idStr::snPrintf( buffer, 1024, "Renderer:\t%s", qglGetString( GL_RENDERER ) );
  491. SetDlgItemText( hwndDlg, IDC_ABOUT_GLRENDERER, buffer );
  492. idStr::snPrintf( buffer, 1024, "Version:\t\t%s", qglGetString( GL_VERSION ) );
  493. SetDlgItemText( hwndDlg, IDC_ABOUT_GLVERSION, buffer );
  494. idStr::snPrintf( buffer, 1024, "Vendor:\t\t%s", qglGetString( GL_VENDOR ) );
  495. SetDlgItemText( hwndDlg, IDC_ABOUT_GLVENDOR, buffer);
  496. char extensions[4096];
  497. idStr::snPrintf( extensions, 4096, "%s", qglGetString( GL_EXTENSIONS ) );
  498. HWND hWndExtensions = GetDlgItem( hwndDlg, IDC_ABOUT_GLEXTENSIONS );
  499. char *start = extensions;
  500. char *end;
  501. do {
  502. end = strchr(start, ' ');
  503. if ( end ) {
  504. *end = 0;
  505. }
  506. SendMessage( hWndExtensions, LB_ADDSTRING, 0, (LPARAM)start );
  507. start = end + 1;
  508. } while ( end );
  509. }
  510. return TRUE;
  511. case WM_CLOSE:
  512. EndDialog( hwndDlg, 1 );
  513. return TRUE;
  514. case WM_COMMAND:
  515. if ( LOWORD( wParam ) == IDOK )
  516. EndDialog(hwndDlg, 1);
  517. return TRUE;
  518. }
  519. return FALSE;
  520. }
  521. void DoAbout(void)
  522. {
  523. DialogBox( g_qeglobals.d_hInstance, ( char * ) IDD_ABOUT, g_pParentWnd->GetSafeHwnd(), AboutDlgProc );
  524. }