Skip to content

Commit

Permalink
feat(game/game-loader): parse the BMS
Browse files Browse the repository at this point in the history
  • Loading branch information
dtinth committed Feb 16, 2015
1 parent fa0161c commit f500be2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"dependencies": {
"audio-context": "^0.1.0",
"bluebird": "^2.9.6",
"bms": "^0.2.0",
"bms": "^0.5.0",
"bytes": "^1.0.0",
"chance": "^0.7.3",
"co": "^4.3.1",
Expand Down
12 changes: 11 additions & 1 deletion src/game/game-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import co from 'co'
import bytes from 'bytes'
import { basename } from 'path'
import BMS from 'bms'

import { EventEmitter } from 'events'
import TaskList from 'bemuse/task-list'
Expand Down Expand Up @@ -30,7 +31,11 @@ export class GameLoader extends EventEmitter {
}.bind(this)),
song: co(function*() {
let buffer = yield download(bms).as('arraybuffer', tasks.bms)
return buffer
let source = yield readBMS(buffer)
let compileResult = BMS.Compiler.compile(source)
let chart = compileResult.chart
let songInfo = BMS.SongInfo.fromBMSChart(chart)
void songInfo
}.bind(this)),
}
yield Promise.all([promises.graphics, promises.song])
Expand Down Expand Up @@ -67,4 +72,9 @@ function loadEngine(task) {
})
}

function readBMS(buffer) {
buffer = new Buffer(new Uint8Array(buffer))
return Promise.promisify(BMS.Reader.readAsync)(buffer)
}

export default GameLoader
5 changes: 4 additions & 1 deletion src/game/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import GameLoader from './game-loader'
export function main() {
let song = {
title: 'オリヴィアの幻術',
subtitle: [
subtitles: [
'[Tonalite]',
],
artist: '葵',
genre: 'Sexy Dance',
subartists: [
'mov:いとう まさき/obj:止ヒ糸',
],
}
let loader = new GameLoader()
let promise = loader.load('/music/aoi_olivia/olivia_SPpp.bml')
Expand Down
3 changes: 3 additions & 0 deletions src/game/loading-scene/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
font-size: 4vmin;
margin-top: 0.8ex;
}
&--subartist {
font-size: 2.5vmin;
}

}

Expand Down
4 changes: 3 additions & 1 deletion src/game/loading-scene/view.jade
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ mixin section(name)
.loading-scene-song-info
.loading-scene-song-info--genre {{song.genre}}
.loading-scene-song-info--title {{song.title}}
+section('song.subtitle')
+section('song.subtitles')
.loading-scene-song-info--subtitle {{.}}
.loading-scene-song-info--artist {{song.artist}}
+section('song.subartists')
.loading-scene-song-info--subartist {{.}}
.loading-scene-progress
+section('items')
.loading-scene-progress--item
Expand Down

0 comments on commit f500be2

Please sign in to comment.