~ubuntu-branches/ubuntu/precise/gnome-games/precise-proposed

« back to all changes in this revision

Viewing changes to glchess/src/lib/ui/ui.py

  • Committer: Package Import Robot
  • Author(s): Rodrigo Moya
  • Date: 2011-05-30 13:32:04 UTC
  • mfrom: (1.3.4)
  • mto: (163.1.3 precise)
  • mto: This revision was merged to the branch mainline in revision 143.
  • Revision ID: package-import@ubuntu.com-20110530133204-celaq1v1dsxc48q1
Tags: upstream-3.0.2
ImportĀ upstreamĀ versionĀ 3.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
"""
3
 
"""
4
 
 
5
 
__author__ = 'Robert Ancell <bob27@users.sourceforge.net>'
6
 
__license__ = 'GNU General Public License Version 2'
7
 
__copyright__ = 'Copyright 2005-2006  Robert Ancell'
8
 
 
9
 
class Player:
10
 
    # Name of the player
11
 
    name = ''
12
 
    
13
 
    # The AI type or '' for human
14
 
    type = ''
15
 
    
16
 
    # The AI difficulty level
17
 
    level = ''
18
 
    
19
 
class Game:
20
 
    name = ''
21
 
    
22
 
    path = None
23
 
    
24
 
    duration = 0
25
 
    
26
 
    allowSpectators = False
27
 
    
28
 
    def __init__(self):
29
 
        self.white = Player()
30
 
        self.black = Player()
31
 
        self.moves = []
32
 
    
33
 
class NetworkFeedback:
34
 
    """Template class for feedback from a network game selector"""
35
 
    
36
 
    def addProfile(self, profile):
37
 
        assert(False)
38
 
    
39
 
    def setProfile(self, profile):
40
 
        assert(False)
41
 
    
42
 
    def joinRoom(self, room):
43
 
        assert(False)
44
 
    
45
 
    def joinTable(self, table):
46
 
        assert(False)
47
 
    
48
 
class NetworkController:
49
 
    """"""
50
 
    
51
 
    def setVisible(self, isVisible):
52
 
        assert(False)
53
 
    
54
 
    def addProfile(self, profile, name):
55
 
        assert(False)
56
 
    
57
 
    def setBusy(self, isBusy):
58
 
        assert(False)
59
 
    
60
 
    def addChat(self, user, channel, text):
61
 
        """Add chat 
62
 
        """
63
 
        assert(False)
64
 
    
65
 
    def addRoom(self, index, name, description, room, protocol):
66
 
        """Add a game room.
67
 
        
68
 
        'index' ???
69
 
        'name' is the name of the room (string).
70
 
        'description' is a description of the room (string).
71
 
        'room' is the room to add (user-defined)
72
 
        'protocol' ???
73
 
        """
74
 
        assert(False)
75
 
 
76
 
    def removeRoom(self, room):
77
 
        assert(False)
78
 
    
79
 
    def clearRooms(self):
80
 
        assert(False)
81
 
    
82
 
    def addTable(self, name, table):
83
 
        assert(False)
84
 
 
85
 
    def removeTable(self, table):
86
 
        assert(False)
87
 
    
88
 
    def clearTables(self):
89
 
        assert(False)
90
 
    
91
 
    def addPlayer(self, player, name, icon):
92
 
        assert(False)
93
 
    
94
 
    def removePlayer(self, player):
95
 
        assert(False)
96
 
    
97
 
    def clearPlayers(self):
98
 
        assert(False)
99
 
 
100
 
    def addAdvert(self, title, rating, advert):
101
 
        """Add a game advert.
102
 
        
103
 
        'title' is the title of the advert (string).
104
 
        'rating' is the rating for this game (string).
105
 
        'advert' is an object to key this advert with (user-defined).
106
 
        """
107
 
        assert(False)
108
 
        
109
 
    def removeAdvert(self, advert):
110
 
        """Remove a game advert.
111
 
        
112
 
        'advert' is an object that was passed into addAdvert().
113
 
        """
114
 
        assert(False)
115
 
    
116
 
    def requestGame(self, gameName):
117
 
        """Request this player joins a game.
118
 
        
119
 
        'gameName' is the name of the game this player requested to join (string).
120
 
        """
121
 
        assert(False)
122
 
    
123
 
class ViewFeedback:
124
 
    """Template class for feedback from a view object"""
125
 
    
126
 
    def showMoveHints(self, showHints):
127
 
        """Configure move hinting.
128
 
        
129
 
        'showHints' sets if move hints should be shown (boolean).
130
 
        """
131
 
        assert(False)
132
 
        
133
 
    def showSmooth(self, doNumbering):
134
 
        pass
135
 
    
136
 
    def saveGame(self, path):
137
 
        """Called when the user requests the game in this view to be saved.
138
 
        
139
 
        'path' is the path to the file to save to (string).
140
 
        
141
 
        Returns the error that occurred (string) or None if successful.
142
 
        """
143
 
        assert(False)
144
 
    
145
 
    def renderGL(self, background_color = (0, 0, 0)):
146
 
        """Render the scene using OpenGL"""
147
 
        assert(False)
148
 
    
149
 
    def renderCairoStatic(self, context, background_color = (0, 0, 0)):
150
 
        """Render the static elements of the scene.
151
 
        
152
 
        'context' is the cairo context to modify.
153
 
        
154
 
        Return False if the static elements have not changed otherwise True.
155
 
        """
156
 
        assert(False)
157
 
    
158
 
    def renderCairoDynamic(self, context):
159
 
        """Render the dynamic elements of the scene.
160
 
        
161
 
        'context' is the cairo context to modify.
162
 
        """
163
 
        assert(False)
164
 
    
165
 
    def reshape(self, width, height):
166
 
        """This method is called when the UI resizes the scene.
167
 
        
168
 
        'width' is the new width of the scene in pixels (integer).
169
 
        'height' is the new height of the scene in pixels (integer).
170
 
        """
171
 
        assert(False)
172
 
    
173
 
    def select(self, x, y):
174
 
        """This method is called when the UI selects a position on the scene.
175
 
        
176
 
        'x' is the horizontal pixel location when the user has selected (integer, 0 = left pixel).
177
 
        'y' is the vertical pixel location when the user has selected (integer, 0 = top pixel).
178
 
        """
179
 
        assert(False)
180
 
    
181
 
    def deselect(self, x, y):
182
 
        """This method is called when the UI deselects a position on the scene.
183
 
        
184
 
        'x' is the horizontal pixel location when the user has selected (integer, 0 = left pixel).
185
 
        'y' is the vertical pixel location when the user has selected (integer, 0 = top pixel).
186
 
        """
187
 
        assert(False)
188
 
    
189
 
    def setMoveNumber(self, moveNumber):
190
 
        """This method is called when the UI changes the move to render.
191
 
        
192
 
        'moveNumber' is the moveNumber to watch (integer, negative numbers index from latest move).
193
 
        """
194
 
        assert(False)
195
 
 
196
 
    def getFileName(self):
197
 
        """Get the file name to save to.
198
 
        
199
 
        Returns the file name (string) or None if game is not saved.
200
 
        """
201
 
        assert(False)
202
 
 
203
 
    def save(self, filename = None):
204
 
        """Save the game using this view.
205
 
        
206
 
        'filename' is the file to save to (string or None to save to last filename).
207
 
        """
208
 
        assert(False)
209
 
        
210
 
    def undo(self):
211
 
        """Indicates the human player wants to undo their last move"""
212
 
        assert(False)
213
 
    
214
 
    def regsign(self):
215
 
        """Indicates the human player wants to resign"""
216
 
        assert(False)
217
 
    
218
 
    def claimDraw(self):
219
 
        """Indicates the human player wants to claim a draw"""
220
 
        assert(False)
221
 
 
222
 
class ViewController:
223
 
    """Template class for methods to control a view"""
224
 
    
225
 
    def setTitle(self, title):
226
 
        """Set the title for this view.
227
 
        
228
 
        'title' is the title to use (string).
229
 
        """
230
 
        assert(False)
231
 
        
232
 
    def setNeedsSaving(self, needsSaving):
233
 
        """Mark if this view needs saving.
234
 
        
235
 
        'needsSaving' True if this view needs saving.
236
 
        """
237
 
        assert(False)
238
 
 
239
 
    def addMove(self, move):
240
 
        """Register a move with this view.
241
 
        
242
 
        'move' is the move made (string).
243
 
        """
244
 
        assert(False)
245
 
        
246
 
    def undoMove(self):
247
 
        """Remove the last move from this view"""
248
 
        assert(False)
249
 
    
250
 
    def render(self):
251
 
        """Request this view is redrawn"""
252
 
        assert(False)
253
 
    
254
 
    def setWhiteTimer(self, total, remaining):
255
 
        """Set the time remaining for the white player.
256
 
        
257
 
        'total' FIXME TODO
258
 
        'remaining' FIXME TODO
259
 
        """
260
 
        assert(False)
261
 
 
262
 
    def setBlackTimer(self, total, remaining):
263
 
        """Set the time remaining for the black player.
264
 
        
265
 
        'total' FIXME TODO
266
 
        'remaining' FIXME TODO
267
 
        """
268
 
        assert(False)
269
 
 
270
 
    def setAttention(self, requiresAttention):
271
 
        """Get the users attention for this view.
272
 
        
273
 
        'requiresAttention' is a flag to show if this view requires attention.
274
 
        """
275
 
        assert(False)
276
 
 
277
 
class UIFeedback:
278
 
    """Template class for feedback from a UI"""
279
 
    
280
 
    def onAnimate(self, timeStep):
281
 
        """Called when an animation tick occurs.
282
 
        
283
 
        'timeStep' is the time between the last call to this method in seconds (float).
284
 
        
285
 
        Return True if animation should continue otherwise False
286
 
        """
287
 
        assert(False)
288
 
 
289
 
    def onReadFileDescriptor(self, fd):
290
 
        """Called when a file descriptor is able to be read.
291
 
        
292
 
        'fd' is the file descriptor with available data to read (integer).
293
 
        
294
 
        Return False when finished otherwise True.
295
 
        """
296
 
        assert(False)
297
 
 
298
 
    def onWriteFileDescriptor(self, fd):
299
 
        """Called when a file descriptor can be written to.
300
 
        
301
 
        'fd' is the file descriptor that can be written to (integer).
302
 
        
303
 
        Return False if writing is completed otherwise True
304
 
        """
305
 
        return False
306
 
    
307
 
    def onGameStart(self, game):
308
 
        """Called when a local game is started.
309
 
        
310
 
        'game' is the game propertied (Game).
311
 
        """
312
 
        assert(False)
313
 
    
314
 
    def loadGame(self, path):
315
 
        """Called when a game is loaded.
316
 
        
317
 
        'path' is the path to the game to load (string).
318
 
        
319
 
        Returns the error that occurred (string) or None if successful.
320
 
        """
321
 
        assert(False)
322
 
 
323
 
    def onNewNetworkGame(self):
324
 
        """
325
 
        """
326
 
        assert(False)
327
 
        
328
 
    def onQuit(self):
329
 
        """Called when the user quits the program"""
330
 
        assert(False)
331
 
    
332
 
class TimerFeedback:
333
 
    """
334
 
    """
335
 
    
336
 
    def onTick(self, time):
337
 
        """Called when the timer hits a one second boundary.
338
 
        
339
 
        'time' is the boundary time in seconds.
340
 
        """
341
 
        assert(False)
342
 
    
343
 
    def onExpired(self):
344
 
        """Called when this timer expires"""
345
 
        assert(False)
346
 
    
347
 
class Timer:
348
 
    """
349
 
    """
350
 
    
351
 
    def getRemaining(self):
352
 
        """Get the amount of time remaining on this clock.
353
 
        
354
 
        returns the amount of time in milliseconds (int)
355
 
        """
356
 
        assert(False)
357
 
       
358
 
    def pause(self):
359
 
        """Stop this timer from counting down"""
360
 
        assert(False)
361
 
    
362
 
    def run(self):
363
 
        """Continue counting down"""
364
 
        assert(False)
365
 
    
366
 
    def delete(self):
367
 
        """Delete this timer"""
368
 
        assert(False)
369
 
    
370
 
class Log:
371
 
    """
372
 
    """
373
 
        
374
 
    def addBinary(self, data, style = None):
375
 
        """
376
 
        """
377
 
        assert(False)
378
 
 
379
 
    def addText(self, text, style = None):
380
 
        """
381
 
        """
382
 
        assert(False)
383
 
    
384
 
    def addLine(self, text, style = None):
385
 
        """
386
 
        """
387
 
        assert(False)
388
 
 
389
 
    def close(self):
390
 
        """
391
 
        """
392
 
        assert(False)
393
 
        
394
 
SAVE_YES   = 'SAVE_YES'
395
 
SAVE_NO    = 'SAVE_NO'
396
 
SAVE_ABORT = 'SAVE_ABORT'
397
 
 
398
 
class UI:
399
 
    """Template class for a glChess UI.
400
 
    """
401
 
    
402
 
    def __init__(self, feedback):
403
 
        """Constructor.
404
 
        
405
 
        'feedback' is the feedback object for this UI to report with (extends UIFeedback).
406
 
        """
407
 
        assert(False)
408
 
    
409
 
    def addLogWindow(self, title, executable, description):
410
 
        assert(False)
411
 
    
412
 
    def startAnimation(self):
413
 
        """Start the animation callback"""
414
 
        assert(False)
415
 
    
416
 
    def watchFileDescriptor(self, fd):
417
 
        """Notify when a file descriptor is able to be read.
418
 
        
419
 
        'fd' is the file descriptor to watch (integer).
420
 
        
421
 
        When data is available onReadFileDescriptor() is called.
422
 
        """
423
 
        assert(False)
424
 
 
425
 
    def unwatchFileDescriptor(self, fd):
426
 
        assert(False)
427
 
        
428
 
    def writeFileDescriptor(self, fd):
429
 
        """Notify when a file descriptor can be written to.
430
 
        
431
 
        'fd' is the file descriptor to write (integer).
432
 
        
433
 
        When data can be written onWriteFileDescriptor is called.
434
 
        """
435
 
        assert(False)
436
 
    
437
 
    def addTimer(self, feedback, duration):
438
 
        """Add a timer.
439
 
        
440
 
        'feedback' is an object containing methods to call for feedback (extends TimerFeedback).
441
 
        'duration' is the period to call this method at in seconds (integer).
442
 
        
443
 
        returns a timer object to control this timer (extends Timer).
444
 
        """
445
 
        assert(False)
446
 
 
447
 
    def setView(self, title, feedback, isPlayable = True):
448
 
        """Set the view to display.
449
 
        
450
 
        'title' is the title for the view (string).
451
 
        'feedback' is a object to report view events with (extends ViewFeedback).
452
 
        'isPlayable' is True if this view can be played.
453
 
        
454
 
        Returns a view controller object (extends ViewController).
455
 
        """
456
 
        assert(False)
457
 
    
458
 
    def addNetworkDialog(self, feedback):
459
 
        """
460
 
        'feedback' is a object to report view events with (extends NetworkFeedback).
461
 
        
462
 
        Returns a network controller object (excends NetworkController).
463
 
        """
464
 
        assert(False)
465
 
    
466
 
    def reportGameLoaded(self, game):
467
 
        """Report a loaded game as required by onGameLoad().
468
 
        
469
 
        'game' is the game properties (Game).
470
 
        """
471
 
        assert(False)
472
 
    
473
 
    def addNetworkGame(self, name, game):
474
 
        """Report a detected network game.
475
 
        
476
 
        'name' is the name of the network game (string).
477
 
        'game' is the game detected (user-defined).
478
 
        """
479
 
        assert(False)
480
 
    
481
 
    def removeNetworkGame(self, game):
482
 
        """Report a network game as terminated.
483
 
        
484
 
        'game' is the game that has removed (as registered with addNetworkGame()).
485
 
        """
486
 
        assert(False)
487
 
    
488
 
    def requestSave(self, title):
489
 
        """Request a game is saved.
490
 
        
491
 
        'title' is the request to make to the user.
492
 
        
493
 
        Returns SAVE_YES, SAVE_NO or SAVE_ABORT.
494
 
        """
495
 
        assert(False)
496
 
        
497
 
    def close(self):
498
 
        """Report the application has ended"""
499
 
        assert(False)