~vitty/armagetronad/trunk-armagetronad-breakpad

402 by nemostultae
You can now get/set configuration items through Armagetronad::TOldConf:
1
module Armagetronad
2
  
3
  class TOldConf < TConfItemBase
4
    def self.get_config_item(name)
5
      ci = find_config_item(name)
6
      raise(RuntimeError, "Configuration item #{name} does not exist.") if ci.nil?
7
      ci
8
    end
9
    
10
    def self.update_config_item(name, value)
11
      ci = get_config_item(name)
12
      return ci.set(value) if ci.respond_to?(:set)
13
      ci.read_val(Istringstream.new(value.to_s))
14
    end
15
    
16
    def self.method_missing(name, *args, &block)
17
      name = name.to_s
18
      if args.size.zero?
19
        get_config_item(name)
20
      elsif args.size == 1
21
        update_config_item(name.delete("="), args.first)
22
      # multiple arguments are parsed together into a string
23
      else
24
        update_config_item(name, args.join(" "))
25
      end
26
    end
27
  end
28
  
29
end