Flyff

源码添加可拖拽大小背包【2】

2018-5-6 09:06 | 发布者: admin

+ add in WndField.cpp
Code:
#ifdef _INVENTORY_RESIZEABLE
    if(m_arTexInvGrid.size() > 0)
    {
        CWndTabCtrl *pwnd = (CWndTabCtrl*)GetDlgItem(WIDC_INVENTORY);
        int left = (pwnd->GetWndRect().left + 5) - 1; // +5 border left
        int top = (pwnd->GetWndRect().top + 1) - 1; // +1 offset top
        int width = (pwnd->GetWndRect().Width() - 23); // -18 scrollbar right (-5 border left)
        int height = (pwnd->GetWndRect().Height() - 22); // -21 label bottom (-1 offset top)
        //int right = (left + width), bottom = (top + height);
        int rows = (height / nGridTexSize), cols = (width / nGridTexSize);
        bool bScrolledToBottom = ((m_wndItemCtrl.getScrollbarPos() >= m_wndItemCtrl.getScrollbarMax()) && ((MAX_INVENTORY / cols) >= rows) && ((MAX_INVENTORY % cols) > 0));

        for(int y = 0, z = 0; y < rows; y++)
        {
            for(int x = 0; x < cols; x++)
            {
                CTexture *ptex = NULL;
                CPoint cp;
                cp.x = (left + (nGridTexSize * x));
                cp.y = (top + (nGridTexSize * y));

                if(m_arTexInvGrid.size() >= 12)
                {
                    bool bIsEmptySpaceScroll = (bScrolledToBottom && /*((MAX_INVENTORY / cols) > rows) && ((MAX_INVENTORY % cols) > 0) &&*/ ((y + 1) >= rows));

                    if((y >= (MAX_INVENTORY / cols)) || // if there are more rows than required last will get bottom grid
                        bIsEmptySpaceScroll) // scrolled to the last row
                    {
                        if((((y * cols) + (x + 1)) > MAX_INVENTORY) || // max inventory size (empty space)
                            (bIsEmptySpaceScroll && (((MAX_INVENTORY / cols) * cols) + (x + 1)) > MAX_INVENTORY)) // last scrolled line (empty space)
                        {
                            if(z < cols)
                            {
                                ptex = m_arTexInvGrid[x == 0 ? 9 : (((x + 1) == cols ? 11 : 10))];
                                z = (x + 1);
                            } else
                            {
                                ptex = NULL;
                            }
                        } else // last row
                        {
                            if(x == 0)
                            {
                                ptex = m_arTexInvGrid[6];
                            } else if(x == (cols - 1))
                            {
                                ptex = m_arTexInvGrid[8];
                            } else
                            {
                                ptex = m_arTexInvGrid[7];
                            }
                        }
                    } else // fill grid
                    {
                        if(y == 0) // first row
                        {
                            if(x == 0)
                            {
                                ptex = m_arTexInvGrid[0];
                            } else if(x == (cols - 1))
                            {
                                ptex = m_arTexInvGrid[2];
                            } else
                            {
                                ptex = m_arTexInvGrid[1];
                            }
                        } else if(y == (rows - 1)) // last row
                        {
                            if(x == 0)
                            {
                                ptex = m_arTexInvGrid[6];
                            } else if(x == (cols - 1))
                            {
                                ptex = m_arTexInvGrid[8];
                            } else
                            {
                                ptex = m_arTexInvGrid[7];
                            }
                        } else // rows in between
                        {
                            if(x == 0)
                            {
                                ptex = m_arTexInvGrid[3];
                            } else if(x == (cols - 1))
                            {
                                ptex = m_arTexInvGrid[5];
                            } else
                            {
                                ptex = m_arTexInvGrid[4];
                            }
                        }
                    }
                }

                if(ptex != NULL)
                {
                    ptex->Render(p2DRender, cp, CPoint(nGridTexSize, nGridTexSize), 255, 1.0f, 1.0f);
                }
            }
        }
    }
#endif // _INVENTORY_RESIZEABLE
= before
Code:
	pGoldNum->SetTitle( strGoldNum );
发布者: admin
查看: 162 | 评论: 0

老飞飞发布站  

GMT+8, 2019-3-20 01:29 , Processed in 0.075085 second(s), 7 queries , File On.

Copyright © 2018和平玩家

Powered by 作死联萌! ZSLM!

返回顶部