public StatScreen(Character character) { _character = character; var elems = new List <UiElement> { new UiLabel { Row = 1, Column = 1, Text = "Strength : " }, new UiLabel { Row = 2, Column = 1, Text = "Perception : " }, new UiLabel { Row = 3, Column = 1, Text = "Stamina : " }, new UiLabel { Row = 4, Column = 1, Text = "Charisma : " }, new UiLabel { Row = 5, Column = 1, Text = "Intelligence : " }, new UiLabel { Row = 6, Column = 1, Text = "Agility : " } }; _strength = new UiValue { Row = 1, Column = 2, Text = _character.Stats.Strength.ToString() }; _perception = new UiValue { Row = 2, Column = 2, Text = _character.Stats.Perception.ToString() }; _stamina = new UiValue { Row = 3, Column = 2, Text = _character.Stats.Stamina.ToString() }; _charisma = new UiValue { Row = 4, Column = 2, Text = _character.Stats.Charisma.ToString() }; _intelligence = new UiValue { Row = 5, Column = 2, Text = _character.Stats.Intelligence.ToString() }; _agility = new UiValue { Row = 6, Column = 2, Text = _character.Stats.Agility.ToString() }; elems.Add(_strength); elems.Add(_perception); elems.Add(_stamina); elems.Add(_charisma); elems.Add(_intelligence); elems.Add(_agility); _selectList = new UiSelectList(elems); }
/// <summary> /// Appends the corresponding type to the name space /// </summary> /// <param name="nameSpace">The namespace in which the type must be added</param> /// <param name="name">the name of the type</param> /// <param name="type">the type to convert</param> private DataDictionary.Types.Type AppendType(DataDictionary.Types.NameSpace nameSpace, string name, ErtmsSolutions.CodecNT.Type type) { DataDictionary.Types.Type retVal = null; if (EFSType(type) == null) { if (type.value is UiValue) { UiValue uiValue = type.value as UiValue; List <DataDictionary.Constants.EnumValue> values = getSpecialValues(uiValue.special_or_reserved_values); Decimal maxValue = twoPow(type.length) - 1; if (IsEnumeration(values, maxValue)) { DataDictionary.Types.Enum enumeration = (DataDictionary.Types.Enum)DataDictionary.Generated.acceptor.getFactory().createEnum(); enumeration.Name = type.id; enumeration.Default = values[0].Name; foreach (DataDictionary.Constants.EnumValue value in values) { enumeration.appendValues(value); } nameSpace.appendEnumerations(enumeration); retVal = enumeration; } else { DataDictionary.Types.Range range = (DataDictionary.Types.Range)DataDictionary.Generated.acceptor.getFactory().createRange(); range.Name = type.id; double factor = 1.0; System.Globalization.CultureInfo info = System.Globalization.CultureInfo.InvariantCulture; ResolutionFormula resolutionFormula = uiValue.resolution_formula; if (resolutionFormula != null && resolutionFormula.Value != null) { factor = double.Parse(resolutionFormula.Value, info); // In that case the precision is integer range.setPrecision(DataDictionary.Generated.acceptor.PrecisionEnum.aIntegerPrecision); range.MinValue = "0"; range.MaxValue = "" + maxValue; range.Default = "0"; } else { if (Math.Round(factor) == factor) { // Integer precision range.setPrecision(DataDictionary.Generated.acceptor.PrecisionEnum.aIntegerPrecision); range.MinValue = "0"; range.MaxValue = "" + maxValue * new Decimal(factor); range.Default = "0"; } else { // Double precision range.setPrecision(DataDictionary.Generated.acceptor.PrecisionEnum.aDoublePrecision); range.MinValue = "0.0"; range.MaxValue = (maxValue * new Decimal(factor)).ToString(info); range.Default = "0.0"; } } foreach (DataDictionary.Constants.EnumValue value in values) { range.appendSpecialValues(value); } nameSpace.appendRanges(range); retVal = range; } } else if (type.value is CharValue) { CharValue charValue = type.value as CharValue; // Nothing to do : translated into string } else if (type.value is BcdValue) { BcdValue bcdValue = type.value as BcdValue; DataDictionary.Types.Range range = (DataDictionary.Types.Range)DataDictionary.Generated.acceptor.getFactory().createRange(); range.Name = type.id; range.MinValue = "0"; range.MaxValue = "" + (twoPow(type.length) - 1); range.Default = "0"; nameSpace.appendRanges(range); retVal = range; } if (retVal != null) { retVal.Comment = type.short_description; if (type.description != null) { retVal.Comment = retVal.Comment + "\n" + type.description; } } } return(retVal); }