static void RecurseAddDirectories(string path, IList nodes, List<Skin> skins) { var di = new DirectoryInfo(path); foreach (FileInfo file in di.GetFiles("*.png", SearchOption.TopDirectoryOnly)) { var skin = new Skin(file); nodes.Add(skin); if (_tempToSelect == null) _tempToSelect = skin; else if (GlobalSettings.LastSkin == skin.File.ToString()) _tempToSelect = skin; skins.Add(skin); } foreach (DirectoryInfo dir in di.GetDirectories()) { if ((dir.Attributes & FileAttributes.Hidden) != 0) continue; var folderNode = new FolderNode(dir.FullName); RecurseAddDirectories(dir.FullName, folderNode.Nodes, skins); nodes.Add(folderNode); } }
public override bool EndClick(ColorGrabber pixels, Skin skin, MouseEventArgs e) { base.EndClick(pixels, skin, e); _seed = _noise.Next(); _noise = _noise2 = new Random(_seed); return false; }
public bool EndClick(ColorGrabber pixels, Skin skin, MouseEventArgs e) { _done = false; if (_undo.Points.Count != 0) skin.Undo.AddBuffer(_undo); _undo = null; Editor.MainForm.CheckUndo(); return false; }
public void BeginClick(Skin skin, Point p, MouseEventArgs e) { _undo = new PixelsChangedUndoable(Editor.GetLanguageString("U_PIXELSCHANGED"), Editor.MainForm.SelectedTool.MenuItem.Text); _boundBox = new Rectangle(0, 0, skin.Width, skin.Height); if ((Control.ModifierKeys & Keys.Control) != 0) _boundBox = Editor.CurrentModel.GetTextureFaceBounds(new Point(p.X, p.Y), skin); _done = false; }
public bool MouseMoveOnSkin(ColorGrabber pixels, Skin skin, int x, int y) { ColorPixel c = pixels[x, y]; ColorManager oldColor = ColorManager.FromRGBA(c.Red, c.Green, c.Blue, c.Alpha); if ((Control.ModifierKeys & Keys.Shift) != 0) Editor.MainForm.ColorPanel.UnselectedColor = oldColor; else Editor.MainForm.ColorPanel.SelectedColor = oldColor; return false; }
public virtual bool EndClick(ColorGrabber pixels, Skin skin, MouseEventArgs e) { if (_undo.Points.Count != 0) { skin.Undo.AddBuffer(_undo); Editor.MainForm.CheckUndo(); _oldPixel = new Point(-1, -1); } _undo = null; return false; }
public void MouseMove(Skin skin, MouseEventArgs e) { var delta = new Point(e.X - _oldMouse.X, e.Y - _oldMouse.Y); Point position = Cursor.Position; if (GlobalSettings.InfiniteMouse) { Rectangle screenBounds = _clickedScreen.Bounds; bool wasWrapped = false; Point oldMouseOnScreen = Editor.MainForm.Renderer.PointToScreen(_oldMouse); if (position.X <= screenBounds.X && oldMouseOnScreen.X > screenBounds.X) { Cursor.Position = new Point(screenBounds.X + screenBounds.Width, position.Y); wasWrapped = true; } else if (position.X >= screenBounds.X + screenBounds.Width - 1 && oldMouseOnScreen.X < screenBounds.X + screenBounds.Width - 1) { Cursor.Position = new Point(screenBounds.X, position.Y); wasWrapped = true; } if (position.Y <= screenBounds.Y && oldMouseOnScreen.Y > screenBounds.Y) { Cursor.Position = new Point(position.X, screenBounds.Y + screenBounds.Height); wasWrapped = true; } else if (position.Y >= screenBounds.Y + screenBounds.Height - 1 && oldMouseOnScreen.Y < screenBounds.Y + screenBounds.Height - 1) { Cursor.Position = new Point(position.X, screenBounds.Y); wasWrapped = true; } if (wasWrapped) _oldMouse = Editor.MainForm.Renderer.PointToClient(Cursor.Position); else _oldMouse = e.Location; } else _oldMouse = e.Location; if (e.Button == Editor.MainForm.CameraRotate) Editor.MainForm.RotateView(delta, 1); else if (e.Button == Editor.MainForm.CameraZoom) Editor.MainForm.ScaleView(delta, 1); }
public void PerformCloneSkin() { if (!treeView1.Enabled) return; if (treeView1.SelectedNode == null || !(treeView1.SelectedNode is Skin)) return; var skin = (Skin) treeView1.SelectedNode; string newName = skin.Name; string newFileName; do { newName += " - Copy"; newFileName = skin.Directory.FullName + '\\' + newName + ".png"; } while (File.Exists(newFileName)); File.Copy(skin.File.FullName, newFileName); var newSkin = new Skin(newFileName); skin.GetParentCollection().Add(newSkin); newSkin.SetImages(); }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { if (treeView1.SelectedNode == _lastSkin || !(e.Node is Skin)) return; Renderer.MakeCurrent(); if (_lastSkin != null && treeView1.SelectedNode != _lastSkin) { // Copy over the current changes to the tex stored in the skin. // This allows us to pick up where we left off later, without undoing any work. _lastSkin.CommitChanges(GlobalDirtiness.CurrentSkin, false); // if we aren't dirty, unload if (!_lastSkin.Dirty) _lastSkin.Unload(); } //if (_lastSkin != null) // _lastSkin.Undo.Clear(); var skin = (Skin) treeView1.SelectedNode; SetCanSave(skin.Dirty); if (skin.GLImage == null) skin.Create(); if (skin == null) { _currentUndoBuffer = null; TextureGL.Unbind(); using (var currentSkin = new ColorGrabber(GlobalDirtiness.CurrentSkin, 64, 32)) currentSkin.Save(); undoToolStripMenuItem.Enabled = undoToolStripButton.Enabled = false; redoToolStripMenuItem.Enabled = redoToolStripButton.Enabled = false; } else { using (var glImage = new ColorGrabber(skin.GLImage, skin.Width, skin.Height)) { glImage.Load(); glImage.Texture = GlobalDirtiness.CurrentSkin; glImage.Save(); glImage.Texture = _previewPaint; glImage.Save(); } _currentUndoBuffer = skin.Undo; CheckUndo(); } _lastSkin = (Skin) treeView1.SelectedNode; SetModel(skin.Model); Renderer.Invalidate(); VerifySelectionButtons(); FillPartList(); }
public bool EndClick(ColorGrabber pixels, Skin skin, MouseEventArgs e) { return(false); }
public bool RequestPreview(ColorGrabber pixels, Skin skin, int x, int y) { return false; }
public abstract bool MouseMoveOnSkin(ColorGrabber pixels, Skin skin, int x, int y);
public virtual void BeginClick(Skin skin, Point p, MouseEventArgs e) { _undo = new PixelsChangedUndoable(Editor.GetLanguageString("U_PIXELSCHANGED"), Editor.MainForm.SelectedTool.MenuItem.Text); }
protected override void OnDrawNode(DrawTreeNodeEventArgs e) { if (e.Bounds.Width == 0 || e.Bounds.Height == 0) { return; } int realX = e.Bounds.X + ((e.Node.Level + 1) * 20); Size textLen = TextRenderer.MeasureText(e.Node.Text, Font); if (realX + textLen.Width + ItemHeight + 15 > Width && _newMaximum < (realX + textLen.Width + ItemHeight + 15) - Width) { _newMaximum = (realX + textLen.Width + ItemHeight + 15) - Width; } realX -= _scrollX; e.Graphics.FillRectangle(new SolidBrush(BackColor), 0, e.Bounds.Y, Width, e.Bounds.Height); Skin skin = e.Node is Skin ? (Skin)e.Node : null; bool skinIsNull = skin == null; if (e.Node.IsSelected || e.Node == _overNode) { e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(127, SystemColors.Highlight)), realX, e.Bounds.Y, Width, e.Bounds.Height - 1); } else if (!skinIsNull && skin.IsLastSkin) { e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(127, Color.Yellow)), realX, e.Bounds.Y, Width, e.Bounds.Height - 1); } e.Graphics.InterpolationMode = InterpolationMode.NearestNeighbor; e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; e.Graphics.SmoothingMode = SmoothingMode.None; if (skinIsNull) { if (e.Node.IsExpanded) { e.Graphics.DrawImage(FolderOpen_32x32_72, realX, e.Bounds.Y, ItemHeight - 1, ItemHeight - 1); } else { e.Graphics.DrawImage(Folder_32x32, realX, e.Bounds.Y, ItemHeight - 1, ItemHeight - 1); } if (e.Node.Level == 0 && !Editor.HasOneRoot) { e.Graphics.DrawImage(clone, realX + (ItemHeight - clone.Width) - 1, e.Bounds.Y + (ItemHeight - clone.Height) - 1, clone.Width, clone.Height); } } else { e.Graphics.DrawImage(skin.Head, realX, e.Bounds.Y, ItemHeight - 1, ItemHeight - 1); } if (skinIsNull && e.Node.Nodes.Count != 0) { if (e.Node.IsExpanded) { if ((e.State & TreeNodeStates.Hot) != 0) { e.Graphics.DrawImage(arrow_state_blue_expanded, new Rectangle(realX - 13, e.Bounds.Y + (ItemHeight / 2) - (16 / 2), 16, 16)); } else { e.Graphics.DrawImage(arrow_state_grey_expanded, new Rectangle(realX - 13, e.Bounds.Y + (ItemHeight / 2) - (16 / 2), 16, 16)); } } else { if ((e.State & TreeNodeStates.Hot) != 0) { e.Graphics.DrawImage(arrow_state_blue_right, new Rectangle(realX - 13, e.Bounds.Y + (ItemHeight / 2) - (16 / 2), 16, 16)); } else { e.Graphics.DrawImage(arrow_state_grey_right, new Rectangle(realX - 13, e.Bounds.Y + (ItemHeight / 2) - (16 / 2), 16, 16)); } } } string text = e.Node.ToString(); TextRenderer.DrawText(e.Graphics, text, Font, new Rectangle(realX + ItemHeight + 1, e.Bounds.Y, Width, e.Bounds.Height), (e.Node.IsSelected || e.Node == _overNode) ? Color.White : Color.Black, TextFormatFlags.VerticalCenter); //TextRenderer.DrawText(e.Graphics, "64x32", new Font(Font.FontFamily, 7), new Rectangle(e.Bounds.X, e.Bounds.Y, Width - 20, e.Bounds.Height), (e.Node.IsSelected || e.Node == _overNode) ? Color.White : Color.Black, TextFormatFlags.Right | TextFormatFlags.VerticalCenter); }
public virtual bool RequestPreview(ColorGrabber pixels, Skin skin, int x, int y) { Brush brush = Brushes.SelectedBrush; if (_brushThatWasStamped != brush) { _stampedBrush = null; } if (x == -1) { return(false); } if (_stampedBrush == null && !HoldingShift) { return(false); } int startX = x - (brush.Width / 2); int startY = y - (brush.Height / 2); IsPreview = true; for (int ry = 0; ry < brush.Height; ++ry) { for (int rx = 0; rx < brush.Width; ++rx) { int xx = startX + rx; int yy = startY + ry; if (xx < 0 || xx >= skin.Width || yy < 0 || yy >= skin.Height) { continue; } if (brush[rx, ry] == 0.0f) { continue; } ColorPixel c = pixels[xx, yy]; Color newColor; if (!HoldingShift) { Color oldColor = Color.FromArgb(c.Alpha, c.Red, c.Green, c.Blue); Color color = Color.FromArgb(_stampedBrush[rx, ry].Alpha, _stampedBrush[rx, ry].Red, _stampedBrush[rx, ry].Green, _stampedBrush[rx, ry].Blue); color = Color.FromArgb((byte)(brush[rx, ry] * 255 * (color.A / 255.0f)), color); newColor = BlendColor(color, oldColor); } else { newColor = Color.FromArgb(c.Alpha, Color.White); } pixels[xx, yy] = new ColorPixel(newColor.R | (newColor.G << 8) | (newColor.B << 16) | (newColor.A << 24)); } } return(true); }
public virtual void MouseMove(Skin skin, MouseEventArgs e) { }
public bool MouseMoveOnSkin(ColorGrabber pixels, Skin skin, int x, int y) { return(MouseMoveOnSkin(pixels, skin, x, y, GlobalSettings.PencilIncremental)); }
public bool MouseMoveOnSkin(ColorGrabber pixels, Skin skin, int x, int y, bool incremental) { Brush brush = Brushes.SelectedBrush; if (_brushThatWasStamped != brush) { _stampedBrush = null; } if (x == _oldPixel.X && y == _oldPixel.Y) { return(false); } if (_stampedBrush == null && !HoldingShift) { return(false); } IsPreview = false; int startX = x - (brush.Width / 2); int startY = y - (brush.Height / 2); for (int ry = 0; ry < brush.Height; ++ry) { for (int rx = 0; rx < brush.Width; ++rx) { int xx = startX + rx; int yy = startY + ry; if (xx < 0 || xx >= skin.Width || yy < 0 || yy >= skin.Height) { continue; } if (brush[rx, ry] == 0.0f) { continue; } ColorPixel c = pixels[xx, yy]; if (HoldingShift) { if (_stampedBrush == null) { _stampedBrush = new ColorPixel[brush.Width, brush.Height]; } _brushThatWasStamped = brush; _stampedBrush[rx, ry] = c; continue; } Color oldColor = Color.FromArgb(c.Alpha, c.Red, c.Green, c.Blue); Color color = Color.FromArgb(_stampedBrush[rx, ry].Alpha, _stampedBrush[rx, ry].Red, _stampedBrush[rx, ry].Green, _stampedBrush[rx, ry].Blue); byte maxAlpha = color.A; var alphaToAdd = (float) (byte)(brush[rx, ry] * 255 * ((Editor.MainForm.ColorPanel.SelectedColor.RGB.A / 255.0f) * (color.A / 255.0f))); if (!incremental && _undo.Points.ContainsKey(new Point(xx, yy)) && _undo.Points[new Point(xx, yy)].Item2.TotalAlpha >= maxAlpha) { continue; } if (!incremental && _undo.Points.ContainsKey(new Point(xx, yy)) && _undo.Points[new Point(xx, yy)].Item2.TotalAlpha + alphaToAdd >= maxAlpha) { alphaToAdd = maxAlpha - _undo.Points[new Point(xx, yy)].Item2.TotalAlpha; } color = Color.FromArgb((byte)(alphaToAdd), color); Color newColor = BlendColor(color, oldColor); if (oldColor == newColor) { continue; } if (_undo.Points.ContainsKey(new Point(xx, yy))) { Tuple <Color, ColorAlpha> tupl = _undo.Points[new Point(xx, yy)]; _undo.Points[new Point(xx, yy)] = Tuple.Create(tupl.Item1, new ColorAlpha(newColor, tupl.Item2.TotalAlpha + alphaToAdd)); } else { _undo.Points.Add(new Point(xx, yy), Tuple.Create(oldColor, new ColorAlpha(newColor, alphaToAdd))); } pixels[xx, yy] = new ColorPixel(newColor.R | (newColor.G << 8) | (newColor.B << 16) | (newColor.A << 24)); } } _oldPixel = new Point(x, y); return(!HoldingShift); }
public bool MouseMoveOnSkin(ColorGrabber pixels, Skin skin, int x, int y) { return(false); }
public virtual bool RequestPreview(ColorGrabber pixels, Skin skin, int x, int y) { if (x == -1) return false; Brush brush = Brushes.SelectedBrush; int startX = x - (brush.Width / 2); int startY = y - (brush.Height / 2); IsPreview = true; for (int ry = 0; ry < brush.Height; ++ry) { for (int rx = 0; rx < brush.Width; ++rx) { int xx = startX + rx; int yy = startY + ry; if (xx < 0 || xx >= skin.Width || yy < 0 || yy >= skin.Height) continue; if (brush[rx, ry] == 0.0f) continue; ColorPixel c = pixels[xx, yy]; Color oldColor = Color.FromArgb(c.Alpha, c.Red, c.Green, c.Blue); Color color = GetLeftColor(); color = Color.FromArgb((byte) (brush[rx, ry] * 255 * (color.A / 255.0f)), color); Color newColor = BlendColor(color, oldColor); pixels[xx, yy] = new ColorPixel(newColor.R | (newColor.G << 8) | (newColor.B << 16) | (newColor.A << 24)); } } return true; }
protected override void OnDragDrop(DragEventArgs e) { dragDropOverFolder = 0; dragTimer.Stop(); if (e.Data.GetDataPresent(DataFormats.FileDrop) && !e.Data.GetDataPresent("MCSkin3D.Skin")) { e.Effect = e.AllowedEffect & DragDropEffects.Copy; var files = (string[])e.Data.GetData(DataFormats.FileDrop); string folderLocation = Editor.GetFolderLocationForNode(_overNode); if (string.IsNullOrEmpty(folderLocation)) { return; } foreach (string f in files) { string name = Path.GetFileNameWithoutExtension(f); while (File.Exists(folderLocation + name + ".png")) { name += " (" + Editor.GetLanguageString("C_NEW") + ")"; } File.Copy(f, folderLocation + name + ".png"); var skin = new Skin(folderLocation + name + ".png"); if (_overNode != null) { if (!(_overNode is Skin)) { _overNode.Nodes.Add(skin); } else { if (_overNode.Parent == null) { _overNode.TreeView.Nodes.Add(skin); } else { _overNode.Parent.Nodes.Add(skin); } } } else { Nodes.Add(skin); } skin.SetImages(); SelectedNode = skin; } } else { if (!DropValid(SelectedNode, _overNode)) { e.Effect = DragDropEffects.None; } else { TreeNode selNode = SelectedNode; if (e.Effect == DragDropEffects.Move) { MoveNode(SelectedNode, _overNode); } SelectedNode = selNode; } } //DropTargetHelper.Drop(e.Data, new Point(e.X, e.Y), e.Effect); _dragNode = null; _overNode = null; }
public void BeginClick(Skin skin, Point p, MouseEventArgs e) { }
public void MouseMove(Skin skin, MouseEventArgs e) { }
public bool MouseMoveOnSkin(ColorGrabber pixels, Skin skin, int x, int y, bool incremental) { if (x == _oldPixel.X && y == _oldPixel.Y) return false; IsPreview = false; Brush brush = Brushes.SelectedBrush; int startX = x - (brush.Width / 2); int startY = y - (brush.Height / 2); for (int ry = 0; ry < brush.Height; ++ry) { for (int rx = 0; rx < brush.Width; ++rx) { int xx = startX + rx; int yy = startY + ry; if (xx < 0 || xx >= skin.Width || yy < 0 || yy >= skin.Height) continue; if (brush[rx, ry] == 0.0f) continue; ColorPixel c = pixels[xx, yy]; Color oldColor = Color.FromArgb(c.Alpha, c.Red, c.Green, c.Blue); ColorManager.RGBColor color = (((Control.ModifierKeys & Keys.Shift) != 0) ? Editor.MainForm.ColorPanel.UnselectedColor : Editor.MainForm.ColorPanel.SelectedColor).RGB; byte maxAlpha = color.A; var alphaToAdd = (float) (byte) (brush[rx, ry] * 255 * (Editor.MainForm.ColorPanel.SelectedColor.RGB.A / 255.0f)); if (!incremental && _undo.Points.ContainsKey(new Point(xx, yy)) && _undo.Points[new Point(xx, yy)].Item2.TotalAlpha >= maxAlpha) continue; if (!incremental && _undo.Points.ContainsKey(new Point(xx, yy)) && _undo.Points[new Point(xx, yy)].Item2.TotalAlpha + alphaToAdd >= maxAlpha) alphaToAdd = maxAlpha - _undo.Points[new Point(xx, yy)].Item2.TotalAlpha; color = Color.FromArgb((byte) (alphaToAdd), color); Color newColor = BlendColor(color, oldColor); if (oldColor == newColor) continue; if (_undo.Points.ContainsKey(new Point(xx, yy))) { Tuple<Color, ColorAlpha> tupl = _undo.Points[new Point(xx, yy)]; tupl.Item2 = new ColorAlpha(newColor, tupl.Item2.TotalAlpha + alphaToAdd); _undo.Points[new Point(xx, yy)] = tupl; } else _undo.Points.Add(new Point(xx, yy), Tuple.MakeTuple(oldColor, new ColorAlpha(newColor, alphaToAdd))); pixels[xx, yy] = new ColorPixel(newColor.R | (newColor.G << 8) | (newColor.B << 16) | (newColor.A << 24)); } } _oldPixel = new Point(x, y); return true; }
public void BeginClick(Skin skin, Point p, MouseEventArgs e) { _oldMouse = e.Location; _clickedScreen = Screen.FromPoint(Cursor.Position); }
public bool EndClick(ColorGrabber pixels, Skin skin, MouseEventArgs e) { return false; }
private void DrawPlayer(Texture tex, Skin skin, bool pickView) { TextureGL.Unbind(); bool grass = !pickView && grassToolStripMenuItem.Checked; Point clPt = Renderer.PointToClient(Cursor.Position); int x = clPt.X - (_currentViewport.Width / 2); int y = clPt.Y - (_currentViewport.Height / 2); if (!pickView && GlobalSettings.Transparency == TransparencyMode.All) GL.Enable(EnableCap.Blend); else GL.Disable(EnableCap.Blend); GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.Front); if (grass) DrawSkinnedRectangle(0, GrassY, 0, 1024, 0, 1024, 0, 0, 1024, 1024, _grassTop, 16, 16); GL.Disable(EnableCap.CullFace); Vector3 helmetRotate = (GlobalSettings.FollowCursor) ? new Vector3((float) y / 25, (float) x / 25, 0) : Vector3.Zero; double sinAnim = (GlobalSettings.Animate) ? Math.Sin(_animationTime) : 0; // add meshes if (GlobalSettings.RenderBenchmark && Editor.IsRendering) _compileTimer.Start(); if (CurrentModel != null) { int meshIndex = -1; foreach (Mesh mesh in CurrentModel.Meshes) { meshIndex++; bool meshVisible = CurrentModel.PartsEnabled[meshIndex]; if (meshVisible == false && !(GlobalSettings.Ghost && !pickView)) continue; if (!mesh.IsSolid) mesh.HasTransparency = _lastSkin.TransparentParts[meshIndex]; mesh.Texture = tex; if (mesh.FollowCursor && GlobalSettings.FollowCursor) mesh.Rotate = helmetRotate; // Lazy Man Update! mesh.LastDrawTransparent = mesh.DrawTransparent; mesh.DrawTransparent = (meshVisible == false && GlobalSettings.Ghost && !pickView); if (mesh.LastDrawTransparent != mesh.DrawTransparent) MeshRenderer.UpdateUserData(mesh); if (GlobalSettings.Animate && mesh.RotateFactor != 0) mesh.Rotate += new Vector3((float)sinAnim * mesh.RotateFactor, 0, 0); MeshRenderer.AddMesh(mesh); } } if (GlobalSettings.RenderBenchmark && Editor.IsRendering) _compileTimer.Stop(); if (!pickView) MeshRenderer.Render(); else MeshRenderer.RenderWithoutTransparency(); }
private void ImportSkin(string fileName, string folderLocation, TreeNode parentNode) { string name = Path.GetFileNameWithoutExtension(fileName); while (File.Exists(folderLocation + name + ".png")) name += " (New)"; File.Copy(fileName, folderLocation + name + ".png"); var skin = new Skin(folderLocation + name + ".png"); if (parentNode != null) { if (!(parentNode is Skin)) parentNode.Nodes.Add(skin); else parentNode.GetParentCollection().Add(skin); } else treeView1.Nodes.Add(skin); skin.SetImages(); treeView1.SelectedNode = skin; }
private void PerformUpload() { if (!treeView1.Enabled) return; if (_lastSkin == null) return; if (_lastSkin.Width != 64 || _lastSkin.Height != 32) { MessageBox.Show(this, GetLanguageString("B_MSG_UPLOADRES")); return; } login.Username = GlobalSettings.LastUsername; login.Password = GlobalSettings.LastPassword; bool dialogRes = true; bool didShowDialog = false; if ((ModifierKeys & Keys.Shift) != 0 || !GlobalSettings.RememberMe || !GlobalSettings.AutoLogin) { login.Remember = GlobalSettings.RememberMe; login.AutoLogin = GlobalSettings.AutoLogin; dialogRes = login.ShowDialog() == DialogResult.OK; didShowDialog = true; } if (!dialogRes) return; _pleaseWaitForm = new PleaseWait(); _pleaseWaitForm.FormClosed += _pleaseWaitForm_FormClosed; _uploadThread = new Thread(UploadThread); var ret = new ErrorReturn(); _uploadThread.Start(new object[] {login.Username, login.Password, _lastSkin.File.FullName, ret}); _pleaseWaitForm.DialogResult = DialogResult.OK; _pleaseWaitForm.ShowDialog(); _uploadThread = null; bool didError = true; if (ret.ReportedError != null) { MessageBox.Show(this, GetLanguageString("B_MSG_UPLOADERROR") + "\r\n" + ret.ReportedError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (ret.Exception != null) { MessageBox.Show(this, GetLanguageString("B_MSG_UPLOADERROR") + "\r\n" + ret.Exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (_pleaseWaitForm.DialogResult != DialogResult.Abort) { MessageBox.Show(this, GetLanguageString("B_MSG_UPLOADSUCCESS"), "Woo!", MessageBoxButtons.OK, MessageBoxIcon.Information); GlobalSettings.LastSkin = _lastSkin.File.ToString(); if (_uploadedSkin != null) _uploadedSkin.IsLastSkin = false; _uploadedSkin = _lastSkin; _uploadedSkin.IsLastSkin = true; treeView1.Invalidate(); didError = false; } if (didShowDialog) { GlobalSettings.RememberMe = login.Remember; GlobalSettings.AutoLogin = login.AutoLogin; if (GlobalSettings.RememberMe == false) GlobalSettings.LastUsername = GlobalSettings.LastPassword = ""; else { GlobalSettings.LastUsername = login.Username; GlobalSettings.LastPassword = login.Password; } if (didError && GlobalSettings.AutoLogin) { GlobalSettings.AutoLogin = false; PerformUpload(); } } }
public void PerformNewSkin() { if (!treeView1.Enabled) return; string folderLocation; TreeNodeCollection collection; if (_rightClickedNode == null) _rightClickedNode = treeView1.SelectedNode; GetFolderLocationAndCollectionForNode(treeView1, _rightClickedNode, out folderLocation, out collection); if (collection == null || string.IsNullOrEmpty(folderLocation)) return; string newSkinName = "New Skin"; while (File.Exists(folderLocation + newSkinName + ".png")) newSkinName = newSkinName.Insert(0, GetLanguageString("C_NEW")); using (var bmp = new Bitmap(64, 32)) { using (Graphics g = Graphics.FromImage(bmp)) { g.Clear(Color.FromArgb(0, 255, 255, 255)); g.FillRectangle(System.Drawing.Brushes.White, 0, 0, 32, 32); g.FillRectangle(System.Drawing.Brushes.White, 32, 16, 32, 16); } bmp.SaveSafe(folderLocation + newSkinName + ".png"); } var newSkin = new Skin(folderLocation + newSkinName + ".png"); collection.Add(newSkin); newSkin.SetImages(); newSkin.EnsureVisible(); treeView1.SelectedNode = newSkin; treeView1.Invalidate(); PerformNameChange(); }
public bool RequestPreview(ColorGrabber pixels, Skin skin, int x, int y) { return(false); }
private void DrawPlayer2D(Texture tex, Skin skin, bool pickView) { if (!pickView && GlobalSettings.AlphaCheckerboard) { _alphaTex.Bind(); GL.Begin(BeginMode.Quads); GL.TexCoord2(0, 0); GL.Vertex2(0, 0); GL.TexCoord2(_currentViewport.Width / 16.0f, 0); GL.Vertex2(_currentViewport.Width, 0); GL.TexCoord2(_currentViewport.Width / 16.0f, _currentViewport.Height / 16.0f); GL.Vertex2(_currentViewport.Width, _currentViewport.Height); GL.TexCoord2(0, _currentViewport.Height / 16.0f); GL.Vertex2(0, _currentViewport.Height); GL.End(); } if (skin != null) tex.Bind(); GL.PushMatrix(); GL.Translate((_2DCamOffsetX), (_2DCamOffsetY), 0); GL.Translate((_currentViewport.Width / 2) + -_2DCamOffsetX, (_currentViewport.Height / 2) + -_2DCamOffsetY, 0); GL.Scale(_2DZoom, _2DZoom, 1); if (pickView) GL.Disable(EnableCap.Blend); else GL.Enable(EnableCap.Blend); GL.Translate((_2DCamOffsetX), (_2DCamOffsetY), 0); if (skin != null) { float w = skin.Width; float h = skin.Height; GL.Begin(BeginMode.Quads); GL.TexCoord2(0, 0); GL.Vertex2(-(CurrentModel.DefaultWidth / 2), -(CurrentModel.DefaultHeight / 2)); GL.TexCoord2(1, 0); GL.Vertex2((CurrentModel.DefaultWidth / 2), -(CurrentModel.DefaultHeight / 2)); GL.TexCoord2(1, 1); GL.Vertex2((CurrentModel.DefaultWidth / 2), (CurrentModel.DefaultHeight / 2)); GL.TexCoord2(0, 1); GL.Vertex2(-(CurrentModel.DefaultWidth / 2), (CurrentModel.DefaultHeight / 2)); GL.End(); } if (!pickView) { TextureGL.Unbind(); if (GlobalSettings.GridEnabled && GlobalSettings.DynamicOverlayGridColor.A > 0) { GL.Color4(GlobalSettings.DynamicOverlayGridColor); GL.PushMatrix(); GL.Translate(-(CurrentModel.DefaultWidth / 2), -(CurrentModel.DefaultHeight / 2), 0); GL.Begin(BeginMode.Lines); float wX = skin.Width / CurrentModel.DefaultWidth; float wY = skin.Height / CurrentModel.DefaultHeight; for (int i = 0; i <= skin.Width; ++i) { GL.Vertex2(i / wX, 0); GL.Vertex2(i / wX, skin.Height / wY); } for (int i = 0; i <= skin.Height; ++i) { GL.Vertex2(0, i / wY); GL.Vertex2(skin.Width / wX, i / wY); } GL.End(); GL.PopMatrix(); } if (GlobalSettings.TextureOverlay && skin != null) { if (_backgrounds[_selectedBackground] == _dynamicOverlay) { GL.PushMatrix(); GL.Translate(-(CurrentModel.DefaultWidth / 2), -(CurrentModel.DefaultHeight / 2), 0); float stub = (GlobalSettings.DynamicOverlayLineSize / _2DZoom); float one = (1.0f / _2DZoom); var done = new List<RectangleF>(); foreach (Mesh mesh in CurrentModel.Meshes) { foreach (Face face in mesh.Faces) { RectangleF toint = face.TexCoordsToFloat((int) CurrentModel.DefaultWidth, (int) CurrentModel.DefaultHeight); if (toint.Width == 0 || toint.Height == 0) continue; if (done.Contains(toint)) continue; done.Add(toint); GL.Color4(GlobalSettings.DynamicOverlayLineColor); GL.Begin(BeginMode.Quads); GL.Vertex2(toint.X, toint.Y); GL.Vertex2(toint.X + toint.Width, toint.Y); GL.Vertex2(toint.X + toint.Width, toint.Y + stub); GL.Vertex2(toint.X, toint.Y + stub); GL.Vertex2(toint.X, toint.Y); GL.Vertex2(toint.X + stub, toint.Y); GL.Vertex2(toint.X + stub, toint.Y + toint.Height); GL.Vertex2(toint.X, toint.Y + toint.Height); GL.Vertex2(toint.X + toint.Width + one, toint.Y); GL.Vertex2(toint.X + toint.Width + one, toint.Y + toint.Height); GL.Vertex2(toint.X + toint.Width + one - stub, toint.Y + toint.Height); GL.Vertex2(toint.X + toint.Width + one - stub, toint.Y); GL.Vertex2(toint.X, toint.Y + toint.Height + one); GL.Vertex2(toint.X, toint.Y + toint.Height + one - stub); GL.Vertex2(toint.X + toint.Width, toint.Y + toint.Height + one - stub); GL.Vertex2(toint.X + toint.Width, toint.Y + toint.Height + one); GL.End(); GL.Color4(Color.White); GL.Color4(GlobalSettings.DynamicOverlayTextColor); DrawStringWithinRectangle(_font, toint, mesh.Name + " " + Model.SideFromNormal(face.Normal), (6 * GlobalSettings.DynamicOverlayTextSize) / _2DZoom, (8.0f * GlobalSettings.DynamicOverlayTextSize) / _2DZoom); GL.Color4(Color.White); } } GL.PopMatrix(); } else { _backgrounds[_selectedBackground].GLImage.Bind(); GL.Begin(BeginMode.Quads); GL.TexCoord2(0, 0); GL.Vertex2(-(CurrentModel.DefaultWidth / 2), -(CurrentModel.DefaultHeight / 2)); GL.TexCoord2(1, 0); GL.Vertex2((CurrentModel.DefaultWidth / 2), -(CurrentModel.DefaultHeight / 2)); GL.TexCoord2(1, 1); GL.Vertex2((CurrentModel.DefaultWidth / 2), (CurrentModel.DefaultHeight / 2)); GL.TexCoord2(0, 1); GL.Vertex2(-(CurrentModel.DefaultWidth / 2), (CurrentModel.DefaultHeight / 2)); GL.End(); } } } GL.PopMatrix(); GL.Disable(EnableCap.Blend); }
public override bool RequestPreview(ColorGrabber pixels, Skin skin, int x, int y) { _noise = new Random(_seed); return base.RequestPreview(pixels, skin, x, y); }
private void PerformSaveSkin(Skin s) { Renderer.MakeCurrent(); s.CommitChanges((s == _lastSkin) ? GlobalDirtiness.CurrentSkin : s.GLImage, true); }
public List<int> GetIntersectingParts(Point p, Skin skin) { int mesh = 0; var parts = new List<int>(); foreach (Mesh m in Meshes) { foreach (Face f in m.Faces) { var bounds = new Bounds(new Point(9999, 9999), new Point(-9999, -9999)); foreach (Vector2 c in f.TexCoords) { var coord = new Vector2(c.X * skin.Width, c.Y * skin.Height); bounds.AddPoint(new Point((int)coord.X, (int)coord.Y)); } if (bounds.ToRectangle().Contains(p)) { parts.Add(mesh); break; } } mesh++; } return parts; }
private void RecursiveDeleteSkins(TreeNode node) { foreach (TreeNode sub in node.Nodes) { if (!(sub is Skin)) RecursiveDeleteSkins(sub); else { var skin = (Skin) sub; if (_lastSkin == skin) _lastSkin = null; skin.Dispose(); } } Directory.Delete(GetFolderForNode(node), true); }
// P: polygon support required? used bounds 'n stuff but, you know... public Rectangle GetTextureFaceBounds(Point p, Skin skin) { foreach (Mesh m in Meshes) { foreach (Face f in m.Faces) { var bounds = new Bounds(new Point(9999, 9999), new Point(-9999, -9999)); foreach (Vector2 c in f.TexCoords) { var coord = new Vector2(c.X * skin.Width, c.Y * skin.Height); bounds.AddPoint(new Point((int)coord.X, (int)coord.Y)); } if (bounds.ToRectangle().Contains(p)) return bounds.ToRectangle(); } } return new Rectangle(); }
public void FinishedLoadingSkins(List<Skin> skins, TreeNode selected) { treeView1.EndUpdate(); treeView1.SelectedNode = selected; toolStrip2.Enabled = true; treeView1.Enabled = true; foreach (var s in skins) { if (s.File.ToString() == GlobalSettings.LastSkin) { s.IsLastSkin = true; _uploadedSkin = s; break; } } }
protected override void OnDragDrop(DragEventArgs e) { dragDropOverFolder = 0; dragTimer.Stop(); if (e.Data.GetDataPresent(DataFormats.FileDrop) && !e.Data.GetDataPresent("MCSkin3D.Skin")) { e.Effect = e.AllowedEffect & DragDropEffects.Copy; var files = (string[]) e.Data.GetData(DataFormats.FileDrop); string folderLocation = Editor.GetFolderLocationForNode(_overNode); if (string.IsNullOrEmpty(folderLocation)) return; foreach (string f in files) { string name = Path.GetFileNameWithoutExtension(f); while (File.Exists(folderLocation + name + ".png")) name += " (" + Editor.GetLanguageString("C_NEW") + ")"; File.Copy(f, folderLocation + name + ".png"); var skin = new Skin(folderLocation + name + ".png"); if (_overNode != null) { if (!(_overNode is Skin)) _overNode.Nodes.Add(skin); else { if (_overNode.Parent == null) _overNode.TreeView.Nodes.Add(skin); else _overNode.Parent.Nodes.Add(skin); } } else Nodes.Add(skin); skin.SetImages(); SelectedNode = skin; } } else { if (!DropValid(SelectedNode, _overNode)) e.Effect = DragDropEffects.None; else { TreeNode selNode = SelectedNode; if (e.Effect == DragDropEffects.Move) MoveNode(SelectedNode, _overNode); SelectedNode = selNode; } } //DropTargetHelper.Drop(e.Data, new Point(e.X, e.Y), e.Effect); _dragNode = null; _overNode = null; }
public void PerformImportFromSite() { if (!treeView1.Enabled) return; string accountName = _importFromSite.Show(); if (string.IsNullOrEmpty(accountName)) return; string url = "http://s3.amazonaws.com/MinecraftSkins/" + accountName + ".png"; string folderLocation; TreeNodeCollection collection; if (_rightClickedNode == null) _rightClickedNode = treeView1.SelectedNode; GetFolderLocationAndCollectionForNode(treeView1, _rightClickedNode, out folderLocation, out collection); string newSkinName = accountName; while (File.Exists(folderLocation + newSkinName + ".png")) newSkinName += " - New"; try { byte[] pngData = WebHelpers.DownloadFile(url); using (FileStream file = File.Create(folderLocation + newSkinName + ".png")) file.Write(pngData, 0, pngData.Length); var skin = new Skin(folderLocation + newSkinName + ".png"); collection.Add(skin); skin.SetImages(); treeView1.Invalidate(); } catch (Exception ex) { MessageBox.Show(this, GetLanguageString("M_SKINERROR") + "\r\n" + ex); return; } }
public override bool MouseMoveOnSkin(ColorGrabber pixels, Skin skin, int x, int y) { return(MouseMoveOnSkin(pixels, skin, x, y, GlobalSettings.DarkenLightenIncremental)); }