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]

Re: Civ game


  | > It is a awful patch, but this patch will make some strings clickable.
  | 
  | That works pretty good...except that from "Copper Melting", clicking on
  | "The Furnace" gets you to "The Merchant" ...
  | 
  | 	Steve

I have fixed it and added a 'tree widget' in the help dialog.
this patch requires BWiget-1.4.1 <http://sourceforge.net/projects/tcllib/>.

I have modified BWiget-1.4.1/tree.tcl;
	proc Tree::_get_node_name {path {item current} {tagindex end-1}} {
    +		return [string range [lrange [$path.c gettags $item] $tagindex end-1] 2 end]
    - 		return [string range [lindex [$path.c gettags $item] $tagindex] 2 end]
	}
but I am not sure it really need.


diff -u -r -N xconq.orig/tcltk/advance-needed-to-research.txt xconq/tcltk/advance-needed-to-research.txt
--- xconq.orig/tcltk/advance-needed-to-research.txt	Thu Jan  1 09:00:00 1970
+++ xconq/tcltk/advance-needed-to-research.txt	Fri Sep 20 02:14:15 2002
@@ -0,0 +1,158 @@
+"Advanced Flight" "Machine Tools"
+"Advanced Flight" "Radio"
+"Amphibious Warfare" "Tactics"
+"Amphibious Warfare" "Navigation"
+"Astronomy" "Mysticism"
+"Astronomy" "Mathematics"
+"Atomic Theory" "Theory of Gravity"
+"Atomic Theory" "Physics"
+"Automobile" "Combustion"
+"Automobile" "Steel"
+"Banking" "Trade"
+"Banking" "Republic"
+"Bridge Building" "Iron Working"
+"Bridge Building" "Construction"
+"Chemistry" "The University"
+"Chemistry" "Medicine"
+"Chivalry" "Feudalism"
+"Chivalry" "Horseback Riding"
+"Code of Laws" "Alphabet"
+"Combined Arms" "Mobile Warfare"
+"Combined Arms" "Advanced Flight"
+"Combustion" "Refining"
+"Combustion" "Explosives"
+"Communism" "Philosophy"
+"Communism" "Industrialization"
+"Computers" "Miniaturization"
+"Computers" "Mass Production"
+"Conscription" "Democracy"
+"Conscription" "Metallurgy"
+"Construction" "Masonry"
+"Construction" "Currency"
+"Corporation" "Economics"
+"Corporation" "Industrialization"
+"Currency" "Bronze Working"
+"Democracy" "Banking"
+"Democracy" "Invention"
+"Economics" "Banking"
+"Economics" "The University"
+"Electricity" "Metallurgy"
+"Electricity" "Magnetism"
+"Electronics" "Electricity"
+"Electronics" "Corporation"
+"Engineering" "The Wheel"
+"Engineering" "Construction"
+"Environmentalism" "Recycling"
+"Environmentalism" "Space Flight"
+"Espionage" "Democracy"
+"Espionage" "Communism"
+"Explosives" "Gunpowder"
+"Explosives" "Chemistry"
+"Feudalism" "Warrior Code"
+"Feudalism" "Monarchy"
+"Flight" "Combustion"
+"Flight" "Theory of Gravity"
+"Fundamentalism" "Monotheism"
+"Fundamentalism" "Conscription"
+"Fusion Power" "Nuclear Power"
+"Fusion Power" "Superconductor"
+"Future Technology" "Fusion Power"
+"Future Technology" "Recycling"
+"Genetic Engineering" "Medicine"
+"Genetic Engineering" "Corporation"
+"Guerrilla Warfare" "Communism"
+"Guerrilla Warfare" "Tactics"
+"Gunpowder" "Invention"
+"Gunpowder" "Iron Working"
+"Industrialization" "Railroad"
+"Industrialization" "Banking"
+"Invention" "Engineering"
+"Invention" "Literacy"
+"Iron Working" "Bronze Working"
+"Iron Working" "Warrior Code"
+"Labor Union" "Mass Production"
+"Labor Union" "Guerrilla Warfare"
+"The Laser" "Nuclear Power"
+"The Laser" "Mass Production"
+"Leadership" "Chivalry"
+"Leadership" "Gunpowder"
+"Literacy" "Writing"
+"Literacy" "Code of Laws"
+"Machine Tools" "Steel"
+"Machine Tools" "Tactics"
+"Magnetism" "Iron Working"
+"Magnetism" "Physics"
+"Map Making" "Alphabet"
+"Mass Production" "Automobile"
+"Mass Production" "Corporation"
+"Mathematics" "Alphabet"
+"Mathematics" "Masonry"
+"Medicine" "Philosophy"
+"Medicine" "Trade"
+"Metallurgy" "Gunpowder"
+"Metallurgy" "The University"
+"Miniaturization" "Machine Tools"
+"Miniaturization" "Electronics"
+"Mobile Warfare" "Automobile"
+"Mobile Warfare" "Tactics"
+"Monarchy" "Ceremonial Burial"
+"Monarchy" "Code of Laws"
+"Monotheism" "Philosophy"
+"Monotheism" "Polytheism"
+"Mysticism" "Ceremonial Burial"
+"Navigation" "Seafaring"
+"Navigation" "Astronomy"
+"Nuclear Fission" "Mass Production"
+"Nuclear Fission" "Atomic Theory"
+"Nuclear Power" "Nuclear Fission"
+"Nuclear Power" "Electronics"
+"Philosophy" "Mysticism"
+"Philosophy" "Literacy"
+"Physics" "Navigation"
+"Physics" "Literacy"
+"Plastics" "Refining"
+"Plastics" "Space Flight"
+"Polytheism" "Ceremonial Burial"
+"Polytheism" "Horseback Riding"
+"Radio" "Flight"
+"Radio" "Electricity"
+"Railroad" "Steam Engine"
+"Railroad" "Bridge Building"
+"Recycling" "Mass Production"
+"Recycling" "Democracy"
+"Refining" "Chemistry"
+"Refining" "Corporation"
+"Refrigeration" "Sanitation"
+"Refrigeration" "Electricity"
+"Republic" "Code of Laws"
+"Republic" "Literacy"
+"Robotics" "Plastics"
+"Robotics" "Computers"
+"Rocketry" "Advanced Flight"
+"Rocketry" "Electronics"
+"Sanitation" "Medicine"
+"Sanitation" "Engineering"
+"Seafaring" "Map Making"
+"Seafaring" "Pottery"
+"Space Flight" "Computers"
+"Space Flight" "Rocketry"
+"Stealth" "Superconductor"
+"Stealth" "Robotics"
+"Steam Engine" "Physics"
+"Steam Engine" "Invention"
+"Steel" "Metallurgy"
+"Steel" "Industrialization"
+"Superconductor" "The Laser"
+"Superconductor" "Plastics"
+"Tactics" "Leadership"
+"Tactics" "Conscription"
+"The University" "Mathematics"
+"The University" "Philosophy"
+"Theology" "Monotheism"
+"Theology" "Feudalism"
+"Theory of Gravity" "Astronomy"
+"Theory of Gravity" "The University"
+"Trade" "Currency"
+"Trade" "Code of Laws"
+"The Wheel" "Horseback Riding"
+"Writing" "Alphabet"
diff -u -r -N xconq.orig/tcltk/tkconq.tcl xconq/tcltk/tkconq.tcl
--- xconq.orig/tcltk/tkconq.tcl	Fri Sep 20 02:55:05 2002
+++ xconq/tcltk/tkconq.tcl	Fri Sep 20 02:38:44 2002
@@ -11,6 +11,13 @@
 wm title . "Xconq Main Window"
 wm withdraw .
 
+lappend auto_path BWidget-1.4.1
+package require BWidget                                                             
+
+text .help-tmp 
+set f [open "advance-needed-to-research.txt"]
+while { [gets $f line] >= 0 } { .help-tmp insert end "$line\n" }
+
 # Asking for a specific color sometimes loses...
 
 #set progress_bar_color black
@@ -3502,6 +3509,7 @@
 
     label .research.current -width 25 -height 2 -font $textfont
     pack .research.current -side top
+    frame .research.t
     listbox .research.topics -selectmode browse -width 25 \
 	    -yscrollcommand ".research.yscroll set" -relief sunken -borderwidth 2
     # Whether this scrollbar is actually needed depends on how many
@@ -3510,8 +3518,9 @@
     # is a user preference.
     scrollbar .research.yscroll -orient vert \
 	    -command ".research.topics yview"
-    pack .research.yscroll -side right -fill y
-    pack .research.topics -side top
+    pack .research.yscroll -side right -fill y -in .research.t
+    pack .research.topics -side top -in .research.t
+    pack .research.t
 
     button .research.ok -text "Research" -command ok_research
     pack .research.ok -side left -padx 5 -pady 5
@@ -4140,12 +4149,33 @@
     bind .help.bot.topics.list <ButtonRelease-1> { select_help_topic }
 
     frame .help.bot.t
-    text .help.bot.t.txt -width 60 -height 30 -font $textfont -wrap word \
+    text .help.bot.t.txt -width 60 -height 20 -font $textfont -wrap word \
 	    -yscrollcommand { .help.bot.t.scroll set }
     scrollbar .help.bot.t.scroll -command { .help.bot.t.txt yview }
+
+    frame .help.bot.t2
+    Tree .help.bot.t2.tree -padx 2 -height 10 -yscrollcommand { .help.bot.t2.scroll set }
+    scrollbar .help.bot.t2.scroll -command { .help.bot.t2.tree yview }
+
+    frame .help.bot.t3
+    button .help.bot.t3.b1 -text "Expand All"  -command { .help.bot.t2.tree opentree [.help.bot.t2.tree nodes root] }
+    button .help.bot.t3.b2 -text "Collapse All" -command { .help.bot.t2.tree closetree [.help.bot.t2.tree nodes root] }
+    button .help.bot.t3.b3 -text "Reset Tree"
+    button .help.bot.t3.b4 -text "Expand Unknown"
+    pack .help.bot.t3.b1 -side left
+    pack .help.bot.t3.b2 -side left
+    pack .help.bot.t3.b3 -side left
+    pack .help.bot.t3.b4 -side left
+
     pack .help.bot.t.txt -side left -fill both -expand true
     pack .help.bot.t.scroll -side right -fill y
+
+    pack .help.bot.t2.tree -side left -fill both -expand true
+    pack .help.bot.t2.scroll -side right -fill y
+
     pack .help.bot.t -side right -fill both -expand true
+    pack .help.bot.t2 -before .help.bot.t -side bottom -fill both -expand true
+    pack .help.bot.t3 -before .help.bot.t2 -side bottom
 
     set bgcolor [ .help.bot.t.txt cget -background ]
 
@@ -4197,8 +4227,77 @@
     }
     .help.bot.t.txt delete body.first body.last
     .help.bot.t.txt insert end "$contents" body
+    if { $nclass == "u" } { 
+    	set rxp "Required advances to build: "
+	set len [string length $rxp]
+	set xy [.help.bot.t.txt search $rxp 0.0 end]+28chars
+
+	set le [.help.bot.t.txt search . $xy]
+	set te ""
+	set cnt 0
+	
+	while { $te != $le } {
+		set te [.help.bot.t.txt search , $xy $le]
+		if { $te == "" } { set te $le }
+		.help.bot.t.txt tag add tag$cnt $xy $te
+		.help.bot.t.txt tag configure tag$cnt -relief raised -borderwidth 1
+		set moji [.help.bot.t.txt get $xy $te]
+		.help.bot.t.txt tag bind tag$cnt <Button-1> "help_goto \"$moji\""
+		incr cnt
+		set xy $te+1chars
+	}
+    }
+    if { $nclass == "a" } {
+	set cnt 0
+	foreach rxp { "Prerequisite advances: " "Enables: " } {
+		set tmp [.help.bot.t.txt search $rxp 0.0 end]
+		if { $tmp != "" } {
+			set len [string length $rxp]
+			set tmp $tmp+${len}chars
+			set xy [.help.bot.t.txt search " vs " $tmp]+4chars
+			set le [.help.bot.t.txt search . $xy]
+			set te ""
+
+        		while { $te != $le } {
+                		set te [.help.bot.t.txt search , $xy $le]
+                		if { $te == "" } { set te $le }
+                		.help.bot.t.txt tag add tagg$cnt $xy $te
+                		.help.bot.t.txt tag configure tagg$cnt -relief raised -borderwidth 1
+                		set moji [.help.bot.t.txt get $xy $te]
+                		.help.bot.t.txt tag bind tagg$cnt <Button-1> "help_goto \"$moji\""
+                		incr cnt
+                		set xy $te+2chars
+        		}		
+		}
+    	}
+    }
     .help.bot.t.txt yview moveto 0
     .help.bot.t.txt configure -state disabled
+
+    .help.bot.t2.tree delete [.help.bot.t2.tree nodes root]
+    if { $nclass == "a"} {
+    	.help.bot.t2.tree bindText <ButtonPress-1> "help_goto [.help.bot.t2.tree selection get]"
+
+    	.help.bot.t2.tree insert end root $key -text $key -open 1
+	addnode $key
+    }
+}
+
+proc addnode { key } {
+        set new1 [.help-tmp search -regexp ^\"$key 0.0]
+        if { $new1 != "" } {
+                set c ""
+                regexp "^\"$key\" \"(\[^\"\]+)\"" [ .help-tmp get $new1 ${new1}lineend ] a b
+		if { ![.help.bot.t2.tree exists $b] } {
+                	.help.bot.t2.tree insert end $key $b -text $b -open 1
+			addnode $b
+		}
+                regexp "^\"$key\" \"(\[^\"\]+)\"" [ .help-tmp get $new1+1lines ${new1}+2lines ] a c
+                if { $c != "" && ![.help.bot.t2.tree exists $c] } { 
+			.help.bot.t2.tree insert end $key $c -text $c -open 1 
+			addnode $c 
+		}
+        }
 }
 
 proc scrolled_listbox { f args } {


-- 
MA Dunzi <tadalunch@s5.xrea.com> http://tadalunch.s5.xrea.com/xconq/index.html


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