示例#1
0
        // dynamic features
        public override TCODConsole GetUpdatedConsole()
        {
            DrawBox(skillSelectSection.origin.X, skillSelectSection.origin.Y,
                    skillSelectSection.size.X, skillSelectSection.size.Y, backgroundColor, true);

            DrawBox(skillDropSection.origin.X, skillDropSection.origin.Y,
                    skillDropSection.size.X, skillDropSection.size.Y, backgroundColor, true);

            DrawBox(itemSelectSection.origin.X, itemSelectSection.origin.Y,
                    itemSelectSection.size.X, itemSelectSection.size.Y, backgroundColor, true);

            DrawBox(itemDropSection.origin.X, itemDropSection.origin.Y,
                    itemDropSection.size.X, itemDropSection.size.Y, backgroundColor, true);

            base.GetUpdatedConsole();

            DrawText(3, 9, "points: " + availablePoints.ToString("D3"), Constants.COL_FRIENDLY);

            foreach (StatSelector statSelector in attrSelectors)
            {
                int y = statSelector.increase.origin.Y;

                // draw the stat name, and the value inbetween the inc. and dec. buttons. Center the 3 digit number
                DrawText(3, y, "- " + statSelector.statName, Constants.COL_NORMAL);
                DrawText(statSelector.decrease.origin.X + 2, y, statSelector.current.ToString("D3"), Constants.COL_NORMAL);
            }

            // character name, and label on top of it
            characterNameField.Update(engine.mouseData, engine.lastKey);
            characterNameField.Draw(this);

            // in case nothing was hovered on, close both windows because its impossible to hover on both an item and skill at the same time
            if (!isHoveringOnItem)
            {
                itemInspector.Close();
                skillInspector.Close();
            }

            isHoveringOnItem = false;

            return(console);
        }
示例#2
0
        // dynamic features
        public override TCODConsole GetUpdatedConsole()
        {
            base.GetUpdatedConsole();
            const int left         = 2;
            int       hoveredItemY = -1;
            Entity    hoveredItem  = null;
            int       width        = console.getWidth() - (left + 3);
            Vector2   mLoc         = ScreenToConsoleCoord(engine.mouseData.CellX, engine.mouseData.CellY);

            InitializeConsole();

            // devider line is a horizontal line that can be drawn across the console
            string deviderLine = CharConstants.E_TJOINT + "";

            for (int i = 1; i < console.getWidth() - 1; i++)
            {
                deviderLine += CharConstants.HORZ_LINE;
            }
            deviderLine += CharConstants.W_TJOINT;

            // inventory weight: TODO
            DrawText(left, 2, " weight: X/X", Constants.COL_FRIENDLY);

            // equipped area -------------------------------------------------------------
            int equiptopY = equipSection.starty;

            DrawText(0, equiptopY, deviderLine, TCODColor.white);
            DrawText(left, equiptopY, " equipped ", Constants.COL_NORMAL);

            if (equipment.weapon != null)
            {
                EGetScreenName getName    = (EGetScreenName)equipment.weapon.FireEvent(new EGetScreenName());
                string         weaponName = getName.text;

                // the weapon is being hovered over
                if (mLoc.y == equiptopY + 3 &&
                    mLoc.x >= left && mLoc.x < weaponName.Length + 1 + left)
                {
                    DrawRect(left, equiptopY + 3, width, Constants.COL_FRIENDLY);
                    hoveredItem  = equipment.weapon;
                    hoveredItemY = equiptopY + 3;

                    // was clicked, start dragging it
                    if (engine.mouseData.LeftButtonPressed)
                    {
                        parent.SetDragDrop(weaponName, equipment.weapon, OnDragDroppedEquippedItem);

                        parent.rangeIndicator.range = CombatEngine.GetThrowRange(player, equipment.weapon);
                        draggingItem = true;
                    }
                }

                DrawText(left, equiptopY + 2, "weapon: ", Constants.COL_NORMAL);
                DrawText(left, equiptopY + 3, " " + weaponName, TCODColor.white);
            }

            // pack adrea (general unequipped items) -------------------------------------
            int packtopY = invSection.starty;

            DrawText(0, packtopY, deviderLine, TCODColor.white);
            DrawText(left, packtopY, " pack ", Constants.COL_NORMAL);

            int line = 1;

            foreach (Entity item in inventory.items)
            {
                // get the screen name dynamically: TODO: maybe cache this?
                EGetScreenName getName    = (EGetScreenName)item.FireEvent(new EGetScreenName());
                string         screenName = getName.text;

                // check if the mouse is hovering on this item row
                if (mLoc.y == packtopY + line &&
                    mLoc.x >= left && mLoc.x < screenName.Length + 1 + left)
                {
                    hoveredItem  = item;
                    hoveredItemY = packtopY + line;

                    // highlight the item that is hovered on
                    DrawRect(left, packtopY + line, width, Constants.COL_FRIENDLY);

                    // check for clicks on this item, and start dragging it
                    if (engine.mouseData.LeftButtonPressed)
                    {
                        parent.SetDragDrop(screenName, item, OnDragDroppedInvItem);

                        // set the range indicator based on how far the dragged item can be thrown, in case the player dicides to throw its
                        parent.rangeIndicator.range = CombatEngine.GetThrowRange(player, item);
                        draggingItem = true;
                    }
                }

                DrawText(left, packtopY + line, screenName, TCODColor.white);
                DrawText(left - 1, packtopY + line, ">", Constants.COL_ATTENTION);

                line += 1;
            }

            // if there is a hovered item, open the item details window
            if (hoveredItem != null &&
                (!itemInfoWindow.isVisible || hoveredItem != itemInfoWindow.targetItem))
            {
                // move the window to the correct position, and open it for the new item
                itemInfoWindow.origin.y = hoveredItemY;
                itemInfoWindow.origin.x = origin.x - itemInfoWindow.console.getWidth();
                itemInfoWindow.OpenForItem(hoveredItem);
            }
            else if (hoveredItem == null && itemInfoWindow.isVisible)
            {
                itemInfoWindow.Close();
            }

            // tell the parent to draw the range indicator if the user is looking like they will drop the dragged item
            if (draggingItem)
            {
                if (!ScreenCoordInConsole(new Vector2(engine.mouseData.CellX, engine.mouseData.CellY)))
                {
                    parent.rangeIndicator.active = true;
                }
                else
                {
                    parent.rangeIndicator.active = false;
                }
            }

            return(console);
        }