Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
HexInput Class Reference
Inheritance diagram for HexInput:

Public Member Functions

void SelectColor (Color color)
 

Events

Action< ColorColorSelected
 

Private Member Functions

void Awake ()
 
char OnValidateInput (string text, int charIndex, char addedChar)
 
void BackupColor ()
 
void OnInputValueChanged (string value)
 
string GetAlpha (string alpha)
 
void OnInputEndEdit (string value)
 
Color GetColorByHex (string hex)
 

Private Attributes

ColorPicker colorPicker
 
UiInputField input
 
string hexBackup
 
string currentHex
 

Detailed Description

Definition at line 8 of file HexInput.cs.

Member Function Documentation

◆ Awake()

void HexInput.Awake ( )
inlineprivate

Definition at line 24 of file HexInput.cs.

25 {
26 input.InputSelected += BackupColor;
27 input.onEndEdit.AddListener(OnInputEndEdit);
28 input.onValueChanged.AddListener(OnInputValueChanged);
29 UiInputField uiInputField = input;
30 uiInputField.onValidateInput = (InputField.OnValidateInput)Delegate.Combine(uiInputField.onValidateInput, new InputField.OnValidateInput(OnValidateInput));
31 input.characterLimit = (colorPicker.IsAlphaBeingUsed() ? 8 : 6);
32 }
ColorPicker colorPicker
Definition: HexInput.cs:11
void BackupColor()
Definition: HexInput.cs:43
UiInputField input
Definition: HexInput.cs:14
void OnInputEndEdit(string value)
Definition: HexInput.cs:89
void OnInputValueChanged(string value)
Definition: HexInput.cs:48
char OnValidateInput(string text, int charIndex, char addedChar)
Definition: HexInput.cs:34

References BackupColor(), colorPicker, input, Empyrean.ColorPicker.ColorPicker.IsAlphaBeingUsed(), OnInputEndEdit(), OnInputValueChanged(), and OnValidateInput().

◆ BackupColor()

void HexInput.BackupColor ( )
inlineprivate

Definition at line 43 of file HexInput.cs.

44 {
45 hexBackup = input.text;
46 }
string hexBackup
Definition: HexInput.cs:16

References hexBackup, and input.

Referenced by Awake().

◆ GetAlpha()

string HexInput.GetAlpha ( string  alpha)
inlineprivate

Definition at line 80 of file HexInput.cs.

81 {
83 {
84 return "";
85 }
86 return alpha;
87 }

References colorPicker, and Empyrean.ColorPicker.ColorPicker.IsAlphaBeingUsed().

Referenced by OnInputValueChanged().

◆ GetColorByHex()

Color HexInput.GetColorByHex ( string  hex)
inlineprivate

Definition at line 99 of file HexInput.cs.

100 {
101 return Colorist.HexToColor(hex);
102 }
static Color HexToColor(string hex)
Definition: Colorist.cs:237

References Empyrean.Utils.Colorist.HexToColor().

Referenced by OnInputEndEdit(), and OnInputValueChanged().

◆ OnInputEndEdit()

void HexInput.OnInputEndEdit ( string  value)
inlineprivate

Definition at line 89 of file HexInput.cs.

90 {
91 if (Input.GetKeyDown(KeyCode.Escape))
92 {
94 }
95 input.text = currentHex;
97 }
string currentHex
Definition: HexInput.cs:18
Action< Color > ColorSelected
Definition: HexInput.cs:20
Color GetColorByHex(string hex)
Definition: HexInput.cs:99

References ColorSelected, currentHex, GetColorByHex(), and hexBackup.

Referenced by Awake().

◆ OnInputValueChanged()

void HexInput.OnInputValueChanged ( string  value)
inlineprivate

Definition at line 48 of file HexInput.cs.

49 {
50 if (input.isFocused)
51 {
52 switch (value.Length)
53 {
54 default:
55 return;
56 case 0:
57 case 1:
58 case 2:
59 case 5:
60 case 7:
62 return;
63 case 3:
64 currentHex = string.Concat(value[0], value[0], value[1], value[1], value[2], value[2], GetAlpha("FF"));
65 break;
66 case 4:
67 currentHex = string.Concat(value[0], value[0], value[1], value[1], value[2], value[2], GetAlpha(string.Concat(value[3], value[3])));
68 break;
69 case 6:
70 currentHex = value + GetAlpha("FF");
71 break;
72 case 8:
73 currentHex = value;
74 break;
75 }
77 }
78 }
string GetAlpha(string alpha)
Definition: HexInput.cs:80

References ColorSelected, currentHex, GetAlpha(), GetColorByHex(), hexBackup, and input.

Referenced by Awake().

◆ OnValidateInput()

char HexInput.OnValidateInput ( string  text,
int  charIndex,
char  addedChar 
)
inlineprivate

Definition at line 34 of file HexInput.cs.

35 {
36 if (!Regex.IsMatch(addedChar.ToString(), "[A-Fa-f0-9]"))
37 {
38 return '\0';
39 }
40 return addedChar;
41 }

Referenced by Awake().

◆ SelectColor()

void HexInput.SelectColor ( Color  color)
inline

Definition at line 104 of file HexInput.cs.

105 {
106 if (!input.isFocused)
107 {
108 string text = (currentHex = Colorist.ColorToHex(color));
109 input.text = text;
110 }
111 }
static string ColorToHex(Color32 color)
Definition: Colorist.cs:232

References Empyrean.Utils.Colorist.ColorToHex(), currentHex, and input.

Referenced by Empyrean.ColorPicker.ColorPicker.UpdateColorPicker().

Member Data Documentation

◆ colorPicker

ColorPicker HexInput.colorPicker
private

Definition at line 11 of file HexInput.cs.

Referenced by Awake(), and GetAlpha().

◆ currentHex

string HexInput.currentHex
private

Definition at line 18 of file HexInput.cs.

Referenced by OnInputEndEdit(), OnInputValueChanged(), and SelectColor().

◆ hexBackup

string HexInput.hexBackup
private

Definition at line 16 of file HexInput.cs.

Referenced by BackupColor(), OnInputEndEdit(), and OnInputValueChanged().

◆ input

UiInputField HexInput.input
private

Definition at line 14 of file HexInput.cs.

Referenced by Awake(), BackupColor(), OnInputValueChanged(), and SelectColor().

Event Documentation

◆ ColorSelected

Action<Color> HexInput.ColorSelected
Initial value:
= delegate
{
}

Definition at line 20 of file HexInput.cs.

Referenced by OnInputEndEdit(), and OnInputValueChanged().


The documentation for this class was generated from the following file: