Exemplo n.º 1
0
 private string UnitToMeter(string text)
 {
     try
     {
         float worldScale = HLVRSettingsManager.ModSettings.GetWorldScale();
         return(I18N.IntToString((int)(I18N.ParseFloat(text) * UNIT_TO_CM * worldScale)));
     }
     catch (Exception)
     {
         return("");
     }
 }
Exemplo n.º 2
0
 private string MeterToUnit(string text)
 {
     try
     {
         float worldScale    = HLVRSettingsManager.ModSettings.GetWorldScale();
         float invWorldScale = worldScale != 0 ? 1 / worldScale : 0;
         return(I18N.IntToString((int)(I18N.ParseFloat(text) * CM_TO_UNIT * invWorldScale)));
     }
     catch (Exception)
     {
         return("");
     }
 }
Exemplo n.º 3
0
        public void SetValue(string value)
        {
            switch (Type)
            {
            case SettingType.STRING:
            case SettingType.ENUM:
                Value = value;
                break;

            case SettingType.BOOLEAN:
                Value = (value != null && value.Length > 0 && value != "0") ? "1" : "0";
                break;

            case SettingType.SPEED:
            case SettingType.DISTANCE:
            case SettingType.FACTOR:
                if (I18N.TryParseFloat(value, out float fvalue))
                {
                    Value = I18N.FloatToString(fvalue);
                }
                else
                {
                    Value = "0";
                }
                break;

            case SettingType.COUNT:
                if (I18N.TryParseInt(value, out int ivalue))
                {
                    Value = I18N.IntToString(ivalue);
                }
                else
                {
                    Value = "0";
                }
                break;
            }
        }