本文整理汇总了Java中com.googlecode.lanterna.input.Key.Kind类的典型用法代码示例。如果您正苦于以下问题:Java Kind类的具体用法?Java Kind怎么用?Java Kind使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Kind类属于com.googlecode.lanterna.input.Key包,在下文中一共展示了Kind类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: show
import com.googlecode.lanterna.input.Key.Kind; //导入依赖的package包/类
@Override
public void show() {
_terminal.clearScreen();
while (true) {
Key key = _terminal.readInput();
if (_presenter.isGameOver())
return;
if(key != null && key.getCharacter() == Space){
isStoped = !isStoped;
}
if (key != null && key.getKind() == Kind.Escape){
if(isStoped)_presenter.saveState();
return;
}
if(!isStoped)
_presenter.tick(convertToDirection(key));
Sleep();
}
}
开发者ID:freeuni-sdp,项目名称:snake-15,代码行数:20,代码来源:TerminalMazeView.java
示例2: handleInput
import com.googlecode.lanterna.input.Key.Kind; //导入依赖的package包/类
public void handleInput(Key key) {
////// The part below handles everything controlled by hotkeys and should not be changed (unless a bug is found)
if (currentInputHandler == null){
return;
}
Key.Kind keyKind = key.getKind();
if (keyKind == Key.Kind.ArrowDown || keyKind == Key.Kind.ArrowLeft || keyKind == Key.Kind.ArrowRight || keyKind == Key.Kind.ArrowUp) {
currentInputHandler.arrowPressed(keyKind);
}
else if (keyKind == Key.Kind.Enter){
currentInputHandler.enterPressed();
}
else if (keyKind == Key.Kind.Backspace || keyKind == Key.Kind.Delete || keyKind == Key.Kind.End || keyKind == Key.Kind.Home || keyKind == Key.Kind.Insert || keyKind == Key.Kind.PageUp || keyKind == Key.Kind.PageDown || keyKind == Key.Kind.Tab || keyKind == Key.Kind.Escape){
currentInputHandler.specialKeyPressed(keyKind);
}
else if (keyKind == Kind.NormalKey){
currentInputHandler.normalKeyPressed(key.getCharacter());
}
else if (keyKind == Kind.F1 || keyKind == Kind.F2 || keyKind == Kind.F3 || keyKind == Kind.F4 || keyKind == Kind.F5 || keyKind == Kind.F6 || keyKind == Kind.F7 || keyKind == Kind.F8 || keyKind == Kind.F9 || keyKind == Kind.F10 || keyKind == Kind.F11 || keyKind == Kind.F12){
currentInputHandler.FbuttonPressed(keyKind);
}
}
开发者ID:Teascade,项目名称:Solid-Kingdom,代码行数:23,代码来源:InputHandlerManager.java
示例3: show
import com.googlecode.lanterna.input.Key.Kind; //导入依赖的package包/类
@Override
public void show() {
_terminal.clearScreen();
String[] names = { " Game Over ",
"Do you want to play again?", " Press Y to play again.",
" Press N or ESC to quit." };
TerminalSize screenSize = _terminal.getTerminalSize();
for (int i = 0; i < names.length; i++) {
_terminal.moveCursor(screenSize.getColumns() / 2 - 15,
screenSize.getRows() / 2 - 2 + i);
writeLine(String.format("%s", names[i]));
}
_terminal.flush();
while (true) {
Key p = _terminal.readInput();
if (p == null)
continue;
char ch = p.getCharacter();
if (p.getKind() == Kind.Escape || ch == 'n')
break;
if (ch == 'y') {
_continueGame = true;
break;
}
}
}
开发者ID:freeuni-sdp,项目名称:snake-15,代码行数:29,代码来源:TerminalGameOverView.java
示例4: testShowWithUserAsnwerNoEscape
import com.googlecode.lanterna.input.Key.Kind; //导入依赖的package包/类
@Test
public void testShowWithUserAsnwerNoEscape() {
// First this boolean should be false
assertFalse(gameOver.continueGameOrNot());
// Stub key to return no
Mockito.when(key.getKind()).thenReturn(Kind.Escape);
Mockito.when(terminal.readInput()).thenReturn(key);
gameOver.show();
// Second call of this boolean should be false
assertFalse(gameOver.continueGameOrNot());
}
开发者ID:freeuni-sdp,项目名称:snake-15,代码行数:12,代码来源:TerminalGameOverViewTest.java
示例5: testNewHighScore
import com.googlecode.lanterna.input.Key.Kind; //导入依赖的package包/类
@Test
public void testNewHighScore() {
TerminalHighScoreView v=new TerminalHighScoreView(presenter, terminal);
when(presenter.getScore()).thenReturn(100);
//return normal key kind twice to enter a name containing two characters then retrun Kind.Enter to break
when(key.getKind()).thenReturn(Kind.NormalKey).thenReturn(Kind.NormalKey).thenReturn(Kind.Enter);
when(key.getCharacter()).thenReturn('M').thenReturn('E');
//first return null to check the continue if, then returns key
when(terminal.readInput()).thenReturn(null).thenReturn(key);
when(presenter.checkNewScore(100)).thenReturn(true);
v.show();
Mockito.verify(terminal,atLeastOnce()).putCharacter('M');
Mockito.verify(terminal,atLeastOnce()).putCharacter('E');
}
开发者ID:freeuni-sdp,项目名称:snake-15,代码行数:15,代码来源:TerminalHighScoreViewTest.java
示例6: testConvertToDirectionDown
import com.googlecode.lanterna.input.Key.Kind; //导入依赖的package包/类
@Test
public void testConvertToDirectionDown() {
Mockito.when(presenter.isGameOver()).thenReturn(false).thenReturn(true);
Mockito.when(terminal.readInput()).thenReturn(key);
Mockito.when(key.getKind()).thenReturn(Kind.ArrowDown);
mazeView.show();
Mockito.verify(presenter).tick(DirectionKey.Down);
}
开发者ID:freeuni-sdp,项目名称:snake-15,代码行数:10,代码来源:TerminalMazeViewTest.java
示例7: testConvertToDirectionUp
import com.googlecode.lanterna.input.Key.Kind; //导入依赖的package包/类
@Test
public void testConvertToDirectionUp() {
Mockito.when(presenter.isGameOver()).thenReturn(false).thenReturn(true);
Mockito.when(terminal.readInput()).thenReturn(key);
Mockito.when(key.getKind()).thenReturn(Kind.ArrowUp);
mazeView.show();
Mockito.verify(presenter).tick(DirectionKey.Up);
}
开发者ID:freeuni-sdp,项目名称:snake-15,代码行数:10,代码来源:TerminalMazeViewTest.java
示例8: testConvertToDirectionLeft
import com.googlecode.lanterna.input.Key.Kind; //导入依赖的package包/类
@Test
public void testConvertToDirectionLeft() {
Mockito.when(presenter.isGameOver()).thenReturn(false).thenReturn(true);
Mockito.when(terminal.readInput()).thenReturn(key);
Mockito.when(key.getKind()).thenReturn(Kind.ArrowLeft);
mazeView.show();
Mockito.verify(presenter).tick(DirectionKey.Left);
}
开发者ID:freeuni-sdp,项目名称:snake-15,代码行数:10,代码来源:TerminalMazeViewTest.java
示例9: testConvertToDirectionRight
import com.googlecode.lanterna.input.Key.Kind; //导入依赖的package包/类
@Test
public void testConvertToDirectionRight() {
Mockito.when(presenter.isGameOver()).thenReturn(false).thenReturn(true);
Mockito.when(terminal.readInput()).thenReturn(key);
Mockito.when(key.getKind()).thenReturn(Kind.ArrowRight);
mazeView.show();
Mockito.verify(presenter).tick(DirectionKey.Right);
}
开发者ID:freeuni-sdp,项目名称:snake-15,代码行数:10,代码来源:TerminalMazeViewTest.java
示例10: testConvertToDirectionNone
import com.googlecode.lanterna.input.Key.Kind; //导入依赖的package包/类
@Test
public void testConvertToDirectionNone() {
Mockito.when(presenter.isGameOver()).thenReturn(false).thenReturn(true);
Mockito.when(terminal.readInput()).thenReturn(key);
Mockito.when(key.getKind()).thenReturn(Kind.Enter);
mazeView.show();
Mockito.verify(presenter).tick(DirectionKey.None);
}
开发者ID:freeuni-sdp,项目名称:snake-15,代码行数:11,代码来源:TerminalMazeViewTest.java
示例11: testResumeAfterStop
import com.googlecode.lanterna.input.Key.Kind; //导入依赖的package包/类
@Test
public void testResumeAfterStop(){
Mockito.when(presenter.isGameOver()).thenReturn(false).thenReturn(false).thenReturn(true);
Mockito.when(terminal.readInput()).thenReturn(key);
Mockito.when(key.getKind()).thenReturn(Kind.ArrowDown);
Mockito.when(key.getCharacter()).thenReturn(' ');
mazeView.show();
Mockito.verify(presenter, Mockito.times(1)).tick(DirectionKey.Down);
}
开发者ID:freeuni-sdp,项目名称:snake-15,代码行数:10,代码来源:TerminalMazeViewTest.java
示例12: testQuitStopped
import com.googlecode.lanterna.input.Key.Kind; //导入依赖的package包/类
@Test
public void testQuitStopped(){
Mockito.when(presenter.isGameOver()).thenReturn(false);
Mockito.when(terminal.readInput()).thenReturn(key);
//send stop character on first iteration and something different on second
Mockito.when(key.getCharacter()).thenReturn(' ').thenReturn('\0');
//send something different kind on first iteration and escape key on second
Mockito.when(key.getKind()).thenReturn(Kind.Enter).thenReturn(Kind.Escape);
mazeView.show();
//check if state is saved
Mockito.verify(presenter).saveState();
//check that loop iterated twice
Mockito.verify(terminal, Mockito.times(2)).readInput();
}
开发者ID:freeuni-sdp,项目名称:snake-15,代码行数:15,代码来源:TerminalMazeViewTest.java
示例13: testQuitNotStopped
import com.googlecode.lanterna.input.Key.Kind; //导入依赖的package包/类
@Test
public void testQuitNotStopped(){
Mockito.when(presenter.isGameOver()).thenReturn(false);
Mockito.when(terminal.readInput()).thenReturn(key);
Mockito.when(key.getKind()).thenReturn(Kind.Escape);
mazeView.show();
//check that loop iterated only once
Mockito.verify(terminal, Mockito.times(1)).readInput();
}
开发者ID:freeuni-sdp,项目名称:snake-15,代码行数:10,代码来源:TerminalMazeViewTest.java
示例14: addGeneralShortcuts
import com.googlecode.lanterna.input.Key.Kind; //导入依赖的package包/类
private void addGeneralShortcuts() {
this.addWindowListener(new WindowAdapter() {
@Override
public void onUnhandledKeyboardInteraction(Window window, Key key) {
if (key.getKind() == Kind.Escape)
close();
}
});
}
开发者ID:frincon,项目名称:openeos,代码行数:12,代码来源:UnoWindow.java
示例15: getActionForKey
import com.googlecode.lanterna.input.Key.Kind; //导入依赖的package包/类
@Override
public GameAction getActionForKey(Key k) {
if(k.getKind() == Kind.NormalKey && k.getCharacter() == ' ') {
return new GameAction(7,1);
}
else {
app.getLayers().pop();
Layer layerBelow = app.getLayers().peek();
app.getLayers().push(this);
return layerBelow.getActionForKey(k);
}
}
开发者ID:melloc,项目名称:roguelike,代码行数:13,代码来源:AnnounceLayer.java
示例16: handleGlobalKeyPressed
import com.googlecode.lanterna.input.Key.Kind; //导入依赖的package包/类
public boolean handleGlobalKeyPressed(final Window sender, final Key key)
{
if (key.getCharacter() == 'q' || key.getKind() == Kind.Escape)
{
shutdown();
return true;
}
else if (key.getCharacter() == '?')
{
helpPopup.show();
return true;
}
return false;
}
开发者ID:d0x,项目名称:nchadoop,代码行数:16,代码来源:Controller.java
示例17: keyboardInteraction
import com.googlecode.lanterna.input.Key.Kind; //导入依赖的package包/类
@Override
public Result keyboardInteraction(Key key)
{
final Displayable selectedItem = (Displayable) getSelectedItem();
switch (key.getKind())
{
case Enter:
case ArrowRight:
selectedItem.navigate();
return Result.EVENT_HANDLED;
case ArrowLeft:
selectedItem.navigateToParent();
return Result.EVENT_HANDLED;
default:
break;
}
switch (key.getCharacter())
{
case 'l':
return super.keyboardInteraction(new Key(Kind.ArrowRight));
case 'h':
return super.keyboardInteraction(new Key(Kind.ArrowLeft));
case 'k':
return super.keyboardInteraction(new Key(Kind.ArrowUp));
case 'j':
return super.keyboardInteraction(new Key(Kind.ArrowDown));
default:
break;
}
return super.keyboardInteraction(key);
}
开发者ID:d0x,项目名称:nchadoop,代码行数:41,代码来源:DirectoryListBox.java
示例18: arrowPressed
import com.googlecode.lanterna.input.Key.Kind; //导入依赖的package包/类
@Override
public void arrowPressed(Kind keykind) {
String direction = null;
if (keykind == Key.Kind.ArrowUp) {
direction = UP;
}else if (keykind == Key.Kind.ArrowDown) {
direction = DOWN;
}else if (keykind == Key.Kind.ArrowRight) {
direction = RIGHT;
}else if (keykind == Key.Kind.ArrowLeft) {
direction = LEFT;
}
currentTileSelection.move(direction);
}
开发者ID:Teascade,项目名称:Solid-Kingdom,代码行数:15,代码来源:TileSelectionInputHandler.java
示例19: prepare
import com.googlecode.lanterna.input.Key.Kind; //导入依赖的package包/类
public void prepare() {
ScreenWriter writer = new ScreenWriter(screen);
writer.drawString(0, offsetTop, "Please enter the initial values for the " + this.tapes.length + " tapes:");
writer.drawString(0, offsetTop + 1, "(Press enter for an empty tape)");
terminal.applyBackgroundColor(Color.WHITE);
terminal.applyForegroundColor(Color.BLACK);
this.screen.refresh();
for (int i = 0; i < tapes.length; i++) {
this.screen.putString(0, offsetTop + i + 2, String.format("Tape %d: ", i + 1), Color.WHITE, Color.BLACK);
this.screen.setCursorPosition(8, offsetTop + i + 2);
this.terminal.setCursorVisible(true);
this.screen.refresh();
Key key = null;
StringBuilder builder = new StringBuilder();
while(key == null) {
key = screen.readInput();
if(key == null)
continue;
if(key.getKind() == Kind.NormalKey) {
terminal.putCharacter(key.getCharacter());
builder.append(key.getCharacter());
}
/*
else if(key.getKind() == Kind.Backspace) {
terminal.putCharacter(key.getCharacter());
builder.delete(builder.length() - 2, 1);
}
*/
else if(key.getKind() == Kind.Enter) {
// Store value on tape
// Try to parse as integer
try {
Integer number = new Integer(builder.toString());
// Parse succeeded, treat as unary number
this.tapes[i].initializeAsUnary(number, unarySymbol);
}
catch(NumberFormatException ex) {
// Parse failed, treat a pure character input
if(builder.length() == 0) builder.append(Tape.BLANK);
this.tapes[i].initialize(builder.toString().toCharArray());
}
// Exit the while loop, go to the next tape
break;
}
key = null;
}
}
this.terminal.setCursorVisible(false);
this.screen.setCursorPosition(0, 0);
this.screen.refresh();
}
开发者ID:samfisch3r,项目名称:TuringMachine,代码行数:65,代码来源:TuringMachine.java
示例20: specialKeyPressed
import com.googlecode.lanterna.input.Key.Kind; //导入依赖的package包/类
@Override
public void specialKeyPressed(Kind keykind) {
if (keykind == Key.Kind.Escape) {
this.currentTileSelection.exit();
}
}
开发者ID:Teascade,项目名称:Solid-Kingdom,代码行数:7,代码来源:TileSelectionInputHandler.java
注:本文中的com.googlecode.lanterna.input.Key.Kind类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论