public override void OnRender() { var item = Target as ItemDataControl; RefreshResources(item); if (imageTex == null) { return; } var rect = new RectD(new Vector2d(-0.5f * imageTex.width, -imageTex.height), new Vector2d(imageTex.width, imageTex.height)); var adaptedRect = ComponentBasedEditor.Generic.ToRelative(rect.ToPoints()).ToRectD().ToRect(); GUI.DrawTexture(adaptedRect, rect.Contains(Event.current.mousePosition.ToVector2d()) && imageOverTex ? imageOverTex : imageTex, ScaleMode.ScaleToFit); }
public override void OnRender() { if (Target is NodeDataControl) { Target = Controller.Instance.SelectedChapterDataControl.getPlayer(); } var npc = Target as NPCDataControl; var orientation = Orientation.S; if (SceneEditor.ElementReference != null) { var elementReference = SceneEditor.ElementReference as ElementReferenceDataControl; orientation = elementReference.Orientation; } if (MapEditor.ElementReference != null) { var elementReference = MapEditor.ElementReference as ExtElementRefDataControl; orientation = elementReference.Orientation; } if (npc != null) { var resourceOrientation = ""; switch (orientation) { case Orientation.S: resourceOrientation = NPC.RESOURCE_TYPE_STAND_DOWN; break; case Orientation.N: resourceOrientation = NPC.RESOURCE_TYPE_STAND_UP; break; case Orientation.O: resourceOrientation = NPC.RESOURCE_TYPE_STAND_LEFT; break; case Orientation.E: resourceOrientation = NPC.RESOURCE_TYPE_STAND_RIGHT; break; } var preview = GetCharacterTexturePreview(npc, resourceOrientation); if (preview) { var rect = new RectD(new Vector2d(-0.5f * preview.width, -preview.height), new Vector2d(preview.width, preview.height)); var adaptedRect = ComponentBasedEditor.Generic.ToRelative(rect.ToPoints()).ToRectD().ToRect(); GUI.DrawTexture(adaptedRect, preview, ScaleMode.ScaleToFit); } } }
private static void Center(MapEditor mapEditor, MapElementDataControl mapElement) { var extElementReference = mapElement as ExtElementRefDataControl; var geoElementReference = mapElement as GeoElementRefDataControl; if (extElementReference != null) { var sprite = ScenesWindowElementReference.ReferenceComponent.GetSprite(extElementReference); if (!sprite) { mapEditor.Center = (Vector2d)extElementReference.TransformManager["Position"]; } else { var texture = sprite.texture; var rect = new RectD(new Vector2d(-0.5f * texture.width, -texture.height), new Vector2d(texture.width, texture.height)); var previousTransformManager = mapEditor.PositionManager; mapEditor.PositionManager = extElementReference.TransformManager.GUIMapPositionManager; var relativeRect = mapEditor.ToRelative(rect.ToPoints()).ToRectD(); mapEditor.PositionManager = previousTransformManager; var boundingBox = relativeRect.ToPoints() .Select(p => mapEditor.PixelToLatLon(mapEditor.RelativeToAbsolute(p))) .ToArray() .ToRectD(); mapEditor.ZoomToBoundingBox(boundingBox); mapEditor.Center = boundingBox.Center; } } else if (geoElementReference != null) { var geoElement = geoElementReference.ReferencedDataControl as GeoElementDataControl; var geometry = geoElement.GMLGeometries[geoElement.SelectedGeometry]; mapEditor.ZoomToBoundingBox(geometry.BoundingBox); mapEditor.Center = geometry.BoundingBox.Center; } }
public override bool Update() { if (Event.current.type != EventType.MouseDown) { return(false); } var workingMapElement = Target as MapElementDataControl; var extElementReference = workingMapElement as ExtElementRefDataControl; if (extElementReference == null) { return(false); } var sprite = ScenesWindowElementReference.ReferenceComponent.GetSprite(extElementReference); if (!sprite) { return(false); } var texture = sprite.texture; var rect = new RectD(new Vector2d(-0.5 * texture.width, -texture.height), new Vector2d(texture.width, texture.height)); var adaptedRect = ComponentBasedEditor.Generic.ToRelative(rect.ToPoints()).ToRectD(); var textureContains = false; if (adaptedRect.Contains(Event.current.mousePosition.ToVector2d())) { double x = (Event.current.mousePosition.x - rect.Min.x) / rect.Width; double y = (Event.current.mousePosition.y - rect.Min.y) / rect.Height; textureContains = true; //textureContains = sprite.texture.GetPixel((int)(x * sprite.texture.width), sprite.texture.height - (int)(y * sprite.texture.height)).a > 0; } return(textureContains || extElementReference.TransformManager.GUIMapPositionManager.IsGizmosSelected(MapEditor.Current, rect.ToPoints())); }
public override void OnDrawingGizmosSelected() { var workingMapElement = Target as MapElementDataControl; var extElementReference = workingMapElement as ExtElementRefDataControl; if (extElementReference == null) { return; } var sprite = ScenesWindowElementReference.ReferenceComponent.GetSprite(extElementReference); if (!sprite) { return; } var texture = sprite.texture; var rect = new RectD(new Vector2d(-0.5f * texture.width, -texture.height), new Vector2d(texture.width, texture.height)); extElementReference.TransformManager.GUIMapPositionManager.OnDrawingGizmosSelected(MapEditor.Current, rect.ToPoints()); }