| 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 | |
| 19 | // WorldObjectsGenericDialog.cpp : implementation file |
| 20 | // |
| 21 | |
| 22 | #include <filesystem> |
| 23 | |
| 24 | #include "mfc_compatibility.h" |
| 25 | #include "editor.h" |
| 26 | #include "WorldObjectsGenericDialog.h" |
| 27 | #include "PhysicsDlg.h" |
| 28 | #include "AISettingsDlg.h" |
| 29 | #include "objinfo.h" |
| 30 | #include "polymodel.h" |
| 31 | #include "AnimStatesDialog.h" |
| 32 | #include "EditLineDialog.h" |
| 33 | #include "genericpage.h" |
| 34 | #include "RobotEditWeaponsDialog.h" |
| 35 | #include "GenericLightDialog.h" |
| 36 | #include "robotfire.h" |
| 37 | #include "ddio.h" |
| 38 | #include "soundload.h" |
| 39 | #include "objinit.h" |
| 40 | #include "gametexture.h" |
| 41 | #include "vclip.h" |
| 42 | #include "QuickCompile.h" |
| 43 | #include "mem.h" |
| 44 | |
| 45 | #ifdef _DEBUG |
| 46 | #define new DEBUG_NEW |
| 47 | #undef THIS_FILE |
| 48 | static char THIS_FILE[] = __FILE__; |
| 49 | #endif |
| 50 | |
| 51 | ///////////////////////////////////////////////////////////////////////////// |
| 52 | // CWorldObjectsGenericDialog dialog |
| 53 | |
| 54 | // Data for copy/paste object |
| 55 | object_info Copy_object; |
| 56 | |
| 57 | CWorldObjectsGenericDialog::CWorldObjectsGenericDialog(CWnd *pParent /*=NULL*/) |
| 58 | : CDialog(CWorldObjectsGenericDialog::IDD, pParent) { |
| 59 | //{{AFX_DATA_INIT(CWorldObjectsGenericDialog) |
| 60 | m_type_name = _T(""); |
| 61 | m_current = 0; |
| 62 | m_sInvenDescription = _T(""); |
| 63 | m_sInvenIconName = _T(""); |
| 64 | //}}AFX_DATA_INIT |
| 65 | } |
| 66 | |
| 67 | void CWorldObjectsGenericDialog::DoDataExchange(CDataExchange *pDX) { |
| 68 | CDialog::DoDataExchange(pDX); |
| 69 | //{{AFX_DATA_MAP(CWorldObjectsGenericDialog) |
| 70 | DDX_Control(pDX, IDC_GENERIC_AMBIENT_SOUND_COMBO, m_ambient_sound_combo); |
| 71 | DDX_Control(pDX, IDC_GENERIC_EXPLOSION_SOUND_COMBO, m_explosion_sound_combo); |
| 72 | DDX_Text(pDX, IDC_GENERIC_TYPE_NAME, m_type_name); |
| 73 | DDX_Text(pDX, IDC_GENERIC_ID_EDIT, m_current); |
| 74 | DDX_Text(pDX, IDC_GENERIC_INVEN_DESCRIPTION, m_sInvenDescription); |
| 75 | DDV_MaxChars(pDX, m_sInvenDescription, 180); |
| 76 | DDX_Text(pDX, IDC_GENERIC_INVEN_ICONNAME, m_sInvenIconName); |
| 77 | //}}AFX_DATA_MAP |
| 78 | } |
| 79 | |
| 80 | BEGIN_MESSAGE_MAP(CWorldObjectsGenericDialog, CDialog) |
| 81 | //{{AFX_MSG_MAP(CWorldObjectsGenericDialog) |
| 82 | ON_BN_CLICKED(IDC_GENERIC_EDIT_AI, OnGenericEditAI) |
| 83 | ON_BN_CLICKED(IDC_GENERIC_EDIT_PHYSICS, OnGenericEditPhysics) |
| 84 | ON_BN_CLICKED(IDC_GENERIC_USES_AI, OnGenericUsesAI) |
| 85 | ON_BN_CLICKED(IDC_GENERIC_USES_PHYSICS, OnGenericUsesPhysics) |
| 86 | ON_BN_CLICKED(IDC_GENERIC_ADD_NEW, OnGenericAddNew) |
| 87 | ON_BN_CLICKED(IDC_GENERIC_CHECKED_OUT, OnGenericCheckedOut) |
| 88 | ON_BN_CLICKED(IDC_GENERIC_CHECKIN, OnGenericCheckIn) |
| 89 | ON_BN_CLICKED(IDC_GENERIC_DEFINE_ANIMSTATES, OnGenericDefineAnimStates) |
| 90 | ON_BN_CLICKED(IDC_GENERIC_DELETE, OnGenericDelete) |
| 91 | ON_BN_CLICKED(IDC_GENERIC_LOCK, OnGenericLock) |
| 92 | ON_BN_CLICKED(IDC_GENERIC_NEXT, OnGenericNext) |
| 93 | ON_BN_CLICKED(IDC_GENERIC_PREV, OnGenericPrev) |
| 94 | ON_BN_CLICKED(IDC_GENERIC_CHANGE_MODEL, OnGenericChangeModel) |
| 95 | ON_BN_CLICKED(IDC_GENERIC_CHANGE_NAME, OnGenericChangeName) |
| 96 | ON_WM_TIMER() |
| 97 | ON_CBN_SELENDOK(IDC_GENERIC_NAME_PULLDOWN, OnSelendokGenericNamePulldown) |
| 98 | ON_EN_KILLFOCUS(IDC_GENERIC_SIZE_EDIT, OnKillfocusGenericSizeEdit) |
| 99 | ON_BN_CLICKED(IDC_GENERIC_COPY, OnGenericCopy) |
| 100 | ON_BN_CLICKED(IDC_GENERIC_PASTE, OnGenericPaste) |
| 101 | ON_EN_KILLFOCUS(IDC_GENERIC_SCRIPT_ID_EDIT, OnKillfocusGenericScriptIDEdit) |
| 102 | ON_BN_CLICKED(IDC_GENERIC_UNDO_LOCK, OnGenericUndoLock) |
| 103 | ON_BN_CLICKED(IDC_GENERIC_DESTROYABLE, OnGenericDestroyable) |
| 104 | ON_EN_KILLFOCUS(IDC_GENERIC_HITPOINT_EDIT, OnKillfocusGenericHitpointEdit) |
| 105 | ON_WM_DESTROY() |
| 106 | ON_BN_CLICKED(IDC_GENERIC_WEAPON_INFO_BUTTON, OnGenericWeaponInfoButton) |
| 107 | ON_BN_CLICKED(IDC_GENERIC_LIGHT_BUTTON, OnGenericLightButton) |
| 108 | ON_BN_CLICKED(IDC_DEFAULT_RADIUS_BUTTON, OnDefaultRadiusButton) |
| 109 | ON_BN_CLICKED(IDC_SELSCRIPT, OnSelScript) |
| 110 | ON_BN_CLICKED(IDC_GENERIC_CONCUSSIVE_CHECK, OnGenericConcussiveCheck) |
| 111 | ON_EN_KILLFOCUS(IDC_GENERIC_IMPACT_DAMAGE_EDIT, OnKillfocusGenericImpactDamageEdit) |
| 112 | ON_EN_KILLFOCUS(IDC_GENERIC_IMPACT_SIZE_EDIT, OnKillfocusGenericImpactSizeEdit) |
| 113 | ON_BN_CLICKED(IDC_NOLOD, OnNolod) |
| 114 | ON_BN_CLICKED(IDC_HIRES_RADIO, OnHiresRadio) |
| 115 | ON_BN_CLICKED(IDC_MEDRES_RADIO, OnMedresRadio) |
| 116 | ON_BN_CLICKED(IDC_LORES_RADIO, OnLoresRadio) |
| 117 | ON_EN_KILLFOCUS(IDC_GENERIC_IMPACT_TIME_EDIT, OnKillfocusGenericImpactTimeEdit) |
| 118 | ON_CBN_SELENDOK(IDC_GENERIC_EXPLOSION_SOUND_COMBO, OnSelendokGenericExplosionSoundCombo) |
| 119 | ON_CBN_SELENDOK(IDC_GENERIC_AMBIENT_SOUND_COMBO, OnSelendokGenericAmbientSoundCombo) |
| 120 | ON_EN_KILLFOCUS(IDC_GENERIC_INVEN_DESCRIPTION, OnKillfocusGenericInvenDescription) |
| 121 | ON_EN_KILLFOCUS(IDC_GENERIC_INVEN_ICONNAME, OnKillfocusGenericInvenIconname) |
| 122 | ON_BN_CLICKED(IDC_OVERRIDE, OnOverride) |
| 123 | ON_BN_CLICKED(IDC_GENERIC_INVEN_SELECTABLE, OnGenericInvenSelectable) |
| 124 | ON_BN_CLICKED(IDC_GENERIC_INVEN_NONUSEABLE, OnGenericInvenNonuseable) |
| 125 | ON_EN_KILLFOCUS(IDC_LOD_DISTANCE_EDIT, OnKillfocusLodDistanceEdit) |
| 126 | ON_BN_CLICKED(IDC_INVTYPE_GAME, OnInvtypeGame) |
| 127 | ON_BN_CLICKED(IDC_INVTYPE_MISSION, OnInvtypeMission) |
| 128 | ON_BN_CLICKED(IDC_INVEN_NOREMOVE, OnInvenNoremove) |
| 129 | ON_BN_CLICKED(IDC_INVEN_VISWHENUSED, OnInvenViswhenused) |
| 130 | ON_CBN_SELENDOK(IDC_DEATH_POWERUP1_PULLDOWN, OnSelendokDeathPowerup1Pulldown) |
| 131 | ON_EN_KILLFOCUS(IDC_DEATH_POWERUP1_NUM_EDIT, OnKillfocusDeathPowerup1NumEdit) |
| 132 | ON_EN_KILLFOCUS(IDC_DEATH_POWERUP1_PERCENT_EDIT, OnKillfocusDeathPowerup1PercentEdit) |
| 133 | ON_EN_KILLFOCUS(IDC_DEATH_POWERUP2_NUM_EDIT, OnKillfocusDeathPowerup2NumEdit) |
| 134 | ON_EN_KILLFOCUS(IDC_DEATH_POWERUP2_PERCENT_EDIT, OnKillfocusDeathPowerup2PercentEdit) |
| 135 | ON_CBN_SELENDOK(IDC_DEATH_POWERUP2_PULLDOWN, OnSelendokDeathPowerup2Pulldown) |
| 136 | ON_BN_CLICKED(IDC_DEATH_POWERUP_USE2_IF_HAVE1_CHECK, OnDeathPowerupUse2IfHave1Check) |
| 137 | ON_BN_CLICKED(IDC_GENERIC_DEATH_SPEW_2_IF_ZERO_1, OnGenericDeathSpew2IfZero1) |
| 138 | ON_EN_KILLFOCUS(IDC_SCRIPTNAME, OnKillfocusScriptname) |
| 139 | ON_BN_CLICKED(IDC_COMPILEMODULE, OnCompilemodule) |
| 140 | ON_EN_KILLFOCUS(IDC_SCRIPT_OVERRIDE, OnKillfocusScriptOverride) |
| 141 | ON_BN_CLICKED(IDC_GENERIC_AI_SCRIPTED_DEATH, OnGenericAiScriptedDeath) |
| 142 | ON_EN_KILLFOCUS(IDC_RESPAWN_SCALAR_EDIT, OnKillfocusRespawnScalarEdit) |
| 143 | ON_BN_CLICKED(IDC_GENERIC_DEATHS, OnGenericDeaths) |
| 144 | ON_EN_KILLFOCUS(IDC_GENERIC_SCORE_EDIT, OnKillfocusGenericScoreEdit) |
| 145 | ON_EN_KILLFOCUS(IDC_GENERIC_AMMO_EDIT, OnKillfocusGenericAmmoEdit) |
| 146 | ON_BN_CLICKED(IDC_OBJ_CEILING_CHECK, OnObjCeilingCheck) |
| 147 | ON_BN_CLICKED(IDC_OBJECT_FLY_THROUGH_RENDERED_PORTALS, OnObjectFlyThroughRenderedPortals) |
| 148 | ON_BN_CLICKED(IDC_NSC_BUTTON, OnNscButton) |
| 149 | ON_BN_CLICKED(IDC_DSMPBD_CHECK, OnDsmpbdCheck) |
| 150 | ON_BN_CLICKED(IDC_GENERIC_AMBIENT, OnGenericAmbient) |
| 151 | //}}AFX_MSG_MAP |
| 152 | END_MESSAGE_MAP() |
| 153 | |
| 154 | ///////////////////////////////////////////////////////////////////////////// |
| 155 | // CWorldObjectsGenericDialog message handlers |
| 156 | |
| 157 | void CWorldObjectsGenericDialog::EnableDisableAll(bool flag) { |
| 158 | ((CButton *)GetDlgItem(IDC_GENERIC_USES_AI))->EnableWindow(flag); |
| 159 | ((CButton *)GetDlgItem(IDC_GENERIC_USES_PHYSICS))->EnableWindow(flag); |
| 160 | ((CButton *)GetDlgItem(IDC_GENERIC_CHECKED_OUT))->EnableWindow(flag); |
| 161 | ((CButton *)GetDlgItem(IDC_GENERIC_CHECKIN))->EnableWindow(flag); |
| 162 | ((CButton *)GetDlgItem(IDC_GENERIC_DEFINE_ANIMSTATES))->EnableWindow(flag); |
| 163 | ((CButton *)GetDlgItem(IDC_GENERIC_DELETE))->EnableWindow(flag); |
| 164 | ((CButton *)GetDlgItem(IDC_GENERIC_LOCK))->EnableWindow(flag); |
| 165 | ((CButton *)GetDlgItem(IDC_GENERIC_UNDO_LOCK))->EnableWindow(flag); |
| 166 | ((CButton *)GetDlgItem(IDC_GENERIC_NEXT))->EnableWindow(flag); |
| 167 | ((CButton *)GetDlgItem(IDC_GENERIC_PREV))->EnableWindow(flag); |
| 168 | ((CButton *)GetDlgItem(IDC_GENERIC_EDIT_PHYSICS))->EnableWindow(flag); |
| 169 | ((CButton *)GetDlgItem(IDC_GENERIC_EDIT_AI))->EnableWindow(flag); |
| 170 | ((CButton *)GetDlgItem(IDC_GENERIC_COPY))->EnableWindow(flag); |
| 171 | ((CButton *)GetDlgItem(IDC_GENERIC_CHANGE_NAME))->EnableWindow(flag); |
| 172 | ((CButton *)GetDlgItem(IDC_GENERIC_CHANGE_MODEL))->EnableWindow(flag); |
| 173 | ((CButton *)GetDlgItem(IDC_GENERIC_SIZE_EDIT))->EnableWindow(flag); |
| 174 | ((CButton *)GetDlgItem(IDC_GENERIC_DESTROYABLE))->EnableWindow(flag); |
| 175 | ((CButton *)GetDlgItem(IDC_GENERIC_AI_SCRIPTED_DEATH))->EnableWindow(flag); |
| 176 | ((CButton *)GetDlgItem(IDC_OBJ_CEILING_CHECK))->EnableWindow(flag); |
| 177 | ((CButton *)GetDlgItem(IDC_GENERIC_HITPOINT_EDIT))->EnableWindow(flag); |
| 178 | ((CButton *)GetDlgItem(IDC_GENERIC_SCORE_EDIT))->EnableWindow(flag); |
| 179 | ((CButton *)GetDlgItem(IDC_GENERIC_AMMO_EDIT))->EnableWindow(flag); |
| 180 | } |
| 181 | |
| 182 | // Returns true if the specified object is locked |
| 183 | bool CWorldObjectsGenericDialog::IsLocked(int n) { |
| 184 | return (mng_FindTrackLock(Object_info[n].name, PAGETYPE_GENERIC) != -1); |
| 185 | } |
| 186 | |
| 187 | // Returns the number of locked items of the current type |
| 188 | int CWorldObjectsGenericDialog::CountLockedItems() { |
| 189 | int lock_count = 0; |
| 190 | int first, n; |
| 191 | |
| 192 | first = n = GetObjectID(m_type); |
| 193 | |
| 194 | if (first == -1) |
| 195 | return 0; |
| 196 | |
| 197 | do { |
| 198 | if (IsLocked(n)) |
| 199 | lock_count++; |
| 200 | n = GetNextObjectID(n); |
| 201 | } while (n != first); |
| 202 | |
| 203 | return lock_count; |
| 204 | } |
| 205 | |
| 206 | #define NULL_NAME "<none>" |
| 207 | |
| 208 | void CWorldObjectsGenericDialog::UpdateDialog() { |
| 209 | CEdit *ebox; |
| 210 | CButton *bbox; |
| 211 | int first, n; |
| 212 | char txt[100]; |
| 213 | int i; |
| 214 | |
| 215 | if (m_current == -1) { |
| 216 | // ebox=(CEdit *) GetDlgItem (IDC_GENERIC_NAME_EDIT); |
| 217 | // ebox->SetWindowText ("NONE"); |
| 218 | EnableDisableAll(0); |
| 219 | |
| 220 | // Show paste button if you have the network, and there's an object in the copy buffer |
| 221 | ((CButton *)GetDlgItem(IDC_GENERIC_PASTE))->EnableWindow(Network_up && (Copy_object.type != OBJ_NONE)); |
| 222 | |
| 223 | return; |
| 224 | } |
| 225 | |
| 226 | EnableDisableAll(1); |
| 227 | |
| 228 | ebox = (CEdit *)GetDlgItem(IDC_GENERIC_MODEL_NAME_EDIT); |
| 229 | |
| 230 | PageInPolymodel(Object_info[m_current].render_handle); |
| 231 | |
| 232 | if (m_lod == 0) |
| 233 | ebox->SetWindowText(Poly_models[Object_info[m_current].render_handle].name); |
| 234 | else if (m_lod == 1) { |
| 235 | if (Object_info[m_current].med_render_handle == -1) |
| 236 | ebox->SetWindowText("No model defined"); |
| 237 | else |
| 238 | ebox->SetWindowText(Poly_models[Object_info[m_current].med_render_handle].name); |
| 239 | } else { |
| 240 | if (Object_info[m_current].lo_render_handle == -1) |
| 241 | ebox->SetWindowText("No model defined"); |
| 242 | else |
| 243 | ebox->SetWindowText(Poly_models[Object_info[m_current].lo_render_handle].name); |
| 244 | } |
| 245 | |
| 246 | // Do LOD distance edit box |
| 247 | ebox = (CEdit *)GetDlgItem(IDC_LOD_DISTANCE_EDIT); |
| 248 | |
| 249 | if (m_lod == 0) |
| 250 | ebox->SetWindowText("0"); |
| 251 | else if (m_lod == 1) { |
| 252 | sprintf(txt, "%f", Object_info[m_current].med_lod_distance); |
| 253 | ebox->SetWindowText(txt); |
| 254 | } else { |
| 255 | sprintf(txt, "%f", Object_info[m_current].lo_lod_distance); |
| 256 | ebox->SetWindowText(txt); |
| 257 | } |
| 258 | |
| 259 | int poly_handle; |
| 260 | if (m_lod == 0) |
| 261 | poly_handle = Object_info[m_current].render_handle; |
| 262 | else if (m_lod == 1) |
| 263 | poly_handle = Object_info[m_current].med_render_handle; |
| 264 | else |
| 265 | poly_handle = Object_info[m_current].lo_render_handle; |
| 266 | |
| 267 | if (poly_handle == -1) |
| 268 | sprintf(txt, "Num polys: NA"); |
| 269 | else { |
| 270 | PageInPolymodel(poly_handle); |
| 271 | sprintf(txt, "Num polys: %d", CountFacesInPolymodel(&Poly_models[poly_handle])); |
| 272 | } |
| 273 | ebox = (CEdit *)GetDlgItem(IDC_NUM_POLYS); |
| 274 | ebox->SetWindowText(txt); |
| 275 | |
| 276 | // Print out texture RAM usage |
| 277 | ebox = (CEdit *)GetDlgItem(IDC_TEXTURE_RAM_TEXT); |
| 278 | if (poly_handle == -1) |
| 279 | sprintf(txt, "Texture RAM: NA"); |
| 280 | else { |
| 281 | int tram = GetTextureUsageForPolymodel(poly_handle); |
| 282 | sprintf(txt, "Texture RAM: %dK", tram / 1000); |
| 283 | } |
| 284 | ebox->SetWindowText(txt); |
| 285 | |
| 286 | ebox = (CEdit *)GetDlgItem(IDC_RESPAWN_SCALAR_EDIT); |
| 287 | sprintf(txt, "%f", Object_info[m_current].respawn_scalar); |
| 288 | ebox->SetWindowText(txt); |
| 289 | |
| 290 | ebox = (CEdit *)GetDlgItem(IDC_GENERIC_IMPACT_SIZE_EDIT); |
| 291 | sprintf(txt, "%f", Object_info[m_current].impact_size); |
| 292 | ebox->SetWindowText(txt); |
| 293 | |
| 294 | ebox = (CEdit *)GetDlgItem(IDC_GENERIC_IMPACT_TIME_EDIT); |
| 295 | sprintf(txt, "%f", Object_info[m_current].impact_time); |
| 296 | ebox->SetWindowText(txt); |
| 297 | |
| 298 | ebox = (CEdit *)GetDlgItem(IDC_GENERIC_IMPACT_DAMAGE_EDIT); |
| 299 | sprintf(txt, "%f", Object_info[m_current].damage); |
| 300 | ebox->SetWindowText(txt); |
| 301 | |
| 302 | ebox = (CEdit *)GetDlgItem(IDC_DEATH_POWERUP1_NUM_EDIT); |
| 303 | sprintf(txt, "%d", Object_info[m_current].dspew_number[0]); |
| 304 | ebox->SetWindowText(txt); |
| 305 | |
| 306 | ebox = (CEdit *)GetDlgItem(IDC_DEATH_POWERUP2_NUM_EDIT); |
| 307 | sprintf(txt, "%d", Object_info[m_current].dspew_number[1]); |
| 308 | ebox->SetWindowText(txt); |
| 309 | |
| 310 | ebox = (CEdit *)GetDlgItem(IDC_DEATH_POWERUP1_PERCENT_EDIT); |
| 311 | sprintf(txt, "%f", Object_info[m_current].dspew_percent[0] * 100.0f); |
| 312 | ebox->SetWindowText(txt); |
| 313 | |
| 314 | ebox = (CEdit *)GetDlgItem(IDC_DEATH_POWERUP2_PERCENT_EDIT); |
| 315 | sprintf(txt, "%f", Object_info[m_current].dspew_percent[1] * 100.0f); |
| 316 | ebox->SetWindowText(txt); |
| 317 | |
| 318 | bbox = (CButton *)GetDlgItem(IDC_GENERIC_USES_PHYSICS); |
| 319 | bbox->SetCheck(Object_info[m_current].flags & OIF_USES_PHYSICS); |
| 320 | ((CButton *)GetDlgItem(IDC_GENERIC_EDIT_PHYSICS))->EnableWindow(Object_info[m_current].flags & OIF_USES_PHYSICS); |
| 321 | |
| 322 | bbox = (CButton *)GetDlgItem(IDC_DEATH_POWERUP_USE2_IF_HAVE1_CHECK); |
| 323 | bbox->SetCheck(Object_info[m_current].f_dspew & DSF_ONLY_IF_PLAYER_HAS_OBJ_1); |
| 324 | |
| 325 | bbox = (CButton *)GetDlgItem(IDC_GENERIC_DEATH_SPEW_2_IF_ZERO_1); |
| 326 | bbox->SetCheck(Object_info[m_current].f_dspew & DSF_ONLY_IF_NO_1); |
| 327 | |
| 328 | // Update the sound combo boxes |
| 329 | m_explosion_sound_combo.SetSelected(Object_info[m_current].sounds[GSI_EXPLODE]); |
| 330 | m_ambient_sound_combo.SetSelected(Object_info[m_current].sounds[GSI_AMBIENT]); |
| 331 | |
| 332 | SendDlgItemMessage(IDC_DEATH_POWERUP1_PULLDOWN, CB_RESETCONTENT, 0, 0); |
| 333 | SendDlgItemMessage(IDC_DEATH_POWERUP1_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)NULL_NAME); |
| 334 | for (i = 0; i < MAX_OBJECT_IDS; i++) { |
| 335 | if (Object_info[i].type != OBJ_NONE) |
| 336 | SendDlgItemMessage(IDC_DEATH_POWERUP1_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)Object_info[i].name); |
| 337 | } |
| 338 | if (Object_info[m_current].dspew[0] >= 0 && Object_info[m_current].dspew[0] < MAX_OBJECT_IDS && |
| 339 | Object_info[Object_info[m_current].dspew[0]].type != OBJ_NONE) |
| 340 | SendDlgItemMessage(IDC_DEATH_POWERUP1_PULLDOWN, CB_SELECTSTRING, 0, |
| 341 | (LPARAM)(LPCTSTR)Object_info[Object_info[m_current].dspew[0]].name); |
| 342 | else |
| 343 | SendDlgItemMessage(IDC_DEATH_POWERUP1_PULLDOWN, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR)NULL_NAME); |
| 344 | |
| 345 | SendDlgItemMessage(IDC_DEATH_POWERUP2_PULLDOWN, CB_RESETCONTENT, 0, 0); |
| 346 | SendDlgItemMessage(IDC_DEATH_POWERUP2_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)NULL_NAME); |
| 347 | for (i = 0; i < MAX_OBJECT_IDS; i++) { |
| 348 | if (Object_info[i].type != OBJ_NONE) |
| 349 | SendDlgItemMessage(IDC_DEATH_POWERUP2_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)Object_info[i].name); |
| 350 | } |
| 351 | if (Object_info[m_current].dspew[1] >= 0 && Object_info[m_current].dspew[1] < MAX_OBJECT_IDS && |
| 352 | Object_info[Object_info[m_current].dspew[1]].type != OBJ_NONE) |
| 353 | SendDlgItemMessage(IDC_DEATH_POWERUP2_PULLDOWN, CB_SELECTSTRING, 0, |
| 354 | (LPARAM)(LPCTSTR)Object_info[Object_info[m_current].dspew[1]].name); |
| 355 | else |
| 356 | SendDlgItemMessage(IDC_DEATH_POWERUP2_PULLDOWN, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR)NULL_NAME); |
| 357 | |
| 358 | // Edit AI box |
| 359 | bbox = (CButton *)GetDlgItem(IDC_GENERIC_USES_AI); |
| 360 | bbox->SetCheck(Object_info[m_current].flags & OIF_CONTROL_AI); |
| 361 | ((CButton *)GetDlgItem(IDC_GENERIC_EDIT_AI))->EnableWindow(Object_info[m_current].flags & OIF_CONTROL_AI); |
| 362 | |
| 363 | // Weapon Info box |
| 364 | ((CButton *)GetDlgItem(IDC_GENERIC_WEAPON_INFO_BUTTON)) |
| 365 | ->EnableWindow(Poly_models[Object_info[m_current].render_handle].num_wbs > 0); |
| 366 | |
| 367 | // Update the size in the edit box |
| 368 | sprintf(txt, "%.2f", Object_info[m_current].size); |
| 369 | ((CEdit *)GetDlgItem(IDC_GENERIC_SIZE_EDIT))->SetWindowText(txt); |
| 370 | |
| 371 | // Edit hitpoint box |
| 372 | bbox = (CButton *)GetDlgItem(IDC_GENERIC_DESTROYABLE); |
| 373 | bbox->SetCheck(Object_info[m_current].flags & OIF_DESTROYABLE); |
| 374 | ((CButton *)GetDlgItem(IDC_GENERIC_HITPOINT_EDIT))->EnableWindow(Object_info[m_current].flags & OIF_DESTROYABLE); |
| 375 | ((CButton *)GetDlgItem(IDC_GENERIC_SCORE_EDIT))->EnableWindow(Object_info[m_current].flags & OIF_DESTROYABLE); |
| 376 | |
| 377 | bbox = (CButton *)GetDlgItem(IDC_GENERIC_AI_SCRIPTED_DEATH); |
| 378 | bbox->SetCheck(Object_info[m_current].flags & OIF_AI_SCRIPTED_DEATH); |
| 379 | |
| 380 | bbox = (CButton *)GetDlgItem(IDC_OBJ_CEILING_CHECK); |
| 381 | bbox->SetCheck(Object_info[m_current].flags & OIF_DO_CEILING_CHECK); |
| 382 | |
| 383 | bbox = (CButton *)GetDlgItem(IDC_OBJECT_FLY_THROUGH_RENDERED_PORTALS); |
| 384 | bbox->SetCheck(Object_info[m_current].flags & OIF_IGNORE_FORCEFIELDS_AND_GLASS); |
| 385 | |
| 386 | bbox = (CButton *)GetDlgItem(IDC_NSC_BUTTON); |
| 387 | bbox->SetCheck(Object_info[m_current].flags & OIF_NO_DIFF_SCALE_DAMAGE); |
| 388 | |
| 389 | bbox = (CButton *)GetDlgItem(IDC_DSMPBD_CHECK); |
| 390 | bbox->SetCheck(Object_info[m_current].flags & OIF_NO_DIFF_SCALE_MOVE); |
| 391 | |
| 392 | bbox = (CButton *)GetDlgItem(IDC_GENERIC_AMBIENT); |
| 393 | bbox->SetCheck(Object_info[m_current].flags & OIF_AMBIENT_OBJECT); |
| 394 | |
| 395 | // Update the hit points in the edit box |
| 396 | sprintf(txt, (Object_info[m_current].flags & OIF_DESTROYABLE) ? "%d" : "", Object_info[m_current].hit_points); |
| 397 | ((CEdit *)GetDlgItem(IDC_GENERIC_HITPOINT_EDIT))->SetWindowText(txt); |
| 398 | |
| 399 | // Update the score in the edit box |
| 400 | sprintf(txt, (Object_info[m_current].flags & OIF_DESTROYABLE) ? "%d" : "", Object_info[m_current].score); |
| 401 | ((CEdit *)GetDlgItem(IDC_GENERIC_SCORE_EDIT))->SetWindowText(txt); |
| 402 | |
| 403 | // Update ammo control |
| 404 | sprintf(txt, "%d", Object_info[m_current].ammo_count); |
| 405 | ((CEdit *)GetDlgItem(IDC_GENERIC_AMMO_EDIT))->SetWindowText(txt); |
| 406 | ((CButton *)GetDlgItem(IDC_GENERIC_AMMO_TEXT))->EnableWindow(Object_info[m_current].type == OBJ_POWERUP); |
| 407 | ((CButton *)GetDlgItem(IDC_GENERIC_AMMO_EDIT))->EnableWindow(Object_info[m_current].type == OBJ_POWERUP); |
| 408 | |
| 409 | // Show script handle |
| 410 | // sprintf(txt,(Object_info[m_current].script_handle==-1)?"None":"%d",Object_info[m_current].script_handle); |
| 411 | // ((CEdit *) GetDlgItem(IDC_GENERIC_SCRIPT_ID_EDIT))->SetWindowText(txt); |
| 412 | |
| 413 | // Enabled show checked out button if there are items checked out |
| 414 | ((CButton *)GetDlgItem(IDC_GENERIC_CHECKED_OUT))->EnableWindow(m_locked_count > 0); |
| 415 | |
| 416 | // Show the current ID |
| 417 | sprintf(txt, "%d", m_current); |
| 418 | ((CEdit *)GetDlgItem(IDC_GENERIC_ID_EDIT))->SetWindowText(txt); |
| 419 | |
| 420 | // Show paste button if you have the network, and there's an object in the copy buffer |
| 421 | ((CButton *)GetDlgItem(IDC_GENERIC_PASTE))->EnableWindow(Network_up && (Copy_object.type != OBJ_NONE)); |
| 422 | |
| 423 | // Show delete button if page is locked |
| 424 | ((CButton *)GetDlgItem(IDC_GENERIC_DELETE))->EnableWindow(IsLocked(m_current)); |
| 425 | |
| 426 | // Show lock button if network is up, and item not already locked |
| 427 | ((CButton *)GetDlgItem(IDC_GENERIC_LOCK))->EnableWindow(Network_up && !IsLocked(m_current)); |
| 428 | |
| 429 | // Show checkin button if network is up, and item is locked |
| 430 | ((CButton *)GetDlgItem(IDC_GENERIC_CHECKIN))->EnableWindow(Network_up && IsLocked(m_current)); |
| 431 | |
| 432 | // Show undo lock button if network is up, and item is locked |
| 433 | ((CButton *)GetDlgItem(IDC_GENERIC_UNDO_LOCK))->EnableWindow(Network_up && IsLocked(m_current)); |
| 434 | |
| 435 | // Show add new button if network is up |
| 436 | ((CButton *)GetDlgItem(IDC_GENERIC_ADD_NEW))->EnableWindow(Network_up); |
| 437 | |
| 438 | // Reset name pulldown list |
| 439 | SendDlgItemMessage(IDC_GENERIC_NAME_PULLDOWN, CB_RESETCONTENT, 0, 0); |
| 440 | first = n = GetObjectID(m_type); |
| 441 | if (first != -1) { |
| 442 | do { |
| 443 | SendDlgItemMessage(IDC_GENERIC_NAME_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)Object_info[n].name); |
| 444 | n = GetNextObjectID(n); |
| 445 | } while (n != first); |
| 446 | n = SendDlgItemMessage(IDC_GENERIC_NAME_PULLDOWN, CB_FINDSTRINGEXACT, 0, |
| 447 | (LPARAM)(LPCTSTR)Object_info[m_current].name); |
| 448 | ASSERT(n != CB_ERR); |
| 449 | SendDlgItemMessage(IDC_GENERIC_NAME_PULLDOWN, CB_SETCURSEL, n, 0); |
| 450 | } |
| 451 | |
| 452 | // Reset script edit box |
| 453 | ebox = (CEdit *)GetDlgItem(IDC_SCRIPTNAME); |
| 454 | if (!Object_info[m_current].module_name[0]) |
| 455 | ebox->SetWindowText("null"); |
| 456 | else |
| 457 | ebox->SetWindowText(Object_info[m_current].module_name); |
| 458 | |
| 459 | ebox = (CEdit *)GetDlgItem(IDC_SCRIPT_OVERRIDE); |
| 460 | if (!Object_info[m_current].script_name_override[0]) |
| 461 | ebox->SetWindowText("null"); |
| 462 | else |
| 463 | ebox->SetWindowText(Object_info[m_current].script_name_override); |
| 464 | |
| 465 | bbox = (CButton *)GetDlgItem(IDC_GENERIC_INVEN_SELECTABLE); |
| 466 | bbox->SetCheck(Object_info[m_current].flags & OIF_INVEN_SELECTABLE); |
| 467 | |
| 468 | bbox = (CButton *)GetDlgItem(IDC_GENERIC_INVEN_NONUSEABLE); |
| 469 | bbox->SetCheck(Object_info[m_current].flags & OIF_INVEN_NONUSEABLE); |
| 470 | |
| 471 | bbox = (CButton *)GetDlgItem(IDC_INVEN_NOREMOVE); |
| 472 | bbox->SetCheck(Object_info[m_current].flags & OIF_INVEN_NOREMOVE); |
| 473 | |
| 474 | bbox = (CButton *)GetDlgItem(IDC_INVEN_VISWHENUSED); |
| 475 | bbox->SetCheck(Object_info[m_current].flags & OIF_INVEN_VISWHENUSED); |
| 476 | |
| 477 | if (Object_info[m_current].flags & OIF_INVEN_TYPE_MISSION) { |
| 478 | bbox = (CButton *)GetDlgItem(IDC_INVTYPE_MISSION); |
| 479 | bbox->SetCheck(true); |
| 480 | bbox = (CButton *)GetDlgItem(IDC_INVTYPE_GAME); |
| 481 | bbox->SetCheck(false); |
| 482 | } else { |
| 483 | bbox = (CButton *)GetDlgItem(IDC_INVTYPE_GAME); |
| 484 | bbox->SetCheck(true); |
| 485 | bbox = (CButton *)GetDlgItem(IDC_INVTYPE_MISSION); |
| 486 | bbox->SetCheck(false); |
| 487 | } |
| 488 | |
| 489 | ebox = (CEdit *)GetDlgItem(IDC_GENERIC_INVEN_DESCRIPTION); |
| 490 | if (!Object_info[m_current].description) |
| 491 | ebox->SetWindowText("<no description>"); |
| 492 | else |
| 493 | ebox->SetWindowText(Object_info[m_current].description); |
| 494 | |
| 495 | ebox = (CEdit *)GetDlgItem(IDC_GENERIC_INVEN_ICONNAME); |
| 496 | if (!Object_info[m_current].icon_name[0]) |
| 497 | ebox->SetWindowText("<no icon>"); |
| 498 | else |
| 499 | ebox->SetWindowText(Object_info[m_current].icon_name); |
| 500 | |
| 501 | ebox = (CEdit *)GetDlgItem(IDC_NOLOD); |
| 502 | if (m_lod == 0) |
| 503 | ebox->EnableWindow(FALSE); |
| 504 | else if (m_lod == 1) { |
| 505 | if (Object_info[m_current].med_render_handle == -1) |
| 506 | ebox->EnableWindow(FALSE); |
| 507 | else |
| 508 | ebox->EnableWindow(TRUE); |
| 509 | } else { |
| 510 | if (Object_info[m_current].lo_render_handle == -1) |
| 511 | ebox->EnableWindow(FALSE); |
| 512 | else |
| 513 | ebox->EnableWindow(TRUE); |
| 514 | } |
| 515 | |
| 516 | bbox = (CButton *)GetDlgItem(IDC_HIRES_RADIO); |
| 517 | bbox->SetCheck(m_lod == 0); |
| 518 | |
| 519 | bbox = (CButton *)GetDlgItem(IDC_MEDRES_RADIO); |
| 520 | bbox->SetCheck(m_lod == 1); |
| 521 | |
| 522 | bbox = (CButton *)GetDlgItem(IDC_LORES_RADIO); |
| 523 | bbox->SetCheck(m_lod == 2); |
| 524 | |
| 525 | // Update the picture |
| 526 | UpdateObjectView(); |
| 527 | } |
| 528 | |
| 529 | BOOL CWorldObjectsGenericDialog::OnInitDialog() { |
| 530 | static bool first_time = 1; |
| 531 | |
| 532 | m_type_name = Object_type_names[m_type]; |
| 533 | m_lod = 0; |
| 534 | |
| 535 | Copy_object.description = NULL; |
| 536 | |
| 537 | CDialog::OnInitDialog(); |
| 538 | |
| 539 | // Start the timer |
| 540 | CWnd::SetTimer(1, 50, NULL); |
| 541 | |
| 542 | // Make sure we have a valid object |
| 543 | if (Object_info[m_current].type != m_type) |
| 544 | m_current = GetObjectID(m_type); |
| 545 | |
| 546 | // Find out how many locked items |
| 547 | m_locked_count = CountLockedItems(); |
| 548 | |
| 549 | // Init copy/paste |
| 550 | if (first_time) { |
| 551 | Copy_object.type = OBJ_NONE; |
| 552 | first_time = 0; |
| 553 | } |
| 554 | |
| 555 | CEdit *edit = (CEdit *)GetDlgItem(IDC_GENERIC_INVEN_DESCRIPTION); |
| 556 | edit->LimitText(0); |
| 557 | |
| 558 | // Initialize sound combo boxes |
| 559 | m_explosion_sound_combo.Init(Object_info[m_current].sounds[GSI_EXPLODE]); |
| 560 | m_ambient_sound_combo.Init(Object_info[m_current].sounds[GSI_AMBIENT]); |
| 561 | |
| 562 | // Update all the fields |
| 563 | UpdateDialog(); |
| 564 | |
| 565 | return TRUE; // return TRUE unless you set the focus to a control |
| 566 | // EXCEPTION: OCX Property Pages should return FALSE |
| 567 | } |
| 568 | |
| 569 | void CWorldObjectsGenericDialog::OnGenericEditAI() { |
| 570 | CAISettingsDlg dlg(Object_info[m_current].ai_info); |
| 571 | |
| 572 | dlg.DoModal(); |
| 573 | } |
| 574 | |
| 575 | void CWorldObjectsGenericDialog::OnGenericEditPhysics() { |
| 576 | CPhysicsDlg dlg(&Object_info[m_current].phys_info); |
| 577 | |
| 578 | dlg.DoModal(); |
| 579 | } |
| 580 | |
| 581 | void CWorldObjectsGenericDialog::OnGenericUsesAI() { |
| 582 | CButton *btn; |
| 583 | |
| 584 | btn = (CButton *)GetDlgItem(IDC_GENERIC_USES_AI); |
| 585 | |
| 586 | if (btn->GetCheck()) |
| 587 | Object_info[m_current].flags |= OIF_CONTROL_AI; |
| 588 | else |
| 589 | Object_info[m_current].flags &= ~OIF_CONTROL_AI; |
| 590 | |
| 591 | ((CButton *)GetDlgItem(IDC_GENERIC_EDIT_AI))->EnableWindow(Object_info[m_current].flags & OIF_CONTROL_AI); |
| 592 | } |
| 593 | |
| 594 | void CWorldObjectsGenericDialog::OnGenericUsesPhysics() { |
| 595 | CButton *btn; |
| 596 | |
| 597 | btn = (CButton *)GetDlgItem(IDC_GENERIC_USES_PHYSICS); |
| 598 | |
| 599 | if (btn->GetCheck()) |
| 600 | Object_info[m_current].flags |= OIF_USES_PHYSICS; |
| 601 | else |
| 602 | Object_info[m_current].flags &= ~OIF_USES_PHYSICS; |
| 603 | |
| 604 | ((CButton *)GetDlgItem(IDC_GENERIC_EDIT_PHYSICS))->EnableWindow(Object_info[m_current].flags & OIF_USES_PHYSICS); |
| 605 | } |
| 606 | |
| 607 | // Gets a name from the user, making sure it's unique |
| 608 | // Returns true if got new name, false if cancelled. |
| 609 | // the data in buf not changed if cancel is pressed |
| 610 | bool InputObjectName(char *buf, int len, char *title, char *prompt, CWnd *wnd) { |
| 611 | if (len > (PAGENAME_LEN - 1)) |
| 612 | len = PAGENAME_LEN - 1; |
| 613 | |
| 614 | char *tempbuf = (char *)mem_malloc(len); |
| 615 | |
| 616 | strncpy(tempbuf, buf, len - 1); |
| 617 | tempbuf[len - 1] = '\0'; |
| 618 | |
| 619 | try_again: |
| 620 | |
| 621 | if (!InputString(tempbuf, len, title, prompt, wnd)) { |
| 622 | mem_free(tempbuf); |
| 623 | return 0; |
| 624 | } |
| 625 | |
| 626 | if (FindObjectIDName(tempbuf) != -1) { |
| 627 | OutrageMessageBox("The name you specified is already in use. Enter another name."); |
| 628 | goto try_again; |
| 629 | } |
| 630 | |
| 631 | strcpy(buf, tempbuf); |
| 632 | mem_free(tempbuf); |
| 633 | |
| 634 | return 1; |
| 635 | } |
| 636 | |
| 637 | void CWorldObjectsGenericDialog::OnGenericAddNew() { |
| 638 | char filename[256], dir[256], fname[256], ext[32]; |
| 639 | char cur_name[100], *t; |
| 640 | int img_handle; |
| 641 | int object_handle; |
| 642 | int c = 1, finding_name = 1; |
| 643 | |
| 644 | ASSERT(Network_up); |
| 645 | |
| 646 | // Get the filename of the representing image |
| 647 | |
| 648 | CString filter = "Descent III files (*.pof,*.oof)|*.pof;*.oof||"; |
| 649 | |
| 650 | if (!OpenFileDialog(this, (LPCTSTR)filter, filename, Current_model_dir, sizeof(Current_model_dir))) |
| 651 | return; |
| 652 | |
| 653 | ddio_SplitPath(filename, dir, fname, ext); |
| 654 | |
| 655 | std::filesystem::path tmp = ChangePolyModelName(filename); |
| 656 | strcpy(cur_name, tmp.u8string().c_str()); |
| 657 | |
| 658 | if ((FindPolyModelName(fname)) != -1) { |
| 659 | OutrageMessageBox("You must rename your model to something else because there is already a model with that name!"); |
| 660 | return; |
| 661 | } |
| 662 | |
| 663 | // Okay, we selected a file. Lets do what needs to be done here. |
| 664 | img_handle = LoadPolyModel(filename, 0); |
| 665 | |
| 666 | if (img_handle < 0) { |
| 667 | OutrageMessageBox("Couldn't open that model file."); |
| 668 | return; |
| 669 | } |
| 670 | |
| 671 | // Get a default name |
| 672 | strcpy(cur_name, fname); // Start with the filename |
| 673 | t = strchr(cur_name, '.'); // Strip the extention |
| 674 | if (!t) |
| 675 | t = cur_name + strlen(cur_name); |
| 676 | *t = 0; |
| 677 | do { // Make sure the name not already in use |
| 678 | int c = 0; |
| 679 | |
| 680 | if (FindObjectIDName(cur_name) == -1) |
| 681 | break; |
| 682 | |
| 683 | *t = 0; |
| 684 | sprintf(cur_name, "%s%d", cur_name, ++c); |
| 685 | } while (1); |
| 686 | cur_name[0] = toupper(cur_name[0]); // make first char uppercase |
| 687 | |
| 688 | // Get the object name from the user |
| 689 | retry_name: |
| 690 | |
| 691 | if (!InputObjectName(cur_name, sizeof(cur_name), "Object name", "Enter a name for your object:", this)) |
| 692 | return; |
| 693 | |
| 694 | if (FindObjectIDName(cur_name) != -1) { |
| 695 | OutrageMessageBox("That name is taken, please choose another."); |
| 696 | goto retry_name; |
| 697 | } |
| 698 | |
| 699 | // Alloc an object and give a name not already taken by some other object |
| 700 | |
| 701 | object_handle = AllocObjectID(m_type, true, true, true); |
| 702 | |
| 703 | if (object_handle == -1) { |
| 704 | OutrageMessageBox("Cannot add object: There are no free object slots."); |
| 705 | return; |
| 706 | } |
| 707 | |
| 708 | strcpy(Object_info[object_handle].name, cur_name); |
| 709 | |
| 710 | Object_info[object_handle].render_handle = img_handle; |
| 711 | |
| 712 | // figure out size of object |
| 713 | ComputeDefaultSize(Object_info[object_handle].type, img_handle, &Object_info[object_handle].size); |
| 714 | |
| 715 | // Init some stuff |
| 716 | Object_info[object_handle].flags = OIF_DESTROYABLE; |
| 717 | Object_info[object_handle].hit_points = 100; |
| 718 | memset(&Object_info[object_handle].lighting_info, 0, sizeof(light_info)); |
| 719 | Object_info[object_handle].lighting_info.timebits = 0xFFFFFFFF; |
| 720 | if (m_type == OBJ_BUILDING) |
| 721 | Object_info[object_handle].lighting_info.lighting_render_type = LRT_LIGHTMAPS; |
| 722 | else |
| 723 | Object_info[object_handle].lighting_info.lighting_render_type = LRT_GOURAUD; |
| 724 | |
| 725 | // Finally, save a local copy of the model/anim and alloc a tracklock |
| 726 | mprintf(0, "Making a copy of this model locally...\n"); |
| 727 | |
| 728 | std::filesystem::path destname = LocalModelsDir / Poly_models[Object_info[object_handle].render_handle].name; |
| 729 | cf_CopyFile(destname, filename); |
| 730 | |
| 731 | mng_AllocTrackLock(cur_name, PAGETYPE_GENERIC); |
| 732 | |
| 733 | m_current = object_handle; |
| 734 | |
| 735 | RemapStaticIDs(); |
| 736 | |
| 737 | UpdateDialog(); |
| 738 | } |
| 739 | |
| 740 | void CWorldObjectsGenericDialog::OnGenericCheckedOut() { |
| 741 | char str[10000]; |
| 742 | int total = 0; |
| 743 | |
| 744 | mng_DisplayLockList(TableUser); |
| 745 | |
| 746 | sprintf(str, "User %s has these objects held locally:\n\n", TableUser); |
| 747 | for (int i = 0; i < MAX_TRACKLOCKS; i++) { |
| 748 | |
| 749 | if (GlobalTrackLocks[i].used && GlobalTrackLocks[i].pagetype == PAGETYPE_GENERIC) { |
| 750 | |
| 751 | int n = FindObjectIDName(GlobalTrackLocks[i].name); |
| 752 | |
| 753 | ASSERT(n != -1); |
| 754 | |
| 755 | if (Object_info[n].type == m_type) { // found one of our type |
| 756 | strcat(str, " "); |
| 757 | strcat(str, GlobalTrackLocks[i].name); |
| 758 | strcat(str, "\n"); |
| 759 | total++; |
| 760 | } |
| 761 | } |
| 762 | } |
| 763 | |
| 764 | if (total != 0) // Display list |
| 765 | MessageBox(str, "Textures", MB_OK); |
| 766 | } |
| 767 | |
| 768 | void CWorldObjectsGenericDialog::OnGenericCheckIn() { |
| 769 | mngs_Pagelock temp_pl; |
| 770 | int r; |
| 771 | |
| 772 | if (m_current == -1) |
| 773 | return; |
| 774 | |
| 775 | if (!mng_MakeLocker()) |
| 776 | return; |
| 777 | |
| 778 | // Make sure we own this object |
| 779 | strcpy(temp_pl.name, Object_info[m_current].name); |
| 780 | temp_pl.pagetype = PAGETYPE_GENERIC; |
| 781 | |
| 782 | r = mng_CheckIfPageOwned(&temp_pl, TableUser); |
| 783 | if (r < 0) |
| 784 | OutrageMessageBox(ErrorString); |
| 785 | else if (r == 0) |
| 786 | OutrageMessageBox(InfoString); |
| 787 | else { |
| 788 | // Change the pagelock state to UNLOCKED |
| 789 | strcpy(temp_pl.holder, "UNLOCKED"); |
| 790 | if (!mng_ReplacePagelock(temp_pl.name, &temp_pl)) { |
| 791 | MessageBox(ErrorString, "Error!"); |
| 792 | mng_EraseLocker(); |
| 793 | return; |
| 794 | } else { |
| 795 | // Now actually replace the copy on the net with our local one |
| 796 | |
| 797 | if (!mng_ReplacePage(Object_info[m_current].name, Object_info[m_current].name, m_current, PAGETYPE_GENERIC, 0)) |
| 798 | OutrageMessageBox(ErrorString); |
| 799 | else { |
| 800 | // Save this object anim/model to the network for all |
| 801 | |
| 802 | std::filesystem::path srcname = LocalModelsDir / Poly_models[Object_info[m_current].render_handle].name; |
| 803 | std::filesystem::path destname = NetModelsDir / Poly_models[Object_info[m_current].render_handle].name; |
| 804 | cf_CopyFile(destname, srcname); |
| 805 | |
| 806 | if (Object_info[m_current].med_render_handle != -1) { |
| 807 | srcname = LocalModelsDir / Poly_models[Object_info[m_current].med_render_handle].name; |
| 808 | destname = NetModelsDir / Poly_models[Object_info[m_current].med_render_handle].name; |
| 809 | cf_CopyFile(destname, srcname); |
| 810 | } |
| 811 | |
| 812 | if (Object_info[m_current].lo_render_handle != -1) { |
| 813 | srcname = LocalModelsDir / Poly_models[Object_info[m_current].lo_render_handle].name; |
| 814 | destname = NetModelsDir / Poly_models[Object_info[m_current].lo_render_handle].name; |
| 815 | cf_CopyFile(destname, srcname); |
| 816 | } |
| 817 | |
| 818 | OutrageMessageBox("Object checked in."); |
| 819 | |
| 820 | // Delete it from local pagefile if its there |
| 821 | int dret = mng_DeletePage(Object_info[m_current].name, PAGETYPE_GENERIC, 1); |
| 822 | |
| 823 | ASSERT(dret == 1); |
| 824 | mng_EraseLocker(); |
| 825 | |
| 826 | // Free the tracklock |
| 827 | int p = mng_FindTrackLock(Object_info[m_current].name, PAGETYPE_GENERIC); |
| 828 | ASSERT(p != -1); |
| 829 | mng_FreeTrackLock(p); |
| 830 | UpdateDialog(); |
| 831 | } |
| 832 | } |
| 833 | } |
| 834 | |
| 835 | UpdateDialog(); |
| 836 | } |
| 837 | |
| 838 | void CWorldObjectsGenericDialog::OnGenericDefineAnimStates() { |
| 839 | if (m_current == -1) |
| 840 | return; |
| 841 | |
| 842 | CAnimStatesDialog dlg(Object_info[m_current].render_handle, Object_info[m_current].anim); |
| 843 | |
| 844 | if (dlg.DoModal() == IDOK) // Copy back into object |
| 845 | dlg.GetAnimData(Object_info[m_current].anim); |
| 846 | } |
| 847 | |
| 848 | void CWorldObjectsGenericDialog::OnGenericDelete() { |
| 849 | int answer, tl; |
| 850 | mngs_Pagelock pl; |
| 851 | int old_current; |
| 852 | |
| 853 | if (m_current == -1) |
| 854 | return; |
| 855 | |
| 856 | // Check to see if we even have it locked |
| 857 | if ((tl = mng_FindTrackLock(Object_info[m_current].name, PAGETYPE_GENERIC)) == -1) { |
| 858 | OutrageMessageBox("This object is not yours to delete. Lock first."); |
| 859 | return; |
| 860 | } |
| 861 | |
| 862 | // Make sure its to be deleted |
| 863 | answer = MessageBox("Are you sure you want to delete this object?", Object_info[m_current].name, MB_YESNO); |
| 864 | if (answer == IDNO) |
| 865 | return; |
| 866 | |
| 867 | if (!mng_MakeLocker()) |
| 868 | return; |
| 869 | |
| 870 | strcpy(pl.name, Object_info[m_current].name); |
| 871 | pl.pagetype = PAGETYPE_GENERIC; |
| 872 | |
| 873 | // Check to see if this is a local object only. If so, only delete it locally |
| 874 | if (mng_CheckIfPageOwned(&pl, TableUser) != 1) { |
| 875 | mng_FreeTrackLock(tl); |
| 876 | if (!mng_DeletePage(Object_info[m_current].name, PAGETYPE_GENERIC, 1)) { |
| 877 | mprintf(0, ErrorString); |
| 878 | Int3(); |
| 879 | } |
| 880 | } else // if its network, delete it from both the net and local drives |
| 881 | { |
| 882 | |
| 883 | mng_FreeTrackLock(tl); |
| 884 | mng_DeletePage(Object_info[m_current].name, PAGETYPE_GENERIC, 0); |
| 885 | mng_DeletePage(Object_info[m_current].name, PAGETYPE_GENERIC, 1); |
| 886 | |
| 887 | mng_DeletePagelock(Object_info[m_current].name, PAGETYPE_GENERIC); |
| 888 | } |
| 889 | |
| 890 | // Advance to the next object |
| 891 | old_current = m_current; |
| 892 | m_current = GetNextObjectID(m_current); |
| 893 | if (m_current == old_current) |
| 894 | m_current = -1; |
| 895 | |
| 896 | FreePolyModel(Object_info[old_current].render_handle); |
| 897 | |
| 898 | if (Object_info[old_current].med_render_handle != -1) |
| 899 | FreePolyModel(Object_info[old_current].med_render_handle); |
| 900 | if (Object_info[old_current].lo_render_handle != -1) |
| 901 | FreePolyModel(Object_info[old_current].lo_render_handle); |
| 902 | |
| 903 | FreeObjectID(old_current); |
| 904 | mng_EraseLocker(); |
| 905 | |
| 906 | OutrageMessageBox("Object deleted."); |
| 907 | |
| 908 | RemapStaticIDs(); |
| 909 | |
| 910 | UpdateDialog(); |
| 911 | } |
| 912 | |
| 913 | void CWorldObjectsGenericDialog::OnGenericLock() { |
| 914 | mngs_Pagelock temp_pl; |
| 915 | mngs_generic_page page; |
| 916 | int r; |
| 917 | |
| 918 | if (m_current == -1) |
| 919 | return; |
| 920 | |
| 921 | if (!mng_MakeLocker()) |
| 922 | return; |
| 923 | |
| 924 | // Make sure it can be locked |
| 925 | strcpy(temp_pl.name, Object_info[m_current].name); |
| 926 | temp_pl.pagetype = PAGETYPE_GENERIC; |
| 927 | |
| 928 | r = mng_CheckIfPageLocked(&temp_pl); |
| 929 | if (r == 2) { |
| 930 | int answer; |
| 931 | answer = OutrageMessageBox(MBOX_YESNO, "This page is not even in the table file, or the database maybe corrupt. " |
| 932 | "Override to 'Unlocked'? (Select NO if you don't know what you're doing)"); |
| 933 | if (answer == IDYES) { |
| 934 | strcpy(temp_pl.holder, "UNLOCKED"); |
| 935 | if (!mng_ReplacePagelock(temp_pl.name, &temp_pl)) |
| 936 | MessageBox(ErrorString, "Error!"); |
| 937 | } |
| 938 | } else if (r < 0) |
| 939 | OutrageMessageBox(ErrorString); |
| 940 | else if (r == 1) |
| 941 | OutrageMessageBox(InfoString); |
| 942 | else { |
| 943 | // Everything is ok. Tell the network we're locking it and get a copy to |
| 944 | // our local drive |
| 945 | |
| 946 | strcpy(temp_pl.holder, TableUser); |
| 947 | if (!mng_ReplacePagelock(temp_pl.name, &temp_pl)) { |
| 948 | MessageBox(ErrorString, "Error!"); |
| 949 | mng_EraseLocker(); |
| 950 | return; |
| 951 | } else { |
| 952 | // Search thru the net pagefile and get a new copy in RAM in case anyone |
| 953 | // changed it since we started the editor |
| 954 | if (mng_FindSpecificGenericPage(temp_pl.name, &page)) { |
| 955 | if (mng_AssignGenericPageToObjInfo(&page, m_current)) { |
| 956 | if (!mng_ReplacePage(Object_info[m_current].name, Object_info[m_current].name, m_current, PAGETYPE_GENERIC, |
| 957 | 1)) { |
| 958 | OutrageMessageBox("There was problem writing that page locally!"); |
| 959 | mng_EraseLocker(); |
| 960 | return; |
| 961 | } |
| 962 | OutrageMessageBox("Object locked."); |
| 963 | } else |
| 964 | OutrageMessageBox( |
| 965 | "There was a problem loading this object. You might encounter problems in dealing with it. Good luck!"); |
| 966 | |
| 967 | mng_AllocTrackLock(Object_info[m_current].name, PAGETYPE_GENERIC); |
| 968 | UpdateDialog(); |
| 969 | } else |
| 970 | OutrageMessageBox("Couldn't find that object in the table file!"); |
| 971 | } |
| 972 | } |
| 973 | mng_EraseLocker(); |
| 974 | UpdateDialog(); |
| 975 | } |
| 976 | |
| 977 | void CWorldObjectsGenericDialog::OnGenericNext() { |
| 978 | m_current = GetNextObjectID(m_current); |
| 979 | m_lod = 0; |
| 980 | |
| 981 | UpdateDialog(); |
| 982 | } |
| 983 | |
| 984 | void CWorldObjectsGenericDialog::OnGenericPrev() { |
| 985 | m_current = GetPrevObjectID(m_current); |
| 986 | m_lod = 0; |
| 987 | |
| 988 | UpdateDialog(); |
| 989 | } |
| 990 | |
| 991 | void CWorldObjectsGenericDialog::OnGenericChangeModel() { |
| 992 | char filename[255]; |
| 993 | char curname[255]; |
| 994 | char fname[255]; |
| 995 | char dir[255]; |
| 996 | char ext[100]; |
| 997 | int img_handle; |
| 998 | int c = 1, finding_name = 1; |
| 999 | int model = 0; |
| 1000 | |
| 1001 | // Get the filename of the representing image |
| 1002 | |
| 1003 | CString filter = "Descent III files (*.pof,*.oof)|*.pof;*.oof||"; |
| 1004 | |
| 1005 | if (!OpenFileDialog(this, (LPCTSTR)filter, filename, Current_model_dir, sizeof(Current_model_dir))) |
| 1006 | return; |
| 1007 | |
| 1008 | std::filesystem::path tmp = ChangePolyModelName(filename); |
| 1009 | strcpy(curname, tmp.u8string().c_str()); |
| 1010 | |
| 1011 | ddio_SplitPath(filename, dir, fname, ext); |
| 1012 | |
| 1013 | if ((FindPolyModelName(curname)) != -1) { |
| 1014 | |
| 1015 | int answer = MessageBox("There is already a model in memory with this name. Are you sure you want to replace it?", |
| 1016 | fname, MB_YESNO); |
| 1017 | if (answer == IDNO) |
| 1018 | return; |
| 1019 | } |
| 1020 | |
| 1021 | // Okay, we selected a file. Lets do what needs to be done here. |
| 1022 | img_handle = LoadPolyModel(filename, 0); |
| 1023 | |
| 1024 | if (img_handle < 0) { |
| 1025 | OutrageMessageBox("Couldn't open that animation/model file."); |
| 1026 | return; |
| 1027 | } |
| 1028 | |
| 1029 | if (m_lod == 0) { |
| 1030 | ChangeOldModelsForObjects(Object_info[m_current].render_handle, img_handle); |
| 1031 | FreePolyModel(Object_info[m_current].render_handle); |
| 1032 | Object_info[m_current].render_handle = img_handle; |
| 1033 | } else if (m_lod == 1) { |
| 1034 | if (Object_info[m_current].med_render_handle != -1) |
| 1035 | FreePolyModel(Object_info[m_current].med_render_handle); |
| 1036 | |
| 1037 | Object_info[m_current].med_render_handle = img_handle; |
| 1038 | } else { |
| 1039 | if (Object_info[m_current].lo_render_handle != -1) |
| 1040 | FreePolyModel(Object_info[m_current].lo_render_handle); |
| 1041 | |
| 1042 | Object_info[m_current].lo_render_handle = img_handle; |
| 1043 | } |
| 1044 | |
| 1045 | // A new model might induce a new weapon stucture |
| 1046 | if (OutrageMessageBox(MBOX_YESNO, "Would you like to clear the weapon battery info?") == IDYES) { |
| 1047 | WBClearInfo(Object_info[m_current].static_wb); |
| 1048 | } |
| 1049 | // Finally, save a local copy of the model |
| 1050 | |
| 1051 | sprintf(curname, "%s\\%s", LocalModelsDir.u8string().c_str(), Poly_models[img_handle].name); |
| 1052 | cf_CopyFile(curname, filename); |
| 1053 | |
| 1054 | UpdateDialog(); |
| 1055 | } |
| 1056 | |
| 1057 | void CWorldObjectsGenericDialog::OnGenericChangeName() { |
| 1058 | char name[PAGENAME_LEN]; |
| 1059 | mngs_Pagelock pl; |
| 1060 | |
| 1061 | // Make sure we have this ship locked, if not reset name and bail |
| 1062 | int p = mng_FindTrackLock(Object_info[m_current].name, PAGETYPE_GENERIC); |
| 1063 | if (p == -1) { |
| 1064 | OutrageMessageBox("You must lock this object if you wish to change its name."); |
| 1065 | return; |
| 1066 | } |
| 1067 | |
| 1068 | // Get new name |
| 1069 | retry_name: |
| 1070 | strcpy(name, Object_info[m_current].name); |
| 1071 | if (!InputObjectName(name, sizeof(name), "Object name", "Enter a new name for this object:", this)) |
| 1072 | return; |
| 1073 | |
| 1074 | if (FindObjectIDName(name) != -1) { |
| 1075 | OutrageMessageBox("That name is taken, please choose another."); |
| 1076 | goto retry_name; |
| 1077 | } |
| 1078 | |
| 1079 | if (!mng_MakeLocker()) |
| 1080 | return; |
| 1081 | |
| 1082 | // Check to see if this page exists on the network. If so, we have to |
| 1083 | // rename it so we can prevent havoc |
| 1084 | strcpy(pl.name, Object_info[m_current].name); |
| 1085 | pl.pagetype = PAGETYPE_GENERIC; |
| 1086 | |
| 1087 | int ret = mng_CheckIfPageOwned(&pl, TableUser); |
| 1088 | if (ret < 0) |
| 1089 | OutrageMessageBox(ErrorString); |
| 1090 | else if (ret == 1) |
| 1091 | mng_RenamePage(Object_info[m_current].name, name, PAGETYPE_GENERIC); |
| 1092 | else if (ret == 2) { |
| 1093 | // This page has never been checked in, replace only local copy |
| 1094 | |
| 1095 | char oldname[PAGENAME_LEN]; |
| 1096 | strcpy(oldname, Object_info[m_current].name); |
| 1097 | strcpy(Object_info[m_current].name, name); |
| 1098 | |
| 1099 | mng_ReplacePage(oldname, Object_info[m_current].name, m_current, PAGETYPE_GENERIC, 1); |
| 1100 | } else if (ret == 0) { |
| 1101 | OutrageMessageBox("You don't own this page. Get Jason now!"); |
| 1102 | mng_FreeTrackLock(p); |
| 1103 | return; |
| 1104 | } |
| 1105 | |
| 1106 | // Finally, copy our new name to the appropriate arrays |
| 1107 | strcpy(GlobalTrackLocks[p].name, name); |
| 1108 | strcpy(Object_info[m_current].name, name); |
| 1109 | mng_EraseLocker(); |
| 1110 | |
| 1111 | RemapStaticIDs(); |
| 1112 | |
| 1113 | // check to see if current has been remapped |
| 1114 | if (Object_info[m_current].type != m_type) |
| 1115 | m_current = GetObjectID(m_type); |
| 1116 | |
| 1117 | UpdateDialog(); |
| 1118 | } |
| 1119 | |
| 1120 | #define NUM_ANIM_FRAMES 30 |
| 1121 | |
| 1122 | void CWorldObjectsGenericDialog::UpdateObjectView(void) { |
| 1123 | CWnd *objwnd; |
| 1124 | RECT rect; |
| 1125 | int x, y, bm_handle, w, h; |
| 1126 | static int frame = 0, spin_frame = 0; |
| 1127 | static int last_object = -1; |
| 1128 | static int last_render_handle = -1; |
| 1129 | static int object_dir = 0; |
| 1130 | |
| 1131 | if (m_current == -1) |
| 1132 | return; |
| 1133 | |
| 1134 | if (object_dir == 0) { |
| 1135 | frame++; |
| 1136 | if (frame == NUM_ANIM_FRAMES) { |
| 1137 | frame = NUM_ANIM_FRAMES - 1; |
| 1138 | object_dir = 1; |
| 1139 | } |
| 1140 | } else { |
| 1141 | frame--; |
| 1142 | if (frame == -1) { |
| 1143 | frame = 0; |
| 1144 | object_dir = 0; |
| 1145 | } |
| 1146 | } |
| 1147 | |
| 1148 | objwnd = GetDlgItem(IDC_GENERIC_OBJECTVIEW); |
| 1149 | objwnd->GetWindowRect(&rect); |
| 1150 | ScreenToClient(&rect); |
| 1151 | |
| 1152 | Desktop_surf->attach_to_window((unsigned)m_hWnd); |
| 1153 | |
| 1154 | w = rect.right - rect.left; |
| 1155 | h = rect.bottom - rect.top; |
| 1156 | |
| 1157 | int render_handle; |
| 1158 | |
| 1159 | if (m_lod == 0) |
| 1160 | render_handle = Object_info[m_current].render_handle; |
| 1161 | else if (m_lod == 1) |
| 1162 | render_handle = Object_info[m_current].med_render_handle; |
| 1163 | else |
| 1164 | render_handle = Object_info[m_current].lo_render_handle; |
| 1165 | |
| 1166 | if (last_object != m_current || last_render_handle != render_handle) { |
| 1167 | Desktop_surf->clear(rect.left, rect.top, w, h); |
| 1168 | last_object = m_current; |
| 1169 | last_render_handle = render_handle; |
| 1170 | } |
| 1171 | |
| 1172 | bm_handle = render_handle; |
| 1173 | |
| 1174 | if (bm_handle == -1) |
| 1175 | return; |
| 1176 | |
| 1177 | vector zero_vector; |
| 1178 | vector view_vector = {0, 0, -20}; |
| 1179 | matrix id_matrix, rot_matrix; |
| 1180 | poly_model *pm = GetPolymodelPointer(bm_handle); |
| 1181 | |
| 1182 | vm_MakeZero(&zero_vector); |
| 1183 | vm_MakeIdentity(&id_matrix); |
| 1184 | |
| 1185 | float norm_angles[256]; |
| 1186 | |
| 1187 | float keyframe = pm->frame_min + (pm->frame_max - pm->frame_min) * ((float)frame / (float)NUM_ANIM_FRAMES); |
| 1188 | |
| 1189 | SetNormalizedTimeAnim(keyframe, norm_angles, pm); |
| 1190 | |
| 1191 | spin_frame++; |
| 1192 | |
| 1193 | vm_AnglesToMatrix(&rot_matrix, 0, spin_frame * 400, 0); |
| 1194 | view_vector.z = -(fabs(pm->maxs.z - pm->mins.z) * 2); |
| 1195 | |
| 1196 | m_ObjectSurf.create(128, 128, BPP_16); |
| 1197 | grViewport *vport = new grViewport(&m_ObjectSurf); |
| 1198 | StartEditorFrame(vport, &view_vector, &id_matrix, D3_DEFAULT_ZOOM); |
| 1199 | DrawPolygonModel(&zero_vector, &rot_matrix, bm_handle, norm_angles, 0, 1.0, 1.0, 1.0); |
| 1200 | EndEditorFrame(); |
| 1201 | |
| 1202 | x = rect.left + ((rect.right - rect.left) / 2) - m_ObjectSurf.width() / 2; |
| 1203 | y = rect.top + ((rect.bottom - rect.top) / 2) - m_ObjectSurf.height() / 2; |
| 1204 | Desktop_surf->blt(x, y, &m_ObjectSurf); |
| 1205 | |
| 1206 | delete vport; |
| 1207 | m_ObjectSurf.free(); |
| 1208 | } |
| 1209 | |
| 1210 | void CWorldObjectsGenericDialog::OnTimer(UINT nIDEvent) { |
| 1211 | UpdateObjectView(); |
| 1212 | |
| 1213 | CDialog::OnTimer(nIDEvent); |
| 1214 | } |
| 1215 | |
| 1216 | void CWorldObjectsGenericDialog::OnSelendokGenericNamePulldown() { |
| 1217 | int i, cur; |
| 1218 | char name[200]; |
| 1219 | |
| 1220 | cur = SendDlgItemMessage(IDC_GENERIC_NAME_PULLDOWN, CB_GETCURSEL, 0, 0); |
| 1221 | SendDlgItemMessage(IDC_GENERIC_NAME_PULLDOWN, CB_GETLBTEXT, cur, (LPARAM)(LPCTSTR)name); |
| 1222 | |
| 1223 | i = FindObjectIDName(name); |
| 1224 | |
| 1225 | if (i == -1) { |
| 1226 | mprintf(0, "Possible corrupted object list, but probably nothing."); |
| 1227 | } else { |
| 1228 | ASSERT(Object_info[i].type == m_type); |
| 1229 | m_current = i; |
| 1230 | } |
| 1231 | |
| 1232 | UpdateDialog(); |
| 1233 | } |
| 1234 | |
| 1235 | void CWorldObjectsGenericDialog::OnKillfocusGenericSizeEdit() { |
| 1236 | char str[20]; |
| 1237 | |
| 1238 | ((CEdit *)GetDlgItem(IDC_GENERIC_SIZE_EDIT))->GetWindowText(str, 20); |
| 1239 | |
| 1240 | Object_info[m_current].size = atof(str); |
| 1241 | } |
| 1242 | |
| 1243 | void CWorldObjectsGenericDialog::OnKillfocusGenericScriptIDEdit() { |
| 1244 | /* |
| 1245 | char str[20]; |
| 1246 | |
| 1247 | ((CEdit *) GetDlgItem(IDC_GENERIC_SCRIPT_ID_EDIT))->GetWindowText(str,20); |
| 1248 | |
| 1249 | strcpy(Object_info[m_current].script_name, str); |
| 1250 | */ |
| 1251 | } |
| 1252 | |
| 1253 | void CWorldObjectsGenericDialog::OnGenericCopy() { |
| 1254 | if (m_current != -1) { |
| 1255 | if (Copy_object.description) { |
| 1256 | mem_free(Copy_object.description); |
| 1257 | } |
| 1258 | |
| 1259 | Copy_object = Object_info[m_current]; |
| 1260 | |
| 1261 | Copy_object.description = NULL; |
| 1262 | |
| 1263 | if (!Object_info[m_current].description) |
| 1264 | Copy_object.description = mem_strdup("<no description>"); |
| 1265 | else |
| 1266 | Copy_object.description = mem_strdup(Object_info[m_current].description); |
| 1267 | } |
| 1268 | |
| 1269 | UpdateDialog(); |
| 1270 | } |
| 1271 | |
| 1272 | void CWorldObjectsGenericDialog::OnGenericPaste() { |
| 1273 | char temp_name[PAGENAME_LEN + 10]; // need to add some space for the "CopyxOf" |
| 1274 | int n; |
| 1275 | |
| 1276 | ASSERT(Network_up); |
| 1277 | |
| 1278 | ASSERT(Copy_object.type != OBJ_NONE); |
| 1279 | |
| 1280 | if (Copy_object.type != m_type) { |
| 1281 | if (OutrageMessageBox(MBOX_YESNO, "You are about to paste a %s object as a %s. Is this OK?", |
| 1282 | Object_type_names[Copy_object.type], Object_type_names[m_type]) != IDYES) |
| 1283 | return; |
| 1284 | } |
| 1285 | |
| 1286 | // Get the name of the new object |
| 1287 | strcpy(temp_name, Copy_object.name); |
| 1288 | if (FindObjectIDName(temp_name) != -1) { |
| 1289 | int c = 2; |
| 1290 | sprintf(temp_name, "CopyOf%s", Copy_object.name); |
| 1291 | do { // Make sure the name not already in use |
| 1292 | if (FindObjectIDName(temp_name) == -1) |
| 1293 | break; |
| 1294 | sprintf(temp_name, "Copy%dOf%s", c, Copy_object.name); |
| 1295 | c++; |
| 1296 | } while (1); |
| 1297 | } |
| 1298 | |
| 1299 | if (!InputObjectName(temp_name, sizeof(temp_name), "Object name", "Enter a name for your object:", this)) // bail |
| 1300 | return; |
| 1301 | |
| 1302 | // Get a slot for this object |
| 1303 | n = AllocObjectID(m_type, true, true, true); |
| 1304 | |
| 1305 | if (n == -1) { |
| 1306 | OutrageMessageBox("Cannot paste object: There are no free object slots."); |
| 1307 | return; |
| 1308 | } |
| 1309 | |
| 1310 | // Copy into new slot |
| 1311 | Object_info[n] = Copy_object; |
| 1312 | |
| 1313 | Object_info[n].description = Copy_object.description; |
| 1314 | Copy_object.description = NULL; |
| 1315 | |
| 1316 | // Set type and name |
| 1317 | Object_info[n].type = m_type; |
| 1318 | strcpy(Object_info[n].name, temp_name); |
| 1319 | |
| 1320 | // Increment the used count of the polymodels |
| 1321 | Poly_models[Object_info[m_current].render_handle].used++; |
| 1322 | if (Object_info[m_current].med_render_handle != -1) |
| 1323 | Poly_models[Object_info[m_current].med_render_handle].used++; |
| 1324 | if (Object_info[m_current].lo_render_handle != -1) |
| 1325 | Poly_models[Object_info[m_current].lo_render_handle].used++; |
| 1326 | |
| 1327 | // Make this the current item |
| 1328 | m_current = n; |
| 1329 | |
| 1330 | // Add this to paging system |
| 1331 | mng_AllocTrackLock(Object_info[n].name, PAGETYPE_GENERIC); |
| 1332 | |
| 1333 | // I'm not sure if this belongs here |
| 1334 | RemapStaticIDs(); |
| 1335 | |
| 1336 | UpdateDialog(); |
| 1337 | } |
| 1338 | |
| 1339 | // When closing, save all our checked out objects locally so we know |
| 1340 | // what stuff to flag as "checked out" the next time we start up |
| 1341 | void CWorldObjectsGenericDialog::SaveGenericsOnClose() { |
| 1342 | int i, t; |
| 1343 | |
| 1344 | if (!Network_up) |
| 1345 | return; // don't save a damn thing if the network is down |
| 1346 | |
| 1347 | for (i = 0; i < MAX_TRACKLOCKS; i++) { |
| 1348 | if (GlobalTrackLocks[i].used == 1 && GlobalTrackLocks[i].pagetype == PAGETYPE_GENERIC) { |
| 1349 | t = FindObjectIDName(GlobalTrackLocks[i].name); |
| 1350 | ASSERT(t != -1); |
| 1351 | |
| 1352 | mng_ReplacePage(Object_info[t].name, Object_info[t].name, t, PAGETYPE_GENERIC, 1); |
| 1353 | } |
| 1354 | } |
| 1355 | } |
| 1356 | |
| 1357 | void CWorldObjectsGenericDialog::OnDestroy() { |
| 1358 | CDialog::OnDestroy(); |
| 1359 | |
| 1360 | if (Copy_object.description) { |
| 1361 | mem_free(Copy_object.description); |
| 1362 | Copy_object.description = NULL; |
| 1363 | } |
| 1364 | |
| 1365 | SaveGenericsOnClose(); |
| 1366 | |
| 1367 | ObjReInitAll(); |
| 1368 | } |
| 1369 | |
| 1370 | BOOL CWorldObjectsGenericDialog::DestroyWindow() { return CDialog::DestroyWindow(); } |
| 1371 | |
| 1372 | void CWorldObjectsGenericDialog::OnGenericUndoLock() { |
| 1373 | int tl; |
| 1374 | mngs_Pagelock pl; |
| 1375 | mngs_generic_page page; |
| 1376 | |
| 1377 | if (m_current == -1) |
| 1378 | return; |
| 1379 | |
| 1380 | // Should have this item locked |
| 1381 | if ((tl = mng_FindTrackLock(Object_info[m_current].name, PAGETYPE_GENERIC)) == -1) |
| 1382 | return; |
| 1383 | |
| 1384 | // Make sure its to be deleted |
| 1385 | if (OutrageMessageBox(MBOX_YESNO, |
| 1386 | "Are you sure you want to undo your lock and lose any changes you may have made?") != IDYES) |
| 1387 | return; |
| 1388 | |
| 1389 | if (!mng_MakeLocker()) |
| 1390 | return; |
| 1391 | |
| 1392 | strcpy(pl.name, Object_info[m_current].name); |
| 1393 | pl.pagetype = PAGETYPE_GENERIC; |
| 1394 | |
| 1395 | mng_FreeTrackLock(tl); |
| 1396 | |
| 1397 | // Delete local page |
| 1398 | if (!mng_DeletePage(Object_info[m_current].name, PAGETYPE_GENERIC, 1)) { |
| 1399 | mprintf(0, ErrorString); |
| 1400 | Int3(); |
| 1401 | } |
| 1402 | |
| 1403 | // Get old data from net |
| 1404 | if (!mng_FindSpecificGenericPage(pl.name, &page)) |
| 1405 | Int3(); |
| 1406 | |
| 1407 | // Copy old get into our local array |
| 1408 | if (!mng_AssignGenericPageToObjInfo(&page, m_current)) |
| 1409 | Int3(); |
| 1410 | |
| 1411 | // We're done |
| 1412 | mng_EraseLocker(); |
| 1413 | |
| 1414 | // Update the display |
| 1415 | UpdateDialog(); |
| 1416 | } |
| 1417 | |
| 1418 | void CWorldObjectsGenericDialog::OnGenericDestroyable() { |
| 1419 | CButton *btn; |
| 1420 | |
| 1421 | btn = (CButton *)GetDlgItem(IDC_GENERIC_DESTROYABLE); |
| 1422 | |
| 1423 | if (btn->GetCheck()) |
| 1424 | Object_info[m_current].flags |= OIF_DESTROYABLE; |
| 1425 | else |
| 1426 | Object_info[m_current].flags &= ~OIF_DESTROYABLE; |
| 1427 | |
| 1428 | ((CButton *)GetDlgItem(IDC_GENERIC_HITPOINT_EDIT))->EnableWindow(Object_info[m_current].flags & OIF_DESTROYABLE); |
| 1429 | ((CButton *)GetDlgItem(IDC_GENERIC_SCORE_EDIT))->EnableWindow(Object_info[m_current].flags & OIF_DESTROYABLE); |
| 1430 | } |
| 1431 | |
| 1432 | void CWorldObjectsGenericDialog::OnKillfocusGenericHitpointEdit() { |
| 1433 | char str[20]; |
| 1434 | |
| 1435 | ((CEdit *)GetDlgItem(IDC_GENERIC_HITPOINT_EDIT))->GetWindowText(str, 20); |
| 1436 | |
| 1437 | Object_info[m_current].hit_points = atoi(str); |
| 1438 | } |
| 1439 | |
| 1440 | void CWorldObjectsGenericDialog::OnGenericWeaponInfoButton() { |
| 1441 | RobotEditWeaponsDialog dlg(Object_info[m_current].static_wb, |
| 1442 | GetPolymodelPointer(Object_info[m_current].render_handle)); |
| 1443 | |
| 1444 | if (dlg.DoModal() == IDOK) |
| 1445 | dlg.GetData(); |
| 1446 | } |
| 1447 | |
| 1448 | void CWorldObjectsGenericDialog::OnGenericLightButton() { |
| 1449 | if (m_current == -1) |
| 1450 | return; |
| 1451 | |
| 1452 | CGenericLightDialog dlg(&Object_info[m_current].lighting_info); |
| 1453 | dlg.DoModal(); |
| 1454 | |
| 1455 | UpdateDialog(); |
| 1456 | } |
| 1457 | |
| 1458 | void CWorldObjectsGenericDialog::OnDefaultRadiusButton() { |
| 1459 | ComputeDefaultSize(Object_info[m_current].type, Object_info[m_current].render_handle, &Object_info[m_current].size); |
| 1460 | |
| 1461 | UpdateDialog(); |
| 1462 | } |
| 1463 | |
| 1464 | void CWorldObjectsGenericDialog::OnSelScript() { |
| 1465 | CString filter = "D3 Compiled Scripts (*.dll)|*.dll||"; |
| 1466 | |
| 1467 | char filename[_MAX_PATH]; |
| 1468 | char pathname[_MAX_PATH], name[_MAX_PATH]; |
| 1469 | strcpy(pathname, LocalScriptDir); |
| 1470 | |
| 1471 | if (!OpenFileDialog(this, (LPCTSTR)filter, filename, pathname, sizeof(pathname))) |
| 1472 | return; |
| 1473 | |
| 1474 | ddio_SplitPath(filename, NULL, name, NULL); |
| 1475 | sprintf(filename, "%s.dll", name); |
| 1476 | |
| 1477 | strcpy(Object_info[m_current].module_name, filename); |
| 1478 | |
| 1479 | UpdateDialog(); |
| 1480 | |
| 1481 | /* |
| 1482 | // TODO: Add your control notification handler code here |
| 1483 | CScriptSelect dlg(REF_OBJTYPE); |
| 1484 | |
| 1485 | if (dlg.DoModal() == IDOK) { |
| 1486 | strcpy(Object_info[m_current].script_name, (LPCSTR)dlg.m_ScriptName); |
| 1487 | UpdateDialog(); |
| 1488 | } |
| 1489 | */ |
| 1490 | } |
| 1491 | |
| 1492 | void CWorldObjectsGenericDialog::OnGenericConcussiveCheck() { |
| 1493 | // TODO: Add your control notification handler code here |
| 1494 | } |
| 1495 | |
| 1496 | void CWorldObjectsGenericDialog::OnKillfocusGenericImpactDamageEdit() { |
| 1497 | CEdit *ebox; |
| 1498 | char str[20]; |
| 1499 | |
| 1500 | ebox = (CEdit *)GetDlgItem(IDC_GENERIC_IMPACT_DAMAGE_EDIT); |
| 1501 | ebox->GetWindowText(str, 20); |
| 1502 | |
| 1503 | Object_info[m_current].damage = atof(str); |
| 1504 | UpdateDialog(); |
| 1505 | } |
| 1506 | |
| 1507 | void CWorldObjectsGenericDialog::OnKillfocusGenericImpactSizeEdit() { |
| 1508 | CEdit *ebox; |
| 1509 | char str[20]; |
| 1510 | |
| 1511 | ebox = (CEdit *)GetDlgItem(IDC_GENERIC_IMPACT_SIZE_EDIT); |
| 1512 | ebox->GetWindowText(str, 20); |
| 1513 | |
| 1514 | Object_info[m_current].impact_size = atof(str); |
| 1515 | UpdateDialog(); |
| 1516 | } |
| 1517 | |
| 1518 | void CWorldObjectsGenericDialog::OnNolod() { |
| 1519 | // TODO: Add your control notification handler code here |
| 1520 | if (m_lod == 0) { |
| 1521 | MessageBox("You must have a hi-res model."); |
| 1522 | return; |
| 1523 | } |
| 1524 | |
| 1525 | else if (m_lod == 1) { |
| 1526 | FreePolyModel(Object_info[m_current].med_render_handle); |
| 1527 | Object_info[m_current].med_render_handle = -1; |
| 1528 | |
| 1529 | } else { |
| 1530 | FreePolyModel(Object_info[m_current].lo_render_handle); |
| 1531 | Object_info[m_current].lo_render_handle = -1; |
| 1532 | } |
| 1533 | |
| 1534 | UpdateDialog(); |
| 1535 | } |
| 1536 | |
| 1537 | void CWorldObjectsGenericDialog::OnHiresRadio() { |
| 1538 | m_lod = 0; |
| 1539 | UpdateDialog(); |
| 1540 | } |
| 1541 | |
| 1542 | void CWorldObjectsGenericDialog::OnMedresRadio() { |
| 1543 | m_lod = 1; |
| 1544 | UpdateDialog(); |
| 1545 | } |
| 1546 | |
| 1547 | void CWorldObjectsGenericDialog::OnLoresRadio() { |
| 1548 | m_lod = 2; |
| 1549 | UpdateDialog(); |
| 1550 | } |
| 1551 | |
| 1552 | void CWorldObjectsGenericDialog::OnKillfocusGenericImpactTimeEdit() { |
| 1553 | CEdit *ebox; |
| 1554 | char str[20]; |
| 1555 | |
| 1556 | ebox = (CEdit *)GetDlgItem(IDC_GENERIC_IMPACT_TIME_EDIT); |
| 1557 | ebox->GetWindowText(str, 20); |
| 1558 | |
| 1559 | Object_info[m_current].impact_time = atof(str); |
| 1560 | UpdateDialog(); |
| 1561 | } |
| 1562 | |
| 1563 | void CWorldObjectsGenericDialog::OnSelendokGenericExplosionSoundCombo() { |
| 1564 | Object_info[m_current].sounds[GSI_EXPLODE] = m_explosion_sound_combo.GetSelected(); |
| 1565 | } |
| 1566 | |
| 1567 | void CWorldObjectsGenericDialog::OnSelendokGenericAmbientSoundCombo() { |
| 1568 | |
| 1569 | Object_info[m_current].sounds[GSI_AMBIENT] = m_ambient_sound_combo.GetSelected(); |
| 1570 | } |
| 1571 | |
| 1572 | void CWorldObjectsGenericDialog::OnKillfocusGenericInvenDescription() { |
| 1573 | CEdit *ebox; |
| 1574 | char str[255]; |
| 1575 | |
| 1576 | ebox = (CEdit *)GetDlgItem(IDC_GENERIC_INVEN_DESCRIPTION); |
| 1577 | ebox->GetWindowText(str, 180); |
| 1578 | |
| 1579 | if (Object_info[m_current].description) { |
| 1580 | mem_free(Object_info[m_current].description); |
| 1581 | Object_info[m_current].description = NULL; |
| 1582 | } |
| 1583 | |
| 1584 | if ((strlen(str) > 0) && (strcmp(str, "<no description>"))) { |
| 1585 | Object_info[m_current].description = mem_strdup(str); |
| 1586 | } else { |
| 1587 | ebox->SetWindowText("<no description>"); |
| 1588 | } |
| 1589 | |
| 1590 | UpdateDialog(); |
| 1591 | } |
| 1592 | |
| 1593 | void CWorldObjectsGenericDialog::OnKillfocusGenericInvenIconname() { |
| 1594 | CEdit *ebox; |
| 1595 | char str[255]; |
| 1596 | |
| 1597 | ebox = (CEdit *)GetDlgItem(IDC_GENERIC_INVEN_ICONNAME); |
| 1598 | ebox->GetWindowText(str, 180); |
| 1599 | |
| 1600 | strcpy(Object_info[m_current].icon_name, str); |
| 1601 | UpdateDialog(); |
| 1602 | } |
| 1603 | |
| 1604 | void CWorldObjectsGenericDialog::OnOverride() { |
| 1605 | int n = m_current; |
| 1606 | mngs_Pagelock temp_pl; |
| 1607 | |
| 1608 | strcpy(temp_pl.name, Object_info[n].name); |
| 1609 | temp_pl.pagetype = PAGETYPE_GENERIC; |
| 1610 | |
| 1611 | mng_OverrideToUnlocked(&temp_pl); |
| 1612 | } |
| 1613 | |
| 1614 | void CWorldObjectsGenericDialog::OnGenericInvenSelectable() { |
| 1615 | CButton *btn; |
| 1616 | |
| 1617 | btn = (CButton *)GetDlgItem(IDC_GENERIC_INVEN_SELECTABLE); |
| 1618 | |
| 1619 | if (btn->GetCheck()) |
| 1620 | Object_info[m_current].flags |= OIF_INVEN_SELECTABLE; |
| 1621 | else |
| 1622 | Object_info[m_current].flags &= ~OIF_INVEN_SELECTABLE; |
| 1623 | } |
| 1624 | |
| 1625 | void CWorldObjectsGenericDialog::OnGenericInvenNonuseable() { |
| 1626 | CButton *btn; |
| 1627 | |
| 1628 | btn = (CButton *)GetDlgItem(IDC_GENERIC_INVEN_NONUSEABLE); |
| 1629 | |
| 1630 | if (btn->GetCheck()) |
| 1631 | Object_info[m_current].flags |= OIF_INVEN_NONUSEABLE; |
| 1632 | else |
| 1633 | Object_info[m_current].flags &= ~OIF_INVEN_NONUSEABLE; |
| 1634 | } |
| 1635 | |
| 1636 | void CWorldObjectsGenericDialog::OnKillfocusLodDistanceEdit() { |
| 1637 | CEdit *ebox; |
| 1638 | char str[255]; |
| 1639 | float dist; |
| 1640 | |
| 1641 | ebox = (CEdit *)GetDlgItem(IDC_LOD_DISTANCE_EDIT); |
| 1642 | ebox->GetWindowText(str, 180); |
| 1643 | dist = atof(str); |
| 1644 | |
| 1645 | if (dist < 0) |
| 1646 | return; |
| 1647 | |
| 1648 | if (m_lod == 1) { |
| 1649 | Object_info[m_current].med_lod_distance = dist; |
| 1650 | } else if (m_lod == 2) { |
| 1651 | Object_info[m_current].lo_lod_distance = dist; |
| 1652 | } |
| 1653 | |
| 1654 | UpdateDialog(); |
| 1655 | } |
| 1656 | |
| 1657 | void CWorldObjectsGenericDialog::OnInvtypeGame() { |
| 1658 | Object_info[m_current].flags &= ~OIF_INVEN_TYPE_MISSION; |
| 1659 | UpdateDialog(); |
| 1660 | } |
| 1661 | |
| 1662 | void CWorldObjectsGenericDialog::OnInvtypeMission() { |
| 1663 | Object_info[m_current].flags |= OIF_INVEN_TYPE_MISSION; |
| 1664 | UpdateDialog(); |
| 1665 | } |
| 1666 | |
| 1667 | void CWorldObjectsGenericDialog::OnInvenNoremove() { |
| 1668 | CButton *btn; |
| 1669 | |
| 1670 | btn = (CButton *)GetDlgItem(IDC_INVEN_NOREMOVE); |
| 1671 | |
| 1672 | if (btn->GetCheck()) |
| 1673 | Object_info[m_current].flags |= OIF_INVEN_NOREMOVE; |
| 1674 | else |
| 1675 | Object_info[m_current].flags &= ~OIF_INVEN_NOREMOVE; |
| 1676 | } |
| 1677 | |
| 1678 | void CWorldObjectsGenericDialog::OnInvenViswhenused() { |
| 1679 | CButton *btn; |
| 1680 | |
| 1681 | btn = (CButton *)GetDlgItem(IDC_INVEN_VISWHENUSED); |
| 1682 | |
| 1683 | if (btn->GetCheck()) |
| 1684 | Object_info[m_current].flags |= OIF_INVEN_VISWHENUSED; |
| 1685 | else |
| 1686 | Object_info[m_current].flags &= ~OIF_INVEN_VISWHENUSED; |
| 1687 | } |
| 1688 | |
| 1689 | void CWorldObjectsGenericDialog::OnSelendokDeathPowerup1Pulldown() { |
| 1690 | int cur; |
| 1691 | char name[200]; |
| 1692 | |
| 1693 | cur = SendDlgItemMessage(IDC_DEATH_POWERUP1_PULLDOWN, CB_GETCURSEL, 0, 0); |
| 1694 | SendDlgItemMessage(IDC_DEATH_POWERUP1_PULLDOWN, CB_GETLBTEXT, cur, (LPARAM)(LPCTSTR)name); |
| 1695 | |
| 1696 | Object_info[m_current].dspew[0] = FindObjectIDName(name); |
| 1697 | |
| 1698 | UpdateDialog(); |
| 1699 | } |
| 1700 | |
| 1701 | void CWorldObjectsGenericDialog::OnKillfocusDeathPowerup1NumEdit() { |
| 1702 | CEdit *ebox; |
| 1703 | char str[20]; |
| 1704 | |
| 1705 | ebox = (CEdit *)GetDlgItem(IDC_DEATH_POWERUP1_NUM_EDIT); |
| 1706 | ebox->GetWindowText(str, 20); |
| 1707 | |
| 1708 | Object_info[m_current].dspew_number[0] = atoi(str); |
| 1709 | UpdateDialog(); |
| 1710 | } |
| 1711 | |
| 1712 | void CWorldObjectsGenericDialog::OnKillfocusDeathPowerup1PercentEdit() { |
| 1713 | CEdit *ebox; |
| 1714 | char str[20]; |
| 1715 | |
| 1716 | ebox = (CEdit *)GetDlgItem(IDC_DEATH_POWERUP1_PERCENT_EDIT); |
| 1717 | ebox->GetWindowText(str, 20); |
| 1718 | |
| 1719 | Object_info[m_current].dspew_percent[0] = atof(str) / 100.0f; |
| 1720 | UpdateDialog(); |
| 1721 | } |
| 1722 | |
| 1723 | void CWorldObjectsGenericDialog::OnKillfocusDeathPowerup2NumEdit() { |
| 1724 | CEdit *ebox; |
| 1725 | char str[20]; |
| 1726 | |
| 1727 | ebox = (CEdit *)GetDlgItem(IDC_DEATH_POWERUP2_NUM_EDIT); |
| 1728 | ebox->GetWindowText(str, 20); |
| 1729 | |
| 1730 | Object_info[m_current].dspew_number[1] = atoi(str); |
| 1731 | UpdateDialog(); |
| 1732 | } |
| 1733 | |
| 1734 | void CWorldObjectsGenericDialog::OnKillfocusDeathPowerup2PercentEdit() { |
| 1735 | CEdit *ebox; |
| 1736 | char str[20]; |
| 1737 | |
| 1738 | ebox = (CEdit *)GetDlgItem(IDC_DEATH_POWERUP2_PERCENT_EDIT); |
| 1739 | ebox->GetWindowText(str, 20); |
| 1740 | |
| 1741 | Object_info[m_current].dspew_percent[1] = atof(str) / 100.0f; |
| 1742 | UpdateDialog(); |
| 1743 | } |
| 1744 | |
| 1745 | void CWorldObjectsGenericDialog::OnSelendokDeathPowerup2Pulldown() { |
| 1746 | int cur; |
| 1747 | char name[200]; |
| 1748 | |
| 1749 | cur = SendDlgItemMessage(IDC_DEATH_POWERUP2_PULLDOWN, CB_GETCURSEL, 0, 0); |
| 1750 | SendDlgItemMessage(IDC_DEATH_POWERUP2_PULLDOWN, CB_GETLBTEXT, cur, (LPARAM)(LPCTSTR)name); |
| 1751 | |
| 1752 | Object_info[m_current].dspew[1] = FindObjectIDName(name); |
| 1753 | |
| 1754 | UpdateDialog(); |
| 1755 | } |
| 1756 | |
| 1757 | void CWorldObjectsGenericDialog::OnDeathPowerupUse2IfHave1Check() { |
| 1758 | CButton *btn; |
| 1759 | |
| 1760 | btn = (CButton *)GetDlgItem(IDC_DEATH_POWERUP_USE2_IF_HAVE1_CHECK); |
| 1761 | |
| 1762 | if (btn->GetCheck()) |
| 1763 | Object_info[m_current].f_dspew |= DSF_ONLY_IF_PLAYER_HAS_OBJ_1; |
| 1764 | else |
| 1765 | Object_info[m_current].f_dspew &= ~DSF_ONLY_IF_PLAYER_HAS_OBJ_1; |
| 1766 | |
| 1767 | UpdateDialog(); |
| 1768 | } |
| 1769 | |
| 1770 | void CWorldObjectsGenericDialog::OnGenericDeathSpew2IfZero1() { |
| 1771 | CButton *btn; |
| 1772 | |
| 1773 | btn = (CButton *)GetDlgItem(IDC_GENERIC_DEATH_SPEW_2_IF_ZERO_1); |
| 1774 | |
| 1775 | if (btn->GetCheck()) |
| 1776 | Object_info[m_current].f_dspew |= DSF_ONLY_IF_NO_1; |
| 1777 | else |
| 1778 | Object_info[m_current].f_dspew &= ~DSF_ONLY_IF_NO_1; |
| 1779 | |
| 1780 | UpdateDialog(); |
| 1781 | } |
| 1782 | int CWorldObjectsGenericDialog::GetTextureUsageForPolymodel(int modelnum) { |
| 1783 | poly_model *pm = &Poly_models[modelnum]; |
| 1784 | int total = 0; |
| 1785 | uint8_t already_used[100]; |
| 1786 | |
| 1787 | memset(already_used, 0, 100); |
| 1788 | |
| 1789 | ASSERT(pm && pm->used != 0); |
| 1790 | |
| 1791 | for (int i = 0; i < pm->n_models; i++) { |
| 1792 | bsp_info *sm = &pm->submodel[i]; |
| 1793 | |
| 1794 | for (int t = 0; t < sm->num_faces; t++) { |
| 1795 | polyface *fp = &sm->faces[t]; |
| 1796 | |
| 1797 | if (fp->texnum != -1 && !already_used[fp->texnum]) { |
| 1798 | already_used[fp->texnum] = 1; |
| 1799 | |
| 1800 | int texnum = pm->textures[fp->texnum]; |
| 1801 | |
| 1802 | texture *texp = &GameTextures[texnum]; |
| 1803 | |
| 1804 | if (texnum == 0) |
| 1805 | continue; // don't count error texture |
| 1806 | |
| 1807 | if (texp->used) { |
| 1808 | if (texp->flags & TF_ANIMATED) { |
| 1809 | vclip *vc = &GameVClips[texp->bm_handle]; |
| 1810 | for (int j = 0; j < vc->num_frames; j++) { |
| 1811 | int bm_handle = vc->frames[j]; |
| 1812 | int mem_this_tex = bm_w(bm_handle, 0) * bm_h(bm_handle, 0); |
| 1813 | if (bm_mipped(bm_handle)) |
| 1814 | mem_this_tex += (mem_this_tex / 3); |
| 1815 | |
| 1816 | mem_this_tex *= 2; |
| 1817 | |
| 1818 | total += mem_this_tex; |
| 1819 | } |
| 1820 | } else { |
| 1821 | int mem_this_tex = bm_w(texp->bm_handle, 0) * bm_h(texp->bm_handle, 0); |
| 1822 | if (bm_mipped(texp->bm_handle)) |
| 1823 | mem_this_tex += (mem_this_tex / 3); |
| 1824 | |
| 1825 | mem_this_tex *= 2; |
| 1826 | |
| 1827 | total += mem_this_tex; |
| 1828 | } |
| 1829 | } |
| 1830 | } |
| 1831 | } |
| 1832 | } |
| 1833 | |
| 1834 | return total; |
| 1835 | } |
| 1836 | |
| 1837 | void CWorldObjectsGenericDialog::OnKillfocusScriptname() { |
| 1838 | char str[MAX_MODULENAME_LEN]; |
| 1839 | |
| 1840 | ((CEdit *)GetDlgItem(IDC_SCRIPTNAME))->GetWindowText(str, MAX_MODULENAME_LEN); |
| 1841 | |
| 1842 | if (!strcmp(str, "null")) { |
| 1843 | Object_info[m_current].module_name[0] = '\0'; |
| 1844 | UpdateDialog(); |
| 1845 | return; |
| 1846 | } |
| 1847 | |
| 1848 | strcpy(Object_info[m_current].module_name, str); |
| 1849 | UpdateDialog(); |
| 1850 | } |
| 1851 | |
| 1852 | void CWorldObjectsGenericDialog::OnCompilemodule() { |
| 1853 | CQuickCompile dlg(Object_info[m_current].module_name); |
| 1854 | dlg.DoModal(); |
| 1855 | |
| 1856 | switch (dlg.ret_value) { |
| 1857 | case -1: // does not exist |
| 1858 | break; |
| 1859 | case 0: // failed compile |
| 1860 | break; |
| 1861 | case 1: // success |
| 1862 | break; |
| 1863 | }; |
| 1864 | } |
| 1865 | |
| 1866 | void CWorldObjectsGenericDialog::OnKillfocusScriptOverride() { |
| 1867 | char str[PAGENAME_LEN]; |
| 1868 | |
| 1869 | ((CEdit *)GetDlgItem(IDC_SCRIPT_OVERRIDE))->GetWindowText(str, PAGENAME_LEN); |
| 1870 | |
| 1871 | if (!strcmp(str, "null")) { |
| 1872 | Object_info[m_current].script_name_override[0] = '\0'; |
| 1873 | UpdateDialog(); |
| 1874 | return; |
| 1875 | } |
| 1876 | |
| 1877 | strncpy(Object_info[m_current].script_name_override, str, PAGENAME_LEN - 1); |
| 1878 | Object_info[m_current].script_name_override[PAGENAME_LEN - 1] = '\0'; |
| 1879 | UpdateDialog(); |
| 1880 | } |
| 1881 | |
| 1882 | void CWorldObjectsGenericDialog::OnGenericAiScriptedDeath() { |
| 1883 | CButton *btn; |
| 1884 | |
| 1885 | btn = (CButton *)GetDlgItem(IDC_GENERIC_AI_SCRIPTED_DEATH); |
| 1886 | |
| 1887 | if (btn->GetCheck()) |
| 1888 | Object_info[m_current].flags |= OIF_AI_SCRIPTED_DEATH; |
| 1889 | else |
| 1890 | Object_info[m_current].flags &= ~OIF_AI_SCRIPTED_DEATH; |
| 1891 | } |
| 1892 | |
| 1893 | void CWorldObjectsGenericDialog::OnKillfocusRespawnScalarEdit() { |
| 1894 | CEdit *ebox; |
| 1895 | char str[20]; |
| 1896 | float val; |
| 1897 | |
| 1898 | ebox = (CEdit *)GetDlgItem(IDC_RESPAWN_SCALAR_EDIT); |
| 1899 | ebox->GetWindowText(str, 20); |
| 1900 | |
| 1901 | val = atof(str); |
| 1902 | |
| 1903 | if (val < -1) |
| 1904 | val = -1; |
| 1905 | if (val > 10000) |
| 1906 | val = 10000; |
| 1907 | |
| 1908 | Object_info[m_current].respawn_scalar = val; |
| 1909 | UpdateDialog(); |
| 1910 | } |
| 1911 | |
| 1912 | #include "GenericDeathDialog.h" |
| 1913 | |
| 1914 | void CWorldObjectsGenericDialog::OnGenericDeaths() { |
| 1915 | CGenericDeathDialog dlg(&Object_info[m_current]); |
| 1916 | |
| 1917 | dlg.DoModal(); |
| 1918 | } |
| 1919 | |
| 1920 | void CWorldObjectsGenericDialog::OnKillfocusGenericScoreEdit() { |
| 1921 | char str[20]; |
| 1922 | |
| 1923 | ((CEdit *)GetDlgItem(IDC_GENERIC_SCORE_EDIT))->GetWindowText(str, 20); |
| 1924 | |
| 1925 | Object_info[m_current].score = atoi(str); |
| 1926 | } |
| 1927 | |
| 1928 | void CWorldObjectsGenericDialog::OnKillfocusGenericAmmoEdit() { |
| 1929 | char str[20]; |
| 1930 | |
| 1931 | ((CEdit *)GetDlgItem(IDC_GENERIC_AMMO_EDIT))->GetWindowText(str, 20); |
| 1932 | |
| 1933 | Object_info[m_current].ammo_count = atoi(str); |
| 1934 | } |
| 1935 | |
| 1936 | void CWorldObjectsGenericDialog::OnObjCeilingCheck() { |
| 1937 | CButton *btn; |
| 1938 | |
| 1939 | btn = (CButton *)GetDlgItem(IDC_OBJ_CEILING_CHECK); |
| 1940 | |
| 1941 | if (btn->GetCheck()) |
| 1942 | Object_info[m_current].flags |= OIF_DO_CEILING_CHECK; |
| 1943 | else |
| 1944 | Object_info[m_current].flags &= ~OIF_DO_CEILING_CHECK; |
| 1945 | } |
| 1946 | |
| 1947 | void CWorldObjectsGenericDialog::OnObjectFlyThroughRenderedPortals() { |
| 1948 | CButton *btn; |
| 1949 | |
| 1950 | btn = (CButton *)GetDlgItem(IDC_OBJECT_FLY_THROUGH_RENDERED_PORTALS); |
| 1951 | |
| 1952 | if (btn->GetCheck()) |
| 1953 | Object_info[m_current].flags |= OIF_IGNORE_FORCEFIELDS_AND_GLASS; |
| 1954 | else |
| 1955 | Object_info[m_current].flags &= ~OIF_IGNORE_FORCEFIELDS_AND_GLASS; |
| 1956 | } |
| 1957 | |
| 1958 | void CWorldObjectsGenericDialog::OnNscButton() { |
| 1959 | CButton *btn; |
| 1960 | |
| 1961 | btn = (CButton *)GetDlgItem(IDC_NSC_BUTTON); |
| 1962 | |
| 1963 | if (btn->GetCheck()) |
| 1964 | Object_info[m_current].flags |= OIF_NO_DIFF_SCALE_DAMAGE; |
| 1965 | else |
| 1966 | Object_info[m_current].flags &= ~OIF_NO_DIFF_SCALE_DAMAGE; |
| 1967 | } |
| 1968 | |
| 1969 | void CWorldObjectsGenericDialog::OnDsmpbdCheck() { |
| 1970 | CButton *btn; |
| 1971 | |
| 1972 | btn = (CButton *)GetDlgItem(IDC_DSMPBD_CHECK); |
| 1973 | |
| 1974 | if (btn->GetCheck()) |
| 1975 | Object_info[m_current].flags |= OIF_NO_DIFF_SCALE_MOVE; |
| 1976 | else |
| 1977 | Object_info[m_current].flags &= ~OIF_NO_DIFF_SCALE_MOVE; |
| 1978 | } |
| 1979 | |
| 1980 | void CWorldObjectsGenericDialog::OnGenericAmbient() { |
| 1981 | CButton *btn; |
| 1982 | |
| 1983 | btn = (CButton *)GetDlgItem(IDC_GENERIC_AMBIENT); |
| 1984 | |
| 1985 | if (btn->GetCheck()) |
| 1986 | Object_info[m_current].flags |= OIF_AMBIENT_OBJECT; |
| 1987 | else |
| 1988 | Object_info[m_current].flags &= ~OIF_AMBIENT_OBJECT; |
| 1989 | } |