An image editing program inspired by the 3DS title 'FlipNote Studio' featuring the same resolution to give the images the same look.
at master 8.1 kB view raw
1using System; 2using System.Linq; 3using Fjord; 4using Fjord.Modules.Debug; 5using Fjord.Modules.Game; 6using Fjord.Modules.Graphics; 7using Fjord.Modules.Input; 8using Fjord.Modules.Mathf; 9using Fjord.Modules.Sound; 10using static SDL2.SDL; 11using Game; 12 13namespace Game.Gui { 14 public static class gui { 15 private static string selected_input = ""; 16 17 private static V4 on_color = new V4(192, 175, 250, 255); 18 private static V4 off_color = new V4(255, 255, 255, 255); 19 private static V4 text_color = new V4(0, 0, 0, 255); 20 21 public static void slider(SDL_Rect rect, ref int value, int max, V4 off, V4 on) { 22 if (helpers.mouse_inside(rect, 2) && (mouse.button_pressed(0))) { 23 value = (int)((mouse.x - rect.x) / ((float)rect.w / max)); 24 } 25 26 value = Math.Clamp(value, 1, max); 27 28 draw.rect(rect, (byte)off.x, (byte)off.y, (byte)off.z, (byte)off.w, true); 29 rect.w = (int)(value * ((float)rect.w / (float)max)); 30 draw.rect(rect, (byte)on.x, (byte)on.y, (byte)on.z, (byte)on.w, true); 31 } 32 33 public static void slider(SDL_Rect rect, ref int value, int max) { 34 if (helpers.mouse_inside(rect, 2) && (mouse.button_pressed(0))) { 35 value = (int)((mouse.x - rect.x) / ((float)rect.w / max)); 36 } 37 38 value = Math.Clamp(value, 1, max); 39 40 draw.rect(rect, (byte)off_color.x, (byte)off_color.y, (byte)off_color.z, (byte)off_color.w, true); 41 rect.w = (int)(value * ((float)rect.w / (float)max)); 42 draw.rect(rect, (byte)on_color.x, (byte)on_color.y, (byte)on_color.z, (byte)on_color.w, true); 43 } 44 45 public static void button(SDL_Rect rect, ref bool value, string font, string text, V4 off, V4 on, V4 text_color) { 46 if (helpers.mouse_inside(rect, 2) && (mouse.button_just_pressed(0))) 47 value = !value; 48 49 if(!value) 50 draw.rect(rect, (byte)off.x, (byte)off.y, (byte)off.z, (byte)off.w, true); 51 else 52 draw.rect(rect, (byte)on.x, (byte)on.y, (byte)on.z, (byte)on.w, true); 53 54 draw.text(rect.x + 5, rect.y + 5, font, rect.h - 10, text, (byte)text_color.x, (byte)text_color.y, (byte)text_color.z, (byte)text_color.w); 55 } 56 57 public static void button(SDL_Rect rect, ref bool value, string font, string text) { 58 59 if (helpers.mouse_inside(rect, 2) && (mouse.button_just_pressed(0))) 60 value = !value; 61 62 if(!value) 63 draw.rect(rect, (byte)off_color.x, (byte)off_color.y, (byte)off_color.z, (byte)off_color.w, true); 64 else 65 draw.rect(rect, (byte)on_color.x, (byte)on_color.y, (byte)on_color.z, (byte)on_color.w, true); 66 67 draw.text(rect.x + 5, rect.y + 5, font, rect.h - 10, text, (byte)text_color.x, (byte)text_color.y, (byte)text_color.z, (byte)text_color.w); 68 } 69 70 public static void num_input_box(SDL_Rect rect, ref int value, string id, string font, V4 off, V4 on, V4 text_color) { 71 if (helpers.mouse_inside(rect, 2) && (mouse.button_just_pressed(0))) 72 selected_input = selected_input == id ? "" : id; 73 74 if(selected_input == id) { 75 switch(input.get_any_key_just_pressed()) { 76 case input.key_backspace: 77 Int32.TryParse(value.ToString().Length > 0 ? value.ToString().Substring(0, value.ToString().Length - 1) : "0", out value); 78 break; 79 case input.key_0: 80 Int32.TryParse(value.ToString() + "0", out value); 81 break; 82 case input.key_1: 83 Int32.TryParse(value.ToString() + "1", out value); 84 break; 85 case input.key_2: 86 Int32.TryParse(value.ToString() + "2", out value); 87 break; 88 case input.key_3: 89 Int32.TryParse(value.ToString() + "3", out value); 90 break; 91 case input.key_4: 92 Int32.TryParse(value.ToString() + "4", out value); 93 break; 94 case input.key_5: 95 Int32.TryParse(value.ToString() + "5", out value); 96 break; 97 case input.key_6: 98 Int32.TryParse(value.ToString() + "6", out value); 99 break; 100 case input.key_7: 101 Int32.TryParse(value.ToString() + "7", out value); 102 break; 103 case input.key_8: 104 Int32.TryParse(value.ToString() + "8", out value); 105 break; 106 case input.key_9: 107 Int32.TryParse(value.ToString() + "9", out value); 108 break; 109 } 110 } 111 112 if(selected_input != id) 113 draw.rect(rect, (byte)off.x, (byte)off.y, (byte)off.z, (byte)off.w, true); 114 else 115 draw.rect(rect, (byte)on.x, (byte)on.y, (byte)on.z, (byte)on.w, true); 116 117 draw.text(rect.x + 5, rect.y + 5, font, rect.h - 10, value.ToString(), (byte)text_color.x, (byte)text_color.y, (byte)text_color.z, (byte)text_color.w); 118 } 119 120 public static void num_input_box(SDL_Rect rect, ref int value, string id, string font) { 121 if (helpers.mouse_inside(rect, 2) && (mouse.button_just_pressed(0))) 122 selected_input = selected_input == id ? "" : id; 123 124 if(selected_input == id) { 125 switch(input.get_any_key_just_pressed()) { 126 case input.key_backspace: 127 Int32.TryParse(value.ToString().Length > 0 ? value.ToString().Substring(0, value.ToString().Length - 1) : "0", out value); 128 break; 129 case input.key_0: 130 Int32.TryParse(value.ToString() + "0", out value); 131 break; 132 case input.key_1: 133 Int32.TryParse(value.ToString() + "1", out value); 134 break; 135 case input.key_2: 136 Int32.TryParse(value.ToString() + "2", out value); 137 break; 138 case input.key_3: 139 Int32.TryParse(value.ToString() + "3", out value); 140 break; 141 case input.key_4: 142 Int32.TryParse(value.ToString() + "4", out value); 143 break; 144 case input.key_5: 145 Int32.TryParse(value.ToString() + "5", out value); 146 break; 147 case input.key_6: 148 Int32.TryParse(value.ToString() + "6", out value); 149 break; 150 case input.key_7: 151 Int32.TryParse(value.ToString() + "7", out value); 152 break; 153 case input.key_8: 154 Int32.TryParse(value.ToString() + "8", out value); 155 break; 156 case input.key_9: 157 Int32.TryParse(value.ToString() + "9", out value); 158 break; 159 } 160 } 161 162 if(selected_input != id) 163 draw.rect(rect, (byte)off_color.x, (byte)off_color.y, (byte)off_color.z, (byte)off_color.w, true); 164 else 165 draw.rect(rect, (byte)on_color.x, (byte)on_color.y, (byte)on_color.z, (byte)on_color.w, true); 166 167 draw.text(rect.x + 5, rect.y + 5, font, rect.h - 10, value.ToString(), (byte)text_color.x, (byte)text_color.y, (byte)text_color.z, (byte)text_color.w); 168 } 169 } 170}