Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
Jeopardy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Hacksaar
Jeopardy
Commits
f7a1b92e
Commit
f7a1b92e
authored
Nov 18, 2015
by
Agrigor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Conditions for Enabling of the start button implemented correctly
parent
bf202ccd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
15 deletions
+23
-15
client/gui.py
client/gui.py
+23
-15
No files found.
client/gui.py
View file @
f7a1b92e
...
...
@@ -19,6 +19,7 @@ from PyQt4.uic import *
PORT
=
50000
IP
=
"127.0.0.1"
PLAYERS_MAX
=
4
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~ CLASS DEFINITION ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
...
@@ -94,6 +95,11 @@ class StartGUI:
self
.
socketCreated
=
socketCreated
self
.
players
=
players
self
.
players_ready
=
[
False
]
*
PLAYERS_MAX
self
.
playerInputs
=
[
self
.
__UI_Start
.
I_NamePlayer1
,
self
.
__UI_Start
.
I_NamePlayer2
,
self
.
__UI_Start
.
I_NamePlayer3
,
self
.
__UI_Start
.
I_NamePlayer4
]
self
.
__UI_Start
.
connect
(
self
.
__UI_Start
.
I_Connect
,
SIGNAL
(
"clicked()"
),
self
.
connect
)
self
.
__UI_Start
.
connect
(
self
.
__UI_Start
.
I_Start
,
SIGNAL
(
"clicked()"
),
self
.
start
)
...
...
@@ -106,29 +112,27 @@ class StartGUI:
self
.
__UI_Start
.
show
()
def
name_player_changed
(
self
,
name
):
sender
=
self
.
__UI_Start
.
sender
()
self
.
__UI_Start
.
O_Msg
.
setText
(
str
(
sender
.
text
()))
# TODO
if
len
(
str
(
sender
.
text
()))
>
1
:
for
i
in
range
(
len
(
self
.
playerInputs
)):
if
i
+
1
>
int
(
self
.
__UI_Start
.
O_NumberOfPlayers
.
text
())
or
len
(
self
.
playerInputs
[
i
].
text
())
>
1
:
self
.
players_ready
[
i
]
=
True
else
:
self
.
players_ready
[
i
]
=
False
if
all
(
self
.
players_ready
):
self
.
__UI_Start
.
I_Start
.
setDisabled
(
False
)
else
:
self
.
__UI_Start
.
I_Start
.
setDisabled
(
True
)
def
show_names_input_field
(
self
,
number
):
number
-=
1
playerInputs
=
[
self
.
__UI_Start
.
I_NamePlayer1
,
self
.
__UI_Start
.
I_NamePlayer2
,
self
.
__UI_Start
.
I_NamePlayer3
,
self
.
__UI_Start
.
I_NamePlayer4
]
for
i
in
range
(
len
(
playerInputs
)):
for
i
in
range
(
len
(
self
.
playerInputs
)):
if
i
<=
number
and
self
.
socketCreated
:
playerInputs
[
i
].
setDisabled
(
False
)
self
.
playerInputs
[
i
].
setDisabled
(
False
)
else
:
playerInputs
[
i
].
setDisabled
(
True
)
self
.
playerInputs
[
i
].
setDisabled
(
True
)
if
number
>=
1
:
self
.
__UI_Start
.
O_Msg
.
setText
(
str
(
number
+
1
)
+
" Players"
)
self
.
show_msg
(
str
(
number
+
1
)
+
" Players"
)
else
:
self
.
__UI_Start
.
O_Msg
.
setText
(
"1 Player"
)
self
.
show_msg
(
"1 Player"
)
def
start
(
self
):
namesOfPlayers
=
[
str
(
self
.
__UI_Start
.
I_NamePlayer1
.
text
()),
...
...
@@ -144,13 +148,17 @@ class StartGUI:
self
.
UDP
.
create_client_socket
()
self
.
socketCreated
=
True
self
.
__UI_Start
.
I_Connect
.
setDisabled
(
True
)
self
.
__UI_Start
.
O_Msg
.
setText
(
"Connected"
)
self
.
__UI_Start
.
I_IPAdress
.
setDisabled
(
True
)
self
.
show_msg
(
"Connected"
)
self
.
__UI_Start
.
I_NumberOfPlayers
.
setDisabled
(
False
)
self
.
__UI_Start
.
I_NamePlayer1
.
setDisabled
(
False
)
else
:
self
.
__UI_Start
.
O_Msg
.
setText
(
"No valid IP-address"
)
self
.
show_msg
(
"No valid IP-address"
)
self
.
socketCreated
=
False
def
show_msg
(
self
,
msg
):
self
.
__UI_Start
.
O_Msg
.
setText
(
msg
)
def
cleanup
(
self
):
if
self
.
socketCreated
:
self
.
UDP
.
cleanup
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment