public void ToggleEnable(GalMapType tpsel = null) { GalMapType tpon = galacticMapTypes.Find(x => x.Enabled == true); // find if any are on foreach (GalMapType tp in galacticMapTypes) { if (tpsel == null) // if toggle all.. { tp.Enabled = (tpon == null); // enabled if all are OFF, else disabled if any are on } else if (tpsel == tp) { tp.Enabled = !tp.Enabled; } } }
public bool ParseData() { galacticMapObjects = new List <GalacticMapObject>(); try { string json = Tools.TryReadAllTextFromFile(GalacticMappingFile); if (json != null) { JArray galobjects = (JArray)JArray.Parse(json); foreach (JObject jo in galobjects) { GalacticMapObject galobject = new GalacticMapObject(jo); GalMapType ty = galacticMapTypes.Find(x => x.Typeid.Equals(galobject.type)); if (ty == null) { ty = galacticMapTypes[galacticMapTypes.Count - 1]; // last one is default.. Console.WriteLine("Unknown Gal Map object " + galobject.type); } galobject.galMapType = ty; galacticMapObjects.Add(galobject); } return(true); } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine("GalacticMapping.parsedata exception:" + ex.Message); } return(false); }
public void ToggleEnable(GalMapType tpsel = null) { int index = 0; int sel = 0; GalMapType tpon = galacticMapTypes.Find(x => x.Enabled == true); // find if any are on foreach (GalMapType tp in galacticMapTypes) { if (tpsel == null) // if toggle all.. { tp.Enabled = (tpon == null); // enabled if all are OFF, else disabled if any are on } else if (tpsel == tp) { tp.Enabled = !tp.Enabled; } sel |= (tp.Enabled ? 1 : 0) << index; index++; } SQLiteDBClass.PutSettingInt("GalObjectsEnable", sel); }
public void ToggleEnable(GalMapType tpsel = null) { GalMapType tpon = galacticMapTypes.Find(x => x.Enabled == true); // find if any are on foreach (GalMapType tp in galacticMapTypes) { if (tpsel == null) // if toggle all.. tp.Enabled = (tpon == null); // enabled if all are OFF, else disabled if any are on else if (tpsel == tp) tp.Enabled = !tp.Enabled; } }