Skip to content

Instantly share code, notes, and snippets.

@peterix
Created October 25, 2016 16:58
Show Gist options
  • Save peterix/c9db1ade3fb197e923ac91d0e71ad90c to your computer and use it in GitHub Desktop.
Save peterix/c9db1ade3fb197e923ac91d0e71ad90c to your computer and use it in GitHub Desktop.
MCLauncher interface
var MCLauncher;
// if there's not a MCLauncher object, make a new one... an interface between js and native code
if (!MCLauncher)
MCLauncher = {};
// reassign all the interface functions anyway, no matter what
(
function()
{
MCLauncher.writePreferences = function(config)
{
native function WritePreferences(config);
return WritePreferences(config);
};
MCLauncher.readPreferences = function(callback)
{
native function ReadPreferences(callback);
return ReadPreferences(callback);
};
MCLauncher.startGame = function(token)
{
native function StartGame(token);
return StartGame(token);
};
MCLauncher.createGameInstance = function(settings)
{
native function CreateGameInstance(settings);
return CreateGameInstance(settings);
};
MCLauncher.setLogListener = function(id, callback)
{
native function SetLogListener(id, callback);
return SetLogListener(id, callback);
};
MCLauncher.removeLogListener = function(id)
{
native function RemoveLogListener(id);
return RemoveLogListener(id);
};
MCLauncher.getSystemInfo = function(callback)
{
native function GetSystemInfo(callback);
return GetSystemInfo(callback);
};
MCLauncher.setClipboard = function(text)
{
native function SetClipboard(text);
return SetClipboard(text);
};
MCLauncher.openDirectory = function(directory)
{
native function OpenDirectory(directory);
return OpenDirectory(directory);
};
MCLauncher.openFile = function(directory)
{
native function OpenFile(directory);
return OpenFile(directory);
};
MCLauncher.getFileInfo = function(file, callback)
{
native function GetFileInfo(file, callback);
return GetFileInfo(file, callback);
};
MCLauncher.openFileDialog = function(config)
{
nativefunction OpenFileDialog(config);
return OpenFileDialog(config);
};
MCLauncher.openLogWindow = function(token)
{
native function OpenLogWindow(token);
return OpenLogWindow(token);
};
MCLauncher.getCrashedInstances = function(callback)
{
native function GetCrashedInstances(callback);
return GetCrashedInstances(callback);
};
MCLauncher.searchPage = function(str, forward, matchCase, findNext)
{
native function SearchPage();
return SearchPage(str, forward, matchCase, findNext);
};
MCLauncher.stopSearch = function()
{
native function StopSearch();
return StopSearch();
};
MCLauncher.logEvent = function(event, properties, success, fail)
{
native function LogEvent(event, properties, success, fail);
return LogEvent(event, properties, success, fail);
};
MCLauncher.startHeartbeat = function()
{
native function StartHeartbeat();
return StartHeartbeat();
};
MCLauncher.disableAnalytics = function()
{
native function DisableAnalytics();
return DisableAnalytics();
};
MCLauncher.markInteractedWith = function()
{
native function MarkInteractedWith();
return MarkInteractedWith();
};
MCLauncher.sha1 = function(input)
{
native function SHA1(input);
return SHA1(input);
};
MCLauncher.extractFile = function(url, path, callback)
{
native function ExtractFile(url, path, callback);
return ExtractFile(url, path, callback);
};
}
)();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment