Camera debug menu - reuse enum instead of strange indexing/magic numbers (#2717)

This commit is contained in:
Matt Dallmeyer 2023-06-15 12:28:54 -07:00 committed by GitHub
parent ccaa1f41e5
commit 2624934e72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 107 additions and 174 deletions

View File

@ -31,102 +31,63 @@
(defun dm-cam-settings-func ((arg0 int) (arg1 debug-menu-msg))
(when (and (= arg1 (debug-menu-msg press)) *camera*)
(cond
((zero? arg0)
(send-event *camera* 'toggle-slave-option 1)
)
((= arg0 13)
(send-event *camera* 'toggle-slave-option 8192)
)
((= arg0 1)
(send-event *camera* 'toggle-slave-option 2)
)
((= arg0 2)
(send-event *camera* 'toggle-slave-option 4)
)
((= arg0 3)
(send-event *camera* 'toggle-slave-option 128)
)
((= arg0 4)
(send-event *camera* 'toggle-slave-option 8)
)
((= arg0 7)
(send-event *camera* 'toggle-slave-option 16)
)
((= arg0 8)
(send-event *camera* 'toggle-slave-option 64)
)
((= arg0 6)
(case arg0
(((cam-slave-options))
(send-event *camera* 'reset-root)
)
((= arg0 9)
(((cam-slave-options BUTT_CAM)
(cam-slave-options SAME_SIDE)
(cam-slave-options MOVE_SPHERICAL)
(cam-slave-options ALLOW_Z_ROT)
(cam-slave-options JUMP_PITCHES)
(cam-slave-options COLLIDE)
(cam-slave-options FIND_HIDDEN_TARGET)
(cam-slave-options DRAG)
(cam-slave-options LINE_OF_SIGHT)
(cam-slave-options BLOCK_SHIFT_BUTTONS)
(cam-slave-options NO_ROTATE)
(cam-slave-options STICKY_ANGLE)
)
(send-event *camera* 'toggle-slave-option arg0)
)
((9) ;; ignore regions
(logxor! (-> *camera* master-options) 1)
)
((= arg0 10)
((10) ;; switch only on ground
(logxor! (-> *camera* master-options) 4)
)
((= arg0 11)
(send-event *camera* 'toggle-slave-option 32)
)
((= arg0 12)
(send-event *camera* 'toggle-slave-option 512)
)
((= arg0 14)
(send-event *camera* 'toggle-slave-option #x8000)
)
((= arg0 15)
(send-event *camera* 'toggle-slave-option #x10000)
(else
(format 0 "Unrecognized camera settings menu item selected: ~I~%" arg0)
)
)
)
(cond
(*camera*
(cond
((zero? arg0)
(logtest? (-> *camera* slave-options) 1)
)
((= arg0 13)
(logtest? (-> *camera* slave-options) 8192)
)
((= arg0 1)
(logtest? (-> *camera* slave-options) 2)
)
((= arg0 2)
(logtest? (-> *camera* slave-options) 4)
)
((= arg0 3)
(logtest? (-> *camera* slave-options) 128)
)
((= arg0 4)
(logtest? (-> *camera* slave-options) 8)
)
((= arg0 7)
(logtest? (-> *camera* slave-options) 16)
)
((= arg0 8)
(logtest? (-> *camera* slave-options) 64)
)
((= arg0 11)
(logtest? (-> *camera* slave-options) 32)
)
((= arg0 12)
(logtest? (-> *camera* slave-options) 512)
)
((= arg0 14)
(logtest? (-> *camera* slave-options) #x8000)
)
((= arg0 15)
(logtest? #x10000 (-> *camera* slave-options))
)
((= arg0 9)
(logtest? (-> *camera* master-options) 1)
)
((= arg0 10)
(logtest? (-> *camera* master-options) 4)
)
(else
#f
(case arg0
(((cam-slave-options BUTT_CAM)
(cam-slave-options SAME_SIDE)
(cam-slave-options MOVE_SPHERICAL)
(cam-slave-options ALLOW_Z_ROT)
(cam-slave-options JUMP_PITCHES)
(cam-slave-options COLLIDE)
(cam-slave-options FIND_HIDDEN_TARGET)
(cam-slave-options DRAG)
(cam-slave-options LINE_OF_SIGHT)
(cam-slave-options BLOCK_SHIFT_BUTTONS)
(cam-slave-options NO_ROTATE)
(cam-slave-options STICKY_ANGLE)
)
(logtest? (-> *camera* slave-options) arg0)
)
((9) ;; ignore regions
(logtest? (-> *camera* master-options) 1)
)
((10) ;; switch only on ground
(logtest? (-> *camera* master-options) 4)
)
(else
#f
)
)
)
(else
@ -819,7 +780,7 @@
(debug-menu-append-item arg1 a1-41)
)
(let ((a1-43
(new 'debug 'debug-menu-item-function "Reset Free" 6 (the-as (function object object) dm-cam-settings-func))
(new 'debug 'debug-menu-item-function "Reset Free" (cam-slave-options) (the-as (function object object) dm-cam-settings-func))
)
)
(debug-menu-append-item arg1 a1-43)
@ -885,28 +846,28 @@
(let ((a1-29 (new 'debug 'debug-menu-item-submenu "Settings" s4-1)))
(debug-menu-append-item gp-0 a1-29)
)
(let ((a1-31 (new 'debug 'debug-menu-item-flag "Butt cam" 0 dm-cam-settings-func)))
(let ((a1-31 (new 'debug 'debug-menu-item-flag "Butt cam" (cam-slave-options BUTT_CAM) dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-31)
)
(let ((a1-33 (new 'debug 'debug-menu-item-flag "Block shift buttons" 13 dm-cam-settings-func)))
(let ((a1-33 (new 'debug 'debug-menu-item-flag "Block shift buttons" (cam-slave-options BLOCK_SHIFT_BUTTONS) dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-33)
)
(let ((a1-35 (new 'debug 'debug-menu-item-flag "Same side" 1 dm-cam-settings-func)))
(let ((a1-35 (new 'debug 'debug-menu-item-flag "Same side" (cam-slave-options SAME_SIDE) dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-35)
)
(let ((a1-37 (new 'debug 'debug-menu-item-flag "Move spherical" 2 dm-cam-settings-func)))
(let ((a1-37 (new 'debug 'debug-menu-item-flag "Move spherical" (cam-slave-options MOVE_SPHERICAL) dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-37)
)
(let ((a1-39 (new 'debug 'debug-menu-item-flag "Drag" 3 dm-cam-settings-func)))
(let ((a1-39 (new 'debug 'debug-menu-item-flag "Drag" (cam-slave-options DRAG) dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-39)
)
(let ((a1-41 (new 'debug 'debug-menu-item-flag "Allow Z rot" 4 dm-cam-settings-func)))
(let ((a1-41 (new 'debug 'debug-menu-item-flag "Allow Z rot" (cam-slave-options ALLOW_Z_ROT) dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-41)
)
(let ((a1-43 (new 'debug 'debug-menu-item-flag "Pitch for jump" 7 dm-cam-settings-func)))
(let ((a1-43 (new 'debug 'debug-menu-item-flag "Pitch for jump" (cam-slave-options JUMP_PITCHES) dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-43)
)
(let ((a1-45 (new 'debug 'debug-menu-item-flag "Find hidden target" 8 dm-cam-settings-func)))
(let ((a1-45 (new 'debug 'debug-menu-item-flag "Find hidden target" (cam-slave-options FIND_HIDDEN_TARGET) dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-45)
)
(let ((a1-47
@ -921,16 +882,16 @@
(let ((a1-51 (new 'debug 'debug-menu-item-flag "Switch only on ground" 10 dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-51)
)
(let ((a1-53 (new 'debug 'debug-menu-item-flag "Collide" 11 dm-cam-settings-func)))
(let ((a1-53 (new 'debug 'debug-menu-item-flag "Collide" (cam-slave-options COLLIDE) dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-53)
)
(let ((a1-55 (new 'debug 'debug-menu-item-flag "Line of Sight" 12 dm-cam-settings-func)))
(let ((a1-55 (new 'debug 'debug-menu-item-flag "Line of Sight" (cam-slave-options LINE_OF_SIGHT) dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-55)
)
(let ((a1-57 (new 'debug 'debug-menu-item-flag "No Rotate" 14 dm-cam-settings-func)))
(let ((a1-57 (new 'debug 'debug-menu-item-flag "No Rotate" (cam-slave-options NO_ROTATE) dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-57)
)
(let ((a1-59 (new 'debug 'debug-menu-item-flag "Sticky Angle" 15 dm-cam-settings-func)))
(let ((a1-59 (new 'debug 'debug-menu-item-flag "Sticky Angle" (cam-slave-options STICKY_ANGLE) dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-59)
)
(let ((s3-2 (new 'debug 'debug-menu-item-var "Interp Frms" 40 80)))

View File

@ -79,78 +79,50 @@
(defun dm-cam-settings-func ((arg0 cam-slave-options) (arg1 debug-menu-msg))
(when (and (= arg1 (debug-menu-msg press)) *camera*)
(cond
((zero? arg0)
(send-event *camera* 'toggle-slave-option 1)
(case arg0
(((cam-slave-options JUMP_PITCHES))
(if (not (setting-control-method-14 *setting-control* 'slave-options))
(set-setting-by-param *setting-control* 'slave-options 'clear 0 arg0)
(remove-setting-by-arg0 *setting-control* 'slave-options)
)
)
((= arg0 (cam-slave-options BUTT_CAM))
(send-event *camera* 'toggle-slave-option 2)
)
((= arg0 (cam-slave-options SAME_SIDE))
(send-event *camera* 'toggle-slave-option 4)
)
((= arg0 (cam-slave-options BUTT_CAM SAME_SIDE))
(send-event *camera* 'toggle-slave-option 128)
)
((= arg0 (cam-slave-options MOVE_SPHERICAL))
(send-event *camera* 'toggle-slave-option 8)
)
((= arg0 (cam-slave-options SAME_SIDE MOVE_SPHERICAL))
(set-setting-by-param *setting-control* 'slave-options 'clear 0 16)
)
((= arg0 (cam-slave-options BUTT_CAM SAME_SIDE MOVE_SPHERICAL))
(send-event *camera* 'toggle-slave-option 64)
)
((= arg0 (cam-slave-options ALLOW_Z_ROT))
(send-event *camera* 'toggle-slave-option 32)
)
((= arg0 (cam-slave-options BUTT_CAM ALLOW_Z_ROT))
(send-event *camera* 'toggle-slave-option 512)
)
((= arg0 (cam-slave-options SAME_SIDE ALLOW_Z_ROT))
(send-event *camera* 'toggle-slave-option #x4000)
)
((= arg0 (cam-slave-options BUTT_CAM SAME_SIDE ALLOW_Z_ROT))
(send-event *camera* 'toggle-slave-option #x8000)
(((cam-slave-options BUTT_CAM)
(cam-slave-options SAME_SIDE)
(cam-slave-options MOVE_SPHERICAL)
(cam-slave-options ALLOW_Z_ROT)
(cam-slave-options COLLIDE)
(cam-slave-options FIND_HIDDEN_TARGET)
(cam-slave-options DRAG)
(cam-slave-options LINE_OF_SIGHT)
(cam-slave-options STICKY_ANGLE)
(cam-slave-options NO_ROTATE)
)
(send-event *camera* 'toggle-slave-option arg0)
)
(else
(format 0 "Unrecognized camera settings menu item selected: ~I~%" arg0)
)
)
)
(cond
(*camera*
(cond
((zero? arg0)
(logtest? (-> *camera* slave-options) 1)
)
((= arg0 (cam-slave-options BUTT_CAM))
(logtest? (-> *camera* slave-options) 2)
)
((= arg0 (cam-slave-options SAME_SIDE))
(logtest? (-> *camera* slave-options) 4)
)
((= arg0 (cam-slave-options BUTT_CAM SAME_SIDE))
(logtest? (-> *camera* slave-options) 128)
)
((= arg0 (cam-slave-options MOVE_SPHERICAL))
(logtest? (-> *camera* slave-options) 8)
)
((= arg0 (cam-slave-options SAME_SIDE MOVE_SPHERICAL))
(not (setting-control-method-14 *setting-control* 'slave-options))
)
((= arg0 (cam-slave-options BUTT_CAM SAME_SIDE MOVE_SPHERICAL))
(logtest? (-> *camera* slave-options) 64)
)
((= arg0 (cam-slave-options ALLOW_Z_ROT))
(logtest? (-> *camera* slave-options) 32)
)
((= arg0 (cam-slave-options BUTT_CAM ALLOW_Z_ROT))
(logtest? (-> *camera* slave-options) 512)
)
((= arg0 (cam-slave-options SAME_SIDE ALLOW_Z_ROT))
(logtest? (-> *camera* slave-options) #x4000)
)
((= arg0 (cam-slave-options BUTT_CAM SAME_SIDE ALLOW_Z_ROT))
(logtest? (-> *camera* slave-options) #x8000)
)
(case arg0
(((cam-slave-options JUMP_PITCHES))
(not (setting-control-method-14 *setting-control* 'slave-options))
)
(((cam-slave-options BUTT_CAM)
(cam-slave-options SAME_SIDE)
(cam-slave-options MOVE_SPHERICAL)
(cam-slave-options ALLOW_Z_ROT)
(cam-slave-options COLLIDE)
(cam-slave-options FIND_HIDDEN_TARGET)
(cam-slave-options DRAG)
(cam-slave-options LINE_OF_SIGHT)
(cam-slave-options STICKY_ANGLE)
(cam-slave-options NO_ROTATE)
)
(logtest? (-> *camera* slave-options) arg0)
)
(else
#f
)
@ -1463,37 +1435,37 @@
)
(debug-menu-append-item s4-1 s3-2)
)
(let ((a1-36 (new 'debug 'debug-menu-item-flag "Butt cam" 0 dm-cam-settings-func)))
(let ((a1-36 (new 'debug 'debug-menu-item-flag "Butt cam" (cam-slave-options BUTT_CAM) dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-36)
)
(let ((a1-38 (new 'debug 'debug-menu-item-flag "Same side" 1 dm-cam-settings-func)))
(let ((a1-38 (new 'debug 'debug-menu-item-flag "Same side" (cam-slave-options SAME_SIDE) dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-38)
)
(let ((a1-40 (new 'debug 'debug-menu-item-flag "Move spherical" 2 dm-cam-settings-func)))
(let ((a1-40 (new 'debug 'debug-menu-item-flag "Move spherical" (cam-slave-options MOVE_SPHERICAL) dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-40)
)
(let ((a1-42 (new 'debug 'debug-menu-item-flag "Drag" 3 dm-cam-settings-func)))
(let ((a1-42 (new 'debug 'debug-menu-item-flag "Drag" (cam-slave-options DRAG) dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-42)
)
(let ((a1-44 (new 'debug 'debug-menu-item-flag "Allow Z rot" 4 dm-cam-settings-func)))
(let ((a1-44 (new 'debug 'debug-menu-item-flag "Allow Z rot" (cam-slave-options ALLOW_Z_ROT) dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-44)
)
(let ((a1-46 (new 'debug 'debug-menu-item-flag "Pitch for jump" 6 dm-cam-settings-func)))
(let ((a1-46 (new 'debug 'debug-menu-item-flag "Pitch for jump" (cam-slave-options JUMP_PITCHES) dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-46)
)
(let ((a1-48 (new 'debug 'debug-menu-item-flag "Find hidden target" 7 dm-cam-settings-func)))
(let ((a1-48 (new 'debug 'debug-menu-item-flag "Find hidden target" (cam-slave-options FIND_HIDDEN_TARGET) dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-48)
)
(let ((a1-50 (new 'debug 'debug-menu-item-flag "Collide" 8 dm-cam-settings-func)))
(let ((a1-50 (new 'debug 'debug-menu-item-flag "Collide" (cam-slave-options COLLIDE) dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-50)
)
(let ((a1-52 (new 'debug 'debug-menu-item-flag "Line of Sight" 9 dm-cam-settings-func)))
(let ((a1-52 (new 'debug 'debug-menu-item-flag "Line of Sight" (cam-slave-options LINE_OF_SIGHT) dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-52)
)
(let ((a1-54 (new 'debug 'debug-menu-item-flag "No Rotate" 10 dm-cam-settings-func)))
(let ((a1-54 (new 'debug 'debug-menu-item-flag "No Rotate" (cam-slave-options NO_ROTATE) dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-54)
)
(let ((a1-56 (new 'debug 'debug-menu-item-flag "Sticky Angle" 11 dm-cam-settings-func)))
(let ((a1-56 (new 'debug 'debug-menu-item-flag "Sticky Angle" (cam-slave-options STICKY_ANGLE) dm-cam-settings-func)))
(debug-menu-append-item s4-1 a1-56)
)
(let ((s3-3 (new 'debug 'debug-menu-item-var "Interp Frms" 40 80)))