[wpdev-commits] xmlscripts/scripts/wolfpack gumps.py,1.9,1.10
Brought to you by:
rip,
thiagocorrea
|
From: <thi...@us...> - 2003-08-28 04:07:04
|
Update of /cvsroot/wpdev/xmlscripts/scripts/wolfpack
In directory sc8-pr-cvs1:/tmp/cvs-serv15992/wolfpack
Modified Files:
gumps.py
Log Message:
added WarningGump
Index: gumps.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/scripts/wolfpack/gumps.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** gumps.py 17 Jun 2003 20:55:55 -0000 1.9
--- gumps.py 28 Aug 2003 04:07:01 -0000 1.10
***************
*** 33,36 ****
--- 33,38 ----
elif type( char ).__name__ == "wpsocket":
socket = char
+ else:
+ raise TypeError( "You passed an invalid socket." )
# Dump the gump data
***************
*** 53,60 ****
self.layout.insert( 0, '{ nomove }' )
! if not socket:
! raise TypeError( "You passed an invalid socket." )
! else:
! socket.sendgump( self.x, self.y, 0, 0, 0, self.serialid, self.typeid, self.layout, self.texts, self.callback, self.args )
# For "rawly" modifying the list
--- 55,59 ----
self.layout.insert( 0, '{ nomove }' )
! socket.sendgump( self.x, self.y, 0, 0, 0, self.serialid, self.typeid, self.layout, self.texts, self.callback, self.args )
# For "rawly" modifying the list
***************
*** 191,192 ****
--- 190,248 ----
def add( self, line ):
self.layout.append( line )
+
+
+
+ class WarningGump:
+
+ def __init__(self, header, headerColor, content, contentColor, width, height, callback, state ):
+ self.callback = callback
+ self.state = state
+
+ self.gump = cGump( 1, 0, 0, (640 - width) / 2, (480 - height) / 2 )
+ self.gump.startPage( 0 )
+ self.gump.addBackground( 5054, width, height )
+ self.gump.addTiledGump( 10, 10, width - 20, 20, 2624 )
+ self.gump.addCheckerTrans( 10, 10, width - 20, 20 )
+ self.gump.addXmfHtmlGump( 10, 10, width - 20, 20, header, 0, 0, headerColor )
+ self.gump.addTiledGump( 10, 40, width - 20, height - 80, 2624 )
+ self.gump.addCheckerTrans( 10, 40, width - 20, height - 80 )
+ if type( content ) is IntType:
+ self.gump.addXmfHtmlGump( 10, 40, width - 20, height - 80, content, 0, 1, contentColor )
+ else:
+ self.gump.addHtmlGump( 10, 40, width - 20, height - 80, "<BASEFONT COLOR=#%x>%s</BASEFONT>" % ( contentColor, content ), 0, 1 )
+
+ self.gump.addTiledGump( 10, height - 30, width - 20, 20, 2624 )
+ self.gump.addCheckerTrans( 10, height - 30, width - 20, 20 )
+ self.gump.addButton( 10, height - 30, 4005, 4007, 1 )
+ self.gump.addXmfHtmlGump( 40, height - 30, 170, 20, 1011036, 0, 0, 32767 )
+
+ self.gump.addButton( 10 + ((width - 20) / 2), height - 30, 4005, 4007, 0 )
+ self.gump.addXmfHtmlGump( 40 + ((width - 20) / 2), height - 30, 170, 20, 1011012, 0, 0, 32767 )
+
+ # set the callback
+
+ def send( self, char ) :
+ # There are two possibilities
+ socket = None
+
+ if type( char ).__name__ == "wpchar":
+ socket = char.socket
+ elif type( char ).__name__ == "wpsocket":
+ socket = char
+ else:
+ raise TypeError( "You passed an invalid socket." )
+
+ self.gump.setArgs([self.callback, self.state])
+ self.gump.setCallback("wolfpack.gumps.WarningGump_onResponse")
+ self.gump.send( socket )
+
+
+
+ def WarningGump_onResponse( player, args, choice ):
+ socket = player.socket
+ callback = args[0]
+ state = args[1]
+ if choice.button == 0 or not callback or not socket:
+ callback( player, False, state )
+ if choice.button == 1:
+ callback( player, True, state )
|