Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/heclak/community-a4e-c i…
Browse files Browse the repository at this point in the history
…nto develop
  • Loading branch information
callmepartario committed Sep 19, 2021
2 parents eab92aa + 9a9a767 commit ae280b7
Show file tree
Hide file tree
Showing 24 changed files with 1,536 additions and 36 deletions.
6 changes: 6 additions & 0 deletions A-4E-C/Cockpit/Scripts/EFM_Data_Bus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ local fm_acceleration_z = get_param_handle("FM_ACCELERATION_Z")

local fm_cas = get_param_handle("FM_CAS")

local fm_radar_disabled = get_param_handle("FM_RADAR_DISABLED")
local fm_wheel_brake_assist = get_param_handle("FM_WHEEL_BRAKE_ASSIST")

local tanks = {
Expand All @@ -96,6 +97,10 @@ local tanks = {
[3] = fm_r_tank_capacity,
}

function fm_setRadarDisabled(value)
fm_radar_disabled:set(value)
end

--Mask for tank states
function fm_setTankState(idx, value)
tanks[idx]:set(value)
Expand Down Expand Up @@ -366,6 +371,7 @@ function get_efm_data_bus()
efm_data_bus.fm_setGForce = fm_setGForce
efm_data_bus.fm_setTacanID = fm_setTacanID
efm_data_bus.fm_setTacanName = fm_setTacanName
efm_data_bus.fm_setRadarDisabled = fm_setRadarDisabled


efm_data_bus.fm_getGunsightAngle = fm_getGunsightAngle
Expand Down
5 changes: 3 additions & 2 deletions A-4E-C/Cockpit/Scripts/RADAR/Indicator/indication_page.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dofile(LockOn_Options.script_path.."RADAR/Indicator/definitions.lua")
dofile(LockOn_Options.script_path.."RADAR/Indicator/radar_display_settings.lua")


yscale=0.8527
Expand Down Expand Up @@ -81,7 +82,7 @@ function add_1000ft_profile_scribe(max_range_nm)
scribe.element_params = {"RADAR_PROFILE_SCRIBE_"..tostring(max_range_nm).."NM","RADAR_FILTER"}
scribe.controllers = {
{"opacity_using_parameter", 0},
{"change_color_when_parameter_equal_to_number", 1, 1, 0.02, 0.001, 0.0}, -- temporary, to be overridden in 2.1
{"change_color_when_parameter_equal_to_number", 1, 1, blob_color_filter[1], blob_color_filter[2], blob_color_filter[3]},
}
scribe.additive_alpha = true

Expand Down Expand Up @@ -135,7 +136,7 @@ for i=1,max_blobs do
{"move_up_down_using_parameter", 0, 0.0383},
{"move_left_right_using_parameter", 1, 0.0383},
{"opacity_using_parameter",2},
{"change_color_when_parameter_equal_to_number", 3, 1, 0.02, 0.001, 0.0}, -- temporary, to be overridden in 2.1
{"change_color_when_parameter_equal_to_number", 3, 1, blob_color_filter[1], blob_color_filter[2], blob_color_filter[3]},
}

radar_blob.use_mipfilter = true
Expand Down
14 changes: 14 additions & 0 deletions A-4E-C/Cockpit/Scripts/RADAR/Indicator/radar_display_settings.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function normalise(color)
t = {}
for i,v in ipairs(color) do
t[i] = v / 255.0
end

return t
end


-- Shared file between materials.lua and indication_page.lua

blob_color = {0, 255, 80, 200}
blob_color_filter = normalise({32, 2, 0})
38 changes: 37 additions & 1 deletion A-4E-C/Cockpit/Scripts/RADAR/apg53a.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ dofile(LockOn_Options.script_path.."utils.lua")
dofile(LockOn_Options.script_path.."Systems/radar_scope_api.lua")
dofile(LockOn_Options.script_path.."EFM_Data_Bus.lua")

local cpp_radar_disabled = not get_plugin_option_value("A-4E-C", "experimentalRadar", "local")

local dev = GetSelf()

local Terrain = require('terrain')
Expand Down Expand Up @@ -918,10 +920,38 @@ function apg53a_draw_a2g()
end
end


function check_disabled()
if cpp_radar_disabled then
efm_data_bus.fm_setRadarDisabled(1.0)
return false
else
efm_data_bus.fm_setRadarDisabled(0.0)
return true
end
end


function SetCommand(command,value)

--[[
if command == device_commands.radar_storage then
if value > 0.5 then
cpp_radar_disabled = true
check_disabled()
else
cpp_radar_disabled = false
check_disabled()
end
end
]]


--print_message_to_user(value)
if check_disabled() then
return
end


local mode_changed=false
if command == device_commands.radar_planprofile then
apg53a_planprofile = apg53a_planprofilelist[ value+1 ]
Expand Down Expand Up @@ -1313,6 +1343,12 @@ end

local elec_26=true
function update()

if check_disabled() then
return
end


if get_elec_26V_ac_ok() then
if not elec_26 then -- triggered on power restoration
change_state(apg53a_state, apg53a_state)
Expand Down
2 changes: 2 additions & 0 deletions A-4E-C/Cockpit/Scripts/Systems/sound_system.lua
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ function post_initialize()
Sound_Player(sndhost_cockpit, "Aircrafts/A-4E-C/a-4e_HydraulicsSpeedbrakeMove", "SND_CONT_HYD_MOV", SOUND_CONTINUOUS),
Sound_Player(sndhost_cockpit, "Aircrafts/A-4E-C/a-4e_HydraulicsSpeedbrakeStop", "SND_INST_HYD_STOP", SOUND_ONCE),

Sound_Player(sndhost_cockpit, "Aircrafts/A-4E-C/obsttone", "D_GLARE_OBST", SOUND_CONTINUOUS, nil, nil, nil, nil, "APG53_OBST_VOLUME")

}

-- initialise sounds
Expand Down
8 changes: 4 additions & 4 deletions A-4E-C/Cockpit/Scripts/clickabledata.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ elements["PNT_165"] = default_2_position_tumb("AFCS Stability Augmentation Switc
elements["PNT_166"] = default_2_position_tumb("AFCS Aileron Trim Switch (unimplemented)", devices.AFCS, device_commands.afcs_ail_trim,166, TOGGLECLICK_LEFT_AFT)

-- RADAR SCOPE #20
elements["PNT_400"] = default_axis_limited("Radar Storage", devices.RADAR, device_commands.radar_storage, 400, 0.0, 0.3, false, false, {-1,1})
elements["PNT_401"] = default_axis_limited("Radar Brilliance", devices.RADAR, device_commands.radar_brilliance, 401, 0.0, 0.3, false, false, {-1,1})
elements["PNT_402"] = default_axis_limited("Radar Detail", devices.RADAR, device_commands.radar_detail, 402, 0.0, 0.3, false, false, {-1,1})
elements["PNT_403"] = default_axis_limited("Radar Gain", devices.RADAR, device_commands.radar_gain, 403, 0.0, 0.3, false, false, {-1,1})
elements["PNT_400"] = default_axis_limited("Radar Storage", devices.RADAR, device_commands.radar_storage, 400, 0.0, 0.3, false, false, {0,1})
elements["PNT_401"] = default_axis_limited("Radar Brilliance", devices.RADAR, device_commands.radar_brilliance, 401, 0.0, 0.3, false, false, {0,1})
elements["PNT_402"] = default_axis_limited("Radar Detail", devices.RADAR, device_commands.radar_detail, 402, 0.0, 0.3, false, false, {0,1})
elements["PNT_403"] = default_axis_limited("Radar Gain", devices.RADAR, device_commands.radar_gain, 403, 0.0, 0.05, false, false, {0,1})
elements["PNT_404"] = default_axis_limited("Radar Reticle", devices.RADAR, device_commands.radar_reticle, 404, 0.0, 0.3, false, false, {-1,1})
elements["PNT_405"] = default_2_position_tumb("Radar Filter Plate", devices.RADAR, device_commands.radar_filter, 405)
elements["PNT_405"].animated = {true, true}
Expand Down
3 changes: 2 additions & 1 deletion A-4E-C/Cockpit/Scripts/materials.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
dofile(LockOn_Options.script_path.."fonts.lua")
dofile(LockOn_Options.common_script_path.."Fonts/fonts_cmn.lua")
dofile(LockOn_Options.script_path.."RADAR/Indicator/radar_display_settings.lua")

-------MATERIALS-------
materials = {}
Expand All @@ -8,7 +9,7 @@ materials["DBG_BLACK"] = {0, 0, 0, 100}
materials["DBG_GREEN"] = {0, 80, 0, 255}
materials["DBG_RED"] = {255, 0, 0, 100}
materials["DBG_CLEAR"] = {0, 0, 0, 0}
materials["BLOB_COLOR"] = {0, 255, 0, 255} -- temporary, to be overridden in 2.1
materials["BLOB_COLOR"] = blob_color
materials["RADAR_FOV"] = {17, 80, 7, 0}
materials["RADAR_GRID"] = {0, 96, 48, 192}
materials["RADAR_SCRIBE"] = {0, 192, 0, 128} -- temporary, to be overridden in 2.1
Expand Down
12 changes: 11 additions & 1 deletion A-4E-C/Cockpit/Scripts/sound_class.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ SOUND_ONCE = 2
SOUND_ALWAYS = 3
SOUND_ALWAYS_CONTROLLED = 4

function Sound_Player.new(sndhost, sound_file, param, type, min_speed, max_speed, factor, fade)
function Sound_Player.new(sndhost, sound_file, param, type, min_speed, max_speed, factor, fade, volume_param)
local self = setmetatable({}, Sound_Player)
self.sound = sndhost:create_sound(sound_file)
self.type = type or SOUND_ONCE
Expand All @@ -28,6 +28,7 @@ function Sound_Player.new(sndhost, sound_file, param, type, min_speed, max_speed
self.fade = fade or 0.0
self.volume = 0.0
self.airspeed_param = get_param_handle("FM_AIRSPEED")
self.volume_param = volume_param

--self.update_fnc = nil

Expand Down Expand Up @@ -69,6 +70,11 @@ function Sound_Player:updateOnce()
self.played = false
end
end

if self.volume_param ~= nil then
self.sound:update(nil, self.volume_param:get(), nil)
end

end

function Sound_Player:updateContinuous()
Expand All @@ -82,6 +88,10 @@ function Sound_Player:updateContinuous()
self.sound:stop()
self.played = false
end

if self.volume_param ~= nil then
self.sound:update(nil, self.volume_param:get(), nil)
end
end

function Sound_Player:updateAlways()
Expand Down
2 changes: 1 addition & 1 deletion A-4E-C/ExternalFM/FM/Engine2.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define ENGINE_2_H
//=========================================================================//
//
// FILE NAME : Engine2.cpp
// FILE NAME : Engine2.h
// AUTHOR : Joshua Nelson
// DATE : October 2020
//
Expand Down
8 changes: 7 additions & 1 deletion A-4E-C/ExternalFM/FM/FM.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,13 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;ED_FM_TEMPLATE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>CockpitBase.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>%(SolutionDir)/include/Cockpit;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(SolutionDir)include\Cockpit;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
Expand Down Expand Up @@ -191,6 +192,8 @@
<ClInclude Include="LERX.h" />
<ClInclude Include="LuaVM.h" />
<ClInclude Include="Maths.h" />
<ClInclude Include="Radar.h" />
<ClInclude Include="RadarScope.h" />
<ClInclude Include="Radio.h" />
<ClInclude Include="Scooter.h" />
<ClInclude Include="ED_FM_API.h" />
Expand All @@ -203,6 +206,7 @@
<ClInclude Include="Tacan.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="Timer.h" />
<ClInclude Include="Units.h" />
<ClInclude Include="Vec3.h" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -235,6 +239,8 @@
<ClCompile Include="Input.cpp" />
<ClCompile Include="LuaVM.cpp" />
<ClCompile Include="Maths.cpp" />
<ClCompile Include="Radar.cpp" />
<ClCompile Include="RadarScope.cpp" />
<ClCompile Include="Radio.cpp" />
<ClCompile Include="Safe.cpp" />
<ClCompile Include="Shake.cpp" />
Expand Down
4 changes: 2 additions & 2 deletions A-4E-C/ExternalFM/FM/FuelSystem2.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class FuelSystem2 : public BaseComponent
inline void setSelectedTank( Tank tank );
inline void setFuelDumping(bool dumping);

private:
public:

double m_fuel[NUMBER_OF_TANKS] = { 0.0, 0.0, 0.0, 0.0, 0.0 };
double m_fuelPrevious[NUMBER_OF_TANKS] = { 0.0, 0.0, 0.0, 0.0, 0.0 };
Expand All @@ -86,7 +86,7 @@ class FuelSystem2 : public BaseComponent
double m_fuelCapacity[NUMBER_OF_TANKS] = { 731.0, 1737.0, 0.0, 0.0, 0.0 }; //changed it to 1737 to match the values from the entry.
Vec3 m_fuelPos[NUMBER_OF_TANKS] = { Vec3(), Vec3(), Vec3(), Vec3(), Vec3() };

bool m_enginePump = true;
const bool m_enginePump = true;
bool m_boostPump = true;
bool m_boostPumpPressure = false;
bool m_externalTankPressure = true;
Expand Down
2 changes: 1 addition & 1 deletion A-4E-C/ExternalFM/FM/Hashes.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ static WCHAR* files[] = {
static BYTE hashes[][32] = {
{0x2d,0x02,0xa2,0xcf,0x76,0x4d,0x4c,0x59,0x85,0x35,0x1c,0x54,0xdf,0x58,0xc8,0x85,0x91,0x48,0xf0,0x5c},
{0x6e,0xb1,0x3b,0xcc,0x5e,0x6c,0x4f,0x7b,0xed,0x41,0xef,0x8a,0x77,0x1d,0x17,0xf2,0xc0,0xef,0x3a,0xb3},
{0xa8,0xf7,0x0b,0xa4,0xcf,0x94,0xeb,0x38,0x36,0x69,0x26,0x11,0x61,0x35,0xb3,0x07,0x0c,0x16,0x30,0x67},
{0x6c,0x1e,0x41,0xfa,0xc3,0x0a,0xb7,0x8a,0x36,0x2f,0xd1,0x3c,0xc1,0x97,0x04,0xc5,0x55,0x78,0x4a,0x18},
{0x76,0x0a,0x96,0x5c,0xff,0x3d,0x20,0x51,0xc0,0x2e,0x9a,0x79,0x72,0xe6,0x67,0x1b,0x20,0x5b,0x6e,0x92}
};

24 changes: 17 additions & 7 deletions A-4E-C/ExternalFM/FM/Interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class Interface
m_averageLoadFactor = m_api.pfn_ed_cockpit_get_parameter_handle( "SND_ALWS_DAMAGE_AIRFRAME_STRESS" );
m_engineStall = m_api.pfn_ed_cockpit_get_parameter_handle( "SND_INST_ENGINE_STALL" );

m_disableRadar = m_api.pfn_ed_cockpit_get_parameter_handle( "FM_RADAR_DISABLED" );
m_wheelBrakeAssist = m_api.pfn_ed_cockpit_get_parameter_handle( "FM_WHEEL_BRAKE_ASSIST" );

}
Expand Down Expand Up @@ -269,6 +270,11 @@ class Interface
//printf( "%s\n", buffer );
}

inline bool getRadarDisabled()
{
return getParamNumber( m_disableRadar ) > 0.5;
}

inline void setEngineStall( bool stall )
{
setParamNumber( m_engineStall, (double)stall );
Expand Down Expand Up @@ -609,23 +615,26 @@ class Interface
}

void* m_test = NULL;
private:
inline double getParamNumber(void* ptr) const

inline void setParamNumber( void* ptr, double number )
{
m_api.pfn_ed_cockpit_update_parameter_with_number( ptr, number );
}
inline double getParamNumber( void* ptr ) const
{
double result;
m_api.pfn_ed_cockpit_parameter_value_to_number(ptr, result, false);
m_api.pfn_ed_cockpit_parameter_value_to_number( ptr, result, false );
return result;
}

private:

inline void getParamString(void* ptr, char* buffer, unsigned int bufferSize) const
{
m_api.pfn_ed_cockpit_parameter_value_to_string(ptr, buffer, bufferSize);
}

inline void setParamNumber(void* ptr, double number)
{
m_api.pfn_ed_cockpit_update_parameter_with_number(ptr, number);
}


inline void setParamString(void* ptr, const char* string)
{
Expand Down Expand Up @@ -755,6 +764,7 @@ class Interface

void* m_engineStall = NULL;

void* m_disableRadar = NULL;
void* m_wheelBrakeAssist = NULL;
};

Expand Down
Loading

0 comments on commit ae280b7

Please sign in to comment.