1 | #!/usr/bin/env python |
---|
2 | # -*- coding: utf-8 -*- |
---|
3 | # |
---|
4 | # Puzzlebox - Brainstorms - Client Interface - Network |
---|
5 | # |
---|
6 | # Copyright Puzzlebox Productions, LLC (2010) |
---|
7 | # |
---|
8 | # This code is released under the GNU Pulic License (GPL) version 2 |
---|
9 | # For more information please refer to http://www.gnu.org/copyleft/gpl.html |
---|
10 | # |
---|
11 | # Last Update: 2010.06.10 |
---|
12 | # |
---|
13 | ##################################################################### |
---|
14 | |
---|
15 | import os, sys |
---|
16 | |
---|
17 | import pygame |
---|
18 | #import pygame.font |
---|
19 | import pygame.image |
---|
20 | import pygame.locals |
---|
21 | |
---|
22 | from twisted.internet import reactor, protocol, defer |
---|
23 | |
---|
24 | import puzzlebox_brainstorms_configuration as configuration |
---|
25 | import puzzlebox_brainstorms_client_interface as client_interface |
---|
26 | #import puzzlebox_logger |
---|
27 | |
---|
28 | ##################################################################### |
---|
29 | # Globals |
---|
30 | ##################################################################### |
---|
31 | |
---|
32 | DEBUG = 1 |
---|
33 | |
---|
34 | SERVER_HOST = configuration.SERVER_HOST |
---|
35 | SERVER_PORT = configuration.SERVER_PORT |
---|
36 | |
---|
37 | DISPLAY_WINDOW_X_COORDINATE = configuration.DISPLAY_WINDOW_X_COORDINATE |
---|
38 | DISPLAY_WINDOW_Y_COORDINATE = configuration.DISPLAY_WINDOW_Y_COORDINATE |
---|
39 | DISPLAY_WINDOW_X_DIMENSION = configuration.DISPLAY_WINDOW_X_DIMENSION |
---|
40 | DISPLAY_WINDOW_Y_DIMENSION = configuration.DISPLAY_WINDOW_Y_DIMENSION |
---|
41 | |
---|
42 | WINDOW_BACKGROUND_COLOR = configuration.WINDOW_BACKGROUND_COLOR |
---|
43 | |
---|
44 | ##################################################################### |
---|
45 | # Classes |
---|
46 | ##################################################################### |
---|
47 | |
---|
48 | ##################################################################### |
---|
49 | # Functions |
---|
50 | ##################################################################### |
---|
51 | |
---|
52 | ##################################################################### |
---|
53 | # Main |
---|
54 | ##################################################################### |
---|
55 | |
---|
56 | if __name__ == '__main__': |
---|
57 | |
---|
58 | #log = puzzlebox_logger.puzzlebox_logger(logfile='mcc') |
---|
59 | log = None |
---|
60 | |
---|
61 | |
---|
62 | # Collect default settings and command line parameters |
---|
63 | server_host = SERVER_HOST |
---|
64 | server_port = SERVER_PORT |
---|
65 | display_window_x_coordinate = DISPLAY_WINDOW_X_COORDINATE |
---|
66 | display_window_y_coordinate = DISPLAY_WINDOW_Y_COORDINATE |
---|
67 | display_window_x_dimension = DISPLAY_WINDOW_X_DIMENSION |
---|
68 | display_window_y_dimension = DISPLAY_WINDOW_Y_DIMENSION |
---|
69 | window_background_color = WINDOW_BACKGROUND_COLOR |
---|
70 | |
---|
71 | |
---|
72 | for each in sys.argv: |
---|
73 | |
---|
74 | if each.startswith("--host="): |
---|
75 | server_host = each[ len("--host="): ] |
---|
76 | if each.startswith("--port="): |
---|
77 | server_port = each[ len("--port="): ] |
---|
78 | |
---|
79 | |
---|
80 | # Window Defaults |
---|
81 | try: |
---|
82 | display_window_x_coordinate = string.atoi(sys.argv[-4]) |
---|
83 | display_window_y_coordinate = string.atoi(sys.argv[-3]) |
---|
84 | display_window_x_dimension = string.atoi(sys.argv[-2]) |
---|
85 | display_window_y_dimension = string.atoi(sys.argv[-1]) |
---|
86 | except: |
---|
87 | if DEBUG > 1: |
---|
88 | print "Using default display coordinates" |
---|
89 | |
---|
90 | |
---|
91 | interface = client_interface.puzzlebox_brainstorms_client_interface( \ |
---|
92 | log, \ |
---|
93 | display_window_x_coordinate, \ |
---|
94 | display_window_y_coordinate, \ |
---|
95 | display_window_x_dimension, \ |
---|
96 | display_window_y_dimension, \ |
---|
97 | window_background_color, \ |
---|
98 | DEBUG=DEBUG) |
---|
99 | |
---|
100 | reactor.callWhenRunning(interface.check_events) |
---|
101 | |
---|
102 | |
---|
103 | reactor.run() |
---|
104 | |
---|