Class: Osu::DB::Beatmap
- Inherits:
-
Object
- Object
- Osu::DB::Beatmap
- Defined in:
- lib/osu-db/beatmap.rb
Overview
Structure of osu!.db
-
str[rdoc-ref:StringIO#read_str] #artist, #artist_unicode, #title, #title_unicode, #creator, #version: metadata section in .osu
-
str[rdoc-ref:StringIO#read_str] #audio_filename: general section in .osu
-
str[rdoc-ref:StringIO#read_str] #beatmapcode: digest of Beatmap
-
str[rdoc-ref:StringIO#read_str] #osu_filename:
-
int[rdoc-ref:StringIO#read_int] #type: see BeatmapType
-
int[rdoc-ref:StringIO#read_int] #circles, #sliders, #spinners: the number of circles, sliders and spinners
-
time[rdoc-ref:StringIO#read_time] #last_edit:
-
int[rdoc-ref:StringIO#read_int] #approach_rate, #circle_size, #hp_drain_rate, #overall_difficulty: difficulty section in .osu
-
double[rdoc-ref:StringIO#read_double] #slider_multiplier: difficulty section in .osu
-
int[rdoc-ref:StringIO#read_int] #draining_time: or play time, in second
-
int[rdoc-ref:StringIO#read_int] #total_time: the offset of the last hit object, in millisecond
-
int[rdoc-ref:StringIO#read_int] #preview_time: general section in .osu, in millisecond
-
TimingPoint #timing_points: timing points section in .osu
-
int[rdoc-ref:StringIO#read_int] #beatmapid, #beatmapsetid, #threadid: metadata section in .osu
-
int[rdoc-ref:StringIO#read_int] #ratings: user ratings for different GameMode
-
int[rdoc-ref:StringIO#read_int] #your_offset:
-
float[rdoc-ref:StringIO#read_float] #stack_leniency: general section in .osu
-
int[rdoc-ref:StringIO#read_int] #mode: see GameMode
-
str[rdoc-ref:StringIO#read_str] #source, #tags: metadata section in .osu
-
str[rdoc-ref:StringIO#read_int] #online_offset:
-
str[rdoc-ref:StringIO#read_str] #letterbox: general section in .osu
-
bool[rdoc-ref:StringIO#read_bool] #played?:
-
time[rdoc-ref:StringIO#read_time] #last_play:
-
0
-
str[rdoc-ref:StringIO#read_str] #path: beatmap directory
-
time[rdoc-ref:StringIO#read_time] #last_sync:
-
bool[rdoc-ref:StringIO#read_bool] #ignore_hitsound?, #ignore_skin?, #disable_storyboard?: visual settings
-
int[rdoc-ref:StringIO#read_int] #background_dim: visual settings
-
0
-
unknown
-
_0|7_
Instance Attribute Summary collapse
-
#approach_rate ⇒ Object
readonly
Returns the value of attribute approach_rate.
-
#artist ⇒ Object
readonly
Returns the value of attribute artist.
-
#artist_unicode ⇒ Object
readonly
Returns the value of attribute artist_unicode.
-
#audio_filename ⇒ Object
readonly
Returns the value of attribute audio_filename.
-
#background_dim ⇒ Object
readonly
Returns the value of attribute background_dim.
-
#beatmapcode ⇒ Object
readonly
Returns the value of attribute beatmapcode.
-
#beatmapid ⇒ Object
readonly
Returns the value of attribute beatmapid.
-
#beatmapsetid ⇒ Object
readonly
Returns the value of attribute beatmapsetid.
-
#circle_size ⇒ Object
readonly
Returns the value of attribute circle_size.
-
#circles ⇒ Object
readonly
Returns the value of attribute circles.
-
#creator ⇒ Object
readonly
Returns the value of attribute creator.
-
#disable_storyboard ⇒ Object
(also: #disable_storyboard?)
readonly
Returns the value of attribute disable_storyboard.
-
#draining_time ⇒ Object
readonly
Returns the value of attribute draining_time.
-
#hp_drain_rate ⇒ Object
readonly
Returns the value of attribute hp_drain_rate.
-
#ignore_hitsound ⇒ Object
(also: #ignore_hitsound?)
readonly
Returns the value of attribute ignore_hitsound.
-
#ignore_skin ⇒ Object
(also: #ignore_skin?)
readonly
Returns the value of attribute ignore_skin.
-
#int1 ⇒ Object
readonly
Returns the value of attribute int1.
-
#int2 ⇒ Object
readonly
Returns the value of attribute int2.
-
#last_edit ⇒ Object
readonly
Returns the value of attribute last_edit.
-
#last_play ⇒ Object
readonly
Returns the value of attribute last_play.
-
#last_sync ⇒ Object
readonly
Returns the value of attribute last_sync.
-
#letterbox ⇒ Object
readonly
Returns the value of attribute letterbox.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#online_offset ⇒ Object
readonly
Returns the value of attribute online_offset.
-
#osu_filename ⇒ Object
readonly
Returns the value of attribute osu_filename.
-
#overall_difficulty ⇒ Object
readonly
Returns the value of attribute overall_difficulty.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#played ⇒ Object
(also: #played?)
readonly
Returns the value of attribute played.
-
#preview_time ⇒ Object
readonly
Returns the value of attribute preview_time.
-
#ratings ⇒ Object
readonly
Returns the value of attribute ratings.
-
#slider_multiplier ⇒ Object
readonly
Returns the value of attribute slider_multiplier.
-
#sliders ⇒ Object
readonly
Returns the value of attribute sliders.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#spinners ⇒ Object
readonly
Returns the value of attribute spinners.
-
#stack_leniency ⇒ Object
readonly
Returns the value of attribute stack_leniency.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#threadid ⇒ Object
readonly
Returns the value of attribute threadid.
-
#timing_points ⇒ Object
readonly
Returns the value of attribute timing_points.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#title_unicode ⇒ Object
readonly
Returns the value of attribute title_unicode.
-
#total_time ⇒ Object
readonly
Returns the value of attribute total_time.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
-
#your_offset ⇒ Object
readonly
Returns the value of attribute your_offset.
-
#zero1 ⇒ Object
readonly
Returns the value of attribute zero1.
-
#zero2 ⇒ Object
readonly
Returns the value of attribute zero2.
Instance Method Summary collapse
- #audio_path ⇒ Object
- #beatmap_url ⇒ Object
- #beatmapset_url ⇒ Object
-
#initialize(ios = nil) ⇒ Beatmap
constructor
A new instance of Beatmap.
- #load(ios) ⇒ Object
- #osu_path ⇒ Object
- #thread_url ⇒ Object
Constructor Details
#initialize(ios = nil) ⇒ Beatmap
Returns a new instance of Beatmap.
78 79 80 |
# File 'lib/osu-db/beatmap.rb', line 78 def initialize(ios = nil) load(ios) if ios end |
Instance Attribute Details
#approach_rate ⇒ Object (readonly)
Returns the value of attribute approach_rate.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def approach_rate @approach_rate end |
#artist ⇒ Object (readonly)
Returns the value of attribute artist.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def artist @artist end |
#artist_unicode ⇒ Object (readonly)
Returns the value of attribute artist_unicode.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def artist_unicode @artist_unicode end |
#audio_filename ⇒ Object (readonly)
Returns the value of attribute audio_filename.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def audio_filename @audio_filename end |
#background_dim ⇒ Object (readonly)
Returns the value of attribute background_dim.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def background_dim @background_dim end |
#beatmapcode ⇒ Object (readonly)
Returns the value of attribute beatmapcode.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def beatmapcode @beatmapcode end |
#beatmapid ⇒ Object (readonly)
Returns the value of attribute beatmapid.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def beatmapid @beatmapid end |
#beatmapsetid ⇒ Object (readonly)
Returns the value of attribute beatmapsetid.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def beatmapsetid @beatmapsetid end |
#circle_size ⇒ Object (readonly)
Returns the value of attribute circle_size.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def circle_size @circle_size end |
#circles ⇒ Object (readonly)
Returns the value of attribute circles.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def circles @circles end |
#creator ⇒ Object (readonly)
Returns the value of attribute creator.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def creator @creator end |
#disable_storyboard ⇒ Object (readonly) Also known as: disable_storyboard?
Returns the value of attribute disable_storyboard.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def disable_storyboard @disable_storyboard end |
#draining_time ⇒ Object (readonly)
Returns the value of attribute draining_time.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def draining_time @draining_time end |
#hp_drain_rate ⇒ Object (readonly)
Returns the value of attribute hp_drain_rate.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def hp_drain_rate @hp_drain_rate end |
#ignore_hitsound ⇒ Object (readonly) Also known as: ignore_hitsound?
Returns the value of attribute ignore_hitsound.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def ignore_hitsound @ignore_hitsound end |
#ignore_skin ⇒ Object (readonly) Also known as: ignore_skin?
Returns the value of attribute ignore_skin.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def ignore_skin @ignore_skin end |
#int1 ⇒ Object (readonly)
Returns the value of attribute int1.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def int1 @int1 end |
#int2 ⇒ Object (readonly)
Returns the value of attribute int2.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def int2 @int2 end |
#last_edit ⇒ Object (readonly)
Returns the value of attribute last_edit.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def last_edit @last_edit end |
#last_play ⇒ Object (readonly)
Returns the value of attribute last_play.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def last_play @last_play end |
#last_sync ⇒ Object (readonly)
Returns the value of attribute last_sync.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def last_sync @last_sync end |
#letterbox ⇒ Object (readonly)
Returns the value of attribute letterbox.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def letterbox @letterbox end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def mode @mode end |
#online_offset ⇒ Object (readonly)
Returns the value of attribute online_offset.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def online_offset @online_offset end |
#osu_filename ⇒ Object (readonly)
Returns the value of attribute osu_filename.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def osu_filename @osu_filename end |
#overall_difficulty ⇒ Object (readonly)
Returns the value of attribute overall_difficulty.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def overall_difficulty @overall_difficulty end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def path @path end |
#played ⇒ Object (readonly) Also known as: played?
Returns the value of attribute played.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def played @played end |
#preview_time ⇒ Object (readonly)
Returns the value of attribute preview_time.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def preview_time @preview_time end |
#ratings ⇒ Object (readonly)
Returns the value of attribute ratings.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def @ratings end |
#slider_multiplier ⇒ Object (readonly)
Returns the value of attribute slider_multiplier.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def @slider_multiplier end |
#sliders ⇒ Object (readonly)
Returns the value of attribute sliders.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def @sliders end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def source @source end |
#spinners ⇒ Object (readonly)
Returns the value of attribute spinners.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def spinners @spinners end |
#stack_leniency ⇒ Object (readonly)
Returns the value of attribute stack_leniency.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def stack_leniency @stack_leniency end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def @tags end |
#threadid ⇒ Object (readonly)
Returns the value of attribute threadid.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def threadid @threadid end |
#timing_points ⇒ Object (readonly)
Returns the value of attribute timing_points.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def timing_points @timing_points end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def title @title end |
#title_unicode ⇒ Object (readonly)
Returns the value of attribute title_unicode.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def title_unicode @title_unicode end |
#total_time ⇒ Object (readonly)
Returns the value of attribute total_time.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def total_time @total_time end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def type @type end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def version @version end |
#your_offset ⇒ Object (readonly)
Returns the value of attribute your_offset.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def your_offset @your_offset end |
#zero1 ⇒ Object (readonly)
Returns the value of attribute zero1.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def zero1 @zero1 end |
#zero2 ⇒ Object (readonly)
Returns the value of attribute zero2.
60 61 62 |
# File 'lib/osu-db/beatmap.rb', line 60 def zero2 @zero2 end |
Instance Method Details
#audio_path ⇒ Object
82 83 84 |
# File 'lib/osu-db/beatmap.rb', line 82 def audio_path "#{path}\\#{audio_filename}".gsub('\\', File::SEPARATOR) end |
#beatmap_url ⇒ Object
90 91 92 |
# File 'lib/osu-db/beatmap.rb', line 90 def beatmap_url "http://osu.ppy.sh/b/#{beatmapid}" end |
#beatmapset_url ⇒ Object
94 95 96 |
# File 'lib/osu-db/beatmap.rb', line 94 def beatmapset_url "http://osu.ppy.sh/s/#{beatmapsetid}" end |
#load(ios) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/osu-db/beatmap.rb', line 102 def load(ios) @artist = ios.read_str @artist_unicode = ios.read_str @title = ios.read_str @title_unicode = ios.read_str @creator = ios.read_str @version = ios.read_str @audio_filename = ios.read_str @beatmapcode = ios.read_str @osu_filename = ios.read_str @type = BeatmapType[ios.read_int 1] @circles, @sliders, @spinners = *ios.unpack(6, 'v*') @last_edit = ios.read_time # approach_rate(??) might be different from that in .osu @approach_rate, @circle_size, @hp_drain_rate, @overall_difficulty = *ios.unpack(4, 'C*') @slider_multiplier = ios.read_double @draining_time, @total_time, @preview_time = *ios.unpack(12, 'V*') # PreviewTime: -1 @preview_time = nil if @preview_time == 0xFFFFFFFF n = ios.read_int 4 @timing_points = Array.new(n) do bpm = ios.read_double offset = ios.read_double type = ios.read_bool (type ? RegularTimingPoint : InheritedTimingPoint).new(offset, bpm) end @beatmapid = ios.read_int 4 @beatmapsetid = ios.read_int 4 @threadid = ios.read_int 4 @ratings = ios.unpack(4, 'C*') @your_offset = ios.read_signed_int 2 @stack_leniency = ios.read_float @mode = GameMode[ios.read_int 1] @source = ios.read_str @tags = ios.read_str @online_offset = ios.read_signed_int 2 @letterbox = ios.read_str @played = !ios.read_bool @last_play = ios.read_time # if !@played && @last_play != nil # raise DBCorruptError, "played=%s doesn't match last_play=%s" % # [@played, @last_play].map{|i| i.inspect} # end @zero1 = ios.read_int 1 # TODO: =0 raise if @zero1 != 0 @path = ios.read_str @last_sync = ios.read_time @ignore_hitsound = ios.read_bool @ignore_skin = ios.read_bool @disable_storyboard = ios.read_bool @background_dim = ios.read_int 1 # @disable_video is not saved @zero2 = ios.read_int 1 # TODO: =0 raise if @zero2 != 0 @int1 = ios.read_int 4 # TODO: almost=0 @int2 = ios.read_int 1 # TODO: almost=0, otherwise=7 raise unless @int2 == 0 || @int2 == 7 # 0 iff original mode only end |
#osu_path ⇒ Object
86 87 88 |
# File 'lib/osu-db/beatmap.rb', line 86 def osu_path "#{path}\\#{osu_filename}".gsub('\\', File::SEPARATOR) end |
#thread_url ⇒ Object
98 99 100 |
# File 'lib/osu-db/beatmap.rb', line 98 def thread_url "http://osu.ppy.sh/forum/t/#{threadid}" end |