Skip to content
Snippets Groups Projects
Commit 8f2c211c authored by Papp Benjámin's avatar Papp Benjámin
Browse files

egér javítás

parent 86f09ccc
Branches
No related tags found
No related merge requests found
......@@ -8,10 +8,14 @@ using namespace genv;
Mester::Mester(Palya* _p) : p(_p) {}
void Mester::iranyitas(Palyamezo* f, event ev) {
if(f->hozzaer(ev) && !f->filled)
if(f->hozzaer(ev) && !f->filled && !f->chosen){
f->chosen_draw();
if(!f->hozzaer(ev) && !f->filled)
f->set_chosen();
}
if(!f->hozzaer(ev) && !f->filled && f->chosen){
f->draw();
f->reset_chosen();
}
if(f->select(ev) && !f->filled)
lepes = true;
}
......
......@@ -12,10 +12,19 @@ void Palyamezo::draw(){
gout << move_to(x+1,y+1) << color(t,t,t) << box(w-2,h-2);
}
void Palyamezo::chosen_draw()
{
void Palyamezo::chosen_draw(){
int t = 175;
gout << move_to(x+1,y+1) << color(t,t,t) << box(w-2,h-2);
}
void Palyamezo::set_chosen(){
if(!chosen)
chosen = true;
}
void Palyamezo::reset_chosen(){
if(chosen)
chosen = false;
}
Palyamezo::~Palyamezo() {}
......@@ -12,6 +12,9 @@ public:
void draw() override;
void chosen_draw();
bool filled = false;
bool chosen = false;
void set_chosen();
void reset_chosen();
};
#endif // PALYAMEZO_H
......@@ -2,18 +2,16 @@
using namespace genv;
Widget::Widget(Palya* _p, int _x, int _y, int _w, int _h) : p(_p), x(_x), y(_y), w(_w), h(_h){}
Widget::Widget(Palya* _p, int _x, int _y, int _w, int _h) : p(_p), x(_x), y(_y), w(_w), h(_h) {}
bool Widget::hozzaer(event ev)
{
bool Widget::hozzaer(event ev){
if(ev.pos_x > x && ev.pos_x < x+w && ev.pos_y < y+h && ev.pos_y > y)
return true;
else
return false;
}
bool Widget::select(event ev)
{
bool Widget::select(event ev){
if(hozzaer(ev) && ev.button==btn_left)
return true;
if(!hozzaer(ev) && ev.button==btn_left)
......
......@@ -4,7 +4,8 @@
class Palya;
class Widget{
class Widget
{
protected:
int x,y,w,h;
Palya* p;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment