battlesystem: add special back button to get back in cursor mode

This commit is contained in:
Kazhnuz 2019-03-31 17:35:55 +02:00
parent 4b2a59b413
commit b25a1e380c
2 changed files with 20 additions and 1 deletions

View file

@ -6,6 +6,7 @@ local CharacterMenu = ListBox:extend()
local CharMenuWidget = Widget.Text:extend()
local SubMenuWidget = CharMenuWidget:extend()
local BackMenuWidget = CharMenuWidget:extend()
local MENUPOS_X1, MENUPOS_X2, MENUPOS_Y = 32, 32, 110
local MENU_WIDTH, MENU_ITEM_HEIGHT = 112, 17
@ -36,7 +37,7 @@ function MenuConstructor:buildBaseMenu(character)
SubMenuWidget(self.controller, "BaseMenu", "Objets", "ObjectMenu", character)
CharMenuWidget(self.controller, "BaseMenu", "Défendre", "", character)
CharMenuWidget(self.controller, "BaseMenu", "Fuite", "", character)
CharMenuWidget(self.controller, "BaseMenu", "Retour", "", character)
BackMenuWidget(self.controller, "BaseMenu", "Retour", character)
self.controller.menusystem.menus["BaseMenu"]:setCancelWidget()
end
@ -182,4 +183,16 @@ function SubMenuWidget:action()
self.scene.menusystem:switchMenu(self.newmenu)
end
-- Back Widget
function BackMenuWidget:new(scene, menu_name, label, character)
BackMenuWidget.super.new(self, scene, menu_name, "Retour", "", character)
end
function BackMenuWidget:action()
self.character:getBackSignal()
self.scene.menusystem:reset()
end
return MenuConstructor

View file

@ -132,4 +132,10 @@ function Character:getSignal(action_type, id)
end
end
function Character:getBackSignal()
self.currentAction = "selectDirection"
self.controller.cursor:set(self.x, self.y)
self:setAnimation("walk")
end
return Character