| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program 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 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | --- HISTORICAL COMMENTS FOLLOW --- |
| 19 | |
| 20 | * $Logfile: /DescentIII/Main/editor/DoorwayDialog.cpp $ |
| 21 | * $Revision: 1.1.1.1 $ |
| 22 | * $Date: 2003-08-26 03:57:37 $ |
| 23 | * $Author: kevinb $ |
| 24 | * |
| 25 | * Doorway keypad |
| 26 | * |
| 27 | * $Log: not supported by cvs2svn $ |
| 28 | * |
| 29 | * 23 5/05/99 2:02a Matt |
| 30 | * Added doorway flag to tell the Guide-Bot to ignore the locked state of |
| 31 | * the door. |
| 32 | * |
| 33 | * 22 4/03/99 7:55p Matt |
| 34 | * Use new keypad update system instead of timer to update. |
| 35 | * |
| 36 | * 21 3/05/99 1:51p Kevin |
| 37 | * Fixed small crash bug |
| 38 | * |
| 39 | * 20 3/01/99 10:37a Matt |
| 40 | * Update doorway tab when the door object is renamed |
| 41 | * |
| 42 | * 19 2/06/99 10:03p Matt |
| 43 | * Added keys system |
| 44 | * |
| 45 | * 18 2/04/99 2:05p Matt |
| 46 | * Added blastable doors |
| 47 | * |
| 48 | * 17 1/29/99 12:48p Matt |
| 49 | * Rewrote the doorway system |
| 50 | * |
| 51 | * 16 9/22/98 12:02p Matt |
| 52 | * Fixed compile warnings |
| 53 | * |
| 54 | * 15 9/08/98 12:06p Jason |
| 55 | * added automatic reinitting of doors when rooms get deleted |
| 56 | * |
| 57 | * 14 9/02/98 4:32p Matt |
| 58 | * Added some error checking when placing a door. |
| 59 | * |
| 60 | * 13 6/15/98 4:00p Jason |
| 61 | * replaced monochromatic polymodel lighting with rgb lighting |
| 62 | * |
| 63 | * 12 4/20/98 2:52p Jason |
| 64 | * added doorway reinit function |
| 65 | * |
| 66 | * 11 4/07/98 11:05a Kevin |
| 67 | * For Samir, added m_Active to the if statement in the timer interrupt |
| 68 | * |
| 69 | * 10 4/02/98 3:54p Jason |
| 70 | * first pass in getting polymodel paging to work |
| 71 | * |
| 72 | * 9 12/19/97 11:25a Samir |
| 73 | * g3_StartFrame and g3_EndFrame replaced by EditorStartFrame and |
| 74 | * EditorEndFrame |
| 75 | * |
| 76 | * 8 10/03/97 12:24p Jason |
| 77 | * added new keys for doorways |
| 78 | * |
| 79 | * 7 9/29/97 12:09p Jason |
| 80 | * added functionality to doorway system |
| 81 | * |
| 82 | * 6 9/23/97 12:29p Jason |
| 83 | * fixed m_Active bug |
| 84 | * |
| 85 | * 5 9/17/97 1:01p Matt |
| 86 | * Ripped out segment code |
| 87 | * |
| 88 | * 4 9/11/97 5:46p Jason |
| 89 | * first pass at getting doors to work with room engine |
| 90 | * |
| 91 | * 3 7/24/97 6:11p Matt |
| 92 | * Created symbolic constant for default zoom, and used it every place |
| 93 | * that specifies zoom |
| 94 | * |
| 95 | * 20 6/03/97 4:55p Mark |
| 96 | * |
| 97 | * 20 6/03/97 4:51p Jeff |
| 98 | * Added Context Sensitive Help |
| 99 | * |
| 100 | * 19 4/02/97 5:15p Samir |
| 101 | * Added a Opened checkbox to mark a door as open or closed initially |
| 102 | * |
| 103 | * 18 4/01/97 11:00p Matt |
| 104 | * Changed editor to keep a viewer object (type camera) seperate from the |
| 105 | * player object. This camera, and not the player, is now moved by |
| 106 | * slewing, the C key, etc. When going into the game, the viewer position |
| 107 | * & orientation are copied to the player. When going back to the editor, |
| 108 | * the player position is copied to the viewer, and the player object is |
| 109 | * reset to its start location. |
| 110 | * |
| 111 | * 17 3/31/97 5:57p Matt |
| 112 | * Revamped mine update flags |
| 113 | * |
| 114 | * 16 3/26/97 5:43p Samir |
| 115 | * Fixed refresh of doorway selector when changing state of door page. |
| 116 | * |
| 117 | * 15 3/25/97 6:31p Samir |
| 118 | * Now you can select from different 3d doors hopefully. |
| 119 | * |
| 120 | * 14 3/24/97 6:47p Samir |
| 121 | * Fixed some place,remove doorway probs with 3d doors. Made some state |
| 122 | * vars static for multiple instances of dialog. |
| 123 | * |
| 124 | * 13 3/20/97 12:10p Samir |
| 125 | * Fixed prob when going into fullscreen with doorway keypad visible. |
| 126 | * |
| 127 | * 12 3/19/97 7:02p Samir |
| 128 | * If adding door segment fails, don't register it as a door! And |
| 129 | * deactivated moving doorways from one seg to another for now. |
| 130 | * |
| 131 | * 11 3/18/97 11:35a Samir |
| 132 | * Fixed user interface problems. |
| 133 | * |
| 134 | * $NoKeywords: $ |
| 135 | */ |
| 136 | |
| 137 | // DoorwayDialog.cpp : implementation file |
| 138 | // |
| 139 | |
| 140 | #include "stdafx.h" |
| 141 | #include "editor.h" |
| 142 | #include "DoorwayDialog.h" |
| 143 | |
| 144 | #include "door.h" |
| 145 | #include "HView.h" |
| 146 | #include "HRoom.h" |
| 147 | #include "polymodel.h" |
| 148 | #include "edoors.h" |
| 149 | |
| 150 | #ifdef _DEBUG |
| 151 | #define new DEBUG_NEW |
| 152 | #undef THIS_FILE |
| 153 | static char THIS_FILE[] = __FILE__; |
| 154 | #endif |
| 155 | |
| 156 | int Current_door_room = -1; |
| 157 | |
| 158 | ///////////////////////////////////////////////////////////////////////////// |
| 159 | // CDoorwayDialog dialog |
| 160 | |
| 161 | CDoorwayDialog::CDoorwayDialog(CWnd *pParent /*=NULL*/) : CKeypadDialog(CDoorwayDialog::IDD, pParent) { |
| 162 | //{{AFX_DATA_INIT(CDoorwayDialog) |
| 163 | // NOTE: the ClassWizard will add member initialization here |
| 164 | //}}AFX_DATA_INIT |
| 165 | |
| 166 | // m_SelectionType = DOORWAY_DOOR; |
| 167 | } |
| 168 | |
| 169 | void CDoorwayDialog::DoDataExchange(CDataExchange *pDX) { |
| 170 | CDialog::DoDataExchange(pDX); |
| 171 | //{{AFX_DATA_MAP(CDoorwayDialog) |
| 172 | // NOTE: the ClassWizard will add DDX and DDV calls here |
| 173 | //}}AFX_DATA_MAP |
| 174 | } |
| 175 | |
| 176 | BEGIN_MESSAGE_MAP(CDoorwayDialog, CDialog) |
| 177 | //{{AFX_MSG_MAP(CDoorwayDialog) |
| 178 | ON_WM_VSCROLL() |
| 179 | ON_WM_HSCROLL() |
| 180 | ON_WM_SIZE() |
| 181 | ON_WM_PAINT() |
| 182 | ON_BN_CLICKED(IDC_DOORWAY_PLACEDOOR, OnDoorwayPlaceDoorway) |
| 183 | ON_BN_CLICKED(IDC_NEXT_DOOR, OnNextDoor) |
| 184 | ON_BN_CLICKED(IDC_PREV_DOOR, OnPrevDoor) |
| 185 | ON_BN_CLICKED(IDC_DOORWAY_LOCKED, OnDoorwayLocked) |
| 186 | ON_BN_CLICKED(IDC_KEY1_CHECK, OnKey1Check) |
| 187 | ON_BN_CLICKED(IDC_KEY2_CHECK, OnKey2Check) |
| 188 | ON_BN_CLICKED(IDC_KEY3_CHECK, OnKey3Check) |
| 189 | ON_BN_CLICKED(IDC_KEY4_CHECK, OnKey4Check) |
| 190 | ON_BN_CLICKED(IDC_KEY5_CHECK, OnKey5Check) |
| 191 | ON_BN_CLICKED(IDC_KEY6_CHECK, OnKey6Check) |
| 192 | ON_BN_CLICKED(IDC_KEY7_CHECK, OnKey7Check) |
| 193 | ON_BN_CLICKED(IDC_KEY8_CHECK, OnKey8Check) |
| 194 | ON_BN_CLICKED(IDC_DOORWAY_ATTACHDOOR, OnDoorwayAttachDoor) |
| 195 | ON_BN_CLICKED(IDC_DOORWAY_AUTO, OnDoorwayAuto) |
| 196 | ON_EN_KILLFOCUS(IDC_DOORWAY_POS_EDIT, OnKillfocusDoorwayPosEdit) |
| 197 | ON_EN_KILLFOCUS(IDC_DOORWAY_HITPOINT_EDIT, OnKillfocusDoorwayHitpointEdit) |
| 198 | ON_BN_CLICKED(IDC_DOORWAY_KEY_ALL, OnDoorwayKeyAll) |
| 199 | ON_BN_CLICKED(IDC_DOORWAY_KEY_ONLY_ONE, OnDoorwayKeyOnlyOne) |
| 200 | ON_BN_CLICKED(IDC_DOORWAY_GB_IGNORE_LOCKED, OnDoorwayGBIgnoreLocked) |
| 201 | //}}AFX_MSG_MAP |
| 202 | END_MESSAGE_MAP() |
| 203 | |
| 204 | ///////////////////////////////////////////////////////////////////////////// |
| 205 | // CDoorwayDialog message handlers |
| 206 | |
| 207 | void CDoorwayDialog::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar) { |
| 208 | // TODO: Add your message handler code here and/or call default |
| 209 | |
| 210 | CKeypadDialog::OnVScroll(nSBCode, nPos, pScrollBar); |
| 211 | } |
| 212 | |
| 213 | void CDoorwayDialog::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar) { |
| 214 | // TODO: Add your message handler code here and/or call default |
| 215 | |
| 216 | CKeypadDialog::OnHScroll(nSBCode, nPos, pScrollBar); |
| 217 | } |
| 218 | |
| 219 | void CDoorwayDialog::OnSize(UINT nType, int cx, int cy) { CKeypadDialog::OnSize(nType, cx, cy); } |
| 220 | |
| 221 | void CDoorwayDialog::OnPaint() { |
| 222 | CPaintDC dc(this); // device context for painting |
| 223 | |
| 224 | UpdateDialog(); |
| 225 | } |
| 226 | |
| 227 | BOOL CDoorwayDialog::OnInitDialog() { |
| 228 | CDialog::OnInitDialog(); |
| 229 | UpdateDialog(); |
| 230 | return TRUE; |
| 231 | } |
| 232 | |
| 233 | void CDoorwayDialog::OnOK() { |
| 234 | CWnd *focus = CWnd::GetFocus(); |
| 235 | if (focus) |
| 236 | focus->GetNextWindow()->SetFocus(); |
| 237 | } |
| 238 | |
| 239 | void CDoorwayDialog::EnableCurrentItems(bool state) { |
| 240 | ((CButton *)GetDlgItem(IDC_DOORWAY_ID))->EnableWindow(state); |
| 241 | ((CButton *)GetDlgItem(IDC_DOORWAY_LOCKED))->EnableWindow(state); |
| 242 | ((CButton *)GetDlgItem(IDC_DOORWAY_GB_IGNORE_LOCKED))->EnableWindow(state); |
| 243 | ((CButton *)GetDlgItem(IDC_DOORWAY_AUTO))->EnableWindow(state); |
| 244 | ((CButton *)GetDlgItem(IDC_DOORWAY_CURRENT_BOX))->EnableWindow(state); |
| 245 | ((CButton *)GetDlgItem(IDC_DOORWAY_POS_TEXT))->EnableWindow(state); |
| 246 | ((CButton *)GetDlgItem(IDC_DOORWAY_POS_EDIT))->EnableWindow(state); |
| 247 | ((CButton *)GetDlgItem(IDC_DOORWAY_HITPOINT_TEXT))->EnableWindow(state); |
| 248 | ((CButton *)GetDlgItem(IDC_DOORWAY_HITPOINT_EDIT))->EnableWindow(state); |
| 249 | ((CButton *)GetDlgItem(IDC_DOORWAY_KEYS_TEXT))->EnableWindow(state); |
| 250 | ((CButton *)GetDlgItem(IDC_DOORWAY_KEY_ALL))->EnableWindow(state); |
| 251 | ((CButton *)GetDlgItem(IDC_DOORWAY_KEY_ONLY_ONE))->EnableWindow(state); |
| 252 | ((CButton *)GetDlgItem(IDC_KEY1_CHECK))->EnableWindow(state); |
| 253 | ((CButton *)GetDlgItem(IDC_KEY2_CHECK))->EnableWindow(state); |
| 254 | ((CButton *)GetDlgItem(IDC_KEY3_CHECK))->EnableWindow(state); |
| 255 | ((CButton *)GetDlgItem(IDC_KEY4_CHECK))->EnableWindow(state); |
| 256 | ((CButton *)GetDlgItem(IDC_KEY5_CHECK))->EnableWindow(state); |
| 257 | ((CButton *)GetDlgItem(IDC_KEY6_CHECK))->EnableWindow(state); |
| 258 | ((CButton *)GetDlgItem(IDC_KEY7_CHECK))->EnableWindow(state); |
| 259 | ((CButton *)GetDlgItem(IDC_KEY8_CHECK))->EnableWindow(state); |
| 260 | } |
| 261 | |
| 262 | // --------------------------------------------------------------------------- |
| 263 | // Update doorway key functions functions |
| 264 | // --------------------------------------------------------------------------- |
| 265 | |
| 266 | char last_name[OBJ_NAME_LEN + 1]; |
| 267 | |
| 268 | void CDoorwayDialog::UpdateDialog() { |
| 269 | if (!m_Active) |
| 270 | return; |
| 271 | |
| 272 | if (Num_doors <= 0) |
| 273 | return; |
| 274 | if (Doors[D3EditState.current_door].used == 0) |
| 275 | D3EditState.current_door = GetNextDoor(D3EditState.current_door); |
| 276 | |
| 277 | int door_handle = D3EditState.current_door; |
| 278 | |
| 279 | CEdit *ebox = (CEdit *)GetDlgItem(IDC_DOORWAYSELEDIT); |
| 280 | ebox->SetWindowText(Doors[door_handle].name); |
| 281 | DrawDoorwayDoorPic(); |
| 282 | |
| 283 | ((CButton *)GetDlgItem(IDC_DOORWAY_ATTACHDOOR))->EnableWindow(Placed_door != -1); |
| 284 | |
| 285 | ebox = (CEdit *)GetDlgItem(IDC_DOORWAY_ID); |
| 286 | |
| 287 | if (Cur_object_index == -1 || Objects[Cur_object_index].type != OBJ_DOOR) { |
| 288 | ebox->SetWindowText("No doorway selected"); |
| 289 | Current_door_room = -1; |
| 290 | EnableCurrentItems(0); |
| 291 | } else { |
| 292 | char str[250]; |
| 293 | object *objp = &Objects[Cur_object_index]; |
| 294 | |
| 295 | EnableCurrentItems(1); |
| 296 | |
| 297 | Current_door_room = objp->roomnum; |
| 298 | |
| 299 | ASSERT(Rooms[Current_door_room].flags & RF_DOOR); |
| 300 | |
| 301 | strcpy(last_name, Objects[Cur_object_index].name ? Objects[Cur_object_index].name : "<no name>"); |
| 302 | sprintf(str, "Door: %s ", last_name); |
| 303 | ebox->SetWindowText(str); |
| 304 | |
| 305 | doorway *dw = Rooms[Current_door_room].doorway_data; |
| 306 | |
| 307 | sprintf(str, "%.2f", dw->position); |
| 308 | ebox = (CEdit *)GetDlgItem(IDC_DOORWAY_POS_EDIT); |
| 309 | ebox->SetWindowText(str); |
| 310 | |
| 311 | // Update key check boxes |
| 312 | CButton *bbox = (CButton *)GetDlgItem(IDC_DOORWAY_LOCKED); |
| 313 | bbox->SetCheck(dw->flags & DF_LOCKED); |
| 314 | |
| 315 | bbox = (CButton *)GetDlgItem(IDC_DOORWAY_AUTO); |
| 316 | bbox->SetCheck(dw->flags & DF_AUTO); |
| 317 | |
| 318 | bbox = (CButton *)GetDlgItem(IDC_DOORWAY_GB_IGNORE_LOCKED); |
| 319 | bbox->SetCheck(dw->flags & DF_GB_IGNORE_LOCKED); |
| 320 | |
| 321 | bbox = (CButton *)GetDlgItem(IDC_KEY1_CHECK); |
| 322 | bbox->SetCheck(dw->keys_needed & KEY_FLAG(1)); |
| 323 | |
| 324 | bbox = (CButton *)GetDlgItem(IDC_KEY2_CHECK); |
| 325 | bbox->SetCheck(dw->keys_needed & KEY_FLAG(2)); |
| 326 | |
| 327 | bbox = (CButton *)GetDlgItem(IDC_KEY3_CHECK); |
| 328 | bbox->SetCheck(dw->keys_needed & KEY_FLAG(3)); |
| 329 | |
| 330 | bbox = (CButton *)GetDlgItem(IDC_KEY4_CHECK); |
| 331 | bbox->SetCheck(dw->keys_needed & KEY_FLAG(4)); |
| 332 | |
| 333 | bbox = (CButton *)GetDlgItem(IDC_KEY5_CHECK); |
| 334 | bbox->SetCheck(dw->keys_needed & KEY_FLAG(5)); |
| 335 | |
| 336 | bbox = (CButton *)GetDlgItem(IDC_KEY6_CHECK); |
| 337 | bbox->SetCheck(dw->keys_needed & KEY_FLAG(6)); |
| 338 | |
| 339 | bbox = (CButton *)GetDlgItem(IDC_KEY7_CHECK); |
| 340 | bbox->SetCheck(dw->keys_needed & KEY_FLAG(7)); |
| 341 | |
| 342 | bbox = (CButton *)GetDlgItem(IDC_KEY8_CHECK); |
| 343 | bbox->SetCheck(dw->keys_needed & KEY_FLAG(8)); |
| 344 | |
| 345 | // Update key radio buttons |
| 346 | bbox = (CButton *)GetDlgItem(IDC_DOORWAY_KEY_ALL); |
| 347 | bbox->SetCheck(!(dw->flags & DF_KEY_ONLY_ONE)); |
| 348 | bbox = (CButton *)GetDlgItem(IDC_DOORWAY_KEY_ONLY_ONE); |
| 349 | bbox->SetCheck(dw->flags & DF_KEY_ONLY_ONE); |
| 350 | |
| 351 | // Update hitpoints editing |
| 352 | door *door = &Doors[dw->doornum]; |
| 353 | bool blastable = ((door->flags & DF_BLASTABLE) != 0); |
| 354 | ((CButton *)GetDlgItem(IDC_DOORWAY_HITPOINT_TEXT))->EnableWindow(blastable); |
| 355 | sprintf(str, "%d", (int)objp->shields); |
| 356 | ebox = (CEdit *)GetDlgItem(IDC_DOORWAY_HITPOINT_EDIT); |
| 357 | ebox->SetWindowText(str); |
| 358 | ebox->EnableWindow(blastable); |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | // update doorway picture |
| 363 | |
| 364 | void CDoorwayDialog::DrawDoorwayDoorPic() { |
| 365 | int door_handle = D3EditState.current_door; |
| 366 | vector zero_vector; |
| 367 | vector view_vector = {0, 0, -20}; |
| 368 | matrix id_matrix; |
| 369 | float norm_angles[30]; |
| 370 | int w, h, bm_handle, x, y; |
| 371 | RECT rect; |
| 372 | CWnd *wnd = GetDlgItem(IDC_DOORPIC); |
| 373 | |
| 374 | Desktop_surf->attach_to_window((unsigned)wnd->m_hWnd); |
| 375 | |
| 376 | wnd->GetWindowRect(&rect); |
| 377 | ScreenToClient(&rect); |
| 378 | |
| 379 | w = rect.right - rect.left; |
| 380 | h = rect.bottom - rect.top; |
| 381 | |
| 382 | m_DoorSurf.create(w, h, BPP_16); |
| 383 | |
| 384 | Desktop_surf->clear(0, 0, w, h); |
| 385 | |
| 386 | bm_handle = GetDoorImage(door_handle); |
| 387 | |
| 388 | poly_model *pm = GetPolymodelPointer(bm_handle); |
| 389 | |
| 390 | vm_MakeZero(&zero_vector); |
| 391 | vm_MakeIdentity(&id_matrix); |
| 392 | |
| 393 | for (int i = 0; i < 30; i++) |
| 394 | norm_angles[i] = 0; |
| 395 | |
| 396 | grViewport *vport = new grViewport(&m_DoorSurf); |
| 397 | StartEditorFrame(vport, &view_vector, &id_matrix, D3_DEFAULT_ZOOM); |
| 398 | DrawPolygonModel(&zero_vector, &id_matrix, bm_handle, norm_angles, 0, 1.0, 1.0, 1.0); |
| 399 | EndEditorFrame(); |
| 400 | |
| 401 | x = rect.left + ((rect.right - rect.left) / 2) - m_DoorSurf.width() / 2; |
| 402 | y = rect.top + ((rect.bottom - rect.top) / 2) - m_DoorSurf.height() / 2; |
| 403 | Desktop_surf->blt(0, 0, &m_DoorSurf); |
| 404 | |
| 405 | delete vport; |
| 406 | m_DoorSurf.free(); |
| 407 | Desktop_surf->attach_to_window((unsigned)NULL); |
| 408 | } |
| 409 | |
| 410 | // --------------------------------------------------------------------------- |
| 411 | // Doorway editing functions |
| 412 | // --------------------------------------------------------------------------- |
| 413 | |
| 414 | void CDoorwayDialog::OnDoorwayPlaceDoorway() { |
| 415 | if (Num_doors <= 0) |
| 416 | return; |
| 417 | |
| 418 | if (D3EditState.current_door == -1) { |
| 419 | OutrageMessageBox("You must have a current door for this operation"); |
| 420 | return; |
| 421 | } |
| 422 | |
| 423 | if (Curroomp->faces[Curface].portal_num != -1) { |
| 424 | OutrageMessageBox("There's already a connection at the current room:face."); |
| 425 | return; |
| 426 | } |
| 427 | |
| 428 | PlaceDoor(Curroomp, Curface, D3EditState.current_door); |
| 429 | |
| 430 | UpdateDialog(); |
| 431 | |
| 432 | World_changed = 1; |
| 433 | } |
| 434 | |
| 435 | /*BOOL CDoorwayDialog::OnHelpInfo(HELPINFO* pHelpInfo) |
| 436 | { |
| 437 | // TODO: Add your message handler code here and/or call default |
| 438 | WinHelp(HID_DOORWAYTAB,HELP_CONTEXT); |
| 439 | return TRUE; |
| 440 | //return CDialog::OnHelpInfo(pHelpInfo); |
| 441 | }*/ |
| 442 | |
| 443 | void CDoorwayDialog::OnNextDoor() { |
| 444 | if (Num_doors <= 0) |
| 445 | return; |
| 446 | |
| 447 | D3EditState.current_door = GetNextDoor(D3EditState.current_door); |
| 448 | UpdateDialog(); |
| 449 | } |
| 450 | |
| 451 | void CDoorwayDialog::OnPrevDoor() { |
| 452 | if (Num_doors <= 0) |
| 453 | return; |
| 454 | |
| 455 | D3EditState.current_door = GetPrevDoor(D3EditState.current_door); |
| 456 | UpdateDialog(); |
| 457 | } |
| 458 | |
| 459 | void CDoorwayDialog::OnDoorwayLocked() { |
| 460 | if (Current_door_room == -1) |
| 461 | return; |
| 462 | |
| 463 | doorway *dp = Rooms[Current_door_room].doorway_data; |
| 464 | |
| 465 | ASSERT(dp != NULL); |
| 466 | |
| 467 | int c = IsDlgButtonChecked(IDC_DOORWAY_LOCKED); |
| 468 | |
| 469 | if (c) |
| 470 | dp->flags |= DF_LOCKED; |
| 471 | else |
| 472 | dp->flags &= ~DF_LOCKED; |
| 473 | } |
| 474 | |
| 475 | void CDoorwayDialog::UpdateKeypad(int mask) { |
| 476 | if (mask & (KUF_CUROBJ_CHANGED + KUF_CUROBJ_NAME_CHANGED)) |
| 477 | UpdateDialog(); |
| 478 | } |
| 479 | |
| 480 | void CDoorwayDialog::OnKeyCheck(int id, int keynum) { |
| 481 | if (Current_door_room == -1) |
| 482 | return; |
| 483 | |
| 484 | doorway *dp = Rooms[Current_door_room].doorway_data; |
| 485 | |
| 486 | ASSERT(dp != NULL); |
| 487 | |
| 488 | if (IsDlgButtonChecked(id)) |
| 489 | dp->keys_needed |= KEY_FLAG(keynum); |
| 490 | else |
| 491 | dp->keys_needed &= ~KEY_FLAG(keynum); |
| 492 | } |
| 493 | |
| 494 | void CDoorwayDialog::OnKey1Check() { OnKeyCheck(IDC_KEY1_CHECK, 1); } |
| 495 | |
| 496 | void CDoorwayDialog::OnKey2Check() { OnKeyCheck(IDC_KEY2_CHECK, 2); } |
| 497 | |
| 498 | void CDoorwayDialog::OnKey3Check() { OnKeyCheck(IDC_KEY3_CHECK, 3); } |
| 499 | |
| 500 | void CDoorwayDialog::OnKey4Check() { OnKeyCheck(IDC_KEY4_CHECK, 4); } |
| 501 | |
| 502 | void CDoorwayDialog::OnKey5Check() { OnKeyCheck(IDC_KEY5_CHECK, 5); } |
| 503 | |
| 504 | void CDoorwayDialog::OnKey6Check() { OnKeyCheck(IDC_KEY6_CHECK, 6); } |
| 505 | |
| 506 | void CDoorwayDialog::OnKey7Check() { OnKeyCheck(IDC_KEY7_CHECK, 7); } |
| 507 | |
| 508 | void CDoorwayDialog::OnKey8Check() { OnKeyCheck(IDC_KEY8_CHECK, 8); } |
| 509 | |
| 510 | void CDoorwayDialog::OnDoorwayAttachDoor() { |
| 511 | ASSERT(Placed_door != -1); |
| 512 | |
| 513 | AttachRoom(); |
| 514 | |
| 515 | UpdateDialog(); |
| 516 | } |
| 517 | |
| 518 | void CDoorwayDialog::OnDoorwayAuto() { |
| 519 | if (Current_door_room == -1) |
| 520 | return; |
| 521 | |
| 522 | doorway *dp = Rooms[Current_door_room].doorway_data; |
| 523 | |
| 524 | ASSERT(dp != NULL); |
| 525 | |
| 526 | int c = IsDlgButtonChecked(IDC_DOORWAY_AUTO); |
| 527 | |
| 528 | if (c) |
| 529 | dp->flags |= DF_AUTO; |
| 530 | else |
| 531 | dp->flags &= ~DF_AUTO; |
| 532 | } |
| 533 | |
| 534 | void CDoorwayDialog::OnKillfocusDoorwayPosEdit() { |
| 535 | if (Current_door_room == -1) |
| 536 | return; |
| 537 | |
| 538 | doorway *dp = Rooms[Current_door_room].doorway_data; |
| 539 | |
| 540 | ASSERT(dp != NULL); |
| 541 | |
| 542 | char str[100]; |
| 543 | |
| 544 | CEdit *ebox = (CEdit *)GetDlgItem(IDC_DOORWAY_POS_EDIT); |
| 545 | ebox->GetWindowText(str, sizeof(str)); |
| 546 | |
| 547 | dp->position = dp->dest_pos = atof(str); |
| 548 | |
| 549 | if (dp->position < 0.0) |
| 550 | dp->position = 0.0; |
| 551 | if (dp->position > 1.0) |
| 552 | dp->position = 1.0; |
| 553 | |
| 554 | dp->dest_pos = dp->position; |
| 555 | |
| 556 | DoorwayUpdateAnimation(&Rooms[Current_door_room]); |
| 557 | |
| 558 | World_changed = 1; |
| 559 | } |
| 560 | |
| 561 | void CDoorwayDialog::OnKillfocusDoorwayHitpointEdit() { |
| 562 | if (Current_door_room == -1) |
| 563 | return; |
| 564 | |
| 565 | doorway *dp = Rooms[Current_door_room].doorway_data; |
| 566 | |
| 567 | ASSERT(dp != NULL); |
| 568 | |
| 569 | char str[100]; |
| 570 | |
| 571 | CEdit *ebox = (CEdit *)GetDlgItem(IDC_DOORWAY_HITPOINT_EDIT); |
| 572 | ebox->GetWindowText(str, sizeof(str)); |
| 573 | |
| 574 | ASSERT(Objects[Cur_object_index].type == OBJ_DOOR); |
| 575 | |
| 576 | Objects[Cur_object_index].shields = atof(str); |
| 577 | |
| 578 | World_changed = 1; |
| 579 | } |
| 580 | |
| 581 | void CDoorwayDialog::OnDoorwayKeyAll() { |
| 582 | if (Current_door_room == -1) |
| 583 | return; |
| 584 | |
| 585 | doorway *dp = Rooms[Current_door_room].doorway_data; |
| 586 | |
| 587 | ASSERT(dp != NULL); |
| 588 | |
| 589 | if (IsDlgButtonChecked(IDC_DOORWAY_KEY_ALL)) |
| 590 | dp->flags &= ~DF_KEY_ONLY_ONE; |
| 591 | else |
| 592 | dp->flags |= DF_KEY_ONLY_ONE; |
| 593 | |
| 594 | World_changed = 1; |
| 595 | |
| 596 | UpdateDialog(); |
| 597 | } |
| 598 | |
| 599 | void CDoorwayDialog::OnDoorwayKeyOnlyOne() { |
| 600 | if (Current_door_room == -1) |
| 601 | return; |
| 602 | |
| 603 | doorway *dp = Rooms[Current_door_room].doorway_data; |
| 604 | |
| 605 | ASSERT(dp != NULL); |
| 606 | |
| 607 | if (IsDlgButtonChecked(IDC_DOORWAY_KEY_ONLY_ONE)) |
| 608 | dp->flags |= DF_KEY_ONLY_ONE; |
| 609 | else |
| 610 | dp->flags &= ~DF_KEY_ONLY_ONE; |
| 611 | |
| 612 | World_changed = 1; |
| 613 | |
| 614 | UpdateDialog(); |
| 615 | } |
| 616 | |
| 617 | void CDoorwayDialog::OnDoorwayGBIgnoreLocked() { |
| 618 | if (Current_door_room == -1) |
| 619 | return; |
| 620 | |
| 621 | doorway *dp = Rooms[Current_door_room].doorway_data; |
| 622 | |
| 623 | ASSERT(dp != NULL); |
| 624 | |
| 625 | int c = IsDlgButtonChecked(IDC_DOORWAY_GB_IGNORE_LOCKED); |
| 626 | |
| 627 | if (c) |
| 628 | dp->flags |= DF_GB_IGNORE_LOCKED; |
| 629 | else |
| 630 | dp->flags &= ~DF_GB_IGNORE_LOCKED; |
| 631 | } |