| 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/roomkeypaddialog.cpp $ |
| 21 | * $Revision: 1.1.1.1 $ |
| 22 | * $Date: 2003-08-26 03:57:38 $ |
| 23 | * $Author: kevinb $ |
| 24 | * |
| 25 | * Room keypad |
| 26 | * |
| 27 | * $Log: not supported by cvs2svn $ |
| 28 | * |
| 29 | * 68 10/21/99 1:45p Jeff |
| 30 | * fixed dialog update bug |
| 31 | * |
| 32 | * 67 10/21/99 1:33p Jeff |
| 33 | * added checkbox to prevent certain rooms from lighting |
| 34 | * |
| 35 | * 66 4/29/99 5:44p Chris |
| 36 | * Added the check for bad center points |
| 37 | * |
| 38 | * 65 4/29/99 1:59a Chris |
| 39 | * Added the portal blockage support |
| 40 | * |
| 41 | * 64 4/28/99 1:39p Chris |
| 42 | * Added the ability to block portals |
| 43 | * |
| 44 | * 63 4/24/99 4:32p Jason |
| 45 | * fixed secret room checkbox |
| 46 | * |
| 47 | * 62 4/16/99 1:44p Jason |
| 48 | * fixed selection of special rooms as goal rooms |
| 49 | * |
| 50 | * 61 4/15/99 12:18p Jason |
| 51 | * made mirrors more robust and able to have multiple mirrored faces in |
| 52 | * the same room (as long as they are all on the same plane) |
| 53 | * |
| 54 | * 60 4/14/99 7:21p Jason |
| 55 | * added secret room checkbox |
| 56 | * |
| 57 | * 59 4/03/99 7:55p Matt |
| 58 | * Use new keypad update system instead of timer to update. |
| 59 | * |
| 60 | * 58 3/31/99 5:15p Matt |
| 61 | * Added checkboxes on the room tab to control rendering of faces based on |
| 62 | * shell flag. |
| 63 | * |
| 64 | * 57 3/31/99 11:34a Matt |
| 65 | * Got rid of unused forcefield checkbox on room tab |
| 66 | * |
| 67 | * 56 3/30/99 6:25p Matt |
| 68 | * Use new error system for combine faces function. |
| 69 | * |
| 70 | * 55 2/03/99 5:48p Matt |
| 71 | * Added room damage system |
| 72 | * |
| 73 | * 54 1/21/99 11:15p Jeff |
| 74 | * pulled out some structs and defines from header files and moved them |
| 75 | * into seperate header files so that multiplayer dlls don't require major |
| 76 | * game headers, just those new headers. Side effect is a shorter build |
| 77 | * time. Also cleaned up some header file #includes that weren't needed. |
| 78 | * This affected polymodel.h, object.h, player.h, vecmat.h, room.h, |
| 79 | * manage.h and multi.h |
| 80 | * |
| 81 | * 53 1/15/99 10:50a Matt |
| 82 | * Added rename room to Room menu & added shortcut key |
| 83 | * |
| 84 | * 52 1/08/99 6:32p Samir |
| 85 | * |
| 86 | * 51 1/08/99 5:37p Samir |
| 87 | * reverb values per room. |
| 88 | * |
| 89 | * 50 12/30/98 6:50p Matt |
| 90 | * Don't add rooms with no name (which may be placed doors) to the room |
| 91 | * palette list |
| 92 | * |
| 93 | * 49 12/22/98 2:03p Matt |
| 94 | * Added room names, and made rooms not compress so that room numbers are |
| 95 | * suitable for persistant uses. |
| 96 | * |
| 97 | * 48 11/11/98 2:15p Jason |
| 98 | * |
| 99 | * 47 11/11/98 2:15p Jason |
| 100 | * save current room directory |
| 101 | * |
| 102 | * 46 10/06/98 6:08p Jason |
| 103 | * added RF_TRIANGULATE so that special rooms (with non-planar UVS) can be |
| 104 | * drawn correctly |
| 105 | * |
| 106 | * 45 10/04/98 2:35p Matt |
| 107 | * Added debug options to limit rendering |
| 108 | * |
| 109 | * 44 9/28/98 6:09p Jason |
| 110 | * Corrected appending ORF to rooms |
| 111 | * |
| 112 | * 43 9/18/98 8:13p Jason |
| 113 | * automatically append .orf extension when saving rooms |
| 114 | * |
| 115 | * 42 9/07/98 8:04p Matt |
| 116 | * After combining faces, set curface to marked face. (Old curface gets |
| 117 | * deleting when joined.) |
| 118 | * |
| 119 | * 41 9/01/98 12:04p Matt |
| 120 | * Ripped out multi-face portal code |
| 121 | * |
| 122 | * 40 8/28/98 6:21p Matt |
| 123 | * Added a function to flip a face. |
| 124 | * |
| 125 | * 39 8/27/98 7:16p Jason |
| 126 | * changes to dialog |
| 127 | * |
| 128 | * 38 8/20/98 12:17p Matt |
| 129 | * When building ambient sound pattern list, ignore patterns that have |
| 130 | * been marked as deleted. |
| 131 | * |
| 132 | * 37 8/20/98 12:07p Matt |
| 133 | * Rebuild the ambient sound pattern list whenever we update, since the |
| 134 | * list can change while the program is running. |
| 135 | * |
| 136 | * 36 8/17/98 6:40p Matt |
| 137 | * Added ambient sound system |
| 138 | * |
| 139 | * 35 8/10/98 7:31p Jeff |
| 140 | * fixed bug with special flag 6 |
| 141 | * |
| 142 | * 34 7/20/98 4:46p Jason |
| 143 | * added BOA vis table stuff |
| 144 | * |
| 145 | * 33 7/16/98 12:06p Jason |
| 146 | * added special flags to room structure |
| 147 | * |
| 148 | * 32 4/21/98 2:31p Matt |
| 149 | * When showing what vertex selected, show vert number in addition to |
| 150 | * index |
| 151 | * |
| 152 | * 31 4/10/98 4:12p Jason |
| 153 | * fixed room loading bug |
| 154 | * |
| 155 | * 30 4/10/98 11:52a Jason |
| 156 | * fixed face splintering bug |
| 157 | * |
| 158 | * 29 3/30/98 5:49p Jason |
| 159 | * fixed selection of faces |
| 160 | * |
| 161 | * 28 3/16/98 6:41p Jason |
| 162 | * added goal room stuff |
| 163 | * |
| 164 | * 27 3/06/98 3:23p Jason |
| 165 | * added lighting from satellites to indoor rooms |
| 166 | * |
| 167 | * 26 2/10/98 7:46p Matt |
| 168 | * Added roompad check boxes for fuelcen and goals |
| 169 | * |
| 170 | * 25 2/10/98 1:12p Jason |
| 171 | * added forcefields and saturating walls |
| 172 | * |
| 173 | * 24 1/21/98 12:33p Matt |
| 174 | * Revamped viewer system |
| 175 | * |
| 176 | * 23 1/20/98 4:05p Matt |
| 177 | * Move BuildListOfPortalVerts() from roomkeypaddialog.cpp to erooms.cpp |
| 178 | * |
| 179 | * 22 12/23/97 1:33p Samir |
| 180 | * Added pserror.h |
| 181 | * |
| 182 | * 21 12/02/97 5:31p Samir |
| 183 | * New file dialog interface implemented. |
| 184 | * |
| 185 | * 20 11/05/97 9:31p Jason |
| 186 | * made render_external_rooms button work |
| 187 | * |
| 188 | * 19 10/01/97 7:49p Matt |
| 189 | * Added "External Room" checkbox on room keypad |
| 190 | * |
| 191 | * 18 9/15/97 12:26p Matt |
| 192 | * When a face is deleted (via combining faces) update markedface if it's |
| 193 | * changed |
| 194 | * |
| 195 | * 17 9/10/97 5:13p Matt |
| 196 | * Made small portal change to room keypad |
| 197 | * |
| 198 | * 16 9/06/97 10:53p Matt |
| 199 | * Added portal stuff to room keypad |
| 200 | * |
| 201 | * 15 9/06/97 3:14p Matt |
| 202 | * Added button to go to next portal |
| 203 | * Added seperate face & vert count displays for current room & cur |
| 204 | * palette room |
| 205 | * Use new PrintToDsgItem() function |
| 206 | * |
| 207 | * 14 9/02/97 12:08p Samir |
| 208 | * Fixed scrolling. |
| 209 | * |
| 210 | * 13 8/29/97 3:57p Samir |
| 211 | * This should add scrolling support. |
| 212 | * |
| 213 | * 12 8/21/97 5:59p Matt |
| 214 | * Added next vertex & combine faces functions |
| 215 | * |
| 216 | * 11 8/04/97 12:48p Matt |
| 217 | * Use SetMarkedRoom() |
| 218 | * |
| 219 | * 10 8/01/97 4:56p Jason |
| 220 | * added face moving |
| 221 | * |
| 222 | * 9 8/01/97 12:50p Jason |
| 223 | * added code to support scaling of rooms/faces/edges |
| 224 | * |
| 225 | * 8 7/31/97 3:31p Jason |
| 226 | * added functions to rotate portal rooms |
| 227 | * |
| 228 | * 7 7/29/97 12:45p Matt |
| 229 | * Force window redraws when loading or switching rooms |
| 230 | * |
| 231 | * 6 7/28/97 5:32p Matt |
| 232 | * When loading a room, update the keypad dialog, and force the editor |
| 233 | * into room view |
| 234 | * |
| 235 | * 6 6/30/97 1:30p Jason |
| 236 | * added netherspace stuff |
| 237 | * |
| 238 | * 5 6/27/97 4:34p Jason |
| 239 | * fixed silly bug |
| 240 | * |
| 241 | * 4 6/27/97 4:15p Jason |
| 242 | * added more room functions |
| 243 | * |
| 244 | * 3 6/27/97 3:10p Jason |
| 245 | * added groovy stuff for rooms |
| 246 | * |
| 247 | * 2 6/27/97 12:20p Samir |
| 248 | * Added RCS comment header. |
| 249 | * |
| 250 | * $NoKeywords: $ |
| 251 | */ |
| 252 | |
| 253 | #include "stdafx.h" |
| 254 | #include "editor.h" |
| 255 | #include "RoomKeypadDialog.h" |
| 256 | #include "ddio.h" |
| 257 | #include "erooms.h" |
| 258 | #include "mainfrm.h" |
| 259 | #include "rotateroom.h" |
| 260 | #include "boa.h" |
| 261 | #include "HRoom.h" |
| 262 | #include "pserror.h" |
| 263 | #include "HView.h" |
| 264 | #include "ambient.h" |
| 265 | #include "render.h" |
| 266 | #include "EditLineDialog.h" |
| 267 | #include "hlsoundlib.h" |
| 268 | #include "mem.h" |
| 269 | #include "damage_external.h" |
| 270 | #include "boa.h" |
| 271 | |
| 272 | #ifdef _DEBUG |
| 273 | #define new DEBUG_NEW |
| 274 | #undef THIS_FILE |
| 275 | static char THIS_FILE[] = __FILE__; |
| 276 | #endif |
| 277 | |
| 278 | // list shold match hlsoundlib.h constants. |
| 279 | const char *EnvAudio_PresetNames[N_ENVAUDIO_PRESETS] = { |
| 280 | "<none>", "Padded Cell", "Room", "Bathroom", "Living Room", "Stone Room", "Auditorium", |
| 281 | "Concert Hall", "Cave", "Arena", "Hangar", "Carpet Hall", "Hall", "Stone Corridor", |
| 282 | "Alley", "Forest", "City", "Mountains", "Quarry", "Plain", "Parkinglot", |
| 283 | "Sewer", "Underwater", "Drugged", "Dizzy", "Psychotic"}; |
| 284 | |
| 285 | ///////////////////////////////////////////////////////////////////////////// |
| 286 | // CRoomKeypadDialog dialog |
| 287 | |
| 288 | int CRoomKeypadDialog::m_Instances = 0; // number of instances of this keypad. |
| 289 | |
| 290 | CRoomKeypadDialog::CRoomKeypadDialog(CWnd *pParent /*=NULL*/) : CKeypadDialog(CRoomKeypadDialog::IDD, pParent) { |
| 291 | //{{AFX_DATA_INIT(CRoomKeypadDialog) |
| 292 | // NOTE: the ClassWizard will add member initialization here |
| 293 | //}}AFX_DATA_INIT |
| 294 | } |
| 295 | |
| 296 | void CRoomKeypadDialog::DoDataExchange(CDataExchange *pDX) { |
| 297 | CDialog::DoDataExchange(pDX); |
| 298 | //{{AFX_DATA_MAP(CRoomKeypadDialog) |
| 299 | // NOTE: the ClassWizard will add DDX and DDV calls here |
| 300 | //}}AFX_DATA_MAP |
| 301 | } |
| 302 | |
| 303 | void CRoomKeypadDialog::RunKeypadFunction(int code) {} |
| 304 | |
| 305 | // These functions save information about this dialog's current UI state to the database |
| 306 | void CRoomKeypadDialog::LoadSettings() {} |
| 307 | |
| 308 | void CRoomKeypadDialog::SaveSettings() {} |
| 309 | |
| 310 | BEGIN_MESSAGE_MAP(CRoomKeypadDialog, CDialog) |
| 311 | //{{AFX_MSG_MAP(CRoomKeypadDialog) |
| 312 | ON_BN_CLICKED(IDC_LOAD_ROOM, OnLoadRoom) |
| 313 | ON_BN_CLICKED(IDC_SAVE_ROOM_LOCALLY, OnSaveRoomLocally) |
| 314 | ON_CBN_SELENDOK(IDC_ROOM_PULLDOWN, OnSelendokRoomPulldown) |
| 315 | ON_WM_PAINT() |
| 316 | ON_WM_HELPINFO() |
| 317 | ON_BN_CLICKED(IDC_MARK_ROOM, OnMarkRoom) |
| 318 | ON_BN_CLICKED(IDC_ROOMPAD_ROTATE_LEFT, OnRoompadRotateLeft) |
| 319 | ON_BN_CLICKED(IDC_ROOMPAD_ROTATE_RIGHT, OnRoompadRotateRight) |
| 320 | ON_BN_CLICKED(IDC_ROOMPAD_PITCH_FORWARD, OnRoompadPitchForward) |
| 321 | ON_BN_CLICKED(IDC_ROOMPAD_PITCH_BACKWARD, OnRoompadPitchBackward) |
| 322 | ON_BN_CLICKED(IDC_ROOMPAD_BANK_RIGHT, OnRoompadBankRight) |
| 323 | ON_BN_CLICKED(IDC_ROOMPAD_BANK_LEFT, OnRoompadBankLeft) |
| 324 | ON_BN_CLICKED(IDC_ROOMPAD_NEXT_EDGE, OnRoompadNextEdge) |
| 325 | ON_BN_CLICKED(IDC_ROOMPAD_EXPAND_ROOM, OnRoompadExpandRoom) |
| 326 | ON_BN_CLICKED(IDC_ROOMPAD_CONTRACT_ROOM, OnRoompadContractRoom) |
| 327 | ON_BN_CLICKED(IDC_ROOMPAD_EXPAND_FACE, OnRoompadExpandFace) |
| 328 | ON_BN_CLICKED(IDC_ROOMPAD_CONTRACT_FACE, OnRoompadContractFace) |
| 329 | ON_BN_CLICKED(IDC_ROOMPAD_EXPAND_EDGE, OnRoompadExpandEdge) |
| 330 | ON_BN_CLICKED(IDC_ROOMPAD_CONTRACT_EDGE, OnRoompadContractEdge) |
| 331 | ON_BN_CLICKED(IDC_ROOMPAD_MOVE_FORWARD, OnRoompadMoveForward) |
| 332 | ON_BN_CLICKED(IDC_ROOMPAD_MOVE_BACKWARD, OnRoompadMoveBackward) |
| 333 | ON_BN_CLICKED(IDC_ROOMPAD_MOVE_RIGHT, OnRoompadMoveRight) |
| 334 | ON_BN_CLICKED(IDC_ROOMPAD_MOVE_LEFT, OnRoompadMoveLeft) |
| 335 | ON_BN_CLICKED(IDC_ROOMPAD_MOVE_UP, OnRoompadMoveUp) |
| 336 | ON_BN_CLICKED(IDC_ROOMPAD_MOVE_DOWN, OnRoompadMoveDown) |
| 337 | ON_BN_CLICKED(IDC_ROOMPAD_NEXT_VERTEX, OnRoompadNextVertex) |
| 338 | ON_BN_CLICKED(IDC_ROOMPAD_COMBINE_FACES, OnRoompadCombineFaces) |
| 339 | ON_WM_HSCROLL() |
| 340 | ON_WM_VSCROLL() |
| 341 | ON_WM_SIZE() |
| 342 | ON_BN_CLICKED(IDC_ROOMPAD_NEXT_PORTAL, OnRoompadNextPortal) |
| 343 | ON_BN_CLICKED(IDC_RENDER_PORTAL_FACES, OnRenderPortalFaces) |
| 344 | ON_BN_CLICKED(IDC_ENABLE_PORTAL_FLYTHROUGH, OnEnablePortalFlythrough) |
| 345 | ON_BN_CLICKED(IDC_EXTERNAL_ROOM, OnExternalRoom) |
| 346 | ON_BN_CLICKED(IDC_RENDER_EXTERNAL_ROOMS, OnRenderExternalRooms) |
| 347 | ON_BN_CLICKED(IDC_NEXT_FACE, OnNextFace) |
| 348 | ON_BN_CLICKED(IDC_ROOMPAD_GOAL1, OnRoompadGoal1) |
| 349 | ON_BN_CLICKED(IDC_ROOMPAD_GOAL2, OnRoompadGoal2) |
| 350 | ON_BN_CLICKED(IDC_ROOMPAD_REFUELING_CENTER, OnRoompadRefuelingCenter) |
| 351 | ON_BN_CLICKED(IDC_TOUCHES_OUTSIDE, OnTouchesOutside) |
| 352 | ON_BN_CLICKED(IDC_ROOMPAD_GOAL3, OnRoompadGoal3) |
| 353 | ON_BN_CLICKED(IDC_ROOMPAD_GOAL4, OnRoompadGoal4) |
| 354 | ON_BN_CLICKED(IDC_GOALFACE_CHECK, OnGoalfaceCheck) |
| 355 | ON_BN_CLICKED(IDC_SPECIAL_1, OnSpecial1) |
| 356 | ON_BN_CLICKED(IDC_SPECIAL_2, OnSpecial2) |
| 357 | ON_BN_CLICKED(IDC_SPECIAL_3, OnSpecial3) |
| 358 | ON_BN_CLICKED(IDC_SPECIAL_4, OnSpecial4) |
| 359 | ON_BN_CLICKED(IDC_SPECIAL_5, OnSpecial5) |
| 360 | ON_BN_CLICKED(IDC_SPECIAL_6, OnSpecial6) |
| 361 | ON_BN_CLICKED(IDC_BOA_VIS_BUTTON, OnBoaVisButton) |
| 362 | ON_CBN_SELENDOK(IDC_ROOM_AMBIENT, OnSelendokRoomAmbient) |
| 363 | ON_BN_CLICKED(IDC_MIRROR_BUTTON, OnMirrorButton) |
| 364 | ON_BN_CLICKED(IDC_NO_MIRROR_BUTTON, OnNoMirrorButton) |
| 365 | ON_BN_CLICKED(IDC_ROOMPAD_FLIP_FACE, OnRoompadFlipFace) |
| 366 | ON_BN_CLICKED(IDC_ROOMPAD_NO_DRAW_TERRAIN, OnRoompadNoDrawTerrain) |
| 367 | ON_BN_CLICKED(IDC_ROOMPAD_ONE_ROOM_ONLY, OnRoompadOneRoomOnly) |
| 368 | ON_BN_CLICKED(IDC_TRIANGULATE, OnTriangulate) |
| 369 | ON_BN_CLICKED(IDC_EDIT_NAME, OnEditName) |
| 370 | ON_CBN_SELCHANGE(IDC_ROOM_ENVAUDIO, OnSelchangeRoomEnvaudio) |
| 371 | ON_EN_KILLFOCUS(IDC_ROOMPAD_DAMAGE, OnKillfocusRoompadDamage) |
| 372 | ON_CBN_SELCHANGE(IDC_ROOMPAD_DAMAGETYPE, OnSelchangeRoompadDamageType) |
| 373 | ON_BN_CLICKED(IDC_RENDER_SHELL, OnRenderShell) |
| 374 | ON_BN_CLICKED(IDC_RENDER_NON_SHELL, OnRenderNonShell) |
| 375 | ON_BN_CLICKED(IDC_SECRET_CHECK, OnSecretCheck) |
| 376 | ON_BN_CLICKED(IDC_PORTAL_BLOCKED_CHECK, OnPortalBlockedCheck) |
| 377 | ON_BN_CLICKED(IDC_PORTAL_BLOCKED_CAN_GO_AWAY_CHECK, OnPortalBlockedCanGoAwayCheck) |
| 378 | ON_BN_CLICKED(IDC_BAD_CENTERPOINTS, OnBadCenterpoints) |
| 379 | ON_BN_CLICKED(IDC_ROOM_SKIP_LIGHTING, OnRoomSkipLighting) |
| 380 | //}}AFX_MSG_MAP |
| 381 | END_MESSAGE_MAP() |
| 382 | |
| 383 | ///////////////////////////////////////////////////////////////////////////// |
| 384 | // CRoomKeypadDialog message handlers |
| 385 | |
| 386 | void CRoomKeypadDialog::OnLoadRoom() { |
| 387 | char filename[255]; |
| 388 | int c = 1, finding_name = 1; |
| 389 | |
| 390 | CString filter = "Descent III room files (*.orf)|*.orf||"; |
| 391 | |
| 392 | if (!OpenFileDialog(this, (LPCSTR)filter, filename, Current_room_dir, sizeof(Current_room_dir))) |
| 393 | return; |
| 394 | |
| 395 | char name[255]; |
| 396 | char path[255]; |
| 397 | char extension[255]; |
| 398 | char roomname[255]; |
| 399 | int find_new = 0; |
| 400 | |
| 401 | // Find a unique name for this room |
| 402 | ddio_SplitPath(filename, path, name, extension); |
| 403 | int done = 0; |
| 404 | int count = 1; |
| 405 | |
| 406 | strcpy(Current_room_dir, path); |
| 407 | |
| 408 | sprintf(roomname, "%s.ORF", name); |
| 409 | |
| 410 | int val = FindRoomName(roomname); |
| 411 | |
| 412 | if (val != -1) { |
| 413 | int answer = |
| 414 | MessageBox("Do you wish to overwrite the room in memory that already has this name?", roomname, MB_YESNO); |
| 415 | if (answer == IDYES) |
| 416 | FreeRoom(&Rooms[val]); |
| 417 | else |
| 418 | find_new = 1; |
| 419 | } |
| 420 | |
| 421 | // Okay, we selected a file. Lets do what needs to be done here. |
| 422 | int n = AllocLoadRoom(filename); |
| 423 | |
| 424 | if (n < 0) { |
| 425 | OutrageMessageBox("Couldn't load that room for some reason."); |
| 426 | return; |
| 427 | } |
| 428 | |
| 429 | while (!done && find_new) { |
| 430 | val = FindRoomName(roomname); |
| 431 | if (val == -1) { |
| 432 | done = 1; |
| 433 | continue; |
| 434 | } |
| 435 | count++; |
| 436 | sprintf(roomname, "%s%d.ORF", name, count); |
| 437 | } |
| 438 | |
| 439 | ASSERT(Rooms[n].name == NULL); |
| 440 | Rooms[n].name = (char *)mem_malloc(strlen(roomname) + 1); |
| 441 | strcpy(Rooms[n].name, roomname); |
| 442 | |
| 443 | D3EditState.current_room = n; |
| 444 | |
| 445 | // Update keypad |
| 446 | UpdateDialog(); |
| 447 | |
| 448 | // Force into room view |
| 449 | ResetRoomViewer(); |
| 450 | SetViewMode(VM_ROOM); |
| 451 | |
| 452 | // Force window updates |
| 453 | State_changed = 1; |
| 454 | } |
| 455 | |
| 456 | void CRoomKeypadDialog::OnSaveRoomLocally() { |
| 457 | char filename[255]; |
| 458 | |
| 459 | if (Curroomp == NULL || Curroomp->used == 0) { |
| 460 | OutrageMessageBox("No valid room selected for saving!"); |
| 461 | return; |
| 462 | } |
| 463 | |
| 464 | CString filter = "Descent III room files (*.orf)|*.orf||"; |
| 465 | |
| 466 | if (!SaveFileDialog(this, (LPCSTR)filter, filename, Current_weapon_dir, sizeof(Current_weapon_dir))) |
| 467 | return; |
| 468 | |
| 469 | int len = strlen(filename); |
| 470 | if (filename[len - 4] != '.' || filename[len - 3] != 'o' || filename[len - 2] != 'r' || filename[len - 1] != 'f') |
| 471 | strcat(filename, ".orf"); |
| 472 | |
| 473 | // Save it out to disk (locally) |
| 474 | SaveRoom(Curroomp - Rooms, filename); |
| 475 | OutrageMessageBox("Room saved."); |
| 476 | } |
| 477 | |
| 478 | void CRoomKeypadDialog::OnSelendokRoomPulldown() { |
| 479 | int i, cur; |
| 480 | char name[200]; |
| 481 | |
| 482 | cur = SendDlgItemMessage(IDC_ROOM_PULLDOWN, CB_GETCURSEL, 0, 0); |
| 483 | SendDlgItemMessage(IDC_ROOM_PULLDOWN, CB_GETLBTEXT, cur, (LPARAM)(LPCTSTR)name); |
| 484 | |
| 485 | i = FindRoomName(name); |
| 486 | |
| 487 | if (i == -1) { |
| 488 | mprintf(0, "Possible corrupted room list, but probably nothing."); |
| 489 | UpdateDialog(); |
| 490 | } |
| 491 | |
| 492 | D3EditState.current_room = i; |
| 493 | UpdateDialog(); |
| 494 | |
| 495 | ResetRoomViewer(); |
| 496 | |
| 497 | // Force window updates |
| 498 | State_changed = 1; |
| 499 | } |
| 500 | |
| 501 | #define NULL_NAME "<none>" |
| 502 | |
| 503 | void CRoomKeypadDialog::UpdateDialog() { |
| 504 | int i; |
| 505 | |
| 506 | // Show the number of verts, faces, & portals in the current room |
| 507 | PrintToDlgItem(this, IDC_ROOM_NAME, "Name:\t%s", Curroomp->name ? Curroomp->name : "<none>"); |
| 508 | PrintToDlgItem(this, IDC_VERTEX_COUNT, "Vertices:\t%d", Curroomp->num_verts); |
| 509 | PrintToDlgItem(this, IDC_FACE_COUNT, "Faces:\t%d", Curroomp->num_faces); |
| 510 | PrintToDlgItem(this, IDC_PORTAL_COUNT, "Portals:\t%d", Curroomp->num_portals); |
| 511 | |
| 512 | // Show flags |
| 513 | ((CButton *)GetDlgItem(IDC_EXTERNAL_ROOM))->SetCheck(Curroomp->flags & RF_EXTERNAL); |
| 514 | ((CButton *)GetDlgItem(IDC_ROOM_SKIP_LIGHTING))->SetCheck((Curroomp->flags & RF_NO_LIGHT) ? 1 : 0); |
| 515 | ((CButton *)GetDlgItem(IDC_ROOMPAD_REFUELING_CENTER))->SetCheck(Curroomp->flags & RF_FUELCEN); |
| 516 | ((CButton *)GetDlgItem(IDC_ROOMPAD_GOAL1))->SetCheck(Curroomp->flags & RF_GOAL1); |
| 517 | ((CButton *)GetDlgItem(IDC_ROOMPAD_GOAL2))->SetCheck(Curroomp->flags & RF_GOAL2); |
| 518 | ((CButton *)GetDlgItem(IDC_ROOMPAD_GOAL3))->SetCheck(Curroomp->flags & RF_GOAL3); |
| 519 | ((CButton *)GetDlgItem(IDC_ROOMPAD_GOAL4))->SetCheck(Curroomp->flags & RF_GOAL4); |
| 520 | ((CButton *)GetDlgItem(IDC_SPECIAL_1))->SetCheck(Curroomp->flags & RF_SPECIAL1); |
| 521 | ((CButton *)GetDlgItem(IDC_SPECIAL_2))->SetCheck(Curroomp->flags & RF_SPECIAL2); |
| 522 | ((CButton *)GetDlgItem(IDC_SPECIAL_3))->SetCheck(Curroomp->flags & RF_SPECIAL3); |
| 523 | ((CButton *)GetDlgItem(IDC_SPECIAL_4))->SetCheck(Curroomp->flags & RF_SPECIAL4); |
| 524 | ((CButton *)GetDlgItem(IDC_SPECIAL_5))->SetCheck(Curroomp->flags & RF_SPECIAL5); |
| 525 | ((CButton *)GetDlgItem(IDC_SPECIAL_6))->SetCheck(Curroomp->flags & RF_SPECIAL6); |
| 526 | ((CButton *)GetDlgItem(IDC_TRIANGULATE))->SetCheck(Curroomp->flags & RF_TRIANGULATE); |
| 527 | ((CButton *)GetDlgItem(IDC_TOUCHES_OUTSIDE))->SetCheck(Curroomp->flags & RF_TOUCHES_TERRAIN); |
| 528 | |
| 529 | if (Curroomp->flags & RF_SECRET) |
| 530 | ((CButton *)GetDlgItem(IDC_SECRET_CHECK))->SetCheck(1); |
| 531 | else |
| 532 | ((CButton *)GetDlgItem(IDC_SECRET_CHECK))->SetCheck(0); |
| 533 | |
| 534 | // Show flags |
| 535 | ((CButton *)GetDlgItem(IDC_EXTERNAL_ROOM))->SetCheck(Curroomp->flags & RF_EXTERNAL); |
| 536 | ((CButton *)GetDlgItem(IDC_ROOMPAD_NO_DRAW_TERRAIN))->SetCheck(Render_inside_only); |
| 537 | ((CButton *)GetDlgItem(IDC_ROOMPAD_ONE_ROOM_ONLY))->SetCheck(Render_one_room_only); |
| 538 | ((CButton *)GetDlgItem(IDC_ROOM_SKIP_LIGHTING))->SetCheck((Curroomp->flags & RF_NO_LIGHT) ? 1 : 0); |
| 539 | |
| 540 | // set forcefield check |
| 541 | //@@((CButton *) GetDlgItem(IDC_FORCEFIELD_CHECK))->SetCheck(Curroomp->faces[Curface].flags & FF_FORCEFIELD); |
| 542 | ((CButton *)GetDlgItem(IDC_GOALFACE_CHECK))->SetCheck(Curroomp->faces[Curface].flags & FF_GOALFACE); |
| 543 | PrintToDlgItem(this, IDC_CURRENT_FACE, "Current face: %d", Curface); |
| 544 | |
| 545 | // Enable/disable the next portal button |
| 546 | ((CButton *)GetDlgItem(IDC_ROOMPAD_NEXT_PORTAL)) |
| 547 | ->EnableWindow(((Curportal == -1) && (Curroomp->num_portals > 0)) || (Curroomp->num_portals > 1)); |
| 548 | |
| 549 | // Enable/disable the portal items |
| 550 | ((CButton *)GetDlgItem(IDC_CURRENT_PORTAL))->EnableWindow(Curportal != -1); |
| 551 | ((CButton *)GetDlgItem(IDC_RENDER_PORTAL_FACES))->EnableWindow(Curportal != -1); |
| 552 | ((CButton *)GetDlgItem(IDC_PORTAL_BLOCKED_CHECK))->EnableWindow(Curportal != -1); |
| 553 | ((CButton *)GetDlgItem(IDC_PORTAL_BLOCKED_CAN_GO_AWAY_CHECK))->EnableWindow(Curportal != -1); |
| 554 | |
| 555 | // Set shell render checkboxes |
| 556 | ((CButton *)GetDlgItem(IDC_RENDER_SHELL))->SetCheck(!(Shell_render_flag & SRF_NO_SHELL)); |
| 557 | ((CButton *)GetDlgItem(IDC_RENDER_NON_SHELL))->SetCheck(!(Shell_render_flag & SRF_NO_NON_SHELL)); |
| 558 | |
| 559 | // Update the portal number & checkboxes |
| 560 | if (Curportal != -1) { |
| 561 | portal *pp = &Curroomp->portals[Curportal]; |
| 562 | |
| 563 | ASSERT(Curportal < Curroomp->num_portals); |
| 564 | |
| 565 | PrintToDlgItem(this, IDC_CURRENT_PORTAL, "Portal:\t%d", Curportal); |
| 566 | ((CButton *)GetDlgItem(IDC_RENDER_PORTAL_FACES))->SetCheck(pp->flags & PF_RENDER_FACES); |
| 567 | ((CButton *)GetDlgItem(IDC_ENABLE_PORTAL_FLYTHROUGH))->SetCheck(pp->flags & PF_RENDERED_FLYTHROUGH); |
| 568 | ((CButton *)GetDlgItem(IDC_PORTAL_BLOCKED_CHECK))->SetCheck(pp->flags & PF_BLOCK); |
| 569 | ((CButton *)GetDlgItem(IDC_PORTAL_BLOCKED_CAN_GO_AWAY_CHECK))->SetCheck(pp->flags & PF_BLOCK_REMOVABLE); |
| 570 | |
| 571 | // if render faces is on, enable the rendered flythrough checkbox |
| 572 | ((CButton *)GetDlgItem(IDC_ENABLE_PORTAL_FLYTHROUGH))->EnableWindow(pp->flags & PF_RENDER_FACES); |
| 573 | ((CButton *)GetDlgItem(IDC_PORTAL_BLOCKED_CAN_GO_AWAY_CHECK))->EnableWindow(pp->flags & PF_BLOCK); |
| 574 | } else { |
| 575 | ((CButton *)GetDlgItem(IDC_ENABLE_PORTAL_FLYTHROUGH))->EnableWindow(0); |
| 576 | ((CButton *)GetDlgItem(IDC_RENDER_PORTAL_FACES))->SetCheck(0); |
| 577 | ((CButton *)GetDlgItem(IDC_ENABLE_PORTAL_FLYTHROUGH))->SetCheck(0); |
| 578 | ((CButton *)GetDlgItem(IDC_PORTAL_BLOCKED_CHECK))->SetCheck(0); |
| 579 | ((CButton *)GetDlgItem(IDC_PORTAL_BLOCKED_CAN_GO_AWAY_CHECK))->SetCheck(0); |
| 580 | } |
| 581 | |
| 582 | // Build the ambient sound list |
| 583 | SendDlgItemMessage(IDC_ROOM_AMBIENT, CB_RESETCONTENT, 0, 0); |
| 584 | SendDlgItemMessage(IDC_ROOM_AMBIENT, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)NULL_NAME); |
| 585 | for (i = 0; i < Num_ambient_sound_patterns; i++) |
| 586 | if (Ambient_sound_patterns[i].name[0]) |
| 587 | SendDlgItemMessage(IDC_ROOM_AMBIENT, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)AmbientSoundPatternName(i)); |
| 588 | SendDlgItemMessage(IDC_ROOM_AMBIENT, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR)NULL_NAME); |
| 589 | |
| 590 | // Set the current ambient sound pattern |
| 591 | SendDlgItemMessage(IDC_ROOM_AMBIENT, CB_SELECTSTRING, 0, |
| 592 | (LPARAM)(LPCTSTR)((Curroomp->ambient_sound == -1) |
| 593 | ? NULL_NAME |
| 594 | : AmbientSoundPatternName(Curroomp->ambient_sound))); |
| 595 | |
| 596 | // Build environmental presets list |
| 597 | ((CComboBox *)GetDlgItem(IDC_ROOM_ENVAUDIO)) |
| 598 | ->SelectString(-1, EnvAudio_PresetNames[(Curroomp->env_reverb < N_ENVAUDIO_PRESETS) ? Curroomp->env_reverb : 0]); |
| 599 | |
| 600 | // Update Mirror Stuff |
| 601 | char str[255]; |
| 602 | if (Curroomp->mirror_face == -1) |
| 603 | strcpy(str, "None"); |
| 604 | else |
| 605 | sprintf(str, "%d", Curroomp->mirror_face); |
| 606 | |
| 607 | PrintToDlgItem(this, IDC_MIRROR_FACE_TEXT, "Current mirror face:\t%s", str); |
| 608 | |
| 609 | // Update the damage |
| 610 | CEdit *box = (CEdit *)GetDlgItem(IDC_ROOMPAD_DAMAGE); |
| 611 | sprintf(str, "%.2f", Curroomp->damage); |
| 612 | box->SetWindowText(str); |
| 613 | |
| 614 | // Update the damage type |
| 615 | CComboBox *cbox = (CComboBox *)GetDlgItem(IDC_ROOMPAD_DAMAGETYPE); |
| 616 | int n = cbox->GetCount(); |
| 617 | for (i = 0; i < n; i++) { |
| 618 | if (cbox->GetItemData(i) == Curroomp->damage_type) { |
| 619 | cbox->SetCurSel(i); |
| 620 | break; |
| 621 | } |
| 622 | } |
| 623 | ASSERT(i < n); |
| 624 | |
| 625 | // Get current room in palette |
| 626 | n = D3EditState.current_room; |
| 627 | if ((n == -1) || !Rooms[n].used) // no current room? |
| 628 | n = D3EditState.current_room = GetNextRoom(n); //..try to get one |
| 629 | |
| 630 | // Update palette room stuff |
| 631 | if (n != -1) { |
| 632 | |
| 633 | // Show the number of verts & faces in the current palette room |
| 634 | PrintToDlgItem(this, IDC_PALETTE_VERTEX_COUNT, "Vertices:\t%d", Rooms[n].num_verts); |
| 635 | PrintToDlgItem(this, IDC_PALETTE_FACE_COUNT, "Faces:\t%d", Rooms[n].num_faces); |
| 636 | |
| 637 | // Update the list of palette rooms |
| 638 | SendDlgItemMessage(IDC_ROOM_PULLDOWN, CB_RESETCONTENT, 0, 0); |
| 639 | |
| 640 | for (int i = FIRST_PALETTE_ROOM; i < FIRST_PALETTE_ROOM + MAX_PALETTE_ROOMS; i++) { |
| 641 | if (Rooms[i].used && Rooms[i].name) // if a placed door, won't have a name |
| 642 | SendDlgItemMessage(IDC_ROOM_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)Rooms[i].name); |
| 643 | } |
| 644 | SendDlgItemMessage(IDC_ROOM_PULLDOWN, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR)Rooms[n].name); |
| 645 | } |
| 646 | } |
| 647 | |
| 648 | void CRoomKeypadDialog::OnPaint() { |
| 649 | CPaintDC dc(this); // device context for painting |
| 650 | |
| 651 | UpdateDialog(); |
| 652 | |
| 653 | // Do not call CDialog::OnPaint() for painting messages |
| 654 | } |
| 655 | |
| 656 | BOOL CRoomKeypadDialog::OnHelpInfo(HELPINFO *pHelpInfo) { |
| 657 | // TODO: Add your message handler code here and/or call default |
| 658 | WinHelp(HID_ROOMTAB, HELP_CONTEXT); |
| 659 | return TRUE; |
| 660 | // return CDialog::OnHelpInfo(pHelpInfo); |
| 661 | } |
| 662 | |
| 663 | void CRoomKeypadDialog::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar) { |
| 664 | CKeypadDialog::OnHScroll(nSBCode, nPos, pScrollBar); |
| 665 | } |
| 666 | |
| 667 | void CRoomKeypadDialog::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar) { |
| 668 | CKeypadDialog::OnVScroll(nSBCode, nPos, pScrollBar); |
| 669 | } |
| 670 | |
| 671 | void CRoomKeypadDialog::OnSize(UINT nType, int cx, int cy) { CKeypadDialog::OnSize(nType, cx, cy); } |
| 672 | |
| 673 | ///////////////////////////////////////////////////////////////////////////// |
| 674 | // helper functions |
| 675 | |
| 676 | // Goes through all the vertices in the room and scales them by scale_factor |
| 677 | void SizeRoomVertices(room *rp, float scale_factor) { |
| 678 | vector room_center; |
| 679 | vector vec; |
| 680 | int portal_list[MAX_VERTS_PER_ROOM]; |
| 681 | int i, t, ok_to_scale; |
| 682 | int num_portal_verts; |
| 683 | |
| 684 | ASSERT(rp->used > 0); |
| 685 | |
| 686 | num_portal_verts = BuildListOfPortalVerts(rp, portal_list); |
| 687 | |
| 688 | ComputeRoomCenter(&room_center, rp); |
| 689 | |
| 690 | for (i = 0; i < rp->num_verts; i++) { |
| 691 | for (ok_to_scale = 1, t = 0; t < num_portal_verts; t++) { |
| 692 | if (portal_list[t] == i) { |
| 693 | ok_to_scale = 0; |
| 694 | break; |
| 695 | } |
| 696 | } |
| 697 | |
| 698 | if (ok_to_scale) { |
| 699 | vec = rp->verts[i] - room_center; |
| 700 | vec *= scale_factor; |
| 701 | rp->verts[i] = vec + room_center; |
| 702 | } |
| 703 | } |
| 704 | } |
| 705 | |
| 706 | // Goes through all the vertices in a face and scales them by scale_factor |
| 707 | void SizeFaceVertices(room *rp, int facenum, float scale_factor) { |
| 708 | vector face_center; |
| 709 | vector vec; |
| 710 | int portal_list[MAX_VERTS_PER_ROOM]; |
| 711 | int face_list[MAX_FACES_PER_ROOM]; |
| 712 | int i, t, ok_to_scale, k; |
| 713 | int num_portal_verts; |
| 714 | int facecount = 0; |
| 715 | face *fp = &rp->faces[facenum]; |
| 716 | |
| 717 | ASSERT(rp->used > 0); |
| 718 | |
| 719 | num_portal_verts = BuildListOfPortalVerts(rp, portal_list); |
| 720 | |
| 721 | ComputeCenterPointOnFace(&face_center, rp, facenum); |
| 722 | |
| 723 | for (i = 0; i < fp->num_verts; i++) { |
| 724 | int vertnum = fp->face_verts[i]; |
| 725 | |
| 726 | for (ok_to_scale = 1, t = 0; t < num_portal_verts; t++) { |
| 727 | if (portal_list[t] == vertnum) { |
| 728 | ok_to_scale = 0; |
| 729 | break; |
| 730 | } |
| 731 | } |
| 732 | |
| 733 | if (ok_to_scale) { |
| 734 | vec = rp->verts[vertnum] - face_center; |
| 735 | vec *= scale_factor; |
| 736 | rp->verts[vertnum] = vec + face_center; |
| 737 | } |
| 738 | } |
| 739 | |
| 740 | // Build a list of faces that share vertices with this face |
| 741 | for (i = 0; i < rp->num_faces; i++) { |
| 742 | for (t = 0; t < rp->faces[i].num_verts; t++) { |
| 743 | for (k = 0; k < fp->num_verts; k++) { |
| 744 | if (fp->face_verts[k] == rp->faces[i].face_verts[t]) { |
| 745 | face_list[facecount] = i; |
| 746 | facecount++; |
| 747 | } |
| 748 | } |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | // Now fixup any concave/nonplanar faces |
| 753 | FixConcaveFaces(rp, face_list, facecount); |
| 754 | } |
| 755 | |
| 756 | void SizeFaceEdge(room *rp, int facenum, int edge, float scale_factor) { |
| 757 | vector line_center; |
| 758 | vector vec; |
| 759 | int portal_list[MAX_VERTS_PER_ROOM]; |
| 760 | int face_list[MAX_FACES_PER_ROOM]; |
| 761 | int i, t, ok_to_scale; |
| 762 | int num_portal_verts; |
| 763 | int facecount = 0; |
| 764 | face *fp = &rp->faces[facenum]; |
| 765 | int nextedge, vert, nextvert; |
| 766 | |
| 767 | nextedge = (edge + 1) % fp->num_verts; |
| 768 | vert = fp->face_verts[edge]; |
| 769 | nextvert = fp->face_verts[nextedge]; |
| 770 | |
| 771 | ASSERT(rp->used > 0); |
| 772 | |
| 773 | num_portal_verts = BuildListOfPortalVerts(rp, portal_list); |
| 774 | |
| 775 | line_center = ((rp->verts[nextvert] - rp->verts[vert]) / 2) + rp->verts[vert]; |
| 776 | |
| 777 | for (ok_to_scale = 1, t = 0; t < num_portal_verts; t++) |
| 778 | if (portal_list[t] == vert) |
| 779 | ok_to_scale = 0; |
| 780 | |
| 781 | if (ok_to_scale) { |
| 782 | vec = rp->verts[vert] - line_center; |
| 783 | vec *= scale_factor; |
| 784 | rp->verts[vert] = vec + line_center; |
| 785 | } |
| 786 | |
| 787 | for (ok_to_scale = 1, t = 0; t < num_portal_verts; t++) |
| 788 | if (portal_list[t] == nextvert) |
| 789 | ok_to_scale = 0; |
| 790 | |
| 791 | if (ok_to_scale) { |
| 792 | vec = rp->verts[nextvert] - line_center; |
| 793 | vec *= scale_factor; |
| 794 | rp->verts[nextvert] = vec + line_center; |
| 795 | } |
| 796 | |
| 797 | // Build a list of faces that share vertices with this edge |
| 798 | for (i = 0; i < rp->num_faces; i++) { |
| 799 | for (t = 0; t < rp->faces[i].num_verts; t++) { |
| 800 | if (rp->faces[i].face_verts[t] == vert || rp->faces[i].face_verts[t] == nextvert) { |
| 801 | face_list[facecount] = i; |
| 802 | facecount++; |
| 803 | } |
| 804 | } |
| 805 | } |
| 806 | |
| 807 | // Now fixup any concave/nonplanar faces |
| 808 | FixConcaveFaces(rp, face_list, facecount); |
| 809 | } |
| 810 | |
| 811 | // moves a face of a room by a delta amount |
| 812 | void MoveRoomFace(room *rp, int facenum, float dx, float dy, float dz) { |
| 813 | matrix facematrix; |
| 814 | vector norm = -rp->faces[facenum].normal; |
| 815 | |
| 816 | int face_list[MAX_FACES_PER_ROOM]; |
| 817 | int portal_list[MAX_VERTS_PER_ROOM]; |
| 818 | int i, t, ok_to_scale, k, touches_portal = 0; |
| 819 | int num_portal_verts; |
| 820 | int facecount = 0; |
| 821 | face *fp = &rp->faces[facenum]; |
| 822 | |
| 823 | ASSERT(rp->used > 0); |
| 824 | ASSERT(facenum >= 0 && facenum < rp->num_faces); |
| 825 | |
| 826 | num_portal_verts = BuildListOfPortalVerts(rp, portal_list); |
| 827 | |
| 828 | vm_VectorToMatrix(&facematrix, &norm, NULL, NULL); |
| 829 | |
| 830 | for (i = 0; i < fp->num_verts; i++) { |
| 831 | for (ok_to_scale = 1, t = 0; t < num_portal_verts; t++) { |
| 832 | if (portal_list[t] == fp->face_verts[i]) { |
| 833 | ok_to_scale = 0; |
| 834 | touches_portal = 1; |
| 835 | } |
| 836 | } |
| 837 | |
| 838 | if (ok_to_scale) { |
| 839 | rp->verts[fp->face_verts[i]] += (facematrix.rvec * dx); |
| 840 | rp->verts[fp->face_verts[i]] += (facematrix.uvec * dy); |
| 841 | rp->verts[fp->face_verts[i]] += (facematrix.fvec * dz); |
| 842 | } |
| 843 | } |
| 844 | |
| 845 | // Build a list of faces that share vertices with this edge |
| 846 | for (i = 0; i < rp->num_faces; i++) { |
| 847 | if (i == facenum && touches_portal == 0) |
| 848 | continue; |
| 849 | |
| 850 | for (t = 0; t < rp->faces[i].num_verts; t++) { |
| 851 | for (k = 0; k < fp->num_verts; k++) { |
| 852 | if (fp->face_verts[k] == rp->faces[i].face_verts[t]) { |
| 853 | face_list[facecount] = i; |
| 854 | facecount++; |
| 855 | } |
| 856 | } |
| 857 | } |
| 858 | } |
| 859 | |
| 860 | // Now fixup any concave/nonplanar faces |
| 861 | FixConcaveFaces(rp, face_list, facecount); |
| 862 | } |
| 863 | |
| 864 | void CRoomKeypadDialog::OnMarkRoom() { SetMarkedRoom(); } |
| 865 | |
| 866 | void CRoomKeypadDialog::OnRoompadRotateLeft() { RotateRooms(0, (angle)-512, 0); } |
| 867 | |
| 868 | void CRoomKeypadDialog::OnRoompadRotateRight() { RotateRooms(0, (angle)512, 0); } |
| 869 | |
| 870 | void CRoomKeypadDialog::OnRoompadPitchForward() { RotateRooms((angle)512, 0, 0); } |
| 871 | |
| 872 | void CRoomKeypadDialog::OnRoompadPitchBackward() { RotateRooms((angle)-512, 0, 0); } |
| 873 | |
| 874 | void CRoomKeypadDialog::OnRoompadBankRight() { RotateRooms(0, 0, (angle)512); } |
| 875 | |
| 876 | void CRoomKeypadDialog::OnRoompadBankLeft() { RotateRooms(0, 0, (angle)-512); } |
| 877 | |
| 878 | void CRoomKeypadDialog::OnRoompadNextEdge() { |
| 879 | Curedge++; |
| 880 | if (Curedge >= Curroomp->faces[Curface].num_verts) |
| 881 | Curedge = 0; |
| 882 | |
| 883 | EditorStatus("Edge %d selected.", Curedge); |
| 884 | |
| 885 | State_changed = 1; |
| 886 | } |
| 887 | |
| 888 | void CRoomKeypadDialog::OnRoompadNextVertex() { |
| 889 | if (++Curvert >= Curroomp->faces[Curface].num_verts) |
| 890 | Curvert = 0; |
| 891 | |
| 892 | EditorStatus("Vertex %d (%d) selected.", Curvert, Curroomp->faces[Curface].face_verts[Curvert]); |
| 893 | |
| 894 | State_changed = 1; |
| 895 | } |
| 896 | |
| 897 | void CRoomKeypadDialog::OnRoompadExpandRoom() { |
| 898 | if (Curroomp == NULL) |
| 899 | return; |
| 900 | |
| 901 | SizeRoomVertices(Curroomp, 1.05f); |
| 902 | World_changed = 1; |
| 903 | } |
| 904 | |
| 905 | void CRoomKeypadDialog::OnRoompadContractRoom() { |
| 906 | if (Curroomp == NULL) |
| 907 | return; |
| 908 | |
| 909 | SizeRoomVertices(Curroomp, .95f); |
| 910 | World_changed = 1; |
| 911 | } |
| 912 | |
| 913 | void CRoomKeypadDialog::OnRoompadExpandFace() { |
| 914 | if (Curroomp == NULL || Curface < 0 || Curface >= Curroomp->num_faces) |
| 915 | return; |
| 916 | |
| 917 | SizeFaceVertices(Curroomp, Curface, 1.05f); |
| 918 | World_changed = 1; |
| 919 | } |
| 920 | |
| 921 | void CRoomKeypadDialog::OnRoompadContractFace() { |
| 922 | if (Curroomp == NULL || Curface < 0 || Curface >= Curroomp->num_faces) |
| 923 | return; |
| 924 | |
| 925 | SizeFaceVertices(Curroomp, Curface, .95f); |
| 926 | World_changed = 1; |
| 927 | } |
| 928 | |
| 929 | void CRoomKeypadDialog::OnRoompadExpandEdge() { |
| 930 | |
| 931 | if (Curroomp == NULL || Curface < 0 || Curface >= Curroomp->num_faces) |
| 932 | return; |
| 933 | |
| 934 | SizeFaceEdge(Curroomp, Curface, Curedge, 1.05f); |
| 935 | World_changed = 1; |
| 936 | } |
| 937 | |
| 938 | void CRoomKeypadDialog::OnRoompadContractEdge() { |
| 939 | if (Curroomp == NULL || Curface < 0 || Curface >= Curroomp->num_faces) |
| 940 | return; |
| 941 | |
| 942 | SizeFaceEdge(Curroomp, Curface, Curedge, .95f); |
| 943 | World_changed = 1; |
| 944 | } |
| 945 | |
| 946 | void CRoomKeypadDialog::OnRoompadMoveForward() { |
| 947 | MoveRoomFace(Curroomp, Curface, 0, 0, 1); |
| 948 | World_changed = 1; |
| 949 | } |
| 950 | |
| 951 | void CRoomKeypadDialog::OnRoompadMoveBackward() { |
| 952 | MoveRoomFace(Curroomp, Curface, 0, 0, -1); |
| 953 | World_changed = 1; |
| 954 | } |
| 955 | |
| 956 | void CRoomKeypadDialog::OnRoompadMoveRight() { |
| 957 | MoveRoomFace(Curroomp, Curface, 1, 0, 0); |
| 958 | World_changed = 1; |
| 959 | } |
| 960 | |
| 961 | void CRoomKeypadDialog::OnRoompadMoveLeft() { |
| 962 | MoveRoomFace(Curroomp, Curface, -1, 0, 0); |
| 963 | World_changed = 1; |
| 964 | } |
| 965 | |
| 966 | void CRoomKeypadDialog::OnRoompadMoveUp() { |
| 967 | MoveRoomFace(Curroomp, Curface, 0, 1, 0); |
| 968 | World_changed = 1; |
| 969 | } |
| 970 | |
| 971 | void CRoomKeypadDialog::OnRoompadMoveDown() { |
| 972 | MoveRoomFace(Curroomp, Curface, 0, -1, 0); |
| 973 | World_changed = 1; |
| 974 | } |
| 975 | |
| 976 | void CRoomKeypadDialog::OnRoompadCombineFaces() { |
| 977 | if (Markedroomp == NULL) { |
| 978 | OutrageMessageBox("You must have a marked face for this operation."); |
| 979 | return; |
| 980 | } |
| 981 | |
| 982 | if (Markedroomp != Curroomp) { |
| 983 | OutrageMessageBox("The marked face and current face must be in the same room for this operation."); |
| 984 | return; |
| 985 | } |
| 986 | |
| 987 | if (Markedface == Curface) { |
| 988 | OutrageMessageBox("The marked face and current face cannot be the same for this operation."); |
| 989 | return; |
| 990 | } |
| 991 | |
| 992 | // Combine the faces |
| 993 | if (!CombineFaces(Curroomp, Markedface, Curface)) { |
| 994 | OutrageMessageBox("Cannot combine faces: %s", GetErrorMessage()); |
| 995 | return; |
| 996 | } |
| 997 | |
| 998 | // Fix marked face, if the number has changed |
| 999 | if (Curface < Markedface) |
| 1000 | Markedface--; |
| 1001 | |
| 1002 | // Reset curface, which should no longer exist |
| 1003 | Curface = Markedface; |
| 1004 | Curedge = Curvert = 0; |
| 1005 | } |
| 1006 | |
| 1007 | void CRoomKeypadDialog::OnRoompadNextPortal() { |
| 1008 | if (Curroomp->num_portals) { |
| 1009 | Curportal = (Curportal + 1) % Curroomp->num_portals; |
| 1010 | portal *pp = &Curroomp->portals[Curportal]; |
| 1011 | Curface = pp->portal_face; |
| 1012 | EditorStatus("Portal %d selected. Face %d selected.", Curportal, Curface); |
| 1013 | State_changed = 1; |
| 1014 | UpdateDialog(); |
| 1015 | } |
| 1016 | } |
| 1017 | |
| 1018 | BOOL CRoomKeypadDialog::OnInitDialog() { |
| 1019 | CDialog::OnInitDialog(); |
| 1020 | |
| 1021 | int i; |
| 1022 | |
| 1023 | // set up reverb dropdown listbox |
| 1024 | CComboBox *cbox = (CComboBox *)GetDlgItem(IDC_ROOM_ENVAUDIO); |
| 1025 | cbox->ResetContent(); |
| 1026 | for (i = 0; i < N_ENVAUDIO_PRESETS; i++) { |
| 1027 | cbox->AddString(EnvAudio_PresetNames[i]); |
| 1028 | } |
| 1029 | |
| 1030 | // Set up damage type dialog |
| 1031 | CComboBox *box = (CComboBox *)GetDlgItem(IDC_ROOMPAD_DAMAGETYPE); |
| 1032 | i = box->AddString("None"); |
| 1033 | box->SetItemData(i, PD_NONE); |
| 1034 | i = box->AddString("Energy Weapon"); |
| 1035 | box->SetItemData(i, PD_ENERGY_WEAPON); |
| 1036 | i = box->AddString("Matter Weapon"); |
| 1037 | box->SetItemData(i, PD_MATTER_WEAPON); |
| 1038 | i = box->AddString("Melee Attach"); |
| 1039 | box->SetItemData(i, PD_MELEE_ATTACK); |
| 1040 | i = box->AddString("Concussive Force"); |
| 1041 | box->SetItemData(i, PD_CONCUSSIVE_FORCE); |
| 1042 | i = box->AddString("Wall Hit"); |
| 1043 | box->SetItemData(i, PD_WALL_HIT); |
| 1044 | |
| 1045 | return TRUE; // return TRUE unless you set the focus to a control |
| 1046 | // EXCEPTION: OCX Property Pages should return FALSE |
| 1047 | } |
| 1048 | |
| 1049 | void CRoomKeypadDialog::UpdateKeypad(int mask) { |
| 1050 | if (mask & (KUF_CURROOM_CHANGED + KUF_CURFACE_CHANGED)) |
| 1051 | UpdateDialog(); |
| 1052 | } |
| 1053 | |
| 1054 | void CRoomKeypadDialog::OnRenderPortalFaces() { |
| 1055 | CButton *btn; |
| 1056 | portal *pp = &Curroomp->portals[Curportal]; |
| 1057 | |
| 1058 | btn = (CButton *)GetDlgItem(IDC_RENDER_PORTAL_FACES); |
| 1059 | |
| 1060 | if (btn->GetCheck()) |
| 1061 | pp->flags |= PF_RENDER_FACES; |
| 1062 | else |
| 1063 | pp->flags &= ~PF_RENDER_FACES; |
| 1064 | |
| 1065 | World_changed = 1; |
| 1066 | |
| 1067 | UpdateDialog(); |
| 1068 | } |
| 1069 | |
| 1070 | void CRoomKeypadDialog::OnEnablePortalFlythrough() { |
| 1071 | CButton *btn; |
| 1072 | portal *pp = &Curroomp->portals[Curportal]; |
| 1073 | |
| 1074 | btn = (CButton *)GetDlgItem(IDC_ENABLE_PORTAL_FLYTHROUGH); |
| 1075 | |
| 1076 | if (btn->GetCheck()) |
| 1077 | pp->flags |= PF_RENDERED_FLYTHROUGH; |
| 1078 | else |
| 1079 | pp->flags &= ~PF_RENDERED_FLYTHROUGH; |
| 1080 | |
| 1081 | World_changed = 1; |
| 1082 | } |
| 1083 | |
| 1084 | void CRoomKeypadDialog::OnExternalRoom() { |
| 1085 | CButton *btn; |
| 1086 | portal *pp = &Curroomp->portals[Curportal]; |
| 1087 | |
| 1088 | btn = (CButton *)GetDlgItem(IDC_EXTERNAL_ROOM); |
| 1089 | |
| 1090 | if (btn->GetCheck()) |
| 1091 | Curroomp->flags |= RF_EXTERNAL; |
| 1092 | else |
| 1093 | Curroomp->flags &= ~RF_EXTERNAL; |
| 1094 | |
| 1095 | World_changed = 1; |
| 1096 | |
| 1097 | UpdateDialog(); |
| 1098 | } |
| 1099 | |
| 1100 | void CRoomKeypadDialog::OnRoompadRefuelingCenter() { |
| 1101 | CButton *btn; |
| 1102 | |
| 1103 | btn = (CButton *)GetDlgItem(IDC_ROOMPAD_REFUELING_CENTER); |
| 1104 | |
| 1105 | if (btn->GetCheck()) |
| 1106 | Curroomp->flags |= RF_FUELCEN; |
| 1107 | else |
| 1108 | Curroomp->flags &= ~RF_FUELCEN; |
| 1109 | |
| 1110 | World_changed = 1; |
| 1111 | |
| 1112 | UpdateDialog(); |
| 1113 | } |
| 1114 | |
| 1115 | void CRoomKeypadDialog::OnRoompadGoal1() { |
| 1116 | CButton *btn; |
| 1117 | |
| 1118 | btn = (CButton *)GetDlgItem(IDC_ROOMPAD_GOAL1); |
| 1119 | |
| 1120 | if (btn->GetCheck()) |
| 1121 | Curroomp->flags |= RF_GOAL1; |
| 1122 | else |
| 1123 | Curroomp->flags &= ~RF_GOAL1; |
| 1124 | |
| 1125 | World_changed = 1; |
| 1126 | |
| 1127 | UpdateDialog(); |
| 1128 | } |
| 1129 | |
| 1130 | void CRoomKeypadDialog::OnRoompadGoal2() { |
| 1131 | CButton *btn; |
| 1132 | |
| 1133 | btn = (CButton *)GetDlgItem(IDC_ROOMPAD_GOAL2); |
| 1134 | |
| 1135 | if (btn->GetCheck()) |
| 1136 | Curroomp->flags |= RF_GOAL2; |
| 1137 | else |
| 1138 | Curroomp->flags &= ~RF_GOAL2; |
| 1139 | |
| 1140 | World_changed = 1; |
| 1141 | |
| 1142 | UpdateDialog(); |
| 1143 | } |
| 1144 | |
| 1145 | void CRoomKeypadDialog::OnRenderExternalRooms() { |
| 1146 | CButton *btn; |
| 1147 | |
| 1148 | btn = (CButton *)GetDlgItem(IDC_RENDER_EXTERNAL_ROOMS); |
| 1149 | |
| 1150 | if (btn->GetCheck()) |
| 1151 | Render_all_external_rooms = 1; |
| 1152 | else |
| 1153 | Render_all_external_rooms = 0; |
| 1154 | |
| 1155 | State_changed = 1; |
| 1156 | |
| 1157 | UpdateDialog(); |
| 1158 | } |
| 1159 | |
| 1160 | void CRoomKeypadDialog::OnNextFace() { |
| 1161 | if (++Curface >= Curroomp->num_faces) |
| 1162 | Curface = 0; |
| 1163 | |
| 1164 | EditorStatus("Face %d selected.", Curface); |
| 1165 | UpdateDialog(); |
| 1166 | |
| 1167 | State_changed = 1; |
| 1168 | } |
| 1169 | |
| 1170 | void CRoomKeypadDialog::OnTouchesOutside() { |
| 1171 | CButton *btn; |
| 1172 | |
| 1173 | btn = (CButton *)GetDlgItem(IDC_TOUCHES_OUTSIDE); |
| 1174 | |
| 1175 | if (btn->GetCheck()) |
| 1176 | Curroomp->flags |= RF_TOUCHES_TERRAIN; |
| 1177 | else |
| 1178 | Curroomp->flags &= ~RF_TOUCHES_TERRAIN; |
| 1179 | |
| 1180 | World_changed = 1; |
| 1181 | |
| 1182 | UpdateDialog(); |
| 1183 | } |
| 1184 | |
| 1185 | void CRoomKeypadDialog::OnRoompadGoal3() { |
| 1186 | CButton *btn; |
| 1187 | |
| 1188 | btn = (CButton *)GetDlgItem(IDC_ROOMPAD_GOAL3); |
| 1189 | |
| 1190 | if (btn->GetCheck()) |
| 1191 | Curroomp->flags |= RF_GOAL3; |
| 1192 | else |
| 1193 | Curroomp->flags &= ~RF_GOAL3; |
| 1194 | |
| 1195 | World_changed = 1; |
| 1196 | |
| 1197 | UpdateDialog(); |
| 1198 | } |
| 1199 | |
| 1200 | void CRoomKeypadDialog::OnRoompadGoal4() { |
| 1201 | CButton *btn; |
| 1202 | |
| 1203 | btn = (CButton *)GetDlgItem(IDC_ROOMPAD_GOAL4); |
| 1204 | |
| 1205 | if (btn->GetCheck()) |
| 1206 | Curroomp->flags |= RF_GOAL4; |
| 1207 | else |
| 1208 | Curroomp->flags &= ~RF_GOAL4; |
| 1209 | |
| 1210 | World_changed = 1; |
| 1211 | |
| 1212 | UpdateDialog(); |
| 1213 | } |
| 1214 | |
| 1215 | void CRoomKeypadDialog::OnGoalfaceCheck() { |
| 1216 | CButton *btn; |
| 1217 | |
| 1218 | btn = (CButton *)GetDlgItem(IDC_GOALFACE_CHECK); |
| 1219 | |
| 1220 | if (btn->GetCheck()) { |
| 1221 | if (!(Curroomp->flags & GOALROOM | RF_SPECIAL1 | RF_SPECIAL2 | RF_SPECIAL3 | RF_SPECIAL4 | RF_SPECIAL5 | |
| 1222 | RF_SPECIAL6)) { |
| 1223 | OutrageMessageBox("This room needs to marked as a goal first."); |
| 1224 | } else |
| 1225 | Curroomp->faces[Curface].flags |= FF_GOALFACE; |
| 1226 | } else |
| 1227 | Curroomp->faces[Curface].flags &= ~FF_GOALFACE; |
| 1228 | |
| 1229 | World_changed = 1; |
| 1230 | |
| 1231 | UpdateDialog(); |
| 1232 | } |
| 1233 | |
| 1234 | void CRoomKeypadDialog::OnSpecial1() { |
| 1235 | CButton *btn; |
| 1236 | |
| 1237 | btn = (CButton *)GetDlgItem(IDC_SPECIAL_1); |
| 1238 | |
| 1239 | if (btn->GetCheck()) |
| 1240 | Curroomp->flags |= RF_SPECIAL1; |
| 1241 | else |
| 1242 | Curroomp->flags &= ~RF_SPECIAL1; |
| 1243 | |
| 1244 | World_changed = 1; |
| 1245 | |
| 1246 | UpdateDialog(); |
| 1247 | } |
| 1248 | |
| 1249 | void CRoomKeypadDialog::OnSpecial2() { |
| 1250 | CButton *btn; |
| 1251 | |
| 1252 | btn = (CButton *)GetDlgItem(IDC_SPECIAL_2); |
| 1253 | |
| 1254 | if (btn->GetCheck()) |
| 1255 | Curroomp->flags |= RF_SPECIAL2; |
| 1256 | else |
| 1257 | Curroomp->flags &= ~RF_SPECIAL2; |
| 1258 | |
| 1259 | World_changed = 1; |
| 1260 | |
| 1261 | UpdateDialog(); |
| 1262 | } |
| 1263 | |
| 1264 | void CRoomKeypadDialog::OnSpecial3() { |
| 1265 | CButton *btn; |
| 1266 | |
| 1267 | btn = (CButton *)GetDlgItem(IDC_SPECIAL_3); |
| 1268 | |
| 1269 | if (btn->GetCheck()) |
| 1270 | Curroomp->flags |= RF_SPECIAL3; |
| 1271 | else |
| 1272 | Curroomp->flags &= ~RF_SPECIAL3; |
| 1273 | |
| 1274 | World_changed = 1; |
| 1275 | |
| 1276 | UpdateDialog(); |
| 1277 | } |
| 1278 | |
| 1279 | void CRoomKeypadDialog::OnSpecial4() { |
| 1280 | CButton *btn; |
| 1281 | |
| 1282 | btn = (CButton *)GetDlgItem(IDC_SPECIAL_4); |
| 1283 | |
| 1284 | if (btn->GetCheck()) |
| 1285 | Curroomp->flags |= RF_SPECIAL4; |
| 1286 | else |
| 1287 | Curroomp->flags &= ~RF_SPECIAL4; |
| 1288 | |
| 1289 | World_changed = 1; |
| 1290 | |
| 1291 | UpdateDialog(); |
| 1292 | } |
| 1293 | |
| 1294 | void CRoomKeypadDialog::OnSpecial5() { |
| 1295 | CButton *btn; |
| 1296 | |
| 1297 | btn = (CButton *)GetDlgItem(IDC_SPECIAL_5); |
| 1298 | |
| 1299 | if (btn->GetCheck()) |
| 1300 | Curroomp->flags |= RF_SPECIAL5; |
| 1301 | else |
| 1302 | Curroomp->flags &= ~RF_SPECIAL5; |
| 1303 | |
| 1304 | World_changed = 1; |
| 1305 | |
| 1306 | UpdateDialog(); |
| 1307 | } |
| 1308 | |
| 1309 | void CRoomKeypadDialog::OnSpecial6() { |
| 1310 | CButton *btn; |
| 1311 | |
| 1312 | btn = (CButton *)GetDlgItem(IDC_SPECIAL_6); |
| 1313 | |
| 1314 | if (btn->GetCheck()) |
| 1315 | Curroomp->flags |= RF_SPECIAL6; |
| 1316 | else |
| 1317 | Curroomp->flags &= ~RF_SPECIAL6; |
| 1318 | |
| 1319 | World_changed = 1; |
| 1320 | |
| 1321 | UpdateDialog(); |
| 1322 | } |
| 1323 | |
| 1324 | void CRoomKeypadDialog::OnBoaVisButton() { |
| 1325 | int answer = MessageBox("Do you wish compute the BOA vis table?", "Question", MB_YESNO); |
| 1326 | |
| 1327 | if (answer == IDNO) |
| 1328 | return; |
| 1329 | |
| 1330 | MakeBOAVisTable(); |
| 1331 | } |
| 1332 | |
| 1333 | void CRoomKeypadDialog::OnSelendokRoomAmbient() { |
| 1334 | int cur; |
| 1335 | char name[200]; |
| 1336 | |
| 1337 | cur = SendDlgItemMessage(IDC_ROOM_AMBIENT, CB_GETCURSEL, 0, 0); |
| 1338 | SendDlgItemMessage(IDC_ROOM_AMBIENT, CB_GETLBTEXT, cur, (LPARAM)(LPCTSTR)name); |
| 1339 | |
| 1340 | Curroomp->ambient_sound = FindAmbientSoundPattern(name); |
| 1341 | |
| 1342 | World_changed = 1; |
| 1343 | } |
| 1344 | |
| 1345 | void CRoomKeypadDialog::OnMirrorButton() { |
| 1346 | if (Curroomp == NULL) |
| 1347 | return; |
| 1348 | Curroomp->mirror_face = Curface; |
| 1349 | ConsolidateMineMirrors(); |
| 1350 | UpdateDialog(); |
| 1351 | } |
| 1352 | |
| 1353 | void CRoomKeypadDialog::OnNoMirrorButton() { |
| 1354 | if (Curroomp == NULL) |
| 1355 | return; |
| 1356 | Curroomp->mirror_face = -1; |
| 1357 | ConsolidateMineMirrors(); |
| 1358 | UpdateDialog(); |
| 1359 | } |
| 1360 | |
| 1361 | void CRoomKeypadDialog::OnRoompadFlipFace() { |
| 1362 | if (Curroomp->faces[Curface].portal_num != -1) { |
| 1363 | OutrageMessageBox("You cannot flip a portal face."); |
| 1364 | return; |
| 1365 | } |
| 1366 | |
| 1367 | if (OutrageMessageBox(MBOX_YESNO, "Are you sure you want to flip the current face?") != IDYES) |
| 1368 | return; |
| 1369 | |
| 1370 | // Flip the face |
| 1371 | FlipFace(Curroomp, Curface); |
| 1372 | } |
| 1373 | |
| 1374 | void CRoomKeypadDialog::OnRoompadNoDrawTerrain() { |
| 1375 | CButton *btn = (CButton *)GetDlgItem(IDC_ROOMPAD_NO_DRAW_TERRAIN); |
| 1376 | |
| 1377 | Render_inside_only = (btn->GetCheck() != 0); |
| 1378 | |
| 1379 | State_changed = 1; |
| 1380 | |
| 1381 | UpdateDialog(); |
| 1382 | } |
| 1383 | |
| 1384 | void CRoomKeypadDialog::OnRoompadOneRoomOnly() { |
| 1385 | CButton *btn = (CButton *)GetDlgItem(IDC_ROOMPAD_ONE_ROOM_ONLY); |
| 1386 | |
| 1387 | Render_one_room_only = (btn->GetCheck() != 0); |
| 1388 | |
| 1389 | State_changed = 1; |
| 1390 | |
| 1391 | UpdateDialog(); |
| 1392 | } |
| 1393 | |
| 1394 | void CRoomKeypadDialog::OnTriangulate() { |
| 1395 | CButton *btn; |
| 1396 | |
| 1397 | btn = (CButton *)GetDlgItem(IDC_TRIANGULATE); |
| 1398 | |
| 1399 | if (btn->GetCheck()) |
| 1400 | Curroomp->flags |= RF_TRIANGULATE; |
| 1401 | else |
| 1402 | Curroomp->flags &= ~RF_TRIANGULATE; |
| 1403 | |
| 1404 | World_changed = 1; |
| 1405 | |
| 1406 | UpdateDialog(); |
| 1407 | } |
| 1408 | |
| 1409 | void CRoomKeypadDialog::OnEditName() { |
| 1410 | extern void RenameRoom(); |
| 1411 | |
| 1412 | RenameRoom(); |
| 1413 | |
| 1414 | UpdateDialog(); |
| 1415 | } |
| 1416 | |
| 1417 | /////////////////////////////////////////////////////////////////////// |
| 1418 | |
| 1419 | void CRoomKeypadDialog::OnSelchangeRoomEnvaudio() { |
| 1420 | CComboBox *cbox = (CComboBox *)GetDlgItem(IDC_ROOM_ENVAUDIO); |
| 1421 | CString selection; |
| 1422 | int i; |
| 1423 | |
| 1424 | cbox->GetLBText(cbox->GetCurSel(), selection); |
| 1425 | |
| 1426 | for (i = 0; i < N_ENVAUDIO_PRESETS; i++) { |
| 1427 | if (selection == EnvAudio_PresetNames[i]) { |
| 1428 | Curroomp->env_reverb = i; |
| 1429 | break; |
| 1430 | } |
| 1431 | } |
| 1432 | } |
| 1433 | |
| 1434 | void CRoomKeypadDialog::OnKillfocusRoompadDamage() { |
| 1435 | char buf[128]; |
| 1436 | |
| 1437 | CEdit *box = (CEdit *)GetDlgItem(IDC_ROOMPAD_DAMAGE); |
| 1438 | |
| 1439 | box->GetWindowText(buf, sizeof(buf)); |
| 1440 | |
| 1441 | Curroomp->damage = atof(buf); |
| 1442 | |
| 1443 | World_changed = 1; |
| 1444 | |
| 1445 | UpdateDialog(); |
| 1446 | } |
| 1447 | |
| 1448 | void CRoomKeypadDialog::OnSelchangeRoompadDamageType() { |
| 1449 | CComboBox *box = (CComboBox *)GetDlgItem(IDC_ROOMPAD_DAMAGETYPE); |
| 1450 | |
| 1451 | Curroomp->damage_type = (int8_t)box->GetItemData(box->GetCurSel()); |
| 1452 | } |
| 1453 | |
| 1454 | void CRoomKeypadDialog::OnRenderShell() { |
| 1455 | Shell_render_flag ^= SRF_NO_SHELL; |
| 1456 | |
| 1457 | State_changed = 1; |
| 1458 | |
| 1459 | UpdateDialog(); |
| 1460 | } |
| 1461 | |
| 1462 | void CRoomKeypadDialog::OnRenderNonShell() { |
| 1463 | Shell_render_flag ^= SRF_NO_NON_SHELL; |
| 1464 | |
| 1465 | State_changed = 1; |
| 1466 | |
| 1467 | UpdateDialog(); |
| 1468 | } |
| 1469 | |
| 1470 | void CRoomKeypadDialog::OnSecretCheck() { |
| 1471 | CButton *btn; |
| 1472 | |
| 1473 | btn = (CButton *)GetDlgItem(IDC_SECRET_CHECK); |
| 1474 | |
| 1475 | if (btn->GetCheck()) |
| 1476 | Curroomp->flags |= RF_SECRET; |
| 1477 | else |
| 1478 | Curroomp->flags &= ~RF_SECRET; |
| 1479 | |
| 1480 | World_changed = 1; |
| 1481 | |
| 1482 | UpdateDialog(); |
| 1483 | } |
| 1484 | |
| 1485 | void CRoomKeypadDialog::OnPortalBlockedCheck() { |
| 1486 | CButton *btn; |
| 1487 | portal *pp = &Curroomp->portals[Curportal]; |
| 1488 | |
| 1489 | btn = (CButton *)GetDlgItem(IDC_PORTAL_BLOCKED_CHECK); |
| 1490 | |
| 1491 | portal *np = &Rooms[Curroomp->portals[Curportal].croom].portals[Curroomp->portals[Curportal].cportal]; |
| 1492 | |
| 1493 | if (btn->GetCheck()) { |
| 1494 | pp->flags |= PF_BLOCK; |
| 1495 | np->flags |= PF_BLOCK; |
| 1496 | } else { |
| 1497 | pp->flags &= ~PF_BLOCK; |
| 1498 | np->flags &= ~PF_BLOCK; |
| 1499 | } |
| 1500 | |
| 1501 | World_changed = 1; |
| 1502 | } |
| 1503 | |
| 1504 | void CRoomKeypadDialog::OnPortalBlockedCanGoAwayCheck() { |
| 1505 | CButton *btn; |
| 1506 | portal *pp = &Curroomp->portals[Curportal]; |
| 1507 | |
| 1508 | btn = (CButton *)GetDlgItem(IDC_PORTAL_BLOCKED_CAN_GO_AWAY_CHECK); |
| 1509 | |
| 1510 | if (btn->GetCheck()) |
| 1511 | pp->flags |= PF_BLOCK_REMOVABLE; |
| 1512 | else |
| 1513 | pp->flags &= ~PF_BLOCK_REMOVABLE; |
| 1514 | |
| 1515 | World_changed = 1; |
| 1516 | } |
| 1517 | |
| 1518 | void CRoomKeypadDialog::OnBadCenterpoints() { |
| 1519 | char message[10000]; |
| 1520 | message[0] = '\0'; |
| 1521 | |
| 1522 | mprintf(0, "Computing bad centers\n"); |
| 1523 | BOA_ComputePathPoints(message, 10000); |
| 1524 | mprintf(0, "Done computing bad centers... List in clipboard.\n"); |
| 1525 | DumpTextToClipboard(message); |
| 1526 | } |
| 1527 | |
| 1528 | void CRoomKeypadDialog::OnRoomSkipLighting() { |
| 1529 | CButton *btn = (CButton *)GetDlgItem(IDC_ROOM_SKIP_LIGHTING); |
| 1530 | |
| 1531 | if (btn->GetCheck()) { |
| 1532 | Curroomp->flags |= RF_NO_LIGHT; |
| 1533 | } else { |
| 1534 | Curroomp->flags &= ~RF_NO_LIGHT; |
| 1535 | } |
| 1536 | |
| 1537 | World_changed = 1; |
| 1538 | UpdateDialog(); |
| 1539 | } |