GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/listeners/textskilllistener.cpp Lines: 3 16 18.8 %
Date: 2017-11-29 Branches: 0 8 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2011-2017  The ManaPlus Developers
4
 *
5
 *  This file is part of The ManaPlus Client.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
#include "listeners/textskilllistener.h"
22
23
#include "gui/windows/textdialog.h"
24
25
#include "net/skillhandler.h"
26
27
#include "debug.h"
28
29
2
TextSkillListener::TextSkillListener() :
30
    ActionListener(),
31
    mDialog(nullptr),
32
    mSkillId(0),
33
    mX(0),
34
    mY(0),
35
4
    mLevel(0)
36
{
37
2
}
38
39
void TextSkillListener::setSkill(const int skillId,
40
                                 const int x,
41
                                 const int y,
42
                                 const int level)
43
{
44
    mSkillId = skillId;
45
    mX = x;
46
    mY = y;
47
    mLevel = level;
48
}
49
50
void TextSkillListener::action(const ActionEvent &event)
51
{
52
    if (event.getId() == "ok" && (mDialog != nullptr))
53
    {
54
        const std::string text = mDialog->getText();
55
        if (text.empty())
56
            return;
57
        skillHandler->usePos(mSkillId,
58
            mLevel,
59
            mX, mY,
60
            text);
61
    }
62
    mDialog = nullptr;
63
}