From e803cb360d353e19cbad94d219cc02b73612402c 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: Mon, 9 Sep 2019 09:56:49 +0900 Subject: [PATCH] Add: typing highest record text in typing buttons --- src/game/lib/flat_button/typing_app_button.js | 46 ++++++++++++++++--- .../lib/flat_button/typing_exam_button.js | 46 ++++++++++++++++--- src/game/lib/util/record_util.js | 8 ++-- 3 files changed, 85 insertions(+), 15 deletions(-) diff --git a/src/game/lib/flat_button/typing_app_button.js b/src/game/lib/flat_button/typing_app_button.js index 7f6022a..8d81aeb 100644 --- a/src/game/lib/flat_button/typing_app_button.js +++ b/src/game/lib/flat_button/typing_app_button.js @@ -59,11 +59,42 @@ function TypingAppButton(x, y) { this.keyboardSprite.height = TypingAppButton.KEYBOARD_WIDTH; this.buttonSprite.addChild(this.keyboardSprite); - this.animal = new Animal( - Animal.TYPE_ICON, 0, - TypingAppButton.WIDTH - Animal.SPRITE_WIDTH / 2, TypingAppButton.HEIGHT / 2 - ); + var animalPosX = TypingAppButton.WIDTH - Animal.SPRITE_WIDTH / 2; + var animalPosY = TypingAppButton.HEIGHT / 2 + TypingAppButton.ANIMAL_OFFSET_Y; + this.animal = new Animal(Animal.TYPE_ICON, 0, animalPosX, animalPosY); this.buttonSprite.addChild(this.animal.sprite); + + this.typingRecordText = this.makeTypingRecordText(animalPosX, animalPosY + 32); + this.buttonSprite.addChild(this.typingRecordText); +} + +TypingAppButton.prototype.makeTypingRecordText = function(x, y) { + var typingRecordText = game.add.text(x, y, ""); + typingRecordText.anchor.set(0.5, 0.5); + typingRecordText.font = this.setting.font; + typingRecordText.fontSize = 13; + typingRecordText.style.fill = MainColor.LIGHTER_CHOCO_STRING; + typingRecordText.lineSpacing = ButtonSetting.DEFAULT_TEXT_LINE_SPACING_PX; + + return typingRecordText; +} + +TypingAppButton.prototype.setTypingRecordText = function(record) { + var typingAppID = 1; + + var noDataAlpha = 0.3; + if(typeof(record) === "undefined") { + this.animal.sprite.alpha = noDataAlpha; + this.typingRecordText.style.fill = MainColor.CHOCO_STRING; + this.typingRecordText.text = "기록 없음"; + } else if(record === 0) { + this.animal.sprite.alpha = noDataAlpha; + this.typingRecordText.style.fill = MainColor.CHOCO_STRING; + this.typingRecordText.text = "기록 없음"; + } else { + var recordWithUnit = RecordUtil.getRecordValueWithUnit(record, typingAppID); + this.typingRecordText.text = recordWithUnit; + } } TypingAppButton.prototype.updateKeyboard = function(appID) { @@ -150,7 +181,7 @@ TypingAppButton.prototype.updateKeyboard = function(appID) { TypingAppButton.prototype.updateAnimal = function(highestRecord) { var animalIndex = Animal.animalIndexByRecord(highestRecord, this.appType); this.animal.chagneStandAnimation(animalIndex); - this.animal.sprite.y = TypingAppButton.HEIGHT / 2 - Animal.getOffsetY(animalIndex); + this.animal.sprite.y = TypingAppButton.HEIGHT / 2 - Animal.getOffsetY(animalIndex) + TypingAppButton.ANIMAL_OFFSET_Y; } TypingAppButton.prototype.setInputEnabled = function(isEnabled) { @@ -198,7 +229,7 @@ TypingAppButton.prototype.updateAppData = function(appData) { this.appData = appData; this.appGroup = this.appData.appGroup; - if(this.appGroup === 0) + if(Number(this.appGroup) === 0) this.appType = Animal.TYPE_PRACTICE; else this.appType = Animal.TYPE_TEST; @@ -208,6 +239,7 @@ TypingAppButton.prototype.updateAppData = function(appData) { this.setMainText(this.appData.koreanName); this.setInputEnabled(this.appData.activated); this.updateAnimal(this.appData.highestRecord); + this.setTypingRecordText(this.appData.highestRecord); } TypingAppButton.prototype.clickEvent = function() { @@ -232,6 +264,8 @@ TypingAppButton.HEIGHT = 80; TypingAppButton.KEYBOARD_WIDTH = 100; +TypingAppButton.ANIMAL_OFFSET_Y = -6; + TypingAppButton.STROKE_COLOR_OUT_HEX = MainColor.LIGHT_CHOCO_HEX; TypingAppButton.STROKE_COLOR_OVER_HEX = MainColor.LIGHT_CHOCO_HEX; TypingAppButton.STROKE_COLOR_DOWN_HEX = MainColor.LIGHT_CHOCO_HEX; diff --git a/src/game/lib/flat_button/typing_exam_button.js b/src/game/lib/flat_button/typing_exam_button.js index b50d724..7d406c6 100644 --- a/src/game/lib/flat_button/typing_exam_button.js +++ b/src/game/lib/flat_button/typing_exam_button.js @@ -56,11 +56,13 @@ function TypingExamButton(x, y) { this.writingNameText = this.makeWritingNameText(); this.buttonSprite.addChild(this.writingNameText); - this.animal = new Animal( - Animal.TYPE_ICON, 0, - TypingExamButton.WIDTH - Animal.SPRITE_WIDTH / 2, TypingExamButton.HEIGHT / 2 - ); + var animalPosX = TypingExamButton.WIDTH - Animal.SPRITE_WIDTH / 2; + var animalPosY = TypingExamButton.HEIGHT / 2 + TypingExamButton.ANIMAL_OFFSET_Y; + this.animal = new Animal(Animal.TYPE_ICON, 0, animalPosX, animalPosY); this.buttonSprite.addChild(this.animal.sprite); + + this.typingRecordText = this.makeTypingRecordText(animalPosX, animalPosY + 32); + this.buttonSprite.addChild(this.typingRecordText); } @@ -75,14 +77,43 @@ TypingExamButton.prototype.makeLetterCountText = function() { return letterCountText; } +TypingExamButton.prototype.makeTypingRecordText = function(x, y) { + var typingRecordText = game.add.text(x, y, ""); + typingRecordText.anchor.set(0.5, 0.5); + typingRecordText.font = this.setting.font; + typingRecordText.fontSize = 13; + typingRecordText.style.fill = MainColor.LIGHTER_CHOCO_STRING; + typingRecordText.lineSpacing = ButtonSetting.DEFAULT_TEXT_LINE_SPACING_PX; + + return typingRecordText; +} + TypingExamButton.prototype.setLetterCountText = function(letterCount) { - this.letterCountText.y = this.mainText.y; + // this.letterCountText.y = this.mainText.y; if(typeof(letterCount) === "undefined") this.letterCountText.text = ""; else this.letterCountText.text = "( " + NumberUtil.numberWithCommas(letterCount) + "자 )"; } +TypingExamButton.prototype.setTypingRecordText = function(record) { + var typingExamAppID = 200; + + var noDataAlpha = 0.3; + if(typeof(record) === "undefined") { + this.animal.sprite.alpha = noDataAlpha; + this.typingRecordText.style.fill = MainColor.CHOCO_STRING; + this.typingRecordText.text = "기록 없음"; + } else if(record === 0) { + this.animal.sprite.alpha = noDataAlpha; + this.typingRecordText.style.fill = MainColor.CHOCO_STRING; + this.typingRecordText.text = "기록 없음"; + } else { + var recordWithUnit = RecordUtil.getRecordValueWithUnit(record, typingExamAppID); + this.typingRecordText.text = recordWithUnit; + } +} + TypingExamButton.prototype.makeWritingNameText = function() { var textWidth = 250; @@ -114,7 +145,7 @@ TypingExamButton.prototype.setWritingNameText = function(writingName) { TypingExamButton.prototype.updateAnimal = function(highestRecord) { var animalIndex = Animal.animalIndexByRecord(highestRecord, this.appType); this.animal.chagneStandAnimation(animalIndex); - this.animal.sprite.y = TypingExamButton.HEIGHT / 2 - Animal.getOffsetY(animalIndex); + this.animal.sprite.y = TypingExamButton.HEIGHT / 2 - Animal.getOffsetY(animalIndex) + TypingExamButton.ANIMAL_OFFSET_Y; } TypingExamButton.prototype.setInputEnabled = function(isEnabled) { @@ -166,6 +197,7 @@ TypingExamButton.prototype.updateAppData = function(appData) { this.setWritingNameText(this.appData.name); this.setInputEnabled(this.appData.activated); this.updateAnimal(this.appData.highestRecord); + this.setTypingRecordText(this.appData.highestRecord); } TypingExamButton.prototype.clickEvent = function() { @@ -190,6 +222,8 @@ TypingExamButton.loadResources = function() { TypingExamButton.WIDTH = 400; TypingExamButton.HEIGHT = 80; +TypingExamButton.ANIMAL_OFFSET_Y = -6; + TypingExamButton.STROKE_COLOR_OUT_HEX = MainColor.LIGHT_CHOCO_HEX; TypingExamButton.STROKE_COLOR_OVER_HEX = MainColor.LIGHT_CHOCO_HEX; TypingExamButton.STROKE_COLOR_DOWN_HEX = MainColor.LIGHT_CHOCO_HEX; diff --git a/src/game/lib/util/record_util.js b/src/game/lib/util/record_util.js index 2883f05..f5cb2ba 100644 --- a/src/game/lib/util/record_util.js +++ b/src/game/lib/util/record_util.js @@ -16,11 +16,13 @@ RecordUtil.getRecordValueText = function(record, appID) { } RecordUtil.getRecordUnit = function(appID) { - if(appID == 104 || appID == 105) // 104 : dodge, 105 : one to fifty + var appIDValue = Number(appID); + // console.log(appIDValue); + if(appIDValue === 104 || appIDValue === 105) // 104 : dodge, 105 : one to fifty return " 초"; - else if(appID == 52 || appID == 53) // word flyingsaucer + else if(appIDValue === 52 || appIDValue === 53) // word flyingsaucer return " 점"; - else if(appID < 100) // typing + else if(appIDValue < 100 || appIDValue === 200) // typing return " 타"; else return " 점";