Add: RankingRecordManager
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
class HistoryBoard {
|
||||
|
||||
constructor() {
|
||||
this.historyRecordManager = new HistoryRecordManager();
|
||||
this.dbConnectManager = new DBConnectManager();
|
||||
|
||||
let arrayTabStyle = { font: "20px Arial", fill: "#fff", align: "left", tabs: [ 40, 80, 120 ] };
|
||||
|
||||
@@ -13,60 +13,22 @@ class HistoryBoard {
|
||||
this.textMyRanking = game.add.text(posX, posY + 100, '', arrayTabStyle)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
|
||||
this.loadHistoryRecords();
|
||||
this.dbConnectManager.requestTempMyHistory( historyRecordManager => {
|
||||
let self = this;
|
||||
|
||||
for(let i = 0; i < historyRecordManager.count; i++) {
|
||||
let data = historyRecordManager.getAt(i);
|
||||
self.printRecord(i, data.date, data.score);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
loadHistoryRecords() {
|
||||
this.historyRecordManager.clear();
|
||||
|
||||
this.historyRecordManager.push(new HistoryRecord("05/10", 15460));
|
||||
this.historyRecordManager.push(new HistoryRecord("05/11", 3040));
|
||||
this.historyRecordManager.push(new HistoryRecord("05/12", 460));
|
||||
this.historyRecordManager.push(new HistoryRecord("05/13", 60));
|
||||
this.historyRecordManager.push(new HistoryRecord("05/14", 8));
|
||||
|
||||
this.printHistoryRecords();
|
||||
}
|
||||
|
||||
printHistoryRecords(historyRecords) {
|
||||
for(let i = 0; i < this.historyRecordManager.count; i++) {
|
||||
let data = this.historyRecordManager.getAt(i);
|
||||
this.printRecord(i, data.date, data.score);
|
||||
}
|
||||
|
||||
// this.chartGraphics.lineStyle(3, 0xffd900, 1);
|
||||
// this.chartGraphics.moveTo(0, 0);
|
||||
// this.chartGraphics.lineTo(game.world.width - 200, 0);
|
||||
}
|
||||
|
||||
printRecord(index, date, score) {
|
||||
if(sessionStorageManager.playingAppName.indexOf("typing") > -1)
|
||||
if(sessionStorageManager.playingAppName.indexOf("typing") < 0)
|
||||
this.printMouseAppHistory(index, date, score);
|
||||
else
|
||||
this.printMouseAppHistory(index, date, score);
|
||||
}
|
||||
|
||||
printTypingAppHistory(index, date, score) {
|
||||
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(score);
|
||||
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.printTypingAppHistory(index, date, appName, score);
|
||||
}
|
||||
|
||||
printMouseAppHistory(index, date, score) {
|
||||
@@ -86,4 +48,27 @@ class HistoryBoard {
|
||||
.setTextBounds(0, 0, 100, 60)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
}
|
||||
|
||||
printTypingAppHistory(index, date, appName, score) {
|
||||
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);
|
||||
|
||||
let typingAppName = appName;
|
||||
game.add.text(posX + 60, posY, typingAppName, style)
|
||||
.setTextBounds(0, 0, 60, 60)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
|
||||
let numberWithCommas = NumberUtil.numberWithCommas(score);
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ class RecordBoard {
|
||||
this.chartGraphics = game.add.graphics(0, 0);
|
||||
|
||||
this.printRecordBoardHeader();
|
||||
this.printSeperator();
|
||||
|
||||
let historyBoard = new HistoryBoard();
|
||||
let rankingBoard = new RankingBoard();
|
||||
@@ -33,12 +34,6 @@ class RecordBoard {
|
||||
|
||||
posX = 780;
|
||||
this.printHeader(posX, posY, "이달의 순위", style);
|
||||
|
||||
posX = 300;
|
||||
posY = 480;
|
||||
this.chartGraphics.lineStyle(3, 0x444444, 1);
|
||||
this.chartGraphics.moveTo(posX, posY);
|
||||
this.chartGraphics.lineTo(posX, posY + 200);
|
||||
}
|
||||
|
||||
printHeader(x, y, title, style) {
|
||||
@@ -47,6 +42,15 @@ class RecordBoard {
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
}
|
||||
|
||||
printSeperator() {
|
||||
const posX = 300;
|
||||
const posY = 480;
|
||||
|
||||
this.chartGraphics.lineStyle(3, 0x444444, 1);
|
||||
this.chartGraphics.moveTo(posX, posY);
|
||||
this.chartGraphics.lineTo(posX, posY + 200);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RecordBoard.HEADER_BAR_HEIGHT_PX = 60;
|
||||
Reference in New Issue
Block a user