| 261 | } |
| 262 | |
| 263 | void CTriggerDialog::UpdateDialog() { |
| 264 | bool portal = 0, floating = 0; |
| 265 | static int last_curroom = -1, last_curface = -1, last_curportal = -1; |
| 266 | |
| 267 | if (Current_trigger >= Num_triggers) |
| 268 | Current_trigger--; |
| 269 | |
| 270 | // If current room/face/portal change, select current trigger from current room/face/portal |
| 271 | if ((ROOMNUM(Curroomp) != last_curroom) || (Curface != last_curface)) { |
| 272 | if (Curroomp->faces[Curface].flags & FF_HAS_TRIGGER) |
| 273 | Current_trigger = (FindTrigger(ROOMNUM(Curroomp), Curface) - Triggers); |
| 274 | } else if ((Curportal != -1) && (Curportal != last_curportal)) |
| 275 | if (Curroomp->portals[Curportal].flags & FF_HAS_TRIGGER) |
| 276 | Current_trigger = (FindTrigger(ROOMNUM(Curroomp), Curroomp->portals[Curportal].portal_face) - Triggers); |
| 277 | last_curroom = ROOMNUM(Curroomp); |
| 278 | last_curface = Curface, last_curportal = Curportal; |
| 279 | |
| 280 | // Enable/Disable some buttons, etc. |
| 281 | ((CButton *)GetDlgItem(IDC_TRIG_NEXT_IN_MINE))->EnableWindow(Num_triggers > 1); |
| 282 | ((CButton *)GetDlgItem(IDC_TRIG_PREV_IN_MINE))->EnableWindow(Num_triggers > 1); |
| 283 | ((CButton *)GetDlgItem(IDC_TRIG_GOTO))->EnableWindow(Num_triggers > 0); |
| 284 | ((CButton *)GetDlgItem(IDC_TRIG_DELETE))->EnableWindow(Current_trigger != -1); |
| 285 | ((CButton *)GetDlgItem(IDC_TRIG_EDIT_SCRIPT))->EnableWindow(Current_trigger != -1); |
| 286 | ((CButton *)GetDlgItem(IDC_TRIG_EDIT_NAME))->EnableWindow(Current_trigger != -1); |
| 287 | ((CButton *)GetDlgItem(IDC_TRIG_ADD_TO_CURFACE))->EnableWindow(!(Curroomp->faces[Curface].flags & FF_HAS_TRIGGER)); |
| 288 | ((CButton *)GetDlgItem(IDC_TRIG_ADD_TO_CURPORTAL)) |
| 289 | ->EnableWindow((Curportal != -1) && |
| 290 | !(Curroomp->faces[Curroomp->portals[Curportal].portal_face].flags & FF_HAS_TRIGGER) && |
| 291 | !(Curroomp->faces[Curroomp->portals[Curportal].portal_face].flags & FF_HAS_TRIGGER)); |
| 292 | ((CButton *)GetDlgItem(IDC_TRIG_CURRENT_NUM))->EnableWindow(Current_trigger != -1); |
| 293 | ((CButton *)GetDlgItem(IDC_TRIG_CURRENT_TYPE))->EnableWindow(Current_trigger != -1); |
| 294 | ((CButton *)GetDlgItem(IDC_TRIG_CURRENT_ROOM))->EnableWindow(Current_trigger != -1); |
| 295 | ((CButton *)GetDlgItem(IDC_TRIG_CURRENT_FACE))->EnableWindow(Current_trigger != -1); |
| 296 | ((CButton *)GetDlgItem(IDC_TRIG_CURRENT_FACE))->EnableWindow(Current_trigger != -1); |
| 297 | ((CButton *)GetDlgItem(IDC_TRIG_CURRENT_TRIG_PORTAL))->EnableWindow(Current_trigger != -1); |
| 298 | ((CButton *)GetDlgItem(IDC_TRIG_ACTIVATORS))->EnableWindow(Current_trigger != -1); |
| 299 | ((CButton *)GetDlgItem(IDC_TRIG_ACTIV_PLAYER))->EnableWindow(Current_trigger != -1); |
| 300 | ((CButton *)GetDlgItem(IDC_TRIG_ACTIV_PLAYER_WEAPONS))->EnableWindow(Current_trigger != -1); |
| 301 | ((CButton *)GetDlgItem(IDC_TRIG_ACTIV_ROBOT_WEAPONS))->EnableWindow(Current_trigger != -1); |
| 302 | ((CButton *)GetDlgItem(IDC_TRIG_ACTIV_ROBOTS))->EnableWindow(Current_trigger != -1); |
| 303 | ((CButton *)GetDlgItem(IDC_TRIG_ONESHOT))->EnableWindow(Current_trigger != -1); |
| 304 | |
| 305 | int n = FindNextTrigInRoom(ROOMNUM(Curroomp), Current_trigger); |
| 306 | ((CButton *)GetDlgItem(IDC_TRIG_NEXT_IN_ROOM))->EnableWindow((n != -1) && (n != Current_trigger)); |
| 307 | ((CButton *)GetDlgItem(IDC_TRIG_PREV_IN_ROOM))->EnableWindow((n != -1) && (n != Current_trigger)); |
| 308 | |
| 309 | // Update current trigger info |
| 310 | if (Current_trigger > -1) { |
| 311 | trigger *tp = &Triggers[Current_trigger]; |
| 312 | room *rp = &Rooms[tp->roomnum]; |
| 313 | face *fp = &rp->faces[tp->facenum]; |
| 314 | |
| 315 | portal = (fp->portal_num != -1); |
| 316 | floating = ((fp->flags & FF_FLOATING_TRIG) != 0); |
| 317 | ASSERT(!(portal && floating)); // Shouldn't be both portal and floating |
| 318 | |
| 319 | PrintToDlgItem(this, IDC_TRIG_CURRENT_NAME, "Name:\t %s", tp->name[0] ? tp->name : "<none>"); |
| 320 | PrintToDlgItem(this, IDC_TRIG_CURRENT_NUM, "Number:\t %d", Current_trigger); |
nothing calls this directly
no test coverage detected