/// <summary> /// Checks if a section exists in an INI file /// </summary> private bool bIniSectionExists(Nini.Config.IniConfigSource source, string sSection) { bool bReturn = false; foreach (Nini.Config.IniConfig config in source.Configs) { if (config.Name == sSection) { return(true); } } return(bReturn); }
public PhysicsScene CreateSimplePhysicsEngine() { Nini.Config.IConfigSource config = new Nini.Config.IniConfigSource(); config.AddConfig("Startup"); config.Configs["Startup"].Set("physics", "basicphysics"); PhysicsScene pScene = new BasicScene(); INonSharedRegionModule mod = pScene as INonSharedRegionModule; mod.Initialise(config); return(pScene); }
/// <summary> /// Looks for and reads the [Program Settings]->DatabaseLoc ini file value from the Time Clock MTS INI File /// </summary> private string sReadIniValue() { string sValue = ""; string sSection = "Program Settings"; string sKey = "DatabaseLoc"; // //Load up ini file // if (!bFileExists(this.sCommonAppDataDirectory + "\\timeclock.ini")) { this.ErrorMessage = this.sCommonAppDataDirectory + "\\timeclock.ini does not exist"; return(sValue); } try { Nini.Config.IniConfigSource source = new Nini.Config.IniConfigSource(this.sCommonAppDataDirectory + "\\timeclock.ini"); // //Check if section exists, if not return // if (!bIniSectionExists(source, sSection)) { this.ErrorMessage = "[" + sSection + "] does not exist"; return(sValue); } // //Check if key exists, create if it doesn't and assign default value // if (!source.Configs[sSection].Contains(sKey)) { this.ErrorMessage = "[" + sKey + "] does not exist"; return(sValue); } else { // //Read value // sValue = source.Configs[sSection].GetString(sKey); } return(sValue); } catch (Exception e) { this.ErrorMessage = e.ToString(); return(sValue); } }
private void SaveKarty(object sender, RoutedEventArgs e) { string cesta = Properties.Settings.Default.LokaceKaret; foreach (AKarta k in Karty) { string path = cesta + "/" + k.Karta.Id + ".pk"; FileStream f = File.Create(path); f.Close(); Nini.Config.IniConfigSource source = new Nini.Config.IniConfigSource(path); source.AddConfig("Karta"); k.Karta.Save(source.Configs["Karta"]); source.Save(); } }
public string VratInit(string jmeno, Nini.Config.IConfigSource defaultConfigSource) { if (defaultConfigSource == null) { return(VratInit(jmeno)); } string IniPath = AppDomain.CurrentDomain.BaseDirectory; if (!Directory.Exists(IniPath)) { return(null); } string s = Path.Combine(IniPath, jmeno + pripona); if (!File.Exists(s)) { File.Create(s).Close(); Nini.Config.IConfigSource source = new Nini.Config.IniConfigSource(s); source.Merge(defaultConfigSource); source.Save(); } return(s); }
private void LoadKarty(string cesta) { if (!Directory.Exists(cesta)) { return; } string[] data = Directory.GetFiles(cesta); Karty.Clear(); foreach (string s in data) { if (s.Contains(".pk")) { //FileStream f = File.Create(s); Nini.Config.IniConfigSource source = new Nini.Config.IniConfigSource(s); PPLCG.DataKarta dataKarta = new PPLCG.DataKarta(); AKarta k = null; Nini.Config.IConfig config = source.Configs["Karta"]; if (config != null) { dataKarta.Load(config); } switch (dataKarta.Typ) { case PPLCG.ETypy.Doplnek: PPLCG.DataDoplnek dd = new PPLCG.DataDoplnek(); dd.Load(config); k = new KartaDoplnek(dd); break; case PPLCG.ETypy.Hrdina: PPLCG.DataHrdina dh = new PPLCG.DataHrdina(); dh.Load(config); k = new KartaHrdina(dh); break; case PPLCG.ETypy.Lokace: PPLCG.DataLokace dl = new PPLCG.DataLokace(); dl.Load(config); k = new KartaLokace(dl); break; case PPLCG.ETypy.Nepritel: PPLCG.DataNepritel dn = new PPLCG.DataNepritel(); dn.Load(config); k = new KartaNepritel(dn); break; case PPLCG.ETypy.Spojenec: PPLCG.DataSpojenec ds = new PPLCG.DataSpojenec(); ds.Load(config); k = new KartaSpojenec(ds); break; case PPLCG.ETypy.Udalost: PPLCG.DataUdalost du = new PPLCG.DataUdalost(); du.Load(config); k = new KartaUdalost(du); break; case PPLCG.ETypy.Zrada: PPLCG.DataZrada dz = new PPLCG.DataZrada(); dz.Load(config); k = new KartaZrada(dz); break; } if (k != null) { Karty.Add(k); listBox1.Items.Add(k.Karta.Id); } } } }
// Create a mesh for the terrain of the current scene public static BInstance CreateTerrainMesh( Scene scene, PrimToMesh assetMesher, IAssetFetcher assetFetcher) { ITerrainChannel terrainDef = scene.Heightmap; int XSize = terrainDef.Width; int YSize = terrainDef.Height; float[,] heightMap = new float[XSize, YSize]; if (ConvOAR.Globals.parms.P <bool>("HalfRezTerrain")) { ConvOAR.Globals.log.DebugFormat("{0}: CreateTerrainMesh. creating half sized terrain sized <{1},{2}>", LogHeader, XSize / 2, YSize / 2); // Half resolution mesh that approximates the heightmap heightMap = new float[XSize / 2, YSize / 2]; for (int xx = 0; xx < XSize; xx += 2) { for (int yy = 0; yy < YSize; yy += 2) { float here = terrainDef.GetHeightAtXYZ(xx + 0, yy + 0, 26); float ln = terrainDef.GetHeightAtXYZ(xx + 1, yy + 0, 26); float ll = terrainDef.GetHeightAtXYZ(xx + 0, yy + 1, 26); float lr = terrainDef.GetHeightAtXYZ(xx + 1, yy + 1, 26); heightMap[xx / 2, yy / 2] = (here + ln + ll + lr) / 4; } } } else { ConvOAR.Globals.log.DebugFormat("{0}: CreateTerrainMesh. creating terrain sized <{1},{2}>", LogHeader, XSize / 2, YSize / 2); for (int xx = 0; xx < XSize; xx++) { for (int yy = 0; yy < YSize; yy++) { heightMap[xx, yy] = terrainDef.GetHeightAtXYZ(xx, yy, 26); } } } // Number found in RegionSettings.cs as DEFAULT_TERRAIN_TEXTURE_3 OMV.UUID convoarID = new OMV.UUID(ConvOAR.Globals.parms.P <string>("ConvoarID")); OMV.UUID defaultTextureID = new OMV.UUID("179cdabd-398a-9b6b-1391-4dc333ba321f"); OMV.Primitive.TextureEntryFace terrainFace = new OMV.Primitive.TextureEntryFace(null); terrainFace.TextureID = defaultTextureID; EntityHandleUUID terrainTextureHandle = new EntityHandleUUID(); MaterialInfo terrainMaterialInfo = new MaterialInfo(terrainFace); if (ConvOAR.Globals.parms.P <bool>("CreateTerrainSplat")) { // Use the OpenSim maptile generator to create a texture for the terrain var terrainRenderer = new TexturedMapTileRenderer(); Nini.Config.IConfigSource config = new Nini.Config.IniConfigSource(); terrainRenderer.Initialise(scene, config); var mapbmp = new Bitmap(terrainDef.Width, terrainDef.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); terrainRenderer.TerrainToBitmap(mapbmp); // Place the newly created image into the Displayable caches ImageInfo terrainImageInfo = new ImageInfo(); terrainImageInfo.handle = terrainTextureHandle; terrainImageInfo.image = mapbmp; terrainImageInfo.resizable = false; // terrain image resolution is not reduced assetFetcher.Images.Add(new BHashULong(terrainTextureHandle.GetHashCode()), terrainTextureHandle, terrainImageInfo); // Store the new image into the asset system so it can be read later. assetFetcher.StoreTextureImage(terrainTextureHandle, scene.Name + " Terrain", convoarID, mapbmp); // Link this image to the material terrainFace.TextureID = terrainTextureHandle.GetUUID(); } else { // Use the default texture code for terrain terrainTextureHandle = new EntityHandleUUID(defaultTextureID); BHash terrainHash = new BHashULong(defaultTextureID.GetHashCode()); assetFetcher.GetImageInfo(terrainHash, () => { ImageInfo terrainImageInfo = new ImageInfo(); terrainImageInfo.handle = terrainTextureHandle; assetFetcher.FetchTextureAsImage(terrainTextureHandle) .Then(img => { terrainImageInfo.image = img; }); return(terrainImageInfo); }); } // The above has created a MaterialInfo for the terrain texture ConvOAR.Globals.log.DebugFormat("{0}: CreateTerrainMesh. calling MeshFromHeightMap", LogHeader); DisplayableRenderable terrainDisplayable = assetMesher.MeshFromHeightMap(heightMap, terrainDef.Width, terrainDef.Height, assetFetcher, terrainFace); BInstance terrainInstance = new BInstance(); Displayable terrainDisp = new Displayable(terrainDisplayable); terrainDisp.name = "Terrain"; terrainDisp.baseUUID = OMV.UUID.Random(); terrainInstance.Representation = terrainDisp; return(terrainInstance); }
private void LoadKarty(string cesta) { if (!Directory.Exists(cesta)) return; string[] data = Directory.GetFiles(cesta); Karty.Clear(); foreach (string s in data) { if (s.Contains(".pk")) { //FileStream f = File.Create(s); Nini.Config.IniConfigSource source = new Nini.Config.IniConfigSource(s); PPLCG.DataKarta dataKarta = new PPLCG.DataKarta(); AKarta k = null; Nini.Config.IConfig config = source.Configs["Karta"]; if(config!=null) dataKarta.Load(config); switch(dataKarta.Typ) { case PPLCG.ETypy.Doplnek: PPLCG.DataDoplnek dd = new PPLCG.DataDoplnek(); dd.Load(config); k = new KartaDoplnek(dd); break; case PPLCG.ETypy.Hrdina: PPLCG.DataHrdina dh = new PPLCG.DataHrdina(); dh.Load(config); k = new KartaHrdina(dh); break; case PPLCG.ETypy.Lokace: PPLCG.DataLokace dl = new PPLCG.DataLokace(); dl.Load(config); k = new KartaLokace(dl); break; case PPLCG.ETypy.Nepritel: PPLCG.DataNepritel dn = new PPLCG.DataNepritel(); dn.Load(config); k = new KartaNepritel(dn); break; case PPLCG.ETypy.Spojenec: PPLCG.DataSpojenec ds = new PPLCG.DataSpojenec(); ds.Load(config); k = new KartaSpojenec(ds); break; case PPLCG.ETypy.Udalost: PPLCG.DataUdalost du = new PPLCG.DataUdalost(); du.Load(config); k = new KartaUdalost(du); break; case PPLCG.ETypy.Zrada: PPLCG.DataZrada dz = new PPLCG.DataZrada(); dz.Load(config); k = new KartaZrada(dz); break; } if (k != null) { Karty.Add(k); listBox1.Items.Add(k.Karta.Id); } } } }
private void SaveKarty(object sender, RoutedEventArgs e) { string cesta = Properties.Settings.Default.LokaceKaret; foreach (AKarta k in Karty) { string path = cesta + "/" + k.Karta.Id + ".pk"; FileStream f = File.Create(path); f.Close(); Nini.Config.IniConfigSource source = new Nini.Config.IniConfigSource(path); source.AddConfig("Karta"); k.Karta.Save(source.Configs["Karta"]); source.Save(); } }
// Create an OpenSimulator Scene and add enough auxillery services and objects // to it so it will allow the loading of assets. public Scene CreateScene(IAssetService memAssetService, string regionName) { RegionInfo regionInfo = new RegionInfo(0, 0, null, regionName); regionInfo.RegionName = regionName; regionInfo.RegionSizeX = regionInfo.RegionSizeY = Constants.RegionSize; regionInfo.RegionID = OMV.UUID.Random(); var estateSettings = new EstateSettings(); estateSettings.EstateOwner = OMV.UUID.Random(); regionInfo.EstateSettings = estateSettings; Scene scene = new Scene(regionInfo); // Add an in-memory asset service for all the loaded assets to go into scene.RegisterModuleInterface <IAssetService>(memAssetService); ISimulationDataService simulationDataService = new NullDataService(); scene.RegisterModuleInterface <ISimulationDataService>(simulationDataService); IRegionSerialiserModule serializerModule = new SerialiserModule(); scene.RegisterModuleInterface <IRegionSerialiserModule>(serializerModule); IUserAccountService userAccountService = new NullUserAccountService(); scene.RegisterModuleInterface <IUserAccountService>(userAccountService); PhysicsScene physScene = CreateSimplePhysicsEngine(); ((INonSharedRegionModule)physScene).AddRegion(scene); ((INonSharedRegionModule)physScene).RegionLoaded(scene); scene.PhysicsScene = physScene; scene.LandChannel = new TestLandChannel(scene); // simple land with no parcels Nini.Config.IConfigSource config = new Nini.Config.IniConfigSource(); config.AddConfig("Terrain"); config.Configs["Terrain"].Set("InitialTerrain", "flat"); var terrainModule = new TerrainModule(); try { terrainModule.Initialise(config); terrainModule.AddRegion(scene); } catch (ReflectionTypeLoadException e) { // The terrain module loads terrain brushes and they might not all have been included StringBuilder sb = new StringBuilder(); foreach (Exception exSub in e.LoaderExceptions) { sb.AppendLine(exSub.Message); FileNotFoundException exFileNotFound = exSub as FileNotFoundException; if (exFileNotFound != null) { if (!string.IsNullOrEmpty(exFileNotFound.FusionLog)) { sb.AppendLine("Fusion Log:"); sb.AppendLine(exFileNotFound.FusionLog); } } sb.AppendLine(); } string errorMessage = sb.ToString(); ConvOAR.Globals.log.Log("BConverterOS.CreateScene: exception adding region:"); ConvOAR.Globals.log.Log(errorMessage); } catch (Exception e) { ConvOAR.Globals.log.Log("BConverterOS.CreateScene: exception adding region: {0}", e); } SceneManager.Instance.Add(scene); return(scene); }