--
-- PushBarGUI
-- V1.0.0.0
--
-- @author Stephan Schlosser
-- @date 11/01/2019

tcGui = {};

local tcGui_mt = Class(tcGui, ScreenElement);

function tcGui:new(target, custom_mt)
    local element = ScreenElement.new(target, tcGui_mt);
    element.returnScreenName = "";
    return element;	
end;

function tcGui:onOpen()
    tcGui:superClass().onOpen(self);
	FocusManager:setFocus(self.backButton);
end;

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

function tcGui:onClickBack()
    tcGui:superClass().onClickBack(self);
	PushBar:guiClosed();
end;

function tcGui:onClickOk()
    tcGui:superClass().onClickOk(self);
	PushBar:settingsFromGui(self.manualAttach:getState(), self.showHelp:getState(), self.showIds:getState(), self.IdsDistanceView:getState(), self.barDistanceView:getState(), self.steeringMode:getState(), self.autoOffVehicle:getState());
    self:onClickBack();
end;

function tcGui:onIngameMenuHelpTextChanged(element)
end;

function tcGui:onCreateTcGuiHeader(element)
    --element:setTextInternal("Push Bar With Hook", false, true)
    element:setTextInternal(g_i18n:getText('gui_tc_Setting'), false, true)
end;

function tcGui:onCreateManualAttach(element)
    self.manualAttach = element;
	element.labelElement.text = g_i18n:getText('gui_tc_manualAttach');
	element.toolTipText = g_i18n:getText('gui_tc_manualAttachToolTip');
    local values = {};

    for i = 1, #PushBar.booleansTexts, 1 do
        values[i] = PushBar.booleansTexts[i];
    end;
	
    element:setTexts(values);
end;
function tcGui:setManualAttach(index)
    self.manualAttach:setState(index, false);
end;

function tcGui:onCreateShowHelp(element)
    self.showHelp = element;
	element.labelElement.text = g_i18n:getText('gui_tc_showHelp');
	element.toolTipText = g_i18n:getText('gui_tc_showHelpToolTip');
    local values = {};

    for i = 1, #PushBar.booleansTexts, 1 do
        values[i] = PushBar.booleansTexts[i];
    end;	
	
    element:setTexts(values);
end;
function tcGui:setShowHelp(index)
    self.showHelp:setState(index, false);
end;

function tcGui:onCreateShowIds(element)
    self.showIds = element;
	element.labelElement.text = g_i18n:getText('gui_tc_showIds');
	element.toolTipText = g_i18n:getText('gui_tc_showIdsToolTip');
    local values = {};

    for i = 1, #PushBar.booleansTexts, 1 do
        values[i] = PushBar.booleansTexts[i];
    end;	
	
    element:setTexts(values);
end;
function tcGui:setShowIds(index)
    self.showIds:setState(index, false);
end;

function tcGui:onCreateIdsDistanceView(element)
    self.IdsDistanceView = element;
	element.labelElement.text = g_i18n:getText('gui_tc_IdsDistanceView');
	element.toolTipText = g_i18n:getText('gui_tc_IdsDistanceViewToolTip');
    local values = {};

    for i = 1, #PushBar.IdsDistanceViewsTexts, 1 do
        values[i] = PushBar.IdsDistanceViewsTexts[i];
    end;	
	
    element:setTexts(values);
end;
function tcGui:setIdsDistanceView(index)
    self.IdsDistanceView:setState(index, false);
end;

function tcGui:onCreateBarDistanceView(element)
    self.barDistanceView = element;
	element.labelElement.text = g_i18n:getText('gui_tc_barDistanceView');
	element.toolTipText = g_i18n:getText('gui_tc_barDistanceViewToolTip');
    local values = {};

    for i = 1, #PushBar.barDistanceViewsTexts, 1 do
        values[i] = PushBar.barDistanceViewsTexts[i];
    end;	
	
    element:setTexts(values);
end;
function tcGui:setBarDistanceView(index)
    self.barDistanceView:setState(index, false);
end

function tcGui:onCreateSteeringMode(element)
    self.steeringMode = element;
	element.labelElement.text = g_i18n:getText('gui_tc_steeringMode');
	element.toolTipText = g_i18n:getText('gui_tc_steeringModeToolTip');
	local values = {};

    for i = 1, #PushBar.steeringModesTexts, 1 do
        values[i] = PushBar.steeringModesTexts[i];
    end;	
	
    element:setTexts(values);
end;
function tcGui:setSteeringMode(index)
    self.steeringMode:setState(index, false);
end;

function tcGui:onCreateAutoOffVehicle(element)
	--DebugUtil.printTableRecursively(element,"-",0,1)
    self.autoOffVehicle = element;
	element.labelElement.text = g_i18n:getText('gui_tc_autoOffVehicle');
	element.toolTipText = g_i18n:getText('gui_tc_autoOffVehicleToolTip');
	--element.toolTipElementId = g_i18n:getText('gui_tc_autoOffVehicleToolTip');
    local values = {};

    for i = 1, #PushBar.booleansTexts, 1 do
        values[i] = PushBar.booleansTexts[i];
    end;	
	
    element:setTexts(values);
end;
function tcGui:setAutoOffVehicle(index)
    self.autoOffVehicle:setState(index, false);
end;
function tcGui:onClickShowIds(element)
	self.IdsDistanceView:setDisabled(not PushBar.booleans[self.showIds:getState()])
end
function tcGui:onClickResetButton()
    PushBar:settingsResetGui();
end;