Add: prev next time

This commit is contained in:
2019-06-06 18:46:24 +09:00
parent 3ab72a05c4
commit ff5c638f01
+97 -38
View File
@@ -25,7 +25,7 @@ var Ranking = {
// this.bgWhite = game.add.sprite(0, 0, "bg_white"); // this.bgWhite = game.add.sprite(0, 0, "bg_white");
// this.bgWhite.width = GAME_SCREEN_SIZE.x; // this.bgWhite.width = GAME_SCREEN_SIZE.x;
// this.bgWhite.height = GAME_SCREEN_SIZE.y; // this.bgWhite.height = GAME_SCREEN_SIZE.y;
// this.setBgColor(); // this.setBgColor(this.timeType);
var posY = 100; var posY = 100;
// var bg = game.add.graphics(); // var bg = game.add.graphics();
@@ -34,7 +34,7 @@ var Ranking = {
this.bgWhite = game.add.sprite(0, 60, "bg_white"); this.bgWhite = game.add.sprite(0, 60, "bg_white");
this.bgWhite.width = GAME_SCREEN_SIZE.x; this.bgWhite.width = GAME_SCREEN_SIZE.x;
this.bgWhite.height = 80; this.bgWhite.height = 80;
this.setBgColor(); this.setBgColor(this.timeType);
// keyboard shortcut // keyboard shortcut
@@ -66,13 +66,14 @@ var Ranking = {
// date time // date time
this.textDateTime = game.add.text(GAME_SCREEN_SIZE.x / 2, 104, "", resultTextStyle); this.textDateTime = game.add.text(GAME_SCREEN_SIZE.x / 2, 104, "", resultTextStyle);
this.textDateTime.fontSize = 34; this.textDateTime.fontSize = 28;
this.textDateTime.fontWeight = "normal"; this.textDateTime.fontWeight = "normal";
this.textDateTime.stroke = "#333333"; this.textDateTime.stroke = "#333333";
this.textDateTime.strokeThickness = 3; this.textDateTime.strokeThickness = 3;
//.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); //.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
this.textDateTime.anchor.set(0.5); this.textDateTime.anchor.set(0.5);
// this.textDateTime.addColor("#ff6666", 0); // this.textDateTime.addColor("#ff6666", 0);
this.printDateTime(this.dateTime);
// rank // rank
@@ -85,23 +86,39 @@ var Ranking = {
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
var buttonOffsetX = 300; var buttonOffsetX = 320;
var buttonPositionY = 100; var buttonPositionY = 100;
var dateTimeButtonWidth = 40;
this.buttonPrevDate = this.makeArrowButton( this.buttonPrevDate = this.makeArrowButton(
buttonOffsetX, buttonPositionY, buttonOffsetX, buttonPositionY,
50, 50, dateTimeButtonWidth, dateTimeButtonWidth,
"<", "<",
(function() { console.log("prev date time"); }).bind(this) (function() { this.decreaseDateTime(); }).bind(this)
); );
// this.buttonPrevDate.inputEnabled = false; // this.buttonPrevDate.inputEnabled = false;
this.buttonNextDate = this.makeArrowButton( this.buttonNextDate = this.makeArrowButton(
GAME_SCREEN_SIZE.x - buttonOffsetX, buttonPositionY, GAME_SCREEN_SIZE.x - buttonOffsetX, buttonPositionY,
50, 50, dateTimeButtonWidth, dateTimeButtonWidth,
">", ">",
(function() { console.log("next date time"); }).bind(this) (function() { this.increaseDateTime(); }).bind(this)
); );
// this.buttonNextDate.inputEnabled = false; // this.buttonNextDate.inputEnabled = false;
var buttonTestDate = null;
if(runMode == MODE_DEBUG) {
buttonTestDate = this.makeArrowButton(
30, buttonPositionY,
50, 50,
"@",
(function() {
this.date = "2018-08-23";
this.time = "15:53:00";
this.dateTime = new Date(this.date + "T" + this.time);
this.getRecordToRankingServer();
}).bind(this)
);
}
buttonOffsetX = 30; buttonOffsetX = 30;
buttonPositionY = 370; buttonPositionY = 370;
@@ -291,10 +308,12 @@ var Ranking = {
this.timeType = Ranking.MODE_HOUR; this.timeType = Ranking.MODE_HOUR;
this.textTitle.text = sessionStorageManager.getPlayingAppKoreanName() + " - 수업시간 순위"; this.textTitle.text = sessionStorageManager.getPlayingAppKoreanName() + " - 수업시간 순위";
this.textTitle.addColor("#ff6666", 0); this.textTitle.addColor("#ff6666", 0);
this.getRecordToRankingServer();
this.printDateTime(this.dateTime);
this.getRecordToRankingServer();
this.setFirstPageIndex(); this.setFirstPageIndex();
this.setBgColor(); this.setBgColor(this.timeType);
}, },
showRankingDay: function() { showRankingDay: function() {
@@ -302,9 +321,11 @@ var Ranking = {
this.textTitle.text = sessionStorageManager.getPlayingAppKoreanName() + " - 오늘의 순위"; this.textTitle.text = sessionStorageManager.getPlayingAppKoreanName() + " - 오늘의 순위";
this.textTitle.addColor("#9999ff", 0); this.textTitle.addColor("#9999ff", 0);
this.printDateTime(this.dateTime);
this.getRecordToRankingServer(); this.getRecordToRankingServer();
this.setFirstPageIndex(); this.setFirstPageIndex();
this.setBgColor(); this.setBgColor(this.timeType);
}, },
showRankingMonth: function() { showRankingMonth: function() {
@@ -312,9 +333,11 @@ var Ranking = {
this.textTitle.text = sessionStorageManager.getPlayingAppKoreanName() + " - 이달의 순위"; this.textTitle.text = sessionStorageManager.getPlayingAppKoreanName() + " - 이달의 순위";
this.textTitle.addColor("#99ff99", 0); this.textTitle.addColor("#99ff99", 0);
this.printDateTime(this.dateTime);
this.getRecordToRankingServer(); this.getRecordToRankingServer();
this.setFirstPageIndex(); this.setFirstPageIndex();
this.setBgColor(); this.setBgColor(this.timeType);
}, },
showRanking: function(rankingRecordManager) { showRanking: function(rankingRecordManager) {
@@ -328,6 +351,7 @@ var Ranking = {
} }
if(rankingRecordManager.rankingRecords.length === 0) { if(rankingRecordManager.rankingRecords.length === 0) {
this.setFirstPageIndex();
var rankEmpty = [ ]; var rankEmpty = [ ];
this.textRanking1to10.parseList(rankEmpty); this.textRanking1to10.parseList(rankEmpty);
this.textRanking11to20.parseList(rankEmpty); this.textRanking11to20.parseList(rankEmpty);
@@ -351,7 +375,7 @@ var Ranking = {
this.recordArray.push(bestRecordRow); this.recordArray.push(bestRecordRow);
} }
this.printDateTime(); this.printDateTime(this.dateTime);
this.printRanking(); this.printRanking();
}, },
@@ -443,18 +467,51 @@ var Ranking = {
this.dateTime = new Date(hourTimeText); this.dateTime = new Date(hourTimeText);
this.date = DateUtil.getYYYYMMDD(this.dateTime); this.date = DateUtil.getYYYYMMDD(this.dateTime);
this.time = DateUtil.getHHMMSS(this.dateTime); this.time = DateUtil.getHHMMSS(this.dateTime);
},
if(runMode == MODE_DEBUG) { setDateTime: function(dateTime) {
this.date = "2018-08-23"; this.date = DateUtil.getYYYYMMDD(dateTime);
this.time = "15:53:00"; this.time = DateUtil.getHHMMSS(dateTime);
this.dateTime = new Date(this.date + "T" + this.time);
}
}, },
increaseDateTime: function() { increaseDateTime: function() {
switch(this.timeType) {
case Ranking.MODE_HOUR:
this.dateTime.setHours(this.dateTime.getHours() + 1);
break;
case Ranking.MODE_DAY:
this.dateTime.setDate(this.dateTime.getDate() + 1);
break;
case Ranking.MODE_MONTH:
this.dateTime.setMonth(this.dateTime.getMonth() + 1);
break;
}
this.setDateTime(this.dateTime);
this.printDateTime(this.dateTime);
this.getRecordToRankingServer();
}, },
decreaseDateTime: function() { decreaseDateTime: function() {
switch(this.timeType) {
case Ranking.MODE_HOUR:
this.dateTime.setHours(this.dateTime.getHours() - 1);
break;
case Ranking.MODE_DAY:
this.dateTime.setDate(this.dateTime.getDate() - 1);
break;
case Ranking.MODE_MONTH:
this.dateTime.setMonth(this.dateTime.getMonth() - 1);
break;
}
this.setDateTime(this.dateTime);
this.printDateTime(this.dateTime);
this.getRecordToRankingServer();
}, },
getDatetimeHour: function() { getDatetimeHour: function() {
@@ -465,37 +522,39 @@ var Ranking = {
return ("0" + this.dateTime.getHours()).slice(-2); return ("0" + this.dateTime.getHours()).slice(-2);
}, },
getYYYYMMDDHHText: function() { getYYYYMMDDHHText: function(dateTime) {
return DateUtil.getFullYear(this.dateTime) + "년 " return DateUtil.getFullYear(dateTime) + "년 "
+ DateUtil.getFullMonth(this.dateTime) + "월 " + DateUtil.getFullMonth(dateTime) + "월 "
+ DateUtil.getFullDate(this.dateTime) + "일, " + DateUtil.getFullDate(dateTime) + "일, "
+ DateUtil.getFullHours(this.dateTime) + "시"; + DateUtil.getFullHours(dateTime) + "시";
}, },
getYYYYMMDDText: function() { getYYYYMMDDText: function(dateTime) {
return DateUtil.getFullYear(this.dateTime) + "년 " return DateUtil.getFullYear(dateTime) + "년 "
+ DateUtil.getFullMonth(this.dateTime) + "월 " + DateUtil.getFullMonth(dateTime) + "월 "
+ DateUtil.getFullDate(this.dateTime) + "일"; + DateUtil.getFullDate(dateTime) + "일";
}, },
getYYYYMMText: function() { getYYYYMMText: function(dateTime) {
return DateUtil.getFullYear(this.dateTime) + "년 " return DateUtil.getFullYear(dateTime) + "년 "
+ DateUtil.getFullMonth(this.dateTime) + "월 "; + DateUtil.getFullMonth(dateTime) + "월 ";
}, },
printDateTime: function() { printDateTime: function(dateTime) {
console.log(this.timeType); // console.log(this.timeType);
// console.log((this.dateTime);
switch(this.timeType) { switch(this.timeType) {
case Ranking.MODE_HOUR: case Ranking.MODE_HOUR:
this.textDateTime.text = this.getYYYYMMDDHHText(); this.textDateTime.text = this.getYYYYMMDDHHText(dateTime);
break; break;
case Ranking.MODE_DAY: case Ranking.MODE_DAY:
this.textDateTime.text = this.getYYYYMMDDText(); this.textDateTime.text = this.getYYYYMMDDText(dateTime);
break; break;
case Ranking.MODE_MONTH: case Ranking.MODE_MONTH:
this.textDateTime.text = this.getYYYYMMText(); this.textDateTime.text = this.getYYYYMMText(dateTime);
break; break;
} }
}, },
@@ -524,8 +583,8 @@ var Ranking = {
this.showingPageIndex = 0; this.showingPageIndex = 0;
}, },
setBgColor: function() { setBgColor: function(timeType) {
switch(this.timeType) { switch(timeType) {
case Ranking.MODE_HOUR: case Ranking.MODE_HOUR:
this.bgWhite.tint = 0x5f4d4d; this.bgWhite.tint = 0x5f4d4d;
break; break;
@@ -545,4 +604,4 @@ Ranking.MODE_HOUR = "mode_hour";
Ranking.MODE_DAY = "mode_day"; Ranking.MODE_DAY = "mode_day";
Ranking.MODE_MONTH = "mode_month"; Ranking.MODE_MONTH = "mode_month";
Ranking.REFRESH_TIME_SEC = 10; Ranking.REFRESH_TIME_SEC = 5;