| 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/MainFrm.cpp $ |
| 21 | * $Revision: 1.1.1.1 $ |
| 22 | * $Date: 2003-08-26 03:57:38 $ |
| 23 | * $Author: kevinb $ |
| 24 | * |
| 25 | * The editor main frame window |
| 26 | * |
| 27 | * $Log: not supported by cvs2svn $ |
| 28 | * |
| 29 | * 164 10/29/99 4:34p Matt |
| 30 | * Added code (not being called) to count the number of specular faces in |
| 31 | * a level. |
| 32 | * |
| 33 | * 163 10/27/99 10:37a Matt |
| 34 | * Added some code (not being called in this version) to list all the |
| 35 | * objects in a level that use lightmaps. |
| 36 | * |
| 37 | * 162 10/25/99 12:54p Jeff |
| 38 | * test1 _really_ destroys all lightmaps |
| 39 | * |
| 40 | * 161 10/13/99 10:41a Chris |
| 41 | * Added 'special forcefields' that have custom bounce factors |
| 42 | * |
| 43 | * 160 9/15/99 1:56p Matt |
| 44 | * Added the option to allow rooms or groups placed on the terrain to |
| 45 | * either align with the terrain or with gravity. |
| 46 | * |
| 47 | * 159 8/18/99 11:29a Matt |
| 48 | * Added shortcuts for next vertex and add vert to face. |
| 49 | * |
| 50 | * 158 8/17/99 4:09p Matt |
| 51 | * Added some accelerator keys, and a function to copy face light |
| 52 | * multiples. |
| 53 | * |
| 54 | * 157 8/12/99 9:36a Matt |
| 55 | * Changed MoveEntireMine() code to move in both X and Y. |
| 56 | * |
| 57 | * 156 7/28/99 5:48p Matt |
| 58 | * Added test code to scale an entire mine. |
| 59 | * |
| 60 | * 155 5/22/99 4:40a Matt |
| 61 | * Fixed yet another small bug in the show-all-locked-pages code. |
| 62 | * |
| 63 | * 154 5/21/99 1:29p Matt |
| 64 | * Fixed tiny bug. |
| 65 | * |
| 66 | * 153 5/21/99 12:36p Matt |
| 67 | * Added test code to check for destroyable textures without a destroyed |
| 68 | * bitmap. |
| 69 | * |
| 70 | * 152 5/10/99 12:04a Matt |
| 71 | * Added function for Luke to shift the entire mine. |
| 72 | * |
| 73 | * 151 5/08/99 1:01p Matt |
| 74 | * Added a function for Luke to scale all the room light multipliers in a |
| 75 | * level. |
| 76 | * |
| 77 | * 150 5/08/99 1:39a Matt |
| 78 | * Added a function to delete all objects of a certain type, and support |
| 79 | * for placing and attaching groups to the terrain. |
| 80 | * |
| 81 | * 149 5/05/99 2:02a Matt |
| 82 | * Added a function to check for precision-error FVI cracks in the level. |
| 83 | * |
| 84 | * 148 5/03/99 2:56a Matt |
| 85 | * Added a function for Luke to delete all the faces in a room that have |
| 86 | * texture 1 on them. |
| 87 | * |
| 88 | * 147 5/02/99 9:23p Matt |
| 89 | * Notify the level keypad when the level has changed, and then re-init |
| 90 | * the combo boxes. |
| 91 | * |
| 92 | * 146 5/02/99 6:41a Jeff |
| 93 | * created 'test/temp' function to force unload all osiris modules |
| 94 | * |
| 95 | * 145 5/02/99 2:01a Jeff |
| 96 | * fixed crash in getchangemask |
| 97 | * |
| 98 | * 144 5/01/99 9:43p Matt |
| 99 | * Apparently, there's no longer a page called "DUMMY PAGE" in the list of |
| 100 | * locked pages, so remove the assert that checked for it. |
| 101 | * |
| 102 | * 143 4/29/99 11:51p Matt |
| 103 | * Improved viewer move functions. |
| 104 | * |
| 105 | * 142 4/29/99 3:19p Jeff |
| 106 | * test function 3 to grab non-physics set objects |
| 107 | * |
| 108 | * 141 4/23/99 4:55p Matt |
| 109 | * Fixed bug in previous version. |
| 110 | * |
| 111 | * 140 4/23/99 2:51p Matt |
| 112 | * Added function to relink objects from the terrain to the mine to fix |
| 113 | * one of Dan's levels. |
| 114 | * |
| 115 | * 139 4/21/99 10:36p Matt |
| 116 | * Fixed typo |
| 117 | * |
| 118 | * 138 4/21/99 10:20p Matt |
| 119 | * Fixed cut room message |
| 120 | * |
| 121 | * 137 4/17/99 6:15p Samir |
| 122 | * replaced gr.h with grdefs.h and fixed resulting compile bugs. |
| 123 | * |
| 124 | * 136 4/16/99 3:54p Nate |
| 125 | * Added Viewer Properties Dialog |
| 126 | * |
| 127 | * 135 4/12/99 12:50p Matt |
| 128 | * Added function to dump goal text to a file. |
| 129 | * |
| 130 | * 134 4/05/99 11:17a Matt |
| 131 | * Added code to list all the objects in the levels. |
| 132 | * |
| 133 | * 133 4/05/99 10:54a Matt |
| 134 | * Added auto-waypoint system |
| 135 | * |
| 136 | * 131 4/03/99 7:54p Matt |
| 137 | * Finished implementing spiffy keypad update system. |
| 138 | * |
| 139 | * 130 4/02/99 5:08p Matt |
| 140 | * Added intro movie. |
| 141 | * |
| 142 | * 129 3/30/99 6:24p Matt |
| 143 | * Added new error system, where instead of putting up an error message, a |
| 144 | * function returns a failure code & returns an error message that the |
| 145 | * caller can display if it wants. |
| 146 | * |
| 147 | * 128 3/30/99 4:09p Matt |
| 148 | * Fixed very small bug |
| 149 | * |
| 150 | * 127 3/30/99 11:25a Matt |
| 151 | * Re-enabled object reset code |
| 152 | * |
| 153 | * 126 3/25/99 4:11p Samir |
| 154 | * added aureal test code. |
| 155 | * |
| 156 | * 125 3/18/99 8:41p Jeff |
| 157 | * created orphan hunter dialog |
| 158 | * |
| 159 | * 124 3/15/99 4:04p Matt |
| 160 | * Added code to show a list of named rooms. |
| 161 | * |
| 162 | * 123 3/10/99 7:17p Samir |
| 163 | * added function that updates keypads. |
| 164 | * |
| 165 | * 122 3/01/99 6:26p Matt |
| 166 | * Added function to fix bad objects in Dan's level |
| 167 | * |
| 168 | * 121 2/23/99 11:51p Jeff |
| 169 | * new script dll sync dialog |
| 170 | * |
| 171 | * 120 2/22/99 11:39p Matt |
| 172 | * Deleted debris editor menu item, since it' no longer needed. |
| 173 | * |
| 174 | * 119 2/21/99 4:20p Matt |
| 175 | * Added SoundSource objects (and reformatted parts of the object header |
| 176 | * files). |
| 177 | * |
| 178 | * 118 2/05/99 1:29p Matt |
| 179 | * Added a function to show the viewer's forward vector. (Also checked |
| 180 | * select-object-by-number to use common code to print out the selected |
| 181 | * object info.) |
| 182 | * |
| 183 | * 117 2/03/99 1:10p Matt |
| 184 | * Changed the paletted room current faces to be stored in a seperate |
| 185 | * array, instead of in the room structure. |
| 186 | * |
| 187 | * 116 2/03/99 1:20a Matt |
| 188 | * Added a system to show all pages locked. |
| 189 | * |
| 190 | * 115 2/01/99 11:36p Matt |
| 191 | * Added menu functions to select an object by number and move the viewer |
| 192 | * to the current object. |
| 193 | * |
| 194 | * 114 1/24/99 6:35p Matt |
| 195 | * Made view set functions behave differently in Room View |
| 196 | * |
| 197 | * 113 1/21/99 11:15p Jeff |
| 198 | * pulled out some structs and defines from header files and moved them |
| 199 | * into seperate header files so that multiplayer dlls don't require major |
| 200 | * game headers, just those new headers. Side effect is a shorter build |
| 201 | * time. Also cleaned up some header file #includes that weren't needed. |
| 202 | * This affected polymodel.h, object.h, player.h, vecmat.h, room.h, |
| 203 | * manage.h and multi.h |
| 204 | * |
| 205 | * 112 1/19/99 6:53p Matt |
| 206 | * Fixed a problem when the viewer was instantaneously moved from inside |
| 207 | * to ourside or vise-versa. |
| 208 | * |
| 209 | * 111 1/15/99 7:52p Chris |
| 210 | * Updated ObjSetPos() to include a f_update_attach_children flag |
| 211 | * |
| 212 | * 110 1/12/99 12:35p Nate |
| 213 | * Clicking on the DALLAS menu item now restores it if it was minimized |
| 214 | * |
| 215 | * 109 1/11/99 3:34p Jeff |
| 216 | * added checks for when going editor->game to see if scripts are out of |
| 217 | * date, if so give the option of breaking out. Add some options to mass |
| 218 | * script compiler, along with a toolbar shortcut. |
| 219 | * |
| 220 | * 108 1/08/99 2:56p Samir |
| 221 | * Ripped out OSIRIS1. |
| 222 | * |
| 223 | * 107 12/23/98 4:01p Nate |
| 224 | * Added code create Dallas as a modeless dialog |
| 225 | * |
| 226 | * 106 12/11/98 6:48p Nate |
| 227 | * Added support for starting D.A.L.L.A.S. from the main menu |
| 228 | * |
| 229 | * 105 12/11/98 5:50p Jeff |
| 230 | * implemented and added changes regarding Level&Scripting manage system |
| 231 | * and compiler interface |
| 232 | * |
| 233 | * 104 12/01/98 11:17p Matt |
| 234 | * Added menu option to disable drawing objects in the wireframe view |
| 235 | * |
| 236 | * 103 11/01/98 1:58a Jeff |
| 237 | * converted the vsprintf calls to use the Pvsprintf, which is a safe |
| 238 | * vsprintf, no buffer overflows allowed |
| 239 | * |
| 240 | * 102 10/21/98 12:50p Sean |
| 241 | * Allow for cameras to be placed on external rooms |
| 242 | * |
| 243 | * 101 10/14/98 4:37p Matt |
| 244 | * Made InitD3System() exit with error if there's a problem instead of |
| 245 | * returning a status value. Also moved some editor-specific code from |
| 246 | * init.cpp to mainfrm.cpp, and cleaned up some other initialization and |
| 247 | * error-handling code. |
| 248 | * |
| 249 | * 100 10/12/98 1:46p Samir |
| 250 | * new Program_version parameters. |
| 251 | * |
| 252 | * 99 10/08/98 4:23p Kevin |
| 253 | * Changed code to comply with memory library usage. Always use mem_malloc |
| 254 | * , mem_free and mem_strdup |
| 255 | * |
| 256 | * 98 10/06/98 12:38p Nate |
| 257 | * |
| 258 | * 97 10/04/98 1:25p Matt |
| 259 | * |
| 260 | * 96 10/02/98 1:43p Samir |
| 261 | * took out FULL_DEVELOPMENT |
| 262 | * |
| 263 | * 95 9/09/98 12:48p Samir |
| 264 | * added script localizer. |
| 265 | * |
| 266 | * 94 9/03/98 5:29p Matt |
| 267 | * Added code to fix cracks in levels. |
| 268 | * |
| 269 | * 93 9/03/98 2:20p Jeff |
| 270 | * flush keyboard after briefeditor exits |
| 271 | * |
| 272 | * 92 9/02/98 2:55p Jeff |
| 273 | * initial creation of briefing editor |
| 274 | * |
| 275 | * 91 8/31/98 4:37p Matt |
| 276 | * Added improved room & mine error checking. |
| 277 | * |
| 278 | * 90 8/27/98 6:42p Chris |
| 279 | * Added the goal keypad and the start of the matcen keypad |
| 280 | * |
| 281 | * 89 8/20/98 12:35p Matt |
| 282 | * Added nice editing for ambient sound patterns |
| 283 | * |
| 284 | * 88 8/13/98 1:06p Nate |
| 285 | * Disabled pausing of Editor when running TableTextEditor |
| 286 | * |
| 287 | * 87 8/10/98 12:14p Nate |
| 288 | * Added Table File Edit dialog. |
| 289 | * |
| 290 | * 86 7/08/98 6:26p Samir |
| 291 | * took out obsolete code. |
| 292 | * |
| 293 | * 85 7/01/98 4:58p Samir |
| 294 | * changed InitD3Systems. |
| 295 | * |
| 296 | * 84 6/29/98 6:45p Samir |
| 297 | * call WM_ACTIVATEAPP Descent Handler from mainframe. |
| 298 | * |
| 299 | * 83 6/25/98 7:16p Matt |
| 300 | * Added code to check for errors in portal linkage |
| 301 | * |
| 302 | * 82 5/01/98 3:57p Matt |
| 303 | * Added function to place a camera in the center of the current face. |
| 304 | * |
| 305 | * 81 4/21/98 2:40p Matt |
| 306 | * Added option to show level stats |
| 307 | * |
| 308 | * 80 4/16/98 6:39p Kevin |
| 309 | * made CKeypadDialog::Activate static. |
| 310 | * |
| 311 | * 79 4/14/98 7:50p Matt |
| 312 | * Added system to keep info for each level |
| 313 | * |
| 314 | * 78 3/27/98 6:05p Samir |
| 315 | * Added key handler for main frame. |
| 316 | * |
| 317 | * 77 3/23/98 8:03p Samir |
| 318 | * A bunch of changes to allow for ALT-TAB to work. |
| 319 | * |
| 320 | * 76 3/23/98 2:17p Jeff |
| 321 | * Included telcom.h |
| 322 | * |
| 323 | * 75 3/06/98 5:36p Matt |
| 324 | * Took out cfile try/catch for editor, since it's probably better to get |
| 325 | * the error in the cfile code when debugging, so you can look at the |
| 326 | * stack & parms and stuff. I've left try/catch in for the game, but |
| 327 | * ideally we'd take that out too when running under the debugger, if we |
| 328 | * could figure out how to do that. |
| 329 | * |
| 330 | * 74 2/17/98 6:13p Jeff |
| 331 | * Changed it so TelCom is forced to go into Briefings when called |
| 332 | * |
| 333 | * 73 2/15/98 7:44p Matt |
| 334 | * Added groovy try/catch/throw error checking for cfile functions |
| 335 | * |
| 336 | * 72 2/09/98 10:54a Matt |
| 337 | * Don't allow user to switch to mine view if there are no internal rooms |
| 338 | * |
| 339 | * 71 2/05/98 3:11p Matt |
| 340 | * Don't move the viewer to an external room. |
| 341 | * |
| 342 | * 70 2/05/98 2:57p Matt |
| 343 | * Changed code to use ObjSetPos() |
| 344 | * |
| 345 | * 69 2/04/98 6:23p Matt |
| 346 | * Changed object room number to indicate a terrain cell via a flag. Got |
| 347 | * rid of the object flag which used to indicate terrain. |
| 348 | * |
| 349 | * 68 1/30/98 6:07p Matt |
| 350 | * Added code and menu items to deal with camera objects |
| 351 | * |
| 352 | * 67 1/29/98 2:15p Samir |
| 353 | * Implemented ObjectListModeless and Toolbar button. |
| 354 | * |
| 355 | * 66 1/21/98 1:08p Matt |
| 356 | * Made SetViewMode() not take new_viewer parm, since it's not needed |
| 357 | * after my revamp of the editor view system. |
| 358 | * |
| 359 | * 65 1/21/98 12:33p Matt |
| 360 | * Revamped viewer system |
| 361 | * |
| 362 | * 64 12/02/97 4:43p Samir |
| 363 | * Repaired MainFrm.cpp |
| 364 | * |
| 365 | * 63 12/01/97 6:06p Samir |
| 366 | * Implemented new FileDialog tracker system. |
| 367 | * |
| 368 | * 62 11/17/97 3:53p Matt |
| 369 | * When deleting objects, set the pointers to them to NULL. |
| 370 | * Added test function to play the briefing. |
| 371 | * |
| 372 | * 61 10/22/97 4:30p Chris |
| 373 | * We can now slew between the mine and the terrain |
| 374 | * |
| 375 | * 60 10/16/97 7:35p Samir |
| 376 | * For fullscreen game from editor, hide all user interface elements of |
| 377 | * the editor window and use the client area for our display. It's REALLY |
| 378 | * hacked, but seems to be the cleanest method of playing the game in |
| 379 | * fullscreen. Old method of blanking window doesn't work. |
| 380 | * |
| 381 | * 59 10/15/97 5:20p Jason |
| 382 | * did a HUGE overhaul of the bitmap system |
| 383 | * |
| 384 | * 58 10/03/97 3:39p Matt |
| 385 | * Added seperate sets of wireframe view variables for mine & room views |
| 386 | * |
| 387 | * 57 9/23/97 10:38a Jason |
| 388 | * Took out OnTerrain |
| 389 | * |
| 390 | * 56 9/23/97 10:27a Jason |
| 391 | * took premature return from OnFileImportRoom |
| 392 | * |
| 393 | * 55 9/22/97 5:59p Samir |
| 394 | * Changed ObjCScript system, so everything is broken, but it shouldn't |
| 395 | * crash the game. |
| 396 | * |
| 397 | * 53 9/17/97 12:58p Samir |
| 398 | * Got rid of Curve Keypad. |
| 399 | * |
| 400 | * 52 9/17/97 12:48p Samir |
| 401 | * Got rid of more obscure segment references. |
| 402 | * |
| 403 | * 51 9/17/97 11:30a Jason |
| 404 | * ripped out segment engine |
| 405 | * |
| 406 | * 50 9/16/97 4:27p Matt |
| 407 | * Got rid of static_light & changed fields in the room struct |
| 408 | * |
| 409 | * 49 9/11/97 5:38p Jason |
| 410 | * initial door coding for room engine |
| 411 | * |
| 412 | * 48 9/09/97 12:23p Samir |
| 413 | * Added a menu item to go to level properties dialog. |
| 414 | * |
| 415 | * 47 9/02/97 6:41p Matt |
| 416 | * Added code for group paste |
| 417 | * |
| 418 | * 46 8/29/97 5:45p Matt |
| 419 | * Made selection & cut/copy/past funcs work with rooms |
| 420 | * |
| 421 | * 45 8/29/97 2:49p Samir |
| 422 | * Nuked SegmentKeypad. |
| 423 | * |
| 424 | * 44 8/27/97 10:55a Samir |
| 425 | * Fixed bug when keypad is initally closed, and you toggle it, and the |
| 426 | * control bar looked fine, just no tab control. |
| 427 | * |
| 428 | * 43 8/21/97 7:48p Matt |
| 429 | * Added code to move player object (like old move player to curseg) |
| 430 | * |
| 431 | * 42 8/20/97 5:28p Samir |
| 432 | * Took out Desktop_surf init and put it into init.cpp |
| 433 | * |
| 434 | * 41 8/15/97 6:32p Samir |
| 435 | * Added ScriptWizard! |
| 436 | * |
| 437 | * 40 8/13/97 5:39p Samir |
| 438 | * Use CompileScript to compile a script now, and we compile default |
| 439 | * script at startup of editor. |
| 440 | * |
| 441 | * 39 8/12/97 5:47p Matt |
| 442 | * Added menu items to edit debris, clutter, & buildings |
| 443 | * Increased number of items in objpage dropdown box |
| 444 | * |
| 445 | * 38 8/12/97 3:22p Samir |
| 446 | * osi_Compile and D3XReallocProgram added parameters. |
| 447 | * |
| 448 | * 37 8/11/97 1:53p Matt |
| 449 | * Ripped out robot & powerup pages, and added generic page |
| 450 | * |
| 451 | * 36 8/08/97 3:30p Matt |
| 452 | * Fixed stupid bug |
| 453 | * |
| 454 | * 35 8/08/97 3:22p Jeff |
| 455 | * Added automatic OGF conversion when extracting HSM |
| 456 | * |
| 457 | * 34 8/08/97 3:09p Matt |
| 458 | * Added testing calls to new generic page dialog |
| 459 | * |
| 460 | * 33 8/08/97 2:51p Jeff |
| 461 | * added code to check if default script is locked |
| 462 | * |
| 463 | * 32 8/06/97 10:36a Samir |
| 464 | * Fixed osi_Compile calls. |
| 465 | * |
| 466 | * 31 8/04/97 4:12p Samir |
| 467 | * Call to osi_Compile uses new prototype. |
| 468 | * |
| 469 | * 30 8/04/97 12:42p Matt |
| 470 | * Made move viewer function work with room engine |
| 471 | * |
| 472 | * 29 8/01/97 2:36p Jeff |
| 473 | * |
| 474 | * 28 7/29/97 3:48p Jeff |
| 475 | * |
| 476 | * 27 7/29/97 2:19p Jason |
| 477 | * added filepage editor to mainframe |
| 478 | * |
| 479 | * 26 7/29/97 2:11p Jeff |
| 480 | * Added compile on exit for Osiris |
| 481 | * |
| 482 | * 25 7/29/97 12:17p Matt |
| 483 | * Made room:face display on status bar show different info for room, |
| 484 | * mine, and terrain views. |
| 485 | * |
| 486 | * 24 7/28/97 5:33p Matt |
| 487 | * Added function to change the view mode |
| 488 | * |
| 489 | * 23 7/28/97 10:51a Jeff |
| 490 | * Changed cha *DefaultExternalEditor to what it should be called, char |
| 491 | * Default_external_editor[256] |
| 492 | * |
| 493 | * 22 7/26/97 8:48p Jeff |
| 494 | * fixed up calls to script editor. Added DefaultExternalEditor global |
| 495 | * variable |
| 496 | * |
| 497 | * 21 7/25/97 6:16p Samir |
| 498 | * Fixed the tile-cascade switching/default madness. |
| 499 | * |
| 500 | * 20 7/24/97 3:00p Matt |
| 501 | * Save/load game & editor settings from/to the registry, and added code |
| 502 | * to display current keypad. |
| 503 | * |
| 504 | * 19 7/22/97 7:08p Matt |
| 505 | * Cleaned up D3EditState, moving some vars in and some out, and renaming |
| 506 | * and changing a few others |
| 507 | * |
| 508 | * 18 7/21/97 5:55p Jeff |
| 509 | * |
| 510 | * 17 7/21/97 4:05p Jeff |
| 511 | * fixed default path for external editor |
| 512 | * |
| 513 | * 16 7/21/97 3:21p Jeff |
| 514 | * |
| 515 | * 15 7/19/97 8:09p Jeff |
| 516 | * |
| 517 | * 14 7/18/97 5:36p Jason |
| 518 | * save changed paletted rooms on exit |
| 519 | * |
| 520 | * 13 7/18/97 5:17p Jeff |
| 521 | * |
| 522 | * 93 6/30/97 1:30p Jason |
| 523 | * added netherspace stuff |
| 524 | * |
| 525 | * 92 6/27/97 7:21p Matt |
| 526 | * Added function to move player 0 to current segment |
| 527 | * |
| 528 | * 91 6/27/97 3:10p Jason |
| 529 | * |
| 530 | * 90 6/27/97 12:19p Samir |
| 531 | * Added room keypad dialog |
| 532 | * |
| 533 | * 89 6/25/97 5:29p Jason |
| 534 | * added/modified code to display a room |
| 535 | * |
| 536 | * 88 6/18/97 11:56a Jason |
| 537 | * added some more terrain functions for Mark |
| 538 | * |
| 539 | * |
| 540 | * 87 6/13/97 2:18p Matt |
| 541 | * Added functions to change wireframe view target |
| 542 | * |
| 543 | * 86 6/11/97 1:07p Samir |
| 544 | * The removal of gameos and replaced with oeApplication, oeDatabase |
| 545 | * |
| 546 | * 85 6/10/97 5:08p Jason |
| 547 | * added reorderpages menu item |
| 548 | * |
| 549 | * 84 6/06/97 4:33p Jason |
| 550 | * added cool stuff for megacells |
| 551 | * |
| 552 | * 83 6/05/97 3:37p Samir |
| 553 | * Added megacell keypad. |
| 554 | * |
| 555 | * 82 6/05/97 2:52p Jason |
| 556 | * added megacell functions |
| 557 | * |
| 558 | * 81 6/03/97 4:55p Mark |
| 559 | * |
| 560 | * 81 6/03/97 4:39p Jeff |
| 561 | * Added code for Context sensitive help |
| 562 | * |
| 563 | * 80 6/02/97 2:31p Samir |
| 564 | * Music test code! |
| 565 | * |
| 566 | * 79 5/19/97 5:10p Jason |
| 567 | * changes for our new abstracted renderer code |
| 568 | * |
| 569 | * 78 5/13/97 7:27p Matt |
| 570 | * Added code to set & clear fuelcen flag in segments |
| 571 | * |
| 572 | * 77 5/13/97 12:04p Matt |
| 573 | * Added code to add a floating segment |
| 574 | * |
| 575 | * 76 5/05/97 3:37p Matt |
| 576 | * |
| 577 | * 75 4/30/97 5:52p Jason |
| 578 | * added ability to switch between 8bit/16bit modes |
| 579 | * |
| 580 | * 74 4/17/97 4:03p Samir |
| 581 | * Apply Tmap 1 and Tmap2 implemented, but no Tmap2 rendering is occurring |
| 582 | * yet. |
| 583 | * |
| 584 | * 73 4/17/97 11:08a Samir |
| 585 | * BuildBridge Implemented |
| 586 | * |
| 587 | * 72 4/16/97 6:11p Matt |
| 588 | * Added code to divide a segment into two |
| 589 | * |
| 590 | * 71 4/15/97 11:29a Samir |
| 591 | * Iimplemented menu item object placement and deletion. |
| 592 | * |
| 593 | * 70 4/11/97 4:59p Samir |
| 594 | * Grab texture menu item works. |
| 595 | * |
| 596 | * 69 4/08/97 10:42a Jason |
| 597 | * implemented path following interface |
| 598 | * |
| 599 | * 68 4/04/97 3:15p Samir |
| 600 | * Added paths keypad, removed player keypad since it's joined with object |
| 601 | * keypad. |
| 602 | * |
| 603 | * 67 4/03/97 1:20p Jason |
| 604 | * changes to get the sound page system playing |
| 605 | * |
| 606 | * 66 4/02/97 10:56a Matt |
| 607 | * Changed "Other" menu to "Object", and removed obsolete set-player-start |
| 608 | * option |
| 609 | * |
| 610 | * 65 4/01/97 11:00p Matt |
| 611 | * Changed editor to keep a viewer object (type camera) seperate from the |
| 612 | * player object. This camera, and not the player, is now moved by |
| 613 | * slewing, the C key, etc. When going into the game, the viewer position |
| 614 | * & orientation are copied to the player. When going back to the editor, |
| 615 | * the player position is copied to the viewer, and the player object is |
| 616 | * reset to its start location. |
| 617 | * |
| 618 | * 64 3/31/97 5:58p Matt |
| 619 | * Revamped mine update flags |
| 620 | * |
| 621 | * 63 3/28/97 12:20p Jason |
| 622 | * added terrain dialog stuff, plus bitmap memory indicator |
| 623 | * |
| 624 | * 62 3/26/97 6:46p Samir |
| 625 | * Fixed order of tabs in dialog box. |
| 626 | * |
| 627 | * 61 3/26/97 5:48p Samir |
| 628 | * Keep splash screen up a bit longer. |
| 629 | * |
| 630 | * 60 3/26/97 4:37p Samir |
| 631 | * Splash screen up and running. |
| 632 | * |
| 633 | * 59 3/24/97 6:48p Samir |
| 634 | * Allow clean delete of door segments. AddDefaultSegment |
| 635 | * |
| 636 | * 58 3/21/97 12:30p Samir |
| 637 | * Added more keypad functionality and NET pane. |
| 638 | * |
| 639 | * 57 3/20/97 5:01p Matt |
| 640 | * Removed obsolete select-from-box code |
| 641 | * |
| 642 | * 56 3/20/97 11:55a Jason |
| 643 | * changes for terrain editing/drawing |
| 644 | * |
| 645 | * 55 3/17/97 2:26p Matt |
| 646 | * Added function to set player view from curseg/curside |
| 647 | * |
| 648 | * 54 3/17/97 1:32p Matt |
| 649 | * Took out redundant and unneeded handlers for View menu items. |
| 650 | * |
| 651 | * 53 3/17/97 12:25a Matt |
| 652 | * Added call to FormJoint(), and changed a bunch of code to use the |
| 653 | * SEGNUM() macro. |
| 654 | * |
| 655 | * 52 3/14/97 6:53p Samir |
| 656 | * Took out unused functions and added delete segment function. |
| 657 | * |
| 658 | * 51 3/14/97 12:50p Samir |
| 659 | * Added marked segment pane |
| 660 | * |
| 661 | * 50 3/13/97 7:02p Samir |
| 662 | * Added current segment:side pane. |
| 663 | * |
| 664 | * 49 3/13/97 12:09p Matt |
| 665 | * Switch to data\levels directory, so the Open file dialog will default |
| 666 | * to that directory. |
| 667 | * |
| 668 | * 48 3/12/97 3:25p Matt |
| 669 | * Added funcs for cut, copy, paste, & delete, and to save and load |
| 670 | * groups. |
| 671 | * |
| 672 | * 47 3/10/97 11:13a Samir |
| 673 | * Changes made to reflect deletion of OSDebug class from system |
| 674 | * |
| 675 | * 46 3/05/97 7:21p Samir |
| 676 | * Added special initialization code for editor and use osD3Winxxxx |
| 677 | * classes for os objects. |
| 678 | * |
| 679 | * 45 3/05/97 11:49a Samir |
| 680 | * Added doorway and terrain keypad tabs. |
| 681 | * |
| 682 | * 44 3/04/97 11:37a Samir |
| 683 | * Fixed goofup in tab ordering for trigger keypad. |
| 684 | * |
| 685 | * 43 3/03/97 5:23p Samir |
| 686 | * Create osDatabase and osDebug obejcts. |
| 687 | * |
| 688 | * 42 3/02/97 4:21p Matt |
| 689 | * Added code to select connected segments |
| 690 | * |
| 691 | * 41 2/28/97 6:40p Matt |
| 692 | * Call code to call box selection code |
| 693 | * |
| 694 | * 40 2/28/97 4:00p Matt |
| 695 | * Added code to handle the list of selected segments |
| 696 | * |
| 697 | * 39 2/28/97 2:37p Mark |
| 698 | * |
| 699 | * 38 2/28/97 11:09a Samir |
| 700 | * Fixed Play in 640x480 menu item. |
| 701 | * |
| 702 | * 37 2/28/97 11:03a Samir |
| 703 | * Changes to reflect newer gameos interface. |
| 704 | * |
| 705 | * 36 2/27/97 5:29p Mark |
| 706 | * |
| 707 | * 35 2/26/97 3:35p Mark |
| 708 | * |
| 709 | * 34 2/20/97 6:05p Samir |
| 710 | * Allow for clean activation and deactivation of surfaces in editor when |
| 711 | * going into fullscreen mode. |
| 712 | * |
| 713 | * 33 2/20/97 5:10p Samir |
| 714 | * Added Tmap1 and Tmap2 apply accels. Tmap1 works by doing a CTRL-1. |
| 715 | * |
| 716 | * 32 2/20/97 9:57a Matt |
| 717 | * Added Add Segment |
| 718 | * |
| 719 | * 31 2/19/97 5:39p Matt |
| 720 | * Made EditorStatus() take printf-type args, as the D1/D2 function did. |
| 721 | * |
| 722 | * 30 2/19/97 2:15p Samir |
| 723 | * Added keypad info. |
| 724 | * |
| 725 | * 29 2/18/97 7:04p Samir |
| 726 | * Added print status bar message functions |
| 727 | * |
| 728 | * 28 2/12/97 4:07p Samir |
| 729 | * Prompts for hogfile name when staring hog editor. |
| 730 | * |
| 731 | * 27 2/12/97 2:33p Samir |
| 732 | * Added hog dialog. |
| 733 | * |
| 734 | * 26 2/10/97 1:59p Jason |
| 735 | * Better import anim/bitmap functionality |
| 736 | * |
| 737 | * 25 2/06/97 2:46p Jason |
| 738 | * added import bitmap function |
| 739 | * |
| 740 | * 24 2/05/97 12:16p Samir |
| 741 | * Added menu item for preferences. |
| 742 | * |
| 743 | * 23 2/04/97 5:27p Samir |
| 744 | * Instead of GAME_MODE go to EDITOR_GAME_MODE when playing the level. |
| 745 | * |
| 746 | * 22 2/04/97 5:18p Samir |
| 747 | * Added Leaving editor... option in File Menu |
| 748 | * |
| 749 | * 21 1/30/97 6:43p Samir |
| 750 | * stupid forgetting an argument |
| 751 | * |
| 752 | * 20 1/30/97 6:24p Samir |
| 753 | * Reflect changes in ddgr system and game->editor->game stuff |
| 754 | * |
| 755 | * 19 1/23/97 4:35p Samir |
| 756 | * Added floating keypad toggle and support |
| 757 | * |
| 758 | * 18 1/21/97 12:45p Samir |
| 759 | * Toggle to get rid of keypad |
| 760 | * |
| 761 | * $NoKeywords: $ |
| 762 | */ |
| 763 | |
| 764 | #include <cstdarg> |
| 765 | #include <cstdio> |
| 766 | #include <filesystem> |
| 767 | |
| 768 | #include "stdafx.h" |
| 769 | #include "editor.h" |
| 770 | |
| 771 | // USER INTERFACE HEADERS |
| 772 | #include "MainFrm.h" |
| 773 | #include "editorDoc.h" |
| 774 | #include "editorView.h" |
| 775 | #include "TextureDialog.h" |
| 776 | #include "ObjectDialog.h" |
| 777 | #include "LightingDialog.h" |
| 778 | #include "MegacellKeypad.h" |
| 779 | #include "TriggerDialog.h" |
| 780 | #include "DoorwayDialog.h" |
| 781 | #include "TerrainDialog.h" |
| 782 | #include "WorldTexturesDialog.h" |
| 783 | #include "WorldWeaponsDialog.h" |
| 784 | #include "WorldObjectsDoorDialog.h" |
| 785 | #include "WorldObjectsLightDialog.h" |
| 786 | #include "WorldObjectsPlayerDialog.h" |
| 787 | #include "RoomKeypadDialog.h" |
| 788 | #include "MegacellDialog.h" |
| 789 | #include "WorldSoundsDialog.h" |
| 790 | #include "PathPadDialog.h" |
| 791 | #include "GrFontDialog.h" |
| 792 | #include "FloatingKeypadDialog.h" |
| 793 | #include "PreferencesDialog.h" |
| 794 | #include "HogDialog.h" |
| 795 | #include "D3Splash.h" |
| 796 | #include "filepagedialog.h" |
| 797 | #include "LevelDialog.h" |
| 798 | #include "ObjectListDialog.h" |
| 799 | #include "TelCom.h" |
| 800 | #include "Slew.h" |
| 801 | #include "AmbientSoundPattern.h" |
| 802 | #include "levelkeypad.h" |
| 803 | #include "matcenkeypad.h" |
| 804 | #include "scriptlevelinterface.h" |
| 805 | #include "ScriptMassCompile.h" |
| 806 | #include "EditLineDialog.h" |
| 807 | |
| 808 | // D3 EDITOR HEADERS |
| 809 | #include "pserror.h" |
| 810 | #include "application.h" |
| 811 | #include "AppDatabase.h" |
| 812 | #include "program.h" |
| 813 | #include "gr.h" |
| 814 | #include "init.h" |
| 815 | #include "mono.h" |
| 816 | #include "ds3dlib.h" |
| 817 | #include "ddio.h" |
| 818 | #include "descent.h" |
| 819 | #include "bitmap.h" |
| 820 | #include "gametexture.h" |
| 821 | #include "manage.h" |
| 822 | #include "vclip.h" |
| 823 | #include "erooms.h" |
| 824 | #include "HTexture.h" |
| 825 | #include "HView.h" |
| 826 | #include "selectedroom.h" |
| 827 | #include "drawworld.h" |
| 828 | #include "Group.h" |
| 829 | #include "moveworld.h" |
| 830 | #include "worldobjectsgenericdialog.h" |
| 831 | #include "objinfo.h" |
| 832 | #include "HFile.h" |
| 833 | #include "hroom.h" |
| 834 | #include "read3ds.h" |
| 835 | #include "terrain.h" |
| 836 | #include "HObject.h" |
| 837 | #include "hotspotmap.h" |
| 838 | #include "TableFileEdit.h" |
| 839 | #include "BriefEdit.h" |
| 840 | #include "TableFileFilter.h" |
| 841 | #include "DallasMainDlg.h" |
| 842 | #include "ViewerPropDlg.h" |
| 843 | #include "mem.h" |
| 844 | #include "findintersection.h" |
| 845 | #include "renderer.h" |
| 846 | |
| 847 | #ifdef _DEBUG |
| 848 | #define new DEBUG_NEW |
| 849 | #undef THIS_FILE |
| 850 | static char THIS_FILE[] = __FILE__; |
| 851 | #endif |
| 852 | |
| 853 | ///////////////////////////////////////////////////////////////////////////// |
| 854 | // CMainFrame |
| 855 | |
| 856 | IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) |
| 857 | |
| 858 | BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) |
| 859 | //{{AFX_MSG_MAP(CMainFrame) |
| 860 | ON_WM_CREATE() |
| 861 | ON_WM_DESTROY() |
| 862 | ON_COMMAND(ID_TOOLS_WORLD_TEXTURES, OnToolsWorldTextures) |
| 863 | ON_WM_SIZE() |
| 864 | ON_COMMAND(ID_TOOLS_WORLD_WEAPONS, OnToolsWorldWeapons) |
| 865 | ON_COMMAND(ID_TOOLS_WORLD_OBJECTS_DOOR, OnToolsWorldObjectsDoor) |
| 866 | ON_COMMAND(ID_TOOLS_WORLD_OBJECTS_LIGHTS, OnToolsWorldObjectsLights) |
| 867 | ON_COMMAND(ID_TOOLS_WORLD_OBJECTS_PLAYER, OnToolsWorldObjectsPlayer) |
| 868 | ON_COMMAND(ID_TOOLS_WORLD_OBJECTS_POWERUPS, OnToolsWorldObjectsPowerups) |
| 869 | ON_COMMAND(ID_TOOLS_WORLD_OBJECTS_ROBOTS, OnToolsWorldObjectsRobots) |
| 870 | ON_COMMAND(ID_SUBEDITORS_FONT, OnSubeditorsFont) |
| 871 | |
| 872 | ON_COMMAND(ID_FILE_PLAY640X480, OnFilePlayin640x480) |
| 873 | ON_UPDATE_COMMAND_UI(ID_VIEW_KEYPAD_TOGGLE, OnUpdateViewKeypadToggle) |
| 874 | ON_COMMAND(ID_VIEW_KEYPAD_TOGGLE, OnViewKeypadToggle) |
| 875 | ON_COMMAND(ID_FILE_LEAVE_EDITOR, OnFileLeaveEditor) |
| 876 | ON_COMMAND(ID_FILE_PREFERENCES, OnFilePreferences) |
| 877 | ON_COMMAND(IDM_IMPORT_BITMAP, OnImportBitmap) |
| 878 | ON_COMMAND(ID_SUBEDITORS_HOGMAKER, OnSubeditorsHogmaker) |
| 879 | ON_COMMAND(ID_NUMPAD0, OnNumpad0) |
| 880 | ON_COMMAND(ID_NUMPAD1, OnNumpad1) |
| 881 | ON_COMMAND(ID_NUMPAD2, OnNumpad2) |
| 882 | ON_COMMAND(ID_NUMPAD3, OnNumpad3) |
| 883 | ON_COMMAND(ID_NUMPAD4, OnNumpad4) |
| 884 | ON_COMMAND(ID_NUMPAD5, OnNumpad5) |
| 885 | ON_COMMAND(ID_NUMPAD6, OnNumpad6) |
| 886 | ON_COMMAND(ID_NUMPAD7, OnNumpad7) |
| 887 | ON_COMMAND(ID_NUMPAD8, OnNumpad8) |
| 888 | ON_COMMAND(ID_NUMPAD9, OnNumpad9) |
| 889 | ON_COMMAND(ID_NUMPADDEL, OnNumpaddel) |
| 890 | ON_COMMAND(ID_NUMPADMINUS, OnNumpadminus) |
| 891 | ON_COMMAND(ID_NUMPADADD, OnNumpadadd) |
| 892 | ON_COMMAND(ID_VIEW_CENTERONMINE, OnViewCenterOnMine) |
| 893 | ON_COMMAND(ID_VIEW_MOVECAMERATOSELECTEDROOM, OnViewMoveCameraToSelectedRoom) |
| 894 | ON_COMMAND(ID_VIEW_CENTERONCUBE, OnViewCenterOnCube) |
| 895 | ON_COMMAND(ID_VIEW_CENTERONOBJECT, OnViewCenterOnObject) |
| 896 | ON_COMMAND(ID_GROUP_CREATEGROUP, OnGroupCreateGroup) |
| 897 | ON_COMMAND(ID_GROUP_LOADGROUP, OnGroupLoadGroup) |
| 898 | ON_COMMAND(ID_GROUP_MIRRORGROUP, OnGroupMirrorGroup) |
| 899 | ON_COMMAND(ID_GROUP_SAVEGROUP, OnGroupSaveGroup) |
| 900 | ON_COMMAND(ID_EDIT_ADDSELECT, OnEditAddSelect) |
| 901 | ON_COMMAND(ID_EDIT_CLEARSELECTED, OnEditClearSelected) |
| 902 | ON_COMMAND(ID_EDIT_REMOVESELECT, OnEditRemoveSelect) |
| 903 | ON_COMMAND(ID_EDIT_SELECTATTACHED, OnEditSelectAttached) |
| 904 | ON_COMMAND(ID_EDIT_SAVESCRAP, OnEditSaveScrap) |
| 905 | ON_COMMAND(ID_EDIT_LOADSCRAP, OnEditLoadScrap) |
| 906 | ON_COMMAND(ID_EDIT_COPY, OnEditCopy) |
| 907 | ON_COMMAND(ID_EDIT_CUT, OnEditCut) |
| 908 | ON_COMMAND(ID_EDIT_DELETE, OnEditDelete) |
| 909 | ON_UPDATE_COMMAND_UI(ID_INDICATOR_CURSEG, OnSegSidePane) |
| 910 | ON_UPDATE_COMMAND_UI(ID_INDICATOR_NET, OnNetPane) |
| 911 | ON_UPDATE_COMMAND_UI(ID_INDICATOR_BMMEM, OnBMMemPane) |
| 912 | ON_UPDATE_COMMAND_UI(ID_INDICATOR_ENGINE, OnEnginePane) |
| 913 | ON_UPDATE_COMMAND_UI(ID_INDICATOR_VIEWER, OnViewerPane) |
| 914 | ON_COMMAND(ID_NUMPADDIV, OnNumpadDiv) |
| 915 | ON_COMMAND(ID_NUMPADENTER, OnNumpadEnter) |
| 916 | ON_COMMAND(ID_NUMPADLOCK, OnNumpadLock) |
| 917 | ON_COMMAND(ID_NUMPADMUL, OnNumpadMul) |
| 918 | ON_COMMAND(ID_OBJECT_DELETEOBJECT, OnObjectDeleteObject) |
| 919 | ON_COMMAND(ID_OBJECT_PLACEOBJECT, OnObjectPlaceObject) |
| 920 | ON_COMMAND(ID_TOOLS_WORLD_OBJECTS_SOUND, OnToolsWorldObjectsSound) |
| 921 | ON_COMMAND(ID_TEST_TEST1, OnTestTest1) |
| 922 | ON_COMMAND(ID_TEST_TEST2, OnTestTest2) |
| 923 | ON_COMMAND(ID_TEST_TEST3, OnTestTest3) |
| 924 | ON_WM_HELPINFO() |
| 925 | ON_COMMAND(ID_EDITORS_MEGACELLS, OnEditorsMegacells) |
| 926 | ON_COMMAND(IDD_REORDER_PAGES, OnReorderPages) |
| 927 | ON_COMMAND(ID_FILE_IMPORT_ROOM, OnFileImportRoom) |
| 928 | ON_COMMAND(ID_OBJECT_MOVEPLAYER, OnObjectMovePlayer) |
| 929 | ON_COMMAND(ID_ROOM_VIEW, OnRoomView) |
| 930 | ON_COMMAND(ID_TERRAIN_VIEW, OnTerrainView) |
| 931 | ON_COMMAND(ID_MINE_VIEW, OnMineView) |
| 932 | ON_UPDATE_COMMAND_UI(ID_MINE_VIEW, OnUpdateMineView) |
| 933 | ON_UPDATE_COMMAND_UI(ID_ROOM_VIEW, OnUpdateRoomView) |
| 934 | ON_UPDATE_COMMAND_UI(ID_TERRAIN_VIEW, OnUpdateTerrainView) |
| 935 | ON_COMMAND(ID_VIEW_NEWVIEWER, OnViewNewviewer) |
| 936 | ON_COMMAND(ID_VIEWER_NEXT, OnViewNextviewer) |
| 937 | ON_COMMAND(ID_VIEW_DELETEVIEWER, OnViewDeleteviewer) |
| 938 | ON_COMMAND(ID_D3HELP, OnD3help) |
| 939 | ON_COMMAND(ID_HOTSPOT_TGA, OnHotspotTga) |
| 940 | ON_COMMAND(ID_EDITORS_FILES, OnEditorsFiles) |
| 941 | ON_COMMAND(ID_TOOLS_WORLD_OBJECTS_CLUTTER, OnToolsWorldObjectsClutter) |
| 942 | ON_COMMAND(ID_TOOLS_WORLD_OBJECTS_BUILDINGS, OnToolsWorldObjectsBuildings) |
| 943 | ON_COMMAND(ID_EDIT_PLACE, OnEditPlace) |
| 944 | ON_COMMAND(ID_EDIT_ATTACH, OnEditAttach) |
| 945 | ON_UPDATE_COMMAND_UI(ID_EDIT_ATTACH, OnUpdateEditAttach) |
| 946 | ON_UPDATE_COMMAND_UI(ID_EDIT_SAVESCRAP, OnUpdateEditSaveScrap) |
| 947 | ON_COMMAND(ID_FILE_LEVELPROPS, OnFileLevelProps) |
| 948 | ON_COMMAND(ID_OBJBUTTON, OnObjbutton) |
| 949 | ON_UPDATE_COMMAND_UI(ID_OBJBUTTON, OnUpdateObjbutton) |
| 950 | ON_WM_NCDESTROY() |
| 951 | ON_COMMAND(ID_OBJECT_SETCAMERAFROMVIEWER, OnObjectSetCameraFromViewer) |
| 952 | ON_COMMAND(ID_OBJECT_PLACECAMERAATVIEWER, OnObjectPlaceCameraAtViewer) |
| 953 | ON_COMMAND(ID_OBJECT_SETVIEWERFROMCAMERA, OnObjectSetViewerFromCamera) |
| 954 | ON_WM_KEYDOWN() |
| 955 | ON_COMMAND(ID_FILE_LEVEL_INFO, OnFileLevelInfo) |
| 956 | ON_COMMAND(ID_FILE_STATS, OnFileStats) |
| 957 | ON_COMMAND(ID_FILE_VERIFY_LEVEL, OnFileVerifyLevel) |
| 958 | ON_COMMAND(ID_OBJECT_PLACECAMERAATCURRENTFACE, OnObjectPlaceCameraAtCurrentFace) |
| 959 | ON_COMMAND(ID_SUBEDITORS_TABLEFILEEDIT, OnSubEditorsTableFileEdit) |
| 960 | ON_COMMAND(ID_EDITORS_AMBIENTSOUNDS, OnEditorsAmbientSounds) |
| 961 | ON_COMMAND(ID_BRIEFING_EDITOR, OnBriefingEditor) |
| 962 | ON_COMMAND(ID_SCRIPT_LEVEL_INTERFACE, OnScriptLevelInterface) |
| 963 | ON_COMMAND(ID_FILE_FIXCRACKS, OnFileFixCracks) |
| 964 | ON_COMMAND(ID_VIEW_RESETVIEWRADIUS, OnViewResetViewRadius) |
| 965 | ON_COMMAND(ID_SUBEDITORS_TABLEFILEFILTER, OnSubeditorsTablefilefilter) |
| 966 | ON_COMMAND(ID_VIEW_SHOWOBJECTSINWIREFRAMEVIEW, OnViewShowObjectsInWireframeView) |
| 967 | ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWOBJECTSINWIREFRAMEVIEW, OnUpdateViewShowObjectsInWireframeView) |
| 968 | ON_COMMAND(ID_EDITORS_DALLAS, OnEditorsDallas) |
| 969 | ON_UPDATE_COMMAND_UI(ID_OSIRISCOMPILE, OnUpdateOsiriscompile) |
| 970 | ON_COMMAND(ID_OSIRISCOMPILE, OnOsiriscompile) |
| 971 | ON_COMMAND(ID_VIEW_MOVECAMERATOCURRENTOBJECT, OnViewMoveCameraToCurrentObject) |
| 972 | ON_COMMAND(ID_OBJECT_SELECTBYNUMBER, OnObjectSelectByNumber) |
| 973 | ON_COMMAND(IDD_SHOW_ALL_CHECKED_OUT, OnShowAllCheckedOut) |
| 974 | ON_COMMAND(ID_VIEW_SHOWVIEWERFORWARDVECTOR, OnViewShowViewerForwardVector) |
| 975 | ON_COMMAND(ID_OBJECT_PLACESOUNDSOURCEATVIEWER, OnObjectPlaceSoundSourceAtViewer) |
| 976 | ON_COMMAND(IDD_ORPHANHUNTER, OnOrphanhunter) |
| 977 | ON_COMMAND(ID_OBJECT_PLACEWAYPOINTATVIEWER, OnObjectPlaceWaypointAtViewer) |
| 978 | ON_COMMAND(ID_FILE_SAVEGOALTEXT, OnFileSaveGoalText) |
| 979 | ON_COMMAND(ID_VIEW_VIEWPROP, OnViewViewprop) |
| 980 | ON_UPDATE_COMMAND_UI(ID_VIEW_VIEWPROP, OnUpdateViewViewprop) |
| 981 | ON_COMMAND(ID_VIEW_MOVECAMERATOSELECTEDFACE, OnViewMoveCameraToSelectedFace) |
| 982 | ON_COMMAND(ID_EDIT_PLACE_TERRAIN, OnEditPlaceTerrain) |
| 983 | ON_COMMAND(ID_CONTEXT_HELP, OnContextHelp) |
| 984 | ON_COMMAND(ID_VIEW_NEXTVIEWER, OnViewNextviewer) |
| 985 | ON_COMMAND(ID_ACCEL_COPY_LIGHT_MULTIPLE, OnAccelCopyLightMultiple) |
| 986 | ON_COMMAND(ID_ACCEL_SLIDEDOWN, OnAccelSlidedown) |
| 987 | ON_COMMAND(ID_ACCEL_SLIDELEFT, OnAccelSlideleft) |
| 988 | ON_COMMAND(ID_ACCEL_SLIDERIGHT, OnAccelSlideright) |
| 989 | ON_COMMAND(ID_ACCEL_SLIDEUP, OnAccelSlideup) |
| 990 | ON_COMMAND(ID_ACCEL_NEXTVERTEX, OnAccelNextVertex) |
| 991 | //}}AFX_MSG_MAP |
| 992 | ON_COMMAND(ID_HELP_FINDER, CFrameWnd::OnHelpFinder) |
| 993 | ON_COMMAND(ID_HELP, CFrameWnd::OnHelp) |
| 994 | ON_COMMAND(ID_CONTEXT_HELP, OnContextHelp) |
| 995 | ON_COMMAND(ID_DEFAULT_HELP, CFrameWnd::OnHelpFinder) |
| 996 | END_MESSAGE_MAP() |
| 997 | |
| 998 | static UINT indicators[] = { |
| 999 | ID_SEPARATOR, // status line indicator |
| 1000 | ID_INDICATOR_BMMEM, // How much memory our bitmaps used |
| 1001 | ID_INDICATOR_NET, // network indicator |
| 1002 | ID_INDICATOR_CURSEG, // our current seg.side indicator |
| 1003 | ID_INDICATOR_MARKSEG, // our marked seg.side indicator |
| 1004 | ID_INDICATOR_NUM, |
| 1005 | ID_INDICATOR_ENGINE, // which engine is running (mine or room) |
| 1006 | ID_INDICATOR_VIEWER // which viewer is current |
| 1007 | }; |
| 1008 | |
| 1009 | static CMainFrame *MFC_Main_frame = NULL; |
| 1010 | |
| 1011 | ///////////////////////////////////////////////////////////////////////////// |
| 1012 | // CMainFrame construction/destruction |
| 1013 | |
| 1014 | CMainFrame::CMainFrame() { |
| 1015 | // TODO: add member initialization code here |
| 1016 | m_KeypadTabDialog = NULL; |
| 1017 | |
| 1018 | m_LightingDialog = NULL; |
| 1019 | m_TextureDialog = NULL; |
| 1020 | m_ObjectDialog = NULL; |
| 1021 | m_TriggerDialog = NULL; |
| 1022 | m_DoorwayDialog = NULL; |
| 1023 | m_PathPadDialog = NULL; |
| 1024 | m_TerrainDialog = NULL; |
| 1025 | m_MegacellKeypad = NULL; |
| 1026 | m_LevelDialog = NULL; |
| 1027 | m_MatcenDialog = NULL; |
| 1028 | |
| 1029 | m_ObjModeless = NULL; |
| 1030 | m_KeypadTabCtrl = NULL; |
| 1031 | m_RoomDialog = NULL; |
| 1032 | m_FloatingKeypadDialog = NULL; |
| 1033 | m_D3Splash = NULL; |
| 1034 | } |
| 1035 | |
| 1036 | CMainFrame::~CMainFrame() {} |
| 1037 | |
| 1038 | int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { |
| 1039 | if (CFrameWnd::OnCreate(lpCreateStruct) == -1) |
| 1040 | return -1; |
| 1041 | |
| 1042 | // Initializes the ddgr system and prepares for gr. |
| 1043 | if (!m_wndToolBar.Create(this) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { |
| 1044 | TRACE0("Failed to create toolbar\n"); |
| 1045 | return -1; // fail to create |
| 1046 | } |
| 1047 | |
| 1048 | if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators) / sizeof(UINT))) { |
| 1049 | TRACE0("Failed to create status bar\n"); |
| 1050 | return -1; // fail to create |
| 1051 | } |
| 1052 | |
| 1053 | // Add keypad dialog bar to the right side of the app. |
| 1054 | if (!m_wndKeypadBar.Create(this, IDD_KEYPAD_DLGBAR, CBRS_RIGHT, IDC_DLGBAR_KEYPAD)) { |
| 1055 | TRACE0("Failed to create status bar\n"); |
| 1056 | return -1; // fail to create |
| 1057 | } |
| 1058 | |
| 1059 | // TODO: Remove this if you don't want tool tips or a resizeable toolbar |
| 1060 | m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); |
| 1061 | |
| 1062 | // TODO: Delete these three lines if you don't want the toolbar to |
| 1063 | // be dockable |
| 1064 | |
| 1065 | m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); |
| 1066 | EnableDocking(CBRS_ALIGN_ANY); |
| 1067 | DockControlBar(&m_wndToolBar, AFX_IDW_DOCKBAR_RIGHT); |
| 1068 | |
| 1069 | InitKeypadDialog(); |
| 1070 | DockKeypad(TRUE); // dock if tiled |
| 1071 | |
| 1072 | theApp.main_frame = MFC_Main_frame = this; |
| 1073 | |
| 1074 | return 0; |
| 1075 | } |
| 1076 | |
| 1077 | BOOL CMainFrame::PreCreateWindow(CREATESTRUCT &cs) { |
| 1078 | // TODO: Modify the Window class or styles here by modifying |
| 1079 | // the CREATESTRUCT cs |
| 1080 | |
| 1081 | return CFrameWnd::PreCreateWindow(cs); |
| 1082 | } |
| 1083 | |
| 1084 | ///////////////////////////////////////////////////////////////////////////// |
| 1085 | // CMainFrame diagnostics |
| 1086 | |
| 1087 | #ifdef _DEBUG |
| 1088 | void CMainFrame::AssertValid() const { CFrameWnd::AssertValid(); } |
| 1089 | |
| 1090 | void CMainFrame::Dump(CDumpContext &dc) const { CFrameWnd::Dump(dc); } |
| 1091 | |
| 1092 | #endif //_DEBUG |
| 1093 | |
| 1094 | ///////////////////////////////////////////////////////////////////////////// |
| 1095 | // CMainFrame private supporting functions |
| 1096 | |
| 1097 | void CMainFrame::InitGraphicsSystem() { |
| 1098 | // HERE: We create the DDGR Object for general GR use in the editor |
| 1099 | // HERE: We end the DDGR creating module |
| 1100 | } |
| 1101 | |
| 1102 | // Display current tab dialog |
| 1103 | void CMainFrame::ShowCurrentKeypad() { |
| 1104 | switch (D3EditState.keypad_current) { |
| 1105 | case TAB_TEXTURE_KEYPAD: |
| 1106 | m_KeypadTabDialog = m_TextureDialog; |
| 1107 | break; |
| 1108 | case TAB_OBJECTS_KEYPAD: |
| 1109 | m_KeypadTabDialog = m_ObjectDialog; |
| 1110 | break; |
| 1111 | case TAB_LIGHTING_KEYPAD: |
| 1112 | m_KeypadTabDialog = m_LightingDialog; |
| 1113 | break; |
| 1114 | case TAB_ROOM_KEYPAD: |
| 1115 | m_KeypadTabDialog = m_RoomDialog; |
| 1116 | break; |
| 1117 | case TAB_PATHS_KEYPAD: |
| 1118 | m_KeypadTabDialog = m_PathPadDialog; |
| 1119 | break; |
| 1120 | case TAB_TRIGGER_KEYPAD: |
| 1121 | m_KeypadTabDialog = m_TriggerDialog; |
| 1122 | break; |
| 1123 | case TAB_DOORWAY_KEYPAD: |
| 1124 | m_KeypadTabDialog = m_DoorwayDialog; |
| 1125 | break; |
| 1126 | case TAB_TERRAIN_KEYPAD: |
| 1127 | m_KeypadTabDialog = m_TerrainDialog; |
| 1128 | break; |
| 1129 | case TAB_MEGACELL_KEYPAD: |
| 1130 | m_KeypadTabDialog = m_MegacellKeypad; |
| 1131 | break; |
| 1132 | case TAB_LEVEL_KEYPAD: |
| 1133 | m_KeypadTabDialog = m_LevelDialog; |
| 1134 | break; |
| 1135 | case TAB_MATCEN_KEYPAD: |
| 1136 | m_KeypadTabDialog = m_MatcenDialog; |
| 1137 | break; |
| 1138 | default: |
| 1139 | Int3(); |
| 1140 | } |
| 1141 | |
| 1142 | if (m_KeypadTabDialog) { |
| 1143 | CTabCtrl *tab_ctrl = (CTabCtrl *)m_wndKeypadBar.GetDlgItem(IDC_KEYPADS); |
| 1144 | |
| 1145 | m_KeypadTabDialog->ShowWindow(SW_SHOW); |
| 1146 | tab_ctrl->SetCurSel(D3EditState.keypad_current); |
| 1147 | } |
| 1148 | } |
| 1149 | |
| 1150 | void CMainFrame::InitKeypadDialog() { |
| 1151 | CTabCtrl *tab_ctrl; |
| 1152 | TC_ITEM tc_item; |
| 1153 | |
| 1154 | m_KeypadTabCtrl = tab_ctrl = (CTabCtrl *)m_wndKeypadBar.GetDlgItem(IDC_KEYPADS); |
| 1155 | |
| 1156 | // Add tabs to tabcontrol in the keypad dialog bar. |
| 1157 | tc_item.mask = TCIF_TEXT; |
| 1158 | tc_item.pszText = "Texture"; |
| 1159 | tc_item.cchTextMax = lstrlen(tc_item.pszText) + 1; |
| 1160 | tab_ctrl->InsertItem(TAB_TEXTURE_KEYPAD, &tc_item); |
| 1161 | |
| 1162 | tc_item.mask = TCIF_TEXT; |
| 1163 | tc_item.pszText = "Megacell"; |
| 1164 | tc_item.cchTextMax = lstrlen(tc_item.pszText) + 1; |
| 1165 | tab_ctrl->InsertItem(TAB_MEGACELL_KEYPAD, &tc_item); |
| 1166 | |
| 1167 | tc_item.mask = TCIF_TEXT; |
| 1168 | tc_item.pszText = "Terrain"; |
| 1169 | tc_item.cchTextMax = lstrlen(tc_item.pszText) + 1; |
| 1170 | tab_ctrl->InsertItem(TAB_TERRAIN_KEYPAD, &tc_item); |
| 1171 | |
| 1172 | tc_item.mask = TCIF_TEXT; |
| 1173 | tc_item.pszText = "Object"; |
| 1174 | tc_item.cchTextMax = lstrlen(tc_item.pszText) + 1; |
| 1175 | tab_ctrl->InsertItem(TAB_OBJECTS_KEYPAD, &tc_item); |
| 1176 | |
| 1177 | tc_item.mask = TCIF_TEXT; |
| 1178 | tc_item.pszText = "Room"; |
| 1179 | tc_item.cchTextMax = lstrlen(tc_item.pszText) + 1; |
| 1180 | tab_ctrl->InsertItem(TAB_ROOM_KEYPAD, &tc_item); |
| 1181 | |
| 1182 | tc_item.mask = TCIF_TEXT; |
| 1183 | tc_item.pszText = "Doorway"; |
| 1184 | tc_item.cchTextMax = lstrlen(tc_item.pszText) + 1; |
| 1185 | tab_ctrl->InsertItem(TAB_DOORWAY_KEYPAD, &tc_item); |
| 1186 | |
| 1187 | tc_item.mask = TCIF_TEXT; |
| 1188 | tc_item.pszText = "Trigger"; |
| 1189 | tc_item.cchTextMax = lstrlen(tc_item.pszText) + 1; |
| 1190 | tab_ctrl->InsertItem(TAB_TRIGGER_KEYPAD, &tc_item); |
| 1191 | |
| 1192 | tc_item.mask = TCIF_TEXT; |
| 1193 | tc_item.pszText = "Lighting"; |
| 1194 | tc_item.cchTextMax = lstrlen(tc_item.pszText) + 1; |
| 1195 | tab_ctrl->InsertItem(TAB_LIGHTING_KEYPAD, &tc_item); |
| 1196 | |
| 1197 | tc_item.mask = TCIF_TEXT; |
| 1198 | tc_item.pszText = "Paths"; |
| 1199 | tc_item.cchTextMax = lstrlen(tc_item.pszText) + 1; |
| 1200 | tab_ctrl->InsertItem(TAB_PATHS_KEYPAD, &tc_item); |
| 1201 | |
| 1202 | tc_item.mask = TCIF_TEXT; |
| 1203 | tc_item.pszText = "Level"; |
| 1204 | tc_item.cchTextMax = lstrlen(tc_item.pszText) + 1; |
| 1205 | tab_ctrl->InsertItem(TAB_LEVEL_KEYPAD, &tc_item); |
| 1206 | |
| 1207 | tc_item.mask = TCIF_TEXT; |
| 1208 | tc_item.pszText = "Matcen"; |
| 1209 | tc_item.cchTextMax = lstrlen(tc_item.pszText) + 1; |
| 1210 | tab_ctrl->InsertItem(TAB_MATCEN_KEYPAD, &tc_item); |
| 1211 | |
| 1212 | // Get coordinates of dialog bar tab and |
| 1213 | RECT tab_rect, tab_winrect; |
| 1214 | int tx, ty, tw, th; |
| 1215 | |
| 1216 | tab_ctrl->GetWindowRect(&tab_winrect); |
| 1217 | ::CopyRect(&tab_rect, &tab_winrect); |
| 1218 | tab_ctrl->AdjustRect(FALSE, &tab_rect); |
| 1219 | tx = tab_rect.left - tab_winrect.left; |
| 1220 | ty = tab_rect.top - tab_winrect.top; |
| 1221 | tw = tab_rect.right - tab_rect.left; |
| 1222 | th = tab_rect.bottom - tab_rect.top; |
| 1223 | |
| 1224 | // Create tab dialogs |
| 1225 | // resize them to fit the tab control |
| 1226 | // set scroll bars accordingly |
| 1227 | m_TextureDialog = new CTextureDialog(tab_ctrl); |
| 1228 | m_TextureDialog->Create(); |
| 1229 | m_TextureDialog->SetWindowPos(tab_ctrl, tx, ty, tw, th, SWP_NOZORDER); |
| 1230 | |
| 1231 | m_MegacellKeypad = new CMegacellKeypad(tab_ctrl); |
| 1232 | m_MegacellKeypad->Create(); |
| 1233 | m_MegacellKeypad->SetWindowPos(tab_ctrl, tx, ty, tw, th, SWP_NOZORDER); |
| 1234 | |
| 1235 | m_ObjectDialog = new CObjectDialog(tab_ctrl); |
| 1236 | m_ObjectDialog->Create(); |
| 1237 | m_ObjectDialog->SetWindowPos(tab_ctrl, tx, ty, tw, th, SWP_NOZORDER); |
| 1238 | |
| 1239 | m_LightingDialog = new CLightingDialog(tab_ctrl); |
| 1240 | m_LightingDialog->Create(); |
| 1241 | m_LightingDialog->SetWindowPos(tab_ctrl, tx, ty, tw, th, SWP_NOZORDER); |
| 1242 | |
| 1243 | m_RoomDialog = new CRoomKeypadDialog(tab_ctrl); |
| 1244 | m_RoomDialog->Create(); |
| 1245 | m_RoomDialog->SetWindowPos(tab_ctrl, tx, ty, tw, th, SWP_NOZORDER); |
| 1246 | |
| 1247 | m_TriggerDialog = new CTriggerDialog(tab_ctrl); |
| 1248 | m_TriggerDialog->Create(); |
| 1249 | m_TriggerDialog->SetWindowPos(tab_ctrl, tx, ty, tw, th, SWP_NOZORDER); |
| 1250 | |
| 1251 | m_DoorwayDialog = new CDoorwayDialog(tab_ctrl); |
| 1252 | m_DoorwayDialog->Create(); |
| 1253 | m_DoorwayDialog->SetWindowPos(tab_ctrl, tx, ty, tw, th, SWP_NOZORDER); |
| 1254 | |
| 1255 | m_TerrainDialog = new CTerrainDialog(tab_ctrl); |
| 1256 | m_TerrainDialog->Create(); |
| 1257 | m_TerrainDialog->SetWindowPos(tab_ctrl, tx, ty, tw, th, SWP_NOZORDER); |
| 1258 | |
| 1259 | m_PathPadDialog = new CPathPadDialog(tab_ctrl); |
| 1260 | m_PathPadDialog->Create(); |
| 1261 | m_PathPadDialog->SetWindowPos(tab_ctrl, tx, ty, tw, th, SWP_NOZORDER); |
| 1262 | |
| 1263 | m_LevelDialog = new levelkeypad(tab_ctrl); |
| 1264 | m_LevelDialog->Create(); |
| 1265 | m_LevelDialog->SetWindowPos(tab_ctrl, tx, ty, tw, th, SWP_NOZORDER); |
| 1266 | |
| 1267 | m_MatcenDialog = new matcenkeypad(tab_ctrl); |
| 1268 | m_MatcenDialog->Create(); |
| 1269 | m_MatcenDialog->SetWindowPos(tab_ctrl, tx, ty, tw, th, SWP_NOZORDER); |
| 1270 | } |
| 1271 | |
| 1272 | void CMainFrame::DisplaySplashScreen() { |
| 1273 | m_D3Splash = new CD3Splash(this); |
| 1274 | m_D3Splash->Create(); |
| 1275 | m_D3Splash->ShowWindow(SW_SHOW); |
| 1276 | m_D3Splash->UpdateWindow(); |
| 1277 | } |
| 1278 | |
| 1279 | void CMainFrame::RemoveSplashScreen() { |
| 1280 | if (!m_D3Splash) |
| 1281 | return; |
| 1282 | m_D3Splash->ShowWindow(SW_HIDE); |
| 1283 | m_D3Splash->DestroyWindow(); |
| 1284 | m_D3Splash = NULL; |
| 1285 | } |
| 1286 | |
| 1287 | ///////////////////////////////////////////////////////////////////////////// |
| 1288 | // CMainFrame message handlers |
| 1289 | |
| 1290 | void CMainFrame::ActivateFrame(int nCmdShow) { |
| 1291 | // TODO: Add your specialized code here and/or call the base class |
| 1292 | nCmdShow = SW_MAXIMIZE; // Force initial maximization |
| 1293 | |
| 1294 | RemoveSplashScreen(); // shown when CreateClient |
| 1295 | |
| 1296 | DockKeypad(D3EditState.tile_views); |
| 1297 | |
| 1298 | // display object modeless if need be. |
| 1299 | if (D3EditState.objmodeless_on && !m_ObjModeless) { |
| 1300 | m_ObjModeless = new CObjectListModeless(this); |
| 1301 | m_ObjModeless->Create(); |
| 1302 | m_ObjModeless->SetWindowPos(this, D3EditState.objmodeless_x, D3EditState.objmodeless_y, -1, -1, SWP_NOSIZE); |
| 1303 | m_ObjModeless->ShowWindow(SW_SHOW); |
| 1304 | } |
| 1305 | |
| 1306 | CFrameWnd::ActivateFrame(nCmdShow); |
| 1307 | } |
| 1308 | |
| 1309 | BOOL CMainFrame::OnCommand(WPARAM wParam, LPARAM lParam) { return CFrameWnd::OnCommand(wParam, lParam); } |
| 1310 | |
| 1311 | void CMainFrame::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { |
| 1312 | if (nChar == VK_NUMPAD5) { |
| 1313 | SlewStop(Viewer_object); |
| 1314 | } |
| 1315 | |
| 1316 | CFrameWnd::OnKeyDown(nChar, nRepCnt, nFlags); |
| 1317 | } |
| 1318 | |
| 1319 | BOOL CMainFrame::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT *pResult) { |
| 1320 | // Perform notification requests on the keypad tab dialog bar and other |
| 1321 | // custom control bars. |
| 1322 | NMHDR *nmhdr; |
| 1323 | |
| 1324 | assert(lParam != 0); |
| 1325 | |
| 1326 | nmhdr = (NMHDR *)lParam; |
| 1327 | |
| 1328 | switch (wParam) { |
| 1329 | case IDC_KEYPADS: |
| 1330 | DoKeypadTabNotify(nmhdr); |
| 1331 | break; |
| 1332 | } |
| 1333 | |
| 1334 | return CFrameWnd::OnNotify(wParam, lParam, pResult); |
| 1335 | } |
| 1336 | |
| 1337 | void CMainFrame::DoKeypadTabNotify(NMHDR *nmhdr) { |
| 1338 | CTabCtrl *tab_ctrl; |
| 1339 | |
| 1340 | tab_ctrl = (CTabCtrl *)m_wndKeypadBar.GetDlgItem(IDC_KEYPADS); |
| 1341 | |
| 1342 | switch (nmhdr->code) { |
| 1343 | case TCN_SELCHANGE: |
| 1344 | // Tab control changed. So update the controls currently displayed. |
| 1345 | D3EditState.keypad_current = (int)tab_ctrl->GetCurSel(); |
| 1346 | assert(D3EditState.keypad_current > -1); |
| 1347 | |
| 1348 | switch (D3EditState.keypad_current) { |
| 1349 | case TAB_TEXTURE_KEYPAD: |
| 1350 | if (m_KeypadTabDialog) |
| 1351 | m_KeypadTabDialog->ShowWindow(SW_HIDE); |
| 1352 | m_KeypadTabDialog = m_TextureDialog; |
| 1353 | m_KeypadTabDialog->ShowWindow(SW_SHOW); |
| 1354 | break; |
| 1355 | |
| 1356 | case TAB_OBJECTS_KEYPAD: |
| 1357 | if (m_KeypadTabDialog) |
| 1358 | m_KeypadTabDialog->ShowWindow(SW_HIDE); |
| 1359 | m_KeypadTabDialog = m_ObjectDialog; |
| 1360 | m_KeypadTabDialog->ShowWindow(SW_SHOW); |
| 1361 | break; |
| 1362 | |
| 1363 | case TAB_LIGHTING_KEYPAD: |
| 1364 | if (m_KeypadTabDialog) |
| 1365 | m_KeypadTabDialog->ShowWindow(SW_HIDE); |
| 1366 | m_KeypadTabDialog = m_LightingDialog; |
| 1367 | m_KeypadTabDialog->ShowWindow(SW_SHOW); |
| 1368 | break; |
| 1369 | |
| 1370 | case TAB_ROOM_KEYPAD: |
| 1371 | if (m_KeypadTabDialog) |
| 1372 | m_KeypadTabDialog->ShowWindow(SW_HIDE); |
| 1373 | m_KeypadTabDialog = m_RoomDialog; |
| 1374 | m_KeypadTabDialog->ShowWindow(SW_SHOW); |
| 1375 | break; |
| 1376 | |
| 1377 | case TAB_PATHS_KEYPAD: |
| 1378 | if (m_KeypadTabDialog) |
| 1379 | m_KeypadTabDialog->ShowWindow(SW_HIDE); |
| 1380 | m_KeypadTabDialog = m_PathPadDialog; |
| 1381 | m_KeypadTabDialog->ShowWindow(SW_SHOW); |
| 1382 | break; |
| 1383 | |
| 1384 | case TAB_LEVEL_KEYPAD: |
| 1385 | if (m_KeypadTabDialog) |
| 1386 | m_KeypadTabDialog->ShowWindow(SW_HIDE); |
| 1387 | m_KeypadTabDialog = m_LevelDialog; |
| 1388 | m_KeypadTabDialog->ShowWindow(SW_SHOW); |
| 1389 | break; |
| 1390 | |
| 1391 | case TAB_MATCEN_KEYPAD: |
| 1392 | if (m_KeypadTabDialog) |
| 1393 | m_KeypadTabDialog->ShowWindow(SW_HIDE); |
| 1394 | m_KeypadTabDialog = m_MatcenDialog; |
| 1395 | m_KeypadTabDialog->ShowWindow(SW_SHOW); |
| 1396 | break; |
| 1397 | |
| 1398 | case TAB_TRIGGER_KEYPAD: |
| 1399 | if (m_KeypadTabDialog) |
| 1400 | m_KeypadTabDialog->ShowWindow(SW_HIDE); |
| 1401 | m_KeypadTabDialog = m_TriggerDialog; |
| 1402 | m_KeypadTabDialog->ShowWindow(SW_SHOW); |
| 1403 | break; |
| 1404 | |
| 1405 | case TAB_DOORWAY_KEYPAD: |
| 1406 | if (m_KeypadTabDialog) |
| 1407 | m_KeypadTabDialog->ShowWindow(SW_HIDE); |
| 1408 | m_KeypadTabDialog = m_DoorwayDialog; |
| 1409 | m_KeypadTabDialog->ShowWindow(SW_SHOW); |
| 1410 | break; |
| 1411 | |
| 1412 | case TAB_TERRAIN_KEYPAD: |
| 1413 | if (m_KeypadTabDialog) |
| 1414 | m_KeypadTabDialog->ShowWindow(SW_HIDE); |
| 1415 | m_KeypadTabDialog = m_TerrainDialog; |
| 1416 | m_KeypadTabDialog->ShowWindow(SW_SHOW); |
| 1417 | break; |
| 1418 | |
| 1419 | case TAB_MEGACELL_KEYPAD: |
| 1420 | if (m_KeypadTabDialog) |
| 1421 | m_KeypadTabDialog->ShowWindow(SW_HIDE); |
| 1422 | m_KeypadTabDialog = m_MegacellKeypad; |
| 1423 | m_KeypadTabDialog->ShowWindow(SW_SHOW); |
| 1424 | break; |
| 1425 | } |
| 1426 | break; |
| 1427 | } |
| 1428 | } |
| 1429 | |
| 1430 | // Put all non client window destruction here! |
| 1431 | void CMainFrame::OnNcDestroy() { CFrameWnd::OnNcDestroy(); } |
| 1432 | |
| 1433 | void CMainFrame::OnDestroy() { |
| 1434 | CFrameWnd::OnDestroy(); |
| 1435 | |
| 1436 | // Save game & editor variables to the registry |
| 1437 | SaveGameSettings(); |
| 1438 | SaveEditorSettings(); |
| 1439 | |
| 1440 | // kill game and editor objects outside MFC. |
| 1441 | if (Desktop_surf) { |
| 1442 | delete Desktop_surf; |
| 1443 | Desktop_surf = NULL; |
| 1444 | } |
| 1445 | if (Database) { |
| 1446 | delete Database; |
| 1447 | Database = NULL; |
| 1448 | } |
| 1449 | if (Descent) { |
| 1450 | delete Descent; |
| 1451 | Descent = NULL; |
| 1452 | } |
| 1453 | } |
| 1454 | |
| 1455 | void InitCScripts() { |
| 1456 | char path[_MAX_PATH]; |
| 1457 | int dirlen = _MAX_PATH; |
| 1458 | |
| 1459 | // Create a default segment. This should probably be in the editor initialization code |
| 1460 | // This call must come after InitObjects() |
| 1461 | CreateNewMine(); |
| 1462 | |
| 1463 | // Setup include directories for OSIRIS |
| 1464 | ddio_MakePath(path, Base_directory_write, "data", "levels", NULL); |
| 1465 | } |
| 1466 | |
| 1467 | // Copied from winmain.cpp |
| 1468 | void WinMainInitEditor(unsigned hwnd, unsigned hinst) { |
| 1469 | tLnxAppInfo appinfo; |
| 1470 | |
| 1471 | // TODO: HWnd from SDL2 Window |
| 1472 | // appinfo.hwnd = (HWnd)hwnd; |
| 1473 | // appinfo.hinst = (HInstance)hinst; |
| 1474 | appinfo.flags = OEAPP_WINDOWED; |
| 1475 | |
| 1476 | Descent = new oeLnxApplication(&appinfo); |
| 1477 | Database = new oeLnxAppDatabase; |
| 1478 | } |
| 1479 | // Initializes OS components for Descent3. MUST BE DONE BEFORE ANYTHING ELSE! |
| 1480 | |
| 1481 | BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext *pContext) { |
| 1482 | // TODO: Add your specialized code here and/or call the base class |
| 1483 | PreInitD3Systems(); |
| 1484 | WinMainInitEditor((unsigned)CWnd::m_hWnd, (unsigned)AfxGetInstanceHandle()); |
| 1485 | ProgramVersion(DEVELOPMENT_VERSION, 0, 0, 0); |
| 1486 | |
| 1487 | DisplaySplashScreen(); |
| 1488 | |
| 1489 | // Initialize a ton of stuff. |
| 1490 | InitD3Systems1(true); |
| 1491 | InitD3Systems2(true); |
| 1492 | |
| 1493 | // Initialize scripts |
| 1494 | InitCScripts(); |
| 1495 | |
| 1496 | // Load variables from registry |
| 1497 | LoadEditorSettings(); |
| 1498 | |
| 1499 | // Change to the levels directory, since the most likely thing to open is a level |
| 1500 | ddio_SetWorkingDir("data\\levels"); |
| 1501 | |
| 1502 | return CFrameWnd::OnCreateClient(lpcs, pContext); |
| 1503 | } |
| 1504 | |
| 1505 | void CMainFrame::ResizeKeypad() { |
| 1506 | if (::IsWindow(m_wndKeypadBar.m_hWnd)) { |
| 1507 | CTabCtrl *tab_ctrl; |
| 1508 | RECT tab_rect, tab_winrect, dbar_rect; |
| 1509 | int tx, ty, tw, th; |
| 1510 | |
| 1511 | tab_ctrl = (CTabCtrl *)m_wndKeypadBar.GetDlgItem(IDC_KEYPADS); |
| 1512 | |
| 1513 | m_wndKeypadBar.GetClientRect(&dbar_rect); |
| 1514 | dbar_rect.left += 2; |
| 1515 | dbar_rect.right -= 2; |
| 1516 | dbar_rect.top += 2; |
| 1517 | dbar_rect.bottom -= 2; |
| 1518 | tab_ctrl->MoveWindow(&dbar_rect); |
| 1519 | |
| 1520 | tab_ctrl->GetWindowRect(&tab_winrect); |
| 1521 | ::CopyRect(&tab_rect, &tab_winrect); |
| 1522 | tab_ctrl->AdjustRect(FALSE, &tab_rect); |
| 1523 | tx = tab_rect.left - tab_winrect.left; |
| 1524 | ty = tab_rect.top - tab_winrect.top; |
| 1525 | tw = tab_rect.right - tab_rect.left; |
| 1526 | th = tab_rect.bottom - tab_rect.top; |
| 1527 | |
| 1528 | if (m_TextureDialog) |
| 1529 | m_TextureDialog->SetWindowPos(tab_ctrl, tx, ty, tw, th, SWP_NOZORDER); |
| 1530 | if (m_ObjectDialog) |
| 1531 | m_ObjectDialog->SetWindowPos(tab_ctrl, tx, ty, tw, th, SWP_NOZORDER); |
| 1532 | if (m_LightingDialog) |
| 1533 | m_LightingDialog->SetWindowPos(tab_ctrl, tx, ty, tw, th, SWP_NOZORDER); |
| 1534 | if (m_RoomDialog) |
| 1535 | m_RoomDialog->SetWindowPos(tab_ctrl, tx, ty, tw, th, SWP_NOZORDER); |
| 1536 | if (m_PathPadDialog) |
| 1537 | m_PathPadDialog->SetWindowPos(tab_ctrl, tx, ty, tw, th, SWP_NOZORDER); |
| 1538 | if (m_TriggerDialog) |
| 1539 | m_TriggerDialog->SetWindowPos(tab_ctrl, tx, ty, tw, th, SWP_NOZORDER); |
| 1540 | if (m_DoorwayDialog) |
| 1541 | m_DoorwayDialog->SetWindowPos(tab_ctrl, tx, ty, tw, th, SWP_NOZORDER); |
| 1542 | if (m_TerrainDialog) |
| 1543 | m_TerrainDialog->SetWindowPos(tab_ctrl, tx, ty, tw, th, SWP_NOZORDER); |
| 1544 | if (m_MegacellKeypad) |
| 1545 | m_MegacellKeypad->SetWindowPos(tab_ctrl, tx, ty, tw, th, SWP_NOZORDER); |
| 1546 | if (m_LevelDialog) |
| 1547 | m_LevelDialog->SetWindowPos(tab_ctrl, tx, ty, tw, th, SWP_NOZORDER); |
| 1548 | if (m_MatcenDialog) |
| 1549 | m_MatcenDialog->SetWindowPos(tab_ctrl, tx, ty, tw, th, SWP_NOZORDER); |
| 1550 | } |
| 1551 | } |
| 1552 | |
| 1553 | void CMainFrame::OnSize(UINT nType, int cx, int cy) { |
| 1554 | CFrameWnd::OnSize(nType, cx, cy); |
| 1555 | |
| 1556 | // TODO: Add your message handler code here |
| 1557 | ResizeKeypad(); |
| 1558 | } |
| 1559 | |
| 1560 | void CMainFrame::OnActivateApp(BOOL bActive, HTASK hTask) { |
| 1561 | #if 0 |
| 1562 | CFrameWnd::OnActivateApp(bActive, hTask); |
| 1563 | |
| 1564 | if (bActive) { |
| 1565 | theApp.resume(); |
| 1566 | mprintf_at(2,0,0, "App Active "); |
| 1567 | } |
| 1568 | else { |
| 1569 | theApp.pause(); |
| 1570 | mprintf_at(2,0,0, "App Inactive"); |
| 1571 | } |
| 1572 | |
| 1573 | ((oeLnxApplication *)Descent)->run_handler(this->m_hWnd, WM_ACTIVATEAPP, (unsigned)bActive, 0); |
| 1574 | #endif |
| 1575 | } |
| 1576 | |
| 1577 | // --------------------------------------------------------------------------- |
| 1578 | // These functions handle the status bar and displaying stuff in the status bar. |
| 1579 | // --------------------------------------------------------------------------- |
| 1580 | |
| 1581 | void CMainFrame::SetStatusMessage(char *str) { m_wndStatusBar.SetPaneText(0, str); } |
| 1582 | |
| 1583 | void EditorStatus(const char *format, ...) { |
| 1584 | if (MFC_Main_frame) { |
| 1585 | char status_line[256]; |
| 1586 | std::va_list ap; |
| 1587 | |
| 1588 | va_start(ap, format); |
| 1589 | std::vsnprintf(status_line, 256, format, ap); |
| 1590 | va_end(ap); |
| 1591 | |
| 1592 | MFC_Main_frame->SetStatusMessage(status_line); |
| 1593 | } |
| 1594 | } |
| 1595 | |
| 1596 | void SplashMessage(const char *format, ...) { |
| 1597 | if (D3_splash_screen) { |
| 1598 | char status_line[256]; |
| 1599 | std::va_list ap; |
| 1600 | |
| 1601 | va_start(ap, format); |
| 1602 | std::vsnprintf(status_line, 256, format, ap); |
| 1603 | va_end(ap); |
| 1604 | |
| 1605 | D3_splash_screen->PutText(status_line); |
| 1606 | } |
| 1607 | } |
| 1608 | |
| 1609 | char Editor_error_message[1000] = ""; |
| 1610 | |
| 1611 | // Set the editor error message. A function that's going to return a failure |
| 1612 | // code should call this with the error message. |
| 1613 | void SetErrorMessage(const char *fmt, ...) { |
| 1614 | std::va_list arglist; |
| 1615 | |
| 1616 | va_start(arglist, fmt); |
| 1617 | std::vsnprintf(Editor_error_message, sizeof(Editor_error_message), fmt, arglist); |
| 1618 | va_end(arglist); |
| 1619 | |
| 1620 | mprintf(0, "Editor error: %s\n", Editor_error_message); |
| 1621 | } |
| 1622 | |
| 1623 | // Get the error message from the last function that returned failure |
| 1624 | const char *GetErrorMessage() { return Editor_error_message; } |
| 1625 | |
| 1626 | void CMainFrame::OnSegSidePane(CCmdUI *pCmdUI) { |
| 1627 | CString strSegSide; |
| 1628 | |
| 1629 | pCmdUI->Enable(); |
| 1630 | if (Editor_view_mode == VM_TERRAIN) { |
| 1631 | // We could put something here, but I don't know what. Jason? |
| 1632 | } else if (Editor_view_mode == VM_MINE) { |
| 1633 | if (Curroomp) |
| 1634 | strSegSide.Format("Cur %d:%d", ROOMNUM(Curroomp), Curface); |
| 1635 | else |
| 1636 | strSegSide.Format("No curroom"); |
| 1637 | } else if (Editor_view_mode == VM_ROOM) { |
| 1638 | if (Current_faces[D3EditState.current_room - FIRST_PALETTE_ROOM] != -1) |
| 1639 | strSegSide.Format("Face %d", Current_faces[D3EditState.current_room - FIRST_PALETTE_ROOM]); |
| 1640 | else |
| 1641 | strSegSide.Format("No face"); |
| 1642 | } else |
| 1643 | Int3(); |
| 1644 | |
| 1645 | pCmdUI->SetText(strSegSide); |
| 1646 | } |
| 1647 | |
| 1648 | void CMainFrame::OnBMMemPane(CCmdUI *pCmdUI) { |
| 1649 | CString strSegSide; |
| 1650 | |
| 1651 | pCmdUI->Enable(); |
| 1652 | |
| 1653 | strSegSide.Format("Bitmap memory: %d K", Bitmap_memory_used / 1000); |
| 1654 | |
| 1655 | pCmdUI->SetText(strSegSide); |
| 1656 | } |
| 1657 | |
| 1658 | void CMainFrame::OnEnginePane(CCmdUI *pCmdUI) { |
| 1659 | CString strEngineType; |
| 1660 | |
| 1661 | pCmdUI->Enable(); |
| 1662 | |
| 1663 | switch (Editor_view_mode) { |
| 1664 | case VM_MINE: |
| 1665 | strEngineType.Format("Mine View"); |
| 1666 | break; |
| 1667 | case VM_TERRAIN: |
| 1668 | strEngineType.Format("Terrain View"); |
| 1669 | break; |
| 1670 | case VM_ROOM: |
| 1671 | strEngineType.Format("Room View"); |
| 1672 | break; |
| 1673 | } |
| 1674 | pCmdUI->SetText(strEngineType); |
| 1675 | } |
| 1676 | |
| 1677 | void CMainFrame::OnViewerPane(CCmdUI *pCmdUI) { |
| 1678 | CString strViewerNum; |
| 1679 | |
| 1680 | pCmdUI->Enable(); |
| 1681 | |
| 1682 | if (Editor_view_mode == VM_ROOM) |
| 1683 | strViewerNum.Format(""); // Don't show viewer number in room view |
| 1684 | else |
| 1685 | strViewerNum.Format("Viewer %d", GetViewerNum()); |
| 1686 | |
| 1687 | pCmdUI->SetText(strViewerNum); |
| 1688 | } |
| 1689 | |
| 1690 | void CMainFrame::OnNetPane(CCmdUI *pCmdUI) { |
| 1691 | CString strSegSide; |
| 1692 | |
| 1693 | pCmdUI->Enable(); |
| 1694 | if (Network_up) |
| 1695 | strSegSide.Format("NET"); |
| 1696 | else |
| 1697 | strSegSide.Format("NoNet"); |
| 1698 | |
| 1699 | pCmdUI->SetText(strSegSide); |
| 1700 | } |
| 1701 | |
| 1702 | // --------------------------------------------------------------------------- |
| 1703 | // Menu items |
| 1704 | // --------------------------------------------------------------------------- |
| 1705 | |
| 1706 | void CMainFrame::OnToolsWorldTextures() { |
| 1707 | CWorldTexturesDialog wtexdlg; |
| 1708 | |
| 1709 | theApp.pause(); |
| 1710 | wtexdlg.DoModal(); |
| 1711 | theApp.resume(); |
| 1712 | } |
| 1713 | |
| 1714 | void CMainFrame::OnToolsWorldWeapons() { |
| 1715 | CWorldWeaponsDialog wweapdlg; |
| 1716 | |
| 1717 | theApp.pause(); |
| 1718 | wweapdlg.DoModal(); |
| 1719 | theApp.resume(); |
| 1720 | } |
| 1721 | |
| 1722 | void CMainFrame::OnToolsWorldObjectsDoor() { |
| 1723 | CWorldObjectsDoorDialog dlg; |
| 1724 | |
| 1725 | theApp.pause(); |
| 1726 | dlg.DoModal(); |
| 1727 | theApp.resume(); |
| 1728 | } |
| 1729 | |
| 1730 | void CMainFrame::OnToolsWorldObjectsLights() { |
| 1731 | CWorldObjectsLightDialog dlg; |
| 1732 | |
| 1733 | theApp.pause(); |
| 1734 | dlg.DoModal(); |
| 1735 | theApp.resume(); |
| 1736 | } |
| 1737 | |
| 1738 | void CMainFrame::OnToolsWorldObjectsPlayer() { |
| 1739 | CWorldObjectsPlayerDialog dlg; |
| 1740 | |
| 1741 | theApp.pause(); |
| 1742 | dlg.DoModal(); |
| 1743 | theApp.resume(); |
| 1744 | } |
| 1745 | |
| 1746 | void CMainFrame::OnToolsWorldObjectsPowerups() { |
| 1747 | CWorldObjectsGenericDialog dlg; |
| 1748 | |
| 1749 | dlg.m_type = OBJ_POWERUP; |
| 1750 | dlg.m_current = D3EditState.current_powerup; |
| 1751 | |
| 1752 | theApp.pause(); |
| 1753 | dlg.DoModal(); |
| 1754 | theApp.resume(); |
| 1755 | |
| 1756 | if (dlg.m_current != -1) |
| 1757 | D3EditState.current_powerup = dlg.m_current; |
| 1758 | } |
| 1759 | |
| 1760 | void CMainFrame::OnToolsWorldObjectsRobots() { |
| 1761 | CWorldObjectsGenericDialog dlg; |
| 1762 | |
| 1763 | dlg.m_type = OBJ_ROBOT; |
| 1764 | dlg.m_current = D3EditState.current_robot; |
| 1765 | |
| 1766 | theApp.pause(); |
| 1767 | dlg.DoModal(); |
| 1768 | theApp.resume(); |
| 1769 | |
| 1770 | if (dlg.m_current != -1) |
| 1771 | D3EditState.current_robot = dlg.m_current; |
| 1772 | } |
| 1773 | |
| 1774 | void CMainFrame::OnToolsWorldObjectsClutter() { |
| 1775 | CWorldObjectsGenericDialog dlg; |
| 1776 | |
| 1777 | dlg.m_type = OBJ_CLUTTER; |
| 1778 | dlg.m_current = D3EditState.current_clutter; |
| 1779 | |
| 1780 | theApp.pause(); |
| 1781 | dlg.DoModal(); |
| 1782 | theApp.resume(); |
| 1783 | |
| 1784 | if (dlg.m_current != -1) |
| 1785 | D3EditState.current_clutter = dlg.m_current; |
| 1786 | } |
| 1787 | |
| 1788 | void CMainFrame::OnToolsWorldObjectsBuildings() { |
| 1789 | CWorldObjectsGenericDialog dlg; |
| 1790 | |
| 1791 | dlg.m_type = OBJ_BUILDING; |
| 1792 | dlg.m_current = D3EditState.current_building; |
| 1793 | |
| 1794 | theApp.pause(); |
| 1795 | dlg.DoModal(); |
| 1796 | theApp.resume(); |
| 1797 | |
| 1798 | if (dlg.m_current != -1) |
| 1799 | D3EditState.current_building = dlg.m_current; |
| 1800 | } |
| 1801 | |
| 1802 | void CMainFrame::OnSubeditorsFont() { |
| 1803 | CGrFontDialog dlg; |
| 1804 | |
| 1805 | theApp.pause(); |
| 1806 | dlg.DoModal(); |
| 1807 | theApp.resume(); |
| 1808 | } |
| 1809 | |
| 1810 | void CMainFrame::OnUpdateViewKeypadToggle(CCmdUI *pCmdUI) { pCmdUI->SetCheck((BOOL)D3EditState.keypad_visible); } |
| 1811 | |
| 1812 | void CMainFrame::OnViewKeypadToggle() { |
| 1813 | D3EditState.keypad_visible = !D3EditState.keypad_visible; |
| 1814 | |
| 1815 | if (D3EditState.tile_views) { |
| 1816 | ShowControlBar(&m_wndKeypadBar, (BOOL)D3EditState.keypad_visible, FALSE); |
| 1817 | ResizeKeypad(); |
| 1818 | ShowCurrentKeypad(); |
| 1819 | } else if (!D3EditState.keypad_visible && m_FloatingKeypadDialog) |
| 1820 | m_FloatingKeypadDialog->ShowWindow(SW_HIDE); |
| 1821 | else if (D3EditState.keypad_visible && m_FloatingKeypadDialog) |
| 1822 | m_FloatingKeypadDialog->ShowWindow(SW_SHOW); |
| 1823 | } |
| 1824 | |
| 1825 | void CMainFrame::DockKeypad(BOOL dock) { |
| 1826 | if (D3EditState.keypad_visible) { |
| 1827 | if (dock) { |
| 1828 | // Resize the keypad to the size of the window. |
| 1829 | if (m_FloatingKeypadDialog) { |
| 1830 | m_FloatingKeypadDialog->DestroyWindow(); |
| 1831 | m_FloatingKeypadDialog = NULL; |
| 1832 | } |
| 1833 | ShowControlBar(&m_wndKeypadBar, TRUE, FALSE); |
| 1834 | ResizeKeypad(); |
| 1835 | ShowCurrentKeypad(); |
| 1836 | } else { |
| 1837 | ShowControlBar(&m_wndKeypadBar, FALSE, FALSE); |
| 1838 | if (!m_FloatingKeypadDialog) { |
| 1839 | if (!D3EditState.float_keypad_moved) { |
| 1840 | RECT rect; |
| 1841 | m_wndKeypadBar.GetWindowRect(&rect); |
| 1842 | GetActiveFrame()->ScreenToClient(&rect); |
| 1843 | D3EditState.float_keypad_x = rect.left; |
| 1844 | D3EditState.float_keypad_y = rect.top; |
| 1845 | } |
| 1846 | |
| 1847 | CWnd *wnd = GetActiveView(); |
| 1848 | |
| 1849 | m_FloatingKeypadDialog = new CFloatingKeypadDialog(wnd); |
| 1850 | m_FloatingKeypadDialog->Create(); |
| 1851 | |
| 1852 | if (!D3EditState.float_keypad_moved) { |
| 1853 | RECT rect; |
| 1854 | m_FloatingKeypadDialog->GetWindowRect(&rect); |
| 1855 | D3EditState.float_keypad_w = rect.right - rect.left; |
| 1856 | D3EditState.float_keypad_h = rect.bottom - rect.top; |
| 1857 | } |
| 1858 | } |
| 1859 | |
| 1860 | // place keypad at right, top of desktop if not already placed |
| 1861 | m_FloatingKeypadDialog->SetWindowPos(NULL, D3EditState.float_keypad_x, D3EditState.float_keypad_y, |
| 1862 | D3EditState.float_keypad_w, D3EditState.float_keypad_h, SWP_NOZORDER); |
| 1863 | m_FloatingKeypadDialog->SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); |
| 1864 | m_FloatingKeypadDialog->ShowWindow(SW_SHOW); |
| 1865 | D3EditState.float_keypad_moved = 1; |
| 1866 | } |
| 1867 | } else { |
| 1868 | // keypad is NOT visi . |
| 1869 | ShowControlBar(&m_wndKeypadBar, FALSE, FALSE); |
| 1870 | } |
| 1871 | } |
| 1872 | |
| 1873 | // Invoke Descent 3 from D3Edit |
| 1874 | |
| 1875 | extern void RunGameFromEditor(); |
| 1876 | |
| 1877 | void CMainFrame::OnFilePlayin640x480() { |
| 1878 | // Returns true if there are out of data files |
| 1879 | int count = AreScriptsOutofDate(); |
| 1880 | if (count > 0) { |
| 1881 | if (OutrageMessageBox(MBOX_YESNO, "There were %d scripts that couldn't be compiled, continue?", count) != IDYES) |
| 1882 | return; |
| 1883 | } |
| 1884 | |
| 1885 | renderer_type sr_save; |
| 1886 | bool keypad_was_visible = D3EditState.keypad_visible; |
| 1887 | DWORD cbar_was_visible = (m_wndToolBar.GetStyle() & WS_VISIBLE); |
| 1888 | DWORD status_was_visible = (m_wndStatusBar.GetStyle() & WS_VISIBLE); |
| 1889 | |
| 1890 | // Shutdown view system |
| 1891 | m_ViewActivated = FALSE; |
| 1892 | ((CEditorView *)GetActiveView())->DeactivateView(); |
| 1893 | if (m_FloatingKeypadDialog) |
| 1894 | m_FloatingKeypadDialog->Deactivate(); |
| 1895 | CKeypadDialog::Deactivate(); |
| 1896 | delete Desktop_surf; |
| 1897 | |
| 1898 | // hide keypad if it's visible |
| 1899 | if (keypad_was_visible) |
| 1900 | OnViewKeypadToggle(); |
| 1901 | if (cbar_was_visible) |
| 1902 | ShowControlBar(&m_wndToolBar, FALSE, FALSE); |
| 1903 | if (status_was_visible) |
| 1904 | ShowControlBar(&m_wndStatusBar, FALSE, FALSE); |
| 1905 | |
| 1906 | SetFunctionMode(EDITOR_GAME_MODE); |
| 1907 | |
| 1908 | sr_save = Renderer_type; |
| 1909 | |
| 1910 | // if we have selected the windowed toggle, assert this. |
| 1911 | if (D3EditState.game_render_mode == GM_WINDOWED) |
| 1912 | PROGRAM(windowed) = 1; |
| 1913 | else |
| 1914 | PROGRAM(windowed) = 0; |
| 1915 | |
| 1916 | RunGameFromEditor(); |
| 1917 | PROGRAM(windowed) = 1; |
| 1918 | |
| 1919 | Renderer_type = sr_save; |
| 1920 | |
| 1921 | // hide keypad if it's visible |
| 1922 | if (status_was_visible) |
| 1923 | ShowControlBar(&m_wndStatusBar, TRUE, FALSE); |
| 1924 | if (cbar_was_visible) |
| 1925 | ShowControlBar(&m_wndToolBar, TRUE, FALSE); |
| 1926 | if (keypad_was_visible) |
| 1927 | OnViewKeypadToggle(); |
| 1928 | |
| 1929 | // Restore view system |
| 1930 | Desktop_surf = new grSurface(0, 0, 0, SURFTYPE_VIDEOSCREEN, 0); |
| 1931 | if (m_FloatingKeypadDialog) |
| 1932 | m_FloatingKeypadDialog->Activate(); |
| 1933 | CKeypadDialog::Activate(); |
| 1934 | ((CEditorView *)GetActiveView())->ActivateView(); |
| 1935 | m_ViewActivated = TRUE; |
| 1936 | } |
| 1937 | |
| 1938 | void CMainFrame::OnFileLeaveEditor() { |
| 1939 | // Returns true if there are out of data files |
| 1940 | int count = AreScriptsOutofDate(); |
| 1941 | if (count > 0) { |
| 1942 | if (OutrageMessageBox(MBOX_YESNO, "There were %d scripts that couldn't be compiled, continue?", count) != IDYES) |
| 1943 | return; |
| 1944 | } |
| 1945 | |
| 1946 | bool keypad_was_visible = D3EditState.keypad_visible; |
| 1947 | DWORD cbar_was_visible = (m_wndToolBar.GetStyle() & WS_VISIBLE); |
| 1948 | DWORD status_was_visible = (m_wndStatusBar.GetStyle() & WS_VISIBLE); |
| 1949 | |
| 1950 | // Shutdown view system |
| 1951 | m_ViewActivated = FALSE; |
| 1952 | ((CEditorView *)GetActiveView())->DeactivateView(); |
| 1953 | if (m_FloatingKeypadDialog) |
| 1954 | m_FloatingKeypadDialog->Deactivate(); |
| 1955 | CKeypadDialog::Deactivate(); |
| 1956 | delete Desktop_surf; |
| 1957 | |
| 1958 | // hide keypad if it's visible |
| 1959 | if (keypad_was_visible) |
| 1960 | OnViewKeypadToggle(); |
| 1961 | if (cbar_was_visible) |
| 1962 | ShowControlBar(&m_wndToolBar, FALSE, FALSE); |
| 1963 | if (status_was_visible) |
| 1964 | ShowControlBar(&m_wndStatusBar, FALSE, FALSE); |
| 1965 | |
| 1966 | SetFunctionMode(MENU_MODE); |
| 1967 | |
| 1968 | // if we have selected the windowed toggle, assert this. |
| 1969 | if (D3EditState.game_render_mode == GM_WINDOWED) |
| 1970 | PROGRAM(windowed) = 1; |
| 1971 | else |
| 1972 | PROGRAM(windowed) = 0; |
| 1973 | |
| 1974 | RunGameFromEditor(); |
| 1975 | PROGRAM(windowed) = 1; |
| 1976 | |
| 1977 | // hide keypad if it's visible |
| 1978 | if (status_was_visible) |
| 1979 | ShowControlBar(&m_wndStatusBar, TRUE, FALSE); |
| 1980 | if (cbar_was_visible) |
| 1981 | ShowControlBar(&m_wndToolBar, TRUE, FALSE); |
| 1982 | if (keypad_was_visible) |
| 1983 | OnViewKeypadToggle(); |
| 1984 | |
| 1985 | // Restore view system |
| 1986 | Desktop_surf = new grSurface(0, 0, 0, SURFTYPE_VIDEOSCREEN, 0); |
| 1987 | if (m_FloatingKeypadDialog) |
| 1988 | m_FloatingKeypadDialog->Activate(); |
| 1989 | CKeypadDialog::Activate(); |
| 1990 | ((CEditorView *)GetActiveView())->ActivateView(); |
| 1991 | m_ViewActivated = TRUE; |
| 1992 | } |
| 1993 | |
| 1994 | void CMainFrame::OnFilePreferences() { |
| 1995 | CPreferencesDialog dlg; |
| 1996 | |
| 1997 | theApp.pause(); |
| 1998 | dlg.DoModal(); |
| 1999 | theApp.resume(); |
| 2000 | } |
| 2001 | |
| 2002 | void CMainFrame::OnImportBitmap() { |
| 2003 | char filename[200]; |
| 2004 | int bm_handle, anim = 0; |
| 2005 | |
| 2006 | CString filter = |
| 2007 | "Descent III files (*.tga,*.bbm,*.lbm,*.ogf,*.oaf,*.ilf,*.pcx)|*.pcx;*.tga;*.bbm;*.lbm;*.ogf;*.oaf;*.ifl||"; |
| 2008 | |
| 2009 | if (!OpenFileDialog(this, (LPCSTR)filter, filename, Current_bitmap_dir, sizeof(Current_bitmap_dir))) |
| 2010 | return; |
| 2011 | |
| 2012 | // Okay, we selected a file. Lets do what needs to be done here. |
| 2013 | bm_handle = LoadTextureImage(filename, &anim, NOT_TEXTURE, 0); |
| 2014 | |
| 2015 | if (bm_handle < 0) { |
| 2016 | OutrageMessageBox("Couldn't open that bitmap/anim file."); |
| 2017 | return; |
| 2018 | } |
| 2019 | |
| 2020 | mprintf(0, "Making a copy of this bitmap/anim locally...\n"); |
| 2021 | |
| 2022 | if (!anim) { |
| 2023 | sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), GameBitmaps[bm_handle].name); |
| 2024 | bm_SaveFileBitmap(filename, bm_handle); |
| 2025 | bm_FreeBitmap(bm_handle); |
| 2026 | } else { |
| 2027 | sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), GameVClips[bm_handle].name); |
| 2028 | SaveVClip(filename, bm_handle); |
| 2029 | FreeVClip(bm_handle); |
| 2030 | } |
| 2031 | |
| 2032 | OutrageMessageBox("Image(s) imported!"); |
| 2033 | } |
| 2034 | |
| 2035 | void CMainFrame::OnSubeditorsHogmaker() { |
| 2036 | // Open common file open dialog box. |
| 2037 | CString filter = "Descent III hogfiles (*.hog)|*.hog||"; |
| 2038 | CFileDialog dlg_open(TRUE, 0, 0, OFN_FILEMUSTEXIST, (LPCTSTR)filter, this); |
| 2039 | char filename[_MAX_PATH]; |
| 2040 | |
| 2041 | if (dlg_open.DoModal() == IDCANCEL) { |
| 2042 | return; |
| 2043 | } |
| 2044 | |
| 2045 | lstrcpy(filename, dlg_open.GetPathName()); |
| 2046 | |
| 2047 | // Open the HOG Dialog |
| 2048 | CHogDialog dlg(this, filename); |
| 2049 | |
| 2050 | theApp.pause(); |
| 2051 | dlg.DoModal(); |
| 2052 | theApp.resume(); |
| 2053 | } |
| 2054 | |
| 2055 | // --------------------------------------------------------------------------- |
| 2056 | // Number PAD functions |
| 2057 | // --------------------------------------------------------------------------- |
| 2058 | |
| 2059 | void CMainFrame::OnNumpad0() { |
| 2060 | mprintf(0, "NUMPAD0\n"); |
| 2061 | if (!D3EditState.keypad_visible) |
| 2062 | return; |
| 2063 | if (m_FloatingKeypadDialog) |
| 2064 | m_FloatingKeypadDialog->RunKeypadFunction(VK_NUMPAD0); |
| 2065 | else if (m_KeypadTabDialog) |
| 2066 | m_KeypadTabDialog->RunKeypadFunction(VK_NUMPAD0); |
| 2067 | } |
| 2068 | |
| 2069 | void CMainFrame::OnNumpad1() { |
| 2070 | if (!D3EditState.keypad_visible) |
| 2071 | return; |
| 2072 | if (m_FloatingKeypadDialog) |
| 2073 | m_FloatingKeypadDialog->RunKeypadFunction(VK_NUMPAD1); |
| 2074 | else if (m_KeypadTabDialog) |
| 2075 | m_KeypadTabDialog->RunKeypadFunction(VK_NUMPAD1); |
| 2076 | } |
| 2077 | |
| 2078 | void CMainFrame::OnNumpad2() { |
| 2079 | if (!D3EditState.keypad_visible) |
| 2080 | return; |
| 2081 | if (m_FloatingKeypadDialog) |
| 2082 | m_FloatingKeypadDialog->RunKeypadFunction(VK_NUMPAD2); |
| 2083 | else if (m_KeypadTabDialog) |
| 2084 | m_KeypadTabDialog->RunKeypadFunction(VK_NUMPAD2); |
| 2085 | } |
| 2086 | |
| 2087 | void CMainFrame::OnNumpad3() { |
| 2088 | if (!D3EditState.keypad_visible) |
| 2089 | return; |
| 2090 | if (m_FloatingKeypadDialog) |
| 2091 | m_FloatingKeypadDialog->RunKeypadFunction(VK_NUMPAD3); |
| 2092 | else if (m_KeypadTabDialog) |
| 2093 | m_KeypadTabDialog->RunKeypadFunction(VK_NUMPAD3); |
| 2094 | } |
| 2095 | |
| 2096 | void CMainFrame::OnNumpad4() { |
| 2097 | if (!D3EditState.keypad_visible) |
| 2098 | return; |
| 2099 | if (m_FloatingKeypadDialog) |
| 2100 | m_FloatingKeypadDialog->RunKeypadFunction(VK_NUMPAD4); |
| 2101 | else if (m_KeypadTabDialog) |
| 2102 | m_KeypadTabDialog->RunKeypadFunction(VK_NUMPAD4); |
| 2103 | } |
| 2104 | |
| 2105 | void CMainFrame::OnNumpad5() { |
| 2106 | if (!D3EditState.keypad_visible) |
| 2107 | return; |
| 2108 | if (m_FloatingKeypadDialog) |
| 2109 | m_FloatingKeypadDialog->RunKeypadFunction(VK_NUMPAD5); |
| 2110 | else if (m_KeypadTabDialog) |
| 2111 | m_KeypadTabDialog->RunKeypadFunction(VK_NUMPAD5); |
| 2112 | } |
| 2113 | |
| 2114 | void CMainFrame::OnNumpad6() { |
| 2115 | if (!D3EditState.keypad_visible) |
| 2116 | return; |
| 2117 | if (m_FloatingKeypadDialog) |
| 2118 | m_FloatingKeypadDialog->RunKeypadFunction(VK_NUMPAD6); |
| 2119 | else if (m_KeypadTabDialog) |
| 2120 | m_KeypadTabDialog->RunKeypadFunction(VK_NUMPAD6); |
| 2121 | } |
| 2122 | |
| 2123 | void CMainFrame::OnNumpad7() { |
| 2124 | if (!D3EditState.keypad_visible) |
| 2125 | return; |
| 2126 | if (m_FloatingKeypadDialog) |
| 2127 | m_FloatingKeypadDialog->RunKeypadFunction(VK_NUMPAD7); |
| 2128 | else if (m_KeypadTabDialog) |
| 2129 | m_KeypadTabDialog->RunKeypadFunction(VK_NUMPAD7); |
| 2130 | } |
| 2131 | |
| 2132 | void CMainFrame::OnNumpad8() { |
| 2133 | if (!D3EditState.keypad_visible) |
| 2134 | return; |
| 2135 | if (m_FloatingKeypadDialog) |
| 2136 | m_FloatingKeypadDialog->RunKeypadFunction(VK_NUMPAD8); |
| 2137 | else if (m_KeypadTabDialog) |
| 2138 | m_KeypadTabDialog->RunKeypadFunction(VK_NUMPAD8); |
| 2139 | } |
| 2140 | |
| 2141 | void CMainFrame::OnNumpad9() { |
| 2142 | if (!D3EditState.keypad_visible) |
| 2143 | return; |
| 2144 | if (m_FloatingKeypadDialog) |
| 2145 | m_FloatingKeypadDialog->RunKeypadFunction(VK_NUMPAD9); |
| 2146 | else if (m_KeypadTabDialog) |
| 2147 | m_KeypadTabDialog->RunKeypadFunction(VK_NUMPAD9); |
| 2148 | } |
| 2149 | |
| 2150 | void CMainFrame::OnNumpaddel() { |
| 2151 | if (!D3EditState.keypad_visible) |
| 2152 | return; |
| 2153 | if (m_FloatingKeypadDialog) |
| 2154 | m_FloatingKeypadDialog->RunKeypadFunction(VK_DELETE); |
| 2155 | else if (m_KeypadTabDialog) |
| 2156 | m_KeypadTabDialog->RunKeypadFunction(VK_DELETE); |
| 2157 | } |
| 2158 | |
| 2159 | void CMainFrame::OnNumpadminus() { |
| 2160 | if (!D3EditState.keypad_visible) |
| 2161 | return; |
| 2162 | if (m_FloatingKeypadDialog) |
| 2163 | m_FloatingKeypadDialog->RunKeypadFunction(VK_SUBTRACT); |
| 2164 | else if (m_KeypadTabDialog) |
| 2165 | m_KeypadTabDialog->RunKeypadFunction(VK_SUBTRACT); |
| 2166 | } |
| 2167 | |
| 2168 | void CMainFrame::OnNumpadadd() { |
| 2169 | if (!D3EditState.keypad_visible) |
| 2170 | return; |
| 2171 | if (m_FloatingKeypadDialog) |
| 2172 | m_FloatingKeypadDialog->RunKeypadFunction(VK_ADD); |
| 2173 | else if (m_KeypadTabDialog) |
| 2174 | m_KeypadTabDialog->RunKeypadFunction(VK_ADD); |
| 2175 | } |
| 2176 | |
| 2177 | void CMainFrame::OnNumpadDiv() { |
| 2178 | if (!D3EditState.keypad_visible) |
| 2179 | return; |
| 2180 | if (m_FloatingKeypadDialog) |
| 2181 | m_FloatingKeypadDialog->RunKeypadFunction(VK_DIVIDE); |
| 2182 | else if (m_KeypadTabDialog) |
| 2183 | m_KeypadTabDialog->RunKeypadFunction(VK_DIVIDE); |
| 2184 | } |
| 2185 | |
| 2186 | void CMainFrame::OnNumpadEnter() { |
| 2187 | if (!D3EditState.keypad_visible) |
| 2188 | return; |
| 2189 | if (m_FloatingKeypadDialog) |
| 2190 | m_FloatingKeypadDialog->RunKeypadFunction(VK_RETURN); |
| 2191 | else if (m_KeypadTabDialog) |
| 2192 | m_KeypadTabDialog->RunKeypadFunction(VK_RETURN); |
| 2193 | } |
| 2194 | |
| 2195 | void CMainFrame::OnNumpadLock() { |
| 2196 | if (!D3EditState.keypad_visible) |
| 2197 | return; |
| 2198 | if (m_FloatingKeypadDialog) |
| 2199 | m_FloatingKeypadDialog->RunKeypadFunction(VK_NUMLOCK); |
| 2200 | else if (m_KeypadTabDialog) |
| 2201 | m_KeypadTabDialog->RunKeypadFunction(VK_NUMLOCK); |
| 2202 | } |
| 2203 | |
| 2204 | void CMainFrame::OnNumpadMul() { |
| 2205 | if (!D3EditState.keypad_visible) |
| 2206 | return; |
| 2207 | if (m_FloatingKeypadDialog) |
| 2208 | m_FloatingKeypadDialog->RunKeypadFunction(VK_MULTIPLY); |
| 2209 | else if (m_KeypadTabDialog) |
| 2210 | m_KeypadTabDialog->RunKeypadFunction(VK_MULTIPLY); |
| 2211 | } |
| 2212 | |
| 2213 | // --------------------------------------------------------------------------- |
| 2214 | // Yet more editor functions |
| 2215 | // --------------------------------------------------------------------------- |
| 2216 | |
| 2217 | void CMainFrame::OnViewCenterOnMine() { ResetWireframeView(); } |
| 2218 | |
| 2219 | void CMainFrame::OnViewMoveCameraToSelectedRoom() { SetViewerFromRoomFace(Curroomp, Curface, 1); } |
| 2220 | |
| 2221 | void CMainFrame::OnViewCenterOnCube() { |
| 2222 | vector pos; |
| 2223 | |
| 2224 | if (Editor_view_mode == VM_ROOM) |
| 2225 | ComputeRoomCenter(&pos, &Rooms[D3EditState.current_room]); |
| 2226 | else |
| 2227 | ComputeRoomCenter(&pos, Curroomp); |
| 2228 | |
| 2229 | SetWireframeView(&pos); |
| 2230 | } |
| 2231 | |
| 2232 | void CMainFrame::OnViewCenterOnObject() { SetWireframeView(&Objects[Cur_object_index].pos); } |
| 2233 | |
| 2234 | void CMainFrame::OnGroupCreateGroup() { |
| 2235 | // TODO: Add your command handler code here |
| 2236 | } |
| 2237 | |
| 2238 | void CMainFrame::OnGroupLoadGroup() { |
| 2239 | // TODO: Add your command handler code here |
| 2240 | } |
| 2241 | |
| 2242 | void CMainFrame::OnGroupMirrorGroup() { |
| 2243 | // TODO: Add your command handler code here |
| 2244 | } |
| 2245 | |
| 2246 | void CMainFrame::OnGroupSaveGroup() { |
| 2247 | // TODO: Add your command handler code here |
| 2248 | } |
| 2249 | |
| 2250 | void CMainFrame::OnEditAddSelect() { AddRoomToSelectedList(ROOMNUM(Curroomp)); } |
| 2251 | |
| 2252 | void CMainFrame::OnEditClearSelected() { ClearRoomSelectedList(); } |
| 2253 | |
| 2254 | void CMainFrame::OnEditRemoveSelect() { RemoveRoomFromSelectedList(ROOMNUM(Curroomp)); } |
| 2255 | |
| 2256 | void CMainFrame::OnEditSelectAttached() { |
| 2257 | int count; |
| 2258 | |
| 2259 | count = SelectConnectedRooms(ROOMNUM(Curroomp)); |
| 2260 | |
| 2261 | EditorStatus("%d rooms selected", count); |
| 2262 | } |
| 2263 | |
| 2264 | void CMainFrame::OnEditSaveScrap() { |
| 2265 | if (Scrap == NULL) { |
| 2266 | OutrageMessageBox("The scrap buffer is empty."); |
| 2267 | return; |
| 2268 | } |
| 2269 | |
| 2270 | CString filter = "D3 Group Files (*.grp)|*.grp||"; |
| 2271 | char filename[255]; |
| 2272 | |
| 2273 | if (!SaveFileDialog(this, (LPCSTR)filter, filename, Current_scrap_dir, sizeof(Current_scrap_dir))) |
| 2274 | return; |
| 2275 | |
| 2276 | if (!strchr(filename, '.')) |
| 2277 | strcat(filename, ".grp"); |
| 2278 | |
| 2279 | SaveGroup(filename, Scrap); |
| 2280 | |
| 2281 | EditorStatus("Group saved to %s", filename); |
| 2282 | } |
| 2283 | |
| 2284 | void CMainFrame::OnEditLoadScrap() { |
| 2285 | CString filter = "D3 Group Files (*.grp)|*.grp||"; |
| 2286 | char filename[255]; |
| 2287 | group *newscrap; |
| 2288 | |
| 2289 | if (!OpenFileDialog(this, (LPCSTR)filter, filename, Current_scrap_dir, sizeof(Current_scrap_dir))) |
| 2290 | return; |
| 2291 | |
| 2292 | if (!strchr(filename, '.')) |
| 2293 | strcat(filename, ".grp"); |
| 2294 | |
| 2295 | newscrap = LoadGroup(filename); |
| 2296 | |
| 2297 | if (newscrap) { |
| 2298 | if (Scrap) |
| 2299 | FreeGroup(Scrap); |
| 2300 | Scrap = newscrap; |
| 2301 | EditorStatus("Group loaded from %s", filename); |
| 2302 | } |
| 2303 | } |
| 2304 | |
| 2305 | // Copies the selected rooms to the scrap buffer. |
| 2306 | // Returns: true if copied ok, 0 if some error |
| 2307 | int CopySelectedRooms() { |
| 2308 | if (N_selected_rooms == 0) { |
| 2309 | OutrageMessageBox("You must have rooms selected for this operation."); |
| 2310 | return 0; |
| 2311 | } |
| 2312 | |
| 2313 | if (!Markedroomp) { |
| 2314 | OutrageMessageBox("You must have a marked room for this operation."); |
| 2315 | return 0; |
| 2316 | } |
| 2317 | |
| 2318 | if (!IsRoomSelected(ROOMNUM(Markedroomp))) { |
| 2319 | OutrageMessageBox("The Marked room must be selected for this operation."); |
| 2320 | return 0; |
| 2321 | } |
| 2322 | |
| 2323 | if (!((Markedroomp->faces[Markedface].portal_num == -1) || |
| 2324 | (Markedroomp->portals[Markedroomp->faces[Markedface].portal_num].croom == -1) || |
| 2325 | !IsRoomSelected(Markedroomp->portals[Markedroomp->faces[Markedface].portal_num].croom))) { |
| 2326 | OutrageMessageBox("The Marked room/face must be unattached for this operation."); |
| 2327 | return 0; |
| 2328 | } |
| 2329 | |
| 2330 | // Get rid of old contents of scrap buffer |
| 2331 | if (Scrap) |
| 2332 | FreeGroup(Scrap); |
| 2333 | |
| 2334 | Scrap = CopyGroup(N_selected_rooms, Selected_rooms, ROOMNUM(Markedroomp), Markedface); |
| 2335 | |
| 2336 | return 1; |
| 2337 | } |
| 2338 | |
| 2339 | void CMainFrame::OnEditCopy() { |
| 2340 | if (CopySelectedRooms()) |
| 2341 | EditorStatus("%d rooms copied to Scrap", N_selected_rooms); |
| 2342 | } |
| 2343 | |
| 2344 | void CMainFrame::OnEditPlace() { |
| 2345 | if (!Scrap) { |
| 2346 | OutrageMessageBox("There is nothing in the scrap buffer."); |
| 2347 | return; |
| 2348 | } |
| 2349 | |
| 2350 | if (Curroomp->faces[Curface].portal_num != -1) { |
| 2351 | OutrageMessageBox("The selected Room/Face must be free for this operation."); |
| 2352 | return; |
| 2353 | } |
| 2354 | |
| 2355 | PlaceGroup(Curroomp, Curface, Scrap); |
| 2356 | } |
| 2357 | |
| 2358 | void CMainFrame::OnEditPlaceTerrain() { |
| 2359 | if (!Scrap) { |
| 2360 | OutrageMessageBox("There is nothing in the scrap buffer."); |
| 2361 | return; |
| 2362 | } |
| 2363 | |
| 2364 | int cellnum; |
| 2365 | |
| 2366 | if (Num_terrain_selected != 1) { |
| 2367 | OutrageMessageBox("You must have one and only one cell selected this operation"); |
| 2368 | return; |
| 2369 | } else { |
| 2370 | for (cellnum = 0; cellnum < TERRAIN_WIDTH * TERRAIN_DEPTH; cellnum++) |
| 2371 | if (TerrainSelected[cellnum]) |
| 2372 | break; |
| 2373 | |
| 2374 | ASSERT(cellnum != TERRAIN_WIDTH * TERRAIN_DEPTH); |
| 2375 | } |
| 2376 | |
| 2377 | int result = OutrageMessageBox(MBOX_YESNOCANCEL, "Do you want to align to the terrain? NO will align with gravity."); |
| 2378 | |
| 2379 | if (result == IDCANCEL) |
| 2380 | return; |
| 2381 | |
| 2382 | PlaceGroupTerrain(cellnum, Scrap, (result == IDYES)); |
| 2383 | } |
| 2384 | |
| 2385 | void CMainFrame::OnEditAttach() { |
| 2386 | ASSERT(Placed_group != NULL); |
| 2387 | |
| 2388 | AttachGroup(); |
| 2389 | } |
| 2390 | |
| 2391 | void CMainFrame::OnEditCut() { |
| 2392 | if (CopySelectedRooms()) { |
| 2393 | int n = N_selected_rooms; |
| 2394 | DeleteGroup(N_selected_rooms, Selected_rooms); |
| 2395 | EditorStatus("%d rooms cut to Scrap", n); |
| 2396 | ClearRoomSelectedList(); |
| 2397 | } |
| 2398 | } |
| 2399 | |
| 2400 | void CMainFrame::OnEditDelete() { |
| 2401 | if (N_selected_rooms == 0) { |
| 2402 | OutrageMessageBox("You must have rooms selected for this operation."); |
| 2403 | return; |
| 2404 | } |
| 2405 | |
| 2406 | DeleteGroup(N_selected_rooms, Selected_rooms); |
| 2407 | EditorStatus("%d rooms deleted", N_selected_rooms); |
| 2408 | ClearRoomSelectedList(); |
| 2409 | } |
| 2410 | |
| 2411 | void CMainFrame::OnObjectDeleteObject() { |
| 2412 | // TODO: Add your command handler code here |
| 2413 | if (m_ObjectDialog) |
| 2414 | m_ObjectDialog->DeleteObject(); |
| 2415 | } |
| 2416 | |
| 2417 | void CMainFrame::OnObjectPlaceObject() { |
| 2418 | // TODO: Add your command handler code here |
| 2419 | if (m_ObjectDialog) |
| 2420 | m_ObjectDialog->PlaceObject(); |
| 2421 | } |
| 2422 | |
| 2423 | void CMainFrame::OnToolsWorldObjectsSound() { |
| 2424 | CWorldSoundsDialog dlg; |
| 2425 | |
| 2426 | theApp.pause(); |
| 2427 | dlg.DoModal(); |
| 2428 | theApp.resume(); |
| 2429 | } |
| 2430 | |
| 2431 | // Keep this around |
| 2432 | void ResetObjectOntoTerrain() { |
| 2433 | if (Cur_object_index != -1) { |
| 2434 | |
| 2435 | object *objp = &Objects[Cur_object_index]; |
| 2436 | |
| 2437 | if (!OBJECT_OUTSIDE(objp)) { |
| 2438 | int roomnum = GetTerrainRoomFromPos(&objp->pos); |
| 2439 | ObjSetPos(objp, &objp->pos, roomnum, NULL, true); |
| 2440 | |
| 2441 | EditorStatus("Object %d (\"%s\") moved to cell %d", OBJNUM(objp), objp->name ? objp->name : "<no name>", |
| 2442 | CELLNUM(roomnum)); |
| 2443 | |
| 2444 | World_changed = 1; |
| 2445 | } else |
| 2446 | EditorStatus("Object %d (\"%s\") already outside (on cell %d)", OBJNUM(objp), |
| 2447 | objp->name ? objp->name : "<no name>", CELLNUM(objp->roomnum)); |
| 2448 | } |
| 2449 | } |
| 2450 | |
| 2451 | // Keep this around |
| 2452 | void ResetObjectsIntoMine() { |
| 2453 | int i, objnum, count = 0; |
| 2454 | |
| 2455 | for (i = 0; i < TERRAIN_WIDTH * TERRAIN_DEPTH; i++) { |
| 2456 | if (TerrainSelected[i]) { |
| 2457 | for (objnum = Terrain_seg[i].objects; objnum != -1;) { |
| 2458 | object *objp = &Objects[objnum]; |
| 2459 | int next = objp->next; |
| 2460 | if ((objp->type != OBJ_VIEWER) && (objp->type != OBJ_ROOM)) { |
| 2461 | int roomnum = FindPointRoom(&objp->pos); |
| 2462 | if (roomnum == -1) |
| 2463 | OutrageMessageBox("Can't find room for object %d (type = %s)", objnum, Object_type_names[objp->type]); |
| 2464 | else { |
| 2465 | mprintf(0, "Moving object %d to room %d\n", objnum, roomnum); |
| 2466 | ObjSetPos(&Objects[objnum], &objp->pos, roomnum, NULL, true); |
| 2467 | count++; |
| 2468 | } |
| 2469 | } |
| 2470 | objnum = next; |
| 2471 | } |
| 2472 | } |
| 2473 | } |
| 2474 | |
| 2475 | OutrageMessageBox("%d objects were moved from the terrain to the mine.", count); |
| 2476 | |
| 2477 | World_changed = 1; |
| 2478 | } |
| 2479 | |
| 2480 | void DeleteAllFacesWithTexture1(room *rp) { |
| 2481 | int count = 0; |
| 2482 | |
| 2483 | if (OutrageMessageBox(MBOX_YESNO, "Are you sure you want to delete all faces in room %d that have texture 1?", |
| 2484 | ROOMNUM(rp)) != IDYES) |
| 2485 | return; |
| 2486 | |
| 2487 | for (int i = 0; i < rp->num_faces; i++) { |
| 2488 | if ((rp->faces[i].tmap == 1) && (rp->faces[i].portal_num == -1)) { |
| 2489 | DeleteRoomFace(rp, i); |
| 2490 | i--; |
| 2491 | count++; |
| 2492 | } |
| 2493 | } |
| 2494 | |
| 2495 | OutrageMessageBox("%d faces deleted from room %d.", count, ROOMNUM(rp)); |
| 2496 | |
| 2497 | Curface = Curedge = Curvert = 0; |
| 2498 | |
| 2499 | World_changed = 1; |
| 2500 | } |
| 2501 | |
| 2502 | // Put test code here. Feel free to delete any old code. |
| 2503 | |
| 2504 | extern float Room_multiplier[]; |
| 2505 | |
| 2506 | #include "lightmap_info.h" |
| 2507 | #include "lightmap.h" |
| 2508 | #include "polymodel.h" |
| 2509 | |
| 2510 | int IsNonRenderableSubmodel(poly_model *pm, int submodelnum); |
| 2511 | |
| 2512 | extern uint16_t *Free_lmi_list; |
| 2513 | |
| 2514 | void CMainFrame::OnTestTest1() { |
| 2515 | if (MessageBox("Do you really really want to murder the lightmaps?", "Confirm", MB_YESNO) != IDYES) |
| 2516 | return; |
| 2517 | |
| 2518 | // severly bash lightmaps |
| 2519 | int r, f; |
| 2520 | room *rp; |
| 2521 | face *fp; |
| 2522 | |
| 2523 | for (r = 0; r <= Highest_room_index; r++) { |
| 2524 | if (!Rooms[r].used) |
| 2525 | continue; |
| 2526 | rp = &Rooms[r]; |
| 2527 | for (f = 0; f < rp->num_faces; f++) { |
| 2528 | fp = &rp->faces[f]; |
| 2529 | fp->flags &= ~FF_LIGHTMAP; |
| 2530 | fp->lmi_handle = BAD_LMI_INDEX; |
| 2531 | } |
| 2532 | } |
| 2533 | |
| 2534 | // now free lightmap infos |
| 2535 | void CloseLightmapInfos(); |
| 2536 | CloseLightmapInfos(); |
| 2537 | InitLightmapInfo(0); |
| 2538 | Num_of_lightmap_info = 0; |
| 2539 | Num_lightmap_infos_read = 0; |
| 2540 | |
| 2541 | int i, m, t; |
| 2542 | for (i = 0; i < MAX_OBJECTS; i++) { |
| 2543 | if (!Objects[i].lm_object.used) |
| 2544 | continue; |
| 2545 | |
| 2546 | poly_model *pm = &Poly_models[Objects[i].rtype.pobj_info.model_num]; |
| 2547 | for (m = 0; m < pm->n_models; m++) { |
| 2548 | if (IsNonRenderableSubmodel(pm, m)) |
| 2549 | continue; |
| 2550 | |
| 2551 | for (t = 0; t < Objects[i].lm_object.num_faces[m]; t++) { |
| 2552 | lightmap_object_face *fp = &Objects[i].lm_object.lightmap_faces[m][t]; |
| 2553 | fp->lmi_handle = BAD_LMI_INDEX; |
| 2554 | mem_free(fp->u2); |
| 2555 | mem_free(fp->v2); |
| 2556 | } |
| 2557 | mem_free(Objects[i].lm_object.lightmap_faces[m]); |
| 2558 | } |
| 2559 | |
| 2560 | Objects[i].lm_object.used = 0; |
| 2561 | } |
| 2562 | } |
| 2563 | |
| 2564 | extern void dump_text_to_clipboard(char *text); |
| 2565 | |
| 2566 | // Make a list of all the rooms with names |
| 2567 | void ShowRooms() { |
| 2568 | char text_buf[10000], *t; |
| 2569 | int i, n; |
| 2570 | |
| 2571 | t = text_buf; |
| 2572 | sprintf(t, ""); |
| 2573 | for (i = n = 0; i <= Highest_room_index; i++) { |
| 2574 | if (Rooms[i].used && Rooms[i].name) { |
| 2575 | sprintf(t, "Room %d is named \"%s\"\n", i, Rooms[i].name); |
| 2576 | n++; |
| 2577 | t += strlen(t); |
| 2578 | if ((t - text_buf) > (sizeof(text_buf) - 200)) { |
| 2579 | sprintf(t, "Out of buffer space\n"); |
| 2580 | break; |
| 2581 | } |
| 2582 | } |
| 2583 | } |
| 2584 | |
| 2585 | dump_text_to_clipboard(text_buf); |
| 2586 | |
| 2587 | OutrageMessageBox("There are %d named rooms.\n\nThe list has been written to the clipboard.", n); |
| 2588 | } |
| 2589 | |
| 2590 | void ListAllObjects() { |
| 2591 | void ListObjectsInAllLevels(); |
| 2592 | extern bool Stay_paused; |
| 2593 | |
| 2594 | if (OutrageMessageBox(MBOX_YESNO, "This will take a long time.\n\nAre you sure you want to continue?") != IDYES) |
| 2595 | return; |
| 2596 | |
| 2597 | theApp.pause(); |
| 2598 | Stay_paused = 1; |
| 2599 | SetFunctionMode(EDITOR_GAME_MODE); // keep LoadLevel() from bringing up messages |
| 2600 | ListObjectsInAllLevels(); |
| 2601 | SetFunctionMode(EDITOR_MODE); |
| 2602 | Stay_paused = 0; |
| 2603 | theApp.resume(); |
| 2604 | |
| 2605 | OutrageMessageBox("Object infomation written to clipboard."); |
| 2606 | } |
| 2607 | |
| 2608 | void FindBadDestroyedTextures() { |
| 2609 | int count = 0; |
| 2610 | |
| 2611 | for (int i = 0; i < MAX_TEXTURES; i++) { |
| 2612 | if ((GameTextures[i].flags & TF_DESTROYABLE) && (GameTextures[i].destroy_handle == 0)) { |
| 2613 | mprintf(0, "Texture %d, \"%s\" has a bad destroyed bitmap\n", i, GameTextures[i].name); |
| 2614 | count++; |
| 2615 | } |
| 2616 | } |
| 2617 | |
| 2618 | OutrageMessageBox("Found %d bad destroyed textures.", count); |
| 2619 | } |
| 2620 | |
| 2621 | // Make a list of all the objects with lightmaps |
| 2622 | void ListLightmapObjects() { |
| 2623 | int count = 0, lm_count = 0; |
| 2624 | |
| 2625 | for (int i = 0; i <= Highest_object_index; i++) { |
| 2626 | if (Objects[i].type != OBJ_NONE) { |
| 2627 | count++; |
| 2628 | if (IS_GENERIC(Objects[i].type) && |
| 2629 | (Object_info[Objects[i].id].lighting_info.lighting_render_type == LRT_LIGHTMAPS)) { |
| 2630 | lm_count++; |
| 2631 | mprintf(0, "%d: %s %s", i, Object_type_names[Objects[i].type], Object_info[Objects[i].id].name); |
| 2632 | if (Objects[i].name) |
| 2633 | mprintf(0, " name=\"%s\"\n", Objects[i].name); |
| 2634 | else |
| 2635 | mprintf(0, "\n"); |
| 2636 | } else |
| 2637 | ; // mprintf(0,"%d ",i); |
| 2638 | } |
| 2639 | } |
| 2640 | mprintf(0, "Num object = %d. Num with lightmaps = %d\n", count, lm_count); |
| 2641 | } |
| 2642 | |
| 2643 | // Put test code here. Feel free to delete any old code. |
| 2644 | void CMainFrame::OnTestTest2() { FindBadDestroyedTextures(); } |
| 2645 | |
| 2646 | extern char error_buf[]; |
| 2647 | extern int error_buf_offset; |
| 2648 | void CheckError(const char *str, ...); |
| 2649 | uint32_t check_point_to_face(vector *colp, vector *face_normal, int nv, vector **vertex_ptr_list); |
| 2650 | |
| 2651 | void LookForFVICracks() { |
| 2652 | int r, f, v, edgemask, count = 0; |
| 2653 | room *rp; |
| 2654 | face *fp; |
| 2655 | |
| 2656 | error_buf_offset = 0; |
| 2657 | |
| 2658 | for (r = 0, rp = Rooms; r <= Highest_room_index; r++, rp++) { |
| 2659 | if (rp->used) { |
| 2660 | for (f = 0, fp = rp->faces; f < rp->num_faces; f++, fp++) { |
| 2661 | vector *vertex_ptr_list[MAX_VERTS_PER_FACE]; |
| 2662 | for (v = 0; v < fp->num_verts; v++) |
| 2663 | vertex_ptr_list[v] = &rp->verts[fp->face_verts[v]]; |
| 2664 | for (v = 0; v < fp->num_verts; v++) { |
| 2665 | edgemask = check_point_to_face(vertex_ptr_list[v], &fp->normal, fp->num_verts, vertex_ptr_list); |
| 2666 | if (edgemask) { |
| 2667 | CheckError("Vert %d is outside of %d:%d\n", v, r, f); |
| 2668 | count++; |
| 2669 | } |
| 2670 | } |
| 2671 | } |
| 2672 | } |
| 2673 | } |
| 2674 | |
| 2675 | DumpTextToClipboard(error_buf); |
| 2676 | |
| 2677 | OutrageMessageBox("Found %d FVI face cracks.", count); |
| 2678 | } |
| 2679 | |
| 2680 | void MoveEntireMine() { |
| 2681 | char buf[10] = ""; |
| 2682 | |
| 2683 | strcpy(buf, "0"); |
| 2684 | if (!InputString(buf, sizeof(buf), "Move Amount", "Enter an amount to move in X")) |
| 2685 | return; |
| 2686 | float delta_x = atof(buf); |
| 2687 | |
| 2688 | strcpy(buf, "0"); |
| 2689 | if (!InputString(buf, sizeof(buf), "Move Amount", "Enter an amount to move in Z")) |
| 2690 | return; |
| 2691 | float delta_z = atof(buf); |
| 2692 | |
| 2693 | int r; |
| 2694 | room *rp; |
| 2695 | |
| 2696 | for (r = 0, rp = Rooms; r <= Highest_room_index; r++, rp++) { |
| 2697 | if (rp->used) { |
| 2698 | for (int v = 0; v < rp->num_verts; v++) { |
| 2699 | rp->verts[v].x += delta_x; |
| 2700 | rp->verts[v].z += delta_z; |
| 2701 | } |
| 2702 | |
| 2703 | for (int objnum = rp->objects; objnum != -1; objnum = Objects[objnum].next) { |
| 2704 | Objects[objnum].pos.x += delta_x; |
| 2705 | Objects[objnum].pos.z += delta_z; |
| 2706 | } |
| 2707 | } |
| 2708 | } |
| 2709 | |
| 2710 | World_changed = 1; |
| 2711 | } |
| 2712 | |
| 2713 | void ScaleEntireMine() { |
| 2714 | char buf[10] = ""; |
| 2715 | |
| 2716 | if (!InputString(buf, sizeof(buf), "Scale Amount", "Enter an amount by which to scale the mine")) |
| 2717 | return; |
| 2718 | |
| 2719 | float scale = atof(buf); |
| 2720 | |
| 2721 | int r; |
| 2722 | room *rp; |
| 2723 | |
| 2724 | for (r = 0, rp = Rooms; r <= Highest_room_index; r++, rp++) { |
| 2725 | if (rp->used) { |
| 2726 | for (int v = 0; v < rp->num_verts; v++) |
| 2727 | rp->verts[v] *= scale; |
| 2728 | |
| 2729 | for (int objnum = rp->objects; objnum != -1; objnum = Objects[objnum].next) |
| 2730 | Objects[objnum].pos *= scale; |
| 2731 | } |
| 2732 | } |
| 2733 | |
| 2734 | World_changed = 1; |
| 2735 | } |
| 2736 | |
| 2737 | int CountSpecularFaces() { |
| 2738 | int i, t; |
| 2739 | int count = 0; |
| 2740 | |
| 2741 | for (i = 0; i < MAX_ROOMS; i++) { |
| 2742 | if (Rooms[i].used) { |
| 2743 | if (Rooms[i].flags & RF_NO_LIGHT) |
| 2744 | continue; |
| 2745 | |
| 2746 | room *rp = &Rooms[i]; |
| 2747 | |
| 2748 | for (t = 0; t < rp->num_faces; t++) { |
| 2749 | face *fp = &rp->faces[t]; |
| 2750 | if (GameTextures[fp->tmap].flags & TF_SPECULAR) { |
| 2751 | count++; |
| 2752 | } |
| 2753 | } |
| 2754 | } |
| 2755 | } |
| 2756 | |
| 2757 | return count; |
| 2758 | } |
| 2759 | |
| 2760 | // Put test code here. Feel free to delete any old code. |
| 2761 | void CMainFrame::OnTestTest3() { |
| 2762 | MoveEntireMine(); |
| 2763 | return; |
| 2764 | |
| 2765 | // ResetObjectsIntoMine(); |
| 2766 | |
| 2767 | // Check all powerups and make sure they all have physics on them (for spewing) |
| 2768 | CFILE *file = cfopen("C:\\physics.txt", "wt"); |
| 2769 | if (!file) |
| 2770 | return; |
| 2771 | |
| 2772 | char buffer[384]; |
| 2773 | |
| 2774 | for (int i = 0; i < MAX_OBJECT_IDS; i++) { |
| 2775 | if (Object_info[i].type == OBJ_NONE) |
| 2776 | continue; |
| 2777 | |
| 2778 | switch (Object_info[i].type) { |
| 2779 | case OBJ_POWERUP: { |
| 2780 | if (!(Object_info[i].flags & OIF_USES_PHYSICS)) { |
| 2781 | sprintf(buffer, "Powerup: %s", Object_info[i].name); |
| 2782 | cf_WriteString(file, buffer); |
| 2783 | } |
| 2784 | } break; |
| 2785 | case OBJ_CLUTTER: { |
| 2786 | if (!(Object_info[i].flags & OIF_USES_PHYSICS)) { |
| 2787 | sprintf(buffer, "Clutter: %s", Object_info[i].name); |
| 2788 | cf_WriteString(file, buffer); |
| 2789 | } |
| 2790 | } break; |
| 2791 | case OBJ_BUILDING: { |
| 2792 | if (!(Object_info[i].flags & OIF_USES_PHYSICS)) { |
| 2793 | sprintf(buffer, "Building: %s", Object_info[i].name); |
| 2794 | cf_WriteString(file, buffer); |
| 2795 | } |
| 2796 | } break; |
| 2797 | case OBJ_ROBOT: { |
| 2798 | if (!(Object_info[i].flags & OIF_USES_PHYSICS)) { |
| 2799 | sprintf(buffer, "Robot: %s", Object_info[i].name); |
| 2800 | cf_WriteString(file, buffer); |
| 2801 | } |
| 2802 | } break; |
| 2803 | } |
| 2804 | } |
| 2805 | |
| 2806 | cfclose(file); |
| 2807 | } |
| 2808 | |
| 2809 | int GetChangeMask() { |
| 2810 | static room *last_curroomp = NULL; |
| 2811 | static int last_curface = -1, last_curportal = -1, last_curobj = -1; |
| 2812 | static char last_name[OBJ_NAME_LEN + 1] = ""; |
| 2813 | |
| 2814 | int mask = 0; |
| 2815 | |
| 2816 | if (Cur_object_index != last_curobj) |
| 2817 | mask |= KUF_CUROBJ_CHANGED; |
| 2818 | last_curobj = Cur_object_index; |
| 2819 | |
| 2820 | if (Curroomp != last_curroomp) |
| 2821 | mask |= KUF_CURROOM_CHANGED; |
| 2822 | last_curroomp = Curroomp; |
| 2823 | |
| 2824 | if (Curface != last_curface) |
| 2825 | mask |= KUF_CURFACE_CHANGED; |
| 2826 | last_curface = Curface; |
| 2827 | |
| 2828 | if (Curportal != last_curportal) |
| 2829 | mask |= KUF_CURPORTAL_CHANGED; |
| 2830 | last_curportal = Curportal; |
| 2831 | |
| 2832 | if (Cur_object_index != -1) { |
| 2833 | char *name = Objects[Cur_object_index].name ? Objects[Cur_object_index].name : "<no name>"; |
| 2834 | if (strcmp(last_name, name)) |
| 2835 | mask |= KUF_CUROBJ_NAME_CHANGED; |
| 2836 | strcpy(last_name, name); |
| 2837 | } |
| 2838 | |
| 2839 | if (New_mine) |
| 2840 | mask |= KUF_LEVEL_LOADED; |
| 2841 | |
| 2842 | return mask; |
| 2843 | } |
| 2844 | |
| 2845 | // Called from the main idle function |
| 2846 | void CMainFrame::OnIdle() { |
| 2847 | // update keypads. |
| 2848 | int mask = GetChangeMask(); |
| 2849 | |
| 2850 | if (m_TextureDialog) { |
| 2851 | m_TextureDialog->UpdateKeypad(mask); |
| 2852 | } |
| 2853 | if (m_ObjectDialog) { |
| 2854 | m_ObjectDialog->UpdateKeypad(mask); |
| 2855 | } |
| 2856 | if (m_LightingDialog) { |
| 2857 | m_LightingDialog->UpdateKeypad(mask); |
| 2858 | } |
| 2859 | if (m_RoomDialog) { |
| 2860 | m_RoomDialog->UpdateKeypad(mask); |
| 2861 | } |
| 2862 | if (m_PathPadDialog) { |
| 2863 | m_PathPadDialog->UpdateKeypad(mask); |
| 2864 | } |
| 2865 | if (m_TriggerDialog) { |
| 2866 | m_TriggerDialog->UpdateKeypad(mask); |
| 2867 | } |
| 2868 | if (m_DoorwayDialog) { |
| 2869 | m_DoorwayDialog->UpdateKeypad(mask); |
| 2870 | } |
| 2871 | if (m_TerrainDialog) { |
| 2872 | m_TerrainDialog->UpdateKeypad(mask); |
| 2873 | } |
| 2874 | if (m_MegacellKeypad) { |
| 2875 | m_MegacellKeypad->UpdateKeypad(mask); |
| 2876 | } |
| 2877 | if (m_LevelDialog) { |
| 2878 | m_LevelDialog->UpdateKeypad(mask); |
| 2879 | } |
| 2880 | if (m_MatcenDialog) { |
| 2881 | m_MatcenDialog->UpdateKeypad(mask); |
| 2882 | } |
| 2883 | } |
| 2884 | |
| 2885 | BOOL CMainFrame::OnHelpInfo(HELPINFO *pHelpInfo) { |
| 2886 | // TODO: Add your message handler code here and/or call default |
| 2887 | return CFrameWnd::OnHelpInfo(pHelpInfo); |
| 2888 | } |
| 2889 | |
| 2890 | void CMainFrame::OnEditorsMegacells() { |
| 2891 | CMegacellDialog dlg; |
| 2892 | |
| 2893 | theApp.pause(); |
| 2894 | dlg.DoModal(); |
| 2895 | theApp.resume(); |
| 2896 | } |
| 2897 | |
| 2898 | void ReorderPages(int); |
| 2899 | void CMainFrame::OnReorderPages() { |
| 2900 | if (Network_up == 0) { |
| 2901 | OutrageMessageBox("The network is not up, so this function is unavailable."); |
| 2902 | return; |
| 2903 | } |
| 2904 | |
| 2905 | int answer = MessageBox("Are you absolutely positively sure you want to do this? I mean, if you have no idea what " |
| 2906 | "you are doing (ie, a level designer) then please - don't execute this function.", |
| 2907 | "EXTREME DANGER - YOU MIGHT DIE", MB_YESNO); |
| 2908 | |
| 2909 | if (answer == IDNO) { |
| 2910 | OutrageMessageBox("Damn that was close."); |
| 2911 | return; |
| 2912 | } |
| 2913 | ReorderPages(0); |
| 2914 | |
| 2915 | OutrageMessageBox("Done reordering pages!"); |
| 2916 | } |
| 2917 | |
| 2918 | void CMainFrame::OnFileImportRoom() { |
| 2919 | // Filter out the curious |
| 2920 | char filename[200]; |
| 2921 | |
| 2922 | CString filter = "Outrage 3dsmax files (*.p3d)|*.p3d||"; |
| 2923 | |
| 2924 | if (!OpenFileDialog(this, (LPCSTR)filter, filename, Current_room_dir, sizeof(Current_room_dir))) |
| 2925 | return; |
| 2926 | |
| 2927 | int n = Read3DSMaxFile(filename); |
| 2928 | |
| 2929 | if (n >= 0) { |
| 2930 | D3EditState.current_room = n; |
| 2931 | State_changed = 1; |
| 2932 | |
| 2933 | OutrageMessageBox("Room imported and saved locally.\n\nPress OK to check room validity."); |
| 2934 | VerifyRoom(&Rooms[n]); |
| 2935 | } |
| 2936 | |
| 2937 | theApp.resume(); |
| 2938 | } |
| 2939 | |
| 2940 | void CMainFrame::OnObjectMovePlayer() { HObjectMoveToViewer(Player_object); } |
| 2941 | |
| 2942 | // Set the editor view mode |
| 2943 | void SetViewMode(int view_mode) { |
| 2944 | // Set new view mode |
| 2945 | Editor_view_mode = view_mode; |
| 2946 | |
| 2947 | // Get the correct viewer (terrain or mine or room) |
| 2948 | SetEditorViewer(); |
| 2949 | |
| 2950 | // Set the correct wireframe view |
| 2951 | if (view_mode == VM_ROOM) |
| 2952 | Wireframe_view = &Wireframe_view_room; |
| 2953 | else if (view_mode == VM_MINE) |
| 2954 | Wireframe_view = &Wireframe_view_mine; |
| 2955 | |
| 2956 | // Force the windows to update |
| 2957 | AfxGetMainWnd()->Invalidate(TRUE); |
| 2958 | AfxGetMainWnd()->UpdateWindow(); |
| 2959 | } |
| 2960 | |
| 2961 | void CMainFrame::OnRoomView() { SetViewMode(VM_ROOM); } |
| 2962 | |
| 2963 | void CMainFrame::OnTerrainView() { SetViewMode(VM_TERRAIN); } |
| 2964 | |
| 2965 | void CMainFrame::OnMineView() { |
| 2966 | // Make sure there's a room to switch to |
| 2967 | int roomnum; |
| 2968 | for (roomnum = 0; roomnum <= Highest_room_index; roomnum++) |
| 2969 | if (Rooms[roomnum].used && !(Rooms[roomnum].flags & RF_EXTERNAL)) |
| 2970 | break; |
| 2971 | |
| 2972 | if (roomnum > Highest_room_index) { |
| 2973 | OutrageMessageBox("Cannot switch to Mine View: there are no internal rooms."); |
| 2974 | return; |
| 2975 | } |
| 2976 | |
| 2977 | SetViewMode(VM_MINE); |
| 2978 | } |
| 2979 | |
| 2980 | void CMainFrame::OnUpdateMineView(CCmdUI *pCmdUI) { |
| 2981 | // TODO: Add your command update UI handler code here |
| 2982 | pCmdUI->SetRadio(Editor_view_mode == VM_MINE); |
| 2983 | } |
| 2984 | |
| 2985 | void CMainFrame::OnUpdateRoomView(CCmdUI *pCmdUI) { |
| 2986 | // TODO: Add your command update UI handler code here |
| 2987 | int start, end, roomnum; |
| 2988 | bool room_loaded = false; |
| 2989 | |
| 2990 | start = FIRST_PALETTE_ROOM; |
| 2991 | end = start + MAX_PALETTE_ROOMS; |
| 2992 | |
| 2993 | for (roomnum = start; roomnum < end; roomnum++) |
| 2994 | if (Rooms[roomnum].used) { |
| 2995 | room_loaded = true; |
| 2996 | break; |
| 2997 | } |
| 2998 | |
| 2999 | if (!room_loaded) |
| 3000 | pCmdUI->Enable(false); |
| 3001 | else { |
| 3002 | pCmdUI->Enable(true); |
| 3003 | pCmdUI->SetRadio(Editor_view_mode == VM_ROOM); |
| 3004 | } |
| 3005 | } |
| 3006 | |
| 3007 | void CMainFrame::OnUpdateTerrainView(CCmdUI *pCmdUI) { |
| 3008 | // TODO: Add your command update UI handler code here |
| 3009 | pCmdUI->SetRadio(Editor_view_mode == VM_TERRAIN); |
| 3010 | } |
| 3011 | |
| 3012 | void CMainFrame::OnViewNewviewer() { CreateNewViewer(); } |
| 3013 | |
| 3014 | void CMainFrame::OnViewNextviewer() { SelectNextViewer(); } |
| 3015 | |
| 3016 | void CMainFrame::OnViewDeleteviewer() { DeleteViewer(); } |
| 3017 | |
| 3018 | void CMainFrame::OnD3help() { |
| 3019 | // TODO: Add your command handler code here |
| 3020 | WinHelp(HID_GENERAL, HELP_CONTEXT); |
| 3021 | } |
| 3022 | |
| 3023 | // void InitScriptEditor(bool level_script=true); |
| 3024 | |
| 3025 | /* |
| 3026 | void InitScriptEditor(bool level_script) |
| 3027 | { |
| 3028 | int size; |
| 3029 | bool locked=true; |
| 3030 | CScriptEditorDlg editor; |
| 3031 | |
| 3032 | ASSERT(Current_level_script); |
| 3033 | |
| 3034 | // Check to see if we even have default script locked |
| 3035 | if ((!level_script) && ((mng_FindTrackLock ("Default.scr",PAGETYPE_GAMEFILE))==-1)) |
| 3036 | { |
| 3037 | OutrageMessageBox ("Warning: You are trying to edit the Default script,but it's not locked. If you want |
| 3038 | to save your work, lock first."); locked=false; |
| 3039 | } |
| 3040 | |
| 3041 | |
| 3042 | if(strlen(Default_external_editor)==0) |
| 3043 | { |
| 3044 | char buffer[256]; |
| 3045 | CString default_path; |
| 3046 | size=GetWindowsDirectory(buffer,256); |
| 3047 | ASSERT(size<256); |
| 3048 | buffer[size]='\\'; |
| 3049 | buffer[size+1]='\0'; |
| 3050 | |
| 3051 | default_path=buffer; |
| 3052 | default_path+="Notepad.exe"; |
| 3053 | editor.SetExternalEditor(default_path.GetBuffer(1)); |
| 3054 | } |
| 3055 | else |
| 3056 | { |
| 3057 | editor.SetExternalEditor(Default_external_editor); |
| 3058 | } |
| 3059 | |
| 3060 | if(level_script) |
| 3061 | { |
| 3062 | editor.SetScript(Current_level_script, Level_script_prog); |
| 3063 | } |
| 3064 | else |
| 3065 | { |
| 3066 | if(!LoadDefaultScript()) return; |
| 3067 | ASSERT(Default_script); |
| 3068 | editor.SetScript(Default_script, Default_script_prog); |
| 3069 | } |
| 3070 | |
| 3071 | |
| 3072 | if(editor.DoModal()==IDOK) |
| 3073 | { |
| 3074 | if(level_script) |
| 3075 | { |
| 3076 | if(Current_level_script) mem_free(Current_level_script); |
| 3077 | Current_level_script = (char *) mem_malloc(lstrlen(editor.GetScript())+1); |
| 3078 | if(Current_level_script) |
| 3079 | strcpy(Current_level_script,editor.GetScript()); |
| 3080 | else |
| 3081 | OutrageMessageBox("Couldn't allocate memory to save script!"); |
| 3082 | } |
| 3083 | else |
| 3084 | { |
| 3085 | if(!locked) |
| 3086 | { |
| 3087 | OutrageMessageBox("Default script wasn't locked...not saving\n"); |
| 3088 | } |
| 3089 | else |
| 3090 | { |
| 3091 | if(Default_script) mem_free(Default_script); |
| 3092 | Default_script = (char *) mem_malloc(editor.GetScriptLength()); |
| 3093 | if(Default_script) |
| 3094 | strcpy(Default_script,editor.GetScript()); |
| 3095 | else |
| 3096 | OutrageMessageBox("Couldn't allocate memory to save script!"); |
| 3097 | OutrageMessageBox("Don't forget to check back in the default script\n"); |
| 3098 | } |
| 3099 | } |
| 3100 | |
| 3101 | //Try and compile now |
| 3102 | bool exit_ok=false; |
| 3103 | |
| 3104 | if (!CompileScript(editor.GetScript(), editor.m_Program)) |
| 3105 | { |
| 3106 | OutrageMessageBox("WARNING!!!: Your script did not compile correctly, please fix!"); |
| 3107 | if(editor.DoModal()==IDOK) exit_ok=true; |
| 3108 | } |
| 3109 | |
| 3110 | //Save the script if the selected Save and Exit |
| 3111 | if(exit_ok) |
| 3112 | { |
| 3113 | //one last try to compile |
| 3114 | if (!CompileScript(editor.GetScript(), editor.m_Program)) |
| 3115 | { |
| 3116 | OutrageMessageBox("WARNING!!!: Your script still did not compile correctly!"); |
| 3117 | } |
| 3118 | |
| 3119 | if(level_script) |
| 3120 | { |
| 3121 | if(Current_level_script) mem_free(Current_level_script); |
| 3122 | Current_level_script = (char *) mem_malloc(lstrlen(editor.GetScript())+1); |
| 3123 | if(Current_level_script) |
| 3124 | strcpy(Current_level_script,editor.GetScript()); |
| 3125 | else |
| 3126 | OutrageMessageBox("Couldn't allocate memory to save script!"); |
| 3127 | } |
| 3128 | else |
| 3129 | { |
| 3130 | if(!locked) |
| 3131 | { |
| 3132 | OutrageMessageBox("Default script wasn't locked...not saving\n"); |
| 3133 | } |
| 3134 | else |
| 3135 | { |
| 3136 | if(Default_script) free(Default_script); |
| 3137 | Default_script = (char *) mem_malloc(editor.GetScriptLength()); |
| 3138 | if(Default_script) |
| 3139 | strcpy(Default_script,editor.GetScript()); |
| 3140 | else |
| 3141 | OutrageMessageBox("Couldn't allocate memory to save script!"); |
| 3142 | OutrageMessageBox("Don't forget to check back in the default script\n"); |
| 3143 | } |
| 3144 | } |
| 3145 | } |
| 3146 | } |
| 3147 | |
| 3148 | if(strcmp(editor.m_ExternalEditor,Default_external_editor)) |
| 3149 | { |
| 3150 | strcpy(Default_external_editor,editor.m_ExternalEditor.GetBuffer(1)); |
| 3151 | } |
| 3152 | |
| 3153 | if(!level_script) SaveDefaultScript(true); |
| 3154 | |
| 3155 | } |
| 3156 | */ |
| 3157 | |
| 3158 | // Takes a TGA and extracts the hotspot map and ogf from it |
| 3159 | void CMainFrame::OnHotspotTga() { |
| 3160 | // TODO: Add your command handler code here |
| 3161 | CString tga_filter = "TGA (*.tga)|*.tga|All Files (*.*)|*.*||"; |
| 3162 | CString tga_path; |
| 3163 | char *buffer; |
| 3164 | int anim = 0, bm_handle; |
| 3165 | char filename[200]; |
| 3166 | |
| 3167 | CFileDialog dlg(true, 0, 0, OFN_FILEMUSTEXIST, (LPCTSTR)tga_filter, this); |
| 3168 | |
| 3169 | if (dlg.DoModal() == IDOK) { |
| 3170 | tga_path = dlg.GetPathName(); |
| 3171 | } else { |
| 3172 | return; |
| 3173 | } |
| 3174 | |
| 3175 | buffer = (char *)mem_malloc(strlen(tga_path.GetBuffer(1)) + 1); |
| 3176 | if (!buffer) { |
| 3177 | Int3(); // find Jeff |
| 3178 | return; |
| 3179 | } |
| 3180 | strcpy(buffer, tga_path.GetBuffer(1)); |
| 3181 | if (menutga_ConvertTGAtoHSM(buffer)) |
| 3182 | OutrageMessageBox("HotSpot Map Extracted"); |
| 3183 | |
| 3184 | bm_handle = LoadTextureImage(buffer, &anim, NOT_TEXTURE, 0); |
| 3185 | |
| 3186 | if (bm_handle < 0) { |
| 3187 | OutrageMessageBox("Couldn't open that bitmap/anim file."); |
| 3188 | return; |
| 3189 | } |
| 3190 | |
| 3191 | if (!anim) { |
| 3192 | sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(), GameBitmaps[bm_handle].name); |
| 3193 | bm_SaveFileBitmap(filename, bm_handle); |
| 3194 | bm_FreeBitmap(bm_handle); |
| 3195 | } |
| 3196 | |
| 3197 | if (buffer) |
| 3198 | mem_free(buffer); |
| 3199 | } |
| 3200 | |
| 3201 | void CMainFrame::OnEditorsFiles() { |
| 3202 | CFilePageDialog dlg; |
| 3203 | |
| 3204 | theApp.pause(); |
| 3205 | dlg.DoModal(); |
| 3206 | theApp.resume(); |
| 3207 | } |
| 3208 | |
| 3209 | void CMainFrame::OnUpdateEditAttach(CCmdUI *pCmdUI) { pCmdUI->Enable(Placed_group != NULL); } |
| 3210 | |
| 3211 | void CMainFrame::OnUpdateEditSaveScrap(CCmdUI *pCmdUI) { pCmdUI->Enable(Scrap != NULL); } |
| 3212 | |
| 3213 | void CMainFrame::OnFileLevelProps() { |
| 3214 | CLevelDialog dlg(this); |
| 3215 | |
| 3216 | dlg.DoModal(); |
| 3217 | } |
| 3218 | |
| 3219 | void CMainFrame::OnObjbutton() { |
| 3220 | if (m_ObjModeless) { |
| 3221 | RECT rect; |
| 3222 | m_ObjModeless->GetWindowRect(&rect); |
| 3223 | GetActiveFrame()->ScreenToClient(&rect); |
| 3224 | D3EditState.objmodeless_x = rect.left; |
| 3225 | D3EditState.objmodeless_y = rect.top; |
| 3226 | D3EditState.objmodeless_on = false; |
| 3227 | m_ObjModeless->DestroyWindow(); |
| 3228 | m_ObjModeless = NULL; |
| 3229 | } else { |
| 3230 | m_ObjModeless = new CObjectListModeless(this); |
| 3231 | m_ObjModeless->Create(); |
| 3232 | m_ObjModeless->SetWindowPos(this, D3EditState.objmodeless_x, D3EditState.objmodeless_y, -1, -1, SWP_NOSIZE); |
| 3233 | m_ObjModeless->ShowWindow(SW_SHOW); |
| 3234 | D3EditState.objmodeless_on = true; |
| 3235 | } |
| 3236 | } |
| 3237 | |
| 3238 | void CMainFrame::OnUpdateObjbutton(CCmdUI *pCmdUI) { |
| 3239 | if (m_ObjModeless && !D3EditState.objmodeless_on) { |
| 3240 | m_ObjModeless = NULL; |
| 3241 | } |
| 3242 | |
| 3243 | pCmdUI->SetCheck(D3EditState.objmodeless_on); |
| 3244 | } |
| 3245 | |
| 3246 | void CMainFrame::OnObjectSetCameraFromViewer() { |
| 3247 | object *objp = &Objects[Cur_object_index]; |
| 3248 | |
| 3249 | if (objp->type != OBJ_CAMERA) { |
| 3250 | OutrageMessageBox("The current object must be a camera for this operation."); |
| 3251 | return; |
| 3252 | } |
| 3253 | |
| 3254 | ObjSetPos(objp, &Viewer_object->pos, Viewer_object->roomnum, &Viewer_object->orient, false); |
| 3255 | |
| 3256 | EditorStatus("Camera object %d moved to viewer", Cur_object_index); |
| 3257 | |
| 3258 | World_changed = 1; |
| 3259 | } |
| 3260 | |
| 3261 | void CMainFrame::OnObjectPlaceCameraAtViewer() { |
| 3262 | int objnum; |
| 3263 | |
| 3264 | objnum = ObjCreate(OBJ_CAMERA, 0, Viewer_object->roomnum, &Viewer_object->pos, &Viewer_object->orient); |
| 3265 | |
| 3266 | if (objnum == -1) { |
| 3267 | Int3(); |
| 3268 | return; |
| 3269 | } |
| 3270 | |
| 3271 | EditorStatus("Camera created as object %d\n", objnum); |
| 3272 | |
| 3273 | World_changed = 1; |
| 3274 | } |
| 3275 | |
| 3276 | void CMainFrame::OnObjectPlaceCameraAtCurrentFace() { |
| 3277 | vector pos; |
| 3278 | matrix orient; |
| 3279 | int objnum; |
| 3280 | int roomnum; |
| 3281 | |
| 3282 | ComputeCenterPointOnFace(&pos, Curroomp, Curface); |
| 3283 | vm_VectorAngleToMatrix(&orient, &Curroomp->faces[Curface].normal, 0); |
| 3284 | |
| 3285 | if (Curroomp->flags & RF_EXTERNAL) { |
| 3286 | roomnum = GetTerrainRoomFromPos(&pos); |
| 3287 | } else { |
| 3288 | roomnum = ROOMNUM(Curroomp); |
| 3289 | } |
| 3290 | |
| 3291 | objnum = ObjCreate(OBJ_CAMERA, 0, roomnum, &pos, &orient); |
| 3292 | |
| 3293 | if (objnum == -1) { |
| 3294 | Int3(); |
| 3295 | return; |
| 3296 | } |
| 3297 | |
| 3298 | EditorStatus("Camera created as object %d\n", objnum); |
| 3299 | |
| 3300 | World_changed = 1; |
| 3301 | } |
| 3302 | |
| 3303 | void CMainFrame::OnObjectSetViewerFromCamera() { |
| 3304 | object *objp = &Objects[Cur_object_index]; |
| 3305 | |
| 3306 | if (objp->type != OBJ_CAMERA) { |
| 3307 | OutrageMessageBox("The current object must be a camera for this operation."); |
| 3308 | return; |
| 3309 | } |
| 3310 | |
| 3311 | MoveViewer(&objp->pos, objp->roomnum, &objp->orient); |
| 3312 | |
| 3313 | EditorStatus("Viewer moved to object %d", Cur_object_index); |
| 3314 | |
| 3315 | World_changed = 1; |
| 3316 | } |
| 3317 | |
| 3318 | #include "LevelInfoDialog.h" |
| 3319 | |
| 3320 | void CMainFrame::OnFileLevelInfo() { |
| 3321 | CLevelInfoDialog dlg(&Level_info); |
| 3322 | |
| 3323 | dlg.DoModal(); |
| 3324 | } |
| 3325 | |
| 3326 | void CMainFrame::OnFileStats() { ShowLevelStats(); } |
| 3327 | |
| 3328 | void CMainFrame::OnFileVerifyLevel() { VerifyMine(); } |
| 3329 | |
| 3330 | void CMainFrame::OnSubEditorsTableFileEdit() { |
| 3331 | // TODO: Add your command handler code here |
| 3332 | CTableFileEdit dlg; |
| 3333 | |
| 3334 | // theApp.pause(); |
| 3335 | dlg.DoModal(); |
| 3336 | // theApp.resume(); |
| 3337 | } |
| 3338 | |
| 3339 | void CMainFrame::OnEditorsAmbientSounds() { |
| 3340 | CAmbientSoundPattern dlg; |
| 3341 | |
| 3342 | theApp.pause(); |
| 3343 | dlg.DoModal(); |
| 3344 | theApp.resume(); |
| 3345 | } |
| 3346 | |
| 3347 | void CMainFrame::OnBriefingEditor() { |
| 3348 | CBriefEdit dlg; |
| 3349 | dlg.DoModal(); |
| 3350 | ddio_KeyFlush(); |
| 3351 | } |
| 3352 | |
| 3353 | void CMainFrame::OnScriptLevelInterface() { |
| 3354 | CScriptLevelInterface dlg; |
| 3355 | dlg.DoModal(); |
| 3356 | ddio_KeyFlush(); |
| 3357 | } |
| 3358 | |
| 3359 | void CMainFrame::OnFileFixCracks() { FixCracks(); } |
| 3360 | |
| 3361 | void CMainFrame::OnViewResetViewRadius() { ResetWireframeViewRad(); } |
| 3362 | |
| 3363 | void CMainFrame::OnSubeditorsTablefilefilter() { |
| 3364 | // TODO: Add your command handler code here |
| 3365 | TableFileFilter dlg; |
| 3366 | |
| 3367 | dlg.DoModal(); |
| 3368 | } |
| 3369 | |
| 3370 | void CMainFrame::OnViewShowObjectsInWireframeView() { |
| 3371 | D3EditState.objects_in_wireframe = !D3EditState.objects_in_wireframe; |
| 3372 | |
| 3373 | State_changed = 1; |
| 3374 | } |
| 3375 | |
| 3376 | void CMainFrame::OnUpdateViewShowObjectsInWireframeView(CCmdUI *pCmdUI) { |
| 3377 | pCmdUI->SetCheck((BOOL)D3EditState.objects_in_wireframe); |
| 3378 | } |
| 3379 | |
| 3380 | void CMainFrame::OnEditorsDallas() { |
| 3381 | if (theApp.m_DallasModelessDlgPtr == NULL) { |
| 3382 | theApp.m_DallasModelessDlgPtr = new CDallasMainDlg; |
| 3383 | theApp.m_DallasModelessDlgPtr->Create(IDD_DALLAS_MAIN_DIALOG, this); |
| 3384 | theApp.m_DallasModelessDlgPtr->ShowWindow(SW_SHOW); |
| 3385 | } else |
| 3386 | theApp.m_DallasModelessDlgPtr->ShowWindow(SW_RESTORE); |
| 3387 | } |
| 3388 | |
| 3389 | void CMainFrame::OnUpdateOsiriscompile(CCmdUI *pCmdUI) { |
| 3390 | // TODO: Add your command update UI handler code here |
| 3391 | } |
| 3392 | |
| 3393 | void CMainFrame::OnOsiriscompile() { |
| 3394 | CScriptMassCompile dlg; |
| 3395 | dlg.DoModal(); |
| 3396 | } |
| 3397 | |
| 3398 | // Copied here from HObject.cpp |
| 3399 | #define OBJECT_PLACE_DIST 10.0 |
| 3400 | bool MoveObject(object *obj, vector *newpos); |
| 3401 | |
| 3402 | void CMainFrame::OnViewMoveCameraToCurrentObject() { |
| 3403 | object *objp = &Objects[Cur_object_index]; |
| 3404 | vector pos; |
| 3405 | matrix orient; |
| 3406 | fvi_query fq; |
| 3407 | fvi_info hit_info; |
| 3408 | |
| 3409 | // Turn the viewer around so facing the object |
| 3410 | orient.fvec = -objp->orient.fvec; |
| 3411 | orient.rvec = -objp->orient.rvec; |
| 3412 | orient.uvec = objp->orient.uvec; |
| 3413 | |
| 3414 | // Move the viewer to the object |
| 3415 | MoveViewer(&objp->pos, objp->roomnum, &orient); |
| 3416 | |
| 3417 | // Calculate a position a little in front of the object |
| 3418 | pos = Viewer_object->pos - (Viewer_object->orient.fvec * OBJECT_PLACE_DIST); |
| 3419 | |
| 3420 | // Follow vector from start position to desired end position, & move as far as we can |
| 3421 | fq.p0 = &Viewer_object->pos; |
| 3422 | fq.startroom = Viewer_object->roomnum; |
| 3423 | fq.p1 = &pos; |
| 3424 | fq.thisobjnum = OBJNUM(Viewer_object); |
| 3425 | fq.ignore_obj_list = NULL; |
| 3426 | fq.flags = 0; |
| 3427 | fq.rad = 0.0; |
| 3428 | |
| 3429 | fvi_FindIntersection(&fq, &hit_info); |
| 3430 | |
| 3431 | // Move the viewer to the new position |
| 3432 | MoveViewer(&hit_info.hit_pnt, hit_info.hit_room, NULL); |
| 3433 | } |
| 3434 | |
| 3435 | void SelectObject(int objnum); |
| 3436 | |
| 3437 | void CMainFrame::OnObjectSelectByNumber() { |
| 3438 | int n; |
| 3439 | |
| 3440 | if (InputNumber(&n, "Select Object", "Enter object number to select", this)) { |
| 3441 | |
| 3442 | if ((n > Highest_object_index) || (Objects[n].type == OBJ_NONE)) { |
| 3443 | OutrageMessageBox("Invalid object number."); |
| 3444 | return; |
| 3445 | } |
| 3446 | |
| 3447 | SelectObject(n); |
| 3448 | } |
| 3449 | } |
| 3450 | |
| 3451 | #include "manage.h" |
| 3452 | #define MAX_LOCKLIST_ELEMENTS 1000 |
| 3453 | extern const char *PageNames[]; |
| 3454 | extern void dump_text_to_clipboard(char *text); |
| 3455 | |
| 3456 | void CMainFrame::OnShowAllCheckedOut() { |
| 3457 | char text_buf[10000], *t; |
| 3458 | |
| 3459 | // Get all locked pages |
| 3460 | mngs_Pagelock *LockList = (mngs_Pagelock *)mem_malloc(MAX_LOCKLIST_ELEMENTS * sizeof(mngs_Pagelock)); |
| 3461 | int n = mng_GetListOfLocks(LockList, MAX_LOCKLIST_ELEMENTS, NULL); |
| 3462 | |
| 3463 | // ASSERT(n >= 1); //always dummy page? |
| 3464 | // ASSERT(!strcmp(LockList[0].name,"DUMMY PAGE")); |
| 3465 | |
| 3466 | sprintf(text_buf, "Locked pages:\n"); |
| 3467 | t = text_buf + strlen(text_buf); |
| 3468 | for (int i = 0; i < n; i++) { |
| 3469 | sprintf(t, " Type %s, Page = <%s>, Locker = <%s>\n", PageNames[LockList[i].pagetype], LockList[i].name, |
| 3470 | LockList[i].holder); |
| 3471 | t += strlen(t); |
| 3472 | if ((t - text_buf) > (sizeof(text_buf) - 200)) { |
| 3473 | sprintf(t, "Out of buffer space\n"); |
| 3474 | break; |
| 3475 | } |
| 3476 | } |
| 3477 | |
| 3478 | mem_free(LockList); |
| 3479 | |
| 3480 | dump_text_to_clipboard(text_buf); |
| 3481 | |
| 3482 | OutrageMessageBox("%d pages are checked out.\n\nThe list has been written to the clipboard.", n); |
| 3483 | } |
| 3484 | |
| 3485 | void CMainFrame::OnViewShowViewerForwardVector() { |
| 3486 | EditorStatus("Viewer forward vector: %.3f, %.3f, %.3f", Viewer_object->orient.fvec.x + 0.0005, |
| 3487 | Viewer_object->orient.fvec.y + 0.0005, Viewer_object->orient.fvec.z + 0.0005); |
| 3488 | } |
| 3489 | |
| 3490 | void CMainFrame::OnObjectPlaceSoundSourceAtViewer() { |
| 3491 | int objnum; |
| 3492 | |
| 3493 | objnum = ObjCreate(OBJ_SOUNDSOURCE, 0, Viewer_object->roomnum, &Viewer_object->pos, &Viewer_object->orient); |
| 3494 | |
| 3495 | if (objnum == -1) { |
| 3496 | Int3(); |
| 3497 | return; |
| 3498 | } |
| 3499 | |
| 3500 | object *objp = &Objects[objnum]; |
| 3501 | objp->ctype.soundsource_info.sound_index = -1; |
| 3502 | objp->ctype.soundsource_info.volume = 1.0; |
| 3503 | |
| 3504 | EditorStatus("SoundSource created as object %d\n", objnum); |
| 3505 | |
| 3506 | World_changed = 1; |
| 3507 | } |
| 3508 | |
| 3509 | #include "OrphanRemoveDlg.h" |
| 3510 | void CMainFrame::OnOrphanhunter() { |
| 3511 | COrphanRemoveDlg dlg; |
| 3512 | dlg.DoModal(); |
| 3513 | } |
| 3514 | |
| 3515 | #include "player.h" |
| 3516 | |
| 3517 | void CMainFrame::OnObjectPlaceWaypointAtViewer() { |
| 3518 | int objnum; |
| 3519 | int count = 0; |
| 3520 | |
| 3521 | // Count the number of waypoints |
| 3522 | for (int i = 0; i <= Highest_object_index; i++) |
| 3523 | if (Objects[i].type == OBJ_WAYPOINT) |
| 3524 | count++; |
| 3525 | |
| 3526 | if (count >= MAX_WAYPOINTS) { |
| 3527 | EditorMessageBox("Cannot add waypoint: Already at maximum number of waypoints."); |
| 3528 | return; |
| 3529 | } |
| 3530 | |
| 3531 | // Check for waypoint already in this room |
| 3532 | if (OBJECT_OUTSIDE(Viewer_object)) |
| 3533 | objnum = Terrain_seg[CELLNUM(Viewer_object->roomnum)].objects; |
| 3534 | else |
| 3535 | objnum = Rooms[Viewer_object->roomnum].objects; |
| 3536 | |
| 3537 | for (objnum = Rooms[Viewer_object->roomnum].objects; objnum != -1; objnum = Objects[objnum].next) { |
| 3538 | if (Objects[objnum].type == OBJ_WAYPOINT) { |
| 3539 | EditorMessageBox("Cannot add waypoint: There's alerady a waypoint in this room (object %d)", objnum); |
| 3540 | return; |
| 3541 | } |
| 3542 | } |
| 3543 | |
| 3544 | objnum = ObjCreate(OBJ_WAYPOINT, 0, Viewer_object->roomnum, &Viewer_object->pos, &Viewer_object->orient); |
| 3545 | |
| 3546 | if (objnum == -1) { |
| 3547 | Int3(); |
| 3548 | return; |
| 3549 | } |
| 3550 | |
| 3551 | EditorStatus("Waypoint created as object %d\n", objnum); |
| 3552 | |
| 3553 | World_changed = 1; |
| 3554 | } |
| 3555 | |
| 3556 | #include "levelgoal.h" |
| 3557 | |
| 3558 | // Writes the level goal text to a file for localization |
| 3559 | void DumpLevelGoals(char *outname, char *levelname) { |
| 3560 | int n_goals = Level_goals.GetNumGoals(); |
| 3561 | char buf[1000]; |
| 3562 | CFILE *ofile; |
| 3563 | |
| 3564 | ofile = cfopen(outname, "wt"); |
| 3565 | |
| 3566 | if (!ofile) |
| 3567 | return; |
| 3568 | |
| 3569 | cfprintf(ofile, "!/!Level strings for %s\n\n", levelname); |
| 3570 | |
| 3571 | cfprintf(ofile, "!/!Notes on Localizing This File\n"); |
| 3572 | cfprintf(ofile, "!/!\n"); |
| 3573 | cfprintf(ofile, "!/!Line Tokens:\n"); |
| 3574 | cfprintf(ofile, "!/!\n"); |
| 3575 | cfprintf(ofile, "!/! Each non-blank line begins with one of the following tokens that\n"); |
| 3576 | cfprintf(ofile, "!/! identifies it as either a comment or a string in a particular\n"); |
| 3577 | cfprintf(ofile, "!/! language:\n"); |
| 3578 | cfprintf(ofile, "!/!\n"); |
| 3579 | cfprintf(ofile, "!/! !/! = comment (optional)\n"); |
| 3580 | cfprintf(ofile, "!/! !=! = English version of string\n"); |
| 3581 | cfprintf(ofile, "!/! !G! = German version of string\n"); |
| 3582 | cfprintf(ofile, "!/! !S! = Spanish version of string\n"); |
| 3583 | cfprintf(ofile, "!/! !I! = Italian version of string\n"); |
| 3584 | cfprintf(ofile, "!/! !F! = French version of string\n"); |
| 3585 | cfprintf(ofile, "!/!\n"); |
| 3586 | cfprintf(ofile, "!/!Rules:\n"); |
| 3587 | cfprintf(ofile, "!/!\n"); |
| 3588 | cfprintf(ofile, "!/! 1. There must be an English version of each string.\n"); |
| 3589 | cfprintf(ofile, "!/!\n"); |
| 3590 | cfprintf(ofile, "!/! 2. All text when translated should stay very near the\n"); |
| 3591 | cfprintf(ofile, "!/! length of the English version, unless otherwise noted.\n"); |
| 3592 | cfprintf(ofile, "!/!\n"); |
| 3593 | cfprintf(ofile, "!/! 3. The maximum length of any line is 1024 characters.\n"); |
| 3594 | cfprintf(ofile, "!/!\n"); |
| 3595 | cfprintf(ofile, "!/! 4. All %%s,%%d,%%f and similar tokens MUST stay in the string.\n"); |
| 3596 | cfprintf(ofile, "!/! In the game, these tokens will be replaced by:\n"); |
| 3597 | cfprintf(ofile, "!/!\n"); |
| 3598 | cfprintf(ofile, "!/! %%s = another string\n"); |
| 3599 | cfprintf(ofile, "!/! %%d = an integer number\n"); |
| 3600 | cfprintf(ofile, "!/! %%f = a floating point number (a number with a decimal point)\n"); |
| 3601 | cfprintf(ofile, "!/!\n"); |
| 3602 | cfprintf(ofile, "!/! These tokens MUST stay in the same relative order (i.e. in the\n"); |
| 3603 | cfprintf(ofile, "!/! string \"%%s got %%d points\" the %%s must always come before the %%d).\n"); |
| 3604 | cfprintf(ofile, "!/!\n"); |
| 3605 | cfprintf(ofile, "!/!Special Characters:\n"); |
| 3606 | cfprintf(ofile, "!/!\n"); |
| 3607 | cfprintf(ofile, "!/! Special characters can be inserted in strings with the following tokens:\n"); |
| 3608 | cfprintf(ofile, "!/!\n"); |
| 3609 | cfprintf(ofile, "!/! \\t = tab\n"); |
| 3610 | cfprintf(ofile, "!/! \\n = newline\n"); |
| 3611 | cfprintf(ofile, "!/! \\0 - \\255 = specific ASCII character\n"); |
| 3612 | cfprintf(ofile, "\n\n"); |
| 3613 | |
| 3614 | for (int i = 0; i < n_goals; i++) { |
| 3615 | |
| 3616 | Level_goals.GoalGetName(i, buf, sizeof(buf)); |
| 3617 | ASSERT(strlen(buf) < 1024); // localization code can only handle 1024 chars in a string |
| 3618 | cfprintf(ofile, "!/!Goal %d Name\n", i); |
| 3619 | cfprintf(ofile, "!=!%s\n\n", buf); |
| 3620 | |
| 3621 | Level_goals.GoalGetItemName(i, buf, sizeof(buf)); |
| 3622 | ASSERT(strlen(buf) < 1024); // localization code can only handle 1024 chars in a string |
| 3623 | cfprintf(ofile, "!/!Goal %d Item Name\n", i); |
| 3624 | cfprintf(ofile, "!=!%s\n\n", buf); |
| 3625 | |
| 3626 | Level_goals.GoalGetDesc(i, buf, sizeof(buf)); |
| 3627 | ASSERT(strlen(buf) < 1024); // localization code can only handle 1024 chars in a string |
| 3628 | cfprintf(ofile, "!/!Goal %d Description\n", i); |
| 3629 | cfprintf(ofile, "!=!%s\n\n", buf); |
| 3630 | |
| 3631 | // Level_goals.GoalGetCompletionMessage(i,buf,sizeof(buf)); |
| 3632 | // cfprintf(ofile,"!/!Goal %d Completion Message\n",i); |
| 3633 | // cfprintf(ofile,"!=!%s\n\n",buf); |
| 3634 | } |
| 3635 | |
| 3636 | cfclose(ofile); |
| 3637 | } |
| 3638 | |
| 3639 | void CMainFrame::OnFileSaveGoalText() { |
| 3640 | CString path = theApp.main_doc->GetPathName(); |
| 3641 | |
| 3642 | char pathname[_MAX_FNAME], filename[_MAX_FNAME], ext[_MAX_FNAME]; |
| 3643 | ddio_SplitPath(path.GetBuffer(0), pathname, filename, ext); |
| 3644 | strcat(pathname, filename); |
| 3645 | strcat(pathname, ".str"); |
| 3646 | strcat(filename, ext); |
| 3647 | |
| 3648 | CFileDialog dlg_open(FALSE, (LPCTSTR) ".str", pathname, 0, NULL, this); |
| 3649 | if (dlg_open.DoModal() == IDCANCEL) |
| 3650 | return; |
| 3651 | |
| 3652 | DumpLevelGoals(dlg_open.GetPathName().GetBuffer(0), filename); |
| 3653 | } |
| 3654 | |
| 3655 | void CMainFrame::OnViewViewprop() { |
| 3656 | if (theApp.m_ViewerPropDlgPtr == NULL) { |
| 3657 | theApp.m_ViewerPropDlgPtr = new CViewerPropDlg; |
| 3658 | theApp.m_ViewerPropDlgPtr->Create(IDD_VIEWER_DIALOG, this); |
| 3659 | theApp.m_ViewerPropDlgPtr->ShowWindow(SW_SHOW); |
| 3660 | } else { |
| 3661 | theApp.m_ViewerPropDlgPtr->DestroyWindow(); |
| 3662 | } |
| 3663 | } |
| 3664 | |
| 3665 | void CMainFrame::OnUpdateViewViewprop(CCmdUI *pCmdUI) { |
| 3666 | if (theApp.m_ViewerPropDlgPtr == NULL) { |
| 3667 | pCmdUI->SetCheck(0); |
| 3668 | } else { |
| 3669 | pCmdUI->SetCheck(1); |
| 3670 | } |
| 3671 | } |
| 3672 | |
| 3673 | void CMainFrame::OnViewMoveCameraToSelectedFace() { SetViewerFromRoomFace(Curroomp, Curface, 0); } |
| 3674 | |
| 3675 | void CMainFrame::OnAccelCopyLightMultiple() { |
| 3676 | extern void CopyFaceLightMultiple(room * rp, int facenum); |
| 3677 | |
| 3678 | CopyFaceLightMultiple(Curroomp, Curface); |
| 3679 | } |
| 3680 | |
| 3681 | void CMainFrame::OnAccelSlidedown() { HTextureSlide(Curroomp, Curface, 0.0f, (float)-1.0 * D3EditState.texscale); } |
| 3682 | |
| 3683 | void CMainFrame::OnAccelSlideleft() { HTextureSlide(Curroomp, Curface, (float)-1.0 * D3EditState.texscale, 0.0f); } |
| 3684 | |
| 3685 | void CMainFrame::OnAccelSlideright() { HTextureSlide(Curroomp, Curface, (float)1.0 * D3EditState.texscale, 0.0f); } |
| 3686 | |
| 3687 | void CMainFrame::OnAccelSlideup() { HTextureSlide(Curroomp, Curface, 0.0f, (float)1.0 * D3EditState.texscale); } |
| 3688 | |
| 3689 | void CMainFrame::OnAccelNextVertex() { |
| 3690 | if (++Curvert >= Curroomp->faces[Curface].num_verts) |
| 3691 | Curvert = 0; |
| 3692 | |
| 3693 | EditorStatus("Vertex %d (%d) selected.", Curvert, Curroomp->faces[Curface].face_verts[Curvert]); |
| 3694 | |
| 3695 | State_changed = 1; |
| 3696 | } |