From 292358fac69302863fb2696ae95e822d6498cfaa Mon Sep 17 00:00:00 2001 From: Toyobayashi Date: Wed, 21 Mar 2018 20:50:46 +0800 Subject: [PATCH] update 1.3.0 --- .eslintrc.json | 3 +- build/pack.js | 2 +- package-lock.json | 98 ++++++++++++------------- package.json | 6 +- src/js/i18n/ja-JP.js | 4 +- src/js/i18n/zh-CN.js | 4 +- src/js/main.js | 1 + src/js/main/on-game.js | 7 +- src/js/main/resolve-config.js | 2 +- src/js/renderer-game.js | 5 +- src/js/renderer.js | 2 +- src/js/renderer/game.js | 101 ++++++++++++++++++++++++++ src/js/renderer/live.js | 14 +++- src/js/renderer/player.js | 3 + src/vue/Mishiro.vue | 5 +- src/vue/component/TheCombo.vue | 8 +- src/vue/modal/ModalLiveDifficulty.vue | 4 +- src/vue/modal/ModalLiveResult.vue | 76 +++++++++++++++++++ 18 files changed, 277 insertions(+), 68 deletions(-) create mode 100644 src/vue/modal/ModalLiveResult.vue diff --git a/.eslintrc.json b/.eslintrc.json index 92ba3be..3b6aeb3 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -10,7 +10,8 @@ }, "rules": { "eqeqeq": 0, - "no-irregular-whitespace": 0 + "no-irregular-whitespace": 0, + "no-new": 0 }, "plugins": [ "html" diff --git a/build/pack.js b/build/pack.js index 302f6f6..80faa42 100644 --- a/build/pack.js +++ b/build/pack.js @@ -8,7 +8,7 @@ const option = { electronVersion: packageJson.devDependencies.electron, packDir: path.join(__dirname, '..'), distDir: path.join(__dirname, '../dist'), - ignore: new RegExp(`node_modules|build|data|release|download|dist|src|screenshot|${'public/img/card'.replace(/\//g, '\\\\')}|${'public/asset/sound/live'.replace(/\//g, '\\\\')}|${'public/asset/sound/voice'.replace(/\//g, '\\\\')}|.gitignore|README|.eslintrc.json|config.json|package-lock.json|.git|.vscode`), + ignore: new RegExp(`node_modules|build|data|release|download|dist|src|screenshot|public/img/card|public/asset/sound/live|public/asset/sound/voice|public/asset/score|.gitignore|README|.eslintrc.json|config.json|package-lock.json|.git|.vscode`.replace(/\//g, '\\\\')), versionString: { icon: path.join(__dirname, '../src/res/icon/mishiro.ico'), 'file-version': packageJson.version, diff --git a/package-lock.json b/package-lock.json index 4b168cd..9c2518c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,13 @@ { "name": "mishiro", - "version": "1.2.4", + "version": "1.3.0", "lockfileVersion": 1, "requires": true, "dependencies": { "@types/node": { - "version": "8.9.4", - "resolved": "http://registry.npm.taobao.org/@types/node/download/@types/node-8.9.4.tgz", - "integrity": "sha1-39MnWCoGwRTrbgRB+j1vqzXtrUg=", + "version": "8.9.5", + "resolved": "http://registry.npm.taobao.org/@types/node/download/@types/node-8.9.5.tgz", + "integrity": "sha1-FiuGS8cL4Hfm2yErMidUkXkp6XY=", "dev": true }, "accepts": { @@ -2085,12 +2085,12 @@ "dev": true }, "electron": { - "version": "1.8.2", - "resolved": "http://registry.npm.taobao.org/electron/download/electron-1.8.2.tgz", - "integrity": "sha1-qBfNczwpcrPHzE93fK9uQkuIAU0=", + "version": "1.8.4", + "resolved": "http://registry.npm.taobao.org/electron/download/electron-1.8.4.tgz", + "integrity": "sha1-zKjQ5oifI49VtBStIk8D4Dsiajg=", "dev": true, "requires": { - "@types/node": "8.9.4", + "@types/node": "8.9.5", "electron-download": "3.3.0", "extract-zip": "1.6.6" } @@ -2107,7 +2107,7 @@ "minimist": "1.2.0", "nugget": "2.0.1", "path-exists": "2.1.0", - "rc": "1.2.5", + "rc": "1.2.6", "semver": "5.4.1", "sumchecker": "1.3.1" }, @@ -6149,16 +6149,6 @@ "resolved": "http://registry.npm.taobao.org/minimist/download/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true - }, - "pretty-bytes": { - "version": "1.0.4", - "resolved": "http://registry.npm.taobao.org/pretty-bytes/download/pretty-bytes-1.0.4.tgz", - "integrity": "sha1-CiLoIQYJrTVUL4yNXSFZr/B1HIQ=", - "dev": true, - "requires": { - "get-stdin": "4.0.1", - "meow": "3.7.0" - } } } }, @@ -7299,6 +7289,16 @@ "integrity": "sha512-fHWjCwoRZgjP1rvLP7OGqOznq7xH1sHMQUFLX8qLRO79hI57+6xbc5vB904LxEkCfgFgyr3vv06JkafgCSzoZg==", "dev": true }, + "pretty-bytes": { + "version": "1.0.4", + "resolved": "http://registry.npm.taobao.org/pretty-bytes/download/pretty-bytes-1.0.4.tgz", + "integrity": "sha1-CiLoIQYJrTVUL4yNXSFZr/B1HIQ=", + "dev": true, + "requires": { + "get-stdin": "4.0.1", + "meow": "3.7.0" + } + }, "process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", @@ -7325,33 +7325,6 @@ "requires": { "speedometer": "0.1.4", "through2": "0.2.3" - }, - "dependencies": { - "object-keys": { - "version": "0.4.0", - "resolved": "http://registry.npm.taobao.org/object-keys/download/object-keys-0.4.0.tgz", - "integrity": "sha1-KKaq50KN0sOpLz2V8hM13SBOAzY=", - "dev": true - }, - "through2": { - "version": "0.2.3", - "resolved": "http://registry.npm.taobao.org/through2/download/through2-0.2.3.tgz", - "integrity": "sha1-6zKE2k6jEbbMis42U3SKUqvyWj8=", - "dev": true, - "requires": { - "readable-stream": "1.1.14", - "xtend": "2.1.2" - } - }, - "xtend": { - "version": "2.1.2", - "resolved": "http://registry.npm.taobao.org/xtend/download/xtend-2.1.2.tgz", - "integrity": "sha1-bv7MKk2tjmlixJAbM3znuoe10os=", - "dev": true, - "requires": { - "object-keys": "0.4.0" - } - } } }, "promise-inflight": { @@ -7565,9 +7538,9 @@ } }, "rc": { - "version": "1.2.5", - "resolved": "http://registry.npm.taobao.org/rc/download/rc-1.2.5.tgz", - "integrity": "sha1-J1zWh/bjs2zHVrqibf7oCnkDAf0=", + "version": "1.2.6", + "resolved": "http://registry.npm.taobao.org/rc/download/rc-1.2.6.tgz", + "integrity": "sha1-6xiYnG1PTxYsOZ953dKfODVWgJI=", "dev": true, "requires": { "deep-extend": "0.4.2", @@ -8944,6 +8917,33 @@ "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "dev": true }, + "through2": { + "version": "0.2.3", + "resolved": "http://registry.npm.taobao.org/through2/download/through2-0.2.3.tgz", + "integrity": "sha1-6zKE2k6jEbbMis42U3SKUqvyWj8=", + "dev": true, + "requires": { + "readable-stream": "1.1.14", + "xtend": "2.1.2" + }, + "dependencies": { + "object-keys": { + "version": "0.4.0", + "resolved": "http://registry.npm.taobao.org/object-keys/download/object-keys-0.4.0.tgz", + "integrity": "sha1-KKaq50KN0sOpLz2V8hM13SBOAzY=", + "dev": true + }, + "xtend": { + "version": "2.1.2", + "resolved": "http://registry.npm.taobao.org/xtend/download/xtend-2.1.2.tgz", + "integrity": "sha1-bv7MKk2tjmlixJAbM3znuoe10os=", + "dev": true, + "requires": { + "object-keys": "0.4.0" + } + } + } + }, "thunky": { "version": "1.0.2", "resolved": "http://registry.npm.taobao.org/thunky/download/thunky-1.0.2.tgz", diff --git a/package.json b/package.json index 9018e70..7ac32a8 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,9 @@ "pkg64": "npm run prod&&node ./build/pack.js x64", "count": "node ./build/count.js", "reb:hca-ia32": "cd ./src/cpp/hca&&node-gyp rebuild --target=%npm_package_devDependencies_electron% --arch=ia32 --dist-url=https://atom.io/download/electron", - "reb:hca-x64": "cd ./src/cpp/hca&&node-gyp rebuild --target=%npm_package_devDependencies_electron% --arch=x64 --dist-url=https://atom.io/download/electron" + "reb:hca-x64": "cd ./src/cpp/hca&&node-gyp rebuild --target=%npm_package_devDependencies_electron% --arch=x64 --dist-url=https://atom.io/download/electron", + "sql32": "npm install sqlite3@3.1.13 --no-save --build-from-source --runtime=electron --target=%npm_package_devDependencies_electron% --target_arch=ia32 --dist-url=https://atom.io/download/electron", + "sql64": "npm install sqlite3@3.1.13 --no-save --build-from-source --runtime=electron --target=%npm_package_devDependencies_electron% --target_arch=x64 --dist-url=https://atom.io/download/electron" }, "repository": { "type": "git", @@ -35,7 +37,7 @@ "license": "MIT", "devDependencies": { "css-loader": "^0.28.7", - "electron": "1.8.2", + "electron": "1.8.4", "eslint": "^4.16.0", "eslint-config-standard": "^11.0.0-beta.0", "eslint-plugin-html": "^3.2.2", diff --git a/src/js/i18n/ja-JP.js b/src/js/i18n/ja-JP.js index a9a7737..4405200 100644 --- a/src/js/i18n/ja-JP.js +++ b/src/js/i18n/ja-JP.js @@ -119,7 +119,9 @@ export default { live: 'ライブ', noScore: 'この曲は譜面がないので、プレイできません。', noAudio: 'MP3ファイルが見つかりませんでした。', - start: '決定' + start: '決定', + gameRunning: 'ライブ進行中です。', + liveResult: 'ライブ成績' }, gacha: { ikkai: '1回引く', diff --git a/src/js/i18n/zh-CN.js b/src/js/i18n/zh-CN.js index 5c478ed..a4b9275 100644 --- a/src/js/i18n/zh-CN.js +++ b/src/js/i18n/zh-CN.js @@ -119,7 +119,9 @@ export default { live: 'LIVE', noScore: '這首曲子没有譜面。', noAudio: '未発現MP3文件。', - start: '開始' + start: '開始', + gameRunning: 'LIVE正在進行。', + liveResult: 'LIVE成績' }, gacha: { ikkai: '単抽', diff --git a/src/js/main.js b/src/js/main.js index 653755d..614c6f4 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -6,6 +6,7 @@ import './main/ipc.js' let mainWindow function createWindow () { + // Menu.setApplicationMenu(null) mainWindow = new BrowserWindow({ width: 1296, height: 863, diff --git a/src/js/main/on-game.js b/src/js/main/on-game.js index 56a4684..5bccdec 100644 --- a/src/js/main/on-game.js +++ b/src/js/main/on-game.js @@ -16,6 +16,11 @@ export default async function (event, scoreFile, difficulty, bpm, src) { let data = rows.filter(row => row.name === nameField)[0].data.toString() let score = createScore(data, bpm) - let obj = { src, bpm, score } + + let fullCombo = 0 + for (let i = 0; i < score.length; i++) { + fullCombo += score[i][2] ? 2 : 1 + } + let obj = { src, bpm, score, fullCombo } event.sender.send('game', obj) } diff --git a/src/js/main/resolve-config.js b/src/js/main/resolve-config.js index 2521dac..75625b1 100644 --- a/src/js/main/resolve-config.js +++ b/src/js/main/resolve-config.js @@ -21,7 +21,7 @@ let config = (async function () { let fix = {} if (!config.latestResVer) { let rv346 = await getResourceVersionFromMishiroLab() - fix.latestResVer = rv346 || 10036710 + fix.latestResVer = rv346 || 10036950 } if (config.language !== 'zh' && config.language !== 'ja') { fix.language = 'zh' diff --git a/src/js/renderer-game.js b/src/js/renderer-game.js index 861b768..d05c3de 100644 --- a/src/js/renderer-game.js +++ b/src/js/renderer-game.js @@ -7,7 +7,7 @@ import Game from '../vue/MishiroGame.vue' window.addEventListener('load', () => { keyBind() Note.CTX = document.getElementById('live').getContext('2d') - let ctxIconBar = document.getElementById('iconBar').getContext('2d') + let ctxIconBar = Note.BACK_CTX = document.getElementById('iconBar').getContext('2d') let liveIcon = newImage('./img/img.asar/live_icon_857x114.png') liveIcon.addEventListener('load', function () { ctxIconBar.drawImage(this, 211.5, 586) @@ -16,7 +16,8 @@ window.addEventListener('load', () => { ipcRenderer.on('start', (event, song, fromWindowId) => { let name = parse(song.src).name.split('-')[1] - document.getElementsByTagName('title')[0].innerHTML = name + document.getElementsByTagName('title')[0].innerHTML = liveResult.name = name + liveResult.fullCombo = song.fullCombo let isCompleted = false window.addEventListener('beforeunload', (e) => { const fromWindow = remote.BrowserWindow.fromId(fromWindowId) diff --git a/src/js/renderer.js b/src/js/renderer.js index 7601473..856b190 100644 --- a/src/js/renderer.js +++ b/src/js/renderer.js @@ -20,7 +20,7 @@ Vue.use(vueGlobal); } }) - window.app = new Vue({ + new Vue({ el: '#app', i18n, render: h => h(Mishiro) diff --git a/src/js/renderer/game.js b/src/js/renderer/game.js index 810bdd5..7a73c8c 100644 --- a/src/js/renderer/game.js +++ b/src/js/renderer/game.js @@ -5,6 +5,7 @@ let liveResult = { bad: 0, miss: 0, combo: 0, + maxCombo: 0, hp: 100 } @@ -17,6 +18,8 @@ let se = { tapPerfect: new Audio('./asset/sound/se.asar/se_live_tap_perfect.mp3') } +const rankImg = newImage('./img/img.asar/rank.png') + function playSe (se) { se.currentTime = 0 se.play() @@ -242,16 +245,21 @@ function rank (dt) { if (dt <= 50) { liveResult.perfect++ liveResult.combo++ + if (liveResult.combo > liveResult.maxCombo) liveResult.maxCombo = liveResult.combo + showRank('perfect') playSe(se.tapPerfect) // console.log('perfect') } else if (dt <= 75) { liveResult.great++ liveResult.combo++ + if (liveResult.combo > liveResult.maxCombo) liveResult.maxCombo = liveResult.combo + showRank('great') playSe(se.tapGreat) // console.log('great') } else if (dt <= 87.5) { liveResult.nice++ liveResult.combo = 0 + showRank('nice') playSe(se.tapNice) // console.log('nice') } else { @@ -259,6 +267,7 @@ function rank (dt) { liveResult.bad++ liveResult.combo = 0 liveResult.hp -= 4 + showRank('bad') hpCheck() // console.log('bad') } @@ -268,6 +277,7 @@ function miss () { liveResult.miss++ liveResult.combo = 0 liveResult.hp -= 6 + showRank('miss') hpCheck() // console.log('miss') } @@ -276,6 +286,97 @@ function hpCheck () { if (liveResult.hp < 0) window.close() } +function clearRank () { + Note.BACK_CTX.clearRect(0, Note.TOP_TO_BOTTOM - 100, 1280, 54) +} + +let t = 1 +let st = 1 +function showRank (rank) { + clearTimeout(st) + clearRank() + let f = 0 + cancelAnimationFrame(t) + t = requestAnimationFrame(show) + + function show () { + clearRank() + if (rank === 'perfect') { + Note.BACK_CTX.drawImage( + rankImg, + 0, + 212, + 253, + 54, + // (1280 - 253) / 2, + (1280 - f * 253 / 9) / 2, + // Note.TOP_TO_BOTTOM - 100, + Note.TOP_TO_BOTTOM - 75 - f * 25 / 9, + f * 253 / 9, + f * 54 / 9 + ) + } else if (rank === 'great') { + Note.BACK_CTX.drawImage( + rankImg, + 0, + 159, + 208, + 53, + (1280 - f * 208 / 9) / 2, + Note.TOP_TO_BOTTOM - 75 - f * 25 / 9, + f * 208 / 9, + f * 53 / 9 + ) + } else if (rank === 'nice') { + Note.BACK_CTX.drawImage( + rankImg, + 0, + 106, + 141, + 53, + (1280 - f * 141 / 9) / 2, + Note.TOP_TO_BOTTOM - 75 - f * 25 / 9, + f * 141 / 9, + f * 53 / 9 + ) + } else if (rank === 'bad') { + Note.BACK_CTX.drawImage( + rankImg, + 0, + 53, + 128, + 53, + (1280 - f * 128 / 9) / 2, + Note.TOP_TO_BOTTOM - 75 - f * 25 / 9, + f * 128 / 9, + f * 53 / 9 + ) + } else if (rank === 'miss') { + Note.BACK_CTX.drawImage( + rankImg, + 0, + 0, + 151, + 53, + (1280 - f * 151 / 9) / 2, + Note.TOP_TO_BOTTOM - 75 - f * 25 / 9, + f * 151 / 9, + f * 53 / 9 + ) + } + if (f >= 9) { + cancelAnimationFrame(t) + clearTimeout(st) + st = setTimeout(() => { + clearRank() + }, 500) + } else { + f++ + requestAnimationFrame(show) + } + } +} + function keydown (path) { let note = Note.queue[path - 1][0] if (note) { diff --git a/src/js/renderer/live.js b/src/js/renderer/live.js index 0979ed4..a2859e9 100644 --- a/src/js/renderer/live.js +++ b/src/js/renderer/live.js @@ -22,7 +22,8 @@ export default { duration: 100, currentTime: 0, allLive: true, - liveQueryList: [] + liveQueryList: [], + isGameRunning: false } }, props: { @@ -141,6 +142,11 @@ export default { async startGame () { await this.playSe(this.enterSe) + if (this.isGameRunning) { + this.event.$emit('alert', this.$t('home.errorTitle'), this.$t('live.gameRunning')) + return + } + if (this.activeAudio.score) { if (!fs.existsSync(getPath(`./public/asset/sound/live/${this.activeAudio.fileName}`))) { this.event.$emit('alert', this.$t('home.errorTitle'), this.$t('live.noAudio')) @@ -202,6 +208,9 @@ export default { this.activeAudio = this.liveManifest.filter(bgm => bgm.fileName === fileName)[0] } }) + this.event.$on('gameStart', () => { + this.isGameRunning = true + }) this.event.$on('enterKey', (block) => { if (block === 'live') { this.query() @@ -214,8 +223,9 @@ export default { this.event.$emit('liveSelect', { src: url }) }) ipcRenderer.on('liveEnd', (event, liveResult, isCompleted) => { + this.isGameRunning = false if (isCompleted) this.playSe(new Audio('./asset/sound/se.asar/se_live_wow.mp3')) - console.log(liveResult) + this.event.$emit('showLiveResult', liveResult) }) }) } diff --git a/src/js/renderer/player.js b/src/js/renderer/player.js index dff6926..e6cd03c 100644 --- a/src/js/renderer/player.js +++ b/src/js/renderer/player.js @@ -244,6 +244,9 @@ export default { this.event.$on('pauseBgm', () => { this.pause() }) + this.event.$on('playBgm', () => { + this.play() + }) }) } } diff --git a/src/vue/Mishiro.vue b/src/vue/Mishiro.vue index 6afa47e..7147084 100644 --- a/src/vue/Mishiro.vue +++ b/src/vue/Mishiro.vue @@ -23,6 +23,7 @@ + @@ -57,6 +58,7 @@ import ModalOption from './modal/ModalOption.vue' import ModalVersion from './modal/ModalVersion.vue' import ModalCalculator from './modal/ModalCalculator.vue' import ModalLiveDifficulty from './modal/ModalLiveDifficulty.vue' +import ModalLiveResult from './modal/ModalLiveResult.vue' export default { components: { @@ -81,7 +83,8 @@ export default { ModalVersion, ModalOption, ModalCalculator, - ModalLiveDifficulty + ModalLiveDifficulty, + ModalLiveResult }, data () { return { diff --git a/src/vue/component/TheCombo.vue b/src/vue/component/TheCombo.vue index 346fddc..5c0a592 100644 --- a/src/vue/component/TheCombo.vue +++ b/src/vue/component/TheCombo.vue @@ -33,11 +33,11 @@ export default { line-height: 80px; } .combo > .combo-text { - -webkit-text-stroke: 2px rgb(240,144,0); + -webkit-text-stroke: 1px rgb(240,144,0); color: #f0f0f0; - font-size: 40px; + font-size: 35px; font-family: "CGSS-B"; - height: 40px; - line-height: 40px; + height: 35px; + line-height: 35px; } diff --git a/src/vue/modal/ModalLiveDifficulty.vue b/src/vue/modal/ModalLiveDifficulty.vue index ac61b55..f7a3a3f 100644 --- a/src/vue/modal/ModalLiveDifficulty.vue +++ b/src/vue/modal/ModalLiveDifficulty.vue @@ -62,7 +62,7 @@ export default { mounted () { this.$nextTick(() => { ipcRenderer.on('game', (event, obj) => { - console.log(obj) + this.event.$emit('gameStart') this.event.$emit('pauseBgm') const windowID = BrowserWindow.getFocusedWindow().id @@ -85,6 +85,8 @@ export default { win.webContents.on('did-finish-load', function () { win.webContents.send('start', obj, windowID) }) + + this.visible = false }) this.event.$on('game', (live) => { this.difficulty = '4' diff --git a/src/vue/modal/ModalLiveResult.vue b/src/vue/modal/ModalLiveResult.vue new file mode 100644 index 0000000..695f52e --- /dev/null +++ b/src/vue/modal/ModalLiveResult.vue @@ -0,0 +1,76 @@ + + + +