/
ItemButton.cpp
52 lines (42 loc) · 910 Bytes
/
ItemButton.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* File: ItemButton.cpp
* Author: legionth
*
* Created on 4. Juli 2012, 21:54
*/
#include "ItemButton.h"
#include <iostream>
ItemButton::ItemButton() {
setVisible(false);
}
ItemButton::ItemButton(const ItemButton& orig) {
}
ItemButton::~ItemButton() {
delete this->text;
}
ItemButton::ItemButton(int frameRect,sf::Texture* tex,int id){
this->id = id;
this->setImage(tex);
setFrameSize(32,32);
setFrameRect(frameRect);
text = new sf::Text();
updateCount(0);
setVisible(false);
}
sf::Text* ItemButton::getText(){
return this->text;
}
void ItemButton::setCount(int i){
updateCount(i);
}
void ItemButton::updateCount(int i){
this->count = i;
std::stringstream ss;
ss << count;
text->setString("x "+ss.str());
text->setColor(sf::Color::Black);
text->setCharacterSize(20);
}
int ItemButton::getId(){
return this->id;
}