Beispiel #1
0
 public Loon.Core.Geom.Point.Point2i Draw(string name, float x, float y, float w, float h,
                                          float rotation, LColor color)
 {
     this.Pack();
     if (GLEx.Self != null)
     {
         PackEntry entry = GetEntry(name);
         if (entry == null)
         {
             return(null);
         }
         if (texture.IsBatch())
         {
             texture.Draw(x, y, w, h, entry.bounds.left, entry.bounds.top,
                          entry.bounds.right, entry.bounds.bottom, rotation,
                          color);
         }
         else
         {
             GLEx.Self.DrawTexture(texture, x, y, w, h, entry.bounds.left,
                                   entry.bounds.top, entry.bounds.right,
                                   entry.bounds.bottom, rotation, color);
         }
         blittedSize.Set(entry.bounds.Width(), entry.bounds.Height());
     }
     return(blittedSize);
 }
Beispiel #2
0
        public override string ToString()
        {
            StringBuilder sbr = new StringBuilder(1000);

            sbr.Append("<?xml version=\"1.0\" standalone=\"yes\" ?>\n");
            if (colorMask != null)
            {
                sbr.Append("<Pack file=\"" + fileName + "\" mask=\""
                           + colorMask.R + "," + colorMask.G + ","
                           + colorMask.B + "\">\n");
            }
            else
            {
                sbr.Append("<Pack file=\"" + fileName + "\">\n");
            }
            for (int i = 0; i < temps.Size(); i++)
            {
                PackEntry e = (PackEntry)temps.Get(i);
                if (e != null && e.bounds != null)
                {
                    sbr.Append("<block id=\"" + i + "\" name=\"" + e.fileName
                               + "\" left=\"" + e.bounds.left + "\" top=\""
                               + e.bounds.top + "\" right=\"" + e.bounds.right
                               + "\" bottom=\"" + e.bounds.bottom + "\"/>\n");
                }
            }
            sbr.Append("</Pack>");
            return(sbr.ToString());
        }
Beispiel #3
0
 public Loon.Core.Geom.Point.Point2i Draw(string name, float dx1, float dy1, float dx2,
                                          float dy2, float sx1, float sy1, float sx2, float sy2,
                                          float rotation, LColor color)
 {
     this.Pack();
     if (GLEx.Self != null)
     {
         PackEntry entry = GetEntry(name);
         if (entry == null)
         {
             return(null);
         }
         if (texture.IsBatch())
         {
             texture.Draw(dx1, dy1, dx2, dy2, sx1 + entry.bounds.left, sy1
                          + entry.bounds.top, sx2 + entry.bounds.left, sy2
                          + entry.bounds.top, rotation, color);
         }
         else
         {
             GLEx.Self.DrawTexture(texture, dx1, dy1, dx2, dy2, sx1
                                   + entry.bounds.left, sy1 + entry.bounds.top, sx2
                                   + entry.bounds.left, sy2 + entry.bounds.top, rotation,
                                   color);
         }
         blittedSize.Set(entry.bounds.Width(), entry.bounds.Height());
     }
     return(blittedSize);
 }
Beispiel #4
0
        public void ShowRenameSelectedNodeDialog()
        {
            if (!_parentRef.CanWriteCurrentPack)
            {
                MessageBox.Show("Unable to edit current pack as it is read only");
                return;
            }

            PackEntry entry = GetSelectedNodeContent();

            if (entry == null)
            {
                MessageBox.Show("Can only rename Pack Entries");
                return;
            }

            var inputDialog = new InputBox()
            {
                Text = "Rename file:"
            };

            inputDialog.StartPosition = FormStartPosition.CenterParent;
            inputDialog.ShowDialog(this);

            if (inputDialog.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                string newName = inputDialog.Input;
                if (versionedRegex.IsMatch(newName))
                {
                    newName = versionedRegex.Match(newName).Groups[1].Value;
                }

                entry.Name = newName;
            }
        }
Beispiel #5
0
        }         //装备所在的槽, PackEntry的Index 描述这个信息, 后续可能不需要这个数据,因为装备的槽唯一


        public EquipData(PackInfo pkinfo)
        {
            info     = pkinfo;
            entry    = info.PackEntry;
            itemData = Util.GetItemData(1, pkinfo.PackEntry.BaseId);
            KBEngine.Dbg.Assert(itemData == null, "EquipData::initError " + pkinfo.PackEntry.BaseId);
        }
Beispiel #6
0
        public Node Create(PackEntry packEntry, IPackEntryEventHandler eventHandler, Node node = null)
        {
            var newParent = CreateNode(packEntry, null);

            if (node != null)
            {
                node.Nodes.Add(newParent);
            }
            else
            {
                node = newParent;
            }

            var dir = packEntry as VirtualDirectory;

            if (dir != null)
            {
                foreach (var subdirs in dir.Subdirectories.Values)
                {
                    Create(subdirs, eventHandler, newParent);
                }

                foreach (var file in dir.Files.Values)
                {
                    var newFile = CreateNode(file, eventHandler);
                    newParent.Nodes.Add(newFile);
                }
            }

            return(newParent);
        }
Beispiel #7
0
        public Node CreateNode(PackEntry packEntry, IPackEntryEventHandler eventHandler)
        {
            var newNode = new TreeNode(packEntry.Name);

            newNode.Tag = packEntry;

            var dir = packEntry as VirtualDirectory;

            if (dir != null)
            {
                if (eventHandler != null)
                {
                    dir.DirectoryAdded += eventHandler.Dir_FileAdded;
                    dir.FileAdded      += eventHandler.Dir_FileAdded;
                    dir.FileRemoved    += eventHandler.Dir_FileRemoved;
                }
                newNode.Image = _treeViewIconCreator.Folder;
            }
            else
            {
                newNode.Image = _treeViewIconCreator.DefaultFile;
            }

            return(newNode);
        }
Beispiel #8
0
 public PackEntryNode(PackEntry entry)
     : base(entry.Name)
 {
     Tag = entry;
     entry.ModifiedEvent += delegate(PackEntry p) { ChangeColor(); };
     entry.RenameEvent   += (e, name) => { renamed = true; ChangeColor(); };
     ChangeColor();
 }
Beispiel #9
0
        public RectBox GetImageRect(int id)
        {
            PackEntry entry = GetEntry(id);

            if (entry == null)
            {
                return(new RectBox(0, 0, 0, 0));
            }
            return(new RectBox(0, 0, entry.width, entry.height));
        }
Beispiel #10
0
        public int[] GetImageRectArray(int id)
        {
            PackEntry entry = GetEntry(id);

            if (entry == null)
            {
                return(new int[] { 0, 0 });
            }
            return(new int[] { entry.width, entry.height });
        }
Beispiel #11
0
        public Loon.Core.Geom.RectBox.Rect2i GetImageSize(int id)
        {
            PackEntry entry = GetEntry(id);

            if (entry == null)
            {
                return(null);
            }
            return(entry.bounds);
        }
Beispiel #12
0
        public Loon.Core.Geom.RectBox.Rect2i GetImageSize(string name)
        {
            PackEntry entry = GetEntry(name);

            if (entry == null)
            {
                return(null);
            }
            return(entry.bounds);
        }
Beispiel #13
0
        public BackpackData(PackEntry e)
        {
            var pinfo = PackInfo.CreateBuilder();

            pinfo.PackEntry = e;
            packInfo        = pinfo.Build();
            entry           = e;
            //num = entry.Count;
            itemData = Util.GetItemData(e.GoodsType, baseId);
        }
Beispiel #14
0
            internal Node Insert(PackEntry entry)
            {
                if (IsLeaf())
                {
                    if (this.entry != null)
                    {
                        return(null);
                    }
                    int width  = entry.image.GetWidth();
                    int height = entry.image.GetHeight();

                    if ((width > bounds.Width()) || (height > bounds.Height()))
                    {
                        return(null);
                    }

                    if ((width == bounds.Width()) && (height == bounds.Height()))
                    {
                        this.entry = entry;
                        this.entry.bounds.Set(this.bounds);
                        return(this);
                    }

                    child[0] = new Node();
                    child[1] = new Node();

                    int dw = bounds.Width() - width;
                    int dh = bounds.Height() - height;

                    if (dw > dh)
                    {
                        child[0].bounds.Set(bounds.left, bounds.top, bounds.left
                                            + width, bounds.bottom);
                        child[1].bounds.Set(bounds.left + width, bounds.top,
                                            bounds.right, bounds.bottom);
                    }
                    else
                    {
                        child[0].bounds.Set(bounds.left, bounds.top, bounds.right,
                                            bounds.top + height);
                        child[1].bounds.Set(bounds.left, bounds.top + height,
                                            bounds.right, bounds.bottom);
                    }
                    return(child[0].Insert(entry));
                }
                else
                {
                    Node newNode = child[0].Insert(entry);
                    if (newNode != null)
                    {
                        return(newNode);
                    }
                    return(child[1].Insert(entry));
                }
            }
Beispiel #15
0
        public static void CreateCharacter(KBEngine.Packet packet)
        {
            var inpb = packet.protoBody as CGCreateCharacter;
            var au   = GCCreateCharacter.CreateBuilder();
            var role = RolesInfo.CreateBuilder();

            role.Name     = inpb.PlayerName;
            role.PlayerId = 100;
            //playerId++;
            role.Level = 1;
            role.Job   = inpb.Job;

            var msg = role.Build();

            ServerData.Instance.playerInfo.Roles = RolesInfo.CreateBuilder(msg).Build();

            var dress = new int[]
            {
                97, 68, 69, 70, 71, 72,
            };
            int id    = 1;
            var pinfo = ServerData.Instance.playerInfo;

            foreach (var d in dress)
            {
                var pkinfo  = PackInfo.CreateBuilder();
                var pkEntry = PackEntry.CreateBuilder();
                pkEntry.Id        = id++;
                pkEntry.BaseId    = d;
                pkEntry.GoodsType = 1;
                pkEntry.Level     = 1;
                pkinfo.PackEntry  = pkEntry.Build();
                pinfo.AddDressInfo(pkinfo);
            }

            var cinfo = GCCopyInfo.CreateBuilder();
            var cin   = CopyInfo.CreateBuilder();

            cin.Id     = 209;
            cin.IsPass = true;
            cinfo.AddCopyInfo(cin);
            var msg2 = cinfo.Build();

            pinfo.CopyInfos = msg2;

            au.AddRolesInfos(msg);
            ServerBundle.SendImmediate(au, packet.flowId);

            //投掷 跳跃
            pinfo.Roles.Level = 10;
            AddSkillPoint(10);
            LevelUpSkill(3);
            LevelUpSkill(4);
        }
Beispiel #16
0
        public LTexture GetTexture(int id)
        {
            this.Pack();
            PackEntry entry = GetEntry(id);

            if (entry == null)
            {
                return(null);
            }
            return(texture.GetSubTexture(entry.bounds.left, entry.bounds.top,
                                         entry.bounds.right, entry.bounds.bottom));
        }
Beispiel #17
0
        public void DrawOnlyBatch(string name, float x, float y, LColor[] c)
        {
            this.Pack();
            PackEntry entry = GetEntry(name);

            if (texture.IsBatch())
            {
                texture.Draw(x, y, entry.bounds.Width(), entry.bounds.Height(),
                             entry.bounds.left, entry.bounds.top, entry.bounds.right,
                             entry.bounds.bottom, c);
            }
        }
Beispiel #18
0
        public void Dir_FileAdded(PackEntry entry)
        {
            var parentNode = FindTreeNodeByPackEntry(_treeModel.Nodes, entry.Parent);

            if (parentNode == null)
            {
                return;
            }
            var newNode = _treeViewModelCreator.CreateNode(entry, this);

            parentNode.Nodes.Add(newNode);
        }
Beispiel #19
0
 public void Dir_FileRemoved(PackEntry entry)
 {
     foreach (var node in _treeModel.Nodes)
     {
         if (node.Tag == entry)
         {
             treeViewAdv1.BeginUpdate();
             _treeModel.Nodes.Remove(node);
             treeViewAdv1.EndUpdate();
             return;
         }
     }
 }
Beispiel #20
0
                LocFile getlocfile(VirtualDirectory locdb, string name)
                {
                    PackEntry  fileEntry   = locdb.GetEntry(name);
                    PackedFile encodedFile = null;

                    if (fileEntry == null)
                    {
                        throw new KeyNotFoundException(name + " not found in localisation database");
                    }
                    encodedFile = (PackedFile)fileEntry;
                    LocFile decodedFile = LocCodec.Instance.Decode(encodedFile.Data);

                    return(decodedFile);
                }
Beispiel #21
0
 /*
  * 从服务器初始化背包数据
  */
 public BackpackData(PackInfo pinfo)
 {
     if (pinfo != null)
     {
         packInfo = pinfo;
         entry    = packInfo.PackEntry;
         Log.Important("Init ItemData is " + pinfo.PackEntry.GoodsType + " num " + entry.Count);
         itemData = Util.GetItemData(pinfo.PackEntry.GoodsType, baseId);
         if (itemData == null)
         {
             Debug.LogError("BackpackData:: Init Error " + baseId);
         }
     }
 }
Beispiel #22
0
        public LTextureRegion CreateTextureRegion(int id)
        {
            this.Pack();
            PackEntry entry = GetEntry(id);

            if (entry == null)
            {
                return(null);
            }
            LTextureRegion region = new LTextureRegion(texture, entry.bounds.left,
                                                       entry.bounds.top, entry.bounds.right, entry.bounds.bottom);

            return(region);
        }
Beispiel #23
0
        public SpriteRegion CreateSpriteRegion(string name)
        {
            this.Pack();
            PackEntry entry = GetEntry(name);

            if (entry == null)
            {
                return(null);
            }
            SpriteRegion region = new SpriteRegion(texture, entry.bounds.left,
                                                   entry.bounds.top, entry.bounds.right, entry.bounds.bottom);

            return(region);
        }
Beispiel #24
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (obj.GetType() != typeof(PackEntry))
            {
                return(false);
            }

            PackEntry other = (PackEntry)obj;

            return(FileName == other.FileName && Offset == other.Offset && Size == other.Size);
        }
Beispiel #25
0
        public void DrawOnlyBatch(int id, float x, float y, LColor[] c)
        {
            this.Pack();
            PackEntry entry = GetEntry(id);

            if (entry == null)
            {
                return;
            }
            if (texture.IsBatch())
            {
                texture.Draw(x, y, entry.bounds.Width(), entry.bounds.Height(),
                             entry.bounds.left, entry.bounds.top, entry.bounds.right,
                             entry.bounds.bottom, c);
            }
        }
Beispiel #26
0
        private void RemoveEntry(PackEntry entry)
        {
            TreeNode remove = null;

            foreach (TreeNode node in Nodes)
            {
                if (node.Tag == entry)
                {
                    remove = node;
                    break;
                }
            }
            if (remove != null)
            {
                Nodes.Remove(remove);
            }
        }
Beispiel #27
0
        public LPixmap GetImage(string name)
        {
            PackEntry entry = GetEntry(name);

            if (entry != null)
            {
                if (entry.image != null && !entry.image.IsClose())
                {
                    return(entry.image);
                }
                else if (entry.fileName != null)
                {
                    return(new LPixmap(entry.fileName));
                }
            }
            return(null);
        }
Beispiel #28
0
        public LImage GetImage(string name)
        {
            PackEntry entry = GetEntry(name);

            if (entry != null)
            {
                if (entry.image != null && !entry.image.IsClose())
                {
                    return(entry.image);
                }
                else if (entry.fileName != null)
                {
                    return(LImage.CreateImage(entry.fileName));
                }
            }
            return(null);
        }
Beispiel #29
0
 private void Free()
 {
     if (temps != null)
     {
         for (int i = 0; i < temps.Size(); i++)
         {
             PackEntry e = (PackEntry)temps.Get(i);
             if (e != null)
             {
                 if (e.image != null)
                 {
                     e.image.Dispose();
                     e.image = null;
                 }
             }
         }
     }
 }
Beispiel #30
0
        Node FindTreeNodeByPackEntry(Collection <Node> searchSpace, PackEntry target)
        {
            foreach (var node in searchSpace)
            {
                var data = node.Tag as PackEntry;
                if (data == target)
                {
                    return(node);
                }

                var res = FindTreeNodeByPackEntry(node.Nodes, target);
                if (res != null)
                {
                    return(res);
                }
            }

            return(null);
        }
Beispiel #31
0
            internal Node Insert(PackEntry entry)
            {
				if (IsLeaf()) {
					if (this.entry != null) {
						return null;
					}
					int width = entry.image.GetWidth();
					int height = entry.image.GetHeight();
	
					if ((width > bounds.Width()) || (height > bounds.Height())) {
						return null;
					}
	
					if ((width == bounds.Width()) && (height == bounds.Height())) {
						this.entry = entry;
						this.entry.bounds.Set(this.bounds);
						return this;
					}
	
					child[0] = new Node();
					child[1] = new Node();
	
					int dw = bounds.Width() - width;
					int dh = bounds.Height() - height;
	
					if (dw > dh) {
						child[0].bounds.Set(bounds.left, bounds.top, bounds.left
								+ width, bounds.bottom);
						child[1].bounds.Set(bounds.left + width, bounds.top,
								bounds.right, bounds.bottom);
					} else {
						child[0].bounds.Set(bounds.left, bounds.top, bounds.right,
								bounds.top + height);
						child[1].bounds.Set(bounds.left, bounds.top + height,
								bounds.right, bounds.bottom);
					}
					return child[0].Insert(entry);
				} else {
					Node newNode = child[0].Insert(entry);
					if (newNode != null) {
						return newNode;
					}
					return child[1].Insert(entry);
				}
			}
Beispiel #32
0
		private void Set(XMLElement Pack) {
			this.fileName = Pack.GetAttribute("file", null);
			this.name = Pack.GetAttribute("name", fileName);
			int r = Pack.GetIntAttribute("r", -1);
			int g = Pack.GetIntAttribute("g", -1);
			int b = Pack.GetIntAttribute("b", -1);
			int a = Pack.GetIntAttribute("a", -1);
			if (r != -1 && g != -1 && b != -1 && a != -1) {
				colorMask = new LColor(r, g, b, a);
			}
			if (fileName != null) {
				List<XMLElement> blocks = Pack.List("block");
				foreach (XMLElement e  in  blocks) {
					PackEntry entry = new PackEntry(null);
					int id = e.GetIntAttribute("id", count);
					entry.id = id;
					entry.fileName = e.GetAttribute("name", null);
					entry.bounds.left = e.GetIntAttribute("left", 0);
					entry.bounds.top = e.GetIntAttribute("top", 0);
					entry.bounds.right = e.GetIntAttribute("right", 0);
					entry.bounds.bottom = e.GetIntAttribute("bottom", 0);
					if (entry.fileName != null) {
						temps.Put(entry.fileName, entry);
					} else {
						temps.Put(Convert.ToString(id), entry);
					}
					count++;
				}
				this.packing = false;
				this.packed = true;
			}
			this.useAlpha = true;
		}
Beispiel #33
0
        static List<PackEntry> ParsePack(EndianBinaryReader Reader, Section PackSection)
        {
            List<PackEntry> Output = new List<PackEntry>();

            for (int i = 0; i < PackSection.PointerCount; i++)
            {
                PackEntry Entry = new PackEntry();

                Reader.BaseStream.Seek(PackSection.PackPointersOffset + i * 4, SeekOrigin.Begin);
                Entry.Offset = Reader.ReadUInt32() + PackSection.BaseOffset;

                Reader.BaseStream.Seek(PackSection.PackLengthsOffset + i * 4, SeekOrigin.Begin);
                Entry.Length = Reader.ReadUInt32();

                Output.Add(Entry);
            }

            return Output;
        }