Skip to content

Commit a412649

Browse files
authored
6-2024-01-11-2049 error running lua method update (#7)
* cleaned code * new version update * fixed a problem with data compatibility with previous settings
1 parent 0dbd21a commit a412649

File tree

5 files changed

+35
-74
lines changed

5 files changed

+35
-74
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 1.0.0.4
4+
5+
Fix:
6+
7+
- fixed a problem with data compatibility with previous settings
8+
39
## 1.0.0.3
410

511
Features:
@@ -22,4 +28,4 @@ Features:
2228

2329
Features:
2430

25-
- descVersion updated
31+
- descVersion updated

modDesc.xml

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8" standalone="no"?>
22
<modDesc descVersion="79">
33
<author>VertexFloat</author>
4-
<version>1.0.0.3</version>
4+
<version>1.0.0.4</version>
55
<title>
66
<en>Fov Control</en>
77
<de>Fov-Steuerung</de>
@@ -13,40 +13,32 @@
1313
1414
Opening Fov Controller - key combination "left shift + z" (default)
1515
16-
Changelog (1.0.0.3):
17-
- removed unnecessary code
18-
- descVersion updated
19-
- cleaned code
16+
Changelog (1.0.0.4):
17+
- fixed a problem with data compatibility with previous settings, from now on old data will be overwritten when saving new ones, unfortunately old data will be ignored when loading
2018
2119
For more information, full changelog, help, and report issues please visit <a href="https://github.com/4c65736975/fovControl">GitHub</a>.]]></en>
2220
<de><![CDATA[Dank dieser einfachen Modifikation können Sie das Sichtfeld für die aktuell verwendete Fahrzeugkamera einstellen.
2321
2422
Öffnen des Fov-Controllers - Tastenkombination "linke Umschalttaste + z" (Standard)
2523
26-
Änderungsprotokoll (1.0.0.3):
27-
- Unnötigen Code entfernt
28-
- descVersion aktualisiert
29-
- Bereinigter Code
24+
Änderungsprotokoll (1.0.0.4):
25+
- Ein Problem mit der Datenkompatibilität mit vorherigen Einstellungen wurde behoben. Von nun an werden alte Daten beim Speichern neuer Daten überschrieben. Leider werden alte Daten beim Laden ignoriert
3026
3127
Weitere Informationen, ein vollständiges Änderungsprotokoll, Hilfe und das Melden von Problemen finden Sie unter <a href="https://github.com/4c65736975/fovControl">GitHub</a>.]]></de>
3228
<fr><![CDATA[Grâce à cette simple modification, vous pouvez définir le champ de vision de la caméra du véhicule actuellement utilisée.
3329
3430
Ouverture du contrôleur FOV - combinaison de touches "shift gauche + z" (par défaut)
3531
36-
Journal des modifications (1.0.0.3):
37-
- supprimé le code inutile
38-
- descVersion mise à jour
39-
- code nettoyé
32+
Journal des modifications (1.0.0.4):
33+
- correction d'un problème de compatibilité des données avec les paramètres précédents, à partir de maintenant les anciennes données seront écrasées lors de l'enregistrement des nouvelles, malheureusement les anciennes données seront ignorées lors du chargement
4034
4135
Pour plus d'informations, le journal des modifications complet, l'aide et signaler des problèmes, veuillez visiter <a href="https://github.com/4c65736975/fovControl">GitHub</a>.]]></fr>
4236
<pl><![CDATA[Dzięki tej prostej modyfikacji, możesz ustawić pole widzenia dla aktualnie używanej kamery pojazdu.
4337
4438
Otworzenie kontrolera pola widzenia - kombinacja klawiszy "lewy shift + z" (domyślnie)
4539
46-
Dziennik zmian (1.0.0.3):
47-
- usunięto niepotrzebny kod
48-
- zaktualizowano descVersion
49-
- oczyszczono kod
40+
Dziennik zmian (1.0.0.4):
41+
- naprawiono problem ze zgodnością danych z poprzednimi ustawieniami, od teraz stare dane będą nadpisywane przy zapisywaniu nowych, niestety stare dane będą ignorowane przy ładowaniu
5042
5143
Po więcej informacji, pełny dziennik zmian, pomoc lub zgłoszenie błędu, odwiedź stronę <a href="https://github.com/4c65736975/fovControl">GitHub</a>.]]></pl>
5244
</description>
@@ -73,7 +65,7 @@ Po więcej informacji, pełny dziennik zmian, pomoc lub zgłoszenie błędu, odw
7365
<pl>Usuń tło</pl>
7466
</text>
7567
<text name="action_openFovControl">
76-
<en>Open fov control</en>
68+
<en>Open Fov control</en>
7769
<de>Öffnen Sie die Fov-Steuerung</de>
7870
<fr>Ouvrir le contrôle Fov</fr>
7971
<pl>Otwórz kontroler pola widzenia</pl>
@@ -82,7 +74,7 @@ Po więcej informacji, pełny dziennik zmian, pomoc lub zgłoszenie błędu, odw
8274
<en>Open Fov control</en>
8375
<de>Öffnen Sie die Fov-Steuerung</de>
8476
<fr>Ouvrir le contrôle Fov</fr>
85-
<pl>Otwórz kontrolę pola widzenia</pl>
77+
<pl>Otwórz kontroler pola widzenia</pl>
8678
</text>
8779
</l10n>
8880

@@ -93,7 +85,7 @@ Po więcej informacji, pełny dziennik zmian, pomoc lub zgłoszenie błędu, odw
9385
</inputBinding>
9486

9587
<actions>
96-
<action name="TOGGLE_FOV_CONTROL" category="VEHICLE" axisType="HALF"/>
88+
<action name="TOGGLE_FOV_CONTROL" category="VEHICLE" axisType="FULL"/>
9789
</actions>
9890

9991
<extraSourceFiles>

src/FovControl.lua

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- @author: 4c65736975, All Rights Reserved
2-
-- @version: 1.0.0.2, 20|09|2023
2+
-- @version: 1.0.0.3, 25|01|2024
33
-- @filename: FovControl.lua
44

55
-- Changelog (1.0.0.1):
@@ -8,6 +8,9 @@
88
-- Changelog (1.0.0.2):
99
-- removed unnecessary code
1010

11+
-- Changelog (1.0.0.3):
12+
-- fixed a problem with data compatibility with previous settings
13+
1114
FovControl = {
1215
MOD_DIRECTORY = g_currentModDirectory,
1316
MOD_SETTINGS_DIRECTORY = g_modSettingsDirectory
@@ -17,37 +20,25 @@ source(FovControl.MOD_DIRECTORY .. "src/gui/FovControlGui.lua")
1720

1821
local FovControl_mt = Class(FovControl)
1922

20-
---Creating FovControl instance
21-
---@param gui table gui object
22-
---@param l10n table l10n object
23-
---@param settingsModel table settingsModel object
24-
---@return table instance instance of object
2523
function FovControl.new(customMt, gui, l10n, settingsModel)
2624
local self = setmetatable({}, customMt or FovControl_mt)
2725

28-
self.gui = gui
29-
self.l10n = l10n
30-
self.settingsModel = settingsModel
3126
self.modifiedVehicles = {}
3227
self.fovControlGui = FovControlGui.new(nil, gui, l10n, settingsModel)
3328

3429
return self
3530
end
3631

37-
---Initializing FovControl
3832
function FovControl:initialize()
3933
self:loadVehicleCameraFovFromXMLFile()
4034

4135
self.fovControlGui:initialize()
4236
end
4337

44-
---Callback on map loading
45-
---@param filename string map file path
4638
function FovControl:loadMap(filename)
4739
self.fovControlGui:loadMap()
4840
end
4941

50-
---Loading vehicle camera fov from xml file
5142
function FovControl:loadVehicleCameraFovFromXMLFile()
5243
local xmlFile = XMLFile.loadIfExists("FovControlXML", FovControl.MOD_SETTINGS_DIRECTORY .. "fovControl.xml", "vehicles")
5344

@@ -61,9 +52,11 @@ function FovControl:loadVehicleCameraFovFromXMLFile()
6152
xmlFile:iterate(key .. ".cameras.camera", function (_, cameraKey)
6253
local cameraId = xmlFile:getInt(cameraKey .. "#id")
6354

64-
self.modifiedVehicles[xmlFilename][cameraId] = {
65-
fov = xmlFile:getFloat(cameraKey .. "#fov")
66-
}
55+
if cameraId then
56+
self.modifiedVehicles[xmlFilename][cameraId] = {
57+
fov = xmlFile:getFloat(cameraKey .. "#fov")
58+
}
59+
end
6760
end)
6861
end
6962
end)
@@ -72,7 +65,6 @@ function FovControl:loadVehicleCameraFovFromXMLFile()
7265
end
7366
end
7467

75-
---Saving vehicle camera fov to xml file
7668
function FovControl:saveVehicleCameraFovToXMLFile()
7769
local xmlFile = XMLFile.create("FovControlXML", FovControl.MOD_SETTINGS_DIRECTORY .. "fovControl.xml", "vehicles")
7870

@@ -96,7 +88,6 @@ function FovControl:saveVehicleCameraFovToXMLFile()
9688
end
9789
end
9890

99-
---Save vehicle camera fov
10091
function FovControl:saveVehicleCameraFov()
10192
local controlledVehicle = g_currentMission.controlledVehicle
10293

@@ -117,17 +108,10 @@ function FovControl:saveVehicleCameraFov()
117108
self:saveVehicleCameraFovToXMLFile()
118109
end
119110

120-
---ToggleFovControl action event callback
121-
---@param actionName string action name
122-
---@param inputValue integer input value
123-
---@param callbackState any callback state
124-
---@param isAnalog boolean is analog
125111
function FovControl:actionEventToggleFovControl(actionName, inputValue, callbackState, isAnalog)
126112
g_gui:showDialog("FovControlDialog")
127113
end
128114

129-
---Gets controlled vehicle active camera fov
130-
---@return float fov vehicle active camera fov
131115
function FovControl:getVehicleActiveCameraFov()
132116
local controlledVehicle = g_currentMission.controlledVehicle
133117

@@ -142,8 +126,6 @@ function FovControl:getVehicleActiveCameraFov()
142126
return nil
143127
end
144128

145-
---Gets controlled vehicle active camera default fov
146-
---@return float fov default fov of vehicle active camera or nil when not found
147129
function FovControl:getVehicleActiveCameraDefaultFov()
148130
local controlledVehicle = g_currentMission.controlledVehicle
149131

@@ -192,8 +174,11 @@ local function onPostLoad(self, savegame)
192174
if modifiedVehicle ~= nil then
193175
for i = 1, #spec.cameras do
194176
local camera = spec.cameras[i]
177+
local modifiedCamera = modifiedVehicle[i]
195178

196-
setFovY(camera.cameraNode, modifiedVehicle[i].fov)
179+
if modifiedCamera then
180+
setFovY(camera.cameraNode, modifiedCamera.fov)
181+
end
197182
end
198183
end
199184
end

src/gui/FovControlGui.lua

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,14 @@
77

88
FovControlGui = {
99
MOD_DIRECTORY = g_currentModDirectory,
10-
HUD_ATLAS_PATH = g_currentModDirectory .. "data/menu/hud/ui_elements.png"
10+
HUD_ATLAS_PATH = g_currentModDirectory .. "data/menu/hud/ui_elements.png",
11+
GUI_PROFILES_PATH = g_currentModDirectory .. "data/gui/guiProfiles.xml"
1112
}
1213

1314
source(FovControlGui.MOD_DIRECTORY .. "src/gui/dialogs/FovControlDialog.lua")
1415

1516
local FovControlGui_mt = Class(FovControlGui)
1617

17-
---Creating FovControlGui instance
18-
---@param gui table gui object
19-
---@param l10n table l10n object
20-
---@param settingsModel table settingsModel object
21-
---@return table instance instance of object
2218
function FovControlGui.new(customMt, gui, l10n, settingsModel)
2319
local self = setmetatable({}, customMt or FovControlGui_mt)
2420

@@ -28,9 +24,8 @@ function FovControlGui.new(customMt, gui, l10n, settingsModel)
2824
return self
2925
end
3026

31-
---Initializing FovControlGui
3227
function FovControlGui:initialize()
33-
self.gui:loadProfiles(FovControlGui.MOD_DIRECTORY .. "data/gui/guiProfiles.xml")
28+
self.gui:loadProfiles(FovControlGui.GUI_PROFILES_PATH)
3429

3530
for _, profile in pairs(self.gui.profiles) do
3631
for name, value in pairs(profile.values) do
@@ -41,8 +36,6 @@ function FovControlGui:initialize()
4136
end
4237
end
4338

44-
---Callback on map loading
45-
---@param filename string map file path
4639
function FovControlGui:loadMap(filename)
4740
self.gui:loadGui(Utils.getFilename("data/gui/dialogs/FovControlDialog.xml", FovControlGui.MOD_DIRECTORY), "FovControlDialog", self.fovControlDialog)
4841
end

src/gui/dialogs/FovControlDialog.lua

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ FovControlDialog = {
1818

1919
local FovControlDialog_mt = Class(FovControlDialog, MessageDialog)
2020

21-
---Creating FovControlDialog instance
22-
---@param l10n table l10n object
23-
---@param settingsModel table settingsModel object
24-
---@return table instance instance of object
2521
function FovControlDialog.new(target, customMt, l10n, settingsModel)
2622
local self = MessageDialog.new(target, customMt or FovControlDialog_mt)
2723

@@ -35,14 +31,12 @@ function FovControlDialog.new(target, customMt, l10n, settingsModel)
3531
return self
3632
end
3733

38-
---Callback on dialog open
3934
function FovControlDialog:onOpen()
4035
FovControlDialog:superClass().onOpen(self)
4136

4237
self:updateValues()
4338
end
4439

45-
---Updating dialog values
4640
function FovControlDialog:updateValues()
4741
self.fovElement:setTexts(self.settingsModel:getFovYTexts())
4842

@@ -52,8 +46,6 @@ function FovControlDialog:updateValues()
5246
self:setState(self.lastValidFovValue)
5347
end
5448

55-
---Set fov multi text option element state
56-
---@param state float camera fov
5749
function FovControlDialog:setState(state)
5850
if state ~= nil then
5951
if self.settingsModel.fovYToIndexMapping[state] ~= nil then
@@ -64,33 +56,27 @@ function FovControlDialog:setState(state)
6456
end
6557
end
6658

67-
---Saving current vehicle camera fov
6859
function FovControlDialog:save()
6960
g_fovControl:saveVehicleCameraFov()
7061
end
7162

72-
---Callback on click fov value
73-
---@param state integer fov multi text option element state
7463
function FovControlDialog:onClickFovValue(state)
7564
self.selectedFovValue = self.settingsModel.indexToFovYMapping[state]
7665

7766
g_currentMission:consoleCommandSetFOV(self.selectedFovValue)
7867
end
7968

80-
---Callback on click apply
8169
function FovControlDialog:onClickApply()
8270
self:save()
8371
self:close()
8472
end
8573

86-
---Callback on click remove background
8774
function FovControlDialog:onClickRemoveBackground()
8875
self.bgElement:setVisible(not self.bgElement.visible)
8976

9077
self.btnRemoveBgElement.text = not self.bgElement.visible and self.l10n:getText("button_addBackground"):upper() or self.l10n:getText("button_removeBackground"):upper()
9178
end
9279

93-
---Callback on click reset fov
9480
function FovControlDialog:onClickResetFov()
9581
local defaultFovValue = MathUtil.round(math.deg(g_fovControl:getVehicleActiveCameraDefaultFov()))
9682

@@ -103,7 +89,6 @@ function FovControlDialog:onClickResetFov()
10389
g_currentMission:consoleCommandSetFOV(defaultFovValue)
10490
end
10591

106-
---Callback on click back
10792
function FovControlDialog:onClickBack()
10893
g_currentMission:consoleCommandSetFOV(self.lastValidFovValue)
10994

0 commit comments

Comments
 (0)