File: gui.py

package info (click to toggle)
teg 0.11.2%2Bdebian-8
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 12,340 kB
  • sloc: ansic: 17,600; sh: 8,546; python: 1,442; xml: 1,310; makefile: 357
file content (113 lines) | stat: -rw-r--r-- 3,691 bytes parent folder | download | duplicates (4)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
## $Id: gui.py,v 1.4 2003/09/09 21:32:32 riq Exp $
##
## Tenes Empanadas Graciela
##
## Copyright (C) 2000,2003 Ricardo Quesada
##
## Author: Ricardo Calixto Quesada <riq@coresecurity.com>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; only version 2 of the License
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
## 
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.


import pygame

# teg imports
from listeners import *
from controllers import *
from events import *
import model
import map
import toolbar
from ttoolkit import *
import eventmgr
import theme

class GUI( object ):
    def __init__( self ):

        # default size
        self.surface = pygame.display.set_mode( (800,600) )
        pygame.display.set_caption('Tenes Empanadas Graciela')

        # call this before initializing SDL
        self._model = model.Model.getInstance()
        self._display = None

    def initScreen( self ):
#        try:
#            self.surface = pygame.display.set_mode( self._theme['screen']['size'] )
#        except Exception:
#            pass

        # Fill background
        self._background = pygame.Surface(self.surface.get_size())
        self._background = self._background.convert()
        self._background.fill((255, 255, 255))

        self._display = TDisplay( self.surface )
        vbox = TVBoxLayout()
        tb = TToolbar()
        button1 = TButton('Connect', theme.Theme.loadImage('icon_connect.png'))
        button2 = TButton('Start', theme.Theme.loadImage('icon_connect.png'))
        button3 = TButton('Send armies', theme.Theme.loadImage('icon_connect.png'))
        button4 = TButton('1. Regroup', theme.Theme.loadImage('icon_connect.png'))
        button5 = TButton('2. Get card', theme.Theme.loadImage('icon_connect.png'))
        button6 = TButton('3. End turn', theme.Theme.loadImage('icon_connect.png'))
        button7 = TButton('View players', theme.Theme.loadImage('icon_connect.png'))
        tb.addWidget( button1 )
        tb.addWidget( button2 )
        tb.addSeparator()
        tb.addWidget( button3 )
        tb.addWidget( button4 )
        tb.addWidget( button5 )
        tb.addWidget( button6 )
        tb.addSeparator()
        tb.addWidget( button7 )
        theMap = map.Map( self._theme )
        theToolbar = toolbar.Toolbar( self._theme['toolbar'] )
        vbox.addWidget( tb )
        vbox.addWidget( theMap )
        vbox.addWidget( theToolbar )


        self.surface = pygame.display.set_mode( vbox.getSize() )

        self._display.addWidget( vbox )
        self._display.update()


        w = TWindow('Connect to server')
        w.setSize((300,300))
        w.setOrigin((120,120))
        w.update()


    def mainLoop( self ):

        ## XXX: This should be moved to TDisplay
        self._eventMgr = eventmgr.EventMgr()
        # controllers
        self._eventMgr.registerPreController( FPSController() )
        self._eventMgr.registerController( PygameController() )

        # listeners 
        self._eventMgr.registerListener( self._display )

        # post listener
        self._eventMgr.registerPostListener( self._display )

        self._eventMgr.loop()

    def setTheme( self, theme ):
        self._theme = theme