X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-live.git;a=blobdiff_plain;f=yarrg%2Fwhere-vessels;h=b9264923f6b25e4fadda724fe9db250465875cfd;hp=f4fee80f5229325a602e9e53b64cc1fc61377b93;hb=7d38bda05d74767d4c8ab7127f72e3704350bf28;hpb=b6919a190cf9ce37ab245d1ec124320ffe49a969 diff --git a/yarrg/where-vessels b/yarrg/where-vessels index f4fee80..b926492 100755 --- a/yarrg/where-vessels +++ b/yarrg/where-vessels @@ -101,10 +101,11 @@ proc nextarg {} { return $v } -set notes_loc vessel-notes +set notes_loc {} set scraper {./yppedia-ocean-scraper --chart} set info_cache _vessel-info-cache set info_source rsync.yarrg.chiark.net::yarrg/vessel-info +set no_owners 0 proc parseargs {} { global ai argv @@ -131,7 +132,8 @@ proc parseargs {} { proc argdefaults {} { global ocean notes_loc pirate scraper - if {![info exists ocean] || ![info exists pirate]} { + if {![info exists ocean] || + (![info exists pirate] && [string length $notes_loc])} { set cmd {./yarrg --find-window-only --quiet} if {[info exists ocean]} { lappend cmd --ocean $ocean } if {[info exists pirate]} { lappend cmd --pirate $pirate } @@ -140,6 +142,9 @@ proc argdefaults {} { error "$ocean $pirate ?" } } + if {![info exists pirate]} { set pirate {}; glset no_owners 1 } + if {![string length $notes_loc]} { glset no_owners 1 } + lappend scraper $ocean } @@ -440,17 +445,21 @@ proc show-report-decode {code} { {(All lock states)} {(Not battle ready)} } $lock] - switch -exact $notown { - 0 { report-set own "Yours" } - 1 { report-set own "Other pirate's" } - 2 { report-set own "Owner unknown" } - 3 { report-set own "(All ownerships)" } - 4 - 5 { report-set own "(Yours/unknown)" } - default { report-set own "?? $notown" } + global no_owners notes_loc + if {!$no_owners} { + switch -exact $notown { + 0 { report-set own "Yours" } + 1 { report-set own "Other pirate's" } + 2 { report-set own "Owner unknown" } + 3 { report-set own "(All ownerships)" } + 4 - 5 { report-set own "(Yours/unknown)" } + default { report-set own "?? $notown" } + } } global smash_xabbrev_map - if {[llength $smash_xabbrev_map]} { + if {![string length $notes_loc]} { + } elseif {[llength $smash_xabbrev_map]} { if {[string length $xabbrev]} { report-set xabbrev "(Flags: $xabbrev)" } else { @@ -552,9 +561,6 @@ proc populate-control-grid-tickboxes {cw rows inrow varsvn values flipvalues #---------- smashing ---------- -set smash_subclass 0 -set smash_owner 0 - proc smash-code {code} { manyset [split $code _] inport size subclass lockown xabbrev @@ -638,9 +644,12 @@ proc make-smashers {} { image val { expr 0 } { expr {"icon/$vc_code2abbrev($val)"} } $cw.0 configure -state disabled + glset smash_subclass 0 make-radio-smasher subclass Class smash_subclass \ {Show Normal/LE Hide} 1 0 + global no_owners + glset smash_owner [expr {$no_owners ? 3 : 0}] make-radio-smasher owner Owner smash_owner \ {Show Yours? {For you} Lock Hide} 2 3 @@ -952,8 +961,18 @@ proc load-chart {} { }]] } - -set scale 16 +proc init-scales {} { + global scales scaleix scale + set defscale 16 + set scales {1 2 3 4 5 6 8} + set e12 {10 12 15 18 22 27 33 39 47 56 68 82} + foreach t $e12 { + if {$t < $defscale} { set scaleix [llength $scales] } + lappend scales $t + } + foreach t [lrange $e12 0 6] { lappend scales [expr {$t * 10}] } + set scale [lindex $scales $scaleix] +} proc coord {c} { global scale @@ -1236,10 +1255,14 @@ proc islandnames-handler {offset maxchars} { #---------- main user interface ---------- proc widgets-setup {} { - global canvas debug pirate ocean filterstyle + global canvas debug pirate ocean filterstyle notes_loc wm geometry . 1200x800 - wm title . "where-vessels - $pirate on the $ocean ocean" + if {[string length $pirate]} { + wm title . "where-vessels - $pirate on the $ocean ocean" + } else { + wm title . "where-vessels - $ocean ocean" + } #----- map ----- @@ -1289,9 +1312,11 @@ proc widgets-setup {} { frame .cp.ctrl.zoom pack .cp.ctrl.zoom -side top - button .cp.ctrl.zoom.out -text - -font {Courier 16} -command {zoom /2} -pady 0 - button .cp.ctrl.zoom.in -text + -font {Courier 16} -command {zoom *2} -pady 0 - pack .cp.ctrl.zoom.out .cp.ctrl.zoom.in -side left + foreach inout {out in} minplus {- +} { + button .cp.ctrl.zoom.$inout -text $minplus -font {Courier 16} \ + -command "zoom ${minplus}1" -pady 0 + pack .cp.ctrl.zoom.$inout -side left + } parser-control-create .cp.ctrl.acquire \ acquire Acquire \ @@ -1302,9 +1327,13 @@ proc widgets-setup {} { parser-control-create .cp.ctrl.notes \ notes "Reload notes" \ "Vessel notes loading report" \ - + pack .cp.ctrl.notes -side top -pady 2 + if {![string length $notes_loc]} { + .cp.ctrl.notes.do configure -state disabled + } + #----- island name count and copy ----- label .islands.count @@ -1346,6 +1375,8 @@ proc widgets-setup {} { proc report-set {sw val} { .cp.report.details.$sw configure -text $val } proc show-report {islandname code} { + global no_owners + .cp.report.island configure -text $islandname .cp.report.abbrev delete all @@ -1373,19 +1404,23 @@ proc show-report {islandname code} { } else { set owndesc "Owner unknown" } - .cp.report.list insert end "$owndesc:" + if {!$no_owners} { + .cp.report.list insert end "$owndesc:" + } foreach name $owned($owner) { .cp.report.list insert end " $name" } } } -proc zoom {extail} { - global scale canvas - set nscale [expr "\$scale $extail"] - debug "ZOOM $scale $nscale" - if {$nscale < 1 || $nscale > 200} return - set scale $nscale +proc zoom {amt} { + global scaleix scales scale canvas + incr scaleix $amt + if {$scaleix < 0} { set scaleix 0 } + set nscales [llength $scales] + if {$scaleix >= $nscales} { set scaleix [expr {$nscales-1}] } + set scale [lindex $scales $scaleix] + debug "ZOOM $amt $scaleix $scale" draw } @@ -1434,6 +1469,7 @@ proc invoke_notes {} { #---------- main program ---------- +init-scales parseargs argdefaults httpclientsetup where-vessels @@ -1449,7 +1485,9 @@ if {[catch { parse-clipboard } emsg]} { puts stderr "$emsg\n$errorInfo" exit 1 } -after idle invoke_notes +if {[string length $notes_loc]} { + after idle invoke_notes +} draw @@ -1460,4 +1498,10 @@ if {$debug} { -prompt2 { return "> " } } -# rsync -r --exclude=\*~ yarrg/icons/. ijackson@chiark.greenend.org.uk:/home/ftp/users/ijackson/yarrg/vessel-info/. +# some runes I use: +# +# offline development +# ./where-vessels --notes ~/vessel-notes --vessel-info-source '' --pirate Aristarchus --ocean Midnight --debug --local-html-dir . --clipboard-file ~/clipboard-aristarchus +# +# updating published vessel info +# rsync -r --exclude=\*~ yarrg/icons/. ijackson@chiark.greenend.org.uk:/home/ftp/users/ijackson/yarrg/vessel-info/.