Skip to content

Commit

Permalink
Music Select : support Japanese word input on search text field (in
Browse files Browse the repository at this point in the history
progress)
  • Loading branch information
exch-bms2 committed Sep 29, 2016
1 parent 1c25239 commit d14eac5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
30 changes: 24 additions & 6 deletions src/bms/player/beatoraja/select/MusicSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -108,6 +110,7 @@ public class MusicSelector extends MainState {

private FreeTypeFontGenerator generator;
private BitmapFont titlefont;
private BitmapFont searchfont;

private TextureRegion banner;
private Bar bannerbar;
Expand Down Expand Up @@ -269,31 +272,32 @@ 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);
doption = new DetailOptionRenderer(config);

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;
Expand All @@ -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));
}

}

});
Expand Down

0 comments on commit d14eac5

Please sign in to comment.