Falco Engine 3.9.0.1 (beta)
GUI.cs
Go to the documentation of this file.
1using System;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5namespace FalcoEngine
6{
7 public static class GUI
8 {
12 public enum ImageType
13 {
14 Simple,
15 Sliced
16 };
17
22 {
23 Left,
24 Center,
25 Right
26 };
27
32 {
33 Top,
34 Middle,
35 Bottom
36 };
37
41 public enum TextWordWrap
42 {
43 None,
44 WordWrap,
45 BreakWord
46 };
47
53 public static void Text(string text, Rect rect)
54 {
55 Color color = new Color(1, 1, 1, 1);
56 INTERNAL_text(text, ref rect, null, 14, 32, 0.0f, (int)TextWordWrap.WordWrap, (int)TextHorizontalAlignment.Left, (int)TextVerticalAlignment.Top, ref color);
57 }
58
65 public static void Text(string text, Rect rect, Font font)
66 {
67 Color color = new Color(1, 1, 1, 1);
68 INTERNAL_text(text, ref rect, font, 14, 32, 0.0f, (int)TextWordWrap.WordWrap, (int)TextHorizontalAlignment.Left, (int)TextVerticalAlignment.Top, ref color);
69 }
70
78 public static void Text(string text, Rect rect, Font font, float fontSize)
79 {
80 Color color = new Color(1, 1, 1, 1);
81 INTERNAL_text(text, ref rect, font, fontSize, 32, 0.0f, (int)TextWordWrap.WordWrap, (int)TextHorizontalAlignment.Left, (int)TextVerticalAlignment.Top, ref color);
82 }
83
92 public static void Text(string text, Rect rect, Font font, float fontSize, float fontResolution)
93 {
94 Color color = new Color(1, 1, 1, 1);
95 INTERNAL_text(text, ref rect, font, fontSize, fontResolution, 0.0f, (int)TextWordWrap.WordWrap, (int)TextHorizontalAlignment.Left, (int)TextVerticalAlignment.Top, ref color);
96 }
97
107 public static void Text(string text, Rect rect, Font font, float fontSize, float fontResolution, float lineSpacing)
108 {
109 Color color = new Color(1, 1, 1, 1);
110 INTERNAL_text(text, ref rect, font, fontSize, fontResolution, lineSpacing, (int)TextWordWrap.WordWrap, (int)TextHorizontalAlignment.Left, (int)TextVerticalAlignment.Top, ref color);
111 }
112
123 public static void Text(string text, Rect rect, Font font, float fontSize, float fontResolution, float lineSpacing, TextWordWrap wordWrap)
124 {
125 Color color = new Color(1, 1, 1, 1);
126 INTERNAL_text(text, ref rect, font, fontSize, fontResolution, lineSpacing, (int)wordWrap, (int)TextHorizontalAlignment.Left, (int)TextVerticalAlignment.Top, ref color);
127 }
128
141 public static void Text(string text, Rect rect, Font font, float fontSize, float fontResolution, float lineSpacing, TextWordWrap wordWrap, TextHorizontalAlignment horizontalAlignment, TextVerticalAlignment verticalAlignment)
142 {
143 Color color = new Color(1, 1, 1, 1);
144 INTERNAL_text(text, ref rect, font, fontSize, fontResolution, lineSpacing, (int)wordWrap, (int)horizontalAlignment, (int)verticalAlignment, ref color);
145 }
146
160 public static void Text(string text, Rect rect, Font font, float fontSize, float fontResolution, float lineSpacing, TextWordWrap wordWrap, TextHorizontalAlignment horizontalAlignment, TextVerticalAlignment verticalAlignment, Color color)
161 {
162 INTERNAL_text(text, ref rect, font, fontSize, fontResolution, lineSpacing, (int)wordWrap, (int)horizontalAlignment, (int)verticalAlignment, ref color);
163 }
164
172 public static void Text(string text, Rect rect, float fontSize, Color color)
173 {
174 INTERNAL_text(text, ref rect, null, fontSize, 32, 0.0f, (int)TextWordWrap.WordWrap, (int)TextHorizontalAlignment.Left, (int)TextVerticalAlignment.Top, ref color);
175 }
176
185 public static void Text(string text, Rect rect, Font font, float fontSize, Color color)
186 {
187 INTERNAL_text(text, ref rect, font, fontSize, 32, 0.0f, (int)TextWordWrap.WordWrap, (int)TextHorizontalAlignment.Left, (int)TextVerticalAlignment.Top, ref color);
188 }
189
199 public static void Text(string text, Rect rect, Font font, float fontSize, float fontResolution, Color color)
200 {
201 INTERNAL_text(text, ref rect, font, fontSize, fontResolution, 0.0f, (int)TextWordWrap.WordWrap, (int)TextHorizontalAlignment.Left, (int)TextVerticalAlignment.Top, ref color);
202 }
203
209 public static void Image(Texture texture, Rect rect)
210 {
211 Color color = new Color(1, 1, 1, 1);
212 INTERNAL_image(texture, ref rect, ref color, (int)ImageType.Simple);
213 }
214
221 public static void Image(Texture texture, Rect rect, Color color)
222 {
223 INTERNAL_image(texture, ref rect, ref color, (int)ImageType.Simple);
224 }
225
233 public static void Image(Texture texture, Rect rect, Color color, ImageType imageType)
234 {
235 INTERNAL_image(texture, ref rect, ref color, (int)imageType);
236 }
237
245 public static bool Button(int id, Rect rect, bool interactable)
246 {
247 Color color = Color.white;
248 Color colorHov = new Color(0.8f, 0.8f, 0.8f, 1.0f);
249 Color colorAct = new Color(0.6f, 0.6f, 0.6f, 1.0f);
250 Color colorDis = new Color(0.4f, 0.4f, 0.4f, 1.0f);
251
252 return INTERNAL_button(id, ref rect, null, null, null, null, ref color, ref colorHov, ref colorAct, ref colorDis, (int)ImageType.Simple, interactable);
253 }
254
266 public static bool Button(int id, Rect rect, Color normalColor, Color hoverColor, Color activeColor, Color disabledColor, bool interactable)
267 {
268 return INTERNAL_button(id, ref rect, null, null, null, null, ref normalColor, ref hoverColor, ref activeColor, ref disabledColor, (int)ImageType.Simple, interactable);
269 }
270
287 public static bool Button(int id,
288 Rect rect,
289 Color normalColor,
290 Color hoverColor,
291 Color activeColor,
292 Color disabledColor,
293 Texture normalTexture,
294 Texture hoverTexture,
295 Texture activeTexture,
296 Texture disabledTexture,
297 ImageType imageType,
298 bool interactable)
299 {
300 return INTERNAL_button(id, ref rect, normalTexture, hoverTexture, activeTexture, disabledTexture, ref normalColor, ref hoverColor, ref activeColor, ref disabledColor, (int)imageType, interactable);
301 }
302
315 public static bool Button(int id,
316 Rect rect,
317 Texture normalTexture,
318 Texture hoverTexture,
319 Texture activeTexture,
320 Texture disabledTexture,
321 ImageType imageType,
322 bool interactable)
323 {
324 Color color = Color.white;
325 Color colorHov = new Color(0.8f, 0.8f, 0.8f, 1.0f);
326 Color colorAct = new Color(0.6f, 0.6f, 0.6f, 1.0f);
327 Color colorDis = new Color(0.4f, 0.4f, 0.4f, 1.0f);
328
329 return INTERNAL_button(id, ref rect, normalTexture, hoverTexture, activeTexture, disabledTexture, ref color, ref colorHov, ref colorAct, ref colorDis, (int)imageType, interactable);
330 }
331
345 public static bool Button(int id,
346 Rect rect,
347 Color normalColor,
348 Color hoverColor,
349 Color activeColor,
350 Color disabledColor,
351 Texture texture,
352 ImageType imageType,
353 bool interactable)
354 {
355 return INTERNAL_button(id, ref rect, texture, texture, texture, texture, ref normalColor, ref hoverColor, ref activeColor, ref disabledColor, (int)imageType, interactable);
356 }
357
358 // INTERNAL CALLS //
359
360 [MethodImpl(MethodImplOptions.InternalCall)]
361 private static extern void INTERNAL_image(Texture texture, ref Rect rect, ref Color color, int imageType);
362
363 [MethodImpl(MethodImplOptions.InternalCall)]
364 private static extern void INTERNAL_text(string text,
365 ref Rect rect,
366 Font font,
367 float fontSize,
368 float fontResolution,
369 float lineSpacing,
370 int wordWrap,
371 int horizontalTextAlignment,
372 int verticalTextAlignment,
373 ref Color color);
374
375 [MethodImpl(MethodImplOptions.InternalCall)]
376 private static extern bool INTERNAL_button(int id,
377 ref Rect rect,
378 Texture texNormal,
379 Texture texHover,
380 Texture texActive,
381 Texture texDisabled,
382 ref Color color,
383 ref Color colHover,
384 ref Color colActive,
385 ref Color colDisabled,
386 int imageType,
387 bool interactable);
388 }
389}
static void Image(Texture texture, Rect rect, Color color)
Draw image with color tint
Definition: GUI.cs:221
static void Text(string text, Rect rect, Font font, float fontSize, float fontResolution, Color color)
Draw text with font, font size, font resolution and text color
Definition: GUI.cs:199
static void Text(string text, Rect rect, Font font, float fontSize, float fontResolution, float lineSpacing, TextWordWrap wordWrap, TextHorizontalAlignment horizontalAlignment, TextVerticalAlignment verticalAlignment, Color color)
Draw text with font, font size, font resolution, line spacing, word wrap, horizontal alignment,...
Definition: GUI.cs:160
static bool Button(int id, Rect rect, Color normalColor, Color hoverColor, Color activeColor, Color disabledColor, bool interactable)
Draw enabled or disabled button with tint colors
Definition: GUI.cs:266
static void Text(string text, Rect rect, Font font, float fontSize, float fontResolution, float lineSpacing)
Draw text with font, font size, font resolution and line spacing
Definition: GUI.cs:107
static void Image(Texture texture, Rect rect)
Draw image
Definition: GUI.cs:209
static bool Button(int id, Rect rect, bool interactable)
Draw enabled or disabled button
Definition: GUI.cs:245
TextVerticalAlignment
TextVerticalAlignment enum
Definition: GUI.cs:32
static void Text(string text, Rect rect, float fontSize, Color color)
Draw text with font size and text color
Definition: GUI.cs:172
static void Text(string text, Rect rect, Font font, float fontSize)
Draw text with font and font size
Definition: GUI.cs:78
static void Image(Texture texture, Rect rect, Color color, ImageType imageType)
Draw image with color tint and image type
Definition: GUI.cs:233
static void Text(string text, Rect rect, Font font, float fontSize, float fontResolution)
Draw text with font, font size and font resolution
Definition: GUI.cs:92
static bool Button(int id, Rect rect, Color normalColor, Color hoverColor, Color activeColor, Color disabledColor, Texture normalTexture, Texture hoverTexture, Texture activeTexture, Texture disabledTexture, ImageType imageType, bool interactable)
Draw enabled or disabled button with textures and tint colors
Definition: GUI.cs:287
static void Text(string text, Rect rect, Font font, float fontSize, float fontResolution, float lineSpacing, TextWordWrap wordWrap)
Draw text with font, font size, font resolution, line spacing and word wrap
Definition: GUI.cs:123
static void Text(string text, Rect rect, Font font, float fontSize, Color color)
Draw text with font, font size and text color
Definition: GUI.cs:185
static void Text(string text, Rect rect, Font font, float fontSize, float fontResolution, float lineSpacing, TextWordWrap wordWrap, TextHorizontalAlignment horizontalAlignment, TextVerticalAlignment verticalAlignment)
Draw text with font, font size, font resolution, line spacing, word wrap, horizontal alignment and ve...
Definition: GUI.cs:141
ImageType
ImageType enum
Definition: GUI.cs:13
TextWordWrap
TextWordWrap enum
Definition: GUI.cs:42
static void Text(string text, Rect rect, Font font)
Draw text with font
Definition: GUI.cs:65
static bool Button(int id, Rect rect, Texture normalTexture, Texture hoverTexture, Texture activeTexture, Texture disabledTexture, ImageType imageType, bool interactable)
Draw enabled or disabled button with textures
Definition: GUI.cs:315
TextHorizontalAlignment
TextHorizontalAlignment enum
Definition: GUI.cs:22
static void Text(string text, Rect rect)
Draw text
Definition: GUI.cs:53
static bool Button(int id, Rect rect, Color normalColor, Color hoverColor, Color activeColor, Color disabledColor, Texture texture, ImageType imageType, bool interactable)
Draw enabled or disabled button with one texture and tint colors
Definition: GUI.cs:345
static Color white
Definition: Color.cs:30