private static void AssignTextureCoordinateValues(TextureCoordinateSelectionWindow selectionWindow, NamedObjectSave nos) { var texture = selectionWindow.CurrentTexture; var rectangle = selectionWindow.RectangleSelector; if (texture != null) { GlueCommands.Self.GluxCommands.SetVariableOn( nos, "LeftTexturePixel", typeof(float), rectangle.Left); GlueCommands.Self.GluxCommands.SetVariableOn( nos, "RightTexturePixel", typeof(float), rectangle.Right); GlueCommands.Self.GluxCommands.SetVariableOn( nos, "TopTexturePixel", typeof(float), rectangle.Top); GlueCommands.Self.GluxCommands.SetVariableOn( nos, "BottomTexturePixel", typeof(float), rectangle.Bottom); } }
internal void HandleCoordinateChanged(TextureCoordinateSelectionWindow selectionWindow, NamedObjectSave nos) { AssignTextureCoordinateValues(selectionWindow, nos); GlueCommands.Self.GluxCommands.SaveGlux(); GlueCommands.Self.RefreshCommands.RefreshPropertyGrid(); GlueCommands.Self.GenerateCodeCommands.GenerateCurrentElementCode(); }
private static void AssignTextureCoordinateValues(TextureCoordinateSelectionWindow selectionWindow, NamedObjectSave nos) { var texture = selectionWindow.CurrentTexture; var rectangle = selectionWindow.RectangleSelector; if (texture != null) { // Victor Chelaru September 24, 2016 // The user may invert the rectangle and not know it. // Even though there are valid reasons to invert, allowing // it here probably causes more harm than good. Therefore, I'm // adding the Min/Max calls to the rectangle values. GlueCommands.Self.GluxCommands.SetVariableOn( nos, "LeftTexturePixel", typeof(float), System.Math.Min( rectangle.Left, rectangle.Right)); GlueCommands.Self.GluxCommands.SetVariableOn( nos, "RightTexturePixel", typeof(float), System.Math.Max(rectangle.Left, rectangle.Right)); GlueCommands.Self.GluxCommands.SetVariableOn( nos, "TopTexturePixel", typeof(float), System.Math.Min(rectangle.Top, rectangle.Bottom)); GlueCommands.Self.GluxCommands.SetVariableOn( nos, "BottomTexturePixel", typeof(float), System.Math.Max(rectangle.Top, rectangle.Bottom)); } }
public void RefreshSpriteDisplay(TextureCoordinateSelectionWindow selectionWindow) { var nos = GlueState.Self.CurrentNamedObjectSave; float leftTextureCoordinate; float rightTextureCoordinate; float topTextureCoordinate; float bottomTextureCoordinate; string fullFileName; GetTextureCoordinates(nos, out leftTextureCoordinate, out rightTextureCoordinate, out topTextureCoordinate, out bottomTextureCoordinate, out fullFileName); selectionWindow.ShowSprite(fullFileName, topTextureCoordinate, bottomTextureCoordinate, leftTextureCoordinate, rightTextureCoordinate); }
private void HandleIfSprite(TreeNode selectedTreeNode) { if (IsSelectedItemSprite) { if (!mContainer.Controls.Contains(mTab)) { mContainer.Controls.Add(mTab); //mContainer.SelectTab(mContainer.Controls.Count - 1); } mTab.Text = " Texture Coordinates"; // add spaces to make room for the X to close the plugin if (mTextureCoordinateControl == null) { mTextureCoordinateControl = new TextureCoordinateSelectionWindow(); mTextureCoordinateControl.Dock = DockStyle.Fill; mTextureCoordinateControl.RegionChanged += HandleRegionChanged; } if (!mTab.Controls.Contains(mTextureCoordinateControl)) { mTab.Controls.Add(mTextureCoordinateControl); } if (mTab.Controls.Contains(mAchxControl)) { mTab.Controls.Remove(mAchxControl); } textureCoordinateSelectionLogic.RefreshSpriteDisplay(mTextureCoordinateControl); } }
public override bool ShutDown(PluginShutDownReason reason) { // Do anything your plugin needs to do to shut down // or don't shut down and return false if (mTab != null) { mContainer.Controls.Remove(mTab); } mContainer = null; mTab = null; mAchxControl = null; mTextureCoordinateControl = null; return true; }