Skip to content

Commit

Permalink
update 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
toyobayashi committed Dec 29, 2017
1 parent 96624ff commit 4a96006
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 106 deletions.
6 changes: 3 additions & 3 deletions src/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ body{
color: #ffffff;
overflow-y: auto;
}
.black-bg::-webkit-scrollbar-track
.black-bg::-webkit-scrollbar-track, .modal-body::-webkit-scrollbar-track
{
box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
border-radius: 10px;
background-color: #aaa;
}
.black-bg::-webkit-scrollbar
.black-bg::-webkit-scrollbar, .modal-body::-webkit-scrollbar
{
width: 8px;
background-color: rgba(0,0,0,0);
}
.black-bg::-webkit-scrollbar-thumb
.black-bg::-webkit-scrollbar-thumb, .modal-body::-webkit-scrollbar-thumb
{
border-radius: 10px;
box-shadow: inset 0 0 6px rgba(0,0,0,.3);
Expand Down
7 changes: 4 additions & 3 deletions src/js/icpMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ function getRarity(id, cardData){
}
}

ipcMain.on("readManifest", (event, manifestFile) => {
ipcMain.on("readManifest", (event, manifestFile, resVer) => {
manifest = new SQL.Database(manifestFile);
const manifests = manifest._exec("SELECT name, hash FROM manifests");
event.sender.send("readManifest", manifests);
event.sender.send("readManifest", manifests, resVer);
});

ipcMain.on("readMaster", (event, masterFile) => {
Expand All @@ -48,7 +48,8 @@ ipcMain.on("readMaster", (event, masterFile) => {
const leaderSkillData = master._exec("SELECT * FROM leader_skill_data");
const musicData = master._exec("SELECT id, name FROM music_data");

let gachaNow = master._exec("SELECT * FROM gacha_data WHERE start_date = (SELECT MAX(start_date) FROM gacha_data WHERE id LIKE '3%') AND id LIKE '3%'")[0];
let gachaNowArray = master._exec("SELECT * FROM gacha_data WHERE start_date = (SELECT MAX(start_date) FROM gacha_data WHERE id LIKE '3%') AND id LIKE '3%'");
let gachaNow = gachaNowArray[gachaNowArray.length - 1];
let gachaData = config.gacha ? master._exec(`SELECT * FROM gacha_data WHERE id="${config.gacha}"`)[0] : gachaNow;
let gachaAvailable = master._exec(`SELECT * FROM gacha_available WHERE gacha_id LIKE '${gachaData.id}'`);

Expand Down
11 changes: 6 additions & 5 deletions src/js/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ import { remote } from "electron";
import cheerio from "cheerio";
import request from "request";
export default {
data(){
return {

};
},
methods: {
showOption(){
this.playSe(this.enterSe);
Expand Down Expand Up @@ -51,8 +46,14 @@ OTHER DEALINGS IN THE SOFTWARE.</p>`, 800);
},
update(){
this.playSe(this.enterSe);
if(!navigator.onLine){
this.event.$emit("alert", this.$t("home.errorTitle"), this.$t("home.noNetwork"));
return;
}
this.$emit("checking");
const gitRoot = "https://github.com";
request.get(`${gitRoot}/toyobayashi/mishiro/releases`, (err, res, body) => {
this.$emit("checked");
if(!err){
let $ = cheerio.load(body);
const title = $(".release.label-latest .release-title > a").text();
Expand Down
174 changes: 91 additions & 83 deletions src/js/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import getPath from "./getPath.js";
import toName from "./path2name.js";
import idol from "./idol.js";
import player from "./player.js";
import configurer from "./config.js";
const bgmList = player.data().bgmList;
const downloader = new Downloader();

Expand Down Expand Up @@ -67,6 +68,7 @@ export default {
this.text = this.$t("update.master");

let masterFile = "";
console.log(resVer);
if(fs.existsSync(getPath(`./data/master_${resVer}.db`))){
this.loading = 100;
masterFile = getPath(`./data/master_${resVer}.db`);
Expand All @@ -90,105 +92,111 @@ export default {
mounted(){
this.$nextTick(() => {
this.event.$on("enter", async () => { // 已从入口进入
if(navigator.onLine
/* false */
){ // 判断网络是否连接
if(!fs.existsSync(getPath("./public/asset/sound/bgm"))){
fs.mkdirSync(getPath("./public/asset/sound/bgm"));
}
if(!fs.existsSync(getPath("./public/asset/sound/live"))){
fs.mkdirSync(getPath("./public/asset/sound/live"));
}
const resVer = await this.getResVer();
this.$store.commit("updateResVer", resVer);

const manifestFile = await this.getManifest(resVer);

ipcRenderer.on("readManifest", async (event, manifests) => {
this.$store.commit("updateManifest", manifests);
const masterHash = manifests.filter(row => row.name === "master.mdb")[0].hash;
const masterFile = await this.getMaster(resVer, masterHash);
ipcRenderer.send("readMaster", fs.readFileSync(masterFile));
});
ipcRenderer.on("readMaster", async (event, masterData) => {
// console.log(masterData);
this.$store.commit("updateMaster", masterData);
if(!fs.existsSync(getPath("./public/asset/sound/bgm"))){
fs.mkdirSync(getPath("./public/asset/sound/bgm"));
}
if(!fs.existsSync(getPath("./public/asset/sound/live"))){
fs.mkdirSync(getPath("./public/asset/sound/live"));
}
ipcRenderer.on("readManifest", async (event, manifests, resVer) => {
this.$store.commit("updateManifest", manifests);
const masterHash = manifests.filter(row => row.name === "master.mdb")[0].hash;
const masterFile = await this.getMaster(resVer, masterHash);
ipcRenderer.send("readMaster", fs.readFileSync(masterFile));
});
ipcRenderer.on("readMaster", async (event, masterData) => {
// console.log(masterData);
this.$store.commit("updateMaster", masterData);

for(let k in bgmList){
if(!fs.existsSync(path.join(getPath("./public"), bgmList[k].src))){
let acbName = `b/${toName(bgmList[k].src).split(".")[0]}.acb`;
let hash = this.$store.state.manifest.filter(row => row.name === acbName)[0].hash;
await downloader.download(
this.getBgmUrl(hash),
getPath(`./public/asset/sound/bgm/${toName(bgmList[k].src).split(".")[0]}.acb`),
(prog) => {
this.text = prog.name + " " + Math.ceil(prog.current / 1024) + "/" + Math.ceil(prog.max / 1024) + " KB";
this.loading = prog.loading;
}
);
ipcRenderer.send("acb", getPath(`./public/asset/sound/bgm/${toName(bgmList[k].src).split(".")[0]}.acb`));
}
}
if(this.eventInfo.type != 2 && !fs.existsSync(getPath(`./public/asset/sound/bgm/bgm_event_${this.eventInfo.id}.mp3`))){
const eventBgmHash = this.$store.state.manifest.filter(row => row.name === `b/bgm_event_${this.eventInfo.id}.acb`)[0].hash;
for(let k in bgmList){
if(!fs.existsSync(path.join(getPath("./public"), bgmList[k].src))){
let acbName = `b/${toName(bgmList[k].src).split(".")[0]}.acb`;
let hash = this.$store.state.manifest.filter(row => row.name === acbName)[0].hash;
await downloader.download(
this.getBgmUrl(eventBgmHash),
getPath(`./public/asset/sound/bgm/bgm_event_${this.eventInfo.id}.acb`),
this.getBgmUrl(hash),
getPath(`./public/asset/sound/bgm/${toName(bgmList[k].src).split(".")[0]}.acb`),
(prog) => {
this.text = prog.name + " " + Math.ceil(prog.current / 1024) + "/" + Math.ceil(prog.max / 1024) + " KB";
this.loading = prog.loading;
}
);
ipcRenderer.send("acb", getPath(`./public/asset/sound/bgm/bgm_event_${this.eventInfo.id}.acb`));
ipcRenderer.send("acb", getPath(`./public/asset/sound/bgm/${toName(bgmList[k].src).split(".")[0]}.acb`));
}
if(!fs.existsSync(getPath("./public/img/card"))){
fs.mkdirSync(getPath("./public/img/card"));
}
let config = this.configurer.getConfig();
if(config.background){
let result = await idol.methods.downloadCard(config.background, (prog) => {
this.text = prog.name;
}
if(this.eventInfo.type != 2 && !fs.existsSync(getPath(`./public/asset/sound/bgm/bgm_event_${this.eventInfo.id}.mp3`))){
const eventBgmHash = this.$store.state.manifest.filter(row => row.name === `b/bgm_event_${this.eventInfo.id}.acb`)[0].hash;
await downloader.download(
this.getBgmUrl(eventBgmHash),
getPath(`./public/asset/sound/bgm/bgm_event_${this.eventInfo.id}.acb`),
(prog) => {
this.text = prog.name + " " + Math.ceil(prog.current / 1024) + "/" + Math.ceil(prog.max / 1024) + " KB";
this.loading = prog.loading;
});
if(result){
this.event.$emit("eventBgReady", config.background);
}
);
ipcRenderer.send("acb", getPath(`./public/asset/sound/bgm/bgm_event_${this.eventInfo.id}.acb`));
}
if(!fs.existsSync(getPath("./public/img/card"))){
fs.mkdirSync(getPath("./public/img/card"));
}
let config = this.configurer.getConfig();
if(config.background){
let result = await idol.methods.downloadCard(config.background, (prog) => {
this.text = prog.name;
this.loading = prog.loading;
});
if(result){
this.event.$emit("eventBgReady", config.background);
}
else{
const eventAvailable = masterData.eventAvailable;
const cardId = this.getEventCardId(eventAvailable);
// const cardIdEvolution = [(Number(cardId[0]) + 1), (Number(cardId[1]) + 1)];
let result = await idol.methods.downloadCard(Number(cardId[0]) + 1, (prog) => {
this.text = prog.name;
this.loading = prog.loading;
});
if(result){
this.event.$emit("eventBgReady", Number(cardId[0]) + 1);
}
}
else{
const eventAvailable = masterData.eventAvailable;
const cardId = this.getEventCardId(eventAvailable);
// const cardIdEvolution = [(Number(cardId[0]) + 1), (Number(cardId[1]) + 1)];
let result = await idol.methods.downloadCard(Number(cardId[0]) + 1, (prog) => {
this.text = prog.name;
this.loading = prog.loading;
});
if(result){
this.event.$emit("eventBgReady", Number(cardId[0]) + 1);
}
}

if(!fs.existsSync(getPath("./public/img/icon"))){
fs.mkdirSync(getPath("./public/img/icon"));
}
let iconId = [];
for(let index = 0; index < masterData.gachaAvailable.length; index++){
iconId.push(masterData.gachaAvailable[index].reward_id);
}
const iconTask = this.createCardIconTask(iconId);
await downloader.batchDl(iconTask, (name) => {
this.text = name + " " + downloader.index + "/" + iconTask.length;
}, (prog) => {
this.loading = 100 * downloader.index / iconTask.length + prog.loading / iconTask.length;
}).then(() => {
setTimeout(() => {
this.emitReady();
}, 346);
});
if(!fs.existsSync(getPath("./public/img/icon"))){
fs.mkdirSync(getPath("./public/img/icon"));
}
let iconId = [];
for(let index = 0; index < masterData.gachaAvailable.length; index++){
iconId.push(masterData.gachaAvailable[index].reward_id);
}
const iconTask = this.createCardIconTask(iconId);
await downloader.batchDl(iconTask, (name) => {
this.text = name + " " + downloader.index + "/" + iconTask.length;
}, (prog) => {
this.loading = 100 * downloader.index / iconTask.length + prog.loading / iconTask.length;
}).then(() => {
setTimeout(() => {
this.emitReady();
}, 346);
});
ipcRenderer.send("readManifest", fs.readFileSync(manifestFile));
});
if(navigator.onLine
/* false */
){ // 判断网络是否连接
const resVer = await this.getResVer();
this.$store.commit("updateResVer", resVer);
const manifestFile = await this.getManifest(resVer);
ipcRenderer.send("readManifest", fs.readFileSync(manifestFile), resVer);
}
else{ // 如果网络未连接则直接触发ready事件
this.emitReady();
let resVer = configurer.getConfig().latestResVer;
this.$store.commit("updateResVer", resVer);
if(fs.existsSync(getPath(`./data/manifest_${resVer}.db`)) && fs.existsSync(getPath(`./data/master_${resVer}.db`))){
let manifestFile = getPath(`./data/manifest_${resVer}.db`);
ipcRenderer.send("readManifest", fs.readFileSync(manifestFile), resVer);
}
else{
this.event.$emit("alert", this.$t("home.errorTitle"), this.$t("home.noNetwork"));
}
}
});
});
Expand Down
4 changes: 3 additions & 1 deletion src/template/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<idol v-show="currentBlock === 'idol'"></idol>
<live v-show="currentBlock === 'live'"></live>
<gacha v-show="currentBlock === 'gacha'"></gacha>
<menyuu v-show="currentBlock === 'menu'"></menyuu>
<menyuu v-show="currentBlock === 'menu'" @checking="checking = true" @checked="checking = false"></menyuu>
<hide-button @toggle="showBackground"></hide-button>
<version></version>
<player></player>
Expand All @@ -26,6 +26,7 @@
<gacha-card></gacha-card>
<setting></setting>
<alert></alert>
<img v-show="checking" src="../res/img/spinner.gif" class="spinner" />
</div>
</template>

Expand Down Expand Up @@ -79,6 +80,7 @@ export default {
isReady: false,
show: true,
currentBlock: "home",
checking: false,
i18nTabs: {
zh: "i18n.chinese",
ja: "i18n.japanese"
Expand Down
7 changes: 6 additions & 1 deletion src/template/gachaCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</h4>
<small-tab class="pull-right" :tab="practice" :default="'be'" @tabClicked="toggle"></small-tab>
</div>
<div class="modal-body flex-center" id="gachaCardBody">
<div class="modal-body" id="gachaCardBody" ref="gachaCardBody">
<table class="table-bordered" border="1"
:class="{
cute: information.charaData ? information.charaData.type === 1 : false,
Expand Down Expand Up @@ -153,6 +153,11 @@ export default {
},
mounted(){
this.$nextTick(() => {
let gachaCardBody = this.$refs.gachaCardBody;
gachaCardBody.style.maxHeight = window.innerHeight - 267 + "px";
window.addEventListener("resize", () => {
gachaCardBody.style.maxHeight = window.innerHeight - 267 + "px";
}, false);
this.event.$on("showCard", (card) => {
const cardPlus = this.cardData.filter(c => c.id == card.evolution_id)[0];
this.event.$emit("smallTab", "be");
Expand Down
6 changes: 3 additions & 3 deletions src/template/gachaInformation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@
<td width="18%">{{$t("gacha.r")}}</td>
<td width="32%">{{gachaData.count ? gachaData.count.R : 0}} ({{(gachaData.count ? gachaData.count.fes : false) ? "82.00%" : "85.00%"}})</td>
<td width="18%">{{$t("gacha.get")}}</td>
<td width="32%">{{info.r}} ({{(100 * info.r / info.total).toFixed(2)}}%)</td>
<td width="32%">{{info.r}} ({{info.r > 0 ? (100 * info.r / info.total).toFixed(2) : "0.00"}}%)</td>
</tr>
<tr>
<td>{{$t("gacha.sr")}}</td>
<td>{{gachaData.count ? gachaData.count.SR : 0}} (12.00%)</td>
<td>{{$t("gacha.get")}}</td>
<td>{{info.sr}} ({{(100 * info.sr / info.total).toFixed(2)}}%)</td>
<td>{{info.sr}} ({{info.sr > 0 ? (100 * info.sr / info.total).toFixed(2) : "0.00"}}%)</td>
</tr>
<tr>
<td>{{$t("gacha.ssr")}}</td>
<td>{{gachaData.count ? gachaData.count.SSR : 0}} ({{(gachaData.count ? gachaData.count.fes : false) ? "6.00%" : "3.00%"}})</td>
<td>{{$t("gacha.get")}}</td>
<td>{{info.ssr}} ({{(100 * info.ssr / info.total).toFixed(2)}}%)</td>
<td>{{info.ssr}} ({{info.ssr > 0 ? (100 * info.ssr / info.total).toFixed(2) : "0.00"}}%)</td>
</tr>
<tr>
<td colspan="1">{{$t("gacha.cost")}}</td>
Expand Down
7 changes: 7 additions & 0 deletions src/template/menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@
height: calc(100% - 150px);
margin-bottom: 30px;
}
.spinner{
width: 48px;
height: 48px;
position: absolute;
bottom: 40px;
right: 40px;
}
</style>
7 changes: 0 additions & 7 deletions src/template/update.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@
height: 20%;
background-color: #aaa;
}
.spinner{
width: 48px;
height: 48px;
position: absolute;
bottom: 40px;
right: 40px;
}
</style>

<script src="../js/update.js">
Expand Down

0 comments on commit 4a96006

Please sign in to comment.