28 lines
1.0 KiB
Lua
28 lines
1.0 KiB
Lua
local FieldCell = class("FieldCell", BaseCell)
|
|
|
|
function FieldCell:refresh(name, heroInfo, field, isString)
|
|
self.name = name
|
|
self.value = heroInfo[field]
|
|
self.field = field
|
|
self.isString = isString
|
|
|
|
local uiMap = self:getUIMap()
|
|
|
|
local inputField = uiMap["field_cell.InputField_1"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_INPUT_FIELD)
|
|
inputField.text = self.value
|
|
|
|
uiMap["field_cell.desc1"]:setText(name, uiMap["field_cell.desc1"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT))
|
|
uiMap["field_cell.InputField_1"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_INPUT_FIELD).text = self.value or GConst.EMPTY_STRING
|
|
uiMap["field_cell.InputField_1"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_INPUT_FIELD).enabled = field ~= "ishero"
|
|
end
|
|
|
|
function FieldCell:getKV()
|
|
local uiMap = self:getUIMap()
|
|
local value = uiMap["field_cell.InputField_1"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_INPUT_FIELD).text
|
|
if not self.isString then
|
|
value = tonumber(value)
|
|
end
|
|
return self.field, value
|
|
end
|
|
|
|
return FieldCell |