six-updater-web 0.19.4 → 0.19.5

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require 'rake/testtask'
7
7
 
8
8
  spec = Gem::Specification.new do |s|
9
9
  s.name = 'six-updater-web'
10
- s.version = '0.19.4'
10
+ s.version = '0.19.5'
11
11
  s.has_rdoc = false
12
12
  #s.extra_rdoc_files = ['README', 'LICENSE']
13
13
  s.summary = 'Your summary here'
@@ -20,6 +20,6 @@ module AppsettingsHelper
20
20
  end
21
21
 
22
22
  def type_form_column(record, t, options)
23
- collection_select(:record, :type, ["Arma2Appsetting", "Arma2OaAppsetting"], :to_s, :to_s, {}, {:name => options[:name]})
23
+ collection_select(:record, :type, ["Arma2Appsetting", "Arma2StAppsetting", "Arma2OaAppsetting", "Arma2OaStAppsetting", "Arma2OaCoAppsetting"], :to_s, :to_s, {}, {:name => options[:name]})
24
24
  end
25
25
  end
@@ -5,6 +5,17 @@ class Appsetting < ActiveRecord::Base
5
5
  has_many :sixconfigs
6
6
  six_guid
7
7
 
8
+ # Defaults to ArmA2 atm...
9
+ SPECIFIC = false
10
+ FRIENDLY_NAME = "ArmA 2 (Any)"
11
+
12
+ # TODO: Auto enumurate from model properties?
13
+ # folders: expansion, common, addons
14
+ # files: arma2.exe, arma2server.exe (-.exe for linux), arma2oa.exe, arma2oaserver.exe, addons/chernarus.pbo
15
+ FAMILY = Hash.new
16
+ FAMILY["Arma2"] = [["arma2.exe", "arma2server.exe"], {"Arma2St" => []}]
17
+ FAMILY["Arma2Oa"] = [["arma2oa.exe", "arma2oaserver.exe"], {"Arma2OaCo" => ["addons/"], "Arma2OaSt" => ["!addons/"]}]
18
+
8
19
  DEFAULT_EXE = "arma2.exe"
9
20
  DEFAULT_EXE_PATH = ""
10
21
  DEFAULT_BETA_EXE = "arma2.exe"
@@ -14,20 +25,16 @@ class Appsetting < ActiveRecord::Base
14
25
  DEFAULT_MODS_PARAM = "-mod=" # TODO
15
26
  DEFAULT_BETA_MODS = ["beta"]
16
27
 
17
- REGKEY = ['SOFTWARE\\Bohemia Interactive Studio\\ArmA 2', 'MAIN']
18
-
19
28
  # TODO: Windows-only
20
- DEFAULT_PATH = begin; Win32::Registry.open(Win32::Registry::HKEY_LOCAL_MACHINE, REGKEY[0])[REGKEY[1]]; rescue; nil; end
21
-
22
- =begin
23
- before_save :check_values
24
- def check_values
25
- # TODO: Fix hardcoding
26
- if self.type.nil? || !(["Appsetting", "Arma2Appsetting", "Arma2OaAppsetting"].include?(self.type))
27
- self.type = "Appsetting"
28
- end
29
+ REGKEYS = {"Arma2Oa" => ['SOFTWARE\\Bohemia Interactive Studio\\ArmA 2 OA', 'MAIN'], "Arma2" => ['SOFTWARE\\Bohemia Interactive Studio\\ArmA 2', 'MAIN']}
30
+ path = nil
31
+
32
+ self::REGKEYS.each_pair do |k, v|
33
+ path = begin; Win32::Registry.open(Win32::Registry::HKEY_LOCAL_MACHINE, v[0])[v[1]]; rescue; nil; end
34
+ break if path
29
35
  end
30
- =end
36
+ DEFAULT_PATH = path
37
+
31
38
 
32
39
  def to_updater_yml
33
40
  hash = Hash.new
@@ -42,21 +49,87 @@ class Appsetting < ActiveRecord::Base
42
49
  hash
43
50
  end
44
51
 
45
- def found_type
46
- case self.real_exe
47
- when "arma2.exe"
48
- Arma2StAppsetting.found_type
49
- when "arma2oa.exe"
50
- Arma2OaAppsetting.found_type
51
- else
52
- self.class
53
- end
52
+ def self.label
53
+ #self.to_s.sub("Appsetting", "")
54
+ self::FRIENDLY_NAME
54
55
  end
55
56
 
56
- def self.label
57
+ def self.short
57
58
  self.to_s.sub("Appsetting", "")
58
59
  end
59
60
 
61
+ def detect_edition
62
+ return self.class if self.class::SPECIFIC
63
+ return self.class unless self.real_path
64
+ game = nil
65
+ cond = nil
66
+ ed = nil
67
+ self.class::FAMILY.each_pair do |key, value|
68
+ found = false
69
+ # Find game
70
+ value[0].each do |e|
71
+ case e
72
+ when /\/$/
73
+ # folder
74
+ found = File.directory?(File.join(self.real_path, e))
75
+ else
76
+ # file
77
+ case RUBY_PLATFORM
78
+ when /-mingw32$/, /-mswin32$/
79
+ else
80
+ e = e.clone
81
+ e.sub!(/\.exe$/)
82
+ end
83
+ found = File.exists?(File.join(self.real_path, e))
84
+ end
85
+ break if found
86
+ end
87
+ next unless found
88
+ game = key
89
+
90
+ # Find edition
91
+ found = nil
92
+ cond = true
93
+ ed = nil
94
+ value[1].each_pair do |edition, conditions|
95
+ ed = edition
96
+ conditions.each do |condition|
97
+ c = condition.clone
98
+ reverse = c.sub!(/^!/, "")
99
+ case c
100
+ when /\/$/
101
+ # folder
102
+ found = File.directory?(File.join(self.real_path, c))
103
+ else
104
+ case RUBY_PLATFORM
105
+ when /-mingw32$/, /-mswin32$/
106
+ else
107
+ c = c.clone
108
+ c.sub!(/\.exe$/)
109
+ end
110
+ # file
111
+ found = File.exists?(File.join(self.real_path, c))
112
+ end
113
+ cond = reverse ? !found : found
114
+ break if cond
115
+ end
116
+ game = ed if cond
117
+ next unless cond
118
+ end
119
+ end
120
+
121
+ return nil unless game
122
+ Object.const_get("#{game}Appsetting")
123
+ end
124
+
125
+ def found_type
126
+ #Arma2StAppsetting
127
+ # TODO: Add detection support based on user settings (exe/path)
128
+ return self.class unless self.real_path
129
+ d = self.detect_edition
130
+ d ? d : self.class
131
+ end
132
+
60
133
  def found_types
61
134
  self.found_type.types
62
135
  end
@@ -1,6 +1,7 @@
1
1
  class Arma2Appsetting < Appsetting
2
+
2
3
  # Default game (Appsetting) is atm arma2
3
- def found_type
4
- Arma2StAppsetting
5
- end
4
+ #def found_type
5
+ # Arma2StAppsetting
6
+ #end
6
7
  end
@@ -1,20 +1,18 @@
1
1
  class Arma2OaAppsetting < Arma2Appsetting
2
+ FRIENDLY_NAME = "A2 Op. Arrowhead (Any)"
3
+
4
+ # TODO: Specific server support like done with Beta?
2
5
  DEFAULT_EXE = "arma2oa.exe"
3
6
  DEFAULT_BETA_EXE = "arma2oa.exe"
4
7
  DEFAULT_BETA_EXE_PATH = "expansion/beta"
5
- REGKEY = ['SOFTWARE\\Bohemia Interactive Studio\\ArmA 2 OA', 'MAIN']
8
+ REGKEYS = {"Arma2Oa" => ['SOFTWARE\\Bohemia Interactive Studio\\ArmA 2 OA', 'MAIN']}
9
+
10
+ FAMILY = Hash.new
11
+ FAMILY["Arma2Oa"] = [["arma2oa.exe", "arma2oaserver.exe"], {"Arma2OaCo" => ["addons/"], "Arma2OaSt" => ["!addons/"]}]
6
12
 
7
- def found_type
8
- return self.class unless self.real_path
9
- # TODO: Alternative ways to figure out the edition? Find arma2.exe? etc
10
- dir = File.join(self.real_path, "addons")
11
- rdir = File.directory?(dir) ? dir : File.join(self.real_path, "Addons")
12
- rdir = File.join(self.real_path, "AddOns") unless File.directory?(rdir)
13
+ # def found_type
14
+ # return self.class unless self.real_path
15
+ # self.detect_edition
16
+ # end
13
17
 
14
- if File.exists?(File.join(rdir, "chernarus.pbo")) || File.exists?(File.join(rdir, "Chernarus.pbo"))
15
- Arma2OaCoAppsetting
16
- else
17
- Arma2OaStAppsetting
18
- end
19
- end
20
18
  end
@@ -1,5 +1,6 @@
1
1
  class Arma2OaCoAppsetting < Arma2OaAppsetting
2
- #Code here
2
+ FRIENDLY_NAME = "A2 Op. Arrowhead (Combined Ops)"
3
+ SPECIFIC = true
3
4
 
4
5
  # TODO: Evaluate
5
6
  # Perhaps look at adding a boolean: specific, so when it is enabled, non of the inherited editions can be used?
@@ -1,3 +1,3 @@
1
- class Arma2OaCo < Arma2OaStMod
1
+ class Arma2OaCoMod < Arma2OaStMod
2
2
  #Code here
3
3
  end
@@ -1,3 +1,5 @@
1
1
  class Arma2OaStAppsetting < Arma2OaAppsetting
2
+ FRIENDLY_NAME = "A2 Op. Arrowhead (Standalone)"
3
+ SPECIFIC = true
2
4
  #Code here
3
5
  end
@@ -1,3 +1,2 @@
1
1
  class Arma2OaStMod < Arma2OaMod
2
- #Code here
3
2
  end
@@ -1,3 +1,5 @@
1
1
  class Arma2StAppsetting < Arma2Appsetting
2
- #Code here
2
+ FRIENDLY_NAME = "ArmA 2 (Standalone)"
3
+ SPECIFIC = true
4
+ REGKEYS = {"Arma2" => ['SOFTWARE\\Bohemia Interactive Studio\\ArmA 2', 'MAIN']}
3
5
  end
@@ -29,11 +29,15 @@ class Mod < ActiveRecord::Base
29
29
  self.to_s.sub("Mod", "")
30
30
  end
31
31
 
32
+ def self.short
33
+ self.to_s.sub("Mod", "")
34
+ end
35
+
32
36
  def self.types
33
37
  return [Arma2Mod] if self.class == Appsetting
34
38
  e = self
35
39
  unless e.nil? || [Mod, ActiveRecord::Base].include?(e)
36
- types << e.label
40
+ types << e
37
41
  e = e.class
38
42
  end
39
43
  types
@@ -46,7 +50,7 @@ class Mod < ActiveRecord::Base
46
50
  # setting.type == "ArmA2OaSt" (ArmA2Oa, ArmA2)
47
51
  # self.type == "ArmA2Oa"
48
52
  return nil if setting.nil?
49
- self.type.nil? ? true : setting.found_types.map{|e| e.label }.include?(self.class.label)
53
+ self.type.nil? ? true : setting.found_types.map{|e| e.short }.include?(self.class.short)
50
54
  end
51
55
 
52
56
  def real_name
@@ -61,24 +61,16 @@
61
61
  %table{ :border => 1, :cellpadding => "5", :width => "100%"}
62
62
  %tr
63
63
  %td
64
- Edition: #{link_to @current_setting.nice_found_type, nil, :title => "Supports mods for: #{@current_setting.found_types.map{|e| e.label}.join(", ")}" } Autoskip: #{@autoskip ? @autoskip : false}.
65
- Last sync
66
- - if @system_setting.synchronized_at
67
- = time_ago_in_words(@system_setting.synchronized_at)
68
- ago,
69
- - else
70
- never,
71
- Gamespy
72
- - if @system_setting.gamespied_at
73
- = time_ago_in_words(@system_setting.gamespied_at)
74
- ago.
75
- - else
76
- never.
64
+ Edition: #{link_to @current_setting.nice_found_type, nil, :title => "Supports mods for: #{@current_setting.found_types.map{|e| e.label}.join(", ")}" },
65
+ Last sync #{@system_setting.synchronized_at ? time_ago_in_words(@system_setting.synchronized_at) + " ago" : "never"}
66
+ Gamespy #{@system_setting.gamespied_at ? time_ago_in_words(@system_setting.gamespied_at) + " ago" : "never"}
77
67
  %br
78
68
  %br
79
69
  = @msg.join("<br />")
80
70
  %br
81
- - if (@check.size + @skip.size + @install.size) > 0
71
+ Autoskip: #{@autoskip ? "Enabled" : "Disaabled"}.
72
+ %br
73
+ - if (@check.size + @skip.size + @install.size + @disabled.size) > 0
82
74
  - if @check.size > 0
83
75
  %br
84
76
  To be checked:
@@ -22,7 +22,7 @@ case RUBY_VERSION
22
22
  end
23
23
 
24
24
  module SixUpdaterWeb
25
- VERSION = "0.19.4"
25
+ VERSION = "0.19.5"
26
26
  COMPONENT = "six-updater-web"
27
27
 
28
28
  DEFAULT_IP = "127.0.0.1" unless defined?(DEFAULT_IP)
@@ -1,2 +1,2 @@
1
- Any changes made to files in sub-folders will be lost.
2
- See http://activescaffold.com/tutorials/faq#custom-css.
1
+ Any changes made to files in sub-folders will be lost.
2
+ See http://activescaffold.com/tutorials/faq#custom-css.
@@ -1,2 +1,2 @@
1
- Any changes made to files in sub-folders will be lost.
2
- See http://activescaffold.com/tutorials/faq#custom-css.
1
+ Any changes made to files in sub-folders will be lost.
2
+ See http://activescaffold.com/tutorials/faq#custom-css.
@@ -1,2 +1,2 @@
1
- Any changes made to files in sub-folders will be lost.
2
- See http://activescaffold.com/tutorials/faq#custom-css.
1
+ Any changes made to files in sub-folders will be lost.
2
+ See http://activescaffold.com/tutorials/faq#custom-css.
@@ -145,9 +145,9 @@ module Six
145
145
  def real_exe
146
146
  if exe.nil?
147
147
  if self.beta
148
- self.class::DEFAULT_BETA_EXE_PATH.size == 0 ? self.class::DEFAULT_BETA_EXE : "#{self.class::DEFAULT_BETA_EXE_PATH}/#{self.class::DEFAULT_BETA_EXE}"
148
+ self.detect_edition::DEFAULT_BETA_EXE_PATH.size == 0 ? self.detect_edition::DEFAULT_BETA_EXE : "#{self.detect_edition::DEFAULT_BETA_EXE_PATH}/#{self.detect_edition::DEFAULT_BETA_EXE}"
149
149
  else
150
- self.class::DEFAULT_EXE_PATH.size == 0 ? self.class::DEFAULT_EXE : "#{self.class::DEFAULT_EXE_PATH}/#{self.class::DEFAULT_EXE}"
150
+ self.detect_edition::DEFAULT_EXE_PATH.size == 0 ? self.detect_edition::DEFAULT_EXE : "#{self.detect_edition::DEFAULT_EXE_PATH}/#{self.detect_edition::DEFAULT_EXE}"
151
151
  end
152
152
  else
153
153
  exe
@@ -156,7 +156,7 @@ module Six
156
156
 
157
157
  def real_params
158
158
  if params.nil?
159
- self.class::DEFAULT_PARAMS
159
+ self.detect_edition::DEFAULT_PARAMS
160
160
  else
161
161
  params
162
162
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 19
8
- - 4
9
- version: 0.19.4
8
+ - 5
9
+ version: 0.19.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sickboy