public virtual FreeUIUtil.Rectangle GetItemRegion(ItemInventory inventory, IEventArgs args, int screenW, int screenH, ItemPosition ip)
 {
     Initial(args);
     FreeUIUtil.Rectangle rec = GetItemRegion(args, screenW, screenH);
     rec.x = rec.x + ip.GetX() * itemWidth + (int)MyMath.Max(0, (ip.GetX() - 1)) * GetWidthMargin(inventory, args);
     rec.y = rec.y + ip.GetY() * itemHeight + (int)MyMath.Max(0, (ip.GetY() - 1)) * GetHeightMargin(inventory, args);
     return(rec);
 }
示例#2
0
 private static void ExchangeItem(ItemInventory fromIn, ItemInventory toIn, IInventoryUI fromUI, IInventoryUI toUI, ItemPosition ip, ItemPosition old, ISkillArgs args)
 {
     if (fromIn.CanExchange(old, ip) && fromIn.IsCanDrop(old, args))
     {
         fromIn.ExchangeItemPosition(old, ip);
         HandleMoveAction(fromIn, toIn, fromUI, toUI, ip, args, true);
         HandleMoveAction(toIn, fromIn, toUI, fromUI, old, args, true);
         HandleMoveAction(fromIn, toIn, fromUI, toUI, ip, args, false);
         HandleMoveAction(toIn, fromIn, toUI, fromUI, old, args, false);
         if (fromIn == toIn)
         {
             fromUI.UpdateItem(args, fromIn, old);
             fromUI.UpdateItem(args, fromIn, ip);
         }
         else
         {
             fromUI.AddItem(args, fromIn, old);
             toUI.AddItem(args, toIn, ip);
         }
     }
     else
     {
         fromIn.ChangePosition(ip, fromIn, ip.GetX(), ip.GetY());
         if (fromUI.CanNotMoveAction != null)
         {
             fromUI.CanNotMoveAction.Act(args);
         }
         fromUI.UpdateItem(args, fromIn, ip);
     }
 }
示例#3
0
 private static void MoveItem(int countX, int countY, ItemInventory fromIn, ItemInventory toIn, IInventoryUI fromUI, IInventoryUI toUI, ItemPosition ip, ItemPosition old, ISkillArgs args)
 {
     if (fromIn.CanMoveTo(ip, toIn, countX, countY))
     {
         fromIn.ChangePosition(ip, toIn, countX, countY);
         HandleMoveAction(fromIn, toIn, fromUI, toUI, ip, args);
         if (fromIn == toIn)
         {
             fromUI.UpdateItem(args, fromIn, ip);
         }
         else
         {
             fromUI.DeleteItem(args, fromIn, ip);
             toUI.AddItem(args, toIn, ip);
         }
     }
     else
     {
         fromIn.ChangePosition(ip, fromIn, ip.GetX(), ip.GetY());
         if (fromUI.CanNotMoveAction != null)
         {
             fromUI.CanNotMoveAction.Act(args);
         }
         fromUI.UpdateItem(args, fromIn, ip);
     }
 }
示例#4
0
        public void Draw(SimpleInventoryUI ui, IEventArgs args, ItemInventory inventory, ItemPosition ip)
        {
            FreeUICreateAction fui = new FreeUICreateAction();

            FreeImageComponet img = new FreeImageComponet();
            int startX            = GetX(inventory, args, ui, ip, img);
            int startY            = GetY(inventory, args, ui, ip, img);

            img.SetX(startX.ToString());
            img.SetY(startY.ToString());
            img.SetRelative(ui.relative);
            img.SetWidth("64");
            img.SetHeight("64");
            img.SetEvent(inventory.GetName() + "," + ip.GetX() + "," + ip.GetY());
            if (ui.nomouse)
            {
                img.SetNoMouse("true");
            }
            if (ui.itemFixed)
            {
                img.SetFixed("true");
            }

            img.SetUrl(ip.GetKey().GetImg());
            img.SetOriginalSize(ip.GetKey().GetItemWidth() + "," + ip.GetKey().GetItemHeight());

            fui.GetComponents().Add(img);

            fui.SetKey(ip.GetUIKey());
            fui.SetShow(inventory.IsOpen());
            fui.SetScope(1);
            fui.SetPlayer("current");
            fui.Act(args);
        }
示例#5
0
        private void AdjustSize(IEventArgs args, SimpleInventoryUI ui, ItemPosition ip, ItemInventory inventory, FreeImageComponet back, FreeImageComponet itemImg, int startX, int startY)
        {
            //back.SetWidth((ip.GetKey().GetGridWidth() * ui.itemWidth + (ip.GetKey().GetGridWidth() - 1) * ui.GetWidthMargin(inventory, args)).ToString());
            //back.SetHeight((ip.GetKey().GetGridHeight() * ui.itemHeight + (ip.GetKey().GetGridHeight() - 1) * ui.GetHeightMargin(inventory, args)).ToString());
            double w   = double.Parse(back.GetWidth(args)) / (double)ip.GetKey().GetItemWidth();
            double h   = double.Parse(back.GetHeight(args)) / (double)ip.GetKey().GetItemHeight();
            double per = h;

            if (w < h)
            {
                per = w;
            }
            int iw = (int)(ip.GetKey().GetItemWidth() * per * ip.GetKey().GetIconScale());
            //itemImg.SetWidth(iw.ToString());
            int ih = (int)(ip.GetKey().GetItemHeight() * per * ip.GetKey().GetIconScale());

            //itemImg.SetHeight(ih.ToString());
            //itemImg.SetX((startX + (NumberUtil.GetInt(back.GetWidth(args)) - iw) / 2).ToString());
            //itemImg.SetY((startY + (NumberUtil.GetInt(back.GetHeight(args)) - ih) / 2).ToString());
            itemImg.SetEvent(inventory.GetName() + "," + ip.GetX() + "," + ip.GetY());
        }
示例#6
0
        public static void MovePosition(ItemInventory fromIn, ItemInventory toIn, SimpleInventoryUI fromUI, SimpleInventoryUI toUI, ItemPosition ip, int x, int y, ISkillArgs args)
        {
            FreeRuleEventArgs fr = (FreeRuleEventArgs)args;
            int oneX             = toUI.GetWidth(args) / toIn.GetColumn();
            int countX           = x / (oneX);
            int remain           = x % (oneX);

            if (fromIn == toIn)
            {
                if (MyMath.Abs(remain) > oneX / 2)
                {
                    if (remain > 0)
                    {
                        countX++;
                    }
                    else
                    {
                        countX--;
                    }
                }
                countX = countX + ip.GetX();
            }
            else
            {
                if (countX < 0)
                {
                    countX = 0;
                }
            }
            int oneY   = toUI.GetHeight(args) / toIn.GetRow();
            int countY = y / (oneY);

            remain = y % (oneY);
            if (fromIn == toIn)
            {
                if (MyMath.Abs(remain) > oneY / 2)
                {
                    if (remain > 0)
                    {
                        countY++;
                    }
                    else
                    {
                        countY--;
                    }
                }
                countY = countY + ip.GetY();
            }
            else
            {
                if (countY < 0)
                {
                    countY = 0;
                }
                //countY = toIn.row - countY - 1;
            }
            if (MoveOut(fromIn, toIn, ip, countX, countY, args, fr, fromUI, toUI))
            {
                return;
            }
            Move(fromIn, toIn, ip, countX, countY, args, fr, fromUI, toUI);
        }
示例#7
0
 public virtual int GetY(ItemPosition ip)
 {
     return(y + height / row * ip.GetY());
 }
示例#8
0
        private int GetY(ItemInventory inventory, IEventArgs args, SimpleInventoryUI ui, ItemPosition ip, FreeImageComponet back)
        {
            int heightMargin = ui.GetHeightMargin(inventory, args);

            return(ui.GetY(args) + FreeUIUtil.GetDownY(FreeUtil.ReplaceInt(ui.relative, args), ip.GetY() * (ui.itemHeight + heightMargin)));
        }
示例#9
0
        public virtual void Draw(SimpleInventoryUI ui, IEventArgs args, ItemInventory inventory, ItemPosition ip)
        {
            this.inventory = inventory;
            if (fui == null)
            {
                fui = new FreeUICreateAction();
                Sharpen.Collections.AddAll(fui.GetComponents(), components);
            }
            ip.GetParameters().AddPara(new StringPara("inventory", inventory.GetName()));
            StringPara img      = new StringPara("img", string.Empty);
            StringPara itemName = new StringPara("name", string.Empty);
            IntPara    count    = new IntPara("count", 0);

            args.GetDefault().GetParameters().TempUse(img);
            args.GetDefault().GetParameters().TempUse(count);
            args.GetDefault().GetParameters().TempUse(itemName);

            img.SetValue(ip.GetKey().GetImg());
            count.SetValue(ip.GetCount());
            itemName.SetValue(ip.GetKey().GetName());
            FreeImageComponet back = GetBackground();

            if (ui.nomouse)
            {
                back.SetNoMouse("true");
            }
            if (ui.itemFixed)
            {
                back.SetFixed("true");
            }
            int startX = GetX(args, ui, ip, back);
            int startY = GetY(args, ui, ip, back);

            if (!StringUtil.IsNullOrEmpty(notused) && !StringUtil.IsNullOrEmpty(used))
            {
                if (ip.IsUsed())
                {
                    back.SetUrl(used);
                }
                else
                {
                    back.SetUrl(notused);
                }
            }
            back.SetX(startX.ToString());
            back.SetY(startY.ToString());
            back.SetRelative(ui.relative);
            back.SetEvent(inventory.GetName() + "," + ip.GetX() + "," + ip.GetY());
            FreeImageComponet itemImg         = back;
            FreeImageComponet secondComponent = GetItemImage();

            if (secondComponent != null)
            {
                back.SetEvent(string.Empty);
                itemImg = secondComponent;
            }
            if (ui.nomouse)
            {
                itemImg.SetNoMouse("true");
            }
            if (ui.itemFixed)
            {
                itemImg.SetFixed("true");
            }
            itemImg.SetUrl(ip.GetKey().GetImg());
            itemImg.SetOriginalSize(ip.GetKey().GetItemWidth() + "," + ip.GetKey().GetItemHeight());
            if (itemImg == back)
            {
                AdjustSize(args, ui, ip, inventory, back, itemImg, startX, startY);
            }
            else
            {
                AdjustSize(args, ui, ip, inventory, back, itemImg, 0, 0);
            }
            SetCount(ip);
            fui.SetKey(ip.GetUIKey());
            fui.SetShow(inventory.IsOpen());
            fui.SetScope(1);
            fui.SetPlayer("current");
            fui.Act(args);
            UpdateHotKey(ui, args, ip);
            args.GetDefault().GetParameters().Resume("img");
            args.GetDefault().GetParameters().Resume("name");
            args.GetDefault().GetParameters().Resume("count");
        }