Skip to content
Permalink
Browse files

Release 1.5

Added M-2000C
Fixed possible cause of panels not exporting when used with
DCS-SimpleRadio
  • Loading branch information...
Ciaran Fisher
Ciaran Fisher committed Jan 4, 2016
1 parent dc2eb1a commit 226b296e074bdf589f54dd76c90f9448055bfa73
@@ -25,7 +25,7 @@


<Button x:Name="button1" Content="Install / Update for DCS Release" HorizontalAlignment="Left" Margin="18,222,0,0" VerticalAlignment="Top" Width="185" Click="Install_Release"/>
<Button x:Name="button1_Copy" Content="Install / Update DCS Open Beta" HorizontalAlignment="Left" Margin="239,222,0,0" VerticalAlignment="Top" Width="185" Click="Install_Beta"/>
<Button x:Name="button1_Copy" Content="Install / Update DCS Open Alpha" HorizontalAlignment="Left" Margin="239,222,0,0" VerticalAlignment="Top" Width="185" Click="Install_Beta"/>
<GridSplitter x:Name="gridSplitter" HorizontalAlignment="Left" Height="40" Margin="221,217,0,0" VerticalAlignment="Top" Width="5"/>
<Button x:Name="button1_Copy2" Content="Remove DCS-SimpleRadio" HorizontalAlignment="Left" Margin="140,270,0,0" VerticalAlignment="Top" Width="170" Click="Remove_Plugin" />

@@ -27,7 +27,7 @@ public partial class MainWindow
{
const string REG_PATH = "HKEY_CURRENT_USER\\SOFTWARE\\DCS-SimpleRadio";

const string version = "1.2.4";
const string version = "1.3.0";

string currentPath;
string currentDirectory;
@@ -219,7 +219,7 @@ private void InstallSR(bool beta)

if (beta)
{
dcsPath = dcsPath + ".openbeta";
dcsPath = dcsPath + ".openalpha";
}

if (!Directory.Exists(dcsPath))
@@ -277,18 +277,22 @@ private void InstallScripts(string path)
{
String contents = File.ReadAllText(path + "\\Export.lua");

if (contents.Contains("Scripts\\DCS-SimpleRadio\\SimpleRadioInit.lua"))
if (contents.Contains("SimpleRadioInit.lua"))
{
write = false;

contents = contents.Replace("dofile(lfs.writedir()..[[Scripts\\DCS-SimpleRadio\\SimpleRadioInit.lua]])", "");
contents = contents.Replace("local dcsSr=require('lfs');dofile(dcsSr.writedir()..[[Scripts\\DCS-SimpleRadio\\SimpleRadioInit.lua]])", "");
contents = contents.Trim();

File.WriteAllText(path + "\\Export.lua", contents);
}
}

if (write)
{
StreamWriter writer = File.AppendText(path + "\\Export.lua");

writer.WriteLine("\n\n dofile(lfs.writedir()..[[Scripts\\DCS-SimpleRadio\\SimpleRadioInit.lua]])");
writer.WriteLine("\n local dcsSr=require('lfs');dofile(dcsSr.writedir()..[[Scripts\\DCS-SimpleRadio\\SimpleRadioInit.lua]])");
writer.Close();
}

@@ -369,7 +373,7 @@ private void UninstallSR()

string scriptsPath = dcsPath + "\\Scripts";

RemoveScripts(dcsPath + ".openbeta\\Scripts");
RemoveScripts(dcsPath + ".openalpha\\Scripts");
RemoveScripts(dcsPath + "\\Scripts");

RemovePlugin(teamspeakPlugins);
@@ -393,9 +397,11 @@ private void RemoveScripts(string path)
{
String contents = File.ReadAllText(path + "\\Export.lua");

if (contents.Contains("Scripts\\DCS-SimpleRadio\\SimpleRadioInit.lua"))
if (contents.Contains("SimpleRadioInit.lua"))
{
contents = contents.Replace("dofile(lfs.writedir()..[[Scripts\\DCS-SimpleRadio\\SimpleRadioInit.lua]])","");
contents = contents.Replace("local dcsSr=require('lfs');dofile(dcsSr.writedir()..[[Scripts\\DCS-SimpleRadio\\SimpleRadioInit.lua]])", "");
contents = contents.Trim();

File.WriteAllText(path + "\\Export.lua", contents);
}
@@ -41,7 +41,7 @@ static SimpleRadio::Plugin plugin;
namespace SimpleRadio
{
const char* Plugin::NAME = "DCS-SimpleRadio";
const char* Plugin::VERSION = "1.2.4";
const char* Plugin::VERSION = "1.3.0";
const char* Plugin::AUTHOR = "Ciribob - GitHub.com/ciribob";
const char* Plugin::DESCRIPTION = "DCS-SimpleRadio ";
const char* Plugin::COMMAND_KEYWORD = "sr";
BIN +0 Bytes (100%) Plugin/Plugin.rc
Binary file not shown.
@@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.4.0")]
[assembly: AssemblyFileVersion("1.2.4.0")]
[assembly: AssemblyVersion("1.3.0.0")]
[assembly: AssemblyFileVersion("1.3.0.0")]
@@ -1,4 +1,4 @@
-- Version 1.2.4
-- Version 1.3.0
SR = {}

SR.unicast = false -- if you've setup DCS Correctly and the plugin isn't talking to DCS,
@@ -24,35 +24,12 @@ SR.JSON = JSON

--dofile(lfs.writedir()..[[Scripts\DCS-SimpleRadio\SimpleRadio-IO.lua]])

UDPSendSocket = socket.udp()
UDPSendSocket:settimeout(0)
SR.UDPSendSocket = socket.udp()
SR.UDPSendSocket:settimeout(0)

-- Prev Export functions.
local _prevExport = {}
_prevExport.LuaExportStart = LuaExportStart
_prevExport.LuaExportStop = LuaExportStop
_prevExport.LuaExportBeforeNextFrame = LuaExportBeforeNextFrame
_prevExport.LuaExportAfterNextFrame = LuaExportAfterNextFrame

-- Lua Export Functions
LuaExportStart = function()

--socket.try(UDPSendSocket:sendto("Start\n\n", "239.255.50.10", 5050))

-- Chain previously-included export as necessary
if _prevExport.LuaExportStart then
_prevExport.LuaExportStart()
end
end

LuaExportStop = function()

--socket.try(UDPSendSocket:sendto("End\n\n", "239.255.50.10", 5050))
-- Chain previously-included export as necessary
if _prevExport.LuaExportStop then
_prevExport.LuaExportStop()
end
end
_prevExport.LuaExportActivityNextEvent = LuaExportActivityNextEvent

LuaExportActivityNextEvent = function(tCurrent)
local tNext = tCurrent + 0.3
@@ -113,6 +90,8 @@ LuaExportActivityNextEvent = function(tCurrent)
_update = SR.exportRadioC101(_update)
elseif _update.unit == "Hawk" then
_update = SR.exportRadioHawk(_update)
elseif _update.unit == "M-2000C" then
_update = SR.exportRadioM2000C(_update)
else
-- FC 3
_update.radios[1].name = "FC3 UHF"
@@ -139,9 +118,9 @@ LuaExportActivityNextEvent = function(tCurrent)
end

if SR.unicast then
socket.try(UDPSendSocket:sendto(SR.JSON:encode(_update).." \n", "127.0.0.1", 5056))
socket.try(SR.UDPSendSocket:sendto(SR.JSON:encode(_update).." \n", "127.0.0.1", 5056))
else
socket.try(UDPSendSocket:sendto(SR.JSON:encode(_update).." \n", "239.255.50.10", 5050))
socket.try(SR.UDPSendSocket:sendto(SR.JSON:encode(_update).." \n", "239.255.50.10", 5050))
end

else
@@ -163,9 +142,9 @@ LuaExportActivityNextEvent = function(tCurrent)
}

if SR.unicast then
socket.try(UDPSendSocket:sendto(SR.JSON:encode(_update).." \n", "127.0.0.1", 5056))
socket.try(SR.UDPSendSocket:sendto(SR.JSON:encode(_update).." \n", "127.0.0.1", 5056))
else
socket.try(UDPSendSocket:sendto(SR.JSON:encode(_update).." \n", "239.255.50.10", 5050))
socket.try(SR.UDPSendSocket:sendto(SR.JSON:encode(_update).." \n", "239.255.50.10", 5050))
end

end
@@ -176,10 +155,9 @@ LuaExportActivityNextEvent = function(tCurrent)
SR.log('ERROR: ' .. _result)
end


-- Call original function if it exists
if _prevExport.LuaExportAfterNextFrame then
_prevExport.LuaExportAfterNextFrame(tCurrent)
if _prevExport.LuaExportActivityNextEvent then
_prevExport.LuaExportActivityNextEvent(tCurrent)
end

return tNext
@@ -654,17 +632,44 @@ function SR.exportRadioHawk(_data)
return _data;
end

function SR.exportRadioM2000C(_data)

_data.radios[1].name = "UHF"
_data.radios[1].frequency = SR.getRadioFrequency(20)
_data.radios[1].modulation = 0
_data.radios[1].volume = SR.getRadioVolume(0, 706,{0.0,1.0},false)

_data.radios[2].name = "V/UHF"
_data.radios[2].frequency = SR.getRadioFrequency(19)
_data.radios[2].modulation = 0
_data.radios[2].volume = SR.getRadioVolume(0, 707,{0.0,1.0},false)

_data.radios[3].name = "N/A"
_data.radios[3].frequency = 1
_data.radios[3].modulation = 0
_data.radios[3].volume = 0

function LuaExportBeforeNextFrame()
local _switch = SR.getButtonPosition(700)

-- Chain previously-included export as
-- Source DCS-Bios
if _prevExport.LuaExportBeforeNextFrame then
_prevExport.LuaExportBeforeNextFrame()
if _switch == 1 then
_data.selected = 0
else
_data.selected = 1
end

--guard mode for V/UHF Radio
local uhfModeKnob = SR.getSelectorPosition(446,0.25) -- TODO!
if uhfModeKnob == 2 and _data.radios[2].frequency > 1000 then
_data.radios[2].secondaryFrequency = 243.0*1000000
end

return _data


end



function SR.getRadioVolume(_deviceId, _arg,_minMax,_invert)

local _device = GetDevice(_deviceId)

0 comments on commit 226b296

Please sign in to comment.
You can’t perform that action at this time.