⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 autorun.tcl

📁 好东西,欢迎下在,联系方式E-mail:xoming117@tom.com
💻 TCL
📖 第 1 页 / 共 2 页
字号:
################################################################################
# AutoRun.tcl - AutoRun for Tornado CD-ROM
#
# Copyright 1996 Wind River Systems, Inc.
#

# Globals

# The index of currently displayed bitmap
	set nthPreviewBitmapShow 0
# List of bitmap names for the product currently being previewed
	set previewBitmapList ""
# The number of bitmaps in the bitmap list for the current product
	set nPreviewBitmaps 0 
# The name of the product currently being previewed
	set previewProductName ""
# The handle to the setupTclDll
	set setup_lib ""
# The location to which files are unzipped
	set tempDir ""
# List of all possible products that can be previewed, in format
#	of autoRunInfo file 
	set previewProducts "" 
# List of keys (corresponding to directory names) of products the
# 	user has chosen to preview
	set previewKeyList ""

proc tornadoAutoRun@@Init {} {
	upvar setup_lib setup_lib
	set setup_lib [load [CDDriveGet]X86/WIN32/SETUPTCL.DLL]

	controlCreate tornadoAutoRun@@ \
		[list bitmap -x 8 -y 8 -name bitmap -hidden \
		  -title [CDDriveGet]RESOURCE/BITMAPS/TOR256.BMP]

	controlCreate tornadoAutoRun@@ [list \
		button -w 50 -height 16 -hidden -title "&Setup" -name setupButton \
		-callback {
			if {[catch {processCreate setup.exe} error]} {
				messageBox $error
			} {
				tornadoAutoRun@@windowClose
			}
		}]

	controlCreate tornadoAutoRun@@ [list \
		button -w 50 -height 16 -hidden -title "&Preview" -name previewButton \
			-callback tornadoAutoRun@@productSelect]

	controlCreate tornadoAutoRun@@ [list \
		button -w 50 -height 16 -hidden -title "&Read Me..." \
		-name readmeButton \
		-callback {
			if [file exist [CDDriveGet]README.TXT] {
				if {[catch [list processCreate \
					"notepad.exe [CDDriveGet]README.TXT"] error]} {
					messageBox $error
				}
			} {
				messageBox -exclam "No README available at this time."
			}
		}]

	controlCreate tornadoAutoRun@@ [list \
		button -w 50 -height 16 -hidden -title "E&xit" -name exitButton \
		-callback tornadoAutoRun@@windowClose]

	welcomePageLayoutPrepare
}

proc welcomePageLayoutPrepare {} {
	global previewProducts

	# Retrieve the bitmaps width and height in dialog units.
	set bitmapW [lindex [controlSizeGet tornadoAutoRun@@.bitmap] 0]
	set bitmapH [lindex [controlSizeGet tornadoAutoRun@@.bitmap] 1]

	# Resize the dialog now that we know the bitmaps size in dialog units.
	windowSizeSet tornadoAutoRun@@ \
		[expr 8 + $bitmapW + 8 + 50 + 8] [expr 8 + $bitmapH + 8]

	windowTitleSet tornadoAutoRun@@ "Welcome to Tornado"

	controlHide tornadoAutoRun@@.bitmap 0

	controlPositionSet tornadoAutoRun@@.setupButton [expr 8 + $bitmapW + 8] 8
	controlPositionSet tornadoAutoRun@@.previewButton [expr 8 + $bitmapW + 8] [expr 8 + 16 + 8]
	controlPositionSet tornadoAutoRun@@.readmeButton [expr 8 + $bitmapW + 8] [expr 8 + 16 + 8 + 16 + 8]
	controlPositionSet tornadoAutoRun@@.exitButton [expr 8 + $bitmapW + 8] [expr 8 + $bitmapH - 16]
	controlHide tornadoAutoRun@@.setupButton 0
	controlHide tornadoAutoRun@@.previewButton 0
	controlHide tornadoAutoRun@@.exitButton 0
	controlHide tornadoAutoRun@@.readmeButton 0

	# Create list of products that can be previewed
	if {$previewProducts == ""} {
		set previewProducts [previewProductsEnumerate [archiveGet]]
	}

	# Disable preview button if there is nothing to preview
	set nProducts [llength $previewProducts]
	if {$nProducts == 0} {
		controlEnable tornadoAutoRun@@.previewButton 0
	}

	# Disable the readme button if there isn't a readme file
	if [file exist [CDDriveGet]README.TXT] {
		controlEnable tornadoAutoRun@@.readmeButton 1
	} else {
		controlEnable tornadoAutoRun@@.readmeButton 0
	}
}


proc previewPageLayoutPrepare {productKeyList} {
	controlHide tornadoAutoRun@@.bitmap 1
	controlHide tornadoAutoRun@@.previewButton 1
	controlHide tornadoAutoRun@@.readmeButton 1
	controlHide tornadoAutoRun@@.exitButton 1

	global nPreviewBitmaps
	global previewBitmapList
	global previewProductName
	global previewKeyList

	# Setup the first preview
	set archive [archiveGet]
	set nPreviewBitmaps 0 
	set previewProductKey [lindex $productKeyList 0]
	set previewKeyList [lrange $productKeyList 1 end]
	set previewBitmapList \
		[previewBitmapsEnumerate $previewProductKey $archive]
	set nPreviewBitmaps [llength $previewBitmapList]

	# Determine the name of the preview product and use it to update
	# the window title; we grab the directory for the first bitmap
	# and capitalize it
	set previewProductName [lindex [lindex $previewBitmapList 0] 0]
	if {[regexp {^([a-zA-Z])([^/]+)/[0-9]+\.[Bb][Mm][Pp]$} \
		$previewProductName dummy first remainder]} {
		set previewProductName \
			[format "%s%s" [string toupper $first] $remainder]
	}
	tornadoAutoRun@@previewPageTitleSet

	if {$previewBitmapList != ""} {

		# Create a control to display the first bitmap
		set firstBitmap [lindex $previewBitmapList 0]
		if [catch {previewBitmapGet $firstBitmap $archive} errorMsg] {
			return
		}
		set bitmapPath [tempDirGet]$firstBitmap
	
		controlCreate tornadoAutoRun@@ \
			[list bitmap -x 8 -y 8 -name previewBitmap -hidden \
			-title $bitmapPath]

		# Retrieve the bitmaps width and height in dialog units.
		set previewBitmapW [lindex [controlSizeGet \
			tornadoAutoRun@@.previewBitmap] 0]
		set previewBitmapH [lindex [controlSizeGet \
			tornadoAutoRun@@.previewBitmap] 1]

		windowSizeSet tornadoAutoRun@@ \
  			[expr 8 + $previewBitmapW + 8] \
			[expr 8 + $previewBitmapH + 8 + 16 + 8]

		controlPositionSet tornadoAutoRun@@.setupButton 8 \
			[expr 8 + $previewBitmapH + 8]

		controlCreate tornadoAutoRun@@ [list \
			button -w 50 -h 16 -name previousSlide -title "< &Back" \
			-x [expr 8 + ($previewBitmapW / 2) - 54] \
			-y [expr 8 + $previewBitmapH + 8] \
			-callback {
				nextPreviewSlide -1
			}]

		controlCreate tornadoAutoRun@@ [list \
			button -w 50 -h 16 -name nextSlide -title "&Next >" \
			-x [expr 8 + ($previewBitmapW / 2) + 4] \
			-y [expr 8 + $previewBitmapH + 8] \
			-callback {
				nextPreviewSlide 1
			}]

		controlCreate tornadoAutoRun@@ [list \
			button -w 50 -h 16 -name cancelPreview -title "Close" \
			-x [expr 8 + $previewBitmapW - 50] \
			-y [expr 8 + $previewBitmapH + 8] \
			-callback {
				nextPreviewSlide 999
			}]

		controlHide tornadoAutoRun@@.previewBitmap 0
		controlHide tornadoAutoRun@@.cancelPreview 0

		controlEnable tornadoAutoRun@@.previousSlide 0
	}
}

proc nextPreviewSlide {direction} {
	global nthPreviewBitmapShow
	global nPreviewBitmaps
	global previewBitmapList
	global setup_lib
	global previewProductName
	global previewKeyList

	# Remove the last bitmap displayed from disk 
	set lastPreviewBitmap \
		[tempDirGet][lindex $previewBitmapList $nthPreviewBitmapShow]
	file delete -force -- $lastPreviewBitmap

	# Enable or disable the Next button
	if {([expr $nthPreviewBitmapShow + $direction] == \
		[expr $nPreviewBitmaps - 1]) && [llength $previewKeyList] == 0} {
		controlEnable tornadoAutoRun@@.nextSlide 0
	} else {
		controlEnable tornadoAutoRun@@.nextSlide 1
	}

	# This should never happen
	if {[expr $nthPreviewBitmapShow + $direction] < 0} return

	incr nthPreviewBitmapShow $direction

	if {$nthPreviewBitmapShow < $nPreviewBitmaps} {

		# Enable/disable the back button
		if {$nthPreviewBitmapShow > 0} {
			controlEnable tornadoAutoRun@@.previousSlide 1
		} else {
			controlEnable tornadoAutoRun@@.previousSlide 0
		}

		# Transition to next slide in this preview
		set nextPreviewBitmapFile \
			[lindex $previewBitmapList $nthPreviewBitmapShow]
		if {[previewBitmapGet $nextPreviewBitmapFile [archiveGet]]} {
			controlValuesSet tornadoAutoRun@@.previewBitmap \
				[tempDirGet]$nextPreviewBitmapFile	
		}
		tornadoAutoRun@@previewPageTitleSet

	} elseif {$nthPreviewBitmapShow == $nPreviewBitmaps && \
			[llength $previewKeyList] != 0} {

		# Disable Back button 
		controlEnable tornadoAutoRun@@.previousSlide 0

		# Change the slideshow

		set nPreviewBitmaps 0 
		set nthPreviewBitmapShow 0
		set previewProductName [lindex $previewKeyList 0]
		set previewKeyList [lrange $previewKeyList 1 end]
		set previewBitmapList \
			[previewBitmapsEnumerate $previewProductName [archiveGet]]
		set nPreviewBitmaps [llength $previewBitmapList]

		# Set the new bitmap
		set previewBitmapFile \
			[lindex $previewBitmapList $nthPreviewBitmapShow]
		if {[previewBitmapGet $previewBitmapFile [archiveGet]]} {
			controlValuesSet tornadoAutoRun@@.previewBitmap \
				[tempDirGet]$previewBitmapFile	
		}

		# Set the title
		set previewProductName [lindex [lindex $previewBitmapList 0] 0]
		if {[regexp {^([a-zA-Z])([^/]+)/[0-9]+\.[Bb][Mm][Pp]$} \
			$previewProductName dummy first remainder]} {
			set previewProductName \
				[format "%s%s" [string toupper $first] $remainder]
			tornadoAutoRun@@previewPageTitleSet
		}

	} else {
		autoTimerCallbackSet tornadoAutoRun@@ 0

		set nthPreviewBitmapShow 0

		controlDestroy tornadoAutoRun@@.previewBitmap
		controlDestroy tornadoAutoRun@@.previousSlide
		controlDestroy tornadoAutoRun@@.nextSlide
		controlDestroy tornadoAutoRun@@.cancelPreview

		# Reinitialize some globals
		set nthPreviewBitmapShow 0
		set previewBitmapList ""
		set nPreviewBitmaps 0 
		set previewProductName ""

		welcomePageLayoutPrepare
	}
}

proc tornadoAutoRun@@windowClose {} {
	autoTimerCallbackSet tornadoAutoRun@@ 0
	windowClose tornadoAutoRun@@
}

proc tornadoAutoRunShow {} {
	catch {soundPlay -async [CDDriveGet]RESOURCE/SOUNDS/TORHELLO.WAV}

	dialogCreate -name tornadoAutoRun@@ \
		-w 100 -h 100 -init tornadoAutoRun@@Init \
		-nocontexthelp \
		-exit {
			catch {global setup_lib}
			if {$setup_lib != ""} {
				dllUnload $setup_lib
				set setup_lib ""
			}
		} \
		-nocontexthelp

	catch {soundPlay [CDDriveGet]RESOURCE/SOUNDS/TORBYE.WAV}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -