~pyhalebarde/pyhalebarde/theme_cleanup

« back to all changes in this revision

Viewing changes to halebarde/boardwidget.py

  • Committer: Olivier Le Thanh Duong
  • Date: 2009-06-07 16:21:15 UTC
  • mfrom: (173.1.54 refactoring)
  • Revision ID: olivier@lethanh.be-20090607162115-5pnfqsk3vs696opo
Merge with refactoring branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
import clutter
3
3
import gtk
4
4
 
5
 
from globals import Global
6
5
import globals
7
6
from game import Game
 
7
import game
8
8
 
9
9
class Selection:
10
10
    "current thing selected"
116
116
            cr.line_to(x2, y2)
117
117
            cr.stroke()
118
118
 
119
 
        for i in range(-1, Global.TOTAL_WIDTH):
 
119
        for i in range(-1, globals.TOTAL_WIDTH):
120
120
            x1, y1 = self.game_to_screen(i, -1)
121
 
            x2, y2 = self.game_to_screen(i, Global.TOTAL_HEIGH)
 
121
            x2, y2 = self.game_to_screen(i, globals.TOTAL_HEIGHT)
122
122
            draw_line(x1, y1, x2, y2)
123
 
        for i in range(-1, Global.TOTAL_HEIGH):
 
123
        for i in range(-1, globals.TOTAL_HEIGHT):
124
124
            x1, y1 = self.game_to_screen(-1, i)
125
 
            x2, y2 = self.game_to_screen(Global.TOTAL_WIDTH, i)
 
125
            x2, y2 = self.game_to_screen(globals.TOTAL_WIDTH, i)
126
126
            draw_line(x1, y1, x2, y2)
127
127
 
128
128
        cr.set_line_width(2)
137
137
            cr.stroke()
138
138
 
139
139
        # draw the boards
140
 
        draw_rect(*self.game_to_screen(*Global.WHITE_DIM))
141
 
        draw_rect(*self.game_to_screen(*Global.BLACK_DIM))
142
 
        draw_rect(*self.game_to_screen(*Global.BATTLEFIELD_DIM))
 
140
        draw_rect(*self.game_to_screen(*globals.WHITE_DIM))
 
141
        draw_rect(*self.game_to_screen(*globals.BLACK_DIM))
 
142
        draw_rect(*self.game_to_screen(*globals.BATTLEFIELD_DIM))
143
143
 
144
144
        # draw the hills
145
 
        for x, y in Global.HILLS:
146
 
            sx, sy = self.game_to_screen(x+6, y)
 
145
        for x, y in globals.HILLS:
 
146
            sx, sy = self.game_to_screen(x, y)
147
147
            cr.rectangle(sx, sy, self.theme.case, self.theme.case)
148
148
            cr.fill()
149
149
            cr.stroke()
304
304
            # If it's not our turn do nothing
305
305
            return
306
306
 
307
 
        if button == Global.LEFT_MOUSE_BUTTON:
 
307
        if button == globals.LEFT_MOUSE_BUTTON:
308
308
            gx, gy =  self.case_under(position)
309
 
            if self.game.position_is_valid(gx, gy):
 
309
            if globals.position_is_valid(gx, gy):
310
310
                # If we are on a valid case
311
311
                if not self.selected:
312
312
                    # if no unit is selected, grab one
320
320
                        # if it's a valid attack
321
321
                        self.attack_unit(gx, gy)
322
322
 
323
 
        elif button == Global.RIGHT_MOUSE_BUTTON:
 
323
        elif button == globals.RIGHT_MOUSE_BUTTON:
324
324
            if self.selected != None:
325
325
                # if a unit is selected, unselect it
326
326
                self.cancel_selection()