Esempio n. 1
0
        public override void Update()
        {
            base.Update();
            NoxicoGame.ContextMessage = i18n.GetString("context_interactmode");
            if (this.ParentBoard == null)
            {
                NoxicoGame.Mode = UserMode.Walkabout;
                return;
            }
            //this.ParentBoard.Draw(true);

            if (NoxicoGame.IsKeyDown(KeyBinding.Interact) || NoxicoGame.IsKeyDown(KeyBinding.Back) || Vista.Triggers == XInputButtons.B)
            {
                NoxicoGame.Mode = UserMode.Walkabout;
                NoxicoGame.ClearKeys();
                NoxicoGame.ContextMessage = string.Empty;
                Hide();
                return;
            }

            if (NoxicoGame.IsKeyDown(KeyBinding.TabFocus) || Vista.Triggers == XInputButtons.RightShoulder)
            {
                NoxicoGame.ClearKeys();
                Tabstop++;
                if (Tabstop >= Tabstops.Count)
                {
                    Tabstop = 0;
                }
                XPosition = Tabstops[Tabstop].X;
                YPosition = Tabstops[Tabstop].Y;
                Point();
            }

            if (NoxicoGame.IsKeyDown(KeyBinding.Accept) || Vista.Triggers == XInputButtons.A)
            {
                Subscreens.PreviousScreen.Clear();
                NoxicoGame.ClearKeys();
                var player = NoxicoGame.Me.Player;
#if DEBUG
                if (PointingAt == null)
                {
                    ActionList.Show("Debug?", this.XPosition - NoxicoGame.CameraX, this.YPosition - NoxicoGame.CameraY,
                                    new Dictionary <object, string>()
                    {
                        { "teleport", "Teleport" },
                        { "spawn", "Spawn character" },
                    },
                                    () =>
                    {
                        Hide();
                        if (ActionList.Answer is int && (int)ActionList.Answer == -1)
                        {
                            NoxicoGame.Mode = UserMode.Walkabout;
                            Hide();
                            return;
                        }
                        switch (ActionList.Answer as string)
                        {
                        case "teleport":
                            player.XPosition = this.XPosition;
                            player.YPosition = this.YPosition;
                            ParentBoard.AimCamera();
                            ParentBoard.Redraw();
                            NoxicoGame.Mode = UserMode.Aiming;
                            Point();
                            return;

                        case "spawn":
                            var spawnOptions = new Dictionary <object, string>();
                            foreach (var bp in Character.Bodyplans)
                            {
                                spawnOptions[bp.Text] = bp.Text;
                            }
                            var uniques = Mix.GetTokenTree("uniques.tml", true);
                            foreach (var bp in uniques)
                            {
                                spawnOptions['!' + bp.Text] = bp.Text;
                            }
                            ActionList.Show("Debug?", this.XPosition - NoxicoGame.CameraX, this.YPosition - NoxicoGame.CameraY, spawnOptions,
                                            () =>
                            {
                                if (ActionList.Answer is int && (int)ActionList.Answer == -1)
                                {
                                    NoxicoGame.Mode = UserMode.Aiming;
                                    Point();
                                    return;
                                }
                                Character newChar = null;
                                if (ActionList.Answer is string && ((string)ActionList.Answer).StartsWith('!'))
                                {
                                    newChar = Character.GetUnique(((string)ActionList.Answer).Substring(1));
                                }
                                else
                                {
                                    newChar = Character.Generate((string)ActionList.Answer, Gender.RollDice);
                                }
                                var newBoardChar = new BoardChar(newChar)
                                {
                                    XPosition   = this.XPosition,
                                    YPosition   = this.YPosition,
                                    ParentBoard = this.ParentBoard
                                };
                                newBoardChar.AdjustView();
                                ParentBoard.EntitiesToAdd.Add(newBoardChar);
                                ParentBoard.Redraw();
                                NoxicoGame.Mode = UserMode.Walkabout;
                                Hide();
                                return;
                            }
                                            );
                            break;
                        }
                    }
                                    );
                }
#endif
                if (PointingAt != null)
                {
                    LastTarget = PointingAt;
                    var distance = player.DistanceFrom(PointingAt);
                    var canSee   = player.CanSee(PointingAt);

                    var options     = new Dictionary <object, string>();
                    var description = "something";

                    options["look"] = i18n.GetString("action_lookatit");

                    if (PointingAt is Player)
                    {
                        description     = i18n.Format("action_descyou", player.Character.Name);
                        options["look"] = i18n.GetString("action_lookatyou");
                        if (player.Character.GetStat("excitement") >= 30)
                        {
                            options["f**k"] = i18n.GetString("action_masturbate");
                        }

                        if (player.Character.HasToken("copier") && player.Character.GetToken("copier").Value == 1)
                        {
                            if (player.Character.Path("copier/backup") != null || player.Character.Path("copier/full") == null)
                            {
                                options["revert"] = i18n.GetString("action_revert");
                            }
                        }
                    }
                    else if (PointingAt is DroppedItem)
                    {
                        var drop  = PointingAt as DroppedItem;
                        var item  = drop.Item;
                        var token = drop.Token;
                        description = item.ToString(token);
                        if (distance <= 1)
                        {
                            options["take"] = i18n.GetString("action_pickup");
                        }
                    }
                    else if (PointingAt is Container)
                    {
                        var container = PointingAt as Container;
                        description = container.Name ?? "container";
                    }
                    else if (PointingAt is Clutter)
                    {
                        var clutter = PointingAt as Clutter;
                        description = clutter.Name ?? "something";
                        if (clutter.ID == "craftstation")
                        {
                            options["craft"] = i18n.GetString("action_craft");
                        }
                    }
                    else if (PointingAt is BoardChar)
                    {
                        var boardChar = PointingAt as BoardChar;
                        description     = boardChar.Character.GetKnownName(true);
                        options["look"] = i18n.Format("action_lookathim", boardChar.Character.HimHerIt(true));

                        if (canSee && distance <= 2 && !boardChar.Character.HasToken("beast") && !boardChar.Character.HasToken("sleeping"))
                        {
                            options["talk"] = i18n.Format("action_talktohim", boardChar.Character.HimHerIt(true));
                            if (boardChar.Character.Path("role/vendor") != null && boardChar.Character.Path("role/vendor/class").Text != "carpenter")
                            {
                                options["trade"] = i18n.Format("action_trade", boardChar.Character.HimHerIt(true));
                            }
                        }

                        if (canSee && player.Character.GetStat("excitement") >= 30 && distance <= 1)
                        {
                            var mayFuck  = boardChar.Character.HasToken("willing");
                            var willRape = boardChar.Character.HasToken("helpless");

                            if (!IniFile.GetValue("misc", "allowrape", false) && willRape)
                            {
                                mayFuck = false;
                            }
                            //but DO allow it if they're helpless but willing
                            if (boardChar.Character.HasToken("willing") && willRape)
                            {
                                mayFuck  = true;
                                willRape = false;
                            }
                            if (boardChar.Character.HasToken("beast"))
                            {
                                mayFuck = false;
                            }

                            if (mayFuck)
                            {
                                options["f**k"] = i18n.Format(willRape ? "action_rapehim" : "action_fuckhim", boardChar.Character.HimHerIt(true));
                            }
                        }

                        if (canSee && !boardChar.Character.HasToken("beast") && player.Character.HasToken("copier") && player.Character.Path("copier/timeout") == null)
                        {
                            //if (player.Character.UpdateCopier())
                            if (player.Character.HasToken("fullCopy") || player.Character.HasToken("sexCopy"))
                            {
                                options["copy"] = i18n.Format("action_copyhim", boardChar.Character.HimHerIt(true));
                            }
                        }

                        if (canSee && player.Character.CanShoot() != null && player.ParentBoard.HasToken("combat"))
                        {
                            options["shoot"] = i18n.Format("action_shoothim", boardChar.Character.HimHerIt(true));
                        }
                    }

#if DEBUG
                    if (PointingAt is BoardChar)
                    {
                        options["mutate"] = "(debug) Random mutate";
                    }
                    if (PointingAt is BoardChar)
                    {
                        options["turbomutate"] = "(debug) Apply LOTS of mutations!";
                    }
#endif

                    ActionList.Show(description, PointingAt.XPosition - NoxicoGame.CameraX, PointingAt.YPosition - NoxicoGame.CameraY, options,
                                    () =>
                    {
                        Hide();
                        if (ActionList.Answer is int && (int)ActionList.Answer == -1)
                        {
                            //NoxicoGame.Messages.Add("[Aim message]");
                            NoxicoGame.Mode = UserMode.Aiming;
                            Point();
                            return;
                        }
                        switch (ActionList.Answer as string)
                        {
                        case "look":
                            if (PointingAt is DroppedItem)
                            {
                                var drop  = PointingAt as DroppedItem;
                                var item  = drop.Item;
                                var token = drop.Token;
                                var text  = (item.HasToken("description") && !token.HasToken("unidentified") ? item.GetToken("description").Text : i18n.Format("thisis_x", item.ToString(token))).Trim();
                                MessageBox.Notice(text, true);
                            }
                            else if (PointingAt is Clutter && !((Clutter)PointingAt).Description.IsBlank())
                            {
                                MessageBox.Notice(((Clutter)PointingAt).Description.Trim(), true, ((Clutter)PointingAt).Name ?? "something");
                            }
                            else if (PointingAt is Container)
                            {
                                MessageBox.Notice(((Container)PointingAt).Description.Trim(), true, ((Container)PointingAt).Name ?? "container");
                            }
                            else if (PointingAt is BoardChar)
                            {
                                if (((BoardChar)PointingAt).Character.HasToken("beast"))
                                {
                                    MessageBox.Notice(((BoardChar)PointingAt).Character.LookAt(PointingAt), true, ((BoardChar)PointingAt).Character.GetKnownName(true));
                                }
                                else
                                {
                                    TextScroller.LookAt((BoardChar)PointingAt);
                                }
                            }
                            break;

                        case "talk":
                            if (PointingAt is Player)
                            {
                                //if (Culture.CheckSummoningDay()) return;
                                if (player.Character.Path("mind").Value >= 10)
                                {
                                    MessageBox.Notice(i18n.GetString("talkingotyourself"), true);
                                }
                                else
                                {
                                    MessageBox.Notice(i18n.GetString("talkingtoyourself_nutso"), true);
                                }
                            }
                            else if (PointingAt is BoardChar)
                            {
                                var boardChar = PointingAt as BoardChar;
                                if (boardChar.Character.HasToken("hostile") && !boardChar.Character.HasToken("helpless"))
                                {
                                    MessageBox.Notice(i18n.Format("nothingtosay", boardChar.Character.GetKnownName(false, false, true, true)), true);
                                }
                                else
                                {
                                    SceneSystem.Engage(player.Character, boardChar.Character);
                                }
                            }
                            break;

                        case "trade":
                            ContainerMan.Setup(((BoardChar)PointingAt).Character);
                            break;

                        case "f**k":
                            if (PointingAt is BoardChar)
                            {
                                SexManager.Engage(player.Character, ((BoardChar)PointingAt).Character);
                            }
                            break;

                        case "shoot":
                            player.AimShot(PointingAt);
                            break;

                        case "copy":
                            player.Character.Copy(((BoardChar)PointingAt).Character);
                            player.AdjustView();
                            //NoxicoGame.AddMessage(i18n.Format((player.Character.Path("copier/full") == null) ? "youimitate_x" : "become_x", ((BoardChar)PointingAt).Character.GetKnownName(false, false, true)));
                            NoxicoGame.AddMessage(i18n.Format(player.Character.HasToken("fullCopy") ? "x_becomes_y" : "x_imitates_y").Viewpoint(player.Character, ((BoardChar)PointingAt).Character));
                            player.Energy -= 2000;
                            break;

                        case "revert":
                            player.Character.Copy(null);
                            player.AdjustView();
                            NoxicoGame.AddMessage(i18n.GetString((player.Character.HasToken("fullCopy")) ? "youmelt" : "yourevert"));
                            player.Energy -= 1000;
                            break;

                        case "take":
                            if (PointingAt is DroppedItem)
                            {
                                var drop  = PointingAt as DroppedItem;
                                var item  = drop.Item;
                                var token = drop.Token;
                                drop.Take(player.Character, ParentBoard);
                                player.Energy -= 1000;
                                NoxicoGame.AddMessage(i18n.Format("youpickup_x", item.ToString(token, true)), drop.ForegroundColor);
                                NoxicoGame.Sound.PlaySound("set://GetItem");
                                ParentBoard.Redraw();
                            }
                            break;

                        case "craft":
                            Crafting.Open(player.Character);
                            break;

#if DEBUG
                        case "edit":
                            TokenCarrier tc = null;
                            if (PointingAt is DroppedItem)
                            {
                                tc = ((DroppedItem)PointingAt).Token;
                            }
                            else if (PointingAt is BoardChar)
                            {
                                tc = ((BoardChar)PointingAt).Character;
                            }

                            NoxicoGame.HostForm.Write("TOKEN EDIT ENGAGED. Waiting for editor process to exit.", Color.Black, Color.White, 0, 0);
                            NoxicoGame.HostForm.Draw();
                            ((MainForm)NoxicoGame.HostForm).timer.Enabled = false;
                            var dump = "-- WARNING! Many things may cause strange behavior or crashes. WATCH YOUR F*****G STEP.\r\n" + tc.DumpTokens(tc.Tokens, 0);
                            var temp = Path.Combine(Path.GetTempPath(), DateTime.Now.Ticks.ToString() + ".txt");
                            File.WriteAllText(temp, dump);
                            var process = System.Diagnostics.Process.Start(temp);
                            process.WaitForExit();
                            var newDump = File.ReadAllText(temp);
                            File.Delete(temp);
                            ((MainForm)NoxicoGame.HostForm).timer.Enabled = true;
                            ParentBoard.Redraw();
                            if (newDump == dump)
                            {
                                break;
                            }
                            tc.Tokenize(newDump);
                            ((BoardChar)PointingAt).AdjustView();
                            ((BoardChar)PointingAt).Character.RecalculateStatBonuses();
                            ((BoardChar)PointingAt).Character.CheckHasteSlow();
                            break;

                        case "mutate":
                            var result = ((BoardChar)PointingAt).Character.Mutate(1, 30);
                            NoxicoGame.AddMessage(result);
                            break;

                        case "turbomutate":
                            result = ((BoardChar)PointingAt).Character.Mutate(2500, 30);
                            NoxicoGame.AddMessage(result);
                            break;
#endif

                        default:
                            MessageBox.Notice("Unknown action handler \"" + ActionList.Answer.ToString() + "\".", true);
                            break;
                        }
                    }
                                    );             //	true, true);
                    return;
                }
                else
                {
                    /*
                     * var tSD = this.ParentBoard.GetDescription(YPosition, XPosition);
                     * if (!string.IsNullOrWhiteSpace(tSD))
                     * {
                     *      PointingAt = null;
                     *      MessageBox.ScriptPauseHandler = () =>
                     *      {
                     *              NoxicoGame.Mode = UserMode.Aiming;
                     *              Point();
                     *      };
                     *      MessageBox.Notice(tSD, true);
                     *      return;
                     * }
                     */
                }
            }

#if DEBUG
            if (NoxicoGame.KeyMap[Keys.D])
            {
                NoxicoGame.ClearKeys();
                if (PointingAt != null && PointingAt is BoardChar)
                {
                    ((BoardChar)PointingAt).Character.CreateInfoDump();
                    NoxicoGame.AddMessage("Info for " + ((BoardChar)PointingAt).Character.GetKnownName(true, true, true) + " dumped.", Color.Red);
                }
            }
#endif

            if (NoxicoGame.IsKeyDown(KeyBinding.Left) || Vista.DPad == XInputButtons.Left)
            {
                this.Move(Direction.West);
            }
            else if (NoxicoGame.IsKeyDown(KeyBinding.Right) || Vista.DPad == XInputButtons.Right)
            {
                this.Move(Direction.East);
            }
            else if (NoxicoGame.IsKeyDown(KeyBinding.Up) || Vista.DPad == XInputButtons.Up)
            {
                this.Move(Direction.North);
            }
            else if (NoxicoGame.IsKeyDown(KeyBinding.Down) || Vista.DPad == XInputButtons.Down)
            {
                this.Move(Direction.South);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Generic Subscreen handler.
        /// </summary>
        public static void Handler()
        {
            var keys   = NoxicoGame.KeyMap;
            var player = NoxicoGame.Me.Player;
            var width  = (Program.Cols / 2) - 2;

            if (Subscreens.FirstDraw)
            {
                UIManager.Initialize();
                UIManager.Elements.Clear();

                //Prepare the left item list and its UIElements...
                var height = 1;
                containerTokens.Clear();
                containerItems.Clear();
                containerList = null;
                var containerTexts = new List <string>();

                containerWindow = new UIWindow(title)
                {
                    Left = 1, Top = 1, Width = width, Height = 2 + height
                };
                containerList = new UIList(string.Empty, null, containerTexts)
                {
                    Width = width - 2, Height = height, Index = indexLeft, Background = UIColors.WindowBackground
                };
                containerList.Move(1, 1, containerWindow);
                UIManager.Elements.Add(containerWindow);
                var emptyMessage  = mode == ContainerMode.Vendor ? i18n.Format("inventory_x_hasnothing", vendorChar.Name.ToString()) : mode == ContainerMode.Corpse ? i18n.GetString("inventory_nothingleft") : i18n.GetString("inventory_empty");
                var emptyMessageC = new UILabel(emptyMessage)
                {
                    Width = width - 3, Height = 1
                };
                emptyMessageC.Move(2, 1, containerWindow);
                UIManager.Elements.Add(emptyMessageC);
                UIManager.Elements.Add(containerList);

                if (other.Tokens.Count == 0)
                {
                    containerList.Hidden   = true;
                    containerWindow.Height = 3;
                }
                else
                {
                    //Populate the left list...
                    foreach (var carriedItem in other.Tokens)
                    {
                        //Only let vendors sell things meant for sale, not their literal shirt off their back
                        if (vendorChar != null && !carriedItem.HasToken("for_sale"))
                        {
                            continue;
                        }

                        var find = NoxicoGame.KnownItems.Find(x => x.ID == carriedItem.Name);
                        if (find == null)
                        {
                            continue;
                        }
                        containerTokens.Add(carriedItem);
                        containerItems.Add(find);

                        var item       = find;
                        var itemString = item.ToString(carriedItem, false, false);
                        if (itemString.Length > width - 5)
                        {
                            itemString = itemString.Disemvowel();
                        }
                        itemString = itemString.PadEffective(width - 5);
                        //Add any extra sigils.
                        if (mode == ContainerMode.Vendor && carriedItem.HasToken("equipped"))
                        {
                            itemString = itemString.Remove(width - 6) + i18n.GetString("sigil_short_worn");
                        }
                        if (carriedItem.Path("cursed/known") != null)
                        {
                            itemString = itemString.Remove(width - 6) + "C";                             //DO NOT TRANSLATE -- Curses will be replaced with better terms and variants such as "Slippery" or "Sticky".
                        }
                        containerTexts.Add(itemString);
                    }
                    height = containerItems.Count;
                    if (height > Program.Rows - 15)
                    {
                        height = Program.Rows - 15;
                    }
                    if (indexLeft >= containerItems.Count)
                    {
                        indexLeft = containerItems.Count - 1;
                    }

                    containerList.Items.Clear();
                    containerList.Items.AddRange(containerTexts);
                    containerWindow.Height = 2 + height;
                    containerList.Height   = height;
                }

                //Prepare the right item list and its UIElements...
                playerTokens.Clear();
                playerItems.Clear();
                playerList = null;
                var playerTexts = new List <string>();

                playerWindow = new UIWindow(i18n.GetString("inventory_yours"))
                {
                    Width = width, Height = 3
                };
                playerWindow.MoveBeside(2, 0, containerWindow);
                playerList = new UIList(string.Empty, null, playerTexts)
                {
                    Width = width - 2, Height = 1, Index = indexRight, Background = UIColors.WindowBackground
                };
                playerList.Move(1, 1, playerWindow);
                UIManager.Elements.Add(playerWindow);
                var playerNothing = new UILabel(i18n.GetString("inventory_youhavenothing"))
                {
                    Left = width + 5, Top = 2, Width = width - 3, Height = 1
                };
                playerNothing.Move(2, 1, playerWindow);
                UIManager.Elements.Add(playerNothing);
                UIManager.Elements.Add(playerList);

                if (player.Character.GetToken("items").Tokens.Count == 0)
                {
                    playerList.Hidden   = true;
                    playerWindow.Height = 3;
                }
                else
                {
                    //Populate the right list...
                    foreach (var carriedItem in player.Character.GetToken("items").Tokens)
                    {
                        var find = NoxicoGame.KnownItems.Find(x => x.ID == carriedItem.Name);
                        if (find == null)
                        {
                            continue;
                        }
                        playerTokens.Add(carriedItem);
                        playerItems.Add(find);

                        var item       = find;
                        var itemString = item.ToString(carriedItem, false, false);
                        if (itemString.Length > width - 5)
                        {
                            itemString = itemString.Disemvowel();
                        }
                        itemString = itemString.PadEffective(width - 5);
                        if (carriedItem.HasToken("equipped"))
                        {
                            itemString = itemString.Remove(width - 6) + i18n.GetString("sigil_short_worn");
                        }
                        if (carriedItem.Path("cursed/known") != null)
                        {
                            itemString = itemString.Remove(width - 6) + "C";                             //DO NOT TRANSLATE -- Curses will be replaced with better terms and variants such as "Slippery" or "Sticky".
                        }
                        playerTexts.Add(itemString);
                    }
                    var height2 = playerItems.Count;
                    if (height2 == 0)
                    {
                        height2 = 1;
                    }
                    if (height2 > Program.Rows - 15)
                    {
                        height2 = Program.Rows - 15;
                    }
                    if (indexRight >= playerItems.Count)
                    {
                        indexRight = playerItems.Count - 1;
                    }

                    if (height2 > height)
                    {
                        height = height2;
                    }

                    playerList.Items.Clear();
                    playerList.Items.AddRange(playerTexts);
                    playerWindow.Height = 2 + height2;
                    playerList.Height   = height2;
                }

                //Build the bottom window.
                UIManager.Elements.Add(new UILabel(new string(' ', Program.Cols))
                {
                    Left = 0, Top = 0, Width = Program.Cols - 1, Height = 1, Background = UIColors.StatusBackground, Foreground = UIColors.StatusForeground
                });
                UIManager.Elements.Add(new UILabel(i18n.GetString(mode == ContainerMode.Vendor ? "inventory_pressenter_vendor" : "inventory_pressenter_container"))
                {
                    Left = 0, Top = 0, Width = Program.Cols - 1, Height = 1, Background = UIColors.StatusBackground, Foreground = UIColors.StatusForeground
                });
                descriptionWindow = new UIWindow(string.Empty)
                {
                    Left = 2, Top = Program.Rows - 10, Width = Program.Cols - 4, Height = 8, Title = UIColors.RegularText
                };
                description = new UILabel(string.Empty)
                {
                    Width = Program.Cols - 8, Height = 5
                };
                description.Move(2, 1, descriptionWindow);
                capacity = new UILabel(string.Format("{0:F2}/{1:F2}", player.Character.Carried, player.Character.Capacity));
                capacity.MoveBelow(4, -1, descriptionWindow);
                UIManager.Elements.Add(descriptionWindow);
                UIManager.Elements.Add(description);
                UIManager.Elements.Add(capacity);
                //Should we be trading, replace the weight with a money indication.
                if (mode == ContainerMode.Vendor)
                {
                    capacity.Text = i18n.Format("inventory_money", vendorChar.Name.ToString(), vendorChar.GetToken("money").Value, player.Character.GetToken("money").Value);
                }

                //FIXME: why is this check a thing?
                if (containerList != null)
                {
                    containerList.Change = (s, e) =>
                    {
                        if (containerList.Items.Count == 0)
                        {
                            return;
                        }
                        indexLeft = containerList.Index;
                        //Build up the content for the description window.
                        var t = containerTokens[containerList.Index];
                        var i = containerItems[containerList.Index];
                        descriptionWindow.Text = i.ToString(t, false, false);
                        var desc = i.GetDescription(t);
                        price = 0;                         //Reset price no matter the mode so we don't accidentally pay for free shit.
                        if (mode == ContainerMode.Vendor && i.HasToken("price"))
                        {
                            price = i.GetToken("price").Value;
                            desc += "\n" + i18n.Format("inventory_itcosts", price);
                        }
                        if (mode == ContainerMode.Vendor && i.HasToken("equipable") && t.HasToken("equipped"))
                        {
                            desc += "\n" + i18n.Format("inventory_vendorusesthis", vendorChar.Name.ToString());
                        }
                        description.Text = Toolkit.Wordwrap(desc.SmartQuote(), description.Width);
                        descriptionWindow.Draw();
                        description.Draw();
                        capacity.Draw();
                    };
                    containerList.Enter = (s, e) =>
                    {
                        if (containerList.Items.Count == 0)
                        {
                            return;
                        }
                        //onLeft = true;
                        var tryAttempt = TryRetrieve(player, containerTokens[containerList.Index], containerItems[containerList.Index]);
                        if (tryAttempt.IsBlank())
                        {
                            //No errors were returned by TryRetrieve, so let's do this.
                            playerItems.Add(containerItems[containerList.Index]);
                            playerTokens.Add(containerTokens[containerList.Index]);
                            playerList.Items.Add(containerList.Items[containerList.Index]);
                            containerItems.RemoveAt(containerList.Index);
                            containerTokens.RemoveAt(containerList.Index);
                            containerList.Items.RemoveAt(containerList.Index);
                            //If this was the bottom-most item, adjust our selection.
                            if (containerList.Index >= containerList.Items.Count)
                            {
                                containerList.Index--;
                            }
                            //If this was the last item, hide the list entirely and switch to the player's side.
                            //We know that's possible -- after all, there must be at -least- one item in there now.
                            if (containerList.Items.Count == 0)
                            {
                                containerList.Hidden = true;
                                keys[NoxicoGame.KeyBindings[KeyBinding.Right]] = true;
                            }
                            else
                            {
                                containerList.Height = (containerList.Items.Count < 10) ? containerList.Items.Count : 10;
                            }
                            playerList.Hidden      = false;                        //always the case.
                            playerList.Height      = (playerList.Items.Count < 10) ? playerList.Items.Count : 10;
                            containerWindow.Height = containerList.Height + 2;
                            playerWindow.Height    = playerList.Height + 2;
                            capacity.Text          = player.Character.Carried + "/" + player.Character.Capacity;
                            if (mode == ContainerMode.Vendor)
                            {
                                capacity.Text = i18n.Format("inventory_money", vendorChar.Name.ToString(), vendorChar.GetToken("money").Value, player.Character.GetToken("money").Value);
                            }
                            containerList.Change(s, e);
                            NoxicoGame.DrawStatus();
                            UIManager.Draw();
                        }
                        else
                        {
                            //There was some error returned by TryRetrieve, which we'll show now.
                            MessageBox.Notice(tryAttempt);
                        }
                    };
                }
                //FIXME: same with this check.
                if (playerList != null)
                {
                    //We do basically the same thing as above in reverse.
                    playerList.Change = (s, e) =>
                    {
                        if (playerList.Items.Count == 0)
                        {
                            return;
                        }
                        indexRight = playerList.Index;
                        var t = playerTokens[playerList.Index];
                        var i = playerItems[playerList.Index];
                        descriptionWindow.Text = i.ToString(t, false, false);
                        var desc = i.GetDescription(t);
                        price = 0;
                        if (mode == ContainerMode.Vendor && i.HasToken("price"))
                        {
                            price = i.GetToken("price").Value;
                            desc += "\n" + i18n.Format("inventory_itcosts", price);
                        }
                        //This is one of the few differences.
                        if (t.Path("cursed/path") != null)
                        {
                            desc += "\nThis item is cursed and can't be removed.";                             //DO NOT TRANSLATE -- Curses will be replaced with better terms and variants such as "Slippery" or "Sticky".
                        }
                        else if (i.HasToken("equipable") && t.HasToken("equipped"))
                        {
                            desc += "\n" + i18n.GetString("inventory_youusethis");
                        }
                        description.Text = Toolkit.Wordwrap(desc.SmartQuote(), description.Width);
                        descriptionWindow.Draw();
                        description.Draw();
                        capacity.Draw();
                    };
                    playerList.Enter = (s, e) =>
                    {
                        if (playerList.Items.Count == 0)
                        {
                            return;
                        }
                        //onLeft = false;
                        var tryAttempt = TryStore(player, playerTokens[playerList.Index], playerItems[playerList.Index]);
                        if (tryAttempt.IsBlank())
                        {
                            containerItems.Add(playerItems[playerList.Index]);
                            containerTokens.Add(playerTokens[playerList.Index]);
                            containerList.Items.Add(playerList.Items[playerList.Index]);
                            playerItems.RemoveAt(playerList.Index);
                            playerTokens.RemoveAt(playerList.Index);
                            playerList.Items.RemoveAt(playerList.Index);
                            if (playerList.Index >= playerList.Items.Count)
                            {
                                playerList.Index--;
                            }
                            if (playerList.Items.Count == 0)
                            {
                                playerList.Hidden = true;
                                keys[NoxicoGame.KeyBindings[KeyBinding.Left]] = true;
                            }
                            else
                            {
                                playerList.Height = (playerList.Items.Count < 10) ? playerList.Items.Count : 10;
                            }
                            containerList.Hidden   = false;                           //always the case.
                            containerList.Height   = (containerList.Items.Count < 10) ? containerList.Items.Count : 10;
                            containerWindow.Height = containerList.Height + 2;
                            playerWindow.Height    = playerList.Height + 2;
                            capacity.Text          = player.Character.Carried + "/" + player.Character.Capacity;
                            if (mode == ContainerMode.Vendor)
                            {
                                capacity.Text = i18n.Format("inventory_money", vendorChar.Name.ToString(), vendorChar.GetToken("money").Value, player.Character.GetToken("money").Value);
                            }
                            playerList.Change(s, e);
                            NoxicoGame.DrawStatus();
                            UIManager.Draw();
                        }
                        else
                        {
                            //This is set by TryStore.
                            if (vendorCaughtYou)
                            {
                                //Immediately break out of ContainerMan and call out.
                                NoxicoGame.ClearKeys();
                                NoxicoGame.Immediate = true;
                                NoxicoGame.Me.CurrentBoard.Redraw();
                                NoxicoGame.Me.CurrentBoard.Draw(true);
                                NoxicoGame.Mode      = UserMode.Walkabout;
                                Subscreens.FirstDraw = true;
                                SceneSystem.Engage(player.Character, vendorChar, "(criminalscum)");
                            }
                            else
                            {
                                MessageBox.Notice(tryAttempt);
                            }
                        }
                    };
                }

                UIManager.Highlight = containerList.Items.Count > 0 ? containerList : playerList;
                UIManager.Draw();
                if (UIManager.Highlight.Change != null)
                {
                    UIManager.Highlight.Change(null, null);
                }
                Subscreens.FirstDraw = false;
            }

            if (NoxicoGame.IsKeyDown(KeyBinding.Back) || Vista.Triggers == XInputButtons.B)
            {
                NoxicoGame.ClearKeys();
                NoxicoGame.Immediate = true;
                NoxicoGame.Me.CurrentBoard.Redraw();
                NoxicoGame.Me.CurrentBoard.Draw(true);
                NoxicoGame.Mode      = UserMode.Walkabout;
                Subscreens.FirstDraw = true;
            }
            else if (NoxicoGame.IsKeyDown(KeyBinding.Left))
            {
                NoxicoGame.ClearKeys();
                if (containerList.Items.Count == 0)
                {
                    return;
                }
                UIManager.Highlight = containerList ?? playerList;
                containerList.DrawQuick();
                containerList.Change(null, null);
                playerList.DrawQuick();
            }
            else if (NoxicoGame.IsKeyDown(KeyBinding.Right))
            {
                NoxicoGame.ClearKeys();
                if (playerList.Items.Count == 0)
                {
                    return;
                }
                UIManager.Highlight = playerList ?? containerList;
                playerList.Change(null, null);
                containerList.DrawQuick();
                playerList.DrawQuick();
            }
            else
            {
                UIManager.CheckKeys();
            }
        }