chiark / gitweb /
where-vessels: No notes is default. Better treatment of lack of notes/ownership
[ypp-sc-tools.db-test.git] / yarrg / where-vessels
index 4e6a2250388cc8f53a015bb36bd54945f2a15678..b9264923f6b25e4fadda724fe9db250465875cfd 100755 (executable)
@@ -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/.