1
1
package mchorse .mclib .client .gui .mclib ;
2
2
3
- import mchorse .mclib .client .gui .framework .elements .GuiElement ;
4
- import mchorse .mclib .client .gui .framework .elements .GuiModelRenderer ;
5
3
import mchorse .mclib .client .gui .framework .elements .buttons .GuiButtonElement ;
6
4
import mchorse .mclib .client .gui .framework .elements .buttons .GuiSlotElement ;
7
5
import mchorse .mclib .client .gui .framework .elements .context .GuiSimpleContextMenu ;
8
- import mchorse .mclib .client .gui .framework .elements .input .GuiTransformations ;
9
- import mchorse .mclib .client .gui .framework .elements .keyframes .GuiDopeSheet ;
10
- import mchorse .mclib .client .gui .framework .elements .keyframes .GuiGraphView ;
11
- import mchorse .mclib .client .gui .framework .elements .keyframes .GuiKeyframesEditor ;
12
- import mchorse .mclib .client .gui .framework .elements .keyframes .GuiSheet ;
6
+ import mchorse .mclib .client .gui .framework .elements .input .GuiTextElement ;
13
7
import mchorse .mclib .client .gui .framework .elements .utils .GuiContext ;
14
8
import mchorse .mclib .client .gui .utils .Icons ;
15
9
import mchorse .mclib .client .gui .utils .keys .IKey ;
16
- import mchorse .mclib .utils .Color ;
17
- import mchorse .mclib .utils .ColorUtils ;
18
- import mchorse .mclib .utils .keyframes .Keyframe ;
19
- import mchorse .mclib .utils .keyframes .KeyframeChannel ;
20
- import mchorse .mclib .utils .keyframes .KeyframeInterpolation ;
21
- import mchorse .mclib .utils .wav .Wave ;
22
- import mchorse .mclib .utils .wav .WavePlayer ;
23
- import mchorse .mclib .utils .wav .WaveReader ;
24
- import mchorse .mclib .utils .wav .Waveform ;
25
10
import net .minecraft .client .Minecraft ;
26
- import net .minecraft .client .renderer .GlStateManager ;
27
11
import net .minecraft .init .Items ;
28
12
import net .minecraft .item .ItemStack ;
29
13
30
14
public class GuiDebugPanel extends GuiDashboardPanel <GuiAbstractDashboard >
31
15
{
32
- public GuiKeyframesEditor <GuiDopeSheet > dopesheet ;
33
- public GuiKeyframesEditor <GuiGraphView > graph ;
34
- public GuiModelRenderer renderer ;
35
16
public GuiButtonElement play ;
36
17
public GuiSlotElement slot ;
37
-
38
- public GuiTransformations top ;
39
- public GuiTransformations bottom ;
40
-
41
- private WavePlayer player ;
42
- private Waveform wave ;
43
-
44
- public GuiElement element ;
18
+ public GuiTextElement text ;
45
19
46
20
public GuiDebugPanel (Minecraft mc , GuiAbstractDashboard dashboard )
47
21
{
48
22
super (mc , dashboard );
49
23
50
- this .dopesheet = new GuiKeyframesEditor <GuiDopeSheet >(mc )
51
- {
52
- @ Override
53
- protected GuiDopeSheet createElement (Minecraft mc )
54
- {
55
- return new GuiDopeSheet (mc , this ::fillData );
56
- }
57
- };
58
-
59
- this .graph = new GuiKeyframesEditor <GuiGraphView >(mc )
60
- {
61
- @ Override
62
- protected GuiGraphView createElement (Minecraft mc )
63
- {
64
- return new GuiGraphView (mc , this ::fillData );
65
- }
66
- };
67
-
68
24
this .slot = new GuiSlotElement (mc , 0 , (t ) -> {});
69
25
this .slot .flex ().relative (this ).x (0.5F ).y (20 ).anchorX (0.5F );
70
26
this .slot .setStack (new ItemStack (Items .BAKED_POTATO , 42 ));
71
27
72
- KeyframeChannel channel = new KeyframeChannel ();
73
-
74
- channel .insert (0 , 10 );
75
- Keyframe a = channel .get (channel .insert (20 , 10 ));
76
- channel .get (channel .insert (80 , 0 ));
77
- channel .get (channel .insert (100 , 0 ));
78
-
79
- a .interp = KeyframeInterpolation .BEZIER ;
80
-
81
- for (int i = 0 ; i < 5 ; i ++)
82
- {
83
- KeyframeChannel c = new KeyframeChannel ();
84
-
85
- c .copy (channel );
86
-
87
- this .dopesheet .graph .sheets .add (new GuiSheet ("" + i , IKey .str ("Test " + i ), new Color ((float ) Math .random (), (float ) Math .random (), (float ) Math .random ()).getRGBColor (), c ));
88
- }
89
-
90
- this .dopesheet .graph .duration = 100 ;
91
- this .graph .graph .setChannel (channel , 0x0088ff );
92
- this .graph .graph .duration = 100 ;
93
-
94
- this .dopesheet .flex ().relative (this ).y (0 ).wh (1F , 0.5F );
95
- this .graph .flex ().relative (this ).y (0.5F ).wh (1F , 0.5F );
96
-
97
- this .renderer = new GuiModelRenderer (mc )
98
- {
99
- @ Override
100
- protected void drawUserModel (GuiContext context )
101
- {}
102
- };
103
- this .play = new GuiButtonElement (mc , IKey .str ("Play me!" ), this ::play );
104
-
105
- this .top = new GuiTransformations (mc );
106
- this .top .fillR (90 , 0 , -90 );
107
- this .top .fillT (1 , 5 , -2 );
108
- this .bottom = new GuiTransformations (mc );
109
- this .bottom .fillT (0 , -2 , 1.5 );
110
- this .bottom .fillS (2 , 2 , 2 );
111
- this .bottom .fillR (0 , 180 , 0 );
28
+ this .play = new GuiButtonElement (mc , IKey .str ("Play me!" ), null ).background (false );
29
+ this .play .flex ().relative (this ).xy (10 , 10 ).w (80 );
112
30
113
- this .top . flex (). relative ( this ). x ( 0.5F ). y ( 10 ). wh ( 190 , 70 ). anchor ( 0.5F , 0 );
114
- this .bottom .flex ().relative (this ).x ( 0.5F ). y ( 1F , - 10 ). wh ( 190 , 70 ). anchor ( 0.5F , 1F );
31
+ this .text = new GuiTextElement ( mc , 1000 , null ). background ( false );
32
+ this .text .flex ().relative (this ).xy ( 10 , 40 ). w ( 80 );
115
33
116
- this .renderer .flex ().relative (this ).wh (1F , 1F );
117
- this .play .flex ().relative (this ).xy (10 , 10 ).w (80 );
118
- this .add (/* this.renderer, this.play, */ this .slot );
119
- // this.add(this.graph, this.dopesheet);
120
- // this.add(this.top, this.bottom);
34
+ this .add (this .slot , this .play , this .text );
121
35
122
36
this .context (() ->
123
37
{
@@ -130,34 +44,6 @@ protected void drawUserModel(GuiContext context)
130
44
131
45
return contextMenu ;
132
46
});
133
-
134
- this .element = new GuiElement (mc );
135
- this .element .flex ().relative (this ).wh (0.33F , 0.33F ).row (5 ).resize ().width (80 ).padding (10 );
136
-
137
- for (int i = 0 ; i < 5 ; i ++)
138
- {
139
- GuiButtonElement buttonElement = new GuiButtonElement (mc , IKey .str (String .valueOf (i )), null );
140
-
141
- buttonElement .flex ().h (20 );
142
-
143
- if (i == 1 )
144
- {
145
- buttonElement .marginLeft (0 );
146
- buttonElement .marginRight (30 );
147
- }
148
- else if (i == 2 )
149
- {
150
- buttonElement .marginTop (50 );
151
- }
152
- else if (i == 3 )
153
- {
154
- buttonElement .marginBottom (50 );
155
- }
156
-
157
- this .element .add (buttonElement );
158
- }
159
-
160
- // this.add(this.element);
161
47
}
162
48
163
49
@ Override
@@ -166,78 +52,17 @@ public boolean isClientSideOnly()
166
52
return true ;
167
53
}
168
54
169
- private void play (GuiButtonElement button )
170
- {
171
- try
172
- {
173
- if (this .player != null )
174
- {
175
- this .player .delete ();
176
- }
177
-
178
- if (this .wave != null )
179
- {
180
- this .wave .delete ();
181
- }
182
-
183
- WaveReader reader = new WaveReader ();
184
- Wave data = reader .read (this .getClass ().getResourceAsStream ("/assets/mclib/8.wav" ));
185
-
186
- if (data .getBytesPerSample () > 2 )
187
- {
188
- data = data .convertTo16 ();
189
- }
190
-
191
- this .player = new WavePlayer ().initialize (data );
192
- this .player .play ();
193
-
194
- this .wave = new Waveform ();
195
- this .wave .generate (data , 20 , 150 );
196
- }
197
- catch (Exception e )
198
- {
199
- e .printStackTrace ();
200
- }
201
- }
202
-
203
55
@ Override
204
56
public void resize ()
205
57
{
206
58
super .resize ();
207
-
208
- this .dopesheet .graph .resetView ();
209
- this .graph .graph .resetView ();
210
59
}
211
60
212
61
@ Override
213
62
public void draw (GuiContext context )
214
63
{
215
- this .element .area .draw (ColorUtils .HALF_BLACK );
216
-
217
- if (this .player != null && !this .player .isPlaying ())
218
- {
219
- this .player .delete ();
220
- this .player = null ;
221
- }
222
-
223
64
super .draw (context );
224
65
225
- if (this .wave != null )
226
- {
227
- int w = this .wave .getWidth ();
228
- int h = this .wave .getHeight ();
229
-
230
- GlStateManager .enableTexture2D ();
231
-
232
- GlStateManager .color (0 , 0 , 0 , 1 );
233
- this .wave .draw (this .area .x + 10 , this .area .my () - h / 2 - 2 , 0 , 0 , w , h );
234
-
235
- GlStateManager .color (0.25F , 0.25F , 0.25F , 1 );
236
- this .wave .draw (this .area .x + 10 , this .area .my () - h / 2 , 0 , 0 , 200 , h );
237
- GlStateManager .color (0.5F , 0.5F , 0.5F , 1 );
238
- this .wave .draw (this .area .x + 10 + 200 , this .area .my () - h / 2 , 200 , 0 , 200 , h );
239
- GlStateManager .color (1 , 1 , 1 , 1 );
240
- this .wave .draw (this .area .x + 10 + 400 , this .area .my () - h / 2 , 400 , 0 , w , h );
241
- }
66
+ this .text .background (System .currentTimeMillis () % 2000 < 1000 );
242
67
}
243
68
}
0 commit comments