~ubuntu-branches/ubuntu/trusty/manaplus/trusty-proposed

« back to all changes in this revision

Viewing changes to src/gui/equipmentwindow.cpp

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2013-09-17 10:35:51 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20130917103551-az7p3nz9jgxwqjfn
Tags: 1.3.9.15-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include "gui/equipmentwindow.h"
24
24
 
25
 
#include "being.h"
 
25
#include "configuration.h"
 
26
#include "dragdrop.h"
26
27
#include "graphicsvertexes.h"
27
28
#include "inventory.h"
28
29
#include "item.h"
29
 
#include "localplayer.h"
 
30
 
 
31
#include "being/being.h"
 
32
#include "being/localplayer.h"
 
33
#include "being/playerinfo.h"
30
34
 
31
35
#include "gui/itempopup.h"
32
36
#include "gui/setup.h"
33
37
#include "gui/viewport.h"
34
38
 
 
39
#include "gui/widgets/button.h"
35
40
#include "gui/widgets/playerbox.h"
36
41
 
37
42
#include "net/inventoryhandler.h"
38
43
#include "net/net.h"
39
44
 
40
45
#include "resources/imageset.h"
41
 
#include "resources/resourcemanager.h"
42
46
 
43
47
#include "utils/dtor.h"
44
48
#include "utils/gettext.h"
160
164
    gcn::Font *const font = getFont();
161
165
    const int fontHeight = font->getHeight();
162
166
 
163
 
    if (openGLMode != 2)
 
167
    if (openGLMode != RENDER_SAFE_OPENGL)
164
168
    {
165
169
        if (mLastRedraw)
166
170
        {
277
281
 
278
282
void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
279
283
{
280
 
    Window::mousePressed(mouseEvent);
281
 
 
282
284
    if (!mEquipment)
 
285
    {
 
286
        Window::mousePressed(mouseEvent);
283
287
        return;
 
288
    }
284
289
 
285
290
    const int x = mouseEvent.getX();
286
291
    const int y = mouseEvent.getY();
292
297
        // Checks if any of the presses were in the equip boxes.
293
298
        int i = 0;
294
299
 
 
300
        bool inBox(false);
 
301
 
295
302
        for (std::vector<EquipmentBox*>::const_iterator it = mBoxes.begin(),
296
303
             it_end = mBoxes.end(); it != it_end; ++ it, ++ i)
297
304
        {
301
308
            const Item *const item = mEquipment->getEquipment(i);
302
309
            const gcn::Rectangle tRect(box->x, box->y, mBoxSize, mBoxSize);
303
310
 
304
 
            if (tRect.isPointInRect(x, y) && item)
305
 
                setSelected(i);
 
311
            if (tRect.isPointInRect(x, y))
 
312
            {
 
313
                inBox = true;
 
314
                if (item)
 
315
                {
 
316
                    setSelected(i);
 
317
                    dragDrop.dragItem(item, DRAGDROP_SOURCE_EQUIPMENT);
 
318
                    return;
 
319
                }
 
320
            }
 
321
            if (inBox)
 
322
                return;
306
323
        }
307
324
    }
308
325
    else if (mouseEvent.getButton() == gcn::MouseEvent::RIGHT)
326
343
            }
327
344
        }
328
345
    }
 
346
    Window::mousePressed(mouseEvent);
 
347
}
 
348
 
 
349
void EquipmentWindow::mouseReleased(gcn::MouseEvent &mouseEvent)
 
350
{
 
351
    Window::mouseReleased(mouseEvent);
 
352
    const DragDropSource src = dragDrop.getSource();
 
353
    if (dragDrop.isEmpty() || (src != DRAGDROP_SOURCE_INVENTORY
 
354
        && src != DRAGDROP_SOURCE_EQUIPMENT))
 
355
    {
 
356
        return;
 
357
    }
 
358
    Inventory *const inventory = player_node
 
359
        ? PlayerInfo::getInventory() : nullptr;
 
360
    if (!inventory)
 
361
        return;
 
362
 
 
363
    Item *const item = inventory->findItem(dragDrop.getItem(),
 
364
        dragDrop.getItemColor());
 
365
    if (!item)
 
366
        return;
 
367
 
 
368
    if (dragDrop.getSource() == DRAGDROP_SOURCE_INVENTORY)
 
369
    {
 
370
        if (item->isEquipment())
 
371
        {
 
372
            if (!item->isEquipped())
 
373
                Net::getInventoryHandler()->equipItem(item);
 
374
        }
 
375
    }
 
376
    else if (dragDrop.getSource() == DRAGDROP_SOURCE_EQUIPMENT)
 
377
    {
 
378
        if (item->isEquipment())
 
379
        {
 
380
            const int x = mouseEvent.getX();
 
381
            const int y = mouseEvent.getY();
 
382
            int i = 0;
 
383
            for (std::vector<EquipmentBox*>::const_iterator
 
384
                 it = mBoxes.begin(), it_end = mBoxes.end();
 
385
                 it != it_end; ++ it, ++ i)
 
386
            {
 
387
                const EquipmentBox *const box = *it;
 
388
                if (!box)
 
389
                    continue;
 
390
                const gcn::Rectangle tRect(box->x, box->y, mBoxSize, mBoxSize);
 
391
 
 
392
                if (tRect.isPointInRect(x, y))
 
393
                    return;
 
394
            }
 
395
 
 
396
            if (item->isEquipped())
 
397
                Net::getInventoryHandler()->unequipItem(item);
 
398
        }
 
399
    }
 
400
    dragDrop.clear();
 
401
    dragDrop.deselect();
329
402
}
330
403
 
331
404
// Show ItemTooltip
491
564
    {
492
565
        id = 0;
493
566
    }
494
 
    else if (name == "free" || name == "misc1")
 
567
    else if (name == "misc1" || name == "cape")
495
568
    {
496
569
        id = 5;
497
570
    }