--***********************************************************
--**                   KI5 / bikinihorst                   **
--***********************************************************

require "Hooks/DAMN_EnterAnimations";

DAMN = DAMN or {};
MR2 = MR2 or {};

DAMN.EnterAnimations:registerVehicleScript("Base.87toyotaMR2", "low");
DAMN.EnterAnimations:registerVehicleScript("Base.87toyotaMR2c", "low");

require "Hooks/DAMN_VehicleMenu";

DAMN.VehicleMenu:registerConditionalSlice(function(radialMenu, playerObj, vehicle, vehicleScriptName)
    if vehicleScriptName == "Base.87toyotaMR2"
    then
        local part = vehicle:getPartById("DAMNSunRoof");

        if part and DAMN.Parts:partIsInstalled(part)
        then
            local door = part:getDoor();

            if door:isOpen()
            then
                radialMenu:addSlice(getText("IGUI_DAMN_close_sunroof"), getTexture("media/textures/Slice_MR2_roof.png"), function()
                    vehicle:playPartAnim(part, "Close");
                    door:setOpen(false);
                end);
            else
                radialMenu:addSlice(getText("IGUI_DAMN_open_sunroof"), getTexture("media/textures/Slice_MR2_roof.png"), function()
                    vehicle:playPartAnim(part, "Open");
                    door:setOpen(true);
                end);
            end
        end
    end
end, "toggle_MR2Sunroof");