Lua virtual replace (#7337)
This commit is contained in:
@@ -273,11 +273,6 @@ local function run(event)
|
||||
if event == nil then
|
||||
error("Cannot run as a model script!")
|
||||
return 2
|
||||
elseif event == EVT_PAGE_BREAK or event == EVT_PAGEDN_FIRST or event == EVT_SHIFT_BREAK then
|
||||
--selectPage(1)
|
||||
elseif event == EVT_PAGE_LONG or event == EVT_PAGEUP_FIRST or event == EVT_SHIFT_LONG then
|
||||
--killEvents(event);
|
||||
--selectPage(-1)
|
||||
end
|
||||
local result = pages[page](event)
|
||||
|
||||
|
||||
@@ -52,10 +52,10 @@ end
|
||||
|
||||
local function fieldIncDec(event, value, max, force)
|
||||
if edit or force==true then
|
||||
if event == EVT_PLUS_BREAK or event == EVT_ROT_LEFT then
|
||||
if event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
value = (value + max)
|
||||
dirty = true
|
||||
elseif event == EVT_MINUS_BREAK or event == EVT_ROT_RIGHT then
|
||||
elseif event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
value = (value + max + 2)
|
||||
dirty = true
|
||||
end
|
||||
@@ -66,12 +66,12 @@ end
|
||||
|
||||
local function valueIncDec(event, value, min, max)
|
||||
if edit then
|
||||
if event == EVT_PLUS_FIRST or event == EVT_PLUS_REPT or event == EVT_ROT_RIGHT then
|
||||
if event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
if value < max then
|
||||
value = (value + 1)
|
||||
dirty = true
|
||||
end
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_MINUS_REPT or event == EVT_ROT_LEFT then
|
||||
elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
if value > min then
|
||||
value = (value - 1)
|
||||
dirty = true
|
||||
@@ -82,11 +82,11 @@ local function valueIncDec(event, value, min, max)
|
||||
end
|
||||
|
||||
local function navigate(event, fieldMax, prevPage, nextPage)
|
||||
if event == EVT_ENTER_BREAK then
|
||||
if event == EVT_VIRTUAL_ENTER then
|
||||
edit = not edit
|
||||
dirty = true
|
||||
elseif edit then
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
edit = false
|
||||
dirty = true
|
||||
elseif not dirty then
|
||||
@@ -120,7 +120,7 @@ local function getFieldFlags(position)
|
||||
end
|
||||
|
||||
local function channelIncDec(event, value)
|
||||
if not edit and event==EVT_MENU_BREAK then
|
||||
if not edit and event == EVT_VIRTUAL_MENU then
|
||||
servoPage = value
|
||||
dirty = true
|
||||
else
|
||||
@@ -284,7 +284,7 @@ local function servoMenu(event)
|
||||
limits.revert = fieldIncDec(event, limits.revert, 1)
|
||||
end
|
||||
model.setOutput(servoPage, limits)
|
||||
elseif event == EVT_EXIT_BREAK then
|
||||
elseif event == EVT_VIRTUAL_EXIT then
|
||||
servoPage = nil
|
||||
dirty = true
|
||||
end
|
||||
@@ -357,9 +357,9 @@ local function confirmationMenu(event)
|
||||
|
||||
navigate(event, fieldsMax, RUDDER_PAGE, page)
|
||||
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
return 2
|
||||
elseif event == EVT_ENTER_LONG then
|
||||
elseif event == EVT_VIRTUAL_ENTER_LONG then
|
||||
killEvents(event)
|
||||
applySettings()
|
||||
return 2
|
||||
|
||||
@@ -57,10 +57,10 @@ end
|
||||
|
||||
local function fieldIncDec(event, value, max, force)
|
||||
if edit or force==true then
|
||||
if event == EVT_PLUS_BREAK or event == EVT_ROT_LEFT then
|
||||
if event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
value = (value + max)
|
||||
dirty = true
|
||||
elseif event == EVT_MINUS_BREAK or event == EVT_ROT_RIGHT then
|
||||
elseif event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
value = (value + max + 2)
|
||||
dirty = true
|
||||
end
|
||||
@@ -71,12 +71,12 @@ end
|
||||
|
||||
local function valueIncDec(event, value, min, max)
|
||||
if edit then
|
||||
if event == EVT_PLUS_FIRST or event == EVT_PLUS_REPT or event == EVT_ROT_RIGHT then
|
||||
if event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
if value < max then
|
||||
value = (value + 1)
|
||||
dirty = true
|
||||
end
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_MINUS_REPT or event == EVT_ROT_LEFT then
|
||||
elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
if value > min then
|
||||
value = (value - 1)
|
||||
dirty = true
|
||||
@@ -87,11 +87,11 @@ local function valueIncDec(event, value, min, max)
|
||||
end
|
||||
|
||||
local function navigate(event, fieldMax, prevPage, nextPage)
|
||||
if event == EVT_ENTER_BREAK then
|
||||
if event == EVT_VIRTUAL_ENTER then
|
||||
edit = not edit
|
||||
dirty = true
|
||||
elseif edit then
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
edit = false
|
||||
dirty = true
|
||||
elseif not dirty then
|
||||
@@ -125,7 +125,7 @@ local function getFieldFlags(position)
|
||||
end
|
||||
|
||||
local function channelIncDec(event, value)
|
||||
if not edit and event==EVT_MENU_BREAK then
|
||||
if not edit and event == EVT_VIRTUAL_MENU then
|
||||
servoPage = value
|
||||
dirty = true
|
||||
else
|
||||
@@ -136,12 +136,12 @@ end
|
||||
|
||||
local function switchValueIncDec(event, value, min, max)
|
||||
if edit then
|
||||
if event == EVT_PLUS_FIRST or event == EVT_PLUS_REPT or event == EVT_ROT_RIGHT then
|
||||
if event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
if value < max then
|
||||
value = (value + 1)
|
||||
dirty = true
|
||||
end
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_MINUS_REPT or event == EVT_ROT_LEFT then
|
||||
elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
if value > min then
|
||||
value = (value - 1)
|
||||
dirty = true
|
||||
@@ -152,7 +152,7 @@ local function switchValueIncDec(event, value, min, max)
|
||||
end
|
||||
|
||||
local function switchIncDec(event, value)
|
||||
if not edit and event==EVT_MENU_BREAK then
|
||||
if not edit and event == EVT_VIRTUAL_MENU then
|
||||
servoPage = value
|
||||
dirty = true
|
||||
else
|
||||
@@ -415,9 +415,9 @@ local function confirmationMenu(event)
|
||||
|
||||
navigate(event, fieldsMax, BEEPER_PAGE, page)
|
||||
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
return 2
|
||||
elseif event == EVT_ENTER_LONG then
|
||||
elseif event == EVT_VIRTUAL_ENTER_LONG then
|
||||
killEvents(event)
|
||||
applySettings()
|
||||
return 2
|
||||
|
||||
@@ -62,10 +62,10 @@ end
|
||||
|
||||
local function fieldIncDec(event, value, max, force)
|
||||
if edit or force==true then
|
||||
if event == EVT_PLUS_BREAK or event == EVT_ROT_LEFT then
|
||||
if event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
value = (value + max)
|
||||
dirty = true
|
||||
elseif event == EVT_MINUS_BREAK or event == EVT_ROT_RIGHT then
|
||||
elseif event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
value = (value + max + 2)
|
||||
dirty = true
|
||||
end
|
||||
@@ -76,12 +76,12 @@ end
|
||||
|
||||
local function valueIncDec(event, value, min, max)
|
||||
if edit then
|
||||
if event == EVT_PLUS_FIRST or event == EVT_PLUS_REPT or event == EVT_ROT_RIGHT then
|
||||
if event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
if value < max then
|
||||
value = (value + 1)
|
||||
dirty = true
|
||||
end
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_MINUS_REPT or event == EVT_ROT_LEFT then
|
||||
elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
if value > min then
|
||||
value = (value - 1)
|
||||
dirty = true
|
||||
@@ -92,11 +92,11 @@ local function valueIncDec(event, value, min, max)
|
||||
end
|
||||
|
||||
local function navigate(event, fieldMax, prevPage, nextPage)
|
||||
if event == EVT_ENTER_BREAK then
|
||||
if event == EVT_VIRTUAL_ENTER then
|
||||
edit = not edit
|
||||
dirty = true
|
||||
elseif edit then
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
edit = false
|
||||
dirty = true
|
||||
elseif not dirty then
|
||||
@@ -130,7 +130,7 @@ local function getFieldFlags(position)
|
||||
end
|
||||
|
||||
local function channelIncDec(event, value)
|
||||
if not edit and event==EVT_MENU_BREAK then
|
||||
if not edit and event == EVT_VIRTUAL_MENU then
|
||||
servoPage = value
|
||||
dirty = true
|
||||
else
|
||||
@@ -425,7 +425,7 @@ local function servoMenu(event)
|
||||
limits.revert = fieldIncDec(event, limits.revert, 1)
|
||||
end
|
||||
model.setOutput(servoPage, limits)
|
||||
elseif event == EVT_EXIT_BREAK then
|
||||
elseif event == EVT_VIRTUAL_EXIT then
|
||||
servoPage = nil
|
||||
dirty = true
|
||||
end
|
||||
@@ -550,9 +550,9 @@ local function confirmationMenu(event)
|
||||
|
||||
navigate(event, fieldsMax, TAIL_PAGE, page)
|
||||
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
return 2
|
||||
elseif event == EVT_ENTER_LONG then
|
||||
elseif event == EVT_VIRTUAL_ENTER_LONG then
|
||||
killEvents(event)
|
||||
applySettings()
|
||||
return 2
|
||||
|
||||
@@ -25,10 +25,10 @@ local MODELTYPE_QUAD = 2
|
||||
|
||||
-- Common functions
|
||||
local function fieldIncDec(event, value, max)
|
||||
if event == EVT_PLUS_BREAK or event == EVT_ROT_LEFT or event == EVT_PLUS_REPT then
|
||||
if event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
value = (value + max)
|
||||
dirty = true
|
||||
elseif event == EVT_MINUS_BREAK or event == EVT_ROT_RIGHT or event == EVT_MINUS_REPT then
|
||||
elseif event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
value = (value + max + 2)
|
||||
dirty = true
|
||||
end
|
||||
@@ -56,7 +56,7 @@ local function modelTypeMenu(event)
|
||||
drawModelChoiceMenu()
|
||||
dirty = false
|
||||
end
|
||||
if event == EVT_ENTER_BREAK then
|
||||
if event == EVT_VIRTUAL_ENTER then
|
||||
if modelType == MODELTYPE_PLANE then
|
||||
return "plane.lua"
|
||||
elseif modelType == MODELTYPE_DELTA then
|
||||
@@ -77,7 +77,7 @@ local function run(event)
|
||||
error("Cannot be run as a model script!")
|
||||
end
|
||||
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
return 2
|
||||
end
|
||||
return modelTypeMenu(event)
|
||||
|
||||
@@ -127,7 +127,7 @@ local function run(event)
|
||||
raise("Cannot be run as a model script!")
|
||||
end
|
||||
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
return 2
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user