Sha256: 4288e186d496706baf40c0198aa3d8941ad068f00ad363d9b75509f873600e53

Contents?: true

Size: 1.87 KB

Versions: 3

Compression:

Stored size: 1.87 KB

Contents

class Appsetting < ActiveRecord::Base
  # FIXME: This should be done automatically
  include Six::Appmanager::Appsetting

  has_many :sixconfigs
  six_guid

  DEFAULT_EXE = "arma2.exe"
  DEFAULT_EXE_PATH = ""
  DEFAULT_BETA_EXE = "arma2.exe"
  DEFAULT_BETA_EXE_PATH = "beta"
  # TODO: Auto beta mod even?
  DEFAULT_PARAMS = "-showScriptErrors -noSplash -noFilePatching"
  DEFAULT_MODS_PARAM = "-mod=" # TODO
  DEFAULT_BETA_MODS = ["beta"]

  REGKEY = ['SOFTWARE\\Bohemia Interactive Studio\\ArmA 2', 'MAIN']

  # TODO: Windows-only
  DEFAULT_PATH = begin; Win32::Registry.open(Win32::Registry::HKEY_LOCAL_MACHINE, REGKEY[0])[REGKEY[1]]; rescue; nil; end

=begin
  before_save :check_values
  def check_values
    # TODO: Fix hardcoding
    if self.type.nil? || !(["Appsetting", "Arma2Appsetting", "Arma2OaAppsetting"].include?(self.type))
      self.type = "Appsetting"
    end
  end
=end

  def to_updater_yml
    hash = Hash.new
    attribute_names.each do |at|
      i = at.to_s
      i = "app_#{i}"
      value = eval(at)
      hash[i.to_sym] = value unless value.nil? || value.to_s.size == 0
    end
    hash[:app_path] = self.real_path unless hash[:app_path]
    hash[:app_exe] = self.real_exe unless hash[:app_exe]
    hash
  end

  def found_type
    case self.real_exe
      when "arma2.exe"
        Arma2StAppsetting.found_type
      when "arma2oa.exe"
        Arma2OaAppsetting.found_type
      else
        self.class
    end
  end

  def self.label
    self.to_s.sub("Appsetting", "")
  end

  def found_types
    self.found_type.types
  end

  def nice_found_type
    self.found_type.label
  end

  def self.types
    return [Arma2Appsetting] if self == Appsetting
    t = []
    e = self
    until e.nil? || [Appsetting, ActiveRecord::Base].include?(e) do
      t << e
      e = e.superclass
    end
    t
  end  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
six-updater-web-0.19.4 lib/six-updater-web/app/models/appsetting.rb
six-updater-web-0.19.3 lib/six-updater-web/app/models/appsetting.rb
six-updater-web-0.19.2 lib/six-updater-web/app/models/appsetting.rb