-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslot.cpp
More file actions
81 lines (68 loc) · 1.45 KB
/
slot.cpp
File metadata and controls
81 lines (68 loc) · 1.45 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
80
81
/*
* slot.cpp
* StepSeq
*
* Created by Magnus Selin on 2012-05-27.
* Copyright 2012 NR. All rights reserved.
*
*/
#include "slot.h"
sf::Image Slot::button_img;
double Slot::pitch;
Sound_Handler * Slot::sound_list;
Slot::Slot(){
active = false;
}
// Static functions
// ********************************************************
bool Slot::init(Sound_Handler * s){
sound_list = s;
if (!button_img.LoadFromFile("button.jpg")){
std::cerr << "Couldn't load button image!";
return false;
}
std::cerr << "Succesfully loaded image!\n";
return true;
}
void Slot::set_pitch(double val){
pitch = val;
}
// ********************************************************
bool Slot::is_active(){
return active;
}
void Slot::set_color(int r, int g, int b){
col[0] = r; col[1] = g; col[2] = b;
}
void Slot::set_pos(int x, int y) {
pos[0] = x; pos[1] = y;
}
void Slot::set_active_sample(int n){
active_sample = n;
}
void Slot::switch_state(){
active = !active;
if(active){
col[0] = 100;
col[1] = 100;
col[2] = 200;
}
else{
col[0] = 100;
col[1] = 100;
col[2] = 100;
}
}
void Slot::disable(int n){
}
void Slot::mute(){muted = true;}
void Slot::unmute(){muted = false;}
void Slot::play(){
if(!muted) sound_list->play(active_sample);
}
void Slot::draw(sf::RenderWindow * window){
sf::Sprite tmp_img(button_img);
tmp_img.SetPosition(pos[0], pos[1]);
tmp_img.SetColor(sf::Color(col[0], col[1], col[2], 200));
window->Draw(tmp_img);
}