From d14eac51413266d4c27e1b6a73609e2a2c56aeb7 Mon Sep 17 00:00:00 2001 From: exch-bms2 Date: Thu, 29 Sep 2016 21:26:34 +0900 Subject: [PATCH] Music Select : support Japanese word input on search text field (in progress) --- README.md | 7 +++-- .../beatoraja/select/MusicSelector.java | 30 +++++++++++++++---- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6d95c7620..b40430631 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Codename beatoraja is a Cross-platform rhythm game based on Java and libGDX. It works on Windows, Mac OS, and Linux. -Features : +# Features - 3 types of Long Note mode : Long Notes, Charge Notes, Hell Charge Notes, and Back Spin Scratch like iidx - show notes duration (like iidx green number), judge details (fast/slow or +-ms) - 8 types of groove gauge (ex. assist-easy, ex-hard, ex-grade) @@ -12,7 +12,8 @@ Features : - pms judge (nax 1 miss / 1 notes, combo is reset when miss) - support bmson 1.0.0 - import difficulty table and create table folder, create course with various constraint (mirror/random OK, no hispeed, and so on) -- import LunaticRave2 skin (now working in progress) +- import LunaticRave2 skin (now working in progress. not supporting DirectXArchive(.dxa) and DirectDrawSurface(.dds) file) -System Requirement : +# System Requirement - Java Runtime Environment 1.8.0 64bit (32bit is not recomended) +- OpenGL 3.1- (may not work under Windows 10 + Intel HD Graphics 2000/3000. See also https://github.com/LWJGL/lwjgl/issues/119) diff --git a/src/bms/player/beatoraja/select/MusicSelector.java b/src/bms/player/beatoraja/select/MusicSelector.java index 12242673c..bcf08c3a3 100644 --- a/src/bms/player/beatoraja/select/MusicSelector.java +++ b/src/bms/player/beatoraja/select/MusicSelector.java @@ -25,6 +25,8 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.math.Rectangle; +import com.badlogic.gdx.scenes.scene2d.Event; +import com.badlogic.gdx.scenes.scene2d.EventListener; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.ui.TextField; import com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldListener; @@ -108,6 +110,7 @@ public class MusicSelector extends MainState { private FreeTypeFontGenerator generator; private BitmapFont titlefont; + private BitmapFont searchfont; private TextureRegion banner; private Bar bannerbar; @@ -269,6 +272,7 @@ public void create() { FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter(); parameter.size = 24; titlefont = generator.generateFont(parameter); + searchfont = generator.generateFont(parameter); option = new GameOptionRenderer(config); aoption = new AssistOptionRenderer(config); @@ -276,24 +280,24 @@ public void create() { getTimer()[TIMER_SONGBAR_CHANGE] = getNowTime(); + // search text field if(getStage() == null) { final Stage stage = new Stage(new FitViewport(MainController.RESOLUTION[config.getResolution()].width, MainController.RESOLUTION[config.getResolution()].height)); - /* TextfieldStyleの定義 */ - TextField.TextFieldStyle textFieldStyle = new TextField.TextFieldStyle(titlefont, // BitmapFont + final TextField.TextFieldStyle textFieldStyle = new TextField.TextFieldStyle(searchfont, // BitmapFont Color.WHITE, // font color new TextureRegionDrawable(new TextureRegion(new Texture("skin/system.png"), 0, 8, 8, 8)), // cusor new TextureRegionDrawable(new TextureRegion(new Texture("skin/system.png"), 0, 8, 2, 8)), // selectoin new TextureRegionDrawable(new TextureRegion(new Texture("skin/system.png"), 0, 8, 1, 8))); // background - textFieldStyle.messageFont = titlefont; - textFieldStyle.messageFontColor = Color.DARK_GRAY; + textFieldStyle.messageFont = searchfont; + textFieldStyle.messageFontColor = Color.GRAY; - /* textFieldの生成 */ search = new TextField("", textFieldStyle); search.setMessageText("search song"); search.setTextFieldListener(new TextFieldListener() { public void keyTyped(TextField textField, char key) { if (key == '\n' || key == 13) { + // TODO 検索結果重複は除外 if (textField.getText().length() > 1) { SearchWordBar swb = new SearchWordBar(MusicSelector.this, textField.getText()); int count = swb.getChildren().length; @@ -303,14 +307,28 @@ public void keyTyped(TextField textField, char key) { bar.updateBar(null); textField.setText(""); textField.setMessageText(count + " song(s) found"); + textFieldStyle.messageFontColor = Color.valueOf("00c0c0"); } else { textField.setText(""); - textField.setMessageText("no song found"); + textField.setMessageText("no song found"); + textFieldStyle.messageFontColor = Color.DARK_GRAY; } } textField.getOnscreenKeyboard().show(false); stage.setKeyboardFocus(null); } + if(!searchfont.getData().hasGlyph(key)) { + FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter(); + parameter.size = 24; + parameter.characters += textField.getText() + key; + BitmapFont newsearchfont = generator.generateFont(parameter); + textFieldStyle.font = newsearchfont; + textFieldStyle.messageFont = newsearchfont; + searchfont.dispose(); + searchfont = newsearchfont; + textField.appendText(String.valueOf(key)); + } + } });