Sprache Deutsch Language English

Script Dokumentation LS 2015 - MouseControlsVehicle (Patch 1.3)

Script Dokumentation Übersicht

scripts/vehicles/specializations/MouseControlsVehicle.lua

Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
1--
2-- MouseControlsVehicle
3-- This is the specialization for vehicles which can be controlled by the mouse
4--
5-- @author Stefan Geiger
6-- @date 18/08/09
7--
8-- Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved.
9
10MouseControlsVehicle = {};
11MouseControlsVehicle.COMBO_COMMAND_1 = 1;
12MouseControlsVehicle.COMBO_COMMAND_2 = 2;
13MouseControlsVehicle.COMBO_COMMAND_3 = 3;
14
15function MouseControlsVehicle.prerequisitesPresent(specializations)
16 return true;
17end
18
19function MouseControlsVehicle:load(xmlFile)
20
21 self.mouseControlsIcons = {};
22 local i=0;
23 while true do
24 local key = string.format("vehicle.mouseControls.mouseControl(%d)", i);
25 if not hasXMLProperty(xmlFile, key) then
26 break;
27 end
28
29 local iconFilename = getXMLString(xmlFile, key.."#iconFilename");
30 local axis = getXMLString(xmlFile, key.."#axis");
31 if iconFilename ~= nil and axis ~= nil then
32 if self.mouseControlsIcons[axis] == nil then
33 local entry = {};
34 iconFilename = Utils.getFilename(iconFilename, self.baseDirectory);
35 g_mouseControlsHelp:addIconFilename(iconFilename);
36 entry.iconFilename= iconFilename;
37 entry.foldMinLimit = Utils.getNoNil(getXMLFloat(xmlFile, key.."#foldMinLimit"), 0);
38 entry.foldMaxLimit = Utils.getNoNil(getXMLFloat(xmlFile, key.."#foldMaxLimit"), 1);
39
40 if GS_IS_CONSOLE_VERSION or g_settingsGamepadHelpEnabled then
41 local buttons = Utils.listToSet(InputBinding.actions[InputBinding[axis]].gamepadButtons);
42 if Utils.isSubset(Utils.listToSet(InputBinding.actions[InputBinding.CONSOLE_ALT_COMMAND3_BUTTON].gamepadButtons), buttons) then
43 entry.comboCommand = MouseControlsVehicle.COMBO_COMMAND_3;
44 elseif Utils.isSubset(Utils.listToSet(InputBinding.actions[InputBinding.CONSOLE_ALT_COMMAND2_BUTTON].gamepadButtons), buttons) then
45 entry.comboCommand = MouseControlsVehicle.COMBO_COMMAND_2;
46 elseif Utils.isSubset(Utils.listToSet(InputBinding.actions[InputBinding.CONSOLE_ALT_COMMAND_BUTTON].gamepadButtons), buttons) then
47 entry.comboCommand = MouseControlsVehicle.COMBO_COMMAND_1;
48 end;
49 end;
50 self.mouseControlsIcons[axis] = entry;
51 else
52 print("Warning: duplicate mouse control axis "..axis.." in "..self.configFileName);
53 end
54 end
55 i = i+1;
56 end
57end
58
59function MouseControlsVehicle:delete()
60end
61
62function MouseControlsVehicle:mouseEvent(posX, posY, isDown, isUp, button)
63end
64
65function MouseControlsVehicle:keyEvent(unicode, sym, modifier, isDown)
66end
67
68function MouseControlsVehicle:update(dt)
69
70 local hasConflict = false;
71 for axis,entry in pairs(self.mouseControlsIcons) do
72 hasConflict = self:hasInputConflictWithSelection();
73 if hasConflict then
74 break;
75 end;
76 end;
77
78 if self:getIsActiveForInput(false) and not hasConflict then --self:hasInputConflictWithSelection() then
79 local foldAnimTime = self.foldAnimTime;
80 local xFilename = nil;
81 local yFilename = nil;
82 local updateFileNames = false;
83 for axis,entry in pairs(self.mouseControlsIcons) do
84 local actionIndex = InputBinding[axis];
85 if actionIndex ~= nil and (foldAnimTime == nil or (foldAnimTime <= entry.foldMaxLimit and foldAnimTime >= entry.foldMinLimit)) then
86 if InputBinding.getIsInputMouseAxisTriggered(actionIndex) then
87 local allButtonsPressed = true;
88 for i,mouseButton in pairs(InputBinding.actions[actionIndex].mouseButtons) do
89 allButtonsPressed = allButtonsPressed and Input.isMouseButtonPressed(mouseButton);
90 end;
91 if allButtonsPressed then
92 updateFileNames = true;
93 if InputBinding.actions[actionIndex].mouseAxis == InputBinding.MOUSE_AXIS_X then
94 xFilename = entry.iconFilename;
95 elseif InputBinding.actions[actionIndex].mouseAxis == InputBinding.MOUSE_AXIS_Y then
96 yFilename = entry.iconFilename;
97 end;
98
99 end;
100 end;
101
102 if InputBinding.actions[actionIndex].mouseAxis ~= InputBinding.MOUSE_AXIS_NONE then
103 g_currentMission:setShowHasMouseButtonInput(true);
104 end;
105
106 if GS_IS_CONSOLE_VERSION or g_settingsGamepadHelpEnabled then
107 if InputBinding.getIsInputGamepadAxisTriggered(actionIndex) then
108 updateFileNames = true;
109 if InputBinding.actions[actionIndex].mouseAxis == InputBinding.MOUSE_AXIS_X then
110 xFilename = entry.iconFilename;
111 elseif InputBinding.actions[actionIndex].mouseAxis == InputBinding.MOUSE_AXIS_Y then
112 yFilename = entry.iconFilename;
113 end
114 end
115
116 -- on screen help in BaseMission needs to know which command buttons are available...
117 if entry.comboCommand ~= nil then
118 g_mouseControlsHelp.usedCommandButtons[entry.comboCommand] = true;
119 end;
120 end;
121
122 end;
123 end;
124 if updateFileNames then
125 g_mouseControlsHelp:setIconFilename(xFilename, yFilename);
126 end;
127 end;
128end;
129
130function MouseControlsVehicle:draw()
131end
132
133function MouseControlsVehicle:onLeave()
134end
135
136function MouseControlsVehicle.convertMouseAxisString(mouseAxis)
137 if mouseAxis ~= nil then
138 mouseAxis = mouseAxis:lower();
139 if mouseAxis == "x" then
140 return InputBinding.MOUSE_AXIS_X;
141 elseif mouseAxis == "y" then
142 return InputBinding.MOUSE_AXIS_Y;
143 end
144 end
145 return InputBinding.MOUSE_AXIS_NONE;
146end
Copyright (c) 2008-2015 GIANTS Software GmbH, Confidential, All Rights Reserved.
This document is to be published solely by ls-mods.de
Script Dokumentation Übersicht