Add: show space indicator

This commit is contained in:
2019-06-24 08:12:39 +09:00
parent d800d41313
commit cb9ac3a017
3 changed files with 25 additions and 82 deletions
+21 -78
View File
@@ -176,27 +176,6 @@ var TypingExamination = {
} }
/*
// keyboard
this.keyMapper = new KeyMapper();
this.keyboard = null;
if(sessionStorageManager.getPlayingAppName().indexOf("korean") > 0)
this.keyboard = new Keyboard(this.keyMapper, Keyboard.KOREAN, Keyboard.NO_OFFSET_POS_Y);
else
this.keyboard = new Keyboard(this.keyMapper, Keyboard.ENGLISH, Keyboard.NO_OFFSET_POS_Y);
this.keyboard.addCallback(
Phaser.KeyCode.ESC, // keyCode
null, // keyDownHandler
(function() { this.back(); }).bind(this), // keyUpHandler
"keyboard_test" // callerClassName
);
// hands
this.leftHand = new LeftHand(this.keyMapper);
this.rightHand = new RightHand(this.keyMapper);
*/
// bottom ui // bottom ui
var screenBottomUI = new ScreenBottomUI(); var screenBottomUI = new ScreenBottomUI();
@@ -348,6 +327,10 @@ var TypingExamination = {
this.startGame(); this.startGame();
}, },
replaceSpaceWithSpaceIndicator: function(text) {
return text.replace(/ /g, TypingExamination.SPACE_INDICATOR);
},
showTypingExaminationContents: function() { showTypingExaminationContents: function() {
for(var i = 0; i < TypingExamination.TYPING_CONTENT_DONE_COUNT; i++) { for(var i = 0; i < TypingExamination.TYPING_CONTENT_DONE_COUNT; i++) {
var doneIndex = this.typingIndex - i - 1; var doneIndex = this.typingIndex - i - 1;
@@ -365,13 +348,15 @@ var TypingExamination = {
return; return;
} }
this.textTypingContent.text = this.typingExaminationContents[this.typingIndex]; var contentText = this.typingExaminationContents[this.typingIndex];
this.textTypingContent.text = this.replaceSpaceWithSpaceIndicator(contentText);
for(var i = 0; i < TypingExamination.TYPING_CONTENT_PREVIEW_COUNT; i++) { for(var i = 0; i < TypingExamination.TYPING_CONTENT_PREVIEW_COUNT; i++) {
var previewIndex = this.typingIndex + i + 1; var previewIndex = this.typingIndex + i + 1;
if(previewIndex < this.typingExaminationContents.length) if(previewIndex < this.typingExaminationContents.length) {
this.textTypingContentPreview[i].text = this.typingExaminationContents[previewIndex]; var previewText = this.typingExaminationContents[previewIndex];
else this.textTypingContentPreview[i].text = this.replaceSpaceWithSpaceIndicator(previewText);
} else
this.textTypingContentPreview[i].text = ""; this.textTypingContentPreview[i].text = "";
} }
}, },
@@ -386,19 +371,19 @@ var TypingExamination = {
if(this.isGameOver) if(this.isGameOver)
return; return;
var inputText = this.inputTextContent.canvasInput.value().trim();
// var inputContent = inputText.replace(/ /g, TypingExamination.SPACE_INDICATOR); // var inputContent = inputText.replace(/ /g, TypingExamination.SPACE_INDICATOR);
var inputContent = inputText; var inputContent = this.inputTextContent.canvasInput.value();
var trimmedInputContent = inputContent.trim();
var typingContent = this.typingExaminationContents[this.typingIndex].trim(); var typingContent = this.typingExaminationContents[this.typingIndex].trim();
if(event.keyCode == Phaser.Keyboard.ENTER || if(event.keyCode == Phaser.Keyboard.ENTER ||
event.keyCode == Phaser.Keyboard.SPACEBAR) { event.keyCode == Phaser.Keyboard.SPACEBAR) {
// console.log("### enter ###"); // console.log("### enter ###");
// console.log("this.typingIndex : " + this.typingIndex); // console.log("this.typingIndex : " + this.typingIndex);
// console.log("inputContent : [" + inputContent + "], length : " + inputContent.length); // console.log("trimmedInputContent : [" + trimmedInputContent + "], length : " + trimmedInputContent.length);
// console.log("typingContent : [" + typingContent + "], length : " + typingContent.length); // console.log("typingContent : [" + typingContent + "], length : " + typingContent.length);
if(inputContent === typingContent) { if(trimmedInputContent === typingContent) {
// console.log("input completed"); // console.log("input completed");
this.calculateTypingRecord(typingContent); this.calculateTypingRecord(typingContent);
@@ -425,18 +410,24 @@ var TypingExamination = {
}, },
showTypingContentHighlight: function(inputContent, typingContent) { showTypingContentHighlight: function(inputContent, typingContent) {
console.log(inputContent + "=");
console.log(typingContent + "=");
this.textTypingContent.clearColors(); this.textTypingContent.clearColors();
this.textTypingContent.addColor(TypingExamination.COLOR_CONTENT_RIGHT, 0); this.textTypingContent.addColor(TypingExamination.COLOR_CONTENT_RIGHT, 0);
if(typingContent == null) if(typingContent == null)
return; return;
// var replaceSpaceIndicatorInputContent = inputContent.replace(/ /g, TypingExamination.SPACE_INDICATOR);
var typingContentLength = typingContent.length; var typingContentLength = typingContent.length;
for(var i = 0; i < typingContentLength; i++) { for(var i = 0; i < typingContentLength; i++) {
// console.log("typingContent.charAt(i) : " + typingContent.charAt(i)); // console.log("typingContent.charAt(i) : " + typingContent.charAt(i));
// console.log("inputContent.charAt(i) : " + inputContent.charAt(i)); // console.log("inputContent.charAt(i) : " + inputContent.charAt(i));
if(typingContent.charAt(i) != inputContent.charAt(i)) { if(typingContent.charAt(i) != inputContent.charAt(i)) {
console.log("inputContent.charAt(" + i + ") : " + inputContent.charCodeAt(i).toString(16) + ", " + inputContent.charAt(i));
console.log("typingContent.charAt(" + i + ") : " + typingContent.charCodeAt(i).toString(16) + ", " + typingContent.charAt(i));
this.textTypingContent.addColor(TypingExamination.COLOR_CONTENT_INPUT, i); this.textTypingContent.addColor(TypingExamination.COLOR_CONTENT_INPUT, i);
return; return;
} }
@@ -726,54 +717,6 @@ var TypingExamination = {
return highlightKey; return highlightKey;
}, },
/*
hideHighlightKey: function(highlightKey) {
// var prevText = this.typingExaminationContents[this.typingIndex];
if(highlightKey === undefined)
return;
this.keyboard.hideHighlight(highlightKey);
},
showHighlightKey: function(highlightKey) {
// var typingText = this.typingExaminationContents[this.typingIndex];
if(highlightKey === undefined)
return;
this.keyboard.showHighlight(highlightKey, this.leftHand, this.rightHand);
},
moveHands: function(highlightKey) {
// var typingText = this.typingExaminationContents[this.typingIndex];
if(highlightKey === undefined)
return;
var key = this.keyboard.getKeyOfText(highlightKey);
var handSide = key.handSide;
if(handSide === KeyButton.LEFT_HAND) {
this.leftHand.moveTo(key);
if(this.keyMapper.isShiftText(highlightKey)) {
var shiftRightKey = this.keyboard.getKey("ShiftRight");
shiftRightKey.showHighlight();
this.rightHand.moveTo(shiftRightKey);
} else {
this.rightHand.moveToDefaultPosition();
}
} else {
this.rightHand.moveTo(key);
if(this.keyMapper.isShiftText(highlightKey)) {
var shiftLeftKey = this.keyboard.getKey("ShiftLeft");
shiftLeftKey.showHighlight();
this.leftHand.moveTo(shiftLeftKey);
} else {
this.leftHand.moveToDefaultPosition();
}
}
},
*/
calculateTypingRecord: function(typingContent) { calculateTypingRecord: function(typingContent) {
// console.log('입력 단어 : ' + this.typingExaminationContents[this.typingIndex]); // console.log('입력 단어 : ' + this.typingExaminationContents[this.typingIndex]);
@@ -856,7 +799,7 @@ var TypingExamination = {
TypingExamination.GAME_TIME_SEC = 60 * 5; // 5 minutes TypingExamination.GAME_TIME_SEC = 60 * 5; // 5 minutes
TypingExamination.SPACE_INDICATOR = " · "; TypingExamination.SPACE_INDICATOR = "ˇ"; // "ᵔ"; // "ᵕ"; // "ˣ"; // "ᵛ"; // " · ";
TypingExamination.TYPING_CONTENT_PREVIEW_COUNT = 4; // 3; TypingExamination.TYPING_CONTENT_PREVIEW_COUNT = 4; // 3;
TypingExamination.TYPING_CONTENT_DONE_COUNT = 4; // 3; TypingExamination.TYPING_CONTENT_DONE_COUNT = 4; // 3;
+1 -1
View File
@@ -133,7 +133,7 @@ TypingTextManager.prototype.makeShortSentences = function(sentence) {
var wordLength = words[i].length; var wordLength = words[i].length;
if(wordLength > TypingTextManager.SENTENCE_MAX_CHARACTER) { if(wordLength > TypingTextManager.SENTENCE_MAX_CHARACTER) {
console.log(words[i]); // console.log(words[i]);
if(shortSentences[sentenceIndex].legnth > 0) if(shortSentences[sentenceIndex].legnth > 0)
sentenceIndex++; sentenceIndex++;
+3 -3
View File
@@ -58,12 +58,12 @@
<script src="../../game/lib/button/fullscreen_button.js"></script> <script src="../../game/lib/button/fullscreen_button.js"></script>
<script src="../../game/lib/db_connect_manager.js"></script> <script src="../../game/lib/db_connect_manager.js"></script>
<script src="../../game/lib/experience_app_timer.js"></script> <script src="../../game/lib/experience_app_timer.js"></script>
<script src="../../game/lib/stage_timer.js"></script> <script src="../../game/lib/stage_timer.js?update=20190622"></script>
<!-- Examination typing : source files --> <!-- Examination typing : source files -->
<script src="../../game/typing/lib/content_progress.js"></script> <script src="../../game/typing/lib/content_progress.js"></script>
<script src="../../game/typing/lib/typing_text_manager.js"></script> <script src="../../game/typing/lib/typing_text_manager.js?update=20190622"></script>
<script src="../../game/typing/lib/typing_content_bg.js"></script> <script src="../../game/typing/lib/typing_content_bg.js?update=20190622"></script>
<script src="../../game/typing/lib/key_mapper.js"></script> <script src="../../game/typing/lib/key_mapper.js"></script>
<!-- <!--
<script src="../../game/typing/lib/key_button.js"></script> <script src="../../game/typing/lib/key_button.js"></script>