Skip to content

Commit 41f7035

Browse files
committed
Updated for DCS 2.7.15.26783 Data.lua changes
1 parent 85d62b9 commit 41f7035

File tree

1 file changed

+23
-11
lines changed
  • DCS-Input-Command-Injector-Quaggles/DCS-Input-Command-Injector-Quaggles/Scripts/Input

1 file changed

+23
-11
lines changed

DCS-Input-Command-Injector-Quaggles/DCS-Input-Command-Injector-Quaggles/Scripts/Input/Data.lua

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ local U = require('me_utilities')
55
local Serializer = require('Serializer')
66
local textutil = require('textutil')
77
local i18n = require('i18n')
8+
local log = require('log')
89

910
local _ = i18n.ptranslate
1011

@@ -590,7 +591,7 @@ local default_assignments =
590591
},
591592
}
592593

593-
local function loadDeviceProfileFromFile(filename, deviceGenericName, folder)
594+
local function loadDeviceProfileFromFile(filename, deviceGenericName, folder,keep_G_untouched)
594595
local f, err = loadfile(filename)
595596
local result
596597

@@ -621,13 +622,21 @@ local function loadDeviceProfileFromFile(filename, deviceGenericName, folder)
621622

622623
-- deviceGenericName will be used for automatic combo selection
623624
if f then
625+
626+
-- cleanup cockpit devices variable [ACS-1111: FC3 kneeboard pages cannot be turned in some cases](https://jira.eagle.ru/browse/ACS-1111)
627+
local old_dev = _G.devices
628+
if not keep_G_untouched then
629+
_G.devices = nil
630+
end
631+
624632
printLog('File[' .. filename .. '] opened successfully!')
625633

626634
local noLocalize = function(s)
627635
return s
628636
end
629637

630638
local setupEnv = function(env)
639+
env.devices = nil
631640
env.folder = folder
632641
env.filename = filename
633642
env.deviceName = deviceGenericName
@@ -637,7 +646,7 @@ local function loadDeviceProfileFromFile(filename, deviceGenericName, folder)
637646
local old_filename = env.filename
638647
local old_folder = env.folder
639648
local fnew = folder_new or old_folder
640-
local res = loadDeviceProfileFromFile(filename,deviceGenericName,fnew)
649+
local res = loadDeviceProfileFromFile(filename,deviceGenericName,fnew,true)
641650

642651
env.filename = old_filename
643652
env.folder = old_folder
@@ -750,7 +759,7 @@ local function loadDeviceProfileFromFile(filename, deviceGenericName, folder)
750759
end
751760

752761
else
753-
print('ERROR:', res)
762+
log.error(res);
754763
end
755764

756765
insideLocalizationHintsFuncCounter_ = insideLocalizationHintsFuncCounter_ - 1
@@ -781,9 +790,12 @@ local function loadDeviceProfileFromFile(filename, deviceGenericName, folder)
781790
axisCommand.categoryHint = nonLocalized.axisCommands[i].categoryHint
782791
end
783792
end
784-
else
785-
-- это ошибка в скрипте! ее быть не должно!
786-
print('ERROR:', result)
793+
else -- это ошибка в скрипте! ее быть не должно!
794+
log.error(result);
795+
end
796+
797+
if not keep_G_untouched then
798+
_G.devices = old_dev
787799
end
788800
else
789801
printLog(err)
@@ -2320,7 +2332,7 @@ local function storeDeviceProfileDiffIntoFile_(filename, diff)
23202332
file:write('return diff')
23212333
file:close()
23222334
else
2323-
printLog(string.format('Cannot save profile into file[%s]! Error %s', filename, err))
2335+
log.error(string.format('Cannot save profile into file[%s]! Error %s', filename, err))
23242336
end
23252337
end
23262338

@@ -2427,7 +2439,7 @@ local function saveProfileModifiers_(profileName, folder)
24272439
file:write('return modifiers')
24282440
file:close()
24292441
else
2430-
printLog(string.format('Cannot save modifiers into file[%s]! Error %s', filename, err))
2442+
log.error(string.format('Cannot save modifiers into file[%s]! Error %s', filename, err))
24312443
end
24322444
end
24332445
end
@@ -2446,7 +2458,7 @@ local function saveDisabledDevices()
24462458
file:write('return disabled')
24472459
file:close()
24482460
else
2449-
printLog(string.format('Cannot save disabled devices into file[%s]! Error %s', filename, err))
2461+
log.error(string.format('Cannot save disabled devices into file[%s]! Error %s', filename, err))
24502462
end
24512463
end
24522464

@@ -2697,7 +2709,7 @@ local function saveFullDeviceProfile(profileName, deviceName, filename)
26972709
file:write('}')
26982710
file:close()
26992711
else
2700-
printLog(string.format('Cannot save profile into file[%s]! Error %s', filename, err))
2712+
log.error(string.format('Cannot save profile into file[%s]! Error %s', filename, err))
27012713
end
27022714
end
27032715

@@ -2838,4 +2850,4 @@ return {
28382850
getUiProfileName = getUiProfileName,
28392851
setDeviceDisabled = setDeviceDisabled,
28402852
getDeviceDisabled = getDeviceDisabled,
2841-
}
2853+
}

0 commit comments

Comments
 (0)