Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
mycard
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
syntax_j
mycard
Commits
520f249d
Commit
520f249d
authored
Apr 11, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BGM修正
parent
c4f8ee6d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
184 deletions
+5
-184
lib/main.rb
lib/main.rb
+2
-2
lib/ogginfo.rb
lib/ogginfo.rb
+0
-180
lib/scene.rb
lib/scene.rb
+3
-2
No files found.
lib/main.rb
View file @
520f249d
...
...
@@ -46,7 +46,7 @@ begin
WM
::
set_caption
(
"MyCard"
,
"MyCard"
)
WM
::
icon
=
Surface
.
load
(
"graphics/system/icon.gif"
)
$screen
=
Screen
.
open
(
$config
[
'screen'
][
'width'
],
$config
[
'screen'
][
'height'
],
0
,
HWSURFACE
|
(
$config
[
'screen'
][
'fullscreen'
]
?
FULLSCREEN
:
0
))
Mixer
.
open
(
Mixer
::
DEFAULT_FREQUENCY
,
Mixer
::
DEFAULT_FORMAT
,
Mixer
::
DEFAULT_CHANNELS
,
4096
)
Mixer
.
open
(
Mixer
::
DEFAULT_FREQUENCY
,
Mixer
::
DEFAULT_FORMAT
,
Mixer
::
DEFAULT_CHANNELS
,
1024
)
Mixer
.
set_volume_music
(
60
)
TTF
.
init
Thread
.
abort_on_exception
=
true
...
...
@@ -96,7 +96,7 @@ begin
$scene
.
main
while
$scene
rescue
Exception
=>
exception
exception
.
backtrace
.
each
{
|
backtrace
|
break
if
backtrace
=~
/^(.*)\.rb:\d+:in `.*'"$/
}
#由于脚本是从main.rb开始执行的,总会有个能匹配成功的文件
$log
.
fatal
(
$1
){[
exception
.
inspect
,
*
exception
.
backtrace
].
collect
{
|
str
|
str
.
encode
(
"UTF-8"
)}.
join
(
"
\n
"
)}
$log
.
fatal
(
$1
){[
exception
.
inspect
,
*
exception
.
backtrace
].
collect
{
|
str
|
str
.
force_encoding
(
"UTF-8"
)}.
join
(
"
\n
"
)}
$game
.
exit
if
$game
require_relative
'scene_error'
$scene
=
Scene_Error
.
new
...
...
lib/ogginfo.rb
deleted
100644 → 0
View file @
c4f8ee6d
# $Id$
# = Description
#
# ruby-ogginfo gives you access to low level information on ogg files
# (bitrate, length, samplerate, encoder, etc... ), as well as tag.
# It is written in pure ruby.
#
#
# = Download
#
#
# http://rubyforge.org/projects/ruby-ogginfo/
#
#
# = Generate documentation
#
# rdoc --template=kilmer ogginfo.rb
#
#
# = Changelog
#
# [0.1 20/06/2004]
#
# * first public version
#
#
# License:: Ruby
# Author:: Guillaume Pierronnet (mailto:moumar_AT__rubyforge_DOT_org)
# Website:: http://ruby-ogginfo.rubyforge.org/
#
# see http://www.xiph.org/ogg/vorbis/docs.html for documentation on vorbis format
# http://www.xiph.org/ogg/vorbis/doc/v-comment.html
#require "iconv"
# Raised on any kind of error related to ruby-ogginfo
class
OggInfoError
<
StandardError
;
end
class
OggInfo
=begin
FIELDS_MAPPING = {
"title" => "songname",
"artist" => "artist",
"album" => "album",
"date" => "year",
"description" => "comment",
"tracknumber" => "tracknum",
"genre" => "genre"
}
=end
attr_reader
:channels
,
:samplerate
,
:bitrate
,
:tag
,
:length
def
initialize
(
filename
,
charset
=
"iso-8859-1"
)
begin
@file
=
File
.
new
(
filename
,
"rb"
)
find_page
()
extract_infos
()
find_page
()
extract_tag
(
charset
)
extract_end
()
ensure
close
end
end
# "block version" of ::new()
def
self
.
open
(
filename
)
m
=
self
.
new
(
filename
)
ret
=
nil
if
block_given?
begin
ret
=
yield
(
m
)
ensure
m
.
close
end
else
ret
=
m
end
ret
end
def
close
@file
.
close
if
@file
and
not
@file
.
closed?
end
def
hastag?
not
@tag
.
empty?
end
def
to_s
"channels
#{
@channels
}
samplerate
#{
@samplerate
}
bitrate
#{
@bitrate
}
length
#{
@length
}
"
end
private
def
find_page
header
=
'OggS'
# 0xf4 . 0x67 . 0x 67 . 0x53
bytes
=
@file
.
read
(
4
)
bytes_read
=
4
while
header
!=
bytes
#raise OggInfoError if bytes_read > 4096 or @file.eof? #bytes.nil?
raise
OggInfoError
if
@file
.
eof?
#bytes.nil?
bytes
.
slice!
(
0
)
char
=
@file
.
read
(
1
)
bytes_read
+=
1
bytes
<<
char
end
end
def
extract_infos
# @bitrate = {}
@file
.
seek
(
35
,
IO
::
SEEK_CUR
)
# seek after "vorbis"
# @channels, @samplerate, @bitrate["upper"], @bitrate["nominal"], @bitrate["lower"] =
@channels
,
@samplerate
,
up_br
,
br
,
down_br
=
@file
.
read
(
17
).
unpack
(
"CV4"
)
@bitrate
=
if
br
==
0
if
up
==
2
**
32
-
1
or
down
==
2
**
32
-
1
0
else
(
up_br
+
down_br
)
/
2
end
else
br
end
end
def
extract_tag
(
charset
)
@tag
=
{}
@file
.
seek
(
22
,
IO
::
SEEK_CUR
)
segs
=
@file
.
read
(
1
).
unpack
(
"C"
)[
0
]
@file
.
seek
(
segs
+
7
,
IO
::
SEEK_CUR
)
size
=
@file
.
read
(
4
).
unpack
(
"V"
)[
0
]
@file
.
seek
(
size
,
IO
::
SEEK_CUR
)
tag_size
=
@file
.
read
(
4
).
unpack
(
"V"
)[
0
]
#ic = Iconv.new(charset, "utf8")
tag_size
.
times
do
|
i
|
size
=
@file
.
read
(
4
).
unpack
(
"V"
)[
0
]
com
=
@file
.
read
(
size
)
comment
=
com
comment
.
force_encoding
"UTF-8"
# begin
# comment = ic.iconv( com )
# rescue Iconv::IllegalSequence, Iconv::InvalidCharacter
# comment = com
# end
key
,
val
=
comment
.
split
(
/=/
)
@tag
[
key
.
downcase
]
=
val
end
#ic.close
end
def
extract_end
begin
#Errno::EINVAL
@file
.
seek
(
-
5000
,
IO
::
SEEK_END
)
#FIXME size of seeking
find_page
pos
=
@file
.
read
(
6
).
unpack
(
"x2 V"
)[
0
]
#FIXME pos is int64
@length
=
pos
.
to_f
/
@samplerate
rescue
Errno
::
EINVAL
@length
=
0
end
end
end
if
$0
==
__FILE__
while
filename
=
ARGV
.
shift
puts
"Getting info from
#{
filename
}
"
begin
ogg
=
OggInfo
.
new
(
filename
)
rescue
OggInfoError
puts
"error: doesn't appear to be an ogg file"
else
puts
ogg
ogg
.
tag
.
each
{
|
key
,
value
|
puts
"
#{
key
}
=>
#{
value
}
"
}
end
puts
end
end
\ No newline at end of file
lib/scene.rb
View file @
520f249d
...
...
@@ -7,7 +7,7 @@
require_relative
'fpstimer'
require_relative
'game'
require_relative
'window_bgm'
require
_relative
'ogginfo'
require
'ogginfo'
require_relative
'widget_inputbox'
class
Scene
attr_reader
:windows
...
...
@@ -55,7 +55,8 @@ class Scene
@@bgm
.
destroy
if
@@bgm
@@bgm
=
Mixer
::
Music
.
load
"audio/bgm/
#{
bgm
}
"
Mixer
.
fade_in_music
(
@@bgm
,
-
1
,
800
)
@bgm_window
=
Window_BGM
.
new
OggInfo
.
new
(
"audio/bgm/
#{
bgm
}
"
,
"UTF-8"
).
tag
[
"title"
]
title
=
OggInfo
.
new
(
"audio/bgm/
#{
bgm
}
"
).
tag
[
"title"
]
@bgm_window
=
Window_BGM
.
new
title
if
title
and
!
title
.
empty?
@@last_bgm
=
bgm
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment