Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
harmadik
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hamar János
harmadik
Commits
cfcb8462
Commit
cfcb8462
authored
1 year ago
by
Hamar János
Browse files
Options
Downloads
Patches
Plain Diff
gyalog beváltás
parent
31aa1168
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dropdown.cpp
+65
-65
65 additions, 65 deletions
dropdown.cpp
main.cpp
+5
-2
5 additions, 2 deletions
main.cpp
pawn.cpp
+13
-10
13 additions, 10 deletions
pawn.cpp
with
83 additions
and
77 deletions
dropdown.cpp
+
65
−
65
View file @
cfcb8462
...
...
@@ -13,7 +13,7 @@ Dropdown::Dropdown(int x, int y, int extentx, int extenty, vector<string> option
_extentx
=
extentx
;
_extenty
=
extenty
;
_mod
=
1
;
_number
=
0
;
_number
=
-
1
;
_scroll
=
0
;
}
...
...
@@ -30,103 +30,103 @@ void Dropdown::image()
void
Dropdown
::
operate
(
event
ev
)
{
gout
<<
move_to
(
_x
,
_y
)
<<
color
(
128
,
128
,
128
)
<<
box
(
_extentx
,
_extenty
)
<<
move_to
(
_x
,
_y
+
_extenty
*
0.8
)
<<
color
(
255
,
255
,
255
)
<<
text
(
_options
[
_number
]);
gout
<<
move_to
(
_x
+
_extentx
-
_extenty
+
3
,
_y
+
3
)
<<
color
(
255
,
255
,
255
)
<<
box
(
_extenty
-
6
,
_extenty
-
6
);
if
(
ev
.
type
==
ev_key
&&
ev
.
keycode
==
key_down
)
bool
run
=
true
;
while
(
gin
>>
ev
&&
run
)
{
if
(
_scroll
!=
_options
.
size
()
-
_limit
+
1
)
// Drawing dropdown items
for
(
int
i
=
0
;
i
<
4
;
++
i
)
{
int
y_offset
=
_y
+
(
i
*
(
_extenty
+
5
));
gout
<<
move_to
(
_x
,
y_offset
)
<<
color
(
128
,
128
,
128
)
<<
box
(
_extentx
,
_extenty
);
gout
<<
move_to
(
_x
,
y_offset
+
_extenty
*
0.8
)
<<
color
(
255
,
255
,
255
)
<<
text
(
_options
[
i
]);
}
gout
<<
refresh
;
// Event handling
if
(
ev
.
type
==
ev_mouse
&&
ev
.
button
==
btn_left
)
{
_scroll
+=
1
;
cout
<<
"Mouse clicked at: "
<<
ev
.
pos_x
<<
" , "
<<
ev
.
pos_y
<<
endl
;
for
(
int
i
=
0
;
i
<
4
;
++
i
)
{
int
y_offset
=
_y
+
(
i
*
(
_extenty
+
5
));
if
(
ev
.
pos_x
>=
_x
&&
ev
.
pos_x
<=
_x
+
_extentx
&&
ev
.
pos_y
>=
y_offset
&&
ev
.
pos_y
<=
y_offset
+
_extenty
)
{
cout
<<
"Option "
<<
i
<<
" clicked"
<<
endl
;
// Debug print
_number
=
i
;
run
=
false
;
// Set run to false to exit the loop
break
;
// Break the loop as we found the clicked option
}
}
}
}
if
(
ev
.
type
==
ev_key
&&
ev
.
keycode
==
key_up
)
{
if
(
_scroll
>
0
)
if
(
_number
!=
-
1
)
{
_scroll
-=
1
;
run
=
false
;
break
;
}
}
int
szam
=
_scroll
;
for
(
int
i
=
_y
+
_extenty
+
2
;
i
<
_y
+
_limit
*
(
_extenty
+
2
);
i
+=
_extenty
+
2
)
/*
bool run = true;
while (gin >> ev and run)
{
gout
<<
color
(
128
,
128
,
128
);
if
(
ev
.
pos_x
>=
_x
and
ev
.
pos_x
<=
_x
+
_extentx
)
// Drawing dropdown items
for (int i = 0; i < 4; ++i) {
int y_offset = _y + (i * (_extenty + 5));
gout << move_to(_x, y_offset) << color(128, 128, 128) << box(_extentx, _extenty);
gout << move_to(_x, y_offset + _extenty * 0.8) << color(255, 255, 255) << text(_options[i]);
}
gout << refresh;
// Event handling
if (ev.type == ev_mouse && ev.button == btn_left)
{
if
(
ev
.
pos_y
>=
i
and
ev
.
pos_y
<=
i
+
_extenty
)
cout << "Mouse clicked at: " << ev.pos_x << " , " << ev.pos_y << endl;
for (int i = 0; i < 4; ++i)
{
gout
<<
color
(
50
,
50
,
50
);
int y_offset = _y + (i * (_extenty + 5));
if (ev.pos_x >= _x && ev.pos_x <= _x + _extentx &&
ev.pos_y >= y_offset && ev.pos_y <= y_offset + _extenty)
{
_number = i;
run = false;
break;
}
}
}
gout
<<
move_to
(
_x
,
i
)
<<
box
(
_extentx
,
_extenty
);
gout
<<
move_to
(
_x
+
5
,
i
+
_extenty
*
0.7
)
<<
color
(
255
,
255
,
255
)
<<
text
(
_options
[
szam
]);
szam
+=
1
;
}
gout
<<
refresh
;
*/
}
void
Dropdown
::
reset
(
event
ev
)
{
gout
<<
move_to
(
_x
,
_y
)
<<
color
(
0
,
0
,
0
)
<<
box
((
_extentx
),
(
_extenty
+
3
)
*
5
);
image
();
cout
<<
_number
<<
"igazsag asd"
<<
endl
;
if
(
_mod
==
2
)
{
int
szam
=
_scroll
;
for
(
int
i
=
_y
+
_extenty
+
2
;
i
<
_y
+
_limit
*
(
_extenty
+
2
);
i
+=
_extenty
+
2
)
{
if
(
ev
.
pos_x
>=
_x
and
ev
.
pos_x
<=
_x
+
_extentx
)
if
(
ev
.
type
==
ev_mouse
&&
ev
.
button
==
btn_left
)
{
if
(
ev
.
pos_
y
>=
i
and
ev
.
pos_
y
<=
i
+
_extent
y
)
if
(
ev
.
pos_
x
>=
_x
and
ev
.
pos_
x
<=
_x
+
_extent
x
)
{
_number
=
szam
;
break
;
if
(
ev
.
pos_y
>=
i
and
ev
.
pos_y
<=
i
+
_extenty
)
{
_number
=
szam
;
cout
<<
_number
<<
"igazsag"
<<
endl
;
break
;
}
}
}
szam
+=
1
;
}
}
image
();
}
bool
Dropdown
::
is_chosen
(
int
mx
,
int
my
,
event
ev
)
{
switch
(
_mod
)
{
case
1
:
if
(
mx
>=
(
_x
+
_extentx
-
_extenty
)
and
mx
<=
(
_x
+
_extentx
-
3
))
{
if
(
my
>=
_y
+
3
and
my
<=
_y
+
_extenty
-
3
)
{
_mod
=
2
;
return
true
;
}
reset
(
ev
);
return
false
;
}
reset
(
ev
);
return
false
;
break
;
case
2
:
if
(
mx
>=
_x
and
mx
<=
_x
+
_extentx
)
{
if
(
my
>=
_y
+
_extenty
+
3
and
my
<=
(
_y
+
_extenty
+
3
)
*
4
)
{
reset
(
ev
);
_mod
=
1
;
return
false
;
}
_mod
=
1
;
reset
(
ev
);
return
false
;
}
_mod
=
1
;
reset
(
ev
);
return
false
;
break
;
default
:
_mod
=
1
;
reset
(
ev
);
return
false
;
break
;
}
return
false
;
}
This diff is collapsed.
Click to expand it.
main.cpp
+
5
−
2
View file @
cfcb8462
...
...
@@ -23,8 +23,8 @@ public:
void
init_pieces
()
{
// Fehér bábuk inicializálása
/*
r1_1 = new Rook(this, 0, 0, true);
kn1_1 = new Knight(this, 80, 0, true);
b1_1 = new Bishop(this, 160, 0, true);
k1 = new King(this, 240, 0, true);
...
...
@@ -32,6 +32,7 @@ public:
b1_2 = new Bishop(this, 400, 0, true);
kn1_2 = new Knight(this, 480, 0, true);
r1_2 = new Rook(this, 560, 0, true);
*/
p1_1
=
new
Pawn
(
this
,
0
,
80
,
true
);
p1_2
=
new
Pawn
(
this
,
80
,
80
,
true
);
p1_3
=
new
Pawn
(
this
,
160
,
80
,
true
);
...
...
@@ -40,9 +41,10 @@ public:
p1_6
=
new
Pawn
(
this
,
400
,
80
,
true
);
p1_7
=
new
Pawn
(
this
,
480
,
80
,
true
);
p1_8
=
new
Pawn
(
this
,
560
,
80
,
true
);
p1_8
=
new
Pawn
(
this
,
560
,
150
,
true
);
// Fekete bábuk inicializálása
/*
r2_1 = new Rook(this, 0, 560, false);
kn2_1 = new Knight(this, 80, 560, false);
b2_1 = new Bishop(this, 160, 560, false);
...
...
@@ -51,6 +53,7 @@ public:
b2_2 = new Bishop(this, 400, 560, false);
kn2_2 = new Knight(this, 480, 560, false);
r2_2 = new Rook(this, 560, 560, false);
*/
p2_1
=
new
Pawn
(
this
,
0
,
480
,
false
);
p2_2
=
new
Pawn
(
this
,
80
,
480
,
false
);
p2_3
=
new
Pawn
(
this
,
160
,
480
,
false
);
...
...
This diff is collapsed.
Click to expand it.
pawn.cpp
+
13
−
10
View file @
cfcb8462
...
...
@@ -427,18 +427,22 @@
}
}
}
if
((
_color
&&
_y
==
560
)
||
(
!
_color
&&
_y
==
0
))
{
cout
<<
'1'
<<
endl
;
event
ev1
;
vector
<
string
>
options
=
{
"Queen"
,
"Rook"
,
"Bishop"
,
"Knight"
};
// A választható opciók listája
Dropdown
Dropdown
(
100
,
100
,
100
,
30
,
options
,
4
);
// Létrehozzuk a Dropdown objektumot
while
(
true
)
{
// A ciklus addig fut, amíg valamilyen választás nem történik
//mukodik de nem elég simán fut
if
((
_color
&&
_y
==
560
)
||
(
!
_color
&&
_y
==
0
))
{
vector
<
string
>
options
=
{
"Queen"
,
"Rook"
,
"Bishop"
,
"Knight"
};
Dropdown
Dropdown
(
100
,
100
,
100
,
30
,
options
,
5
);
while
(
true
)
{
event
ev_dropdown
;
gin
>>
ev_dropdown
;
Dropdown
.
operate
(
ev_dropdown
);
// Kezeljük az eseményeket a dropdown menüben
Dropdown
.
operate
(
ev_dropdown
);
if
(
ev_dropdown
.
type
==
ev_mouse
&&
ev_dropdown
.
button
==
btn_left
)
{
break
;
}
}
cout
<<
Dropdown
.
ret
()
<<
" szam "
<<
endl
;
reset
(
run
)
;
switch
(
Dropdown
.
ret
())
{
case
0
:
...
...
@@ -468,7 +472,6 @@
default
:
break
;
}
}
gout
<<
refresh
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment