chiark / gitweb /
where-vessels: icons for lock state too
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Mon, 14 Dec 2009 02:47:17 +0000 (02:47 +0000)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Mon, 14 Dec 2009 02:47:17 +0000 (02:47 +0000)
yarrg/icons/battle.xbm
yarrg/icons/borrow.xbm [new file with mode: 0644]
yarrg/icons/dot.xbm [new file with mode: 0644]
yarrg/icons/ours.xbm
yarrg/icons/query.xbm
yarrg/icons/sl.xbm
yarrg/icons/unlocked.xbm
yarrg/where-vessels

index c9b20cc6443661d7e26426775164418e66aa4833..a180c3c1515a865cbace5991e3e5a509b354f057 100644 (file)
@@ -1,4 +1,4 @@
 #define battle_width 5
 #define battle_height 9
 static unsigned char battle_bits[] = {
-   0x0e, 0x0a, 0x0e, 0x04, 0x11, 0x0a, 0x04, 0x0a, 0x11};
+   0x00, 0x0e, 0x0e, 0x0e, 0x15, 0x1b, 0x0e, 0x1b, 0x11};
diff --git a/yarrg/icons/borrow.xbm b/yarrg/icons/borrow.xbm
new file mode 100644 (file)
index 0000000..598f76c
--- /dev/null
@@ -0,0 +1,4 @@
+#define borrow_width 5
+#define borrow_height 9
+static unsigned char borrow_bits[] = {
+   0x00, 0x00, 0x00, 0x04, 0x0a, 0x04, 0x00, 0x00, 0x00};
diff --git a/yarrg/icons/dot.xbm b/yarrg/icons/dot.xbm
new file mode 100644 (file)
index 0000000..c551fca
--- /dev/null
@@ -0,0 +1,4 @@
+#define unlocked_width 5
+#define unlocked_height 9
+static unsigned char unlocked_bits[] = {
+   0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00};
index 6471fcaba8244b1c55aed37ac4ab7a4277c78185..1c4aa86ec99296a5728d9648e06dbcd06e0fd392 100644 (file)
@@ -1,4 +1,4 @@
 #define ours_width 5
 #define ours_height 9
 static unsigned char ours_bits[] = {
-   0x07, 0x04, 0x07, 0x04, 0x04, 0x0e, 0x11, 0x11, 0x0e};
+   0x00, 0x00, 0x0f, 0x09, 0x09, 0x09, 0x0f, 0x04, 0x00};
index 1281460f90ea237a1bebb0389409694f85340362..42d73de59b0f49283b63d4dede34f35e350b8809 100644 (file)
@@ -1,4 +1,4 @@
-#define no-owner_width 5
-#define no-owner_height 9
-static unsigned char no-owner_bits[] = {
-   0x0e, 0x11, 0x10, 0x10, 0x08, 0x04, 0x04, 0x00, 0x04};
+#define query_width 5
+#define query_height 9
+static unsigned char query_bits[] = {
+   0x0e, 0x11, 0x11, 0x10, 0x08, 0x04, 0x04, 0x00, 0x04};
index 64a8b65ce6071e88433bce9f50eedbff191dff94..3b6c118f6aea5dc3c8adea096eb4dd10c29a12e4 100644 (file)
@@ -1,5 +1,5 @@
 #define sl_width 12
 #define sl_height 10
 static unsigned char sl_bits[] = {
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, 0x00,
-   0x60, 0x00, 0x40, 0x00, 0xf8, 0x03, 0x00, 0x00};
+   0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, 0x00, 0x60, 0x00,
+   0x40, 0x00, 0xf8, 0x03, 0x00, 0x00, 0x00, 0x00};
index b98cc0714b1b18d14e3eefded10a0ffc04b5ac87..c551fca6416a99ed8b19397c382104094584319c 100644 (file)
@@ -1,4 +1,4 @@
 #define unlocked_width 5
 #define unlocked_height 9
 static unsigned char unlocked_bits[] = {
-   0x06, 0x09, 0x10, 0x10, 0x08, 0x1f, 0x11, 0x11, 0x1f};
+   0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00};
index ec4394b1e2aaef66b8b10c0fc1ecab1e6caa521e..2e625c1e12e12815ec9ad13a3acf9ec51e0fc4d4 100755 (executable)
@@ -264,8 +264,20 @@ proc vesselclasses-init {} {
        set vc_game2code($game) $code
        set vc_code2abbrev($code) $abbrev
        set vc_code2full($code) $full
-       image create bitmap ship-icon/$abbrev -file icons/$abbrev.xbm
+       load-icon $abbrev
     }
+
+    load-icon unlocked
+    load-icon locked
+    load-icon battle
+    load-icon borrow
+    load-icon query
+    load-icon ours
+    load-icon dot
+}
+
+proc load-icon {icon} {
+    image create bitmap icon/$icon -file icons/$icon.xbm
 }
 
 proc code2abbrev-lock {lockown} {
@@ -274,10 +286,10 @@ proc code2abbrev-lock {lockown} {
     append abbrev [lindex {= - ?} [regsub {\D} $notown 2]]
 }    
 
-proc canvas-horiz-stack {xvar y bind type args} {
+proc canvas-horiz-stack {xvar xoff y bind type args} {
     upvar 1 $xvar x
     upvar 1 canvas canvas
-    set id [eval $canvas create $type $x $y $args]
+    set id [eval $canvas create $type [expr {$x+$xoff}] $y $args]
     set bbox [$canvas bbox $id]
     set x [lindex $bbox 2]
     $canvas bind $id <ButtonPress> $bind
@@ -292,22 +304,40 @@ proc code2canvas {code canvas x yvar qty qtylen bind} {
 
     set stackx $x
     incr stackx 2
+    set imy [expr {$y+2}]
 
     append qty [lindex {? {}} $inport]
     set qty [format "%${qtylen}s" $qty]
 
-    set qtyid [canvas-horiz-stack stackx $y $bind \
+    set qtyid [canvas-horiz-stack stackx $y $bind \
                   text -anchor nw -font fixed -text $qty]
 
-    incr stackx -1
-    canvas-horiz-stack stackx [expr {$y+2}] $bind \
-           image -anchor nw -image ship-icon/$vc_code2abbrev($class)
-    incr stackx
+    canvas-horiz-stack stackx -1 $imy $bind \
+           image -anchor nw -image icon/$vc_code2abbrev($class)
 
-    canvas-horiz-stack stackx $y $bind \
-       text -anchor nw -font fixed -text \
-       "$subclass[code2abbrev-lock $lockown]$xabbrev"
+    if {[string length $subclass]} {
+       canvas-horiz-stack stackx 0 $y $bind \
+           text -anchor nw -font fixed -text \
+           $subclass
+    }
+
+    manyset [split $lockown ""] lock notown
 
+    incr stackx
+    canvas-horiz-stack stackx 0 $imy $bind \
+       image -anchor nw -image icon/[lindex {battle dot locked} $lock]
+    incr stackx
+    canvas-horiz-stack stackx 0 $imy $bind \
+       image -anchor nw -image icon/[lindex {ours dot query} \
+                                         [regsub {\D} $notown 2]]
+    incr stackx
+    
+    if {[string length $xabbrev]} {
+       canvas-horiz-stack stackx 0 $y $bind \
+           text -anchor nw -font fixed -text \
+           $xabbrev
+    }
+    
     set bbox [$canvas bbox $qtyid]
     set ny [lindex $bbox 3]
     set bid [$canvas create rectangle \
@@ -361,7 +391,7 @@ set filters {}
 proc filter-values/size {} { global vc_codes; return $vc_codes }
 proc filter-icon/size {code} {
     upvar #0 vc_code2abbrev($code) abb
-    return ship-icon/$abb
+    return icon/$abb
 }
 proc filter-default/size {code} { return 1 }
 proc filter-says-yes/size {codel} {