@@ -872,7 +872,15 @@ Follows is a source code listing for all files that have been open sourced. This
872
872
class AudioHash < Hash
873
873
def volume
874
874
@volume ||= 1.0
875
- @volume
875
+ if $args.gtk.production &&
876
+ $args.state.tick_count != 0 &&
877
+ $args.inputs.keyboard.has_focus
878
+ @volume
879
+ elsif !$args.gtk.production
880
+ @volume
881
+ else
882
+ 0.0
883
+ end
876
884
end
877
885
878
886
def volume= value
@@ -1731,7 +1739,7 @@ Follows is a source code listing for all files that have been open sourced. This
1731
1739
1732
1740
def inputs_scroll_up_half? args
1733
1741
return false if @disabled
1734
- args.inputs.keyboard.ctrl_u
1742
+ args.inputs.keyboard.ctrl_u || args.inputs.keyboard.ctrl_b
1735
1743
end
1736
1744
1737
1745
def scroll_up_half
@@ -1752,7 +1760,7 @@ Follows is a source code listing for all files that have been open sourced. This
1752
1760
1753
1761
def inputs_scroll_down_half? args
1754
1762
return false if @disabled
1755
- args.inputs.keyboard.ctrl_d
1763
+ args.inputs.keyboard.ctrl_d || args.inputs.keyboard.ctrl_f
1756
1764
end
1757
1765
1758
1766
def inputs_clear_command? args
@@ -3452,6 +3460,11 @@ Follows is a source code listing for all files that have been open sourced. This
3452
3460
attr label
3453
3461
end
3454
3462
3463
+ alias_method :dpad_up, :directional_up
3464
+ alias_method :dpad_down, :directional_down
3465
+ alias_method :dpad_left, :directional_left
3466
+ alias_method :dpad_right, :directional_right
3467
+
3455
3468
def back
3456
3469
@select
3457
3470
end
@@ -4681,6 +4694,16 @@ Follows is a source code listing for all files that have been open sourced. This
4681
4694
class KeyboardKeys
4682
4695
include Serialize
4683
4696
4697
+ def self.alias_method from, to
4698
+ @aliases ||= {}
4699
+ @aliases[from] = to
4700
+ super from, to
4701
+ end
4702
+
4703
+ def self.aliases
4704
+ @aliases
4705
+ end
4706
+
4684
4707
attr_accessor :tilde, :underscore, :double_quotation_mark,
4685
4708
:exclamation_point, :at, :hash, :dollar,
4686
4709
:percent, :caret, :ampersand, :asterisk,
@@ -4715,6 +4738,8 @@ Follows is a source code listing for all files that have been open sourced. This
4715
4738
:left_arrow, :right_arrow, :up_arrow, :down_arrow, :page_up, :page_down,
4716
4739
:forward_slash, :back_slash
4717
4740
4741
+ attr_accessor :w_scancode, :a_scancode, :s_scancode, :d_scancode
4742
+
4718
4743
alias_method :section_sign, :section
4719
4744
alias_method :equal_sign, :equal
4720
4745
alias_method :dollar_sign, :dollar
@@ -4893,6 +4918,15 @@ Follows is a source code listing for all files that have been open sourced. This
4893
4918
}
4894
4919
end
4895
4920
4921
+ def self.scancode_to_method_hash
4922
+ @scancode_to_method ||= {
4923
+ 26 => :w_scancode,
4924
+ 4 => :a_scancode,
4925
+ 22 => :s_scancode,
4926
+ 7 => :d_scancode
4927
+ }
4928
+ end
4929
+
4896
4930
def self.sdl_to_key raw_key, modifier
4897
4931
return nil unless (raw_key >= 0 && raw_key <= 255) ||
4898
4932
raw_key == 1073741903 ||
@@ -5140,12 +5174,13 @@ Follows is a source code listing for all files that have been open sourced. This
5140
5174
def get collection
5141
5175
return [] if collection.length == 0
5142
5176
collection.map do |m|
5143
- if m.end_with_bang?
5177
+ resolved_m = KeyboardKeys.aliases[m] || m
5178
+ if resolved_m.end_with_bang?
5144
5179
clear_after_return = true
5145
5180
end
5146
5181
5147
- value = self.instance_variable_get("@#{m .without_ending_bang}".to_sym)
5148
- clear_key m if clear_after_return
5182
+ value = self.instance_variable_get("@#{resolved_m .without_ending_bang}".to_sym)
5183
+ clear_key resolved_m if clear_after_return
5149
5184
[m.without_ending_bang, value]
5150
5185
end
5151
5186
end
@@ -5155,7 +5190,8 @@ Follows is a source code listing for all files that have been open sourced. This
5155
5190
@scrubbed_ivars = nil
5156
5191
5157
5192
collection.each do |m|
5158
- m_to_s = m.to_s
5193
+ resolved_m = KeyboardKeys.aliases[m] || m
5194
+ m_to_s = resolved_m.to_s
5159
5195
self.instance_variable_set("@#{m_to_s}".to_sym, value) if m_to_s.strip.length > 0
5160
5196
rescue Exception => e
5161
5197
raise e, <<-S
@@ -5245,7 +5281,7 @@ Follows is a source code listing for all files that have been open sourced. This
5245
5281
#
5246
5282
# @return [Boolean]
5247
5283
def left
5248
- @key_up.left || @key_held.left || a || false
5284
+ @key_up.left || @key_held.left || a_scancode || false
5249
5285
end
5250
5286
5251
5287
def left_arrow
@@ -5256,7 +5292,7 @@ Follows is a source code listing for all files that have been open sourced. This
5256
5292
#
5257
5293
# @return [Boolean]
5258
5294
def right
5259
- @key_up.right || @key_held.right || d || false
5295
+ @key_up.right || @key_held.right || d_scancode || false
5260
5296
end
5261
5297
5262
5298
def right_arrow
@@ -5267,7 +5303,7 @@ Follows is a source code listing for all files that have been open sourced. This
5267
5303
#
5268
5304
# @return [Boolean]
5269
5305
def up
5270
- @key_up.up || @key_held.up || w || false
5306
+ @key_up.up || @key_held.up || w_scancode || false
5271
5307
end
5272
5308
5273
5309
def up_arrow
@@ -5278,7 +5314,7 @@ Follows is a source code listing for all files that have been open sourced. This
5278
5314
#
5279
5315
# @return [Boolean]
5280
5316
def down
5281
- @key_up.down || @key_held.down || s || false
5317
+ @key_up.down || @key_held.down || s_scancode || false
5282
5318
end
5283
5319
5284
5320
def down_arrow
@@ -5639,18 +5675,26 @@ Follows is a source code listing for all files that have been open sourced. This
5639
5675
keyboard.up || (controller_one && controller_one.up)
5640
5676
end
5641
5677
5678
+ alias_method :up_with_wasd, :up
5679
+
5642
5680
def down
5643
5681
keyboard.down || (controller_one && controller_one.down)
5644
5682
end
5645
5683
5684
+ alias_method :down_with_wasd, :down
5685
+
5646
5686
def left
5647
5687
keyboard.left || (controller_one && controller_one.left)
5648
5688
end
5649
5689
5690
+ alias_method :left_with_wasd, :left
5691
+
5650
5692
def right
5651
5693
keyboard.right || (controller_one && controller_one.right)
5652
5694
end
5653
5695
5696
+ alias_method :right_with_wasd, :right
5697
+
5654
5698
def directional_vector
5655
5699
keyboard.directional_vector ||
5656
5700
(controller_one && controller_one.directional_vector)
@@ -5666,6 +5710,8 @@ Follows is a source code listing for all files that have been open sourced. This
5666
5710
return 0
5667
5711
end
5668
5712
5713
+ alias_method :left_right_with_wasd, :left_right
5714
+
5669
5715
def left_right_arrow
5670
5716
return -1 if keyboard.left_arrow || (controller_one && controller_one.directional_left)
5671
5717
return 1 if keyboard.right_arrow || (controller_one && controller_one.directional_right)
@@ -5674,12 +5720,32 @@ Follows is a source code listing for all files that have been open sourced. This
5674
5720
5675
5721
alias_method :left_right_directional, :left_right_arrow
5676
5722
5723
+ def left_right_perc
5724
+ if controller_one && controller_one.left_analog_x_perc != 0
5725
+ controller_one.left_analog_x_perc
5726
+ else
5727
+ left_right
5728
+ end
5729
+ end
5730
+
5731
+ alias_method :left_right_perc_with_wasd, :left_right_perc
5732
+
5733
+ def left_right_directional_perc
5734
+ if controller_one && controller_one.left_analog_x_perc != 0
5735
+ controller_one.left_analog_x_perc
5736
+ else
5737
+ left_right_directional
5738
+ end
5739
+ end
5740
+
5677
5741
def up_down
5678
5742
return 1 if self.up
5679
5743
return -1 if self.down
5680
5744
return 0
5681
5745
end
5682
5746
5747
+ alias_method :up_down_with_wasd, :up_down
5748
+
5683
5749
def up_down_arrow
5684
5750
return 1 if keyboard.up_arrow || (controller_one && controller_one.directional_up)
5685
5751
return -1 if keyboard.down_arrow || (controller_one && controller_one.directional_down)
@@ -5688,6 +5754,14 @@ Follows is a source code listing for all files that have been open sourced. This
5688
5754
5689
5755
alias_method :up_down_directional, :up_down_arrow
5690
5756
5757
+ def up_down_perc
5758
+ if controller_one && controller_one.left_analog_y_perc != 0
5759
+ controller_one.left_analog_y_perc
5760
+ else
5761
+ up_down_directional
5762
+ end
5763
+ end
5764
+
5691
5765
def click
5692
5766
return nil unless @mouse.click
5693
5767
return @mouse.click.point
@@ -8907,7 +8981,7 @@ Follows is a source code listing for all files that have been open sourced. This
8907
8981
if @last_recorded_input_was_ignored
8908
8982
stopped_at -= stopped_at - @last_recorded_input_was_ignored_at
8909
8983
end
8910
- text = "replay_version 2.0 \n"
8984
+ text = "replay_version 2.1 \n"
8911
8985
text << "stopped_at #{stopped_at}\n"
8912
8986
text << "seed #{@seed_number}\n"
8913
8987
text << "recorded_at #{Time.now.to_s}\n"
@@ -8969,7 +9043,9 @@ Follows is a source code listing for all files that have been open sourced. This
8969
9043
text = @runtime.read_file file_name
8970
9044
return false unless text
8971
9045
8972
- if text.each_line.first.strip != "replay_version 2.0"
9046
+ replay_version = text.each_line.first.strip.gsub("replay_version ", "")
9047
+
9048
+ if replay_version != "2.0" && replay_version != "2.1"
8973
9049
raise "The replay file #{file_name} is not compatible with this version of DragonRuby Game Toolkit. Please recreate the replay (sorry)."
8974
9050
end
8975
9051
@@ -9052,6 +9128,7 @@ Follows is a source code listing for all files that have been open sourced. This
9052
9128
value_2 = __parse_replay_value__ value_2
9053
9129
value_3 = __parse_replay_value__ value_3
9054
9130
9131
+
9055
9132
# create a dictionary entry for the input
9056
9133
$replay_data[:input_history][tick_count.to_i] ||= []
9057
9134
$replay_data[:input_history][tick_count.to_i] << {
@@ -9062,6 +9139,42 @@ Follows is a source code listing for all files that have been open sourced. This
9062
9139
value_3: value_3,
9063
9140
value_count: value_count.to_i
9064
9141
}
9142
+
9143
+ # added scancodes and changed args.inputs.left_right's implementation to look for
9144
+ # (w|a|s|d)_scancode instead of (w|a|s|d). because of this replay versions 2.0 need to insert
9145
+ # a scancode entry for key_(down|up)_raw wasd
9146
+ if replay_version == "2.0"
9147
+ if name == :key_down_raw || name == :key_up_raw
9148
+ scancode_name = if name == :key_down_raw
9149
+ :scancode_down_raw
9150
+ else
9151
+ :scancode_up_raw
9152
+ end
9153
+
9154
+ scancode_value_1 = if value_1 == 119 # ascii w
9155
+ 26
9156
+ elsif value_1 == 97 # ascii a
9157
+ 4
9158
+ elsif value_1 == 115 # ascii s
9159
+ 22
9160
+ elsif value_1 == 100 # ascii d
9161
+ 7
9162
+ else
9163
+ nil
9164
+ end
9165
+
9166
+ if scancode_value_1
9167
+ $replay_data[:input_history][tick_count.to_i] << {
9168
+ id: id.to_i,
9169
+ name: scancode_name,
9170
+ value_1: scancode_value_1,
9171
+ value_2: value_2,
9172
+ value_3: value_3,
9173
+ value_count: value_count.to_i
9174
+ }
9175
+ end
9176
+ end
9177
+ end
9065
9178
else
9066
9179
raise "Replay data seems corrupt. I don't know how to parse #{l}."
9067
9180
end
@@ -10760,6 +10873,7 @@ Follows is a source code listing for all files that have been open sourced. This
10760
10873
core_files_to_reload + @required_files
10761
10874
else
10762
10875
[
10876
+ 'dragon/cvar.rb',
10763
10877
'dragon/docs.rb',
10764
10878
'dragon/help.rb',
10765
10879
'dragon/kernel_docs.rb',
@@ -11109,6 +11223,10 @@ Follows is a source code listing for all files that have been open sourced. This
11109
11223
@simulation_speed = @simulation_speed.abs
11110
11224
@simulation_speed = 1 if @simulation_speed == 0
11111
11225
11226
+ if cli_arguments.keys.include? :scale
11227
+ set_window_scale cli_arguments[:scale].to_f
11228
+ end
11229
+
11112
11230
if cli_arguments.keys.include? :record
11113
11231
@argsv_processed = true
11114
11232
seed = cli_arguments[:seed] || 100
0 commit comments