-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasicImage.cpp
More file actions
79 lines (66 loc) · 2.53 KB
/
BasicImage.cpp
File metadata and controls
79 lines (66 loc) · 2.53 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "stdafx.h"
#include "BasicImage.h"
BasicImage::BasicImage(){
}
BasicImage::BasicImage(float x, float y){
position.x = x;
position.y = y;
shape.setPosition(position);
shape.setFillColor(Color(0, 0, 0, 0));
}
BasicImage::BasicImage(TextureManager* t_manager, Warehouse* w_object, string name){
image.setTexture(t_manager->getTexture(w_object->getWarehouseItem(name)->getTMInfo().first, name));
image.setTextureRect(w_object->getWarehouseItem(name)->getSpriteInfo().first);
shape.setFillColor(Color(0, 0, 0, 0));
shape.setSize(Vector2f(image.getTextureRect().width, image.getTextureRect().height));
}
BasicImage::BasicImage(TextureManager* t_manager, int index, string name, IntRect frame){
image.setTexture(t_manager->getTexture(index, name));
image.setTextureRect(frame);
shape.setFillColor(Color(0, 0, 0, 0));
shape.setSize(Vector2f(image.getTextureRect().width, image.getTextureRect().height));
}
void BasicImage::addInfo(TextureManager* t_manager, Warehouse* w_object, string name){
image.setTexture(t_manager->getTexture(w_object->getWarehouseItem(name)->getTMInfo().first, name));
image.setTextureRect(w_object->getWarehouseItem(name)->getSpriteInfo().first);
shape.setSize(Vector2f(image.getTextureRect().width, image.getTextureRect().height));
}
void BasicImage::addInfo(TextureManager* t_manager, WarehouseItem* w_item){
image.setTexture(t_manager->getTexture(w_item->getTMInfo().first, w_item->getTMInfo().second));
image.setTextureRect(w_item->getSpriteInfo().first);
shape.setSize(Vector2f(image.getTextureRect().width, image.getTextureRect().height));
}
FloatRect BasicImage::getLocalBounds(){
return image.getLocalBounds();
}
FloatRect BasicImage::getGlobalBounds(){
return image.getGlobalBounds();
}
void BasicImage::setPosition(float x, float y){
position.x = x;
position.y = y;
image.setPosition(position);
shape.setPosition(position);
}
void BasicImage::setScale(float scale_){
scale = scale_;
image.setScale(scale, scale);
shape.setScale(scale, scale);
}
void BasicImage::setBColor(Color color){
shape.setFillColor(color);
}
void BasicImage::update(Vector2f mouse_pos, FloatRect view_cords){
image.setPosition(
position.x + view_cords.left - view_cords.width / 2,
position.y + view_cords.top - view_cords.height / 2
);
shape.setPosition(
position.x + view_cords.left - view_cords.width / 2,
position.y + view_cords.top - view_cords.height / 2
);
}
void BasicImage::render(RenderTarget* target){
target->draw(shape);
target->draw(image);
}