From: <man...@us...> - 2009-07-06 21:31:00
|
Revision: 10194 http://openmsx.svn.sourceforge.net/openmsx/?rev=10194&view=rev Author: manuelbi Date: 2009-07-06 21:30:55 +0000 (Mon, 06 Jul 2009) Log Message: ----------- Put some common procs in utils Modified Paths: -------------- openmsx/trunk/share/scripts/info_panel.tcl openmsx/trunk/share/scripts/osd_menu.tcl Added Paths: ----------- openmsx/trunk/share/scripts/utils.tcl Modified: openmsx/trunk/share/scripts/info_panel.tcl =================================================================== --- openmsx/trunk/share/scripts/info_panel.tcl 2009-07-06 14:29:07 UTC (rev 10193) +++ openmsx/trunk/share/scripts/info_panel.tcl 2009-07-06 21:30:55 UTC (rev 10194) @@ -54,7 +54,7 @@ set panel_info(mtime,title) "Time" set panel_info(mtime,width) 60 set panel_info(mtime,row) 1 - set panel_info(mtime,method) {set mtime [machine_info time]; format "%02d:%02d:%02d" [expr int($mtime / 3600)] [expr int($mtime / 60) % 60] [expr int($mtime) % 60]} + set panel_info(mtime,method) {utils::get_machine_time} set panel_info(speed,title) "Speed" set panel_info(speed,width) 48 @@ -64,7 +64,7 @@ set panel_info(machine,title) "Machine" set panel_info(machine,width) 250 set panel_info(machine,row) 1 - set panel_info(machine,method) {array set names [openmsx_info machines [machine_info config_name]]; format "%s %s" $names(manufacturer) $names(code)} + set panel_info(machine,method) {utils::get_machine_display_name} # calc width of software item set software_width 0 Modified: openmsx/trunk/share/scripts/osd_menu.tcl =================================================================== --- openmsx/trunk/share/scripts/osd_menu.tcl 2009-07-06 14:29:07 UTC (rev 10193) +++ openmsx/trunk/share/scripts/osd_menu.tcl 2009-07-06 21:30:55 UTC (rev 10194) @@ -416,12 +416,6 @@ actions { LEFT { incr glow -1 } RIGHT { incr glow 1 }}}}}] -proc get_machine_display_name { machineid } { - set config_name [${machineid}::machine_info config_name] - array set names [openmsx_info machines $config_name] - return [format "%s %s" $names(manufacturer) $names(code)] -} - set running_machines_menu [prepare_menu { bg-color 0x000000a0 text-color 0xffffffff @@ -436,7 +430,7 @@ font-size 10 post-spacing 6 selectable false } - { text "Select Running Machine Tab: [ set name <none>; catch { set name [osd_menu::get_machine_display_name [activate_machine]]}; set name]" + { text "Select Running Machine Tab: [ set name <none>; catch { set name [utils::get_machine_display_name [activate_machine]]}; set name]" actions { A { osd_menu::menu_create [osd_menu::menu_create_running_machine_list] }}} { text "New Running Machine Tab" actions { A { osd_menu::menu_create [osd_menu::menu_create_load_machine_list] }}} Added: openmsx/trunk/share/scripts/utils.tcl =================================================================== --- openmsx/trunk/share/scripts/utils.tcl (rev 0) +++ openmsx/trunk/share/scripts/utils.tcl 2009-07-06 21:30:55 UTC (rev 10194) @@ -0,0 +1,28 @@ +# several utility procs for usage in other scripts +# don't export anything, just use it from the namespace +# +# these procs are not specific to anything special, +# they could be useful in any script. +# +# Born to prevent duplication between scripts for common stuff. + +namespace eval utils { + +proc get_machine_display_name { { machineid "" } } { + if {$machineid eq ""} { + set machineid [machine] + } + set config_name [${machineid}::machine_info config_name] + array set names [openmsx_info machines $config_name] + return [format "%s %s" $names(manufacturer) $names(code)] +} + +proc get_machine_time { { machineid "" } } { + if {$machineid eq ""} { + set machineid [machine] + } + set mtime [${machineid}::machine_info time] + return [format "%02d:%02d:%02d" [expr int($mtime / 3600)] [expr int($mtime / 60) % 60] [expr int($mtime) % 60]] +} + +} ;# namespace utils Property changes on: openmsx/trunk/share/scripts/utils.tcl ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |