//basic scroll right now
        internal void update(double gameTime, SimpleMouseState mouseState)
        {
            if (inventory != null && (invResult = inventory.update(mouseState)) != ItemID.na) {
                //if the inventory returns an item
                inventory = null;
                mBarracks.swapItems(changingChamp, invResult);
                return;
            }
            int mouseY = mouseState.getPos().Y;
            if (GeoLib.isInRect(start,overallRect, new Vector2f(mouseState.getPos().X, mouseState.getPos().Y))){//start.X <= mouseState.getPos().X && mouseState.getPos().X <= start.X + overallRect.Width) {
                if (start.Y <= mouseY && mouseY <= start.Y + scroll) {
                    //clicked in the top box
                    if (mouseState.DoneReleasedIt(mouseButton.LEFT)) {
                        backButton();
                    }
                }else if(start.Y + overallRect.Height - scroll <= mouseY && mouseY <= start.Y + overallRect.Height){
                    //bottom box
                    if (mouseState.DoneReleasedIt(mouseButton.LEFT)){
                        nextButton();
                    }
                } else if (start.Y + scroll <= mouseY && mouseY <= start.Y + overallRect.Height - scroll) {
                    //somewhere in the middle
                    if (draggedChamp != null && mouseState.getPos().X >= start.X + itemIconStart.X) {//if on right side to hover over icons
                        int hoveredOver = -1;//TODO this could be nicer
                        hoveredOver = (int)(topBar + (mouseState.getPos().Y - (int)start.Y - scroll) / (champBarRect.Height));

                        if (mouseState.DoneReleasedIt(mouseButton.LEFT))
                            clickedChampItem(hoveredOver);
                    }
                    //do drag logic
                    if (mouseState.DoneClickedIt(mouseButton.LEFT)) {
                        Vector2f current = new Vector2f(mouseState.getPos().X, mouseState.getPos().Y);
                        draggedChamp = mBarracks.getChamps()[(int)(topBar + (mouseState.getPos().Y - (int)start.Y - scroll) / (champBarRect.Height))];
                        lastClicked = current;
                    } else if (!mouseState.left) {
                        draggedChamp = null;
                    }
                    //do scroll logic
                    if (mouseState.mouseWheelPos - mouseState.prevMouseWheelPos >= 1) {
                        backButton();
                    }
                    if (mouseState.mouseWheelPos - mouseState.prevMouseWheelPos <= -1) {
                        nextButton();
                    }
                }
                for (int i = 0; i < maxShown; i++) {
                    ItemID item = mBarracks.getChamps()[topBar+ i].item;
                    champsItemIcons[topBar+ i].update(mouseState,
                        new Vector2f(start.X + itemIconStart.X, start.Y + itemIconStart.Y + champBarRect.Height * i + scroll),item);
                }
            }
            if (!mouseState.left)//released
                draggedChamp = null;
        }
        internal ItemID update(SimpleMouseState mouseState)
        {
            if (mouseState.DoneReleasedIt(mouseButton.LEFT)) {
                if (mouseState.getPos().Y >= 0 && mouseState.getPos().Y <= 600 && mouseState.getPos().X >= 0 && mouseState.getPos().X <= 800){
                    int rowC = mouseState.getPos().Y / (GameBox.GAMERESY / cols);
                    int colC = mouseState.getPos().X / (GameBox.GAMERESX / rows);
                    if (rowC * rows + colC >= items.Count) return ItemID.none;
                    return items[rowC * rows + colC];
                }
            }

            //if (selected) ;

            return ItemID.na;
        }
Exemple #3
0
		internal virtual bool didRelease(SimpleMouseState mouseState) {
            return mouseState.DoneReleasedIt(mouseButton.LEFT) && didHit(mouseState.getPos());
        }