| 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/WorldObjectsRobotDialog.cpp $ |
| 21 | * $Revision: 1.1.1.1 $ |
| 22 | * $Date: 2003-08-26 03:57:39 $ |
| 23 | * $Author: kevinb $ |
| 24 | * |
| 25 | * WorldObjectsRobotDialog.cpp : implementation file |
| 26 | * |
| 27 | * $Log: not supported by cvs2svn $ |
| 28 | * |
| 29 | * 8 8/08/97 3:48p Samir |
| 30 | * Added script number edit box for temporary editing. |
| 31 | * |
| 32 | * 7 8/08/97 11:45a Matt |
| 33 | * Made anim states dialog keep local copy of anim array. The caller then |
| 34 | * copies the data to his own array if the user exits from the dialog via |
| 35 | * OK. |
| 36 | * |
| 37 | * 6 8/06/97 2:33p Jason |
| 38 | * fixed potential memory bug |
| 39 | * |
| 40 | * 5 8/06/97 1:32p Matt |
| 41 | * Ripped out a bunch of stuff, and added seperate physics and ai dialogs |
| 42 | * |
| 43 | * 4 7/24/97 6:11p Matt |
| 44 | * Created symbolic constant for default zoom, and used it every place |
| 45 | * that specifies zoom |
| 46 | * |
| 47 | * $NoKeywords: $ |
| 48 | */ |
| 49 | |
| 50 | #include "mfc_compatibility.h" |
| 51 | #include "editor.h" |
| 52 | #include "WorldObjectsRobotDialog.h" |
| 53 | #include "AnimStatesDialog.h" |
| 54 | #include "robotpage.h" |
| 55 | #include "manage.h" |
| 56 | #include "robot.h" |
| 57 | #include "polymodel.h" |
| 58 | #include "PhysicsDlg.h" |
| 59 | #include "AISettingsDlg.h" |
| 60 | |
| 61 | #ifdef _DEBUG |
| 62 | #define new DEBUG_NEW |
| 63 | #undef THIS_FILE |
| 64 | static char THIS_FILE[] = __FILE__; |
| 65 | #endif |
| 66 | |
| 67 | ///////////////////////////////////////////////////////////////////////////// |
| 68 | // CWorldObjectsRobotDialog dialog |
| 69 | |
| 70 | CWorldObjectsRobotDialog::CWorldObjectsRobotDialog(CWnd *pParent /*=NULL*/) |
| 71 | : CDialog(CWorldObjectsRobotDialog::IDD, pParent) { |
| 72 | //{{AFX_DATA_INIT(CWorldObjectsRobotDialog) |
| 73 | // NOTE: the ClassWizard will add member initialization here |
| 74 | //}}AFX_DATA_INIT |
| 75 | } |
| 76 | |
| 77 | void CWorldObjectsRobotDialog::DoDataExchange(CDataExchange *pDX) { |
| 78 | CDialog::DoDataExchange(pDX); |
| 79 | //{{AFX_DATA_MAP(CWorldObjectsRobotDialog) |
| 80 | // NOTE: the ClassWizard will add DDX and DDV calls here |
| 81 | //}}AFX_DATA_MAP |
| 82 | } |
| 83 | |
| 84 | BEGIN_MESSAGE_MAP(CWorldObjectsRobotDialog, CDialog) |
| 85 | //{{AFX_MSG_MAP(CWorldObjectsRobotDialog) |
| 86 | ON_BN_CLICKED(IDC_ADD_NEW_ROBOT, OnAddNewRobot) |
| 87 | ON_BN_CLICKED(IDC_CHECKIN_ROBOT, OnCheckinRobot) |
| 88 | ON_BN_CLICKED(IDC_DELETE_ROBOT, OnDeleteRobot) |
| 89 | ON_BN_CLICKED(IDC_LOCK_ROBOT, OnLockRobot) |
| 90 | ON_BN_CLICKED(IDC_NEXT_ROBOT, OnNextRobot) |
| 91 | ON_BN_CLICKED(IDC_PREV_ROBOT, OnPrevRobot) |
| 92 | ON_BN_CLICKED(IDC_ROBOT_MODEL, OnRobotModel) |
| 93 | ON_EN_KILLFOCUS(IDC_ROBOT_NAME_EDIT, OnKillfocusRobotNameEdit) |
| 94 | ON_CBN_SELENDOK(IDC_ROBOT_PULLDOWN, OnSelendokRobotPulldown) |
| 95 | ON_WM_TIMER() |
| 96 | ON_EN_KILLFOCUS(IDC_ROBOT_SIZE_EDIT, OnKillfocusRobotSizeEdit) |
| 97 | ON_BN_CLICKED(IDC_ROBOTS_OUT, OnRobotsOut) |
| 98 | ON_BN_CLICKED(IDC_DEFINE_ANIMSTATES, OnDefineAnimstates) |
| 99 | ON_WM_HELPINFO() |
| 100 | ON_BN_CLICKED(IDC_ROBOT_EDIT_PHYSICS, OnRobotEditPhysics) |
| 101 | ON_BN_CLICKED(IDC_ROBOT_USES_PHYSICS, OnRobotUsesPhysics) |
| 102 | ON_BN_CLICKED(IDC_ROBOT_USES_AI, OnRobotUsesAI) |
| 103 | ON_BN_CLICKED(IDC_ROBOT_EDIT_AI, OnRobotEditAI) |
| 104 | ON_EN_KILLFOCUS(IDC_SCRIPTID, OnKillfocusScriptid) |
| 105 | //}}AFX_MSG_MAP |
| 106 | END_MESSAGE_MAP() |
| 107 | |
| 108 | ///////////////////////////////////////////////////////////////////////////// |
| 109 | // CWorldObjectsRobotDialog message handlers |
| 110 | |
| 111 | void CWorldObjectsRobotDialog::OnAddNewRobot() { |
| 112 | #if 0 // LGT: undeclared symbols |
| 113 | char filename[255]; |
| 114 | char cur_name[100]; |
| 115 | int img_handle; |
| 116 | int robot_handle; |
| 117 | int c=1,finding_name=1; |
| 118 | |
| 119 | if (!Network_up) |
| 120 | { |
| 121 | OutrageMessageBox ("Sorry babe, the network is down. This action is a no-no.\n"); |
| 122 | return; |
| 123 | } |
| 124 | |
| 125 | // Get the filename of the representing image |
| 126 | |
| 127 | CString filter = "Descent III files (*.pof,*.oof)|*.pof;*.oof||"; |
| 128 | |
| 129 | CFileDialog dlg_open(TRUE, 0,0, OFN_FILEMUSTEXIST, (LPCTSTR)filter, this); |
| 130 | |
| 131 | if (dlg_open.DoModal() == IDCANCEL) return; |
| 132 | |
| 133 | // Okay, we selected a file. Lets do what needs to be done here. |
| 134 | |
| 135 | strcpy (filename,dlg_open.GetPathName()); |
| 136 | img_handle=LoadRobotImage (filename); |
| 137 | |
| 138 | if (img_handle<0) |
| 139 | { |
| 140 | OutrageMessageBox ("Couldn't open that model file."); |
| 141 | return; |
| 142 | } |
| 143 | |
| 144 | // Alloc a robot and give a name not already taken by some other robot |
| 145 | |
| 146 | robot_handle=AllocRobot(); |
| 147 | |
| 148 | while (finding_name) |
| 149 | { |
| 150 | // sprintf (cur_name,"%s%d",dlg_open.GetFileName(),c); // LGT: CString not char* |
| 151 | if (FindRobotName (cur_name)!=-1) |
| 152 | c++; |
| 153 | else |
| 154 | finding_name=0; |
| 155 | } |
| 156 | |
| 157 | strcpy (Robots[robot_handle].name,cur_name); |
| 158 | |
| 159 | Robots[robot_handle].render_handle=img_handle; |
| 160 | |
| 161 | // figure out size of robot |
| 162 | vector size_vec; |
| 163 | float size; |
| 164 | |
| 165 | size_vec=Poly_models[img_handle].mins-Poly_models[img_handle].maxs; |
| 166 | size=vm_GetMagnitude (&size_vec); |
| 167 | Robots[robot_handle].size=size/2; |
| 168 | |
| 169 | // Finally, save a local copy of the model/anim and alloc a tracklock |
| 170 | mprintf(0,"Making a copy of this model locally...\n"); |
| 171 | |
| 172 | char destname[100]; |
| 173 | sprintf (destname,"%s\\%s",LocalModelsDir,Poly_models[Robots[robot_handle].render_handle].name); |
| 174 | if (stricmp (destname,filename)) // only copy if they are different |
| 175 | cf_CopyFile (destname,filename); |
| 176 | |
| 177 | mng_AllocTrackLock (cur_name,PAGETYPE_ROBOT); |
| 178 | |
| 179 | D3EditState.current_robot=robot_handle; |
| 180 | |
| 181 | RemapRobots(); |
| 182 | |
| 183 | UpdateDialog (); |
| 184 | |
| 185 | #endif |
| 186 | } |
| 187 | |
| 188 | void CWorldObjectsRobotDialog::OnCheckinRobot() { |
| 189 | #if 0 // LGT: undeclared symbols |
| 190 | int n=D3EditState.current_robot; |
| 191 | mngs_Pagelock temp_pl; |
| 192 | int r; |
| 193 | |
| 194 | if (Num_robots<1) |
| 195 | return; |
| 196 | |
| 197 | if (!mng_MakeLocker()) |
| 198 | { |
| 199 | OutrageMessageBox ("Either you have no network support, or someone else has exclusive access to the table files (retry in a 5 seconds)"); |
| 200 | return; |
| 201 | } |
| 202 | |
| 203 | |
| 204 | // Make sure we own this robot |
| 205 | strcpy (temp_pl.name,Robots[n].name); |
| 206 | temp_pl.pagetype=PAGETYPE_ROBOT; |
| 207 | |
| 208 | r=mng_CheckIfPageOwned (&temp_pl,TableUser); |
| 209 | if (r<0) |
| 210 | OutrageMessageBox (ErrorString); |
| 211 | else if (r==0) |
| 212 | OutrageMessageBox (InfoString); |
| 213 | else |
| 214 | { |
| 215 | // Change the pagelock state to UNLOCKED |
| 216 | strcpy (temp_pl.holder,"UNLOCKED"); |
| 217 | if (!mng_ReplacePagelock (temp_pl.name,&temp_pl)) |
| 218 | { |
| 219 | MessageBox (ErrorString,"Error!"); |
| 220 | mng_EraseLocker(); |
| 221 | return; |
| 222 | } |
| 223 | else |
| 224 | { |
| 225 | // Now actually replace the copy on the net with our local one |
| 226 | |
| 227 | if (!mng_ReplaceRobotPage (Robots[n].name,n,0)) |
| 228 | OutrageMessageBox (ErrorString); |
| 229 | else |
| 230 | { |
| 231 | // Save this robot anim/model to the network for all |
| 232 | |
| 233 | char destname[100],srcname[100]; |
| 234 | |
| 235 | sprintf (srcname,"%s\\%s",LocalModelsDir,Poly_models[Robots[n].render_handle].name); |
| 236 | sprintf (destname,"%s\\%s",NetModelsDir,Poly_models[Robots[n].render_handle].name); |
| 237 | |
| 238 | cf_CopyFile (destname,srcname); |
| 239 | |
| 240 | OutrageMessageBox ("Robot checked in."); |
| 241 | |
| 242 | // Delete it from local pagefile if its there |
| 243 | int dret=mng_DeleteRobotPage (Robots[n].name,1); |
| 244 | ASSERT (dret==1); |
| 245 | mng_EraseLocker(); |
| 246 | |
| 247 | // Free the tracklock |
| 248 | int p=mng_FindTrackLock (Robots[n].name,PAGETYPE_ROBOT); |
| 249 | ASSERT (p!=-1); |
| 250 | mng_FreeTrackLock (p); |
| 251 | UpdateDialog (); |
| 252 | } |
| 253 | } |
| 254 | } |
| 255 | #endif |
| 256 | } |
| 257 | |
| 258 | void CWorldObjectsRobotDialog::OnDeleteRobot() { |
| 259 | #if 0 // LGT: undeclared symbols |
| 260 | int answer,tl; |
| 261 | mngs_Pagelock pl; |
| 262 | int n=D3EditState.current_robot; |
| 263 | |
| 264 | if (Num_robots<1) |
| 265 | return; |
| 266 | |
| 267 | // Check to see if we even have it locked |
| 268 | if ((tl=mng_FindTrackLock (Robots[n].name,PAGETYPE_ROBOT))==-1) |
| 269 | { |
| 270 | OutrageMessageBox ("This robot is not yours to delete. Lock first."); |
| 271 | return; |
| 272 | } |
| 273 | |
| 274 | //Make sure its to be deleted |
| 275 | answer=MessageBox ("Are you sure you want to delete this robot?",Robots[n].name,MB_YESNO); |
| 276 | if (answer==IDNO) |
| 277 | return; |
| 278 | |
| 279 | if (!mng_MakeLocker()) |
| 280 | { |
| 281 | OutrageMessageBox ("Either you have no network support, or someone else has exclusive access to the table files (retry in a 5 seconds)"); |
| 282 | return; |
| 283 | } |
| 284 | |
| 285 | |
| 286 | strcpy (pl.name,Robots[n].name); |
| 287 | pl.pagetype=PAGETYPE_ROBOT; |
| 288 | |
| 289 | // Check to see if this is a local robot only. If so, only delete it locally |
| 290 | if (mng_CheckIfPageOwned (&pl,TableUser)!=1) |
| 291 | { |
| 292 | mng_FreeTrackLock (tl); |
| 293 | if (!mng_DeleteRobotPage (Robots[n].name,1)) |
| 294 | { |
| 295 | mprintf(0,ErrorString); |
| 296 | Int3(); |
| 297 | } |
| 298 | } |
| 299 | else // if its network, delete it from both the net and local drives |
| 300 | { |
| 301 | |
| 302 | mng_FreeTrackLock (tl); |
| 303 | mng_DeleteRobotPage (Robots[n].name,1); |
| 304 | mng_DeleteRobotPage (Robots[n].name,0); |
| 305 | mng_DeletePagelock (Robots[n].name,PAGETYPE_ROBOT); |
| 306 | } |
| 307 | |
| 308 | // Advance to the next robot |
| 309 | D3EditState.current_robot=GetNextRobot (n); |
| 310 | |
| 311 | FreePolyModel (Robots[n].render_handle); |
| 312 | FreeRobot (n); |
| 313 | mng_EraseLocker(); |
| 314 | |
| 315 | OutrageMessageBox ("Robot deleted."); |
| 316 | |
| 317 | RemapRobots(); |
| 318 | |
| 319 | UpdateDialog (); |
| 320 | #endif |
| 321 | } |
| 322 | |
| 323 | void CWorldObjectsRobotDialog::OnLockRobot() { |
| 324 | #if 0 // LGT: undeclared symbols |
| 325 | int n=D3EditState.current_robot; |
| 326 | mngs_Pagelock temp_pl; |
| 327 | mngs_robot_page robotpage; |
| 328 | int r; |
| 329 | |
| 330 | if (Num_robots<1) |
| 331 | return; |
| 332 | |
| 333 | if (!mng_MakeLocker()) |
| 334 | { |
| 335 | OutrageMessageBox ("Either you have no network support, or someone else has exclusive access to the table files (retry in a 5 seconds)"); |
| 336 | return; |
| 337 | } |
| 338 | |
| 339 | // Make sure it can be locked |
| 340 | strcpy (temp_pl.name,Robots[n].name); |
| 341 | temp_pl.pagetype=PAGETYPE_ROBOT; |
| 342 | |
| 343 | r=mng_CheckIfPageLocked (&temp_pl); |
| 344 | if (r==2) |
| 345 | { |
| 346 | int answer; |
| 347 | answer=OutrageMessageBox (MBOX_YESNO, "This page is not even in the table file, or the database maybe corrupt. Override to 'Unlocked'? (Select NO if you don't know what you're doing)"); |
| 348 | if (answer==1) |
| 349 | { |
| 350 | strcpy (temp_pl.holder,"UNLOCKED"); |
| 351 | if (!mng_ReplacePagelock (temp_pl.name,&temp_pl)) |
| 352 | MessageBox (ErrorString,"Error!"); |
| 353 | |
| 354 | } |
| 355 | } |
| 356 | else if (r<0) |
| 357 | OutrageMessageBox (ErrorString); |
| 358 | else if (r==1) |
| 359 | OutrageMessageBox (InfoString); |
| 360 | else |
| 361 | { |
| 362 | |
| 363 | // Everything is ok. Tell the network we're locking it and get a copy to |
| 364 | // our local drive |
| 365 | |
| 366 | strcpy (temp_pl.holder,TableUser); |
| 367 | if (!mng_ReplacePagelock (temp_pl.name,&temp_pl)) |
| 368 | { |
| 369 | MessageBox (ErrorString,"Error!"); |
| 370 | mng_EraseLocker(); |
| 371 | return; |
| 372 | } |
| 373 | else |
| 374 | { |
| 375 | // Search thru the net pagefile and get a new copy in RAM in case anyone |
| 376 | // changed it since we started the editor |
| 377 | if (mng_FindSpecificRobotPage (temp_pl.name,&robotpage)) |
| 378 | { |
| 379 | if (mng_AssignRobotPageToRobot (&robotpage,n)) |
| 380 | { |
| 381 | if (!mng_ReplaceRobotPage (Robots[n].name,n,1)) |
| 382 | { |
| 383 | OutrageMessageBox ("There was problem writing that page locally!"); |
| 384 | mng_EraseLocker(); |
| 385 | return; |
| 386 | } |
| 387 | OutrageMessageBox ("Robot locked."); |
| 388 | } |
| 389 | else |
| 390 | OutrageMessageBox ("There was a problem loading this robot. You might encounter problems in dealing with it. Good luck!"); |
| 391 | |
| 392 | mng_AllocTrackLock(Robots[n].name,PAGETYPE_ROBOT); |
| 393 | UpdateDialog (); |
| 394 | } |
| 395 | else |
| 396 | OutrageMessageBox ("Couldn't find that robot in the table file!"); |
| 397 | } |
| 398 | } |
| 399 | mng_EraseLocker(); |
| 400 | #endif |
| 401 | } |
| 402 | |
| 403 | void CWorldObjectsRobotDialog::OnNextRobot() { |
| 404 | #if 0 // LGT: undeclared symbols |
| 405 | D3EditState.current_robot=GetNextRobot(D3EditState.current_robot); |
| 406 | UpdateDialog(); |
| 407 | #endif |
| 408 | } |
| 409 | |
| 410 | void CWorldObjectsRobotDialog::OnPrevRobot() { |
| 411 | #if 0 // LGT: undeclared symbols |
| 412 | D3EditState.current_robot=GetPrevRobot(D3EditState.current_robot); |
| 413 | UpdateDialog(); |
| 414 | #endif |
| 415 | } |
| 416 | |
| 417 | void CWorldObjectsRobotDialog::OnRobotModel() { |
| 418 | #if 0 // LGT: undeclared symbols |
| 419 | char filename[255]; |
| 420 | char curname[255]; |
| 421 | int img_handle; |
| 422 | int robot_handle; |
| 423 | int c=1,finding_name=1; |
| 424 | int model=0; |
| 425 | |
| 426 | // Get the filename of the representing image |
| 427 | |
| 428 | CString filter = "Descent III files (*.pof,*.oof)|*.pof;*.oof||"; |
| 429 | |
| 430 | CFileDialog dlg_open(TRUE, 0,0, OFN_FILEMUSTEXIST, (LPCTSTR)filter, this); |
| 431 | |
| 432 | if (dlg_open.DoModal() == IDCANCEL) return; |
| 433 | |
| 434 | // Okay, we selected a file. Lets do what needs to be done here. |
| 435 | |
| 436 | strcpy (filename,dlg_open.GetPathName()); |
| 437 | img_handle=LoadRobotImage (filename); |
| 438 | |
| 439 | if (img_handle<0) |
| 440 | { |
| 441 | OutrageMessageBox ("Couldn't open that animation/model file."); |
| 442 | return; |
| 443 | } |
| 444 | |
| 445 | |
| 446 | robot_handle=D3EditState.current_robot; |
| 447 | |
| 448 | Robots[robot_handle].render_handle=img_handle; |
| 449 | |
| 450 | // Finally, save a local copy of the model |
| 451 | |
| 452 | sprintf (curname,"%s\\%s",LocalModelsDir,Poly_models[Robots[robot_handle].render_handle].name); |
| 453 | cf_CopyFile (curname,filename); |
| 454 | |
| 455 | UpdateDialog(); |
| 456 | #endif |
| 457 | } |
| 458 | |
| 459 | void CWorldObjectsRobotDialog::OnKillfocusRobotNameEdit() { |
| 460 | #if 0 // LGT: undeclared symbols |
| 461 | CEdit *ebox; |
| 462 | int n=D3EditState.current_robot; |
| 463 | char name[PAGENAME_LEN]; |
| 464 | mngs_Pagelock pl; |
| 465 | |
| 466 | // Make sure we have this robot locked, if not reset name and bail |
| 467 | int p=mng_FindTrackLock (Robots[n].name,PAGETYPE_ROBOT); |
| 468 | if (p==-1) |
| 469 | { |
| 470 | OutrageMessageBox ("You must lock this robot if you wish to change its name."); |
| 471 | CEdit *ebox=(CEdit *) GetDlgItem (IDC_ROBOT_NAME_EDIT); |
| 472 | ebox->SetWindowText (Robots[n].name); |
| 473 | return; |
| 474 | } |
| 475 | |
| 476 | // Get the new name |
| 477 | ebox=(CEdit *) GetDlgItem (IDC_ROBOT_NAME_EDIT); |
| 478 | ebox->GetWindowText (name,PAGENAME_LEN); |
| 479 | |
| 480 | |
| 481 | // Check to see if there is already a robot with this name. If so, reset and bail |
| 482 | if (FindRobotName(name)!=-1) |
| 483 | { |
| 484 | OutrageMessageBox ("There already is a robot with that name...choose another name."); |
| 485 | |
| 486 | CEdit *ebox=(CEdit *) GetDlgItem (IDC_ROBOT_NAME_EDIT); |
| 487 | ebox->SetWindowText (Robots[n].name); |
| 488 | return; |
| 489 | |
| 490 | } |
| 491 | |
| 492 | |
| 493 | if (!mng_MakeLocker()) |
| 494 | { |
| 495 | OutrageMessageBox ("Either you have no network support, or someone else has exclusive access to the table files (retry in a 5 seconds)"); |
| 496 | return; |
| 497 | } |
| 498 | |
| 499 | // Check to see if this page exists on the network. If so, we have to |
| 500 | // rename it so we can prevent havoc |
| 501 | strcpy (pl.name,Robots[n].name); |
| 502 | pl.pagetype=PAGETYPE_ROBOT; |
| 503 | |
| 504 | int ret=mng_CheckIfPageOwned (&pl,TableUser); |
| 505 | if (ret<0) |
| 506 | OutrageMessageBox (ErrorString); |
| 507 | else if (ret==1) |
| 508 | mng_RenamePage (Robots[n].name,name,PAGETYPE_ROBOT); |
| 509 | else if (ret==2) |
| 510 | { |
| 511 | // This page has never been checked in, replace only local copy |
| 512 | |
| 513 | char oldname[PAGENAME_LEN]; |
| 514 | strcpy (oldname,Robots[n].name); |
| 515 | strcpy (Robots[n].name,name); |
| 516 | mng_ReplaceRobotPage (oldname,n,1); |
| 517 | } |
| 518 | else if (ret==0) |
| 519 | { |
| 520 | OutrageMessageBox ("You don't own this page. Get Jason now!"); |
| 521 | mng_FreeTrackLock (p); |
| 522 | return; |
| 523 | } |
| 524 | |
| 525 | // Finally, copy our new name to the appropriate arrays |
| 526 | strcpy (GlobalTrackLocks[p].name,name); |
| 527 | strcpy (Robots[n].name,name); |
| 528 | mng_EraseLocker(); |
| 529 | |
| 530 | RemapRobots(); |
| 531 | UpdateDialog(); |
| 532 | #endif |
| 533 | } |
| 534 | |
| 535 | void CWorldObjectsRobotDialog::OnSelendokRobotPulldown() { |
| 536 | #if 0 // LGT: undeclared symbols |
| 537 | int i,cur; |
| 538 | char name[200]; |
| 539 | |
| 540 | cur=SendDlgItemMessage( IDC_ROBOT_PULLDOWN, CB_GETCURSEL,0,0); |
| 541 | SendDlgItemMessage( IDC_ROBOT_PULLDOWN, CB_GETLBTEXT,cur,(LPARAM) (LPCTSTR)name); |
| 542 | |
| 543 | i=FindRobotName (name); |
| 544 | |
| 545 | if (i==-1) |
| 546 | { |
| 547 | mprintf(0,"Possible corrupted robot list, but probably nothing."); |
| 548 | UpdateDialog(); |
| 549 | } |
| 550 | |
| 551 | D3EditState.current_robot=i; |
| 552 | UpdateDialog(); |
| 553 | #endif |
| 554 | } |
| 555 | |
| 556 | void CWorldObjectsRobotDialog::UpdateDialog() { |
| 557 | #if 0 |
| 558 | CEdit *ebox; |
| 559 | CButton *bbox; |
| 560 | int n=D3EditState.current_robot; |
| 561 | char str[16]; |
| 562 | |
| 563 | if (Num_robots<1) |
| 564 | { |
| 565 | bbox=(CButton *) GetDlgItem (IDC_NEXT_ROBOT); |
| 566 | bbox->EnableWindow (FALSE); |
| 567 | bbox=(CButton *) GetDlgItem (IDC_PREV_ROBOT); |
| 568 | bbox->EnableWindow (FALSE); |
| 569 | |
| 570 | return; |
| 571 | } |
| 572 | else |
| 573 | { |
| 574 | bbox=(CButton *) GetDlgItem (IDC_NEXT_ROBOT); |
| 575 | bbox->EnableWindow (TRUE); |
| 576 | bbox=(CButton *) GetDlgItem (IDC_PREV_ROBOT); |
| 577 | bbox->EnableWindow (TRUE); |
| 578 | } |
| 579 | |
| 580 | if (!Robots[n].used) |
| 581 | n=D3EditState.current_robot=GetNextRobot(n); |
| 582 | |
| 583 | |
| 584 | ebox=(CEdit *) GetDlgItem (IDC_ROBOT_NAME_EDIT); |
| 585 | ebox->SetWindowText (Robots[n].name); |
| 586 | |
| 587 | ebox=(CEdit *) GetDlgItem (IDC_ROBOT_MODEL_NAME_EDIT); |
| 588 | ebox->SetWindowText (Poly_models[Robots[n].render_handle].name); |
| 589 | |
| 590 | bbox = (CButton *)GetDlgItem(IDC_ROBOT_USES_PHYSICS); |
| 591 | bbox->SetCheck(Robots[n].flags & OIF_USES_PHYSICS); |
| 592 | ((CButton *)GetDlgItem(IDC_ROBOT_EDIT_PHYSICS))->EnableWindow(Robots[n].flags & OIF_USES_PHYSICS); |
| 593 | |
| 594 | bbox = (CButton *)GetDlgItem(IDC_ROBOT_USES_AI); |
| 595 | bbox->SetCheck(Robots[n].flags & OIF_CONTROL_AI); |
| 596 | ((CButton *)GetDlgItem(IDC_ROBOT_EDIT_AI))->EnableWindow(Robots[n].flags & OIF_CONTROL_AI); |
| 597 | |
| 598 | bbox=(CButton *) GetDlgItem (IDC_CHECKIN_ROBOT); |
| 599 | if (mng_FindTrackLock (Robots[n].name,PAGETYPE_ROBOT)==-1) |
| 600 | { |
| 601 | bbox->EnableWindow (FALSE); |
| 602 | bbox=(CButton *) GetDlgItem (IDC_LOCK_ROBOT); |
| 603 | bbox->EnableWindow (TRUE); |
| 604 | } |
| 605 | else |
| 606 | { |
| 607 | bbox->EnableWindow (TRUE); |
| 608 | bbox=(CButton *) GetDlgItem (IDC_LOCK_ROBOT); |
| 609 | bbox->EnableWindow (FALSE); |
| 610 | } |
| 611 | |
| 612 | sprintf(str, "%d", Robots[n].script_handle); |
| 613 | ebox = (CEdit *)GetDlgItem(IDC_SCRIPTID); |
| 614 | ebox->SetWindowText(str); |
| 615 | |
| 616 | SendDlgItemMessage( IDC_ROBOT_PULLDOWN, CB_RESETCONTENT,0,0); |
| 617 | |
| 618 | for (int i=0;i<MAX_ROBOTS;i++) |
| 619 | { |
| 620 | if (Robots[i].used) |
| 621 | SendDlgItemMessage( IDC_ROBOT_PULLDOWN, CB_ADDSTRING,0,(LPARAM) (LPCTSTR) Robots[i].name); |
| 622 | } |
| 623 | SendDlgItemMessage( IDC_ROBOT_PULLDOWN, CB_SELECTSTRING,0,(LPARAM) (LPCTSTR) Robots[n].name); |
| 624 | |
| 625 | UpdateRobotView(); |
| 626 | #endif |
| 627 | } |
| 628 | |
| 629 | #define NUM_ANIM_FRAMES 30 |
| 630 | |
| 631 | void CWorldObjectsRobotDialog::UpdateRobotView(void) { |
| 632 | #if 0 |
| 633 | int n=D3EditState.current_robot; |
| 634 | CWnd *robotwnd; |
| 635 | RECT rect; |
| 636 | int x, y, bm_handle,w,h; |
| 637 | static int frame=0,spin_frame=0; |
| 638 | static last_robot=-1; |
| 639 | static last_render_handle=-1; |
| 640 | static robot_dir=0; |
| 641 | |
| 642 | if (Num_robots<1) |
| 643 | return; |
| 644 | |
| 645 | if (robot_dir==0) |
| 646 | { |
| 647 | frame++; |
| 648 | if (frame==NUM_ANIM_FRAMES) |
| 649 | { |
| 650 | frame=NUM_ANIM_FRAMES-1; |
| 651 | robot_dir=1; |
| 652 | } |
| 653 | } |
| 654 | else |
| 655 | { |
| 656 | frame--; |
| 657 | if (frame==-1) |
| 658 | { |
| 659 | frame=0; |
| 660 | robot_dir=0; |
| 661 | } |
| 662 | } |
| 663 | |
| 664 | |
| 665 | |
| 666 | robotwnd = GetDlgItem(IDC_ROBOTVIEW); |
| 667 | robotwnd->GetWindowRect(&rect); |
| 668 | ScreenToClient(&rect); |
| 669 | |
| 670 | Desktop_surf->attach_to_window((unsigned)m_hWnd); |
| 671 | |
| 672 | w=rect.right-rect.left; |
| 673 | h=rect.bottom-rect.top; |
| 674 | |
| 675 | if (last_robot!=n || last_render_handle!=Robots[n].render_handle) |
| 676 | { |
| 677 | Desktop_surf->clear(rect.left,rect.top,w,h); |
| 678 | last_robot=n; |
| 679 | last_render_handle=Robots[n].render_handle; |
| 680 | } |
| 681 | |
| 682 | bm_handle=GetRobotImage (n); |
| 683 | |
| 684 | vector zero_vector; |
| 685 | vector view_vector={0,0,-20}; |
| 686 | matrix id_matrix,rot_matrix; |
| 687 | poly_model *pm=&Poly_models[bm_handle]; |
| 688 | |
| 689 | vm_MakeZero (&zero_vector); |
| 690 | vm_MakeIdentity (&id_matrix); |
| 691 | |
| 692 | float norm_angles[30]; |
| 693 | |
| 694 | for (int i=0;i<30;i++) |
| 695 | norm_angles[i]=(float)frame/(float)NUM_ANIM_FRAMES; |
| 696 | |
| 697 | spin_frame++; |
| 698 | |
| 699 | vm_AnglesToMatrix (&rot_matrix,0,spin_frame*400,0); |
| 700 | view_vector.z=-(fabs(pm->maxs.z-pm->mins.z)*2); |
| 701 | |
| 702 | m_RobotSurf.create(128, 128, BPP_16); |
| 703 | grViewport *vport=new grViewport (&m_RobotSurf); |
| 704 | g3_StartFrame (vport,&view_vector,&id_matrix,D3_DEFAULT_ZOOM); |
| 705 | DrawPolygonModel (&zero_vector,&rot_matrix,bm_handle,norm_angles,0,1.0); |
| 706 | g3_EndFrame(); |
| 707 | |
| 708 | x = rect.left + ((rect.right-rect.left)/2) - m_RobotSurf.width()/2; |
| 709 | y = rect.top + ((rect.bottom-rect.top)/2) - m_RobotSurf.height()/2; |
| 710 | Desktop_surf->blt(x, y, &m_RobotSurf); |
| 711 | |
| 712 | delete vport; |
| 713 | m_RobotSurf.free(); |
| 714 | #endif |
| 715 | } |
| 716 | |
| 717 | BOOL CWorldObjectsRobotDialog::OnInitDialog() { |
| 718 | #if 0 // LGT: undeclared symbols |
| 719 | CDialog::OnInitDialog(); |
| 720 | |
| 721 | CWnd::SetTimer(1,50,NULL); |
| 722 | |
| 723 | UpdateDialog(); |
| 724 | #endif |
| 725 | return TRUE; // return TRUE unless you set the focus to a control |
| 726 | // EXCEPTION: OCX Property Pages should return FALSE |
| 727 | } |
| 728 | |
| 729 | void CWorldObjectsRobotDialog::OnTimer(UINT nIDEvent) { |
| 730 | #if 0 // LGT: undeclared symbols |
| 731 | UpdateRobotView(); |
| 732 | |
| 733 | CDialog::OnTimer(nIDEvent); |
| 734 | #endif |
| 735 | } |
| 736 | |
| 737 | void CWorldObjectsRobotDialog::OnKillfocusRobotSizeEdit() { |
| 738 | #if 0 // LGT: undeclared symbols |
| 739 | CEdit *ebox; |
| 740 | char str[20]; |
| 741 | int n=D3EditState.current_robot; |
| 742 | |
| 743 | ebox=(CEdit *) GetDlgItem (IDC_ROBOT_SIZE_EDIT); |
| 744 | ebox->GetWindowText (str,20); |
| 745 | |
| 746 | Robots[n].size = atof (str); |
| 747 | #endif |
| 748 | } |
| 749 | |
| 750 | void CWorldObjectsRobotDialog::OnRobotsOut() { |
| 751 | #if 0 // LGT: undeclared symbols |
| 752 | char str[10000]; |
| 753 | int total=0; |
| 754 | |
| 755 | mng_DisplayLockList (TableUser); |
| 756 | |
| 757 | sprintf (str,"User %s has these robots held locally:\n\n",TableUser); |
| 758 | for (int i=0;i<MAX_TRACKLOCKS;i++) |
| 759 | { |
| 760 | if (GlobalTrackLocks[i].used && GlobalTrackLocks[i].pagetype==PAGETYPE_ROBOT) |
| 761 | { |
| 762 | char temp[90]; |
| 763 | |
| 764 | sprintf (temp,"%s",GlobalTrackLocks[i].name); |
| 765 | strcat (str,temp); |
| 766 | strcat (str,"\n"); |
| 767 | total++; |
| 768 | } |
| 769 | } |
| 770 | |
| 771 | if (total!=0) |
| 772 | { |
| 773 | // Display that string |
| 774 | MessageBox (str,"Robots",MB_OK); |
| 775 | } |
| 776 | #endif |
| 777 | } |
| 778 | // When closing, save all our checked out robots locally so we know |
| 779 | // what stuff to flag as "checked out" the next time we start up |
| 780 | void CWorldObjectsRobotDialog::SaveRobotsOnClose() { |
| 781 | #if 0 // LGT: undeclared symbols |
| 782 | int i,t; |
| 783 | |
| 784 | |
| 785 | if (!Network_up) |
| 786 | return; // don't save a damn thing if the network is down |
| 787 | |
| 788 | |
| 789 | for (i=0;i<MAX_TRACKLOCKS;i++) |
| 790 | { |
| 791 | if (GlobalTrackLocks[i].used==1 && GlobalTrackLocks[i].pagetype==PAGETYPE_ROBOT) |
| 792 | { |
| 793 | t=FindRobotName(GlobalTrackLocks[i].name); |
| 794 | ASSERT (t!=-1); |
| 795 | mng_ReplaceRobotPage (Robots[t].name,t,1); |
| 796 | } |
| 797 | } |
| 798 | #endif |
| 799 | } |
| 800 | |
| 801 | BOOL CWorldObjectsRobotDialog::DestroyWindow() { |
| 802 | SaveRobotsOnClose(); |
| 803 | |
| 804 | return CDialog::DestroyWindow(); |
| 805 | } |
| 806 | |
| 807 | void CWorldObjectsRobotDialog::OnDefineAnimstates() { |
| 808 | #if 0 // LGT: used undefined |
| 809 | int n=D3EditState.current_robot; |
| 810 | |
| 811 | if (!Robots[n].used) |
| 812 | return; |
| 813 | |
| 814 | CAnimStatesDialog dlg(Robots[n].render_handle,Robots[n].anim); |
| 815 | |
| 816 | if (dlg.DoModal() == IDOK) //Copy back into object |
| 817 | dlg.GetAnimData(Robots[n].anim); |
| 818 | #endif |
| 819 | } |
| 820 | |
| 821 | BOOL CWorldObjectsRobotDialog::OnHelpInfo(HELPINFO *pHelpInfo) { |
| 822 | // TODO: Add your message handler code here and/or call default |
| 823 | WinHelp(HID_ROBOTSDLG, HELP_CONTEXT); |
| 824 | return TRUE; |
| 825 | // return CDialog::OnHelpInfo(pHelpInfo); |
| 826 | } |
| 827 | |
| 828 | void CWorldObjectsRobotDialog::OnRobotUsesPhysics() { |
| 829 | #if 0 // LGT: undeclared symbols |
| 830 | int n=D3EditState.current_robot; |
| 831 | CButton *btn; |
| 832 | |
| 833 | btn = (CButton *)GetDlgItem(IDC_ROBOT_USES_PHYSICS); |
| 834 | |
| 835 | if (btn->GetCheck()) |
| 836 | Robots[n].flags |= OIF_USES_PHYSICS; |
| 837 | else |
| 838 | Robots[n].flags &= ~OIF_USES_PHYSICS; |
| 839 | |
| 840 | ((CButton *)GetDlgItem(IDC_ROBOT_EDIT_PHYSICS))->EnableWindow(Robots[n].flags & OIF_USES_PHYSICS); |
| 841 | #endif |
| 842 | } |
| 843 | |
| 844 | void CWorldObjectsRobotDialog::OnRobotEditPhysics() { |
| 845 | #if 0 // LGT: CopyPhysicsData undefined |
| 846 | CPhysicsDlg dlg; |
| 847 | |
| 848 | CopyPhysicsData(&dlg,&Robots[D3EditState.current_robot].phys_info); |
| 849 | |
| 850 | if (dlg.DoModal() == IDOK) |
| 851 | CopyPhysicsData(&Robots[D3EditState.current_robot].phys_info,&dlg); |
| 852 | #endif |
| 853 | } |
| 854 | |
| 855 | void CWorldObjectsRobotDialog::OnRobotUsesAI() { |
| 856 | #if 0 // LGT: undeclared symbols |
| 857 | int n=D3EditState.current_robot; |
| 858 | CButton *btn; |
| 859 | |
| 860 | btn = (CButton *)GetDlgItem(IDC_ROBOT_USES_AI); |
| 861 | |
| 862 | if (btn->GetCheck()) |
| 863 | Robots[n].flags |= OIF_CONTROL_AI; |
| 864 | else |
| 865 | Robots[n].flags &= ~OIF_CONTROL_AI; |
| 866 | |
| 867 | ((CButton *)GetDlgItem(IDC_ROBOT_EDIT_AI))->EnableWindow(Robots[n].flags & OIF_CONTROL_AI); |
| 868 | #endif |
| 869 | } |
| 870 | |
| 871 | void CWorldObjectsRobotDialog::OnRobotEditAI() { |
| 872 | #if 0 // LGT: CopyAIData undefined |
| 873 | CAISettingsDlg dlg; |
| 874 | |
| 875 | CopyAIData(&dlg,&Robots[D3EditState.current_robot].ai_info); |
| 876 | |
| 877 | if (dlg.DoModal() == IDOK) |
| 878 | CopyAIData(&Robots[D3EditState.current_robot].ai_info,&dlg); |
| 879 | #endif |
| 880 | } |
| 881 | |
| 882 | void CWorldObjectsRobotDialog::OnKillfocusScriptid() { |
| 883 | #if 0 // LGT: script_handle undefined |
| 884 | // really all this does is set the script item in memory. |
| 885 | CEdit *edit = (CEdit *)GetDlgItem(IDC_SCRIPTID); |
| 886 | char buf[8]; |
| 887 | |
| 888 | edit->GetWindowText(buf, sizeof(buf)); |
| 889 | Robots[D3EditState.current_robot].script_handle = atoi(buf); |
| 890 | #endif |
| 891 | } |