"SfR Fresh" - the SfR Freeware/Shareware Archive

Member "OpenVerse/lib/AvEd.tcl" of archive OpenVerse-0.8-7.tar.gz:


As a special service "SfR Fresh" has tried to format the requested source page into HTML format using (guessed) Tcl/Tk source code syntax highlighting with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
    1 # OpenVerse Avatar Editor
    2 #
    3 # This file contains all the functions for AvEd
    4 # The OpenVerse avatar editor.
    5 #
    6 # Module Name		- Avitar Editor Module
    7 # Current Maintainter 	- Cruise <cruise@openverse.org>
    8 # Sourced By		- InitMainWindow
    9 #
   10 # Copyright (C) 1999 David Gale <cruise@openverse.org>
   11 # For more information visit http://OpenVerse.org/
   12 #
   13 # This program is free software; you can redistribute it and/or
   14 # modify it under the terms of the GNU General Public License
   15 # as published by the Free Software Foundation; either version 2
   16 # of the License, or (at your option) any later version.
   17 #
   18 # This program is distributed in the hope that it will be useful,
   19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
   20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   21 # GNU General Public License for more details.
   22 #
   23 # You should have received a copy of the GNU General Public License
   24 # along with this program; if not, write to the Free Software
   25 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
   26 # USA.
   27 
   28 # Additional Notes
   29 #
   30 # Implemented string compare functions which show to increase performance.
   31 # Implemented more performance things surrounging functions with braces.
   32 # Now uses translator. (06/27/00 - CRUISE)
   33 proc AvEd {} {
   34 	global MV AE
   35 
   36 	if {[winfo exists .aved]} {destroy .aved}
   37 
   38 	set AE(animate) 0
   39 	set AE(loaded) 0
   40 	set AE(name_baloon) 0
   41 	set AE(color) 1
   42 	set AE(existing) 0
   43 	set AE(images) {}
   44 	set AE(name_x) 0
   45 	set AE(name_y) 40
   46 	set AE(baloon_x) 20
   47 	set AE(baloon_y) 0
   48 	set AE(delay.img) 200
   49 	set AE(delay.final) 8000
   50 	toplevel .aved
   51 	wm title .aved [Trns openverse_avatar_editor]
   52 	wm resizable . 0 0
   53 
   54 	frame .aved.col
   55 	radiobutton .aved.col.black -text [Trns black] -variable AE(color) -value 1 -command AvEd_ChangeColor
   56 	radiobutton .aved.col.white -text [Trns white] -variable AE(color) -value 2 -command AvEd_ChangeColor
   57 	radiobutton .aved.col.blue -text [Trns blue] -variable AE(color) -value 3 -command AvEd_ChangeColor
   58 	canvas .aved.c -height 200.0 -width 320.0 -relief sunken \
   59 		-background black
   60 	frame .aved.b -relief sunken
   61 	frame .aved.bb -relief sunken
   62 	frame .aved.bbbb -relief sunken
   63 	frame .aved.bbb -relief sunken
   64 	frame .aved.b.l
   65 	frame .aved.b.r
   66 	frame .aved.b.l.a
   67 	frame .aved.b.l.b
   68 	frame .aved.b.l.c
   69 	frame .aved.b.l.d
   70 	button .aved.b.l.b.7 -text [Trns balloon] -command "AvEd_NameBaloon"
   71 	button .aved.b.l.b.8 -text [Trns up] -command "AvEd_Pos 8"
   72 	button .aved.b.l.b.9 -text [Trns name] -command "AvEd_NameBaloon"
   73 	button .aved.b.l.c.4 -text [Trns left] -command "AvEd_Pos 4"
   74 	frame .aved.b.l.c.5
   75 	button .aved.b.l.c.5.t -text [Trns select_image] -borderwidth 2 \
   76 		-command "AvEd_PickImage 0"
   77 	menubutton .aved.b.l.c.5.b -text [Trns load_existing] \
   78 		-menu .aved.b.l.c.5.b.m -relief raised -borderwidth 2
   79 	menu .aved.b.l.c.5.b.m
   80 	button .aved.b.l.c.6 -text [Trns right] -command "AvEd_Pos 6"
   81 	button .aved.b.l.d.1 -text [Trns play] -command "AvEd_AnimateAvatar 1"
   82 	button .aved.b.l.d.2 -text [Trns down] -command "AvEd_Pos 2"
   83 	button .aved.b.l.d.3 -text [Trns stop] -command "AvEd_AnimateAvatar 0"
   84 
   85 	frame .aved.b.r.cmds -relief sunken -borderwidth 2
   86 	button .aved.b.r.cmds.save -text [Trns save] -command "AvEd_Save"
   87 	checkbutton .aved.b.r.cmds.anim -text [Trns animated] \
   88 		-variable AE(animate) \
   89 		-command AvEd_Animated -relief raised -borderwidth 2
   90 	button .aved.b.r.cmds.add -text [Trns add_image] \
   91 		-command "AvEd_PickImage 1" -borderwidth 2
   92 	button .aved.b.r.cmds.quit -text [Trns quit] -command {destroy .aved}
   93 
   94 	frame .aved.bb.files
   95 	frame .aved.bb.files.l
   96 	listbox .aved.bb.files.l.list -height 6 -width 40 \
   97 		-yscrollcommand ".aved.bb.files.l.yscroll set" \
   98 		-xscrollcommand ".aved.bb.files.xscroll set"
   99 	scrollbar .aved.bb.files.l.yscroll -command ".aved.bb.files.l.list yview"
  100 	scrollbar .aved.bb.files.xscroll -command ".aved.bb.files.l.list \
  101 		 xview" -orient horizontal
  102 
  103 	button .aved.bbbb.del -text [Trns delete_selected] -command "AvEd_DeleteOne"
  104 
  105 	frame .aved.bbb.delays
  106 	scale .aved.bbb.delays.img -from 1 -to 10000 -label [Trns sequence_delay] \
  107 		-variable AE(delay.img) -orient horizontal -relief raised \
  108 		-borderwidth 2
  109 	scale .aved.bbb.delays.fin -from 1 -to 10000 -label [Trns final_delay] \
  110 		-variable AE(delay.final) -orient horizontal -relief raised \
  111 		-borderwidth 2
  112 
  113 	pack .aved.col -side top
  114 	pack .aved.col.black .aved.col.white .aved.col.blue -side left -fill both -expand y
  115 	pack .aved.c -side top
  116 	pack .aved.bbb -side bottom -fill both -expand y
  117 	pack .aved.bbbb -side bottom -fill both -expand y
  118 	pack .aved.bb -side bottom -fill both -expand y
  119 	pack .aved.b -side bottom -fill both -expand y
  120 	pack .aved.b.l -side left -fill y
  121 	pack .aved.b.r -side left -fill both -expand y
  122 	pack .aved.b.l.a -fill x -expand y
  123 	pack .aved.b.l.b -fill x -expand y
  124 	pack .aved.b.l.c -fill x -expand y
  125 	pack .aved.b.l.d -fill x -expand y
  126 	pack .aved.b.l.b.7 .aved.b.l.b.8 .aved.b.l.b.9 -side left -fill both -expand y
  127 	pack .aved.b.l.c.4 .aved.b.l.c.5 .aved.b.l.c.6 -side left -fill both -expand y
  128 	pack .aved.b.l.d.1 .aved.b.l.d.2 .aved.b.l.d.3 -side left -fill both -expand y
  129 	pack .aved.b.l.c.5.t -side top -fill both -expand y
  130 	pack .aved.b.l.c.5.b -side bottom -fill both -expand y
  131 
  132 	pack .aved.b.r.cmds -side left -fill both -expand y
  133 	pack .aved.b.r.cmds.save -fill both -expand y
  134 	pack .aved.b.r.cmds.anim -fill both -expand y
  135 	pack .aved.b.r.cmds.add -fill both -expand y
  136 	pack .aved.b.r.cmds.quit -fill both -expand y
  137 
  138 	pack .aved.bb.files -side bottom -fill both -expand y
  139 	pack .aved.bb.files.xscroll -side top -fill x -expand y
  140 	pack .aved.bb.files.l -fill both -expand y
  141 	pack .aved.bb.files.l.list -side left -fill both -expand y
  142 	pack .aved.bb.files.l.yscroll -side left -fill y -expand y
  143 
  144 	pack .aved.bbb.delays -fill both -expand y
  145 	pack .aved.bbb.delays.img .aved.bbb.delays.fin -side left -fill both -expand y
  146 
  147 	pack .aved.bbbb.del -side left -fill both -expand y
  148 
  149 	bind .aved.bb.files.l.list <ButtonRelease> {catch {AvEd_SelectImage [selection get]}}
  150 	bind .aved.b.l.d.2 <ButtonPress> "AvEd_Pos 2"
  151 	bind .aved.b.l.c.4 <ButtonPress> "AvEd_Pos 4"
  152 	bind .aved.b.l.c.6 <ButtonPress> "AvEd_Pos 6"
  153 	bind .aved.b.l.b.8 <ButtonPress> "AvEd_Pos 8"
  154 	bind .aved <Destroy> "Unset_AvEd"
  155 
  156 	set avatars 0
  157 	set depth 0
  158 	set count 0
  159 	foreach file [List_Avatars] {
  160 		if !$depth {
  161 			incr depth
  162 			.aved.b.l.c.5.b.m add cascade -menu \
  163 				.aved.b.l.c.5.b.m.m$depth -label "[Trns avatars] $depth"
  164 			menu .aved.b.l.c.5.b.m.m$depth
  165 		}
  166 		set AE(loadavatar.$count) "[file tail $file]"
  167 		.aved.b.l.c.5.b.m.m$depth add command -label [file tail $file] \
  168 			-command "AvEd_LoadExisting $count \"$MV(anims)\" \"$MV(images)\""
  169 		incr avatars
  170 		incr count
  171 		if {$avatars > 19} {
  172 			incr depth
  173 			.aved.b.l.c.5.b.m add cascade -menu \
  174 				.aved.b.l.c.5.b.m.m$depth -label "[Trns avatars] $depth"
  175 			menu .aved.b.l.c.5.b.m.m$depth
  176 			set avatars 0
  177 		}
  178 	}
  179 	AvEd_Animated
  180 	AvEd_NameBaloon
  181 }
  182 
  183 # This function is used to build a popup window to save the file.
  184 #
  185 # Notes:
  186 # Now uses translator (06/27/00 CRUISE)
  187 #
  188 proc AvEd_Save {} {
  189 	global AE MV
  190 
  191 	if !$AE(loaded) {return}
  192 	if {[winfo exists .avedsave]} {destroy .avedsave}
  193 	set types {
  194 		{{Avatar Files}		{.av .AV .Av}	}
  195 		{{Avatar Files}		{}	TEXT}
  196 		{{All Files}		*	}
  197 	}
  198 
  199 	if $AE(existing) {
  200 		set file [tk_getSaveFile -initialdir [file nativename "$MV(homedir)/anims"] -initialfile [file nativename "$MV(homedir)/anims/$AE(existing.file)"] -filetypes $types]
  201 	} else {
  202 		set file [tk_getSaveFile -initialdir [file nativename "$MV(homedir)/anims"] -filetypes $types]
  203 	}
  204 	set AE(save.file.name) $file
  205 	AvEd_SaveIt 1
  206 }
  207 
  208 # This function actually saves the file. It will check to see if it exists
  209 # before it saves it.
  210 #
  211 # Notes:
  212 # Now uses translator (06/27/00 CRUISE)
  213 #
  214 proc AvEd_SaveIt {overwrite} {
  215 	global MV AE
  216 
  217 	set filename [file tail $AE(save.file.name)]
  218 	if {[string tolower [string range $filename [expr [string length $filename] -3] end]] != ".av"} {
  219 		set filename "$filename.av"
  220 	}
  221 
  222 	if {[file exists "$MV(anims)/$filename"] && !$overwrite} {
  223 		if ![tk_dialog .aved.save_error [Trns file_exists] \
  224 			[Trns aved_save_warning] \
  225                 	"" 0 [Trns cancel] [Trns save]] {
  226 			destroy .avedsave
  227 			return
  228 		}
  229         }
  230 	destroy .avedsave
  231 	set outfile [open "$MV(anims)/$filename" w]
  232 	puts $outfile "set MV(anim.frames) [.aved.bb.files.l.list size]"
  233 	puts $outfile "set MV(anim.current) 1"
  234 	puts $outfile "set MV(anim.delay) $AE(delay.img)"
  235 	puts $outfile "set MV(anim.final_delay) $AE(delay.final)"
  236 	puts $outfile "set MV(anim.animated) $AE(animate)"
  237 	if $AE(animate) {
  238 		puts $outfile "set MV(anim.stop) 0"
  239 	} else {
  240 		puts $outfile "set MV(anim.stop) 1"
  241 	}
  242 	puts $outfile "set MV(anim.new) 1"
  243 	puts $outfile "set MV(anim.x_off) $AE(name_x)"
  244 	puts $outfile "set MV(anim.y_off) $AE(name_y)"
  245 	puts $outfile "set MV(anim.baloon_x) $AE(baloon_x)"
  246 	puts $outfile "set MV(anim.baloon_y) $AE(baloon_y)"
  247 	for {set c 0} {$c < [.aved.bb.files.l.list size]} {incr c} {
  248 		puts $outfile "set MV(anim.$c) [.aved.bb.files.l.list get $c $c]"
  249 	}
  250 	close $outfile
  251 	AvEd
  252 	DoAvatars
  253 }
  254 
  255 proc AvEd_Pos {dir} {
  256 	global AE
  257 
  258 	if !$AE(loaded) {return}
  259 	if $AE(name_baloon) {
  260 		switch $dir {
  261 			2 {incr AE(name_y)}
  262 			4 {incr AE(name_x) -1}
  263 			6 {incr AE(name_x)}
  264 			8 {incr AE(name_y) -1}
  265 		}
  266 		AvEd_KillName
  267 		AvEd_ShowName $AE(name_x) $AE(name_y)
  268 	} else {
  269 		switch $dir {
  270 			2 {incr AE(baloon_y)}
  271 			4 {incr AE(baloon_x) -1}
  272 			6 {incr AE(baloon_x)}
  273 			8 {incr AE(baloon_y) -1}
  274 		}
  275 		AvEd_KillBaloon
  276 		AvEd_ShowBaloon $AE(baloon_x) $AE(baloon_y)
  277 	}
  278 }
  279 
  280 
  281 proc AvEd_NameBaloon {} {
  282 	global AE
  283 
  284 	if $AE(name_baloon) {
  285 		.aved.b.l.b.7 configure -state disabled
  286 		.aved.b.l.b.9 configure -state normal
  287 		if $AE(loaded) {
  288 			AvEd_ShowBaloon $AE(baloon_x) $AE(baloon_y)
  289 			AvEd_KillName
  290 		}
  291 		set AE(name_baloon) 0
  292 	} else {
  293 		.aved.b.l.b.7 configure -state normal
  294 		.aved.b.l.b.9 configure -state disabled
  295 		if $AE(loaded) {
  296 			AvEd_KillBaloon
  297 			AvEd_ShowName $AE(name_x) $AE(name_y)
  298 		}
  299 		set AE(name_baloon) 1
  300 	}
  301 }
  302 
  303 
  304 proc AvEd_ChangeColor {} {
  305 	global AE
  306 
  307 	switch $AE(color) {
  308 		1 {
  309 			set color black
  310 		}
  311 		2 {
  312 			set color white
  313 		}
  314 		3 {
  315 			set color blue
  316 		}
  317 	}
  318 	.aved.c configure -background $color
  319 }
  320 
  321 proc AvEd_Animated {} {
  322 	global AE
  323 
  324 	if $AE(animate) {
  325 		.aved.b.r.cmds.add configure -state normal
  326 		.aved.bbb.delays.img configure -state normal
  327 		.aved.bbb.delays.fin configure -state normal
  328 		.aved.b.l.c.5.t configure -state disabled
  329 		.aved.b.l.d.1 configure -state normal
  330 		.aved.b.l.d.3 configure -state disabled
  331 	} else {
  332 		.aved.b.r.cmds.add configure -state disabled
  333 		.aved.bbb.delays.img configure -state disabled
  334 		.aved.bbb.delays.fin configure -state disabled
  335 		.aved.b.l.c.5.t configure -state normal
  336 		.aved.b.l.d.1 configure -state disabled
  337 		.aved.b.l.d.3 configure -state disabled
  338 		set AE(anim.stop) 1
  339 		set AE(anim.running) 0
  340 	}
  341 }
  342 
  343 proc AvEd_LoadExisting {what dir imgs} {
  344 	global AE
  345 
  346 
  347 	source "$dir/$AE(loadavatar.$what)"
  348 	set AE(existing) 1
  349 	set AE(existing.file) "$AE(loadavatar.$what)"
  350 	if $AE(loaded) {AvEd}
  351 	set AE(animate) $MV(anim.animated)
  352 	set AE(delay.img) $MV(anim.delay)
  353 	set AE(delay.final) $MV(anim.final_delay)
  354 	set AE(name_x) $MV(anim.x_off)
  355 	set AE(name_y) $MV(anim.y_off)
  356 	set AE(baloon_x) $MV(anim.baloon_x)
  357 	set AE(baloon_y) $MV(anim.baloon_y)
  358 	for {set c 0} {$c < $MV(anim.frames)} {incr c} {
  359 		AvEd_AddImageOld $imgs/$MV(anim.$c)
  360 	}
  361 	AvEd_Animated
  362 }
  363 
  364 # This function adds an image to an animation series.
  365 #
  366 # Notes:
  367 # Now uses translator (06/27/00 CRUISE)
  368 #
  369 proc AvEd_AddImageOld {what} {
  370 	global MV AE
  371 
  372 	if {[catch {image create photo aved -file "$what"}]} {
  373 		ThrowError "[Trns unable_to_load_image] $what"
  374 		return
  375 	}
  376 	if !$AE(loaded) {
  377 		.aved.c create image 160 100 -image aved
  378 		if $AE(name_baloon) {
  379 			AvEd_ShowName $AE(name_x) $AE(name_y)
  380 		} else {
  381 			AvEd_ShowBaloon $AE(baloon_x) $AE(baloon_y)
  382 		}
  383 	}
  384 	set AE(loaded) 1
  385 	.aved.bb.files.l.list insert end [file tail $what]
  386 	lappend AE(images) [file tail $what]
  387 	.aved.bb.files.l.list see end
  388 }
  389 
  390 # This function adds an image to an animation series.
  391 #
  392 # Notes:
  393 # Now uses translator (06/27/00 CRUISE)
  394 #
  395 proc AvEd_AddImage {add} {
  396 	global MV AE
  397 
  398 	#
  399 	# Bugfix 10/17/2001 by Cruise.
  400 	#
  401 	# Wasn't giving the error message when a user tried to load a
  402 	# bad image because it had $what instead of $AE(loadimage)
  403 	#
  404 	if {[catch {image create photo aved -file "$AE(loadimage)"}]} {
  405 		ThrowError "[Trns unable_to_load_image] $AE(loadimage)"
  406 		return
  407 	}
  408 	if !$AE(loaded) {
  409 		.aved.c create image 160 100 -image aved
  410 		if $AE(name_baloon) {
  411 			AvEd_ShowName $AE(name_x) $AE(name_y)
  412 		} else {
  413 			AvEd_ShowBaloon $AE(baloon_x) $AE(baloon_y)
  414 		}
  415 	}
  416 	set AE(loaded) 1
  417 	if $add {
  418 		DebugIt "(AvEd) Adding New Image" other
  419 		.aved.bb.files.l.list insert end [file tail $AE(loadimage)]
  420 		lappend AE(images) [file tail $AE(loadimage)]
  421 		.aved.bb.files.l.list see end
  422 	} else {
  423 		DebugIt "(AvEd) Replacing Image" other
  424 		.aved.bb.files.l.list delete 0 end
  425 		.aved.bb.files.l.list insert end [file tail $AE(loadimage)]
  426 		set AE(images) [file tail $AE(loadimage)]
  427 		.aved.bb.files.l.list see end
  428 	}
  429 }
  430 
  431 proc AvEd_SelectImage {what} {
  432 	global MV AE
  433 
  434 	image create photo aved -file "$MV(images)/$what"
  435 }
  436 
  437 proc AvEd_KillBaloon {} {
  438 	global AE
  439 
  440 	.aved.c delete $AE(baloon)
  441 	.aved.c delete $AE(text)
  442 }
  443 
  444 proc AvEd_ShowBaloon {x y} {
  445 	global AE
  446 
  447 	set width 60
  448 	set rows 2
  449 	set height 20
  450 	set hoff 8
  451 
  452 	set AE(baloon) [.aved.c create polygon \
  453 	[expr (160 + $x) - 20] [expr 100 + $y] \
  454 	[expr (160 + $x)] [expr 100 + $y] \
  455 	[expr (160 + $x) + 20] [expr (100 + $y) - $hoff] \
  456 	[expr (160 + $x) + $width - 20] [expr (100 + $y) - $hoff] \
  457 	[expr (160 + $x) + $width] [expr 100 + $y] \
  458 	[expr (160 + $x) + $width] [expr (100 + $y) + $height]\
  459 	[expr (160 + $x) + $width - 20] [expr (100 + $y) + $height +$hoff] \
  460 	[expr (160 + $x) + 20] [expr (100 + $y) + $hoff + $height] \
  461 	[expr (160 + $x)] [expr (100 + $y) + $height] \
  462 	[expr (160 + $x)] [expr (100 + $y) + 5] \
  463 	[expr (160 + $x) - 20] [expr 100 + $y] \
  464 	-fill white -outline black -smooth 1]
  465 	set AE(text) [.aved.c create text [expr (160 + $x) + \
  466 		($width / 2)] [expr (100 + $y) + (6 * $rows)] \
  467 		-width 200 -text "Hello!"]
  468 }
  469 
  470 proc AvEd_KillName {} {
  471 	global AE
  472 
  473 	.aved.c delete $AE(nametext)
  474 	.aved.c delete $AE(nameplate)
  475 }
  476 
  477 proc AvEd_ShowName {x y} {
  478 	global MV AE
  479 
  480 	set width [expr [string length $MV(nick)] * 8]
  481 	set AE(nameplate) [.aved.c create rectangle \
  482 		[expr (160 + $x) - ($width / 2)] \
  483 		[expr (100 + $y) - 8] \
  484 		[expr (160 + $x) + ($width / 2)] \
  485 		[expr (100 + $y) + 8] -fill black]
  486 	set AE(nametext) [.aved.c create text \
  487 		[expr 160 + $x] [expr 100 + $y] -text $MV(nick) -fill white]
  488 
  489 }
  490 
  491 
  492 proc AvEd_AnimateAvatar {how} {
  493 	global MV AE
  494 
  495 	if {![winfo exists .aved]} {
  496 		set AE(anim.stop) 1
  497 		set AE(anim.running) 0
  498 		return
  499 	}
  500 	switch -- $how {
  501 		0 {
  502 			.aved.b.l.d.1 configure -state normal
  503 			.aved.b.l.d.3 configure -state disabled
  504 			set AE(anim.stop) 1
  505 			set AE(anim.running) 0
  506 		}
  507 		1 {
  508 			.aved.b.l.d.1 configure -state disabled
  509 			.aved.b.l.d.3 configure -state normal
  510 			set AE(anim.stop) 0
  511 			set AE(anim.current) 1
  512 			set AE(anim.new) 1
  513 			AvEd_AnimateAvatar -1
  514 		}
  515 		"-1" {
  516 			set delay 0
  517 			if {$AE(anim.current) == 1 && !$AE(anim.new)} {
  518 				set delay $AE(delay.final)
  519 			}
  520 			set AE(anim.new) 0
  521 			if $AE(anim.stop) {
  522 				image create photo aved -file "$MV(images)/[.aved.bb.files.l.list get 0]"
  523 				set AE(anim.running) 0
  524 				return
  525 			}
  526 			image create photo aved -file "$MV(images)/[.aved.bb.files.l.list get [expr $AE(anim.current) -1]]"
  527 			.aved.bb.files.l.list selection clear 0 end
  528 			.aved.bb.files.l.list selection set [expr $AE(anim.current) -1]
  529 			.aved.bb.files.l.list see [expr $AE(anim.current) -1]
  530 			set AE(anim.running) 1
  531 			incr AE(anim.current)
  532 			if {$AE(anim.current) > [.aved.bb.files.l.list size]} {
  533 				set AE(anim.current) 1
  534 			}
  535 			update idletasks
  536 			set do_delay [expr $AE(delay.img) + $delay]
  537 			after $do_delay AvEd_AnimateAvatar -1
  538 		}
  539 	}
  540 }
  541 
  542 proc AvEd_PickImage {add} {
  543 	global MV AE
  544 
  545 	set types {
  546 		{{GIF Image Files}	{.gif .GIF .Gif}	}
  547 		{{GIF Image Files}	{}	GIFF}
  548 		{{All Files}		*	}
  549 	}
  550 	set file [tk_getOpenFile -initialdir [file nativename "$MV(homedir)/images"] -filetypes $types]
  551 	# Performance Enhancement DRG
  552 	if {![string compare $file ""]} {return}
  553 	if {![file exists "$MV(homedir)/images/[file tail $file]"]} {
  554 		file copy $file "$MV(homedir)/images/"
  555 	} else {
  556 		if {[file size "$MV(homedir)/images/[file tail $file]"] != [file size $file]} {
  557 			file copy -force $file "$MV(homedir)/images/"
  558 		}
  559 	}
  560 	#
  561 	# Don't allow images with spaces in their name... re-name them.
  562 	# Cruise - 10/18/01
  563 	#
  564 	set filename [file tail $file]
  565 	if {[string first " " $filename] != -1} {
  566 		set newfile ""
  567 		for {set c 0} {$c < [string length $filename]} {incr c} {
  568 			switch -- [string range $filename $c $c] {
  569 				" " {append newfile "_"}
  570 				default {append newfile [string range $filename $c $c]}
  571 			}
  572 		}
  573 		file rename "$MV(homedir)/images/$filename" "$MV(homedir)/images/$newfile"
  574 		set filename $newfile
  575 	}
  576 	set AE(loadimage) "$MV(homedir)/images/$filename"
  577 	# Performance Enhancement DRG
  578 	if {[string compare $filename ""]} {
  579 		AvEd_AddImage $add
  580 	}
  581 }
  582 
  583 
  584 proc AvEd_DeleteOne {} {
  585 	global MV AE
  586 
  587 	set what ""
  588 	catch {set what [selection get]}
  589 	set lidx [.aved.bb.files.l.list curselection]
  590 	# Performance Enhancement DRG
  591 	if {[string compare $lidx ""]} {
  592 		.aved.bb.files.l.list delete $lidx
  593 		set idx [lsearch $AE(images) $what]
  594 		set AE(images) [lreplace $AE(images) $idx $idx]
  595 	}
  596 }
  597 
  598 proc Unset_AvEd {} {
  599 	global AE
  600 	catch {unset AE}
  601 }