Advertisement
Guest User

OrangeGreenworks.js

a guest
Dec 15th, 2019
531
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*=============================================================================
  2.  * Orange - Greenworks
  3.  * By Hudell - www.hudell.com
  4.  * OrangeGreenworks.js
  5.  * Version: 1.2
  6.  * Free for commercial and non commercial use.
  7.  *=============================================================================*/
  8. /*:
  9.  * @plugindesc Steamworks Integration <OrangeGreenworks>
  10.  * @author Hudell
  11.  *
  12.  * @help
  13.  * ============================================================================
  14.  * Hudell's Plugins
  15.  * ============================================================================
  16.  *
  17.  * Check out my website to learn how to use this plugin:
  18.  * http://hudell.com/blog/orangegreenworks/
  19.  *
  20.  *=============================================================================*/
  21. var Imported = Imported || {};
  22. var Hudell = Hudell || {};
  23. Hudell.OrangeGreenworks = Hudell.OrangeGreenworks || {};
  24.  
  25. (function($) {
  26.   "use strict";
  27.  
  28.   $.getScreenName = function() {
  29.     return 'Play Test';
  30.   };
  31.  
  32.   $.getUILanguage = function() {
  33.     return 'english';
  34.   };
  35.  
  36.   $.getGameLanguage = function() {
  37.     return 'english';
  38.   };
  39.  
  40.   $.activateAchievement = function(achievementName) {
  41.     console.log('Activate achievement ', achievementName);
  42.   };
  43.  
  44.   $.getAchievement = function(achievementName) {
  45.     return false;
  46.   };
  47.  
  48.   $.clearAchievement = function(achievementName) {
  49.     console.log('Clear achievement ', achievementName);
  50.   };
  51.  
  52.   $.getNumberOfAchievements = function() {
  53.     return 0;
  54.   };
  55.  
  56.   $.isSteamRunning = function() {
  57.     return false;
  58.   };
  59.  
  60.   $.activateGameOverlay = function(option) {
  61.   };
  62.  
  63.   $.isGameOverlayEnabled = function() {
  64.     return false;
  65.   };
  66.  
  67.   $.activateGameOverlayToWebPage = function(url) {
  68.     console.log('Open URL');
  69.   };
  70.  
  71.   $.getDLCCount = function() {
  72.     return 0;
  73.   };
  74.  
  75.   $.isDLCInstalled = function(dlcAppId) {
  76.     return false;
  77.   };
  78.  
  79.   $.installDLC = function(dlcAppId) {
  80.   };
  81.  
  82.   $.uninstallDLC = function(dlcAppId) {
  83.   };
  84.  
  85.   $.getStatInt = function(name) {
  86.     return 0;
  87.   };
  88.  
  89.   $.getStatFloat = function(name) {
  90.     return 0;
  91.   };
  92.  
  93.   $.setStat = function(name, value) {
  94.     console.log('Change Stat', name, value);
  95.     return false;
  96.   };
  97.  
  98.   $.storeStats = function() {
  99.     console.log('Store Stats');
  100.     return false;
  101.   };
  102.  
  103.   $.isSubscribedApp = function(appId) {
  104.     return false;
  105.   };
  106.  
  107.   if (Utils.isNwjs()) {
  108.     $.initialized = false;
  109.  
  110.     try {
  111.       $.greenworks = require('./greenworks');
  112.     }
  113.     catch(e) {
  114.       $.greenworks = false;
  115.       console.log('Greenworks failed to load. Make sure you copied all files from the Steamworks SDK to the right folders;');
  116.       console.log('http://hudell.com/blog/orange-greenworks');
  117.       console.error(e);
  118.     }
  119.  
  120.     if (!!$.greenworks) {
  121.       $.initialized = $.greenworks.initAPI();
  122.  
  123.       if (!$.initialized) {
  124.         console.log('Greenworks failed to initialize.');
  125.         return;
  126.       }
  127.  
  128.       $.steamId = $.greenworks.getSteamId();
  129.       console.log('Steam User: ', $.steamId.screenName);
  130.  
  131.       $.getScreenName = function() {
  132.         return $.steamId.screenName;
  133.       };
  134.  
  135.       $.getUILanguage = function() {
  136.         return $.greenworks.getCurrentUILanguage();
  137.       };
  138.  
  139.       $.getGameLanguage = function() {
  140.         return $.greenworks.getCurrentGameLanguage();
  141.       };
  142.  
  143.       $.isSteamRunning = function() {
  144.         return $.greenworks.isSteamRunning();
  145.       };
  146.  
  147.       $._storeStatsSuccess = function(){
  148.         console.log('Stored Stats Successfully', arguments);
  149.       };
  150.  
  151.       $._storeStatsError = function(){
  152.         console.log('Failed to Store Stats', arguments);
  153.       };
  154.  
  155.       $._achievementSuccess = function(){
  156.         console.log('Achievement activated', arguments);
  157.       };
  158.  
  159.       $._achievementError = function(){
  160.         console.log('Achievement activation error', arguments);
  161.       };
  162.  
  163.       $._clearAchievementSuccess = function(){
  164.         console.log('Successfully Cleared Achievement', arguments);
  165.       };
  166.  
  167.       $._clearAchievementError = function(){
  168.         console.log('Failed to Clear Achievement', arguments);
  169.       };
  170.  
  171.       $._getAchievementSuccess = function(){
  172.       };
  173.  
  174.       $._getAchievementError = function(){
  175.         console.log('Failed to check Achievement', arguments);
  176.       };
  177.  
  178.       $.activateAchievement = function(achievementName) {
  179.         if (!achievementName) {
  180.           console.log('Achievement name not provided.');
  181.           return;
  182.         }
  183.  
  184.         if (!$.isSteamRunning()) {
  185.           console.log('Steam isn\'t running');
  186.           return;
  187.         }
  188.        
  189.         $.greenworks.activateAchievement(achievementName, $._achievementSuccess, $._achievementError);
  190.       };
  191.  
  192.       $.getAchievement = function(achievementName) {
  193.         if (!achievementName) {
  194.           console.log('Achievement name not provided.');
  195.           return false;
  196.         }
  197.  
  198.         if (!$.isSteamRunning()) {
  199.           console.log('Steam isn\'t running');
  200.           return false;
  201.         }
  202.        
  203.         return $.greenworks.getAchievement(achievementName, $._getAchievementSuccess, $._getAchievementError);        
  204.       };
  205.  
  206.       $.clearAchievement = function(achievementName) {
  207.         if (!achievementName) {
  208.           console.log('Achievement name not provided.');
  209.           return false;
  210.         }
  211.  
  212.         if (!$.isSteamRunning()) {
  213.           console.log('Steam isn\'t running');
  214.           return false;
  215.         }
  216.        
  217.         $.greenworks.clearAchievement(achievementName, $._clearAchievementSuccess, $._clearAchievementError);                
  218.       };
  219.  
  220.       $.getNumberOfAchievements = function() {
  221.         if (!$.isSteamRunning()) {
  222.           console.log('Steam isn\'t running');
  223.           return false;
  224.         }
  225.        
  226.         return $.greenworks.getNumberOfAchievements();
  227.       };
  228.  
  229.       $.activateGameOverlay = function(option) {
  230.         if (!$.isSteamRunning()) {
  231.           console.log('Steam isn\'t running');
  232.           return false;
  233.         }
  234.        
  235.         $.greenworks.activateGameOverlay(option);
  236.       };
  237.  
  238.       $.isGameOverlayEnabled = function() {
  239.         if (!$.isSteamRunning()) {
  240.           console.log('Steam isn\'t running');
  241.           return false;
  242.         }
  243.        
  244.         return $.greenworks.isGameOverlayEnabled();
  245.       };
  246.  
  247.       $.activateGameOverlayToWebPage = function(url) {
  248.         if (!$.isSteamRunning()) {
  249.           console.log('Steam isn\'t running');
  250.           return false;
  251.         }
  252.        
  253.         $.greenworks.activateGameOverlayToWebPage(url);
  254.       };
  255.  
  256.       $.isSubscribedApp = function(appId) {
  257.         if (!$.isSteamRunning()) {
  258.           console.log('Steam isn\'t running');
  259.           return false;
  260.         }
  261.        
  262.         return $.greenworks.isSubscribedApp(appId);
  263.       };
  264.  
  265.       $.getDLCCount = function() {
  266.         if (!$.isSteamRunning()) {
  267.           console.log('Steam isn\'t running');
  268.           return 0;
  269.         }
  270.        
  271.         return $.greenworks.getDLCCount();
  272.       };
  273.  
  274.       $.isDLCInstalled = function(dlcAppId) {
  275.         if (!$.isSteamRunning()) {
  276.           console.log('Steam isn\'t running');
  277.           return false;
  278.         }
  279.        
  280.         return $.greenworks.isDLCInstalled(dlcAppId);
  281.       };
  282.  
  283.       $.installDLC = function(dlcAppId) {
  284.         if (!$.isSteamRunning()) {
  285.           console.log('Steam isn\'t running');
  286.           return false;
  287.         }
  288.        
  289.         $.greenworks.installDLC(dlcAppId);
  290.       };
  291.  
  292.       $.uninstallDLC = function(dlcAppId) {
  293.         if (!$.isSteamRunning()) {
  294.           console.log('Steam isn\'t running');
  295.           return false;
  296.         }
  297.        
  298.         $.greenworks.uninstallDLC(dlcAppId);
  299.       };
  300.  
  301.       $.getStatInt = function(name) {
  302.         if (!$.isSteamRunning()) {
  303.           console.log('Steam isn\'t running');
  304.           return 0;
  305.         }
  306.        
  307.         return $.greenworks.getStatInt(name);
  308.       };
  309.  
  310.       $.getStatFloat = function(name) {
  311.         if (!$.isSteamRunning()) {
  312.           console.log('Steam isn\'t running');
  313.           return 0;
  314.         }
  315.        
  316.         return $.greenworks.getStatFloat(name);
  317.       };
  318.  
  319.       $.setStat = function(name, value) {
  320.         if (!$.isSteamRunning()) {
  321.           console.log('Steam isn\'t running');
  322.           return false;
  323.         }
  324.        
  325.         return $.greenworks.setStat(name, value);
  326.       };
  327.  
  328.       $.storeStats = function() {
  329.         if (!$.isSteamRunning()) {
  330.           console.log('Steam isn\'t running');
  331.           return false;
  332.         }
  333.        
  334.         return $.greenworks.setStat($._storeStatsSuccess, $._storeStatsError);
  335.       };
  336.  
  337.       $.getFriendCount = function() {
  338.         return $.greenworks.getFriendCount($.greenworks.FriendFlags.Immediate);
  339.       };
  340.  
  341.       $.isCloudEnabled = function() {
  342.         return $.greenworks.isCloudEnabled();
  343.       };
  344.  
  345.       $.isCloudEnabledForUser = function() {
  346.         return $.greenworks.isCloudEnabledForUser();
  347.       };
  348.     }
  349.   }
  350. })(Hudell.OrangeGreenworks);
  351.  
  352. OrangeGreenworks = Hudell.OrangeGreenworks;
  353. Imported.OrangeGreenworks = 1.2;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement