示例#1
0
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            if (mTarget.LotCurrent == null)
            {
                return(OptionResult.Failure);
            }

            Dictionary <int, Dictionary <string, List <Quality> > > settings = Cupcake.Settings.GetDisplaySettings(mTarget.ObjectId);

            if (settings == null)
            {
                Common.Notify("Unable to find settings for that display.");
                return(OptionResult.Failure);
            }

            DisplayHelper.DisplayTypes displayType = DisplayHelper.GetDisplayType(mTarget as CraftersConsignmentDisplay);

            bool complain = false;

            CraftersConsignmentDisplay[] displays = mTarget.LotCurrent.GetObjects <CraftersConsignmentDisplay>();

            foreach (CraftersConsignmentDisplay display in displays)
            {
                Dictionary <int, Dictionary <string, List <Quality> > > newSettings = new Dictionary <int, Dictionary <string, List <Quality> > >();

                DisplayHelper.DisplayTypes copyDisplayType;
                Dictionary <int, Slot>     containmentSlots = DisplayHelper.GetEmptyOrFoodSlots(display as CraftersConsignmentDisplay, out copyDisplayType);

                if (copyDisplayType != displayType)
                {
                    complain = true;
                    continue;
                }

                foreach (int slot in containmentSlots.Keys)
                {
                    if (settings.ContainsKey(slot))
                    {
                        newSettings.Add(slot, settings[slot]);
                    }
                }

                Cupcake.Settings.SetDisplaySettings(display.ObjectId, newSettings);
            }

            if (complain)
            {
                Common.Notify("Some displays were skipped as they were not of this displays type.");
            }

            Common.Notify(Common.Localize("General:Success"));

            return(OptionResult.SuccessClose);
        }
示例#2
0
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            if (Cupcake.activeDisplay == null)
            {
                Common.Notify(Common.Localize("SlotCopy:NoSelection"));
                return(OptionResult.Failure);
            }

            if (Cupcake.activeDisplay == mTarget)
            {
                Common.Notify(Common.Localize("SlotCopy:SameDisplay"));
                return(OptionResult.Failure);
            }

            DisplayHelper.DisplayTypes targetType = DisplayHelper.GetDisplayType(mTarget as CraftersConsignmentDisplay);
            DisplayHelper.DisplayTypes activeType = DisplayHelper.GetDisplayType(Cupcake.activeDisplay as CraftersConsignmentDisplay);

            if (targetType != activeType)
            {
                Common.Notify(Common.Localize("SlotCopy:TypeMismatch"));
                return(OptionResult.Failure);
            }

            if (!Cupcake.Settings.HasSettings(Cupcake.activeDisplay.ObjectId))
            {
                Common.Notify(Common.Localize("SlotCopy:NoSettings"));
                return(OptionResult.Failure);
            }

            if (Cupcake.Settings.HasSettings(mTarget.ObjectId))
            {
                Cupcake.Settings.RemoveDisplaySettings(mTarget.ObjectId);
            }

            Cupcake.Settings.SetDisplaySettings(mTarget.ObjectId, Cupcake.Settings.GetDisplaySettings(Cupcake.activeDisplay.ObjectId));

            Common.Notify(Common.Localize("General:Success"));

            return(OptionResult.SuccessClose);
        }
示例#3
0
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            if (Cupcake.activeDisplay == null)
            {
                Common.Notify(Common.Localize("SlotCopy:NoSelection"));
                return(OptionResult.Failure);
            }

            if (Cupcake.activeDisplay == mTarget)
            {
                Common.Notify(Common.Localize("SlotCopy:SameDisplay"));
                return(OptionResult.Failure);
            }

            DisplayHelper.DisplayTypes targetType = DisplayHelper.GetDisplayType(mTarget as CraftersConsignmentDisplay);
            DisplayHelper.DisplayTypes activeType = DisplayHelper.GetDisplayType(Cupcake.activeDisplay as CraftersConsignmentDisplay);

            if (targetType != activeType)
            {
                Common.Notify(Common.Localize("SlotCopy:TypeMismatch"));
                return(OptionResult.Failure);
            }

            if (!Cupcake.Settings.HasSettings(Cupcake.activeDisplay.ObjectId))
            {
                Common.Notify(Common.Localize("SlotCopy:NoSettings"));
                return(OptionResult.Failure);
            }

            SimpleMessageDialog.Show(Common.Localize("SlotCopy:MessageTitle"), Common.Localize("SlotCopy:MessageBody"));

            SlotSelection activeSlotSelection = SlotSelection.Create(Cupcake.activeDisplay as CraftersConsignmentDisplay);
            OptionResult  result = activeSlotSelection.Perform();

            if (result != OptionResult.SuccessClose)
            {
                return(OptionResult.Failure);
            }

            SlotSelection targetSlotSelection = null;

            if (activeSlotSelection.selectedItems.Count == 1 && !activeSlotSelection.all)
            {
                targetSlotSelection = SlotSelection.Create(mTarget as CraftersConsignmentDisplay);
                OptionResult targetResult = targetSlotSelection.Perform();

                if (targetResult != OptionResult.SuccessClose)
                {
                    return(OptionResult.Failure);
                }
            }

            if (targetSlotSelection == null)
            {
                // selected multiple from active display, we are doing carbon copying
                foreach (int slot in activeSlotSelection.selectedItems)
                {
                    if (Cupcake.Settings.SlotHasSettings(Cupcake.activeDisplay.ObjectId, slot))
                    {
                        Cupcake.Settings.RemoveDisplaySettingsForSlot(mTarget.ObjectId, slot);
                        Cupcake.Settings.SetDisplaySettingsForSlot(mTarget.ObjectId, Cupcake.Settings.GetDisplaySettingsForSlot(Cupcake.activeDisplay.ObjectId, slot), slot);
                    }
                }
            }
            else
            {
                // selected single from active display, we are doing multiple copy to target display
                foreach (int slot in targetSlotSelection.selectedItems)
                {
                    if (Cupcake.Settings.SlotHasSettings(Cupcake.activeDisplay.ObjectId, activeSlotSelection.selectedItems[0]))
                    {
                        Cupcake.Settings.RemoveDisplaySettingsForSlot(mTarget.ObjectId, slot);
                        Cupcake.Settings.SetDisplaySettingsForSlot(mTarget.ObjectId, Cupcake.Settings.GetDisplaySettingsForSlot(Cupcake.activeDisplay.ObjectId, activeSlotSelection.selectedItems[0]), slot);
                    }
                }
            }

            Common.Notify(Common.Localize("General:Success"));

            return(OptionResult.SuccessClose);
        }