[wpdev-commits] xmlscripts/scripts/wolfpack/commands export.py,1.2,1.3
Brought to you by:
rip,
thiagocorrea
|
From: <dr...@us...> - 2003-10-04 21:35:31
|
Update of /cvsroot/wpdev/xmlscripts/scripts/wolfpack/commands
In directory sc8-pr-cvs1:/tmp/cvs-serv8822
Modified Files:
export.py
Log Message:
Export now works again, def wolfpack twice broke it hehe
Index: export.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/scripts/wolfpack/commands/export.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** export.py 23 Sep 2003 12:17:39 -0000 1.2
--- export.py 4 Oct 2003 21:35:26 -0000 1.3
***************
*** 11,20 ****
from wolfpack.gumps import cGump
! def export( socket, command, arguments ):
socket.sysmessage( "Target the upper left corner of the area you want to export." )
socket.attachtarget( "wolfpack.commands.export.callback", [] )
def onLoad():
! wolfpack.registercommand( "export", export )
def callback( char, args, target ):
--- 11,21 ----
from wolfpack.gumps import cGump
! def exportcmd( socket, command, arguments ):
!
socket.sysmessage( "Target the upper left corner of the area you want to export." )
socket.attachtarget( "wolfpack.commands.export.callback", [] )
def onLoad():
! wolfpack.registercommand( "export", exportcmd )
def callback( char, args, target ):
***************
*** 26,33 ****
socket.sysmessage( "This is an invalid target." )
return
!
socket.sysmessage( "Target the lower right corner of the area you want to export." )
socket.attachtarget( "wolfpack.commands.export.callback", [ target.pos.x, target.pos.y ] )
!
# Lower Right Corner
elif len( args ) == 2:
--- 27,34 ----
socket.sysmessage( "This is an invalid target." )
return
!
socket.sysmessage( "Target the lower right corner of the area you want to export." )
socket.attachtarget( "wolfpack.commands.export.callback", [ target.pos.x, target.pos.y ] )
!
# Lower Right Corner
elif len( args ) == 2:
***************
*** 41,45 ****
y1 = min( args[1], target.pos.y )
y2 = max( args[1], target.pos.y )
!
gump = cGump( x=100, y=100, callback="wolfpack.commands.export.export", args=[ x1, y1, x2, y2 ] )
--- 42,46 ----
y1 = min( args[1], target.pos.y )
y2 = max( args[1], target.pos.y )
!
gump = cGump( x=100, y=100, callback="wolfpack.commands.export.export", args=[ x1, y1, x2, y2 ] )
***************
*** 54,66 ****
gump.addRadioButton( x=20, y=160, off=0x25f8, on=0x25fb, id=1 )
gump.addText( x=55, y=165, text='Sphere 51a', hue=0x835 )
!
gump.addRadioButton( x=150, y=160, off=0x25f8, on=0x25fb, id=2, selected=1 )
gump.addText( x=185, y=165, text='WSC', hue=0x835 )
!
gump.addRadioButton( x=250, y=160, off=0x25f8, on=0x25fb, id=3 )
gump.addText( x=285, y=165, text='Text', hue=0x835 )
# InputField
! gump.addResizeGump( x=20, y=210, id=0xBB8, width=310, height=25 )
gump.addInputField( x=25, y=212, width=295, height=20, hue=0x834, id=1, starttext="export.wsc" )
--- 55,67 ----
gump.addRadioButton( x=20, y=160, off=0x25f8, on=0x25fb, id=1 )
gump.addText( x=55, y=165, text='Sphere 51a', hue=0x835 )
!
gump.addRadioButton( x=150, y=160, off=0x25f8, on=0x25fb, id=2, selected=1 )
gump.addText( x=185, y=165, text='WSC', hue=0x835 )
!
gump.addRadioButton( x=250, y=160, off=0x25f8, on=0x25fb, id=3 )
gump.addText( x=285, y=165, text='Text', hue=0x835 )
# InputField
! gump.addResizeGump( x=20, y=210, id=0xBB8, width=310, height=25 )
gump.addInputField( x=25, y=212, width=295, height=20, hue=0x834, id=1, starttext="export.wsc" )
***************
*** 69,89 ****
gump.send( char )
!
def export( char, args, choice ):
if choice.button != 1 or len( args ) != 4:
! return
!
filename = choice.text[1]
!
if len( choice.switches ) != 1:
char.socket.sysmessage( "Error: len(choice.switches) != 1." )
! return
!
format = choice.switches[0]
if len( filename ) == 0:
char.socket.sysmessage( "Error: You need to provide a valid filename." )
! return
!
# Open the output file
output = open( filename, "wb" ) # Note that we *force* the output to have lines terminated with \n\r
--- 70,90 ----
gump.send( char )
!
def export( char, args, choice ):
if choice.button != 1 or len( args ) != 4:
! return 1
!
filename = choice.text[1]
!
if len( choice.switches ) != 1:
char.socket.sysmessage( "Error: len(choice.switches) != 1." )
! return 1
!
format = choice.switches[0]
if len( filename ) == 0:
char.socket.sysmessage( "Error: You need to provide a valid filename." )
! return 1
!
# Open the output file
output = open( filename, "wb" ) # Note that we *force* the output to have lines terminated with \n\r
***************
*** 104,108 ****
output.write( "COLOR=0%x\r\n" % item.color )
output.write( "P=%d,%d,%i\r\n\r\n" % ( item.pos.x, item.pos.y, item.pos.z ) )
!
elif format == 2: # WSC
output.write( "SECTION WORLDITEM %d\r\n{\r\n" % i )
--- 105,109 ----
output.write( "COLOR=0%x\r\n" % item.color )
output.write( "P=%d,%d,%i\r\n\r\n" % ( item.pos.x, item.pos.y, item.pos.z ) )
!
elif format == 2: # WSC
output.write( "SECTION WORLDITEM %d\r\n{\r\n" % i )
***************
*** 115,122 ****
output.write( "Z %i\r\n" % item.pos.z )
output.write( "CONT -1\r\nTYPE 0\r\n" )
! output.write( "AMOUNT %d\r\n" % item.amount )
output.write( "COLOR %d\r\n" % item.color )
! output.write( "}\r\n\r\n" )
!
else: # Text
output.write( "0x%x %d %d %i 0x%x\r\n" % ( item.id, item.pos.x, item.pos.y, item.pos.z, item.color ) )
--- 116,123 ----
output.write( "Z %i\r\n" % item.pos.z )
output.write( "CONT -1\r\nTYPE 0\r\n" )
! output.write( "AMOUNT %d\r\n" % item.amount )
output.write( "COLOR %d\r\n" % item.color )
! output.write( "}\r\n\r\n" )
!
else: # Text
output.write( "0x%x %d %d %i 0x%x\r\n" % ( item.id, item.pos.x, item.pos.y, item.pos.z, item.color ) )
***************
*** 142,146 ****
gump = cGump( x=100, y=100 )
! gump.addBackground( id=0x2436, width=350, height=300 )
#gump.addCheckerTrans( 15, 15, 320, 270 )
--- 143,147 ----
gump = cGump( x=100, y=100 )
! gump.addBackground( id=0x2436, width=350, height=300 )
#gump.addCheckerTrans( 15, 15, 320, 270 )
|