public Bitmap GetImage(TextureItem item) { lock (PlaceholderImage) { return new Bitmap(PlaceholderImage); } }
public Bitmap GetImage(TextureItem item) { lock (PlaceholderImage) { return(new Bitmap(PlaceholderImage)); } }
public void AddTexture(TextureItem item) { if (Items.ContainsKey(item.Name.ToLowerInvariant())) { return; } Items.Add(item.Name.ToLowerInvariant(), item); }
public Bitmap GetImage(TextureItem item) { foreach (var ss in _streams) { if (ss.HasImage(item)) return ss.GetImage(item); } return null; }
public static void LoadTextureItem(TextureItem item) { if (item == null || item.Package == null) { return; } item.Package.Provider.LoadTextures(new[] { item }); }
public Bitmap GetImage(TextureItem item) { var stream = _streams.First(x => PackageHasTexture(x, item.Reference)); var bmp = Pk3Provider.OpenImage(stream, item.Reference); bool hasTransparency; return(PostProcessBitmap(item.Package.PackageRelativePath, item.Name.ToLowerInvariant(), bmp, out hasTransparency)); }
public void LoadTexture(TextureItem item) { if (!_loadedItems.ContainsKey(item.Name.ToLowerInvariant())) { Provider.LoadTexture(item); _loadedItems.Add(item.Name.ToLowerInvariant(), item); } }
public Bitmap GetImage(TextureItem item) { using (var stream = _streams.First(x => x.HasFile(item.Name.ToLowerInvariant())).OpenFile(item.Name.ToLowerInvariant())) { bool hasTransparency; return(PostProcessBitmap(item.Package.PackageRelativePath, item.Name.ToLowerInvariant(), new Bitmap(stream), out hasTransparency)); } }
public Bitmap GetImage(TextureItem item) { foreach (var ss in _streams) { if (ss.HasImage(item)) { return(ss.GetImage(item)); } } return(null); }
public Bitmap GetImage(TextureItem item) { foreach (var root in item.Package.PackageRoot.Split(';')) { var file = Path.Combine(root, item.Name); if (File.Exists(file)) { return(Parse(file)); } } return(null); }
private static void SetSprite(Entity entity, TextureItem tex) { entity.MetaData.Set(SpriteMetaKey, tex.Name); var bb = new Coordinate(tex.Width, tex.Width, tex.Height); // Don't set the bounding box if the sprite comes from the iconsprite gamedata if (entity.GameData == null || !entity.GameData.Behaviours.Any(x => String.Equals(x.Name, "iconsprite", StringComparison.CurrentCultureIgnoreCase))) { entity.MetaData.Set(SpriteBoundingBoxMetaKey, new Box(-bb / 2, bb / 2)); entity.MetaData.Set("RotateBoundingBox", false); // todo rotations entity.UpdateBoundingBox(); } }
public TextureCollection(List <TexturePackage> packages) { _packages = packages; _items = new Dictionary <string, TextureItem>(); foreach (var item in packages.SelectMany(x => x.Items)) { var k = item.Key.ToLowerInvariant(); if (!_items.ContainsKey(k)) { _items.Add(k, item.Value); } } _recentTextures = new List <TextureItem>(); SelectedTexture = GetDefaultSelection(); }
private static void SetSprite(Entity entity, TextureItem tex) { entity.MetaData.Set(SpriteMetaKey, tex.Name); var scale = 1m; if (entity.GameData != null && entity.GameData.Properties.Any(x => String.Equals(x.Name, "scale", StringComparison.CurrentCultureIgnoreCase))) { var scaleStr = entity.GetEntityData().GetPropertyValue("scale"); if (!Decimal.TryParse(scaleStr, out scale)) scale = 1; if (scale <= 0.1m) scale = 1; } var bb = new Coordinate(tex.Width, tex.Width, tex.Height) * scale; // Don't set the bounding box if the sprite comes from the iconsprite gamedata if (entity.GameData == null || !entity.GameData.Behaviours.Any(x => String.Equals(x.Name, "iconsprite", StringComparison.CurrentCultureIgnoreCase))) { entity.MetaData.Set(SpriteBoundingBoxMetaKey, new Box(-bb / 2, bb / 2)); entity.MetaData.Set("RotateBoundingBox", false); // todo rotations entity.UpdateBoundingBox(); } }
public Bitmap GetImage(TextureItem item) { var root = _roots.FirstOrDefault(x => x.HasFile(item.PrimarySubItem.Name)); if (root == null) { return(null); } var stream = root.OpenFile(item.PrimarySubItem.Name); if (stream == null) { return(null); } using (stream) { return(Vtf.VtfProvider.GetImage(stream, _maxWidth, _maxHeight)); } }
private TexturePackage CreatePackage(string package) { try { var fi = new FileInfo(package); if (!fi.Exists) { return(null); } var tp = new TexturePackage(package, Path.GetFileNameWithoutExtension(package), this); if (LoadFromCache(tp)) { return(tp); } var pack = _roots.Values.FirstOrDefault(x => x.Package.PackageFile.FullName == fi.FullName); if (pack == null) { _roots.Add(tp, pack = new Pk3Stream(new ZipPackage(fi))); } foreach (var file in pack.Package.SearchFiles("textures", @"\.(jpg|png|tga)$", true)) { var size = GetImageSize(pack.StreamSource, file); var fname = file.Substring("textures/".Length); fname = fname.Substring(0, fname.Length - 4); var ti = new TextureItem(tp, fname, GetFlags(fname), size.Width, size.Height) { Reference = file }; tp.AddTexture(ti); } SaveToCache(tp); return(tp); } catch { return(null); } }
public void AddTexture(TextureItem item) { if (Items.ContainsKey(item.Name.ToLowerInvariant())) return; Items.Add(item.Name.ToLowerInvariant(), item); }
private void TextureChanged(object sender, TextureItem texture) { Mediator.Publish(EditorMediator.TextureSelected, texture); }
private void TexturesListTextureSelected(object sender, TextureItem item) { OnTextureApply(item); }
protected virtual void OnTextureApply(TextureItem texture) { if (TextureApply != null) { TextureApply(this, texture); } }
private void TextureSelected(TextureItem selection) { var dis = TextureSelectionPictureBox.Image; TextureSelectionPictureBox.Image = null; if (dis != null) dis.Dispose(); TextureSizeLabel.Text = ""; if (selection == null || DocumentManager.CurrentDocument == null) return; TextureComboBox.SetSelectedTexture(selection); using (var tp = DocumentManager.CurrentDocument.TextureCollection.GetStreamSource()) { var bmp = tp.GetImage(selection); if (bmp.Width > TextureSelectionPictureBox.Width || bmp.Height > TextureSelectionPictureBox.Height) TextureSelectionPictureBox.SizeMode = PictureBoxSizeMode.Zoom; else TextureSelectionPictureBox.SizeMode = PictureBoxSizeMode.CenterImage; TextureSelectionPictureBox.Image = bmp; } TextureSizeLabel.Text = string.Format("{0} x {1}", selection.Width, selection.Height); }
public bool HasImage(TextureItem item) { return(item.Flags.HasFlag(TextureFlags.Missing)); }
public bool HasImage(TextureItem item) { return(_streams.Any(x => x.HasFile(item.Name.ToLowerInvariant()))); }
public bool HasImage(TextureItem item) { return(_roots.Any(x => x.HasFile(item.PrimarySubItem.Name))); }
public bool HasImage(TextureItem item) { return _roots.Any(x => x.HasFile(item.PrimarySubItem.Name)); }
public Bitmap GetImage(TextureItem item) { var root = _roots.FirstOrDefault(x => x.HasFile(item.PrimarySubItem.Name)); if (root == null) return null; var stream = root.OpenFile(item.PrimarySubItem.Name); if (stream == null) return null; using (stream) { return Vtf.VtfProvider.GetImage(stream, _maxWidth, _maxHeight); } }
public bool HasImage(TextureItem item) { return item.Flags.HasFlag(TextureFlags.Missing); }
public Bitmap GetImage(TextureItem item) { var file = item.Package.PackageFile; var child = file.GetFile(item.Name); if (child != null && child.Exists) { return Parse(child); } return null; }
public void TextureSelected(TextureItem selection) { _document.TextureCollection.SelectedTexture = selection; }
private void OwnerDrawItem(System.Drawing.Graphics g, Image bmp, TextureItem ti, Rectangle bounds, Color textColour, Font font, bool drawBorder) { if (bmp == null) return; var lineHeight = (int) Font.GetHeight(); var imageSize = bounds.Height - lineHeight - 9; var iw = bmp.Width; var ih = bmp.Height; if (iw > imageSize && iw >= ih) { ih = (int)Math.Floor(imageSize * (ih / (float)iw)); iw = imageSize; } else if (ih > imageSize) { iw = (int)Math.Floor(imageSize * (iw / (float)ih)); ih = imageSize; } using (var brush = new SolidBrush(textColour)) { g.DrawString(ti.Name, font, brush, bounds.X + 3, bounds.Y + 3); g.DrawString(ti.Width + " x " + ti.Height, font, brush, bounds.X + 6 + imageSize, bounds.Y + lineHeight + 6); } g.DrawImage(bmp, bounds.X + 3, bounds.Y + lineHeight + 6, iw, ih); if (drawBorder) { using (var pen = new Pen(ForeColor)) { var liney = bounds.Y + bounds.Height - 1; g.DrawLine(pen, bounds.X, liney, bounds.X + bounds.Width, liney); } } }
public bool HasImage(TextureItem item) { return(_packages.Any(x => x.Items.ContainsValue(item))); }
public void SetSelectedTexture(TextureItem selection) { SetHistory(selection); }
public void SelectTexture(TextureItem item) { if (item == null) { SelectedTexturesList.SetSelectedTextures(new TextureItem[0]); return; } UpdateRecentTextureList(); // If the texture is in the list of selected faces, select the texture in that list var sl = SelectedTexturesList.GetTextures(); if (sl.Contains(item)) { SelectedTexturesList.SetSelectedTextures(new[] { item }); SelectedTexturesList.ScrollToItem(item); } else if (RecentTexturesList.GetTextures().Contains(item)) { // Otherwise, select the texture in the recent list RecentTexturesList.SetSelectedTextures(new[] {item}); RecentTexturesList.ScrollToItem(item); } RecentTexturesList.Refresh(); SelectedTexturesList.Refresh(); }
public void LoadTextureItem(TextureItem item) { item.Package.LoadTexture(item); }
protected virtual void OnTextureChanged(TextureItem texture) { if (TextureChanged != null) { TextureChanged(this, texture); } }
public bool HasImage(TextureItem item) { return(_streams.Any(x => PackageHasTexture(x, item.Reference))); }
private TextureComboBoxItem GetTexture(TextureItem item, bool isHistory) { return new TextureComboBoxItem { DrawBorder = false, IsHistory = isHistory, Item = item }; }
private void TextureSelected(TextureItem texture) { _form.SelectTexture(texture); }
private void SetHistory(TextureItem ti) { if (ti == null) return; var rem = FindItem(ti.Name, true) ?? GetTexture(ti.Name, true); Items.Remove(rem); Items.Insert(0, rem); FixHistoryBorder(); SelectedItem = rem; }
public Bitmap GetImage(TextureItem item) { var root = _packages[item.Package.PackageFile]; var search = root.Item2.GetItemByName(item.Name + ".bmp", HLLib.FindType.Files); if (search.Exists) { using (var stream = root.Item1.CreateStream(search)) { var bmp = new Bitmap(new MemoryStream(stream.ReadAll())); bool hasTransparency; return PostProcessBitmap(item.Name, bmp, out hasTransparency); } } return null; }
private void TextureSelected(object sender, TextureItem item) { SelectedTexture = item; Close(); }
public override void LoadTexture(TextureItem item) { LoadTextures(new[] {item}); }
public void SelectTexture(TextureItem item) { if (_freeze) return; if (item == null) { SelectedTexturesList.SetSelectedTextures(new TextureItem[0]); return; } UpdateRecentTextureList(); // If the texture is in the list of selected faces, select the texture in that list var sl = SelectedTexturesList.GetTextures(); if (sl.Any(x => String.Equals(x.Name, item.Name, StringComparison.InvariantCultureIgnoreCase))) { SelectedTexturesList.SetSelectedTextures(new[] { item }); SelectedTexturesList.ScrollToItem(item); } else if (RecentTexturesList.GetTextures().Contains(item)) { // Otherwise, select the texture in the recent list RecentTexturesList.SetSelectedTextures(new[] {item}); RecentTexturesList.ScrollToItem(item); } RecentTexturesList.Refresh(); SelectedTexturesList.Refresh(); }
public bool HasImage(TextureItem item) { return(_streams.Any(x => x.HasImage(item))); }
public bool HasImage(TextureItem item) { return _texturePackages.Any(x => x.Items.ContainsValue(item)); }
public abstract void LoadTexture(TextureItem item);
public static void LoadTextureItem(TextureItem item) { item.Package.Provider.LoadTextures(new[] { item }); }
public static void LoadTextureItem(TextureItem item) { if (item == null || item.Package == null) return; item.Package.Provider.LoadTextures(new[] { item }); }