This is the mail archive of the xconq7@sources.redhat.com mailing list for the Xconq project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

tree code


'Tree code' for civ game.
I'd welcome any comments on this..

--- tcltk/tkconq.tcl.orig	Thu Jan  9 05:47:28 2003
+++ tcltk/tkconq.tcl	Thu Jan  9 05:55:00 2003
@@ -4702,6 +4702,9 @@
     pack .help.bot.t -side right -fill both -expand true
     pack .help.bot.t.txt -side left -fill both -expand true
 
+    Tree .help.bot.t.txt.tree -padx 2 -relief flat -bg $lcolor \
+      -highlightbackground $lcolor -height 0 -width 0 -highlightcolor $lcolor
+
     canvas .help.bot.t.txt.img -width 32 -height 32 \
 	-bg $lcolor -highlightbackground $lcolor
     imfsample .help.bot.t.txt.img.samp -width 32 -height 32 -bg $lcolor
@@ -4804,6 +4807,38 @@
 
     .help.bot.t.txt yview moveto 0
     .help.bot.t.txt configure -state disabled
+
+    .help.bot.t.txt window create end -window .help.bot.t.txt.tree
+
+    .help.bot.t.txt.tree configure -height 0 -width 0
+    .help.bot.t.txt.tree delete [.help.bot.t.txt.tree nodes root]
+    if { $nclass == "a"} {
+        .help.bot.t.txt.tree bindText <ButtonPress-1> clicknode
+        .help.bot.t.txt.tree configure -height 25 -width 55
+ 	.help.bot.t.txt.tree insert end root [getn $key] -text $key -open 1
+        addnode [getn $key] 1
+     }
+}
+
+proc clicknode { node } {
+    help_goto "[atype_name $node]"
+}
+
+proc getn { key } {
+    for { set i 0 } { $i < [numatypes]} { incr i } {
+        if { [atype_name $i] == $key } { return $i }
+    }
+}
+
+proc addnode { key dep } {
+    for { set i 0 } { $i < [numatypes] } { incr i } {
+        if { [ advance_needed_to_research $key $i] == 1 && ![.help.bot.t.txt.tree exists $i]} {
+            incr dep 
+            if { $dep < 6 } { set opennode 1 } else { set opennode 0 } 
+            .help.bot.t.txt.tree insert end $key $i -text [atype_name $i] -open $opennode
+            addnode $i $dep
+        }
+    }
 }
 
 proc scrolled_listbox { f args } {

-- 
MA, Dunzi


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]