chiark / gitweb /
where-vessels: No notes is default. Better treatment of lack of notes/ownership
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 8 Aug 2010 18:07:46 +0000 (19:07 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 8 Aug 2010 19:59:56 +0000 (20:59 +0100)
yarrg/README.where-vessels
yarrg/where-vessels

index 190b7b3cabdba527296b29ec8f5b452b3c179060..6fb21c279e6ca7c09026b80cf2e1b6b3cc04b4fa 100644 (file)
@@ -17,7 +17,7 @@ USAGE:
 
     In where-vessels, click "Acquire"
 
 
     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
 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:
 ========
 
 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
 
  --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
 
  --vessel-info-source RSYNC-SRC
      Update information about vessels, subclasses, icons, etc. from
index 4e6a2250388cc8f53a015bb36bd54945f2a15678..b9264923f6b25e4fadda724fe9db250465875cfd 100755 (executable)
@@ -101,10 +101,11 @@ proc nextarg {} {
     return $v
 }
 
     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 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
 
 proc parseargs {} {
     global ai argv
@@ -131,7 +132,8 @@ proc parseargs {} {
 
 proc argdefaults {} {
     global ocean notes_loc pirate scraper
 
 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 }
        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 ?"
        }
     }
            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
 }
 
     lappend scraper $ocean
 }
 
@@ -440,17 +445,21 @@ proc show-report-decode {code} {
        {(All lock states)} {(Not battle ready)}
     } $lock]
 
        {(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
     }
 
     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 {
        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 ----------
 
 
 #---------- smashing ----------
 
-set smash_subclass 0
-set smash_owner 0
-
 proc smash-code {code} {
     manyset [split $code _] inport size subclass lockown xabbrev
 
 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
 
        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
 
     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
 
     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 {} {
 #---------- main user interface ----------
 
 proc widgets-setup {} {
-    global canvas debug pirate ocean filterstyle
+    global canvas debug pirate ocean filterstyle notes_loc
 
     wm geometry . 1200x800
 
     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 -----
 
 
     #----- map -----
 
@@ -1314,9 +1327,13 @@ proc widgets-setup {} {
     parser-control-create .cp.ctrl.notes \
        notes "Reload notes" \
        "Vessel notes loading report" \
     parser-control-create .cp.ctrl.notes \
        notes "Reload notes" \
        "Vessel notes loading report" \
-       
+
     pack .cp.ctrl.notes -side top -pady 2
 
     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
     #----- 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} {
 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
     .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"
        }
        } 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"
        }
        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
 }
     puts stderr "$emsg\n$errorInfo"
     exit 1
 }
-after idle invoke_notes
+if {[string length $notes_loc]} {
+    after idle invoke_notes
+}
 
 draw
 
 
 draw
 
@@ -1475,4 +1498,10 @@ if {$debug} {
        -prompt2 { return "> " }
 }
 
        -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/.