From 7d38bda05d74767d4c8ab7127f72e3704350bf28 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 8 Aug 2010 19:07:46 +0100 Subject: [PATCH] where-vessels: No notes is default. Better treatment of lack of notes/ownership --- yarrg/README.where-vessels | 27 ++++++++++----- yarrg/where-vessels | 67 +++++++++++++++++++++++++++----------- 2 files changed, 67 insertions(+), 27 deletions(-) diff --git a/yarrg/README.where-vessels b/yarrg/README.where-vessels index 190b7b3..6fb21c2 100644 --- a/yarrg/README.where-vessels +++ b/yarrg/README.where-vessels @@ -17,7 +17,7 @@ USAGE: In where-vessels, click "Acquire" -You will probably want to create a "vessel-notes" file to get the best +You may well want to create a "vessel-notes" file to get the best use out of where-vessels, see below. If you don't have exactly one YPP client open and logged in then you @@ -31,15 +31,26 @@ information about the problem. OPTIONS: ======== - --pirate PIRATE Treat vessels belonging to PIRATE as your own - --ocean OCEAN Use map of OCEAN + --ocean OCEAN + Use map of OCEAN. Default is to guess by looking for an + open Puzzle Pirates client on the same display (logged on + as PIRATE, if --pirate was used). + + --pirate PIRATE + Supplies the name of your pirate. If you also supply a notes + file (see below) where-vessels will treat ships belonging to + PIRATE as your own. An empty argument means do not care about + vessel ownership. Default is not to care about ownership without + notes; with notes, default is to look for a Puzzle Pirates client + on the same display (on OCEAN, if --ocean was used). --notes SOURCE - Use SOURCE as the vessel notes; default is "vessel-notes" in the - current directory. See below. SOURCE may be of the following forms: - SCHEME:... eg http:... URL, fetched with Tcl's http package - |COMMAND ARG ARG command (Tcl list) whose output is the notes - NOTES-FILE ordinary file + Use SOURCE as the vessel notes. See below. + SOURCE may be of the following forms: + empty argument No notes, this is the default + SCHEME:... eg http:... URL, fetched with Tcl's http package + |COMMAND ARG ARG command (Tcl list) whose output is the notes + NOTES-FILE ordinary file --vessel-info-source RSYNC-SRC Update information about vessels, subclasses, icons, etc. from diff --git a/yarrg/where-vessels b/yarrg/where-vessels index 4e6a225..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 @@ -1246,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 ----- @@ -1314,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 @@ -1358,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 @@ -1385,7 +1404,9 @@ 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" } @@ -1464,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 @@ -1475,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/. -- 2.30.2