public string write() { MyIni ini = new MyIni(); ini.AddSection(name); foreach (var kv in config) { ini.Set(name, kv.Key, kv.Value); } return(ini.ToString()); }
public Program() { // The constructor, called only once every session and // always before any other method is called. Use it to // initialize your script. // // The constructor is optional and can be removed if not // needed. // // It's recommended to set RuntimeInfo.UpdateFrequency // here, which will allow your script to run itself without a // timer block. // Me.CustomData = defaultParam_ini; bool needResetIni = false; MyIniParseResult result; if (!param_ini.TryParse(Me.CustomData, out result)) { Me.CustomData = ""; param_ini.TryParse("", out result); needResetIni = true; } param_ini.AddSection("Thruster_architecture"); param_ini.SetSectionComment("Thruster_architecture", " Each modifiaction need a recompile to be apply\n Delete a line \"Key = Value\" to recover default value\n (or delete all Custom data)"); needResetIni |= getOrAddIniBool("Thruster_architecture", "AUTO_FIT_GRAVITY_FEILD", ref AUTO_FIT_GRAVITY_FEILD, com_autoFit); needResetIni |= getOrAddIniFloat("Thruster_architecture", "FILLING_OF_GRAVITY_FEILD", ref FILLING_OF_GRAVITY_FEILD, com_filling); needResetIni |= getOrAddIniString("Thrusters_components", "GROUP_NAME_OF_THRUSTER_COMPONENT", ref GROUP_NAME_OF_THRUSTER_COMPONENT, com_groupName); needResetIni |= getOrAddIniBool("Thrusters_components", "RENAME_GRAVITY_GENERATOR", ref RENAME_GRAVITY_GENERATOR, com_rename); needResetIni |= getOrAddIniInt("Time_optimisation", "NB_SIMPLEX_STEPS_PER_TICKS", ref NB_SIMPLEX_STEPS_PER_TICKS, com_nbSimplex); param_ini.AddSection("Developper_option"); param_ini.SetSectionComment("Developper_option", about); needResetIni |= getOrAddIniBool("Developper_option", "USE_DEBUG", ref USE_DEBUG, com_useDebug); needResetIni |= getOrAddIniBool("Developper_option", "COMPUTE_NEW_STATS_SHIP_EVERY_TIME", ref COMPUTE_NEW_STATS_SHIP_EVERY_TIME); if (needResetIni) { Me.CustomData = param_ini.ToString(); } setFont(Me.GetSurface(0)); setFontBIG(Me.GetSurface(1)); Me.GetSurface(0).WriteText("::GRAVITY THRUSTER::"); stateOfShip = new StateOfShip[2]; stateOfShip[0] = new StateOfShip(this); stateOfShip[1] = new StateOfShip(this); //stateOfShip[0] = new StateOfShip(this); idCurrentStateOfShip = 0; idNextStateOfShip = 1; //nexStateOfShip = new StateOfShip(this); firstCompute = true; NewStateOfShipNeedMoreComputeTime = stateOfShip[idNextStateOfShip].ComputeNewStateMachine_OverTime(NB_SIMPLEX_STEPS_PER_TICKS); //PrintLog(); Runtime.UpdateFrequency = UpdateFrequency.Once | UpdateFrequency.Update10; }