From 803460a1d33d37939f2d23c8d3fd134d49252465 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 8 Aug 2010 19:26:25 +0100 Subject: [PATCH] where-vessels: More improvements to lack-of-ownership handling --- yarrg/README.where-vessels | 6 ++++ yarrg/where-vessels | 65 +++++++++++++++++++++++++++++--------- 2 files changed, 56 insertions(+), 15 deletions(-) diff --git a/yarrg/README.where-vessels b/yarrg/README.where-vessels index 6fb21c2..7678784 100644 --- a/yarrg/README.where-vessels +++ b/yarrg/README.where-vessels @@ -52,6 +52,12 @@ OPTIONS: |COMMAND ARG ARG command (Tcl list) whose output is the notes NOTES-FILE ordinary file + --filter-separate-lock-owner + In the filter, show two separate 3-button filters for the lock + status, and the ship owner, rather than one 9-button filter with + an option for each combination. (If there are no notes, only + one 3-button filter, for the lock status, is shown, anyway.) + --vessel-info-source RSYNC-SRC Update information about vessels, subclasses, icons, etc. from RSYNC-SRC. Default is yarrg.chiark.net::yarrg/vessel-info. diff --git a/yarrg/where-vessels b/yarrg/where-vessels index b926492..78342db 100755 --- a/yarrg/where-vessels +++ b/yarrg/where-vessels @@ -105,7 +105,7 @@ 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 +set filter_lockown_separate 0 proc parseargs {} { global ai argv @@ -122,6 +122,7 @@ proc parseargs {} { --local-html-dir { lappend scraper --local-html-dir=[nextarg] } --notes { glset notes_loc [nextarg] } --vessel-info-source { glset info_source [nextarg] } + --filter-separate-lock-owner { glset filter_lockown_separate 1 } --debug { incr debug } default { badusage "unknown option $arg" } } @@ -130,6 +131,11 @@ proc parseargs {} { if {[llength $argv]} { badusage "non-option args not allowed" } } +proc have-notes {} { + global notes_loc + return [string length $notes_loc] +} + proc argdefaults {} { global ocean notes_loc pirate scraper if {![info exists ocean] || @@ -142,8 +148,13 @@ proc argdefaults {} { error "$ocean $pirate ?" } } - if {![info exists pirate]} { set pirate {}; glset no_owners 1 } - if {![string length $notes_loc]} { glset no_owners 1 } + if {![info exists pirate]} { + set pirate {} + glset filter_lockown_separate 1 + } + if {![have-notes]} { + glset filter_lockown_separate 1 + } lappend scraper $ocean } @@ -445,8 +456,7 @@ proc show-report-decode {code} { {(All lock states)} {(Not battle ready)} } $lock] - global no_owners notes_loc - if {!$no_owners} { + if {[have-notes]} { switch -exact $notown { 0 { report-set own "Yours" } 1 { report-set own "Other pirate's" } @@ -458,7 +468,7 @@ proc show-report-decode {code} { } global smash_xabbrev_map - if {![string length $notes_loc]} { + if {![have-notes]} { } elseif {[llength $smash_xabbrev_map]} { if {[string length $xabbrev]} { report-set xabbrev "(Flags: $xabbrev)" @@ -648,8 +658,7 @@ proc make-smashers {} { make-radio-smasher subclass Class smash_subclass \ {Show Normal/LE Hide} 1 0 - global no_owners - glset smash_owner [expr {$no_owners ? 3 : 0}] + glset smash_owner [expr {[have-notes] ? 0 : 3}] make-radio-smasher owner Owner smash_owner \ {Show Yours? {For you} Lock Hide} 2 3 @@ -682,6 +691,26 @@ proc filter-says-yes/size {codel} { return $yes } +proc filter-values/lock {} { return {0 1 2} } +proc filter-icon/lock {lock} { return [code-lockown2icon ${lock}3] } +proc filter-default/lock {lock} { return 1 } +proc filter-says-yes/lock {codel} { + regexp {^.} [lindex $codel 3] lock + upvar #0 filter_lock($lock) yes + debug "FILTER-SAYS-YES/LOCK $codel $lock $yes" + return $yes +} + +proc filter-values/own {} { return {0 1 2} } +proc filter-icon/own {own} { return [code-lockown2icon 3${own}] } +proc filter-default/own {own} { return 1 } +proc filter-says-yes/own {codel} { + regexp {.$} [lindex $codel 3] own + upvar #0 filter_own($own) yes + debug "FILTER-SAYS-YES/OWN $codel $own $yes" + return $yes +} + proc filter-values/lockown {} { foreach lv {0 1 2} { foreach ov {0 1 2} { @@ -775,8 +804,16 @@ proc make-filter {fil label ekind} { } proc make-filters {} { + global filter_lockown_separate make-tickbox-filter size Size 2 0 - make-tickbox-filter lockown "Lock/\nowner" 2 6 + if {!$filter_lockown_separate} { + make-tickbox-filter lockown "Lock/\nowner" 2 6 + } else { + make-tickbox-filter lock "Lock" 1 0 + if {[have-notes]} { + make-tickbox-filter own "Owner" 1 0 + } + } make-entry-filter xabbre "Flags\n regexp" {} } @@ -1255,7 +1292,7 @@ proc islandnames-handler {offset maxchars} { #---------- main user interface ---------- proc widgets-setup {} { - global canvas debug pirate ocean filterstyle notes_loc + global canvas debug pirate ocean filterstyle wm geometry . 1200x800 if {[string length $pirate]} { @@ -1330,7 +1367,7 @@ proc widgets-setup {} { pack .cp.ctrl.notes -side top -pady 2 - if {![string length $notes_loc]} { + if {![have-notes]} { .cp.ctrl.notes.do configure -state disabled } @@ -1375,8 +1412,6 @@ 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 @@ -1404,7 +1439,7 @@ proc show-report {islandname code} { } else { set owndesc "Owner unknown" } - if {!$no_owners} { + if {[have-notes]} { .cp.report.list insert end "$owndesc:" } foreach name $owned($owner) { @@ -1485,7 +1520,7 @@ if {[catch { parse-clipboard } emsg]} { puts stderr "$emsg\n$errorInfo" exit 1 } -if {[string length $notes_loc]} { +if {[have-notes]} { after idle invoke_notes } -- 2.30.2