-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvectoredit.gc
143 lines (102 loc) · 5.21 KB
/
vectoredit.gc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
;;-*-Lisp-*-
(in-package goal)
#|
This is very very janky
An in-game/REPL vector editor
Run (vmenu-on) to turn the process on
Use the D-pad along with L1/L2 to control.
Hold L2 and press left/right to change how the vector is displayed
Hold L1 and press left/right to change which coordinate you are editing (x,y,z,w)
Up and down on the D-pad adds/subtracts "add-amount" from the vector you're editing (currently locked at 1.0 or 4096.0 in the loop)
To affect the game, use the REPL to change "edit-me" to another vector
examples:
(vmenu-on)
(set! edit-me (target-pos 0))
(set! edit-me (-> (the process-drawable (process-by-ename "explorer-4")) root trans))
(set! edit-me (-> (the process-drawable (process-by-ename "ropebridge-4")) draw color-mult))
|#
(defun vmenu-on ()
;process-spawn-function, spawns a process that runs the function you give it
(process-spawn-function process :name 'vmenu-proc
;This lambda is our function
(lambda :behavior process ()
;Code before the loop runs once on process spawn
(define coord-int 0) ;menu's page index
(define coord-size 4) ;number of page used to mod
(define coord-string (new 'static 'boxed-array :type string
"Editing X"
"Editing Y" ;not a type but convenient to toggle
"Editing Z"
"Editing W"
))
(define col-int 8) ;int for menu's font color
(define menu-origin (new 'static 'vector4w :x 10 :y 160 :z 2 :w 0))
(define mode-int 0)
(define mode-size 3)
(define modes (new 'static 'boxed-array :type string
"Vector Float"
"Vector Float (meters)" ;not a type but convenient to toggle
"Vector Decimal"
))
(define add-amount 0.0)
(define edit-me (new 'static 'vector :x 1.0 :y 0.0 :z 2.0 :w 0.0))
;Loop runs once per frame while process is active
(loop
;main controls for left/right menu
;hold l1 to select which coordinate
(when (cpad-hold? 0 l1)
(when (cpad-pressed? 0 right)
(set! coord-int (mod (+ coord-int 1) coord-size)))
(when (cpad-pressed? 0 left)
(set! coord-int (mod (+ (- coord-int 1) coord-size) coord-size)))
)
;lets you +/- add-amount to selected xyzw coord
;coord-int determines which coordinate you're editing
(when (cpad-pressed? 0 up)
(+! (-> edit-me data coord-int) add-amount)
)
(when (cpad-pressed? 0 down)
(-! (-> edit-me data coord-int) add-amount)
)
;hold l2 to use the mode controls
(when (cpad-hold? 0 l2)
(when (cpad-pressed? 0 right)
(set! mode-int (mod (+ mode-int 1) mode-size)))
(when (cpad-pressed? 0 left)
(set! mode-int (mod (+ (- mode-int 1) mode-size) mode-size)))
)
;mode determines add-amound
(when (= mode-int 0)
(set! add-amount 1.0))
(when (= mode-int 1)
(set! add-amount 4096.0))
(when (= mode-int 2)
(set! add-amount 1.0))
;Start a bucket thing block so we can use draw functions
(with-dma-buffer-add-bucket ((testbuf (-> (current-frame) debug-buf)) (bucket-id debug-no-zbuf))
(draw-string-xy (string-format "L2 + L/R to swtich mode, L1 + L/R to switch coord") testbuf (-> menu-origin x) (-> menu-origin y) (the font-color 2) (font-flags shadow kerning))
(draw-string-xy (string-format "~s" (-> modes mode-int)) testbuf (-> menu-origin x) (+ (-> menu-origin y) 8) (the font-color col-int) (font-flags shadow kerning))
(draw-string-xy (string-format "~s" (-> coord-string coord-int)) testbuf (-> menu-origin x) (+ (-> menu-origin y) 24) (the font-color col-int) (font-flags shadow kerning))
;use the mode variable to switch between format strings
(when (= mode-int 0)
(draw-string-xy (string-format "< ~12,,4f ~12,,4f ~12,,4f ~12,,4f >" (-> edit-me data 0) (-> edit-me data 1) (-> edit-me data 2) (-> edit-me data 3)) testbuf (-> menu-origin x) (+ (-> menu-origin y) 16) (the font-color col-int) (font-flags shadow kerning))
)
(when (= mode-int 1)
(draw-string-xy (string-format "< ~12,,4m ~12,,4m ~12,,4m ~12,,4m >" (-> edit-me data 0) (-> edit-me data 1) (-> edit-me data 2) (-> edit-me data 3)) testbuf (-> menu-origin x) (+ (-> menu-origin y) 16) (the font-color col-int) (font-flags shadow kerning))
)
(when (= mode-int 2)
(draw-string-xy (string-format "< ~12d ~12d ~12d ~12d >" (-> edit-me data 0) (-> edit-me data 1) (-> edit-me data 2) (-> edit-me data 3)) testbuf (-> menu-origin x) (+ (-> menu-origin y) 16) (the font-color col-int) (font-flags shadow kerning))
)
)
;Processes should suspend themselves, the loop will resume next frame
(suspend)
)
)
)
;Lisp returns the last form as the function return
(none)
)
(defun vmenu-off ()
"Kill the button process"
(kill-by-name 'vmenu-proc *active-pool*)
)