2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 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.
24 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.
26 ===========================================================================
29 #include "../../idlib/precompiled.h"
32 #include "../../sys/win32/rc/guied_resource.h"
33 #include "../common/ColorButton.h"
39 GEOptionsDlg_GeneralProc
41 Dialog procedure for the general options tab
44 static INT_PTR CALLBACK GEOptionsDlg_GeneralProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
49 ColorButton_SetColor ( GetDlgItem ( hwnd, IDC_GUIED_SELECTIONCOLOR ),
50 RGB(gApp.GetOptions().GetSelectionColor()[0]*255,
51 gApp.GetOptions().GetSelectionColor()[1]*255,
52 gApp.GetOptions().GetSelectionColor()[2]*255) );
53 CheckDlgButton ( hwnd, IDC_GUIED_IGNOREDESKTOP, gApp.GetOptions().GetIgnoreDesktopSelect()?BST_CHECKED:BST_UNCHECKED );
57 switch ( LOWORD ( wParam ) )
59 case IDC_GUIED_SELECTIONCOLOR:
62 ZeroMemory ( &col, sizeof(col) );
63 col.lStructSize = sizeof(col);
64 col.lpCustColors = gApp.GetOptions().GetCustomColors ( );
67 col.Flags = CC_RGBINIT;
68 col.rgbResult = ColorButton_GetColor ( GetDlgItem ( hwnd, IDC_GUIED_SELECTIONCOLOR ) );
69 if ( ChooseColor ( &col ) )
71 ColorButton_SetColor ( GetDlgItem ( hwnd, IDC_GUIED_SELECTIONCOLOR ), col.rgbResult );
79 ColorButton_DrawItem ( GetDlgItem ( hwnd, wParam ), (LPDRAWITEMSTRUCT)lParam );
83 switch (((NMHDR FAR *) lParam)->code)
86 gApp.GetOptions().SetLastOptionsPage ( PropSheet_HwndToIndex ( GetParent ( hwnd ), PropSheet_GetCurrentPageHwnd ( GetParent ( hwnd ) ) ) );
87 gApp.GetOptions().SetSelectionColor ( ColorButton_GetColor ( GetDlgItem ( hwnd, IDC_GUIED_SELECTIONCOLOR ) ) );
88 gApp.GetOptions().SetIgnoreDesktopSelect ( IsDlgButtonChecked ( hwnd, IDC_GUIED_IGNOREDESKTOP ) != 0 );
101 Dialog procedure for the grid settings tab
104 static INT_PTR CALLBACK GEOptionsDlg_GridProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
109 // Copy the options information to the dialog controls
110 ColorButton_SetColor ( GetDlgItem ( hwnd, IDC_GUIED_GRIDCOLOR ), RGB(gApp.GetOptions().GetGridColor()[0]*255,gApp.GetOptions().GetGridColor()[1]*255,gApp.GetOptions().GetGridColor()[2]*255) );
111 SetWindowText ( GetDlgItem ( hwnd, IDC_GUIED_SPACINGWIDTH ), va("%d", gApp.GetOptions().GetGridWidth ( ) ) );
112 SetWindowText ( GetDlgItem ( hwnd, IDC_GUIED_SPACINGHEIGHT ), va("%d", gApp.GetOptions().GetGridHeight ( ) ) );
113 CheckDlgButton ( hwnd, IDC_GUIED_GRIDVISIBLE, gApp.GetOptions().GetGridVisible()?BST_CHECKED:BST_UNCHECKED );
114 CheckDlgButton ( hwnd, IDC_GUIED_GRIDSNAP, gApp.GetOptions().GetGridSnap()?BST_CHECKED:BST_UNCHECKED );
118 ColorButton_DrawItem ( GetDlgItem ( hwnd, wParam ), (LPDRAWITEMSTRUCT)lParam );
122 switch (((NMHDR FAR *) lParam)->code)
128 // Copy the dialog control data back to the options
129 GetWindowText ( GetDlgItem ( hwnd, IDC_GUIED_SPACINGWIDTH ), temp, 32 );
130 gApp.GetOptions().SetGridWidth(atol(temp));
131 GetWindowText ( GetDlgItem ( hwnd, IDC_GUIED_SPACINGHEIGHT ), temp, 32 );
132 gApp.GetOptions().SetGridHeight(atol(temp));
133 gApp.GetOptions().SetGridVisible ( IsDlgButtonChecked ( hwnd, IDC_GUIED_GRIDVISIBLE ) != 0 );
134 gApp.GetOptions().SetGridSnap ( IsDlgButtonChecked ( hwnd, IDC_GUIED_GRIDSNAP ) != 0 );
135 gApp.GetOptions().SetGridColor ( ColorButton_GetColor ( GetDlgItem ( hwnd, IDC_GUIED_GRIDCOLOR ) ) );
142 switch ( LOWORD ( wParam ) )
144 case IDC_GUIED_GRIDCOLOR:
147 ZeroMemory ( &col, sizeof(col) );
148 col.lStructSize = sizeof(col);
149 col.lpCustColors = gApp.GetOptions().GetCustomColors ( );
150 col.hwndOwner = hwnd;
151 col.hInstance = NULL;
152 col.Flags = CC_RGBINIT;
153 col.rgbResult = RGB(gApp.GetOptions().GetGridColor()[0]*255,gApp.GetOptions().GetGridColor()[1]*255,gApp.GetOptions().GetGridColor()[2]*255);
154 if ( ChooseColor ( &col ) )
156 ColorButton_SetColor ( GetDlgItem ( hwnd, IDC_GUIED_GRIDCOLOR ), col.rgbResult );
171 Starts the options dialog and updates the global options if ok is pressed
174 bool GEOptionsDlg_DoModal ( HWND parent )
176 PROPSHEETHEADER propsh;
177 PROPSHEETPAGE propsp[2];
179 propsp[0].dwSize = sizeof(PROPSHEETPAGE);
180 propsp[0].dwFlags = PSP_USETITLE;
181 propsp[0].hInstance = win32.hInstance;
182 propsp[0].pszTemplate = MAKEINTRESOURCE(IDD_GUIED_OPTIONS_GENERAL);
183 propsp[0].pfnDlgProc = GEOptionsDlg_GeneralProc;
184 propsp[0].pszTitle = "General";
185 propsp[0].lParam = 0;
187 propsp[1].dwSize = sizeof(PROPSHEETPAGE);
188 propsp[1].dwFlags = PSP_USETITLE;
189 propsp[1].hInstance = win32.hInstance;
190 propsp[1].pszTemplate = MAKEINTRESOURCE(IDD_GUIED_OPTIONS_GRID);
191 propsp[1].pfnDlgProc = GEOptionsDlg_GridProc;
192 propsp[1].pszTitle = "Grid";
193 propsp[1].lParam = 0;
195 propsh.dwSize = sizeof(PROPSHEETHEADER);
196 propsh.nStartPage = gApp.GetOptions().GetLastOptionsPage ( );
197 propsh.dwFlags = PSH_PROPSHEETPAGE|PSH_NOAPPLYNOW|PSH_NOCONTEXTHELP;
198 propsh.hwndParent = parent;
199 propsh.pszCaption = "Options";
201 propsh.ppsp = (LPCPROPSHEETPAGE)&propsp;
203 if ( PropertySheet ( &propsh ) )
205 gApp.GetOptions().Save ( );