internal Zone( ZoneCollection c, string name, int index ) { _zones = c; _name = name; _index = index; _keys = new List<Key>(); }
public SyosSeatPricing(DataTable perfTable, DataTable priceTypesTable, DataTable zonesTable, DataTable zonePriceTypesTable) { var results = (from row in perfTable.AsEnumerable() select new { Id = row.Field<int?>("Id"), Title = row.Field<string>("Title"), PerformanceDate = row.Field<DateTime?>("PerformanceDate"), ZoneMap = row.Field<string>("ZoneMap"), Venue = row.Field<string>("Venue"), PromoInd = row.Field<bool?>("PromoInd"), GeneralAvailability = row.Field<bool?>("GeneralAvailability"), TimeSlotDescription = row.Field<string>("TimeSlotDescription") }).Single(); PerfId = results.Id; PerfName = results.Title; PerfDateTime = results.PerformanceDate; ZoneMapId = results.ZoneMap; VenueName = results.Venue; IsPromo = results.PromoInd; IsGenerallyAvailable = results.GeneralAvailability; TimeSlotName = results.TimeSlotDescription; Zones = new ZoneCollection(zonesTable); PriceTypes = new SyosPriceTypeCollection(priceTypesTable); ZonePriceTypeCombos = new SyosZonePriceOptionCollection(zonePriceTypesTable); }
public SortShapesIntoZonesAction(ShapeCollection shapes, ZoneCollection zones) : base("Sort shapes into zones") { _zones = zones; if (_zones == null) _zones = EditorManager.Scene.Zones; foreach (ShapeBase shape in shapes) { Layer layer = GetBestLayer(shape); bool bIsExternalLayer = !EditorManager.Scene.Layers.Contains(shape.ParentLayer); if (layer == shape.ParentLayer) // do not re-assign, just leave in the layer continue; if (layer == null) { layer = GetBestLayer(shape); // see again why this failed (debug) layer = GetUnAssignedLayer(shape); } if (bIsExternalLayer) { shape.ChildIndex = -1; this.Add(AddShapeAction.CreateAddShapeAction(shape, layer.Root, layer, false)); } else this.Add(new SetShapeParentAction(shape, layer.Root)); } }
public SortShapesIntoZonesAction(ShapeCollection shapes, ZoneCollection zones) : base("Sort shapes into zones") { _zones = zones; if (_zones == null) { _zones = EditorManager.Scene.Zones; } foreach (ShapeBase shape in shapes) { Layer layer = GetBestLayer(shape); bool bIsExternalLayer = !EditorManager.Scene.Layers.Contains(shape.ParentLayer); if (layer == shape.ParentLayer) // do not re-assign, just leave in the layer { continue; } if (layer == null) { layer = GetBestLayer(shape); // see again why this failed (debug) layer = GetUnAssignedLayer(shape); } if (bIsExternalLayer) { shape.ChildIndex = -1; this.Add(AddShapeAction.CreateAddShapeAction(shape, layer.Root, layer, false)); } else { this.Add(new SetShapeParentAction(shape, layer.Root)); } } }
public static ZoneCollection GetZones(string[] html, out LayoutHtmlCollection result) { Regex zoneRegex = new Regex("name=\"(ZoneName|LayoutId|ID)\".+value=\"(.+)\">"); result = new LayoutHtmlCollection(); ZoneCollection zones = new ZoneCollection(); for (int i = 0; i < html.Count(); i++) { var item = html[i]; if (item == ZoneEntity.ZoneTag) { i++; item = html[i]; ZoneEntity zone = new ZoneEntity(); item.Split(new[] { "<input" }, StringSplitOptions.RemoveEmptyEntries).Each(part => { zoneRegex.Replace(part, evaluator => { if (evaluator.Groups[1].Value.Equals("ZoneName")) { zone.ZoneName = evaluator.Groups[2].Value; } else if (evaluator.Groups[1].Value.Equals("LayoutId")) { zone.LayoutId = evaluator.Groups[2].Value; } else if (evaluator.Groups[1].Value.Equals("ID")) { zone.ID = evaluator.Groups[2].Value; } return(""); }); }); zone.ID = zone.ID ?? Guid.NewGuid().ToString("N"); zones.Add(zone); result.Add(new LayoutHtml { Html = ZoneEntity.ZoneTag }); result.Add(new LayoutHtml { Html = zone.ID }); result.Add(new LayoutHtml { Html = ZoneEntity.ZoneEndTag }); i++; } else { result.Add(new LayoutHtml { Html = item }); } } return(zones); }
private void Load(String path) { try { this.Items = XObject <ZoneCollection> .Load(path); } catch { } }
public IActionResult SaveLayout(string[] html, LayoutEntity layout, ZoneCollection zones) { layout.Html = Zone.Helper.GenerateHtml(html, zones); layout.Zones = zones; Service.UpdateDesign(layout); if (layout.Page != null) { return(RedirectToAction("Design", "Page", new { layout.Page.ID })); } return(RedirectToAction("Index")); }
internal Keyboard( KeyboardCollection holder, string name ) { Debug.Assert( holder != null ); _keyboards = holder; _zones = new ZoneCollection( this ); _layouts = new LayoutCollection( this ); _name = name; _availableMode = _keyboards.Context.EmptyMode; _currentMode = _keyboards.Context.EmptyMode; _reqLayer = new RequirementLayer( "Keyboard" ); }
private static void ZoneRemoveHandler(Player player, Command cmd) { string zoneName = cmd.Next(); if (zoneName == null) { CdZoneRemove.PrintUsage(player); return; } ZoneCollection zones = player.WorldMap.Zones; Zone zone = zones.Find(zoneName); if (zone != null) { if (!player.Info.Rank.AllowSecurityCircumvention) { switch (zone.Controller.CheckDetailed(player.Info)) { case SecurityCheckResult.BlackListed: player.Message("You are not allowed to remove zone {0}: you are blacklisted.", zone.ClassyName); return; case SecurityCheckResult.RankTooLow: player.Message("You are not allowed to remove zone {0}.", zone.ClassyName); return; } } if (!cmd.IsConfirmed) { player.Confirm(cmd, "Remove zone {0}&S?", zone.ClassyName); return; } if (zones.Remove(zone.Name)) { player.Message("Zone \"{0}\" removed.", zone.Name); } } else { player.MessageNoZone(zoneName); } }
public static ZoneCollection SelectAll() { ZoneCollection List = new ZoneCollection(); using (IDataReader rd = SqlHelper.ExecuteReader(DAL.con(), CommandType.StoredProcedure, "sp_tblZone_Select_SelectAll_linhnx")) { while (rd.Read()) { List.Add(getFromReader(rd)); } } return(List); }
public static ZoneCollection SelectByAlias(SqlConnection con, string Alias) { ZoneCollection List = new ZoneCollection(); SqlParameter[] obj = new SqlParameter[1]; obj[0] = new SqlParameter("Alias", Alias); using (IDataReader rd = SqlHelper.ExecuteReader(con, CommandType.StoredProcedure, "sp_tblZone_Select_SelectByAlias_hoangda", obj)) { while (rd.Read()) { List.Add(getFromReader(rd)); } } return(List); }
public static LayoutHtmlCollection GenerateHtml(string[] html, ZoneCollection zones) { int index = 0; foreach (var item in zones) { if (item.HeadingCode.IsNullOrWhiteSpace()) { string zoneCode = $"ZONE-{index}"; while (zones.Any(m => m.HeadingCode == zoneCode)) { index++; zoneCode = $"ZONE-{index}"; } item.HeadingCode = zoneCode; } } int zoneIndex = 0; var result = new LayoutHtmlCollection(); for (int i = 0; i < html.Length; i++) { var item = html[i]; if (item == ZoneEntity.ZoneTag) { var zone = zones[zoneIndex]; result.Add(new LayoutHtml { Html = ZoneEntity.ZoneTag }); result.Add(new LayoutHtml { Html = zone.HeadingCode }); result.Add(new LayoutHtml { Html = ZoneEntity.ZoneEndTag }); i += 1; zoneIndex++; } else { result.Add(new LayoutHtml { Html = item }); } } return(result); }
/// <summary> /// Sets the collection of layers to be diplayed as items /// </summary> /// <param name="layers"></param> public void SetModifiedFiles(LayerCollection layers, ZoneCollection zones) { listView_Layers.BeginUpdate(); listView_Layers.Items.Clear(); foreach (Zone zone in zones) { ListViewItem item = listView_Layers.Items.Add(zone.ZoneName, IMAGE_NEW); item.SubItems.Add("New"); } foreach (Layer layer in layers) { Layer.LayerFileStatus_e status = layer.FileStatus; int iImage = IMAGE_MODIFIED; string statusStr = ""; switch (status) { case Layer.LayerFileStatus_e.Deleted: iImage = IMAGE_DELETED; statusStr = "Deleted"; break; case Layer.LayerFileStatus_e.Modified: iImage = IMAGE_MODIFIED; statusStr = "Modified"; break; case Layer.LayerFileStatus_e.NewLayer: iImage = IMAGE_NEW; statusStr = "New"; break; default: System.Diagnostics.Debug.Assert(false, "Should never get here"); break; } ListViewItem item = listView_Layers.Items.Add(layer.LayerName, iImage); item.SubItems.Add(statusStr); } listView_Layers.EndUpdate(); }
/// <summary> /// Sets the collection of layers to be diplayed as items /// </summary> /// <param name="layers"></param> public void SetModifiedFiles(LayerCollection layers, ZoneCollection zones) { listView_Layers.BeginUpdate(); listView_Layers.Items.Clear(); foreach (Zone zone in zones) { ListViewItem item = listView_Layers.Items.Add(zone.ZoneName, IMAGE_NEW); item.SubItems.Add("New"); } foreach (Layer layer in layers) { Layer.LayerFileStatus_e status = layer.FileStatus; int iImage = IMAGE_MODIFIED; string statusStr = ""; switch (status) { case Layer.LayerFileStatus_e.Deleted: iImage = IMAGE_DELETED; statusStr = "Deleted"; break; case Layer.LayerFileStatus_e.Modified: iImage = IMAGE_MODIFIED; statusStr = "Modified"; break; case Layer.LayerFileStatus_e.NewLayer: iImage = IMAGE_NEW; statusStr = "New"; break; default: System.Diagnostics.Debug.Assert(false,"Should never get here"); break; } ListViewItem item = listView_Layers.Items.Add(layer.LayerName, iImage); item.SubItems.Add(statusStr); } listView_Layers.EndUpdate(); }
public static LayoutHtmlCollection GenerateHtml(string[] html, ZoneCollection zones) { int zoneIndex = 0; var result = new LayoutHtmlCollection(); for (int i = 0; i < html.Length; i++) { var item = html[i]; if (item == ZoneEntity.ZoneTag) { var zone = zones[zoneIndex]; if (zone.ID.IsNullOrWhiteSpace()) { zone.ID = Guid.NewGuid().ToString("N"); } result.Add(new LayoutHtml { Html = ZoneEntity.ZoneTag }); result.Add(new LayoutHtml { Html = zone.ID }); result.Add(new LayoutHtml { Html = ZoneEntity.ZoneEndTag }); i += 1; zoneIndex++; } else { result.Add(new LayoutHtml { Html = item }); } } return(result); }
ZoneCollection GetRelevantZones(Vector3F pos, bool bInsideCachedRadius) { float fFarClip = EditorManager.ActiveView.FarClipPlane; ZoneCollection zones = new ZoneCollection(); Vector3D pivot = EditorManager.Scene.GlobalPivot; foreach (Zone zone in EditorManager.Scene.Zones) { BoundingBox zoneBox = bInsideCachedRadius ? zone.AbsoluteBoundingBox : zone.AssignmentBoundingBox; if (zoneBox == null || !zoneBox.Valid) zoneBox = zone.AssignmentBoundingBox; if (!zoneBox.Valid) continue; Vector3F offset = new Vector3F((float)(pivot.X - zone.ZonePivot.X), (float)(pivot.Y - zone.ZonePivot.Y), (float)(pivot.Z - zone.ZonePivot.Z)); float fDist = zoneBox.GetDistanceXY(pos + offset); if (fDist <= 0.0f || (bInsideCachedRadius && fDist <= zone.GetFinalLoadedDistance(fFarClip))) zones.Add(zone); } return zones; }
/// <summary> /// Initializes a new instance of the <see cref="Layout"/> class. /// </summary> public Layout() { Loaded += MasterLoaded; Zones = new ZoneCollection(); }
private void menuItem_MergeLayersIntoZones_Click(object sender, EventArgs e) { if (EditorManager.Scene == null || EditorManager.Scene.Zones.Count == 0) return; ZoneCollection zones = new ZoneCollection(); foreach (Zone zone in EditorManager.Scene.Zones) if (zone.ConsiderForSortIntoZones) zones.Add(zone); if (zones.Count==0) return; OpenFileDialog dlg = new OpenFileDialog(); dlg.InitialDirectory = EditorManager.Project.ProjectDir; dlg.Filter = "Layer files (*.Layer)|*.Layer"; dlg.Multiselect = true; dlg.Title = "Select one or more layer files from external folders that should be merged into the zones of the currect scenes"; if (dlg.ShowDialog() != DialogResult.OK) return; string[] names = dlg.FileNames; if (names == null || names.Length==0) return; float fProgressStep = 50.0f / (float)names.Length; EditorManager.Progress.ShowProgressDialog("Merging shapes..."); EditorManager.ActiveView.Gizmo.LockCtr++; // do not update ShapeTreeView.UIUpdateLock++; foreach (string name in names) { EditorManager.Progress.StatusString = "Loading Layer" + Path.GetFileName(name); Application.DoEvents(); Layer layer = null; BinaryFormatter fmt = SerializationHelper.BINARY_FORMATTER; try { // open the layer in read-only mode FileStream fs = new FileStream(name, FileMode.Open, FileAccess.Read); layer = (Layer)fmt.Deserialize(fs); fs.Close(); } catch (Exception ex) { EditorManager.DumpException(ex, true); } if (layer == null || layer.Root == null) continue; layer.OnCreateAllEngineInstances(null); // we need the engine instances, because otherwise the bounding boxs are not correct EditorManager.Progress.Percentage += fProgressStep; EditorManager.Progress.StatusString = "Merging Layer" + Path.GetFileName(name); Application.DoEvents(); SortShapesIntoZonesAction action = new SortShapesIntoZonesAction(layer.Root.ChildCollection, zones); // layer cleanup layer.OnRemoveAllEngineInstances(); EditorManager.EngineManager.Resources_PurgeUnusedResources(); EditorManager.Actions.Add(action); EditorManager.Progress.Percentage += fProgressStep; Application.DoEvents(); } EditorManager.Progress.HideProgressDialog(); EditorManager.ActiveView.Gizmo.LockCtr--; // do not update ShapeTreeView.UIUpdateLock--; }
public static ZoneCollection GetZones(string[] html, out LayoutHtmlCollection result) { ZoneEntity zone = null; bool initZoneStart = false; result = new LayoutHtmlCollection(); ZoneCollection zones = new ZoneCollection(); foreach (string item in html) { if (item == ZoneEntity.ZoneTag) { zone = new ZoneEntity(); initZoneStart = true; continue; } else if (item == ZoneEntity.ZoneEndTag) { initZoneStart = false; if (zone.ID.IsNullOrEmpty()) { zone.ID = Guid.NewGuid().ToString("N"); } zones.Add(zone); result.Add(new LayoutHtml { Html = ZoneEntity.ZoneTag }); result.Add(new LayoutHtml { Html = zone.ID }); result.Add(new LayoutHtml { Html = ZoneEntity.ZoneEndTag }); continue; } if (!initZoneStart) { result.Add(new LayoutHtml { Html = item }); } else { if (item.Contains("name=\"ZoneName\"") || item.Contains("name=\"ZoneId\"")) { string[] zoneInfo = item.Split(new string[] { "<input" }, StringSplitOptions.RemoveEmptyEntries); foreach (string zonePart in zoneInfo) { if (zonePart.Contains("name=\"ZoneName\"")) { zone.ZoneName = zonePart.GetInnerContent("value=\"", "\"", 0); } else if (zonePart.Contains("name=\"ID\"")) { zone.ID = zonePart.GetInnerContent("value=\"", "\"", 0); } else if (zonePart.Contains("name=\"LayoutId\"")) { zone.LayoutId = zonePart.GetInnerContent("value=\"", "\"", 0); } } } } } return zones; }
public void Destroy() { if( _name.Length == 0 ) throw new InvalidOperationException( R.ZoneDefaultDestroyed ); if( _zones != null ) { _zones.OnDestroy( this ); _zones = null; } }
/// <summary> /// Opens a dialog to confirm all the layer changes /// </summary> public void UpdateLayers() { LayerCollection modifiedLayers = new LayerCollection(); ZoneCollection modifiedZones = new ZoneCollection(); // gather new and modified layers GatherZones(modifiedZones); GatherLayers(modifiedLayers, null); // gather deleted layers foreach (Layer layer in Layers) { if (layer.OwnsLock) // cannot be deleted or modified continue; if (File.Exists(layer.AbsoluteLayerFilename)) continue; layer.FileStatus = Layer.LayerFileStatus_e.Deleted; modifiedLayers.Add(layer); } if (modifiedLayers.Count == 0 && modifiedZones.Count == 0) { EditorManager.ShowMessageBox("No updated, new or deleted layers/zones have been detected", "Update Layers", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } LayerUpdateDlg dlg = new LayerUpdateDlg(); dlg.SetModifiedFiles(modifiedLayers, modifiedZones); if (dlg.ShowDialog() != DialogResult.OK) return; EditorManager.Actions.StartGroup("Update Layers"); // add new zones foreach (Zone zone in modifiedZones) { zone.ParentScene = this; Zones.Add(zone); } // now merge the layers into the scene foreach (Layer layer in modifiedLayers) { Layer.LayerFileStatus_e status = layer.FileStatus; if (status == Layer.LayerFileStatus_e.Deleted) { EditorManager.Actions.Add(new RemoveLayerAction(layer)); continue; } if (status == Layer.LayerFileStatus_e.NewLayer) { EditorManager.Actions.Add(new AddLayerAction(layer, false)); // no unique filenames, use as-is continue; } if (status == Layer.LayerFileStatus_e.Modified) { Layer oldLayer = Layers.GetLayerByFilename(layer.LayerFilename); EditorManager.Actions.Add(new UpdateLayerAction(oldLayer, layer)); continue; } } EditorManager.Actions.EndGroup(); modifiedZones.MatchupLayerNames(Layers, null); // only call this for new zones! IScene.SendZoneChangedEvent(new ZoneChangedArgs(null, ZoneChangedArgs.Action.RebuildList)); }
/// <summary> /// Loads all zone files in the layer directory into /// </summary> /// <returns></returns> public bool GatherZones(ZoneCollection newZones) { bool bOK = true; string directoryName = LayerDirectoryName; DirectoryInfo layerFolder = new DirectoryInfo(directoryName); if (!layerFolder.Exists) return bOK; List<Zone> zonesToRename = new List<Zone>(); // binary zone files FileInfo[] files = layerFolder.GetFiles("*" + IScene.ZoneFileExtension); // filter out *.Zone foreach (FileInfo fileInfo in files) { IFormatter fmt = SerializationHelper.AUTO_FORMATTER; Zone zone = null; try { // open the layer in read-only mode using (FileStream fs = new FileStream(fileInfo.FullName, FileMode.Open, FileAccess.Read)) { zone = (Zone)fmt.Deserialize(fs); } } catch (Exception ex) { EditorManager.DumpException(ex); EditorManager.ShowMessageBox("An exception occurred while loading zone" + fileInfo.Name + "\n\nDetailed Message:\n" + ex.Message, "Zone loading error", MessageBoxButtons.OK, MessageBoxIcon.Error); continue; } Zone existingZoneFileName = Zones.GetZoneByFilename(zone.ZoneName, null); //check if the zone file is already in the scene if (existingZoneFileName != null) { continue; } Zone existingZone = Zones.GetZoneByName(zone.ZoneName); //check if the zone name already exists in the scene. This can be possible since filename and zonename don't have to match if (existingZone != null) zonesToRename.Add(zone); zone.SetZoneFileNameInternal(fileInfo.Name); zone.ParentScene = this; newZones.Add(zone); } // import from XML FileInfo[] filesXML = layerFolder.GetFiles("*" + IScene.ZoneFileExtensionXML); // filter out *.ZoneXML foreach (FileInfo fileInfo in filesXML) { // already loaded as binary? if (newZones.GetZoneByFilename(fileInfo.Name, null) != null) continue; Zone zone = LoadZoneFromXML(fileInfo.FullName); if (zone == null) continue; Zone existingZoneFileName = Zones.GetZoneByFilename(zone.ZoneName, null); //check if the zone file is already in the scene if (existingZoneFileName != null) { continue; } Zone existingZone = Zones.GetZoneByName(zone.ZoneName); //check if the zone name already exists in the scene. This can be possible since filename and zonename don't have to match if (existingZone != null) zonesToRename.Add(zone); zone.SetZoneFileNameInternal(fileInfo.Name); zone.ParentScene = this; newZones.Add(zone); } if (zonesToRename.Count > 0) { string warningMsg = "The following zones had to be renamed, since they are already loaded in the scene:\n"; foreach (Zone zoneToRename in zonesToRename) { string uniqueZoneName = this.CreateUniqueZoneName(zoneToRename.ZoneName); string oldZoneName = zoneToRename.ZoneName; zoneToRename.SetZoneNameInternal(uniqueZoneName); warningMsg += oldZoneName + " -> " + uniqueZoneName + "\n"; //make dirty so it will be saved when saving the scene zoneToRename.Dirty = true; } EditorManager.ShowMessageBox(warningMsg, "Renaming zone(s)", MessageBoxButtons.OK, MessageBoxIcon.Warning); } newZones.Sort(); return bOK; }
public ZoneCollectionPropertyDescriptor(ZoneCollection coll, int idx) : base("#" + idx.ToString(), null) { this.collection = coll; this.index = idx; }
ZoneCollection GetRelevantZones(Vector3F pos, bool bInsideCachedRadius) { float fFarClip = EditorManager.ActiveView.FarClipPlane; ZoneCollection zones = new ZoneCollection(); foreach (Zone zone in EditorManager.Scene.Zones) { BoundingBox zoneBox = bInsideCachedRadius ? zone.AbsoluteBoundingBox : zone.AssignmentBoundingBox; if (zoneBox == null || !zoneBox.Valid) zoneBox = zone.AssignmentBoundingBox; float fDist = zoneBox.GetDistance(pos); if (fDist <= 0.0f || (bInsideCachedRadius && fDist <= zone.GetFinalLoadedDistance(fFarClip))) zones.Add(zone); } return zones; }
public ContentItemViewModel(ContentItem item) { Zones = new ZoneCollection(); Item = item; }
public bool RunLighting(bool bShowDlg, ZoneCollection zones, bool bIncludeMainZone) { bool bExportInfoOnly = false; if (bShowDlg) { VLuxLightingDlg dlg = new VLuxLightingDlg(); dlg.Settings = (EditorManager.Scene as EditorScene).Settings; // clone settings dlg.LightMainPart = bIncludeMainZone; if (dlg.ShowDialog() != DialogResult.OK) { return(false); } // copy back settings: (EditorManager.Scene as EditorScene).Settings = dlg.Settings; if (!dlg.DoRelighting) { return(true); } bExportInfoOnly = dlg.ExportInfoOnly; } // for progress bar int iRelevantCount = bIncludeMainZone ? 1 : 0; foreach (Zone zone in zones) { if (zone.RunLighting) { iRelevantCount++; } } // nothing to light if (iRelevantCount == 0) { return(true); } Cursor oldCursor = EditorManager.MainForm.Cursor; EditorManager.MainForm.Cursor = Cursors.WaitCursor; VisionLightInfo info = new VisionLightInfo(); EditorManager.Progress.ShowProgressDialog("Calculate static lighting"); EditorManager.Progress.Percentage = 0.0f; float fPercentageStep = 100.0f / (float)iRelevantCount; // collect all infos foreach (Layer layer in EditorManager.Scene.Layers) { layer.GetStaticLightInfo(info); } // save all info files, for every zone and optionally main zone for (int i = 0; i <= zones.Count; i++) { Zone zone = null; if (i == zones.Count) { if (!bIncludeMainZone) { continue; } } else { zone = zones[i]; if (!zone.RunLighting) { continue; } } info.FilterByZone(zone); // save file that contains static lights string basename = "StaticLightingInfo"; if (zone != null) { zone.StaticLightInfo = (StaticLightInfo)info.Clone(); basename += "_" + zone.ZoneName; } string absfilename = Path.Combine(EditorManager.Scene.LayerDirectoryName, basename + ".XML"); if (!info.Save(absfilename)) { EditorManager.MainForm.Cursor = oldCursor; EditorManager.Progress.HideProgressDialog(); return(false); } // also, collect static mesh information string meshRelFilename = Path.Combine(EditorManager.Scene.RelativeLayerDirectoryName, basename + ".temp"); string meshAbsFilename = Path.Combine(EditorManager.Scene.LayerDirectoryName, basename + ".temp"); EditorManager.EngineManager.CreateStaticLightingMeshes(meshAbsFilename, info); EditorManager.Progress.Percentage += fPercentageStep; } if (bExportInfoOnly) { EditorManager.MainForm.Cursor = oldCursor; EditorManager.Progress.HideProgressDialog(); return(true); } // trigger the event (maybe another before info.Save?) EditorManager.TriggerSceneEvent(SceneEventArgs.Action.BeforeStaticLighting, true); // put together vLux parameter string string projectDir = EditorManager.Project.ProjectDir; if (projectDir.EndsWith(@"\")) { projectDir = projectDir.Remove(projectDir.Length - 1, 1); } // restart progress bar EditorManager.Progress.Percentage = 0.0f; // launch vLux n times bool bSuccess = true; for (int i = 0; i <= zones.Count; i++) { bool bVLuxSuccess = true; Zone zone = null; if (i == zones.Count) { if (!bIncludeMainZone) { continue; } } else { zone = zones[i]; if (!zone.Loaded || !zone.RunLighting) { continue; } } // save file that contains static lights string basename = "StaticLightingInfo"; if (zone != null) { basename += "_" + zone.ZoneName; } string meshLitFilename = Path.Combine(EditorManager.Scene.LayerDirectoryName, basename + ".lit"); // determine out filename (including relative path) and remove file extension string outFilename = EditorManager.Scene.FileName; string outFilenameExt = Path.GetExtension(outFilename); if (outFilenameExt != null) { outFilename = outFilename.Remove(outFilename.Length - outFilenameExt.Length, outFilenameExt.Length); } if (zone != null) { outFilename += "_" + zone.ZoneName; } //set edit mode for relevant lighting files EditorManager.EngineManager.EditOrAddRCSLightingFiles(Path.Combine(projectDir, outFilename), zone, meshLitFilename, false); string paramStr = "\"\""; // no v3d (first parameter just empty quotes) paramStr += " -project \"" + projectDir + "\""; // the project folder paramStr += " -tempfolder \"" + EditorManager.Scene.LayerDirectoryName + "\""; // the relative folder name where the temp files are located paramStr += " -out \"" + outFilename + "\""; // output filename if (zone != null) { paramStr += " -zone \"" + zone.ZoneName + "\""; } //paramStr += " -title \"" + EditorApp.Scene.FileName + "\""; // no window title required in this mode paramStr += " -quiet -minimized"; string lightingCfgFile = VLuxLightingTool.GetLightingCfgFile((EditorManager.Scene as EditorScene).Settings); ManagedBase.RCS.GetProvider().EditFile(lightingCfgFile); paramStr += " -config \"" + lightingCfgFile + "\""; try { // create a batch file for stand-alone lighting string batchName = Path.Combine(EditorManager.Scene.LayerDirectoryName, "Relight_" + basename + ".bat"); TextWriter txt = new StreamWriter(batchName); txt.WriteLine("vLux.exe " + paramStr); txt.Close(); } catch (Exception ex) { EditorManager.DumpException(ex); } try { Process vLux = FileHelper.RunExternalTool("vLux", VLuxLightingDlg.vLuxEXEPath, paramStr, true); if (vLux == null) { EditorManager.MainForm.Cursor = oldCursor; EditorManager.Progress.HideProgressDialog(); return(false); } Console.WriteLine(vLux.StandardOutput.ReadToEnd()); vLux.WaitForExit(); int iExitCode = vLux.ExitCode; // can we do something with this? } catch (Exception ex) { EditorManager.ShowMessageBox("vLux did not complete lighting. Please try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); EditorManager.DumpException(ex); bVLuxSuccess = false; } // wait until vLux is finished... EditorManager.Progress.Percentage += fPercentageStep; // reload the engine files if (bSuccess) { bVLuxSuccess &= EditorManager.EngineManager.ReloadLightingFiles(outFilename, zone); bVLuxSuccess &= EditorManager.EngineManager.ReloadStaticLightingMeshes(zone, meshLitFilename); EditorManager.Scene.UpdateView(true); EditorManager.Scene.UpdateView(true); //add relevant lighting files to RCS ManagedBase.RCS.GetProvider().AddFile(lightingCfgFile, false); EditorManager.EngineManager.EditOrAddRCSLightingFiles(Path.Combine(projectDir, outFilename), zone, meshLitFilename, true); } System.Diagnostics.Debug.Assert(bVLuxSuccess, "lighting was not successful"); bSuccess &= bVLuxSuccess; // trigger the event (maybe another before info.Save?) EditorManager.OnSceneEvent(new SceneEventArgs(SceneEventArgs.Action.AfterStaticLighting, bSuccess)); } // Update all shader assignments IScene.SendShaderResourceChangedEvent(new EventArgs()); // repaint EditorManager.Scene.UpdateView(false); EditorManager.MainForm.Cursor = oldCursor; EditorManager.Progress.HideProgressDialog(); return(bSuccess); }
/// <summary> Creates an empty new map of given dimensions. /// Dimensions cannot be changed after creation. </summary> /// <param name="world"> World that owns this map. May be null, and may be changed later. </param> /// <param name="width"> Width (horizontal, Notch's X). </param> /// <param name="length"> Length (horizontal, Notch's Z). </param> /// <param name="height"> Height (vertical, Notch's Y). </param> /// <param name="initBlockArray"> If true, the Blocks array will be created. </param> public Map( World world, int width, int length, int height, bool initBlockArray ) { if( !IsValidDimension( width ) ) throw new ArgumentException( "Invalid map dimension.", "width" ); if( !IsValidDimension( length ) ) throw new ArgumentException( "Invalid map dimension.", "length" ); if( !IsValidDimension( height ) ) throw new ArgumentException( "Invalid map dimension.", "height" ); DateCreated = DateTime.UtcNow; DateModified = DateCreated; Guid = Guid.NewGuid(); Metadata = new MetadataCollection<string>(); Metadata.Changed += OnMetaOrZoneChange; Zones = new ZoneCollection(); Zones.Changed += OnMetaOrZoneChange; World = world; Width = width; Length = length; Height = height; Bounds = new BoundingBox( Vector3I.Zero, Width, Length, Height ); Volume = Bounds.Volume; if( initBlockArray ) { Blocks = new byte[Volume]; } LifeZones = new Dictionary<string, Life2DZone>(); ResetSpawn(); }
public ContentItemViewModel() { Zones = new ZoneCollection(); }
public static ZoneCollection GetZones(string[] html, out LayoutHtmlCollection result) { ZoneEntity zone = null; bool initZoneStart = false; result = new LayoutHtmlCollection(); ZoneCollection zones = new ZoneCollection(); foreach (string item in html) { if (item == ZoneEntity.ZoneTag) { zone = new ZoneEntity(); initZoneStart = true; continue; } else if (item == ZoneEntity.ZoneEndTag) { initZoneStart = false; if (zone.ID.IsNullOrEmpty()) { zone.ID = Guid.NewGuid().ToString("N"); } zones.Add(zone); result.Add(new LayoutHtml { Html = ZoneEntity.ZoneTag }); result.Add(new LayoutHtml { Html = zone.ID }); result.Add(new LayoutHtml { Html = ZoneEntity.ZoneEndTag }); continue; } if (!initZoneStart) { result.Add(new LayoutHtml { Html = item }); } else { if (item.Contains("name=\"ZoneName\"") || item.Contains("name=\"ZoneId\"")) { string[] zoneInfo = item.Split(new string[] { "<input" }, StringSplitOptions.RemoveEmptyEntries); foreach (string zonePart in zoneInfo) { if (zonePart.Contains("name=\"ZoneName\"")) { zone.ZoneName = zonePart.GetInnerContent("value=\"", "\"", 0); } else if (zonePart.Contains("name=\"ID\"")) { zone.ID = zonePart.GetInnerContent("value=\"", "\"", 0); } else if (zonePart.Contains("name=\"LayoutId\"")) { zone.LayoutId = zonePart.GetInnerContent("value=\"", "\"", 0); } } } } } return(zones); }
/// <summary> /// Update the static lighting in the scene /// </summary> /// <param name="bShowDlg">Optionally shows the static lighting dialog</param> /// <param name="zones"></param> /// <param name="bIncludeMainZone"></param> /// <returns></returns> public override bool UpdateStaticLighting(bool bShowDlg, ZoneCollection zones, bool bIncludeMainZone) { if (zones == null) { zones = this.Zones.ShallowClone(); } else { // flag default: foreach (Zone zone in Zones) zone.RunLighting = zones.Contains(zone); } return EditorManager.LightingTool.RunLighting(bShowDlg, zones, bIncludeMainZone); }
public bool RunLighting(bool bShowDlg, ZoneCollection zones, bool bIncludeMainZone) { bool bExportInfoOnly = false; if (bShowDlg) { VLuxLightingDlg dlg = new VLuxLightingDlg(); dlg.Settings = (EditorManager.Scene as EditorScene).Settings; // clone settings dlg.LightMainPart = bIncludeMainZone; if (dlg.ShowDialog() != DialogResult.OK) return false; // copy back settings: (EditorManager.Scene as EditorScene).Settings = dlg.Settings; if (!dlg.DoRelighting) return true; bExportInfoOnly = dlg.ExportInfoOnly; } // for progress bar int iRelevantCount = bIncludeMainZone ? 1 : 0; foreach (Zone zone in zones) if (zone.RunLighting) iRelevantCount++; // nothing to light if (iRelevantCount == 0) return true; Cursor oldCursor = EditorManager.MainForm.Cursor; EditorManager.MainForm.Cursor = Cursors.WaitCursor; VisionLightInfo info = new VisionLightInfo(); EditorManager.Progress.ShowProgressDialog("Calculate static lighting"); EditorManager.Progress.Percentage = 0.0f; float fPercentageStep = 100.0f / (float)iRelevantCount; // collect all infos foreach (Layer layer in EditorManager.Scene.Layers) layer.GetStaticLightInfo(info); // save all info files, for every zone and optionally main zone for (int i = 0; i <= zones.Count; i++) { Zone zone = null; if (i == zones.Count) { if (!bIncludeMainZone) continue; } else { zone = zones[i]; if (!zone.RunLighting) continue; } info.FilterByZone(zone); // save file that contains static lights string basename = "StaticLightingInfo"; if (zone != null) { zone.StaticLightInfo = (StaticLightInfo)info.Clone(); basename += "_" + zone.ZoneName; } string absfilename = Path.Combine(EditorManager.Scene.LayerDirectoryName, basename + ".XML"); if (!info.Save(absfilename)) { EditorManager.MainForm.Cursor = oldCursor; EditorManager.Progress.HideProgressDialog(); return false; } // also, collect static mesh information string meshRelFilename = Path.Combine(EditorManager.Scene.RelativeLayerDirectoryName, basename + ".temp"); string meshAbsFilename = Path.Combine(EditorManager.Scene.LayerDirectoryName, basename + ".temp"); EditorManager.EngineManager.CreateStaticLightingMeshes(meshAbsFilename, info); EditorManager.Progress.Percentage += fPercentageStep; } if (bExportInfoOnly) { EditorManager.MainForm.Cursor = oldCursor; EditorManager.Progress.HideProgressDialog(); return true; } // trigger the event (maybe another before info.Save?) EditorManager.TriggerSceneEvent(SceneEventArgs.Action.BeforeStaticLighting, true); // put together vLux parameter string string projectDir = EditorManager.Project.ProjectDir; if (projectDir.EndsWith(@"\")) projectDir = projectDir.Remove(projectDir.Length - 1, 1); // restart progress bar EditorManager.Progress.Percentage = 0.0f; // launch vLux n times bool bSuccess = true; for (int i = 0; i <= zones.Count; i++) { bool bVLuxSuccess = true; Zone zone = null; if (i == zones.Count) { if (!bIncludeMainZone) continue; } else { zone = zones[i]; if (!zone.Loaded || !zone.RunLighting) continue; } // save file that contains static lights string basename = "StaticLightingInfo"; if (zone != null) basename += "_" + zone.ZoneName; string meshLitFilename = Path.Combine(EditorManager.Scene.LayerDirectoryName, basename + ".lit"); // determine out filename (including relative path) and remove file extension string outFilename = EditorManager.Scene.FileName; string outFilenameExt = Path.GetExtension(outFilename); if (outFilenameExt != null) outFilename = outFilename.Remove(outFilename.Length - outFilenameExt.Length, outFilenameExt.Length); if (zone != null) outFilename += "_" + zone.ZoneName; //set edit mode for relevant lighting files EditorManager.EngineManager.EditOrAddRCSLightingFiles(Path.Combine(projectDir, outFilename), zone, meshLitFilename, false); string paramStr = "\"\""; // no v3d (first parameter just empty quotes) paramStr += " -project \"" + projectDir + "\""; // the project folder paramStr += " -tempfolder \"" + EditorManager.Scene.LayerDirectoryName + "\""; // the relative folder name where the temp files are located paramStr += " -out \"" + outFilename + "\""; // output filename if (zone != null) paramStr += " -zone \"" + zone.ZoneName + "\""; //paramStr += " -title \"" + EditorApp.Scene.FileName + "\""; // no window title required in this mode paramStr += " -quiet -minimized"; string lightingCfgFile = VLuxLightingTool.GetLightingCfgFile((EditorManager.Scene as EditorScene).Settings); ManagedBase.RCS.GetProvider().EditFile(lightingCfgFile); paramStr += " -config \"" + lightingCfgFile + "\""; try { // create a batch file for stand-alone lighting string batchName = Path.Combine(EditorManager.Scene.LayerDirectoryName, "Relight_" + basename + ".bat"); TextWriter txt = new StreamWriter(batchName); txt.WriteLine("vLux.exe " + paramStr); txt.Close(); } catch (Exception ex) { EditorManager.DumpException(ex); } try { Process vLux = FileHelper.RunExternalTool("vLux", VLuxLightingDlg.vLuxEXEPath, paramStr, true); if (vLux == null) { EditorManager.MainForm.Cursor = oldCursor; EditorManager.Progress.HideProgressDialog(); return false; } Console.WriteLine(vLux.StandardOutput.ReadToEnd()); vLux.WaitForExit(); int iExitCode = vLux.ExitCode; // can we do something with this? } catch (Exception ex) { EditorManager.ShowMessageBox("vLux did not complete lighting. Please try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); EditorManager.DumpException(ex); bVLuxSuccess = false; } // wait until vLux is finished... EditorManager.Progress.Percentage += fPercentageStep; // reload the engine files if (bSuccess) { bVLuxSuccess &= EditorManager.EngineManager.ReloadLightingFiles(outFilename, zone); bVLuxSuccess &= EditorManager.EngineManager.ReloadStaticLightingMeshes(zone, meshLitFilename); EditorManager.Scene.UpdateView(true); EditorManager.Scene.UpdateView(true); //add relevant lighting files to RCS ManagedBase.RCS.GetProvider().AddFile(lightingCfgFile, false); EditorManager.EngineManager.EditOrAddRCSLightingFiles(Path.Combine(projectDir, outFilename), zone, meshLitFilename, true); } System.Diagnostics.Debug.Assert(bVLuxSuccess, "lighting was not successful"); bSuccess &= bVLuxSuccess; // trigger the event (maybe another before info.Save?) EditorManager.OnSceneEvent(new SceneEventArgs(SceneEventArgs.Action.AfterStaticLighting, bSuccess)); } // Update all shader assignments IScene.SendShaderResourceChangedEvent(new EventArgs()); // repaint EditorManager.Scene.UpdateView(false); EditorManager.MainForm.Cursor = oldCursor; EditorManager.Progress.HideProgressDialog(); return bSuccess; }
void EditorManager_SceneEvent(object sender, SceneEventArgs e) { if (e.action == SceneEventArgs.Action.AllowExport) { if (MeshExportSettings.AutomaticExport && MeshExportSettings.ExportForAssetProfile.IsActiveProfileSet) { if (EditorManager.ShowMessageBox("The terrain data needs to be saved before the export.\n Continue?", "Save Terrain Data", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { if (e is ExportSceneEventArgs) { ((ExportSceneEventArgs)e).CancelExport = true; } } } } else if (e.action == SceneEventArgs.Action.BeforeExport && HasEngineInstance()) { if (e is ExportSceneEventArgs) { if (MeshExportSettings.ExportForAssetProfile.IsActiveProfileSet) { if (!MeshExportSettings.AutomaticExport) return; EditorManager.ActiveView.SetDefaultContext(); int iCountX = 0; int iCountY = 0; if (!EngineTerrain.GetSectorMeshCount(ref iCountX, ref iCountY)) return; EditorManager.EngineManager.DisableRendering(); EditorManager.Progress.ShowProgressDialog("Exporting terrain sectors as static meshes"); try { // export each sector of the terrain as a .vmesh file EngineTerrain.ExportTerrainMeshs(MeshExportSettings, EditorManager.Progress, 50.0f, false); // collection which holds all exported zones, these zones are removed after the export (see below: SceneEventArgs.Action.AfterExport) exportedZones = new ZoneCollection(); // disable visibility zone disconnecting EngineTerrain.SetTerrainMeshExportFlag(true); float fStep = 50.0f / (float)(iCountX*iCountY); float fPercentage = 50.0f; // create zone, layer, and static mesh for each sector of the terrain for (int sy = 0; sy < iCountY; ++sy) { for (int sx = 0; sx < iCountX; ++sx) { string sectorFileName = EngineTerrain.GetSectorMeshFileName(sx, sy); if (sectorFileName == null) continue; // create static mesh StaticMeshShape shape = new StaticMeshShape(Path.GetFileNameWithoutExtension(sectorFileName)); shape.Position = (Vector3F)EngineTerrain.GetSectorOrigin(sx, sy); shape.MeshFileName = sectorFileName; string lightmapFileName = EngineTerrain.GetSectorLightmapName(sx, sy); if (lightmapFileName != null) shape.CustomLightmap = lightmapFileName; // create zone string uniqueFileName = FileHelper.CreateUniqueFilename(EditorManager.Scene.LayerDirectoryName, "TerrainSectorZone" + sx + "_" + sy, IScene.ZoneFileExtension); object[] zoneParameters = { EditorManager.Scene.CreateUniqueZoneName("TerrainSectorZone" + sx + "_" + sy) }; Zone zone = EditorManager.ZoneFactory.CreateInstance(zoneParameters); zone.SetZoneFileNameInternal(uniqueFileName); zone.LoadedDistance = MeshExportSettings.LoadedDistance; zone.CacheInMargin = MeshExportSettings.CacheInMargin; zone.CacheOutMargin = MeshExportSettings.CacheOutMargin; EditorManager.Scene.AddZone(zone); // create layer string uniqueFile = EditorManager.Scene.Layers.CreateUniqueLayerFileName(EditorManager.Scene.LayerDirectoryName, "TerrainSector" + sx + "_" + sy); object[] layerParameters = { "TerrainSector" }; Layer layer = EditorManager.LayerFactory.CreateInstance(layerParameters); layer.SetLayerFileNameInternal(uniqueFile); layer.AttachToZone(zone); EditorManager.Scene.AddLayer(layer, true); layer.AddShape(shape, shape.Parent); // add zone to export info, so that it gets exported ((ExportSceneEventArgs)e).ExportInfo.RelevantExportZones.Add(zone); ((ExportSceneEventArgs)e).ExportInfo.RelevantEmbeddedZones.Add(zone); // keep reference to be able to remove the zone after export exportedZones.Add(zone); fPercentage += fStep; if (EditorManager.Progress != null) EditorManager.Progress.Percentage = fPercentage; Application.DoEvents(); } } } finally { EditorManager.Progress.HideProgressDialog(); EditorManager.EngineManager.EnableRendering(); } } } } else if (e.action == SceneEventArgs.Action.AfterExport && HasEngineInstance()) { if (e is ExportSceneEventArgs) { if (MeshExportSettings.ExportForAssetProfile.IsActiveProfileSet) { if (!MeshExportSettings.AutomaticExport) return; // re-enable default behaviour for terrain visibility zone serialization EngineTerrain.SetTerrainMeshExportFlag(false); foreach (Zone zone in exportedZones) { // create .deleted filenames string absLayerFileName = zone.Layers[0].AbsoluteLayerFilename + ".deleted"; string absZoneFileName = zone.AbsoluteZoneFilename + ".deleted"; EditorManager.Scene.RemoveZone(zone); // delete .deleted files, because they are not needed in any way if (File.Exists(absLayerFileName)) File.Delete(absLayerFileName); if (File.Exists(absZoneFileName)) File.Delete(absZoneFileName); } exportedZones.Clear(); } } } }
private void sortShapesIntoZonesToolStripMenuItem_Click(object sender, EventArgs e) { ZoneCollection zones = new ZoneCollection(); foreach (Zone zone in EditorManager.Scene.Zones) if (zone.ConsiderForSortIntoZones) zones.Add(zone); if (zones.Count==0) return; ShapeCollection shapes = new ShapeCollection(); foreach (Layer layer in treeView_Layers.Selection_Layers) { if (layer.ParentZone != null || !layer.Modifiable) continue; foreach (ShapeBase shape in layer.Root.ChildCollection) shapes.Add(shape); } if (shapes.Count > 0) { SortShapesIntoZonesAction action = new SortShapesIntoZonesAction(shapes, zones); EditorManager.Actions.Add(action); } }
/// <summary> /// Update the static lighting in the scene /// </summary> /// <param name="bShowDlg">Optionally shows the static lighting dialog</param> /// <param name="zones"></param> /// <param name="bIncludeMainZone"></param> /// <returns></returns> public override bool UpdateStaticLighting(bool bShowDlg, ZoneCollection zones, bool bIncludeMainZone) { if (zones == null) { zones = this.Zones.ShallowClone(); } else { // flag default: foreach (Zone zone in Zones) zone.RunLighting = zones.Contains(zone); } try { return EditorManager.LightingTool.RunLighting(bShowDlg, zones, bIncludeMainZone); } catch (System.Exception ex) { EditorManager.ShowMessageBox(string.Format("Computing the static lighting failed: {0}", ex.Message), "Static lighting failed"); return false; } }
static void ZoneAddHandler(Player player, Command cmd) { World playerWorld = player.World; if (playerWorld == null) { PlayerOpException.ThrowNoWorld(player); } string givenZoneName = cmd.Next(); if (givenZoneName == null) { CdZoneAdd.PrintUsage(player); return; } if (!player.Info.Rank.AllowSecurityCircumvention) { SecurityCheckResult buildCheck = playerWorld.BuildSecurity.CheckDetailed(player.Info); switch (buildCheck) { case SecurityCheckResult.BlackListed: player.Message("Cannot add zones to world {0}&S: You are barred from building here.", playerWorld.ClassyName); return; case SecurityCheckResult.RankTooLow: player.Message("Cannot add zones to world {0}&S: You are not allowed to build here.", playerWorld.ClassyName); return; //case SecurityCheckResult.RankTooHigh: } } Zone newZone = new Zone(); ZoneCollection zoneCollection = player.WorldMap.Zones; if (givenZoneName.StartsWith("+")) { // personal zone (/ZAdd +Name) givenZoneName = givenZoneName.Substring(1); // Find the target player PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches(player, givenZoneName); if (info == null) { return; } // Make sure that the name is not taken already. // If a zone named after the player already exists, try adding a number after the name (e.g. "Notch2") newZone.Name = info.Name; for (int i = 2; zoneCollection.Contains(newZone.Name); i++) { newZone.Name = givenZoneName + i; } newZone.Controller.MinRank = info.Rank.NextRankUp ?? info.Rank; newZone.Controller.Include(info); player.Message("Zone: Creating a {0}+&S zone for player {1}&S.", newZone.Controller.MinRank.ClassyName, info.ClassyName); } else { // Adding an ordinary, rank-restricted zone. if (!World.IsValidName(givenZoneName)) { player.Message("\"{0}\" is not a valid zone name", givenZoneName); return; } if (zoneCollection.Contains(givenZoneName)) { player.Message("A zone with this name already exists. Use &H/ZEdit&S to edit."); return; } newZone.Name = givenZoneName; string rankName = cmd.Next(); if (rankName == null) { player.Message("No rank was specified. See &H/Help zone"); return; } Rank minRank = RankManager.FindRank(rankName); if (minRank != null) { string name; while ((name = cmd.Next()) != null) { if (name.Length == 0) { continue; } if (name.ToLower().StartsWith("msg=")) { newZone.Message = name.Substring(4) + " " + (cmd.NextAll() ?? ""); player.Message("Zone: Custom denied messaged changed to '" + newZone.Message + "'"); break; } PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches(player, name.Substring(1)); if (info == null) { return; } if (name.StartsWith("+")) { newZone.Controller.Include(info); } else if (name.StartsWith("-")) { newZone.Controller.Exclude(info); } } newZone.Controller.MinRank = minRank; } else { player.MessageNoRank(rankName); return; } } player.Message("Zone " + newZone.ClassyName + "&S: Place a block or type &H/Mark&S to use your location."); player.SelectionStart(2, ZoneAddCallback, newZone, CdZoneAdd.Permissions); }
public bool ImportLayerReferences(StringCollection externalLayers, StringCollection errorList) { _bSceneLoadingInProgress = true; bool bResult = true; if (errorList == null) errorList = new StringCollection(); try { List<FileInfo> layerFiles = new List<FileInfo>(); List<FileInfo> zoneFiles = new List<FileInfo>(); LayerCollection newLayers = new LayerCollection(); ZoneCollection newZones = new ZoneCollection(); foreach (string name in externalLayers) { string absname = name; if (!FileHelper.IsAbsolute(absname)) absname = Project.MakeAbsolute(name); string relname = Project.MakeRelative(absname); bool bIsLayer = relname.EndsWith(IScene.LayerFileExtension); bool bIsZone = relname.EndsWith(IScene.ZoneFileExtension); if (bIsLayer) { if (Layers.GetLayerByFilename(absname, null) != null) { errorList.Add(relname + " : Already exists in the scene"); break; } } else if (bIsZone) { if (Zones.GetZoneByFilename(absname, null) != null) { errorList.Add(relname + " : Already exists in the scene"); continue; } } if (File.Exists(absname)) { if (bIsLayer) layerFiles.Add(new FileInfo(absname)); if (bIsZone) zoneFiles.Add(new FileInfo(absname)); } else errorList.Add(relname + " : File not found"); } LoadLayers(newLayers, null, layerFiles.ToArray()); // LoadZones(newZones, null, zoneFiles.ToArray()); // not supported yet // Add layers to the scene (do not lock them) foreach (Layer layer in newLayers) { if (layer is V3DLayer) { errorList.Add(layer.LayerFilename + " : External main layers cannot be added"); continue; } EditorManager.Actions.Add(new AddLayerAction(layer, false)); } foreach (Zone zone in newZones) EditorManager.Actions.Add(new AddZoneAction(zone, false)); } catch (Exception ex) { EditorManager.DumpException(ex, true); bResult = false; } _bSceneLoadingInProgress = false; WriteReferenceFile(); return bResult; }
/// <summary> /// Initializes a new instance of the <see cref="Layout"/> class. /// </summary> public Layout() { Loaded += MasterLoaded; Zones = new ZoneCollection(); }
void ShowAssetDialog(ZoneCollection zones, LayerCollection layers) { ShowAssetListDlg dlg = new ShowAssetListDlg(); ResourceSnapshotInfo info = new ResourceSnapshotInfo(); ExportHelper.StartResourceSnapshot(info); string zoneNames = null; string layerNames = null; if (zones != null) foreach (Zone zone in zones) { zone.GetDependencies(info); if (zoneNames != null) zoneNames += ", "; zoneNames += zone.ZoneName; } if (layers != null) foreach (Layer layer in layers) { layer.GetDependencies(info); if (layerNames != null) layerNames += ", "; layerNames += layer.LayerName; } string desc = "This list shows the native assets used by :"; if (zoneNames != null) desc += "\n Zones : " + zoneNames; if (layerNames != null) desc += "\n Layers : " + layerNames; dlg.Description = desc; dlg.AssetList = EditorManager.AssetManager.ExtractAssetInfo(info); ExportHelper.EndResourceSnapshot(info); // after extracting dlg.ShowDialog(); }
internal Zone( ZoneCollection c, string name ) { _zones = c; _name = name; _keys = new List<Key>(); }
/// <summary> Creates an empty new map of given dimensions. /// Dimensions cannot be changed after creation. </summary> /// <param name="world"> World that owns this map. May be null, and may be changed later. </param> /// <param name="width"> Width (horizontal, Notch's X). </param> /// <param name="length"> Length (horizontal, Notch's Z). </param> /// <param name="height"> Height (vertical, Notch's Y). </param> /// <param name="initBlockArray"> If true, the Blocks array will be created. </param> /// <exception cref="ArgumentOutOfRangeException"> Width, length, or height is not between 16 and 2048. </exception> /// <exception cref="ArgumentException"> Map volume exceeds Int32.MaxValue. </exception> public Map([CanBeNull] World world, int width, int length, int height, bool initBlockArray) { if (!IsValidDimension(width)) throw new ArgumentOutOfRangeException("width", "Invalid map width."); if (!IsValidDimension(length)) throw new ArgumentOutOfRangeException("length", "Invalid map length."); if (!IsValidDimension(height)) throw new ArgumentOutOfRangeException("height", "Invalid map height."); if ((long)width*length*height > Int32.MaxValue) { throw new ArgumentException("Map volume exceeds Int32.MaxValue."); } DateCreated = DateTime.UtcNow; DateModified = DateCreated; Guid = Guid.NewGuid(); Metadata = new MetadataCollection<string>(); Metadata.Changed += OnMetaOrZoneChange; Zones = new ZoneCollection(); Zones.Changed += OnMetaOrZoneChange; World = world; Width = width; Length = length; Height = height; Bounds = new BoundingBox(Vector3I.Zero, Width, Length, Height); Volume = Bounds.Volume; if (initBlockArray) { Blocks = new byte[Volume]; } ResetSpawn(); }
private static void ZoneRenameHandler(Player player, Command cmd) { World playerWorld = player.World; if (playerWorld == null) { PlayerOpException.ThrowNoWorld(player); } // Make sure that both parameters are given. string oldName = cmd.Next(); string newName = cmd.Next(); if (oldName == null || newName == null) { CdZoneRename.PrintUsage(player); return; } // Make sure that the new name is valid. if (!World.IsValidName(newName)) { player.Message("\"{0}\" is not a valid zone name", newName); return; } // Find the old zone. ZoneCollection zones = player.WorldMap.Zones; Zone oldZone = zones.Find(oldName); if (oldZone == null) { player.MessageNoZone(oldName); return; } // Check if a zone with "newName" name already exists. Zone newZone = zones.FindExact(newName); if (newZone != null && newZone != oldZone) { player.Message("A zone with the name \"{0}\" already exists.", newName); return; } // Check if any change is needed. string fullOldName = oldZone.Name; if (fullOldName == newName) { player.Message("The zone is already named \"{0}\"", fullOldName); return; } // Actually rename the zone. zones.Rename(oldZone, newName); // Announce the rename. playerWorld.Players.Message("&SZone \"{0}\" was renamed to \"{1}&S\" by {2}", fullOldName, oldZone.ClassyName, player.ClassyName); Logger.Log(LogType.UserActivity, "Player {0} renamed zone \"{1}\" to \"{2}\" on world {3}", player.Name, fullOldName, newName, playerWorld.Name); }