From be13a4a05b66a09dc1ddfac4dc7fa72a03f8ea9f Mon Sep 17 00:00:00 2001 From: Rob van Son Date: Fri, 7 Aug 2015 11:57:09 +0200 Subject: [PATCH] Moving SelectWords to MainPage --- Data/MainPage.Table | 3 +- Data/MainPage_DE.Table | 1 + Data/MainPage_EN.Table | 1 + Data/MainPage_JA.Table | 1 + Data/MainPage_NL.Table | 1 + Data/MainPage_ZH.Table | 1 + MainPage.praat | 310 +++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 317 insertions(+), 1 deletion(-) diff --git a/Data/MainPage.Table b/Data/MainPage.Table index 77fdcf3..c46ebef 100644 --- a/Data/MainPage.Table +++ b/Data/MainPage.Table @@ -13,7 +13,8 @@ Quit 90 100 90 100 Red DrawQuit Config 90 100 77.5 87.5 Black DrawConfig $WordlistCaption 88 102 70 75 Black DrawNull WordlistUp 90 100 65 70 Black DrawWordListUp -WordlistDown 90 100 59 64 Black DrawWordListDown +SelectWords 90 100 59 64 Black DrawSelectWords +WordlistDown 90 100 53 58 Black DrawWordListDown Refresh 0 10 80 90 Black DrawRefresh Help 0 10 67.5 77.5 Black DrawHelp $SaveAudio 90 100 0 7.5 Blue DrawNull diff --git a/Data/MainPage_DE.Table b/Data/MainPage_DE.Table index be30243..59259ab 100644 --- a/Data/MainPage_DE.Table +++ b/Data/MainPage_DE.Table @@ -12,6 +12,7 @@ Config Einstellungen g Zur Seite "Einstellungen" Refresh Aktualisieren u Der aktuelle Bildschirm wird abgebildet. Mit der Leertaste kann der Bildschirm aktualisiert werden. Help Hilfe ?/ Dr\u"cken Sie auf den Knopf \u"ber den Sie Informationen m\o"chten. Dr\u"cken Sie danach auf "Hilfe". $WordlistCaption Wordliste \A"ndere Wordliste +SelectWords W\o"rter W W\a"hle die W\o"rter zum \u"ben WordlistUp -vorige \-_ Zur voriger Liste WordlistDown +n\a"chste += Zur n\a"chster Liste Previous >. Next word Quit Quit Q Quit SpeakGoodChinese Config Settings S Go to settings page $WordlistCaption Word List Change word list +SelectWords Words ! Select words to practise WordlistUp Previous- v\-_ Previous word list WordlistDown Next+ N+= Next word list Refresh Refresh h Redraw the current screen, the space-bar always refreshes screen diff --git a/Data/MainPage_JA.Table b/Data/MainPage_JA.Table index 1448ad5..e39e05a 100644 --- a/Data/MainPage_JA.Table +++ b/Data/MainPage_JA.Table @@ -12,6 +12,7 @@ Next 次へ > >. 次の単語に進みます。 Quit 終了 Q Q SpeakGoodChineseを終了します。 Config 設定 S S 設定画面に進みます。 $WordlistCaption 単語表 単語表を変更します。 +SelectWords 単語の選択 ! 練習で使う単語を選択します WordlistUp 戻る- v\-_ 一つ前の単語表に戻ります。 WordlistDown 次へ+ N+= 次の単語表に進みます。 Refresh 再描画 h h 画面を再描画します。スペースキーを押しても再描画できます。 diff --git a/Data/MainPage_NL.Table b/Data/MainPage_NL.Table index ebe8752..6bf119a 100644 --- a/Data/MainPage_NL.Table +++ b/Data/MainPage_NL.Table @@ -12,6 +12,7 @@ Next Vooruit > >. Volgende woord Quit Stop S Stop SpeakGoodChinese Config Instellingen I Ga naar de pagina met instellingen $WordlistCaption Woordenlijst Andere woordenlijst +SelectWords Woorden ! Kies de woorden om te oefenen WordlistUp Vorige g\-_ Vorige woordenlijst WordlistDown Volgende l+= Volgende woordenlijst Refresh Ververs r Ververs de huidige pagina, de spatiebalk ververst altijd de pagina diff --git a/Data/MainPage_ZH.Table b/Data/MainPage_ZH.Table index eb41426..88e027c 100644 --- a/Data/MainPage_ZH.Table +++ b/Data/MainPage_ZH.Table @@ -13,6 +13,7 @@ Quit 结束 Q Q 结束SpeakGoodChinese。 Config 设置 S S 切换到设置页面。 $WordlistCaption 单词表 更换单词表。 WordlistUp 上一个- v\-_ 切换到上一个单词表。 +SelectWords 选择单词 ! 选择要练习的单词 WordlistDown 下一个+ N+= 切换到下一个单词表。 Refresh 刷新 h h 刷新页面。也可以按下“空格”键进行刷新。 Help 帮助 ? ?/ 用鼠标点击您想了解的按钮,则显示提示内容。如需解除帮助,请再按下‘帮助’键。 diff --git a/MainPage.praat b/MainPage.praat index f3b4076..12688fd 100644 --- a/MainPage.praat +++ b/MainPage.praat @@ -55,6 +55,18 @@ procedure DrawNext .color$ .x .y .size demo Paint rectangle... '.color$' '.currentX' '.endX' '.lowY' '.highY' endproc +procedure DrawSelectWords .color$ .x .y .size + .currentFontSize = 48 + .y -= .size/2 + .maxHeight = 2*.size + call adjustFontSizeOnHeight 'defaultFont$' '.currentFontSize' '.maxHeight' + .currentFontSize = adjustFontSizeOnHeight.currentFontSize + call set_font_size '.currentFontSize' + demo Colour... '.color$' + demo Text... '.x' Centre '.y' Bottom ... + call set_font_size 'defaultFontSize' +endproc + procedure DrawWordListUp .color$ .x .y .size .xleft = .x - .size .xright = .x + .size @@ -224,6 +236,304 @@ procedure processMainPagePinYinArea .clickX .clickY .pressed$ sgc.writeAll = 0 endproc +# Select the words to practise. This is quite a complex piece of code +procedure processMainPageSelectWords .clickX .clickY .pressed$ + .table$ = "MainPage" + .label$ = "SelectWords" + call Draw_button '.table$' '.label$' 1 + + # Get help text + call findLabel '.table$' '.label$' + .row = findLabel.row + select Table '.table$' + .helpText$ = Get value... '.row' Helptext + call convert_praat_to_latin1 '.helpText$' + .helpText$ = convert_praat_to_latin1.text$ + + # Implement Cancel + select Table 'wordlist$' + .tmpOriginalWordlist = Copy: "Original_'wordlist$'" + + + # Set current word + select Table 'wordlist$' + sgc.numberOfWords = Get number of rows + .currentWord = sgc.currentWord + if .currentWord <= 0 or .currentWord > sgc.numberOfWords or config.shuffleLists + .currentWord = 1 + endif + + # The texts + call get_feedback_text 'config.language$' Part + call convert_praat_to_latin1 'get_feedback_text.text$' + .partText$ = convert_praat_to_latin1.text$ + call get_feedback_text 'config.language$' Tones + call convert_praat_to_latin1 'get_feedback_text.text$' + .toneText$ = convert_praat_to_latin1.text$ + call get_feedback_text 'config.language$' Cancel + call convert_praat_to_latin1 'get_feedback_text.text$' + .cancelText$ = convert_praat_to_latin1.text$ + call get_feedback_text 'config.language$' Clear + call convert_praat_to_latin1 'get_feedback_text.text$' + .clearText$ = convert_praat_to_latin1.text$ + call get_feedback_text 'config.language$' All + call convert_praat_to_latin1 'get_feedback_text.text$' + .allText$ = convert_praat_to_latin1.text$ + call get_feedback_text 'config.language$' Previous + call convert_praat_to_latin1 'get_feedback_text.text$' + .prevWord$ = convert_praat_to_latin1.text$ + call get_feedback_text 'config.language$' Next + call convert_praat_to_latin1 'get_feedback_text.text$' + .nextWord$ = convert_praat_to_latin1.text$ + call get_feedback_text 'config.language$' Continue + call convert_praat_to_latin1 'get_feedback_text.text$' + .continueText$ = convert_praat_to_latin1.text$ + call get_feedback_text 'config.language$' Show + call convert_praat_to_latin1 'get_feedback_text.text$' + .showText$ = convert_praat_to_latin1.text$ + + .pinyinText$ = "Pinyin" + .characterText$ = "Character" + + # Get lesson names + select Table 'wordlist$' + .lessonCol = Get column index: "Lesson" + .lessonList$ = tab$ + .numLessons = 0 + # All shown keeps track whether all words are shown + # If so, selecting a lesson is preceded by a Clear All + .allShown = 0 + # Sort words for consistent selection interface + if config.shuffleLists + # Allow subdivision in lessons + if .lessonCol > 0 + Sort rows... Lesson Pinyin + else + Sort rows... Pinyin + endif + endif + if .lessonCol > 0 + for .i to sgc.numberOfWords + .currentLesson$ = Get value: .i, "Lesson" + if .currentLesson$ <> "" and .currentLesson$ <> "-" and index_regex(.lessonList$, "\t'.currentLesson$'\t") <= 0 + .lessonList$ = .lessonList$ + .currentLesson$ + tab$ + .numLessons += 1 + .lessonName$['.numLessons'] = .currentLesson$ + endif + .shown$ = Get value: .i, "Show" + if .shown$ = "-" + .allShown = 0 + endif + endfor + endif + + clicked = -1 + .numWordsPerScreen = 15 + while clicked <> 6 and clicked <> 1 + .lessonSelected = -1 + .toneSelected = -1 + .firstShown = -1 + + select Table 'wordlist$' + .lessonCol = Get column index: "Lesson" + # Sort words for consistent selection interface + if config.shuffleLists + # Allow subdivision in lessons + if .lessonCol > 0 + Sort rows... Lesson Pinyin + else + Sort rows... Pinyin + endif + endif + .max = .numWordsPerScreen - 1 + if .currentWord + .max > sgc.numberOfWords + .max = sgc.numberOfWords - .currentWord + endif + for .i from 0 to .numWordsPerScreen - 1 + if .i <= .max + .currentPinyin$ = Get value: .currentWord+.i, "Pinyin" + if index_regex(.currentPinyin$, "[0-9]") <= 0 + call pinyin2numbers '.currentPinyin$' + .currentPinyin$ = replace_regex$(pinyin2numbers.intermediatePinyin$, ".+", "\l&", 0) + .currentPinyin$ = replace_regex$(.currentPinyin$, "[^a-zA-Z0-9]", "", 0) + endif + .pinyin$[.i] = .currentPinyin$ + + .character$[.i] = Get value: .currentWord+.i, "Character" + .lessonNum$[.i] = "" + if .lessonCol > 0 + .lessonNum$[.i] = Get value: .currentWord+.i, "Lesson" + .lessonNum$[.i] = " : " + .lessonNum$[.i] + endif + .showText$[.i] = .pinyin$['.i'] + if .character$['.i'] <> "-" + .showText$[.i] = .pinyin$['.i']+" ("+.character$['.i']+.lessonNum$['.i']+")" + elsif .lessonNum$['.i'] <> "" + .showText$[.i] = .pinyin$['.i']+" ( -"+.lessonNum$['.i']+")" + endif + .showValueText$[.i] = Get value: .currentWord+.i, "Show" + if .showValueText$[.i] = "-" + .showValue[.i] = 0 + else + .showValue[.i] = 1 + endif + .showVariable$[.i] = .pinyin$[.i] + .tmp$ = .showVariable$[.i] + '.tmp$' = .showValue[.i] + else + .showText$[.i] = "-" + .showValue[.i] = 0 + endif + endfor + + # The user text input window (beginPause .... endPause) + beginPause(.helpText$) + boolean (.showText$[0], .showValue[0]) + boolean (.showText$[1], .showValue[1]) + boolean (.showText$[2], .showValue[2]) + boolean (.showText$[3], .showValue[3]) + boolean (.showText$[4], .showValue[4]) + boolean (.showText$[5], .showValue[5]) + boolean (.showText$[6], .showValue[6]) + boolean (.showText$[7], .showValue[7]) + boolean (.showText$[8], .showValue[8]) + boolean (.showText$[9], .showValue[9]) + boolean (.showText$[10], .showValue[10]) + boolean (.showText$[11], .showValue[11]) + boolean (.showText$[12], .showValue[12]) + boolean (.showText$[13], .showValue[13]) + boolean (.showText$[14], .showValue[14]) + if .numLessons > 0 + optionMenu: .partText$, 1 + option: "---" + .j = 0 + for .j to .numLessons + option: .lessonName$['.j'] + endfor + endif + optionMenu: .toneText$, 1 + option: "---" + option: "0" + option: "1" + option: "2" + option: "3" + option: "4" + clicked = endPause ("'.cancelText$'", "'.clearText$'", "'.allText$'", "'.prevWord$'", "'.nextWord$'", "'.continueText$'", 6, 1) + + if clicked = 2 + for .i to sgc.numberOfWords + Set string value: .i, "Show", "-" + endfor + .allShown = 0 + elsif clicked = 3 + for .i to sgc.numberOfWords + Set string value: .i, "Show", "+" + endfor + .allShown = 1 + elsif clicked != 1 + # Get selected Part BEFORE we do anything else + if .numLessons > 0 + .tmp$ = replace_regex$(.partText$, "^(.)", "\l\1", 0) + .lessonSelected = '.tmp$' - 1 + endif + if .lessonSelected > 0 + .allShown = 1 + .firstShown = -1 + select Table 'wordlist$' + for .i to sgc.numberOfWords + # Keep track of whether all are shown + .shown$ = Get value: .i, "Show" + if .shown$ = "-" + .allShown = 0 + endif + endfor + for .i to sgc.numberOfWords + # Lessons + .currentLesson$ = Get value: .i, "Lesson" + if .currentLesson$ = .lessonName$['.lessonSelected'] + Set string value: .i, "Show", "+" + elsif .allShown = 1 + Set string value: .i, "Show", "-" + endif + endfor + for .i to sgc.numberOfWords + # Keep track of whether all are shown + .shown$ = Get value: .i, "Show" + if .firstShown <=0 and .shown$ <> "-" + .firstShown = .i + endif + endfor + else + for .i from 0 to .max + .tmp$ = .showVariable$['.i'] + .showValue['.i'] = '.tmp$' + .showWord$['.i'] = "-" + if .showValue['.i'] <> 0 + .showWord$['.i'] = "+" + endif + Set string value: .currentWord+.i, "Show", .showWord$['.i'] + endfor + endif + .tmp$ = replace_regex$(.toneText$, "^(.)", "\l\1", 0) + .toneSelected = '.tmp$' - 2 + if .toneSelected >= 0 + select Table 'wordlist$' + for .i to sgc.numberOfWords + .currentPinyin$ = Get value: .i, "Pinyin" + if index_regex(.currentPinyin$, "[0-9]") <= 0 + call pinyin2numbers '.currentPinyin$' + .currentPinyin$ = replace_regex$(pinyin2numbers.intermediatePinyin$, ".+", "\l&", 0) + .currentPinyin$ = replace_regex$(.currentPinyin$, "[^a-zA-Z0-9]", "", 0) + endif + .tmp$ = Get value: .i, "Show" + if .tmp$ <> "-" and index(.currentPinyin$, "'.toneSelected'") > 0 + Set string value: .i, "Show", "+" + else + Set string value: .i, "Show", "-" + .allShown = 0 + endif + endfor + endif + + if clicked = 4 + if .firstShown > 0 + .currentWord = (.firstShown div .numWordsPerScreen) * .numWordsPerScreen + 1 + elsif .toneSelected < 0 + .currentWord -= .numWordsPerScreen + endif + if .currentWord <= 0 + .currentWord = (sgc.numberOfWords div .numWordsPerScreen) * .numWordsPerScreen + 1 + endif + elsif clicked = 5 + if .firstShown > 0 + .currentWord = (.firstShown div .numWordsPerScreen) * .numWordsPerScreen + 1 + elsif .toneSelected < 0 + .currentWord += .numWordsPerScreen + endif + if .currentWord > sgc.numberOfWords + .currentWord = 1 + endif + endif + endif + # Reset and go to the first selected word (can shuffle list) + if clicked = 6 + sgc.currentWord = -1 + call next_word + endif + endwhile + + # Implement Cancel + if clicked = 1 + select Table 'wordlist$' + Remove + select .tmpOriginalWordlist + Copy: wordlist$ + endif + select .tmpOriginalWordlist + Remove + call Draw_button '.table$' '.label$' 0 +endproc + ############################################################### # # Obligatory button Processing Routines -- 2.11.4.GIT