コード例 #1
0
ファイル: GuiScreen.java プロジェクト: nocaremc/game
  @Override
  public void handleInput(IGuiMouseState gui) {
    if ((gui.getState() == ButtonState.CLICKED)) {
      // Associate lua action file for this guiscreen with the lua engine
      App.getLua().get("dofile").call(LuaValue.valueOf(resourcePath + "buttonActions.lua"));

      // The function we call for clicks, within lua fine
      LuaValue clickAction = App.getLua().get("returnClick");

      // Value we pass to lua function. Button ID in this case
      LuaValue returnValue = clickAction.call(LuaValue.valueOf(((GuiButton) gui).getID()));

      // Set the button's state to none/null so we don't grab it again
      ((GuiButton) gui).setState(ButtonState.NONE);

      // String value of returnValue
      String sReturnValue = returnValue.tojstring();

      // Have App send the command to the proper place
      App.delegateLuaActionResponse(sReturnValue);
    }
  }