2 ===========================================================================
3 Copyright (C) 1997-2006 Id Software, Inc.
5 This file is part of Quake 2 Tools source code.
7 Quake 2 Tools source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
12 Quake 2 Tools source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Quake 2 Tools source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
25 BOOL CALLBACK GammaDlgProc (
26 HWND hwndDlg, // handle to dialog box
28 WPARAM wParam, // first message parameter
29 LPARAM lParam // second message parameter
37 sprintf(sz, "%1.1f", g_qeglobals.d_savedinfo.fGamma);
38 SetWindowText(GetDlgItem(hwndDlg, IDC_G_EDIT), sz);
41 switch (LOWORD(wParam))
45 GetWindowText(GetDlgItem(hwndDlg, IDC_G_EDIT), sz, 255);
46 g_qeglobals.d_savedinfo.fGamma = atof(sz);
47 EndDialog(hwndDlg, 1);
51 EndDialog(hwndDlg, 0);
63 if ( DialogBox(g_qeglobals.d_hInstance, (char *)IDD_GAMMA, g_qeglobals.d_hwndMain, GammaDlgProc))
65 psz = ValueForKey(world_entity, "_wad");
75 //================================================
78 void SelectBrush (int entitynum, int brushnum)
94 Sys_Status ("No such entity.", 0);
100 b = e->brushes.onext;
101 if (b == &e->brushes)
103 Sys_Status ("No such brush.", 0);
109 if (b == &e->brushes)
111 Sys_Status ("No such brush.", 0);
116 Brush_RemoveFromList (b);
117 Brush_AddToList (b, &selected_brushes);
120 Sys_UpdateWindows (W_ALL);
121 for (i=0 ; i<3 ; i++)
122 g_qeglobals.d_xy.origin[i] = (b->mins[i] + b->maxs[i])/2;
124 Sys_Status ("Selected.", 0);
132 void GetSelectionIndex (int *ent, int *brush)
139 b = selected_brushes.next;
140 if (b == &selected_brushes)
144 if (b->owner != world_entity)
147 for (entity = entities.next ; entity != &entities
148 ; entity=entity->next, (*ent)++)
153 for (b2=b->owner->brushes.onext
154 ; b2 != b && b2 != &b->owner->brushes
155 ; b2=b2->onext, (*brush)++)
159 BOOL CALLBACK FindBrushDlgProc (
160 HWND hwndDlg, // handle to dialog box
161 UINT uMsg, // message
162 WPARAM wParam, // first message parameter
163 LPARAM lParam // second message parameter
174 // set entity and brush number
175 GetSelectionIndex (&ent, &brush);
176 sprintf (entstr, "%i", ent);
177 sprintf (brushstr, "%i", brush);
178 SetWindowText(GetDlgItem(hwndDlg, IDC_FIND_ENTITY), entstr);
179 SetWindowText(GetDlgItem(hwndDlg, IDC_FIND_BRUSH), brushstr);
181 h = GetDlgItem(hwndDlg, IDC_FIND_ENTITY);
186 switch (LOWORD(wParam))
189 GetWindowText(GetDlgItem(hwndDlg, IDC_FIND_ENTITY), entstr, 255);
190 GetWindowText(GetDlgItem(hwndDlg, IDC_FIND_BRUSH), brushstr, 255);
191 SelectBrush (atoi(entstr), atoi(brushstr));
192 EndDialog(hwndDlg, 1);
196 EndDialog(hwndDlg, 0);
207 DialogBox(g_qeglobals.d_hInstance, (char *)IDD_FINDBRUSH, g_qeglobals.d_hwndMain, FindBrushDlgProc);
211 ===================================================
215 ===================================================
219 BOOL CALLBACK RotateDlgProc (
220 HWND hwndDlg, // handle to dialog box
221 UINT uMsg, // message
222 WPARAM wParam, // first message parameter
223 LPARAM lParam // second message parameter
233 h = GetDlgItem(hwndDlg, IDC_FIND_ENTITY);
238 switch (LOWORD(wParam))
242 GetWindowText(GetDlgItem(hwndDlg, IDC_ROTX), str, 255);
245 Select_RotateAxis (0, v);
247 GetWindowText(GetDlgItem(hwndDlg, IDC_ROTY), str, 255);
250 Select_RotateAxis (1, v);
252 GetWindowText(GetDlgItem(hwndDlg, IDC_ROTZ), str, 255);
255 Select_RotateAxis (2, v);
257 EndDialog(hwndDlg, 1);
261 EndDialog(hwndDlg, 0);
273 DialogBox(g_qeglobals.d_hInstance, (char *)IDD_ROTATE, g_qeglobals.d_hwndMain, RotateDlgProc);
277 ===================================================
281 ===================================================
285 BOOL CALLBACK SidesDlgProc (
286 HWND hwndDlg, // handle to dialog box
287 UINT uMsg, // message
288 WPARAM wParam, // first message parameter
289 LPARAM lParam // second message parameter
298 h = GetDlgItem(hwndDlg, IDC_FIND_ENTITY);
303 switch (LOWORD(wParam)) {
306 GetWindowText(GetDlgItem(hwndDlg, IDC_SIDES), str, 255);
307 Brush_MakeSided (atoi(str));
309 EndDialog(hwndDlg, 1);
313 EndDialog(hwndDlg, 0);
325 DialogBox(g_qeglobals.d_hInstance, (char *)IDD_SIDES, g_qeglobals.d_hwndMain, SidesDlgProc);
328 //======================================================================
335 BOOL CALLBACK AboutDlgProc( HWND hwndDlg,
347 char extensions[4096];
349 sprintf( renderer, "Renderer:\t%s", glGetString( GL_RENDERER ) );
350 sprintf( version, "Version:\t\t%s", glGetString( GL_VERSION ) );
351 sprintf( vendor, "Vendor:\t\t%s", glGetString( GL_VENDOR ) );
352 sprintf( extensions, "\n%s", glGetString( GL_EXTENSIONS ) );
354 SetWindowText( GetDlgItem( hwndDlg, IDC_ABOUT_GLRENDERER ), renderer );
355 SetWindowText( GetDlgItem( hwndDlg, IDC_ABOUT_GLVERSION ), version );
356 SetWindowText( GetDlgItem( hwndDlg, IDC_ABOUT_GLVENDOR ), vendor );
357 SetWindowText( GetDlgItem( hwndDlg, IDC_ABOUT_GLEXTENSIONS ), extensions );
362 EndDialog( hwndDlg, 1 );
366 if ( LOWORD( wParam ) == IDOK )
367 EndDialog(hwndDlg, 1);
375 DialogBox( g_qeglobals.d_hInstance, ( char * ) IDD_ABOUT, g_qeglobals.d_hwndMain, AboutDlgProc );
380 ===================================================
384 ===================================================
387 texdef_t g_old_texdef;
389 qboolean g_changed_surface;
391 int g_checkboxes[64] = {
392 IDC_CHECK1, IDC_CHECK2, IDC_CHECK3, IDC_CHECK4,
393 IDC_CHECK5, IDC_CHECK6, IDC_CHECK7, IDC_CHECK8,
394 IDC_CHECK9, IDC_CHECK10, IDC_CHECK11, IDC_CHECK12,
395 IDC_CHECK13, IDC_CHECK14, IDC_CHECK15, IDC_CHECK16,
396 IDC_CHECK17, IDC_CHECK18, IDC_CHECK19, IDC_CHECK20,
397 IDC_CHECK21, IDC_CHECK22, IDC_CHECK23, IDC_CHECK24,
398 IDC_CHECK25, IDC_CHECK26, IDC_CHECK27, IDC_CHECK28,
399 IDC_CHECK29, IDC_CHECK30, IDC_CHECK31, IDC_CHECK32,
401 IDC_CHECK33, IDC_CHECK34, IDC_CHECK35, IDC_CHECK36,
402 IDC_CHECK37, IDC_CHECK38, IDC_CHECK39, IDC_CHECK40,
403 IDC_CHECK41, IDC_CHECK42, IDC_CHECK43, IDC_CHECK44,
404 IDC_CHECK45, IDC_CHECK46, IDC_CHECK47, IDC_CHECK48,
405 IDC_CHECK49, IDC_CHECK50, IDC_CHECK51, IDC_CHECK52,
406 IDC_CHECK53, IDC_CHECK54, IDC_CHECK55, IDC_CHECK56,
407 IDC_CHECK57, IDC_CHECK58, IDC_CHECK59, IDC_CHECK60,
408 IDC_CHECK61, IDC_CHECK62, IDC_CHECK63, IDC_CHECK64
415 Set the fields to the current texdef
418 void SetTexMods(void)
424 pt = &g_qeglobals.d_texturewin.texdef;
426 SendMessage (g_surfwin, WM_SETREDRAW, 0, 0);
428 SetWindowText(GetDlgItem(g_surfwin, IDC_TEXTURE), pt->name);
430 sprintf(sz, "%d", (int)pt->shift[0]);
431 SetWindowText(GetDlgItem(g_surfwin, IDC_HSHIFT), sz);
433 sprintf(sz, "%d", (int)pt->shift[1]);
434 SetWindowText(GetDlgItem(g_surfwin, IDC_VSHIFT), sz);
436 sprintf(sz, "%4.2f", pt->scale[0]);
437 SetWindowText(GetDlgItem(g_surfwin, IDC_HSCALE), sz);
439 sprintf(sz, "%4.2f", pt->scale[1]);
440 SetWindowText(GetDlgItem(g_surfwin, IDC_VSCALE), sz);
442 sprintf(sz, "%d", (int)pt->rotate);
443 SetWindowText(GetDlgItem(g_surfwin, IDC_ROTATE), sz);
445 sprintf(sz, "%d", (int)pt->value);
446 SetWindowText(GetDlgItem(g_surfwin, IDC_VALUE), sz);
448 for (i=0 ; i<32 ; i++)
449 SendMessage(GetDlgItem(g_surfwin, g_checkboxes[i]), BM_SETCHECK, !!(pt->flags&(1<<i)), 0 );
450 for (i=0 ; i<32 ; i++)
451 SendMessage(GetDlgItem(g_surfwin, g_checkboxes[32+i]), BM_SETCHECK, !!(pt->contents&(1<<i)), 0 );
453 SendMessage (g_surfwin, WM_SETREDRAW, 1, 0);
454 InvalidateRect (g_surfwin, NULL, true);
462 Reads the fields to get the current texdef
465 void GetTexMods(void)
472 pt = &g_qeglobals.d_texturewin.texdef;
474 GetWindowText (GetDlgItem(g_surfwin, IDC_TEXTURE), sz, 127);
475 strncpy (pt->name, sz, sizeof(pt->name)-1);
476 if (pt->name[0] <= ' ')
478 strcpy (pt->name, "none");
479 SetWindowText(GetDlgItem(g_surfwin, IDC_TEXTURE), pt->name);
482 GetWindowText (GetDlgItem(g_surfwin, IDC_HSHIFT), sz, 127);
483 pt->shift[0] = atof(sz);
485 GetWindowText (GetDlgItem(g_surfwin, IDC_VSHIFT), sz, 127);
486 pt->shift[1] = atof(sz);
488 GetWindowText(GetDlgItem(g_surfwin, IDC_HSCALE), sz, 127);
489 pt->scale[0] = atof(sz);
491 GetWindowText(GetDlgItem(g_surfwin, IDC_VSCALE), sz, 127);
492 pt->scale[1] = atof(sz);
494 GetWindowText(GetDlgItem(g_surfwin, IDC_ROTATE), sz, 127);
495 pt->rotate = atof(sz);
497 GetWindowText(GetDlgItem(g_surfwin, IDC_VALUE), sz, 127);
498 pt->value = atof(sz);
501 for (i=0 ; i<32 ; i++)
503 b = SendMessage(GetDlgItem(g_surfwin, g_checkboxes[i]), BM_GETCHECK, 0, 0);
504 if (b != 1 && b != 0)
510 for (i=0 ; i<32 ; i++)
512 b = SendMessage(GetDlgItem(g_surfwin, g_checkboxes[32+i]), BM_GETCHECK, 0, 0);
513 if (b != 1 && b != 0)
515 pt->contents |= b<<i;
518 g_changed_surface = true;
519 Select_SetTexture(pt);
527 void UpdateSpinners(unsigned uMsg, WPARAM wParam, LPARAM lParam)
533 pt = &g_qeglobals.d_texturewin.texdef;
535 nScrollCode = (int) LOWORD(wParam); // scroll bar value
536 hwnd = (HWND) lParam; // handle of scroll bar
538 if ((nScrollCode != SB_LINEUP) && (nScrollCode != SB_LINEDOWN))
541 if (hwnd == GetDlgItem(g_surfwin, IDC_ROTATEA))
543 if (nScrollCode == SB_LINEUP)
551 if (pt->rotate >= 360)
555 else if (hwnd == GetDlgItem(g_surfwin, IDC_HSCALEA))
557 if (nScrollCode == SB_LINEDOWN)
563 else if (hwnd == GetDlgItem(g_surfwin, IDC_VSCALEA))
565 if (nScrollCode == SB_LINEUP)
571 else if (hwnd == GetDlgItem(g_surfwin, IDC_HSHIFTA))
573 if (nScrollCode == SB_LINEDOWN)
579 else if (hwnd == GetDlgItem(g_surfwin, IDC_VSHIFTA))
581 if (nScrollCode == SB_LINEUP)
588 g_changed_surface = true;
589 Select_SetTexture(pt);
594 BOOL CALLBACK SurfaceDlgProc (
595 HWND hwndDlg, // handle to dialog box
596 UINT uMsg, // message
597 WPARAM wParam, // first message parameter
598 LPARAM lParam // second message parameter
609 switch (LOWORD(wParam)) {
613 EndDialog(hwndDlg, 1);
618 InvalidateRect(g_qeglobals.d_hwndCamera, NULL, false);
619 UpdateWindow (g_qeglobals.d_hwndCamera);
623 g_qeglobals.d_texturewin.texdef = g_old_texdef;
624 if (g_changed_surface)
625 Select_SetTexture(&g_qeglobals.d_texturewin.texdef);
626 EndDialog(hwndDlg, 0);
633 UpdateSpinners(uMsg, wParam, lParam);
634 InvalidateRect(g_qeglobals.d_hwndCamera, NULL, false);
635 UpdateWindow (g_qeglobals.d_hwndCamera);
645 void DoSurface (void)
647 // save current state for cancel
648 g_old_texdef = g_qeglobals.d_texturewin.texdef;
649 g_changed_surface = false;
651 DialogBox(g_qeglobals.d_hInstance, (char *)IDD_SURFACE, g_qeglobals.d_hwndMain, SurfaceDlgProc);