Парсинг меню
This commit is contained in:
parent
444f22eccc
commit
7658d4bb68
@ -144,6 +144,8 @@ public final class Parser {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (match(token, TokenType.MENU)) return menu();
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(matchWithEffect())) return false;
|
if (!TextUtils.isEmpty(matchWithEffect())) return false;
|
||||||
|
|
||||||
position++;
|
position++;
|
||||||
@ -269,6 +271,31 @@ public final class Parser {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean menu() {
|
||||||
|
// menu: title?
|
||||||
|
consume(TokenType.COLON);
|
||||||
|
|
||||||
|
String title = null;
|
||||||
|
if (lookMatch(0, TokenType.TEXT) && !lookMatch(1, TokenType.COLON)) {
|
||||||
|
title = consume(TokenType.TEXT).getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ищем элементы выбора
|
||||||
|
final Menu menu = new Menu(title);
|
||||||
|
int pos = 0;
|
||||||
|
do {
|
||||||
|
if (lookMatch(pos, TokenType.EOF)) return false;
|
||||||
|
if (lookMatch(pos, TokenType.TEXT) && lookMatch(pos + 1, TokenType.COLON)) {
|
||||||
|
menu.addItem(get(pos).getText(), position + pos + 2);
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
pos++;
|
||||||
|
} while (!lookMatch(pos, TokenType.ENDMENU));
|
||||||
|
|
||||||
|
ViewActivity.getInstance().menu(menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private double consumeDouble() {
|
private double consumeDouble() {
|
||||||
return Double.parseDouble(consume(TokenType.NUMBER).getText());
|
return Double.parseDouble(consume(TokenType.NUMBER).getText());
|
||||||
|
@ -302,6 +302,16 @@ public final class ViewActivity extends Activity implements TouchGesture.OnTouch
|
|||||||
return new SpannableString(html ? Html.fromHtml(edited) : edited);
|
return new SpannableString(html ? Html.fromHtml(edited) : edited);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void menu(final Menu menu) {
|
||||||
|
Dialogs.with(this).showGameMenu(menu, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int item) {
|
||||||
|
dialog.dismiss();
|
||||||
|
Parser.getInstance().setPosition(menu.getPosition(item));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void music(String name, FadeInfo fade) {
|
public void music(String name, FadeInfo fade) {
|
||||||
try {
|
try {
|
||||||
stopMusic(fade);
|
stopMusic(fade);
|
||||||
|
Loading…
Reference in New Issue
Block a user