public LogicOption(string name, string niceName, bool active, LogicOptionType type = LogicOptionType.Setting) { Name = name; NiceName = niceName; Active = active; Type = type; }
private LogicFlag ParseFlagDirective(string[] directiveParts) { if (directiveParts.Length < 4) { throw new ParserException("A flag somewhere has an incorrect number of parameters!"); } LogicOptionType optionType = GetOptionType(directiveParts[1]); if (optionType == LogicOptionType.Untyped) { throw new ParserException($"A flag somewhere has an invalid type! ({directiveParts[1]})"); } bool defaultActive; if (directiveParts.Length >= 5) { if (!bool.TryParse(directiveParts[4], out defaultActive)) { throw new ParserException($"{directiveParts[4]} is not a valid boolean value"); } } else { defaultActive = false; } return(new LogicFlag(directiveParts[2], directiveParts[3], defaultActive, optionType)); }
public LogicColorPicker(string name, string niceName, LogicOptionType type, Color startingColor) : base(name, niceName, true, type) { BaseColor = startingColor; DefinedColor = startingColor; InitialColors = new List <Color>(1) { startingColor }; }
private LogicOption ParseNumberboxDirective(string[] directiveParts) { if (directiveParts.Length != 4) { throw new ParserException("A numberbox somewhere has an incorrect number of parameters!"); } LogicOptionType optionType = GetOptionType(directiveParts[1]); if (optionType == LogicOptionType.Untyped) { throw new ParserException($"A numberbox somewhere has an invalid type! ({directiveParts[1]})"); } return(new LogicNumberBox(directiveParts[2], optionType, directiveParts[3])); }
private LogicColorPicker ParseColorDirective(string[] directiveParts) { LogicOptionType optionType = GetOptionType(directiveParts[1]); if (optionType == LogicOptionType.Untyped) { throw new ParserException($"A color somewhere has an invalid type! ({directiveParts[1]})"); } if (directiveParts.Length == 4) { return(new LogicColorPicker(directiveParts[2], directiveParts[3], optionType, Color.White)); } else if (directiveParts.Length % 3 == 1) { List <Color> colors = new List <Color>(); for (int i = 4; i < directiveParts.Length; i += 3) { // This parses the color components out, in groups of three. if (StringUtil.ParseString(directiveParts[i], out int rComponent) && StringUtil.ParseString(directiveParts[i + 1], out int gComponent) && StringUtil.ParseString(directiveParts[i + 2], out int bComponent) ) { colors.Add(Color.FromArgb(rComponent, gComponent, bComponent)); } else { throw new ParserException($"A color somewhere has an incorrect number! ({directiveParts[i]} - {directiveParts[i+1]} - {directiveParts[i+2]})"); } } return(new LogicColorPicker(directiveParts[2], directiveParts[3], optionType, colors)); } else { throw new ParserException($"A color somewhere has an incorrect number of parameters! ({directiveParts.Length})"); } }
private LogicOption ParseDropdownDirective(string[] directiveParts) { if (directiveParts.Length % 2 != 1 || directiveParts.Length < 5) { throw new ParserException("A dropdown somewhere has an incorrect number of parameters!"); } LogicOptionType optionType = GetOptionType(directiveParts[1]); if (optionType == LogicOptionType.Untyped) { throw new ParserException($"A dropdown somewhere has an invalid type! ({directiveParts[1]})"); } Dictionary <string, string> selectionDict = new Dictionary <string, string>((directiveParts.Length / 2) - 1); for (int i = 3; i < directiveParts.Length; i += 2) { selectionDict.Add(directiveParts[i], directiveParts[i + 1]); } return(new LogicDropdown(directiveParts[2], optionType, selectionDict)); }
public LogicFlag(string name, string niceName, bool active, LogicOptionType type) : base(name, niceName, active, type) { }
public LogicNumberBox(string name, LogicOptionType type, string placeholder) : base(name, name, true, type) { this.placeholder = placeholder; }
public LogicDropdown(string name, LogicOptionType type, Dictionary <string, string> selections) : base(name, name, true, type) { Selections = selections; Selection = selections.Keys.First(); }
// Can specify other colors to be defined relative to the first color public LogicColorPicker(string name, string niceName, LogicOptionType type, List <Color> colors) : base(name, niceName, true, type) { BaseColor = colors[0]; DefinedColor = colors[0]; InitialColors = colors; }