From 4ac9681428e6213734d198f5e4ebaa9f0c11de6f Mon Sep 17 00:00:00 2001 From: nveid Date: Wed, 13 Sep 2006 06:51:22 +0000 Subject: [PATCH] changes system update removed changes.sh and made indexing all that sweetass shit happen in genchanges.rb --- game/txt/changes.sh | 14 ------- game/txt/genchanges.rb | 93 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 87 insertions(+), 20 deletions(-) delete mode 100644 game/txt/changes.sh diff --git a/game/txt/changes.sh b/game/txt/changes.sh deleted file mode 100644 index ba4e44e..0000000 --- a/game/txt/changes.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -# First generate our changes file -ruby genchanges.rb - -# Create Entries Index -cat changes.txt | perl index-files.pl > changes.idx - -# Then combine the two -cat changes.idx >> changes.txt - -# Then we clean up our mess -#mv changes.new changes.txt -rm changes.idx diff --git a/game/txt/genchanges.rb b/game/txt/genchanges.rb index f6442a2..74e38b9 100644 --- a/game/txt/genchanges.rb +++ b/game/txt/genchanges.rb @@ -4,8 +4,25 @@ # and place the & help entry appropriately above the highest version # level # +# +class Array + def tabulate(rowwidth=80,spacing=8) + width = inject(0) { |m,i| [m,i.length].max } + spacing + cols = rowwidth / width + rows = [[]] + each { |i| + rows << [] if rows.last.size >= cols + rows.last << i + } + rows.map { |i| i.map { |j| j.ljust(width) }.join.strip } + end +end + + $cur_version = "0.00" +entry_header = "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n" + # Simple add changes to it def chfname(filename) @@ -55,6 +72,25 @@ changes_files.each do |file| end end +# Next Split our changes list into 2 seperate areas.. old & the new version schemes +newversions = Array.new +oldversions = Array.new +ni = 0 +oi = 0 +changes_files.each do |file| + if FileTest.file?("changes/#{file}") + if /^\d.\d\d?[ab]?([p-]\d)?[ab]?$/ =~ file then + newversions[ni] = file + ni += 1 + else + oldversions[oi] = file + oi += 1 + end + end +end +newversions = newversions.sort.reverse +oldversions = oldversions.sort.reverse + # Ok.. Nowe that we have cur_version.. Now we're gonna compile our master helpfile. # Whenever we run across cur_version that is where we'll thrwo the & help # entry right ontop @@ -63,13 +99,58 @@ end # Open our new changes.txt first cfile = File.new("changes.txt", "w") -changes_files.each do |file| - if FileTest.file?(chfname(file)) - if $cur_version == file then - cfile << "& help\n" - end - cfile << File.read(chfname(file)) +newversions.each do |file| + if $cur_version == file then + cfile << "& help\n" end + cfile << File.read(chfname(file)) end +oldversions.each do |file| + cfile << File.read(chfname(file)) +end + +# close the file.. so.. we may reloop through this & build our entries ending thingie cfile.close + +# Now we're gonna reopen the changes file in append and read mode to add our entries +# entry +changes = File.open("changes.txt", "a+") +i = -1 +entries = Array.new + + +changes.each_line do |cur_line| + if i == -1 + i = 0 + # This is where we open a new file.. a + elsif cur_line[0,1] == "&" + curname = String.new(cur_line) + curname[0] = " " + curname = curname.strip + entries[i] = curname + i += 1 + end +end + +changes << "& Entries\n" +changes << entry_header +line = 0 +page = 1 +entries.tabulate.each do |entry| + line += 1 + if line == 9 then + page += 1 + changes << "\n" + changes << "More changes entries listed in entries#{page}".center(80) + changes << "\n" + changes << entry_header + changes << "& Entries#{page}\n" + changes << entry_header + line = 0 + end + changes << "#{entry}\n" +end + +changes << entry_header +changes.close -- 2.30.2