Skip to content

Commit

Permalink
Release 1.0.5.2
Browse files Browse the repository at this point in the history
New HUD code and new Pulldown menu
Some bugfixes and improvements
  • Loading branch information
Stephan-S committed Sep 4, 2019
1 parent a481641 commit 3f0c2ff
Show file tree
Hide file tree
Showing 78 changed files with 1,476 additions and 1,032 deletions.
14 changes: 14 additions & 0 deletions FS19_AutoDrive/gui/AutoDriveGUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ function AutoDrive:loadGUI()
g_gui:loadGui(AutoDrive.directory .. "gui/enterDriverNameGUI.xml", "adEnterDriverNameGui", AutoDrive.gui.adEnterDriverNameGui);
AutoDrive.gui["adEnterTargetNameGui"] = adEnterTargetNameGui:new();
g_gui:loadGui(AutoDrive.directory .. "gui/enterTargetNameGUI.xml", "adEnterTargetNameGui", AutoDrive.gui.adEnterTargetNameGui);
AutoDrive.gui["adEnterGroupNameGui"] = adEnterGroupNameGui:new();
g_gui:loadGui(AutoDrive.directory .. "gui/enterGroupNameGui.xml", "adEnterGroupNameGui", AutoDrive.gui.adEnterGroupNameGui);


AutoDrive.gui["adSettingsPage"] = adSettingsPage:new();
Expand Down Expand Up @@ -49,4 +51,16 @@ function AutoDrive:onOpenEnterTargetName()
elseif g_gui.currentGui == nil then
g_gui:showGui("adEnterTargetNameGui")
end;
end;

function AutoDrive:onOpenEnterGroupName()
if g_dedicatedServerInfo ~= nil then
return;
end;

if AutoDrive.gui.adEnterGroupNameGui.isOpen then
AutoDrive.gui.adEnterGroupNameGui:onClickBack()
elseif g_gui.currentGui == nil then
g_gui:showGui("adEnterGroupNameGui")
end;
end;
72 changes: 72 additions & 0 deletions FS19_AutoDrive/gui/enterGroupNameGUI.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
--
-- AutoDrive Enter Group Name GUI
-- V1.0.0.0
--
-- @author Stephan Schlosser
-- @date 09/06/2019

adEnterGroupNameGui = {};

local adEnterGroupNameGui_mt = Class(adEnterGroupNameGui, ScreenElement);

function adEnterGroupNameGui:new(target, custom_mt)
local self = ScreenElement:new(target, adEnterGroupNameGui_mt);
self.returnScreenName = "";
self.textInputElement = nil;
return self;
end;

function adEnterGroupNameGui:onOpen()
adEnterGroupNameGui:superClass().onOpen(self);
FocusManager:setFocus(self.textInputElement);
self.textInputElement:setText("");
self.textInputElement:onFocusActivate()
end;

function adEnterGroupNameGui:onClickOk()
adEnterGroupNameGui:superClass().onClickOk(self);
local enteredName = self.textInputElement.text;

if enteredName:len() > 1 then
if AutoDrive.groups[enteredName] == nil then
AutoDrive.groupCounter = AutoDrive.groupCounter + 1;
AutoDrive.groups[enteredName] = AutoDrive.groupCounter;

for _,vehicle in pairs(g_currentMission.vehicles) do
if (vehicle.ad ~= nil) then
if vehicle.ad.groups[enteredName] == nil then
vehicle.ad.groups[enteredName] = true;
end;
end;
end;
AutoDrive.Hud.lastUIScale = 0;
end;
end;

self:onClickBack();
end;

function adEnterGroupNameGui:onClickResetButton()
self.textInputElement.text = "";
end;

function adEnterGroupNameGui:onClose()
adEnterGroupNameGui:superClass().onClose(self);
end;

function adEnterGroupNameGui:onClickBack()
adEnterGroupNameGui:superClass().onClickBack(self);
end;

function adEnterGroupNameGui:onCreateInputElement(element)
self.textInputElement = element;
element.text = "";
end;

function adEnterGroupNameGui:onEnterPressed()
--self:onClickOk();
end;

function adEnterGroupNameGui:onEscPressed()
--self:onClose()();
end;
14 changes: 14 additions & 0 deletions FS19_AutoDrive/gui/enterGroupNameGUI.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<GUI onOpen="onOpen" onClose="onClose" onCreate="onCreate">
<GuiElement type="bitmap" profile="uiFullInGameBackground" />
<GuiElement type="bitmap" profile="dialogBg" id="dialogElement">
<GuiElement type="textInput" profile="dialogTextInput" id="textInputElement" onCreate="onCreateInputElement" onEnterPressed="onEnterPressed" onEscPressed="onEscPressed" />

<!-- bottom "back" + "ok" -->
<GuiElement type="flowLayout" profile="buttonBoxDocked" id="buttonsPC">
<GuiElement type="button" profile="buttonBack" text="$l10n_button_back" onClick="onClickBack" id="backButton" />
<GuiElement type="button" profile="buttonOK" text="$l10n_button_ok" onClick="onClickOk" />
<GuiElement type="button" profile="buttonCancel" text="$l10n_button_reset" onClick="onClickResetButton" />
</GuiElement>
</GuiElement>
</GUI>
5 changes: 3 additions & 2 deletions FS19_AutoDrive/gui/enterTargetNameGUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ function adEnterTargetNameGui:onClickOk()
local node = createTransformGroup(enteredName);
setTranslation(node, AutoDrive.mapWayPoints[closest].x, AutoDrive.mapWayPoints[closest].y + 4 , AutoDrive.mapWayPoints[closest].z );

AutoDrive.mapMarker[AutoDrive.mapMarkerCounter] = {id=closest, name= enteredName, node=node};
AutoDrive.mapMarker[AutoDrive.mapMarkerCounter] = {id=closest, name= enteredName, node=node, group="All"};
AutoDrive:MarkChanged();


if g_server ~= nil then
AutoDrive:broadCastUpdateToClients();
Expand All @@ -52,8 +53,8 @@ function adEnterTargetNameGui:onClickOk()
end;
end;
end;


AutoDrive:notifyDestinationListeners();
end;
end;

Expand Down
1 change: 1 addition & 0 deletions FS19_AutoDrive/gui/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ function adSettings:onClickOK()
end;
end;

AutoDrive.Hud.lastUIScale = 0;
AutoDriveUpdateSettingsEvent:sendEvent();
self:onClickBack();
end;
Expand Down
12 changes: 6 additions & 6 deletions FS19_AutoDrive/gui/settingsPage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,28 +100,28 @@
<GuiElement type="text" profile="multiTextOptionSettingsText" />
<GuiElement type="text" profile="multiTextOptionSettingsTitle" />
<GuiElement type="bitmap" profile="multiTextOptionSettingsBg" />
</GuiElement>
<GuiElement type="multiTextOption" profile="multiTextOptionSettings" onCreate="onCreateAutoDriveSetting" name="allowConsoleStyle" toolTipElementId="ingameMenuHelpBoxText">
</GuiElement>
<GuiElement type="multiTextOption" profile="multiTextOptionSettings" onCreate="onCreateAutoDriveSetting" name="enableTrafficDetection" toolTipElementId="ingameMenuHelpBoxText">
<GuiElement type="button" profile="multiTextOptionSettingsLeft" />
<GuiElement type="button" profile="multiTextOptionSettingsRight" />
<GuiElement type="text" profile="multiTextOptionSettingsText" />
<GuiElement type="text" profile="multiTextOptionSettingsTitle" />
<GuiElement type="bitmap" profile="multiTextOptionSettingsBg" />
</GuiElement>
<GuiElement type="multiTextOption" profile="multiTextOptionSettings" onCreate="onCreateAutoDriveSetting" name="enableTrafficDetection" toolTipElementId="ingameMenuHelpBoxText">
<GuiElement type="multiTextOption" profile="multiTextOptionSettings" onCreate="onCreateAutoDriveSetting" name="refillSeedAndFertilizer" toolTipElementId="ingameMenuHelpBoxText">
<GuiElement type="button" profile="multiTextOptionSettingsLeft" />
<GuiElement type="button" profile="multiTextOptionSettingsRight" />
<GuiElement type="text" profile="multiTextOptionSettingsText" />
<GuiElement type="text" profile="multiTextOptionSettingsTitle" />
<GuiElement type="bitmap" profile="multiTextOptionSettingsBg" />
</GuiElement>
<GuiElement type="multiTextOption" profile="multiTextOptionSettings" onCreate="onCreateAutoDriveSetting" name="refillSeedAndFertilizer" toolTipElementId="ingameMenuHelpBoxText">
</GuiElement>
<GuiElement type="multiTextOption" profile="multiTextOptionSettings" onCreate="onCreateAutoDriveSetting" name="useFolders" toolTipElementId="ingameMenuHelpBoxText">
<GuiElement type="button" profile="multiTextOptionSettingsLeft" />
<GuiElement type="button" profile="multiTextOptionSettingsRight" />
<GuiElement type="text" profile="multiTextOptionSettingsText" />
<GuiElement type="text" profile="multiTextOptionSettingsTitle" />
<GuiElement type="bitmap" profile="multiTextOptionSettingsBg" />
</GuiElement>
</GuiElement>
</GuiElement>


Expand Down
2 changes: 1 addition & 1 deletion FS19_AutoDrive/modDesc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Créer, ajouter, modifier, supprimer vos routes ou points de destination à l'ai
]]>
</ru>
</description>
<version>1.0.5.1</version>
<version>1.0.5.2</version>
<multiplayer supported="true"/>
<iconFilename>store.dds</iconFilename>
<extraSourceFiles>
Expand Down
5 changes: 5 additions & 0 deletions FS19_AutoDrive/register.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
-- #############################################################################

source(Utils.getFilename("scripts/AutoDrive.lua", g_currentModDirectory))
source(Utils.getFilename("scripts/HudElements/GenericHudElement.lua", g_currentModDirectory))
source(Utils.getFilename("scripts/HudElements/HudButton.lua", g_currentModDirectory))
source(Utils.getFilename("scripts/HudElements/HudIcon.lua", g_currentModDirectory))
source(Utils.getFilename("scripts/HudElements/HudSpeedmeter.lua", g_currentModDirectory))
source(Utils.getFilename("scripts/HudElements/PullDownList.lua", g_currentModDirectory))
source(Utils.getFilename("scripts/AutoDriveHud.lua", g_currentModDirectory))
source(Utils.getFilename("scripts/Events/AutoDriveEventUtil.lua", AutoDrive.directory))
source(Utils.getFilename("scripts/Events/AutoDriveUpdateEvent.lua", AutoDrive.directory))
Expand Down
96 changes: 90 additions & 6 deletions FS19_AutoDrive/scripts/AutoDrive.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ AutoDrive.drawHeight = 0.3;
AutoDrive.MODE_DRIVETO = 1;
AutoDrive.MODE_PICKUPANDDELIVER = 2;
AutoDrive.MODE_DELIVERTO = 3;
AutoDrive.MODE_UNLOAD = 4;
AutoDrive.MODE_LOAD = 5;
AutoDrive.MODE_LOAD = 4;
AutoDrive.MODE_UNLOAD = 5;
AutoDrive.MODE_BGA = 6;

AutoDrive.WAYPOINTS_PER_PACKET = 25;
Expand Down Expand Up @@ -87,6 +87,7 @@ function AutoDrive:loadMap(name)
source(Utils.getFilename("scripts/AutoDriveSettings.lua", AutoDrive.directory))
source(Utils.getFilename("scripts/AutoDriveExternalInterface.lua", AutoDrive.directory))
source(Utils.getFilename("gui/enterDriverNameGUI.lua", AutoDrive.directory))
source(Utils.getFilename("gui/enterGroupNameGUI.lua", AutoDrive.directory))
source(Utils.getFilename("gui/enterTargetNameGUI.lua", AutoDrive.directory))
source(Utils.getFilename("gui/AutoDriveGUI.lua", AutoDrive.directory))
source(Utils.getFilename("gui/settingsPage.lua", AutoDrive.directory))
Expand All @@ -113,7 +114,9 @@ function AutoDrive:loadMap(name)
AutoDrive.mapWayPointsCounter = 0;
AutoDrive.mapMarker = {};
AutoDrive.mapMarkerCounter = 0;
AutoDrive.showMouse = false;
AutoDrive.showMouse = false;

AutoDrive.pullDownListExpanded = 0;

AutoDrive.lastSetSpeed = 50;

Expand Down Expand Up @@ -152,7 +155,8 @@ function AutoDrive:loadMap(name)
AutoDrive.highestIndex = 1;
end;

AutoDrive.waitingUnloadDrivers = {}
AutoDrive.waitingUnloadDrivers = {};
AutoDrive.destinationListeners = {};
end;

function AutoDrive:saveSavegame()
Expand All @@ -174,6 +178,7 @@ function init(self)

self.ad.isActive = false;
self.ad.isStopping = false;
self.ad.isStoppingWithError = false;
self.ad.drivingForward = true;
self.ad.targetX = 0;
self.ad.targetZ = 0;
Expand Down Expand Up @@ -346,6 +351,15 @@ function init(self)
self.bga.isActive = false;
end;
self.ad.noMovementTimer = AutoDriveTON:new();

if self.ad.groups == nil then
self.ad.groups = {};
end;
for groupName, groupIds in pairs(AutoDrive.groups) do
if self.ad.groups[groupName] == nil then
self.ad.groups[groupName] = true;
end;
end;
end;

function AutoDrive:onLeaveVehicle()
Expand All @@ -355,6 +369,7 @@ function AutoDrive:onLeaveVehicle()
AutoDrive:onToggleMouse(self);
end;
self.ad.showingHud = storedshowingHud
AutoDrive.Hud:closeAllPullDownLists(self);
end;

function AutoDrive:onToggleMouse(vehicle)
Expand Down Expand Up @@ -514,8 +529,6 @@ function AutoDrive:onDrawControlledVehicle(vehicle)
if AutoDrive.Hud ~= nil then
if AutoDrive.Hud.showHud == true then
AutoDrive.Hud:drawHud(vehicle);
else
AutoDrive.Hud:drawMinimalHud(vehicle);
end;
end;
end;
Expand Down Expand Up @@ -679,6 +692,23 @@ function AutoDrive:onPostLoad(savegame)
self.ad.parkDestination = parkDestination;
end;

if self.ad.groups == nil then
self.ad.groups = {};
end;
local groupString = getXMLString(xmlFile, key.."#groups");
if groupString ~= nil then
local groupTable = groupString:split(";");
local temp = {}
for i, groupCombined in pairs(groupTable) do
local groupNameAndBool = groupCombined:split(",");
if tonumber(groupNameAndBool[2]) >= 1 then
self.ad.groups[groupNameAndBool[1]] = true;
else
self.ad.groups[groupNameAndBool[1]] = false;
end;
end;
end;

AutoDrive:readVehicleSettingsFromXML(self, xmlFile, key);
end
end;
Expand All @@ -699,6 +729,25 @@ function AutoDrive:saveToXMLFile(xmlFile, key)
setXMLInt(xmlFile, key.."#" .. settingName, self.ad.settings[settingName].current);
end;
end;

if self.ad.groups ~= nil then
local combinedString = "";
for groupName, groupEntries in pairs(AutoDrive.groups) do
for myGroupName, value in pairs(self.ad.groups) do
if groupName == myGroupName then
if string.len(combinedString) > 0 then
combinedString = combinedString .. ";";
end;
if value == true then
combinedString = combinedString .. myGroupName .. ",1";
else
combinedString = combinedString .. myGroupName .. ",0";
end;
end;
end;
end;
setXMLString(xmlFile, key.."#groups", combinedString);
end;
end

function AutoDrive.zoomSmoothly(self, superFunc, offset)
Expand All @@ -707,6 +756,41 @@ function AutoDrive.zoomSmoothly(self, superFunc, offset)
end
end

function AutoDrive:removeGroup(groupNameToDelete)
if groupNameToDelete:len() > 1 then
local deletedID = math.huge;
for groupName, groupID in pairs(AutoDrive.groups) do
if groupName == groupNameToDelete then
deletedID = groupID;
AutoDrive.groups[groupName] = nil;

for _,vehicle in pairs(g_currentMission.vehicles) do
if (vehicle.ad ~= nil) then
if vehicle.ad.groups[groupName] ~= nil then
vehicle.ad.groups[groupName] = nil;
end;
end;
end;

for markerID, marker in pairs(AutoDrive.mapMarker) do
if AutoDrive.mapMarker[markerID].group == groupName then
AutoDrive.mapMarker[markerID].group = "All";
end;
end;
end;
end;

for groupName, groupID in pairs(AutoDrive.groups) do
if deletedID <= groupID then
groupID = groupID - 1;
AutoDrive.groups[groupName] = groupID;
end;
end;
AutoDrive.Hud.lastUIScale = 0;
AutoDrive.groupCounter = AutoDrive.groupCounter - 1;
end;
end;

function normalizeAngle(inputAngle)
if inputAngle > (2*math.pi) then
inputAngle = inputAngle - (2*math.pi);
Expand Down
Loading

0 comments on commit 3f0c2ff

Please sign in to comment.