uint Grab(RadiacTextInput source, uint back) { var val = back; try { val = uint.Parse(source.text); } catch (Exception) { } return(val); }
uint CheckAndModify(RadiacTextInput text, uint val) { uint v = val; try { v = uint.Parse(text.text); } catch (Exception) { } // Reset the text to the original value, // otherwise this text box will always contains the wrong value without affecting other things... text.text = "" + v; return(v); }
UnitType GrabProdType(RadiacTextInput source, UnitType back) { var val = back; try { val = (UnitType)uint.Parse(source.text); var type = curSelection.type; if (val.IsNothing()) // I can always remove a production. { val = UnitType.None; } else if (type == UnitType.Headquater) { if (!val.IsProduction()) { val = back; } } else if (type == UnitType.Radar) { if (!val.IsAirforce()) { val = back; } } else if (type.IsProductionBuilding()) { if (!val.IsProduction()) { val = back; } } else if (type.IsResourcesBuilding()) { if (!val.IsResources()) { val = back; } } } catch (Exception) { if (source.text == "") { val = UnitType.None; } } return(val); }
UnitType GrabType(RadiacTextInput source, UnitType back) { var val = back; try { val = (UnitType)uint.Parse(source.text); if (!val.IsBuilding()) { val = back; } } catch (Exception) { } return(val); }
Owner Grab(RadiacTextInput source, Owner back) { var val = back; try { val = (Owner)uint.Parse(source.text); if (!Enum.IsDefined(typeof(Owner), val)) { return(back); } } catch (Exception) { } return(val); }