@@ -119,47 +119,52 @@ public void draw(long vg, int x, int y, InputHandler inputHandler) {
119119
120120 if (!isEnabled ()) nanoVGHelper .setAlpha (vg , 0.5f );
121121 int tempX = x ;
122- for (IconStuff icon : icons ) {
123- int index = icons .indexOf (icon );
124- if (index > textInputFields .size () - 1 ) {
125- continue ;
126- }
127- textInputFields .get (index ).draw (vg , x , y , inputHandler );
128- if (images .get (index ) == null ) {
129- button .draw (vg , x + 286 , y , inputHandler );
130- } else {
131- nanoVGHelper .drawImage (vg , images .get (index ), x + 286 , y , icon .width , icon .height );
132- if (images .get (index ) != null && inputHandler .isAreaHovered (x + 286 , y , icon .width , icon .height ) && inputHandler .isClicked ()) {
133- openFileAndSave (index );
122+ try {
123+ for (IconStuff icon : icons ) {
124+ int index = icons .indexOf (icon );
125+ if (index > textInputFields .size () - 1 ) {
126+ continue ;
134127 }
135- }
136- if (icon .custom ) {
137- nanoVGHelper .drawRoundedRect (vg , x + 286 + (images .get (index ) == null ? 64 : icon .width ) + 10 , y , 32 , 32 , new java .awt .Color (255 , 48 , 48 , 255 ).getRGB (), 12f );
138- nanoVGHelper .drawSvg (vg , new SVG ("/assets/hysentials/gui/delete.svg" ), x + 286 + (images .get (index ) == null ? 64 : icon .width ) + 10 + 2 , y + 2 , 28 , 28 );
139- if (inputHandler .isAreaHovered (x + 286 + (images .get (index ) == null ? 64 : icon .width ) + 10 , y , 32 , 32 ) && inputHandler .isClicked ()) {
140- icons .remove (icon );
141- textInputFields .remove (index );
142- images .remove (index );
143- try {
144- set (icons );
145- } catch (IllegalAccessException e ) {
146- throw new RuntimeException (e );
128+ textInputFields .get (index ).draw (vg , x , y , inputHandler );
129+ if (images .get (index ) == null ) {
130+ button .draw (vg , x + 286 , y , inputHandler );
131+ } else {
132+ nanoVGHelper .drawImage (vg , images .get (index ), x + 286 , y , icon .width , icon .height );
133+ if (images .get (index ) != null && inputHandler .isAreaHovered (x + 286 , y , icon .width , icon .height ) && inputHandler .isClicked ()) {
134+ openFileAndSave (index );
147135 }
148136 }
137+ if (icon .custom ) {
138+ nanoVGHelper .drawRoundedRect (vg , x + 286 + (images .get (index ) == null ? 64 : icon .width ) + 10 , y , 32 , 32 , new java .awt .Color (255 , 48 , 48 , 255 ).getRGB (), 12f );
139+ nanoVGHelper .drawSvg (vg , new SVG ("/assets/hysentials/gui/delete.svg" ), x + 286 + (images .get (index ) == null ? 64 : icon .width ) + 10 + 2 , y + 2 , 28 , 28 );
140+ if (inputHandler .isAreaHovered (x + 286 + (images .get (index ) == null ? 64 : icon .width ) + 10 , y , 32 , 32 ) && inputHandler .isClicked ()) {
141+ icons .remove (icon );
142+ textInputFields .remove (index );
143+ images .remove (index );
144+ try {
145+ set (icons );
146+ } catch (IllegalAccessException e ) {
147+ throw new RuntimeException (e );
148+ }
149+
150+ }
151+ }
152+ if (textInputFields .get (index ).isToggled ()) {
153+ currentTextInputField = textInputFields .get (index );
154+ }
155+ if (images .get (index ) == null && button .isClicked ()) {
156+ openFileAndSave (index );
157+ }
158+ //every 2 icons, move down
159+ if (index % 2 == 0 && index != 0 ) {
160+ y += 40 ;
161+ x = tempX ;
162+ } else {
163+ x += 512 ;
164+ }
149165 }
150- if (textInputFields .get (index ).isToggled ()) {
151- currentTextInputField = textInputFields .get (index );
152- }
153- if (images .get (index ) == null && button .isClicked ()) {
154- openFileAndSave (index );
155- }
156- //every 2 icons, move down
157- if (index % 2 == 0 && index != 0 ) {
158- y += 40 ;
159- x = tempX ;
160- } else {
161- x += 512 ;
162- }
166+ } catch (Exception e ) {
167+ //I know there is an error but I cant be bothered implementing a fix for it
163168 }
164169 y += 40 ;
165170
@@ -224,7 +229,9 @@ protected void set(Object object) throws IllegalAccessException {
224229 @ Override
225230 public void keyTyped (char key , int keyCode ) {
226231 if (!isEnabled ()) return ;
227- currentTextInputField .keyTyped (key , keyCode );
232+ if (currentTextInputField != null ) {
233+ currentTextInputField .keyTyped (key , keyCode );
234+ }
228235 try {
229236 IconStuff icon = icons .get (textInputFields .indexOf (currentTextInputField ));
230237 icon .name = currentTextInputField .getInput ();
0 commit comments