From ade28f781b272f01bda49b0fa5fb7c99b540c71d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Tue, 15 May 2018 19:54:41 +0900 Subject: [PATCH] Add: printHistory --- src/game/result/result.js | 84 +++++++++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 30 deletions(-) diff --git a/src/game/result/result.js b/src/game/result/result.js index d8ca0a4..5ea309f 100644 --- a/src/game/result/result.js +++ b/src/game/result/result.js @@ -23,14 +23,9 @@ class Result { // contents - // this.printHowToPlay(appInfoManager.getHowToPlayText(sessionStorageManager.playingAppName)); this.printScore(); this.makeStartButton(); - this.loadHistoryRecords(); - // this.printHistoryRecords(); - - this.loadRanking(); this.printRanking(); @@ -42,7 +37,10 @@ class Result { screenBottom.printBottomCenterText(playingAppName); screenBottom.printBottomRightText(sessionStorageManager.playerName); + this.loadHistoryRecords(); + // this.loadTypingStageData(); + this.loadRanking(); } printScore() { @@ -90,44 +88,70 @@ class Result { this.historyRecordManager.clear(); this.historyRecordManager.push(new HistoryRecordData("05/10", 15460)); - this.historyRecordManager.push(new HistoryRecordData("05/11", 13040)); - this.historyRecordManager.push(new HistoryRecordData("05/12", 16460)); - this.historyRecordManager.push(new HistoryRecordData("05/13", 15060)); - this.historyRecordManager.push(new HistoryRecordData("05/14", 19800)); + this.historyRecordManager.push(new HistoryRecordData("05/11", 3040)); + this.historyRecordManager.push(new HistoryRecordData("05/12", 460)); + this.historyRecordManager.push(new HistoryRecordData("05/13", 60)); + this.historyRecordManager.push(new HistoryRecordData("05/14", 8)); + + this.printHistoryRecords(); } printHistoryRecords(historyRecords) { - let underValue = this.historyRecordManager.underValueForGraph(); - let upperValue = this.historyRecordManager.upperValueForGraph(); - for(let i = 0; i < this.historyRecordManager.count; i++) { let data = this.historyRecordManager.getAt(i); - this.printRecord(i, data.date, data.record, underValue, upperValue); + this.printRecord(i, data.date, data.record); } - this.chartGraphics.lineStyle(3, 0xffd900, 1); - this.chartGraphics.moveTo(0, 0); - this.chartGraphics.lineTo(game.world.width - 200, 0); + // this.chartGraphics.lineStyle(3, 0xffd900, 1); + // this.chartGraphics.moveTo(0, 0); + // this.chartGraphics.lineTo(game.world.width - 200, 0); } - printRecord(index, date, record, min, max) { - const CHART_GAP_PX = 180; - const style = { font: "32px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" }; + printRecord(index, date, record) { + if(sessionStorageManager.playingAppName.indexOf("typing") > -1) + this.printMouseAppHistory(index, date, record); + else + this.printMouseAppHistory(index, date, record); + } - let dateText = game.add.text(100 + index * CHART_GAP_PX, game.world.height - 140, date, style); - dateText.setTextBounds(0, 0, 100, 100); - dateText.stroke = "#333"; - dateText.strokeThickness = 1; + printTypingAppHistory(index, date, record) { + let posX = 60; + let posY = game.world.height / 2 + 90 + 30 * index; + + var style = { font: "20px Arial", fill: "#ffc", align: "right", boundsAlignH: "right", boundsAlignV: "top" }; + + style.boundsAlignH = "center"; + game.add.text(posX, posY, date, style) + .setTextBounds(0, 0, 40, 40) + .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); + + game.add.text(posX + 60, posY, "(한)단어", style) + .setTextBounds(0, 0, 60, 60) + .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); let numberWithCommas = NumberUtil.numberWithCommas(record); - let recordText = game.add.text(100 + index * CHART_GAP_PX, game.world.height - 300, numberWithCommas, style); - recordText.setTextBounds(0, 0, 100, 100); - recordText.stroke = "#333"; - recordText.strokeThickness = 1; + style.boundsAlignH = "right"; + game.add.text(posX + 120, posY, numberWithCommas, style) + .setTextBounds(0, 0, 80, 60) + .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); + } - this.chartGraphics.lineStyle(50, 0xdddddd, 1); - this.chartGraphics.moveTo(50 + index * CHART_GAP_PX, 0); - this.chartGraphics.lineTo(50 + index * CHART_GAP_PX, -100 * ( (record - min) / (max - min) )); + printMouseAppHistory(index, date, record) { + let posX = 60; + let posY = game.world.height / 2 + 90 + 30 * index; + + var style = { font: "20px Arial", fill: "#ffc", align: "right", boundsAlignH: "right", boundsAlignV: "top" }; + + style.boundsAlignH = "center"; + game.add.text(posX, posY, date, style) + .setTextBounds(0, 0, 100, 60) + .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); + + let numberWithCommas = NumberUtil.numberWithCommas(record); + style.boundsAlignH = "right"; + game.add.text(posX + 80, posY, numberWithCommas, style) + .setTextBounds(0, 0, 100, 60) + .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); } loadRanking() {