Beispiel #1
0
        public static void startSteam(Boolean checkChanges, Boolean debug)
        {
            // Debug
            DebugLog.AddListener(new DebugListener());
            DebugLog.Enabled = debug;

            // Setup client
            steamClient = new SteamClient();
            manager     = new CallbackManager(steamClient);

            steamUser    = steamClient.GetHandler <SteamUser>();
            steamApps    = steamClient.GetHandler <SteamApps>();
            steamFriends = steamClient.GetHandler <SteamFriends>();

            // Callbacks
            manager.Subscribe <SteamClient.ConnectedCallback>(OnConnected);
            manager.Subscribe <SteamClient.DisconnectedCallback>(OnDisconnected);
            manager.Subscribe <SteamUser.LoggedOnCallback>(OnLoggedOn);
            manager.Subscribe <SteamUser.LoggedOffCallback>(OnLoggedOff);

            steamClient.Connect();

            timer1          = new System.Timers.Timer();
            timer1.Elapsed += RunWaitCallbacks;
            timer1.Interval = TimeSpan.FromSeconds(Config.isLocal() ? 1 : 10).TotalMilliseconds;
            timer1.Start();

            if (checkChanges)
            {
                timer2          = new System.Timers.Timer();
                timer2.Elapsed += CheckForChanges;
                timer2.Interval = TimeSpan.FromSeconds(Config.isLocal() ? 5 : 60).TotalMilliseconds;
                timer2.Start();
            }
        }
Beispiel #2
0
        internal FuseClient()
        {
            this._Details = new SteamUser.LogOnDetails();
            this._Details.ShouldRememberPassword = true;

            this._Config = SteamConfiguration.Create(builder =>
            {
                builder.WithConnectionTimeout(TimeSpan.FromMinutes(1));
                builder.WithProtocolTypes(ProtocolTypes.WebSocket);
            });

            this._ClientHandler  = new SteamClient(this._Config);
            this._Manager        = new CallbackManager(this._ClientHandler);
            this._UserHandler    = this._ClientHandler.GetHandler <SteamUser>();
            this._FriendsHandler = this._ClientHandler.GetHandler <SteamFriends>();
            this._AppsHandler    = this._ClientHandler.GetHandler <SteamKit2.SteamApps>();
            this._User           = new FuseUser(this._FriendsHandler);
            this._UI             = new FuseUI(this);
            this._StoredApps     = null;

            this._CallbackThread = new Thread(AwaitCallbackResults);
            this._CallbackThread.Start();


            this._Manager.Subscribe <SteamClient.ConnectedCallback>(this.OnConnected);
            this._Manager.Subscribe <SteamClient.DisconnectedCallback>(this.OnDisconnected);
            this._Manager.Subscribe <SteamUser.LoggedOnCallback>(this.OnLoggedOn);
            this._Manager.Subscribe <SteamUser.LoginKeyCallback>(this.OnLoginKey);
            this._Manager.Subscribe <SteamUser.AccountInfoCallback>(this.OnAccountInfo);
            this._Manager.Subscribe <SteamFriends.PersonaStateCallback>(this.OnFriendPersonaStateChange);
            this._Manager.Subscribe <SteamFriends.FriendMsgCallback>(this.OnFriendMessage);
            this._Manager.Subscribe <SteamFriends.FriendMsgEchoCallback>(this.OnFriendMessageEcho);
        }
Beispiel #3
0
        public Steam3Session(SteamUser.LogOnDetails details)
        {
            this.logonDetails = details;

            this.authenticatedUser          = details.Username != null;
            this.credentials                = new Credentials();
            this.bConnected                 = false;
            this.bConnecting                = false;
            this.bAborted                   = false;
            this.bExpectingDisconnectRemote = false;
            this.bDidDisconnect             = false;
            this.bDidReceiveLoginKey        = false;
            this.seq = 0;

            this.AppTickets       = new Dictionary <uint, byte[]>();
            this.AppTokens        = new Dictionary <uint, ulong>();
            this.DepotKeys        = new Dictionary <uint, byte[]>();
            this.CDNAuthTokens    = new ConcurrentDictionary <string, TaskCompletionSource <SteamApps.CDNAuthTokenCallback> >();
            this.AppInfo          = new Dictionary <uint, SteamApps.PICSProductInfoCallback.PICSProductInfo>();
            this.PackageInfo      = new Dictionary <uint, SteamApps.PICSProductInfoCallback.PICSProductInfo>();
            this.AppBetaPasswords = new Dictionary <string, byte[]>();

            this.steamClient = new SteamClient();

            this.steamUser = this.steamClient.GetHandler <SteamUser>();
            this.steamApps = this.steamClient.GetHandler <SteamApps>();
            var steamUnifiedMessages = this.steamClient.GetHandler <SteamUnifiedMessages>();

            this.steamPublishedFile = steamUnifiedMessages.CreateService <IPublishedFile>();

            this.callbacks = new CallbackManager(this.steamClient);

            this.callbacks.Subscribe <SteamClient.ConnectedCallback>(ConnectedCallback);
            this.callbacks.Subscribe <SteamClient.DisconnectedCallback>(DisconnectedCallback);
            this.callbacks.Subscribe <SteamUser.LoggedOnCallback>(LogOnCallback);
            this.callbacks.Subscribe <SteamUser.SessionTokenCallback>(SessionTokenCallback);
            this.callbacks.Subscribe <SteamApps.LicenseListCallback>(LicenseListCallback);
            this.callbacks.Subscribe <SteamUser.UpdateMachineAuthCallback>(UpdateMachineAuthCallback);
            this.callbacks.Subscribe <SteamUser.LoginKeyCallback>(LoginKeyCallback);

            Console.Write("Connecting to Steam3...");

            if (authenticatedUser)
            {
                FileInfo fi = new FileInfo(String.Format("{0}.sentryFile", logonDetails.Username));
                if (AccountSettingsStore.Instance.SentryData != null && AccountSettingsStore.Instance.SentryData.ContainsKey(logonDetails.Username))
                {
                    logonDetails.SentryFileHash = Util.SHAHash(AccountSettingsStore.Instance.SentryData[logonDetails.Username]);
                }
                else if (fi.Exists && fi.Length > 0)
                {
                    var sentryData = File.ReadAllBytes(fi.FullName);
                    logonDetails.SentryFileHash = Util.SHAHash(sentryData);
                    AccountSettingsStore.Instance.SentryData[logonDetails.Username] = sentryData;
                    AccountSettingsStore.Save();
                }
            }

            Connect();
        }
Beispiel #4
0
        /// <summary>
        /// <para>Gets the install folder for a specific AppID.
        /// This works even if the application is not installed, based on where the game would be installed with the default Steam library location.</para>
        /// <a href="https://partner.steamgames.com/doc/api/ISteamApps#GetAppInstallDir">https://partner.steamgames.com/doc/api</a>
        /// </summary>
        /// <param name="appId"></param>
        /// <returns></returns>
        public static string GetAppInstallDir(AppId_t appId)
        {
            string results;

            SteamApps.GetAppInstallDir(appId, out results, 1024);
            return(results);
        }
        private async Task <bool> ConnectToSteam(CancellationToken token)
        {
            handledLogin      = false;
            handledDisconnect = false;
            disposables.Clear();

            logger.Info("Connecting to Steam");
            EnableSteamLogger();

            SteamConfiguration config = SteamConfiguration.Create(CreateSteamConfiguration);

            client = new SteamClient(config);

            apps = client.GetHandler <SteamApps>();
            user = client.GetHandler <SteamUser>();

            CreateSteamCallbacks();

            client.Connect();

            Task.Run(RunSteam, token);

            bool?isConnected = await steamClientConnected.Task;

            return(isConnected.HasValue && isConnected.Value);
        }
    public static string GetSteamAppPath(TaskLoggingHelper taskLoggingHelper, uint appId)
    {
        try {
            if (!SteamClient.IsValid)
            {
                SteamClient.Init(appId);
            }
        }
        catch (Exception ex) {
            taskLoggingHelper.LogWarning(ex.ToString());
#if DEBUG
            Debugger.Launch();
#endif
        }

        string path = null;
        try {
            path = SteamApps.AppInstallDir(appId);
        }
        catch (Exception ex) {
            taskLoggingHelper.LogError(ex.ToString());
#if DEBUG
            Debugger.Launch();
#endif
        }

        return(path);
    }
Beispiel #7
0
        /// <summary>
        /// <para>Gets the command line if the game was launched via Steam URL, e.g. steam://run/<appid>//<command line>/. This method is preferable to launching with a command line via the operating system, which can be a security risk. In order for rich presence joins to go through this and not be placed on the OS command line, you must enable "Use launch command line" from the Installation > General page on your app.</para>
        /// <a href="https://partner.steamgames.com/doc/api/ISteamApps#GetLaunchCommandLine">https://partner.steamgames.com/doc/api</a>
        /// </summary>
        /// <returns></returns>
        public static string GetLaunchCommandLine()
        {
            string buffer;

            SteamApps.GetLaunchCommandLine(out buffer, 1024);
            return(buffer);
        }
Beispiel #8
0
 public SteamClient()
 {
     _steamPlayerService = Factory.CreateSteamWebInterface <PlayerService>(new HttpClient());
     _steamUserStats     = Factory.CreateSteamWebInterface <SteamUserStats>(new HttpClient());
     _steamUser          = Factory.CreateSteamWebInterface <SteamUser>(new HttpClient());
     _steamApps          = Factory.CreateSteamWebInterface <SteamApps>(new HttpClient());
 }
Beispiel #9
0
        public static void Init()
        {
            lock (_initLock)
            {
                if (!Instance)
                {
                    GameObject go = new GameObject();
                    go.name  = "ModLoader";
                    Instance = go.AddComponent <ModLoader>();
                    DontDestroyOnLoad(go);
                    SteamAPI.Init();
                    SteamApps.GetAppInstallDir(AppId_t.SpaceStationOnline, out SteamAppDir, 1024u);

                    AppDataDir    = Path.GetFullPath(Application.dataPath);
                    ManagedDir    = Path.GetFullPath(Path.Combine(AppDataDir, "Managed"));
                    AppRootDir    = Path.GetDirectoryName(AppDataDir);
                    MyGamesModDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), @"My Games\Stationeers\mods");
                    ModLoaderDir  = Path.Combine(AppRootDir, "Mods");

                    if (!Directory.Exists(ModLoaderDir))
                    {
                        Directory.CreateDirectory(ModLoaderDir);
                    }

                    if (!Directory.Exists(MyGamesModDir))
                    {
                        Directory.CreateDirectory(MyGamesModDir);
                    }

                    LoadMods();
                }
            }
        }
    private void Awake()
    {
        GetWorldControllers();
        BindButtons();
        steamUserAvatar.sprite = Sprite.Create(GetSteamAvatar(), new Rect(new Vector2(0, 0), new Vector2(64, 64)), new Vector2(64, 64));
        hudCanvasTopPanelSteamUserAvatar.sprite = Sprite.Create(GetSteamAvatar(), new Rect(new Vector2(0, 0), new Vector2(64, 64)), new Vector2(64, 64));
        helperTipContainer = GetComponent <HelperTipContainer>();
        RefreshHelperTips();
        AudioListener.volume = userVolume;
        if (SteamManager.Initialized)
        {
            string name = SteamFriends.GetPersonaName();
            intro_playerName.text = name;
            hudCanvasTopPanelUsernameText.text = name;
            steamBuildVersionTextNumber.text   = SteamApps.GetAppBuildId().ToString();
        }

        steamLeaderBoardTop100EntriesUIPrefabsList = new List <LeaderboardEntry>();
        for (int i = 0; i < 100; i++) // prepare the leaderboard top 10 entry display prefab objects
        {
            GameObject leaderBoardEntry = Instantiate(Resources.Load("Leaderboard Entry"), LeaderboardEntriesContent.transform, false) as GameObject;
            int        rank             = 1 + i;
            leaderBoardEntry.GetComponent <LeaderboardEntry>().rank          = rank;
            leaderBoardEntry.GetComponent <LeaderboardEntry>().rankText.text = rank + ")";
            steamLeaderBoardTop100EntriesUIPrefabsList.Add(leaderBoardEntry.GetComponent <LeaderboardEntry>());
        }

        EmptyItem           = new Item(ItemName.NO_ITEM);
        tooltipOffsetVector = new Vector3(xOffsetTooltip, yOffsetTooltip, 0);
    }
Beispiel #11
0
        public override void OnEnter()
        {
            m_DlcInstalled = Callback <DlcInstalled_t> .Create(OnDlcInstalled);

            SteamApps.InstallDLC((AppId_t)(uint)appID.Value);
            Finish();
        }
Beispiel #12
0
        public async Task <byte[]> GetDepotKeyAsync(DepotId depotId, AppId appId)
        {
            if (_depotKeys.ContainsKey(depotId))
            {
                return(_depotKeys[depotId]);
            }

            var result = await SteamApps.GetDepotDecryptionKey(depotId, appId);

            if (result.Result != EResult.OK)
            {
                if (result.Result == EResult.AccessDenied)
                {
                    throw new SteamDepotAccessDeniedException(depotId);
                }

                throw new SteamDepotKeyNotRetrievableException(depotId, result.Result);
            }

            while (!_depotKeys.TryAdd(depotId, result.DepotKey))
            {
            }

            return(result.DepotKey);
        }
        public SteamAPIService(ILogger <SteamCMDService> logger)
        {
            _logger = logger;
            // app_info_print

            // create our steamclient instance
            steamClient = new SteamClient();
            // create the callback manager which will route callbacks to function calls
            manager = new CallbackManager(steamClient);

            // get the steamuser handler, which is used for logging on after successfully connecting
            steamUser = steamClient.GetHandler <SteamUser>();

            // get our steamapps handler, we'll use this as an example of how async jobs can be handled
            steamApps = steamClient.GetHandler <SteamApps>();

            // register a few callbacks we're interested in
            // these are registered upon creation to a callback manager, which will then route the callbacks
            // to the functions specified
            manager.Subscribe <SteamClient.ConnectedCallback>(OnConnected);
            manager.Subscribe <SteamClient.DisconnectedCallback>(OnDisconnected);

            manager.Subscribe <SteamUser.LoggedOnCallback>(OnLoggedOn);
            manager.Subscribe <SteamUser.LoggedOffCallback>(OnLoggedOff);

            _logger.LogInformation("Connecting to Steam...");
            steamClient.Connect();

            manager.RunWaitAllCallbacks(TimeSpan.FromSeconds(15));
        }
Beispiel #14
0
        public async Task Install(IServiceProvider _services)
        {
            client = _services.GetService <DiscordSocketClient>();
            config = _services.GetService <Config>();

            steamClient = new SteamClient();
            manager     = new CallbackManager(steamClient);

            steamUser = steamClient.GetHandler <SteamUser>();
            steamApps = steamClient.GetHandler <SteamApps>();

            manager.Subscribe <SteamClient.ConnectedCallback>(OnConnected);
            manager.Subscribe <SteamClient.DisconnectedCallback>(OnDisconnected);

            manager.Subscribe <SteamUser.LoggedOnCallback>(OnLoggedOn);
            manager.Subscribe <SteamUser.LoggedOffCallback>(OnLoggedOff);

            manager.Subscribe <SteamUser.UpdateMachineAuthCallback>(OnMachineAuth);

            isRunning = true;

            Console.WriteLine("Connecting to steam...");

            steamClient.Connect();

            Task.Run(() =>
            {
                while (isRunning)
                {
                    manager.RunWaitCallbacks(TimeSpan.FromSeconds(1));
                }
            }).ConfigureAwait(false);
        }
Beispiel #15
0
        public static void Main( string[] args )
        {
            if ( args.Length != 1 )
            {
                Console.WriteLine( "Please specify an appid to get the icon of." );
                return;
            }

            m_appid       = uint.Parse( args[0] );
            m_http        = new HttpClient();
            m_steamClient = new SteamClient();
            m_manager     = new CallbackManager( m_steamClient );

            m_steamUser = m_steamClient.GetHandler<SteamUser>();
            m_steamApps = m_steamClient.GetHandler<SteamApps>();

            m_manager.Subscribe<SteamClient.ConnectedCallback>   ( OnConnected );
            m_manager.Subscribe<SteamClient.DisconnectedCallback>( OnDisconnected );
            m_manager.Subscribe<SteamUser.LoggedOnCallback>      ( OnLoggedOn );
            m_manager.Subscribe<SteamUser.LoggedOffCallback>     ( OnLoggedOff );

            m_isRunning = true;

            Console.WriteLine( "Connecting to Steam..." );

            m_steamClient.Connect();

            while ( m_isRunning )
            {
                m_manager.RunWaitCallbacks( TimeSpan.FromSeconds( 1 ) );
            }
        }
Beispiel #16
0
        public ContentDownloader(SteamClient client, CDNClientPool cdnClientPool, LicenseList licenses, ILogger logger)
        {
            Licenses = licenses;

            _cdnClientPool = cdnClientPool;
            _client        = client;
            _logger        = logger;

            _apps = client.GetHandler <SteamApps>();


            _depotKeys   = new ConcurrentDictionary <uint, byte[]>();
            _packageInfo = new ConcurrentDictionary <uint, PICSProductInfo>();
            _appInfo     = new ConcurrentDictionary <uint, PICSProductInfo>();


            var currentDir = Directory.GetCurrentDirectory();

            _stagingDir = Path.Combine(Path.GetTempPath(), "content_downloader.staging");
            _cacheDir   = Path.Combine(currentDir, "manifest_cache");
            _dataDir    = Path.Combine(currentDir, "data");

            if (!Directory.Exists(_stagingDir))
            {
                Directory.CreateDirectory(_stagingDir);
            }
            if (!Directory.Exists(_cacheDir))
            {
                Directory.CreateDirectory(_cacheDir);
            }
            if (!Directory.Exists(_dataDir))
            {
                Directory.CreateDirectory(_dataDir);
            }
        }
Beispiel #17
0
        public SteamClient(SteamCredentials credentials, SteamAuthenticationCodesProvider codesProvider, SteamAuthenticationFilesProvider authenticationProvider)
        {
            Credentials             = credentials ?? throw new ArgumentNullException(nameof(credentials));
            _codesProvider          = codesProvider;
            _authenticationProvider = authenticationProvider;
            InternalClient          = new SteamKit.SteamClient();

            _cancellationTokenSource = new CancellationTokenSource();
            CallbackManager          = new SteamKit.CallbackManager(InternalClient);

            _steamUser = InternalClient.GetHandler <SteamKit.SteamUser>();
            _steamApps = InternalClient.GetHandler <SteamKit.SteamApps>();

            Task.Run(async() => await CallbackManagerHandler());

            CallbackManager.Subscribe <SteamKit.SteamClient.ConnectedCallback>(OnConnected);
            CallbackManager.Subscribe <SteamKit.SteamClient.DisconnectedCallback>(OnDisconnected);
            CallbackManager.Subscribe <SteamKit.SteamUser.LoggedOnCallback>(OnLoggedOn);
            CallbackManager.Subscribe <SteamKit.SteamUser.LoggedOffCallback>(OnLoggedOff);
            CallbackManager.Subscribe <SteamKit.SteamApps.LicenseListCallback>(OnLicenseList);
            CallbackManager.Subscribe <SteamKit.SteamUser.UpdateMachineAuthCallback>(OnMachineAuth);
            CallbackManager.Subscribe <SteamKit.SteamUser.LoginKeyCallback>(OnLoginKey);

            InternalClient.Connect();
        }
Beispiel #18
0
        public static string GetAppInstallDir()
        {
            string appInstallDir = null;

            SteamApps.GetAppInstallDir(new AppId_t(Const.STEAM_APP_ID), out appInstallDir, 1024);
            return(appInstallDir);
        }
Beispiel #19
0
        private static Task UpdateSteamAsync()
        {
            Console.WriteLine("Updating Steam App List...");
            var service = new BotServices();
            var token   = service.GetAPIToken("steam");
            var apps    = new SteamApps(token);
            var games   = apps.GetAppListAsync().Result.Data;

            GlobalVariables.SteamAppList.Clear();
            foreach (var game in games)
            {
                if (!string.IsNullOrWhiteSpace(game.Name))
                {
                    GlobalVariables.SteamAppList.Add(Convert.ToUInt32(game.AppId), game.Name);
                }
            }

            Console.WriteLine("Updating TF2 Item Schema...");
            var schema = new EconItems(token, EconItemsAppId.TeamFortress2);
            var items  = schema.GetSchemaForTF2Async();

            GlobalVariables.TFItemSchema.Clear();
            foreach (var item in items.Result.Data.Items)
            {
                if (!string.IsNullOrWhiteSpace(item.ItemName))
                {
                    GlobalVariables.TFItemSchema.Add(Convert.ToUInt32(item.DefIndex), item.ItemName);
                }
            }

            return(Task.CompletedTask);
        }
Beispiel #20
0
        private async Task <LocalConfig.CDNAuthToken> GetCDNAuthToken(SteamApps instance, uint appID, uint depotID)
        {
            if (LocalConfig.CDNAuthTokens.ContainsKey(depotID))
            {
                var token = LocalConfig.CDNAuthTokens[depotID];

                if (DateTime.Now < token.Expiration)
                {
                    return(token);
                }

#if DEBUG
                Log.WriteDebug("Depot Downloader", "Token for depot {0} expired, will request a new one", depotID);
            }
            else
            {
                Log.WriteDebug("Depot Downloader", "Requesting a new token for depot {0}", depotID);
#endif
            }

            var newToken = new LocalConfig.CDNAuthToken
            {
                Server = GetContentServer()
            };

            var task = instance.GetCDNAuthToken(appID, depotID, newToken.Server);
            task.Timeout = TimeSpan.FromMinutes(15);

            SteamApps.CDNAuthTokenCallback tokenCallback;

            try
            {
                tokenCallback = await task;
            }
            catch (TaskCanceledException)
            {
                Log.WriteError("Depot Processor", "CDN auth token timed out for {0}", depotID);

                return(null);
            }

#if DEBUG
            Log.WriteDebug("Depot Downloader", "Token for depot {0} result: {1}", depotID, tokenCallback.Result);
#endif

            if (tokenCallback.Result != EResult.OK)
            {
                return(null);
            }

            newToken.Token      = tokenCallback.Token;
            newToken.Expiration = tokenCallback.Expiration.Subtract(TimeSpan.FromMinutes(1));

            LocalConfig.CDNAuthTokens[depotID] = newToken;

            SaveLocalConfig = true;

            return(newToken);
        }
Beispiel #21
0
        public SteamCdnServerPool(SteamContentClient steamContentClient, SteamContentServerQualityProvider steamContentServerQualityProvider)
        {
            _steamApps          = steamContentClient.SteamClient.InternalClient.GetHandler <SteamKit2.SteamApps>();
            _steamContentClient = steamContentClient;
            _steamContentServerQualityProvider = steamContentServerQualityProvider;

            _steamContentServerQualities = _steamContentServerQualityProvider.Load() ?? new List <SteamContentServerQuality>();
        }
Beispiel #22
0
        /// <summary>
        /// Gets the time of purchase
        /// </summary>
        /// <returns></returns>
        public DateTime GetEarliestPurchaseTime()
        {
            var val      = SteamApps.GetEarliestPurchaseUnixTime(AppId);
            var dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);

            dateTime = dateTime.AddSeconds(val);
            return(dateTime);
        }
Beispiel #23
0
        public static string GetSteamTMLInstallDir()
        {
            SteamApps.GetAppInstallDir(TMLAppID_t, out string tmlInstallDIr, 1000);
#if MAC
            tmlInstallDIr = Path.Combine(tmlInstallDIr, "tModLoader.app/Contents/MacOS");
#endif
            return(tmlInstallDIr);
        }
Beispiel #24
0
        public static string GetSteamTerrariaInstallDir()
        {
            SteamApps.GetAppInstallDir(TerrariaAppId_t, out string terrariaInstallLocation, 1000);
#if MAC
            terrariaInstallLocation = Path.Combine(terrariaInstallLocation, "Terraria.app/Contents/MacOS");
#endif
            return(terrariaInstallLocation);
        }
        protected override void Initialize()
        {
            base.Initialize();

            Exiting += SteamworksIntegration_Exiting;

            try
            {
                SteamClient.Init(480);

                Functions.IsSteamRunning = true;

                SteamFriends.OnGameOverlayActivated += Functions.SteamFriends_OnGameOverlayActivated;
                SteamUserStats.OnUserStatsReceived  += SteamUserStats_OnUserStatsReceived;
                SteamUserStats.RequestCurrentStats();

                SteamUtils.OverlayNotificationPosition = NotificationPosition.TopRight;
                // Uncomment the next line to adjust the OverlayNotificationPosition.
                //SteamUtils.SetOverlayNotificationInset(400, 0);

                _CurrentLanguage = SteamApps.GameLanguage;
                _UserLevel       = SteamUser.SteamLevel;
                _UserID          = SteamClient.SteamId;
                _InstallDir      = SteamApps.AppInstallDir();

                _Scores      = Functions.FindLeaderboard("Quickest Win", 9).Result;
                _UserAvatar  = Functions.GetUserImage(_UserID, GraphicsDevice).Result;
                _PlayerCount = Functions.GetPlayerCount().Result;

                //The following lines can be helpful to know more about the user of your application
                //
                // Check if the user basically owns this app
                _OwnsApp = SteamApps.IsSubscribed;

                // Check if the user owns this app through Family Sharing
                _OwnsAppThroughFamilySharing = SteamApps.IsSubscribedFromFamilySharing;

                // Check if the user owns this app because of a Free Weekend
                _OwnsAppThroughFreeWeekend = SteamApps.IsSubscribedFromFreeWeekend;

                // The ownder SteamID of this app. It will be different from the users ID who started this application, when he just borrowed
                // this app through Family Sharing
                _OwnerID = SteamApps.AppOwner;

                // More information about the original app owner, which could be a Steam Friend (Family Sharing)
                try
                {
                    _OwnerFriend = SteamFriends.GetFriends().Where(x => x.Id == _OwnerID).First();
                }
                catch { }
            }
            catch (Exception e)
            {
                Console.Out.WriteLine(e.ToString());
            }

            Functions.LoadContent(Content);
        }
        private void ShowOrHideElements()
        {
            if (scrUIController.instance == null)
            {
                return;
            }
            scrUIController uiController = scrUIController.instance;

            bool hideEverything = Settings.HideEverything;
            bool hideOtto       = hideEverything || Settings.HideOtto;
            bool hideBeta       = hideEverything || Settings.HideBeta;
            bool hideTitle      = hideEverything || Settings.HideTitle;

            hideEverything &= AdofaiTweaks.IsEnabled && Settings.IsEnabled;
            hideOtto       &= AdofaiTweaks.IsEnabled && Settings.IsEnabled;
            hideBeta       &= AdofaiTweaks.IsEnabled && Settings.IsEnabled;
            hideTitle      &= AdofaiTweaks.IsEnabled && Settings.IsEnabled;

            RDC.noHud = hideEverything;

            scnEditor editor = Object.FindObjectOfType <scnEditor>();

            if (scrController.instance.isEditingLevel)
            {
                if (editor?.ottoCanvas.gameObject.activeSelf == hideOtto)
                {
                    editor.ottoCanvas.gameObject.SetActive(!hideOtto);
                }
            }
            else
            {
                uiController.difficultyImage.enabled = !hideOtto;
                if (uiController.difficultyContainer.gameObject.activeSelf == hideOtto)
                {
                    uiController.difficultyContainer.gameObject.SetActive(!hideOtto);
                }
                if (uiController.difficultyFadeContainer.gameObject.activeSelf == hideOtto)
                {
                    uiController.difficultyFadeContainer.gameObject.SetActive(!hideOtto);
                }
            }

            if (SteamAPI.Init())
            {
                bool            isBeta       = SteamApps.GetCurrentBetaName(out _, 20);
                scrEnableIfBeta enableIfBeta =
                    Resources.FindObjectsOfTypeAll <scrEnableIfBeta>().FirstOrDefault();
                if (isBeta && enableIfBeta && enableIfBeta.gameObject.activeSelf == hideBeta)
                {
                    enableIfBeta.gameObject.SetActive(!hideBeta);
                }
            }

            if (uiController.txtLevelName.gameObject.activeSelf == hideTitle)
            {
                uiController.txtLevelName.gameObject.SetActive(!hideTitle);
            }
        }
        private async void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                if (!SteamAPI.Init())
                {
                    if (SteamAPI.IsSteamRunning())
                    {
                        steamLBL.ForeColor = Color.DarkBlue;
                        steamLBL.Text      = "Steam Running..";
                        steamSTATUS.Image  = HDDowngradeTool.Properties.Resources.dotred;
                    }
                    else
                    {
                        steamLBL.ForeColor = Color.Gold;
                        await Task.Delay(200);

                        steamLBL.Text = "Steam OFF";
                        await Task.Delay(100);

                        steamLBL.ForeColor = Color.Maroon;
                        steamSTATUS.Image  = HDDowngradeTool.Properties.Resources.dotred;
                    }

                    //SteamUtils.GetAppID();
                }
                else
                {
                    steamLBL.ForeColor     = Color.ForestGreen;
                    steamLBL.Text          = "Steam ON";
                    steamSTATUS.Image      = HDDowngradeTool.Properties.Resources.dotgreen;
                    cbPATCH.Enabled        = true;
                    kryptonButton1.Enabled = true;
                    await Task.Delay(200);

                    bool IsDE = SteamApps.BIsAppInstalled(new AppId_t(221380));
                    if (!IsDE)
                    {
                        MessageBox.Show("Please Buy or Install Age of Empires II: Definitive Edition before you proceed!", "Game Missing");
                        cbPATCH.Enabled = false;
                        timer1.Stop();
                    }

                    var    versionInfo = FileVersionInfo.GetVersionInfo(SaveDirectoryPath() + @"\AoK HD.exe");
                    string version     = versionInfo.FileVersion;
                    //string[] sver = version.Split('.');
                    label1.Text = "Current Version: " + version;

                    timer1.Stop();
                }
            }
            catch (SystemException)
            {
                steamLBL.ForeColor = Color.Black;
                steamLBL.Text      = "Steam OFF";
                steamSTATUS.Image  = HDDowngradeTool.Properties.Resources.dotred;
            }
        }
Beispiel #28
0
        ///// Methods /////

        //private string _test = string.Empty;

        private void Awake()
        {
            if (SteamClient.IsValid)
            {
                return;
            }

            Dispatch.OnException = (e) =>
            {
                UnityEngine.Debug.LogError(e.Message);
                UnityEngine.Debug.Log(e.StackTrace);
            };

            //Steamworks.Dispatch.OnDebugCallback = (type, str, server) =>
            //{
            //    UnityEngine.Debug.Log($"[Callback {type} {(server ? "server" : "client")}]");
            //    UnityEngine.Debug.Log($"{str}");
            //};

            //SteamNetworkingUtils.DebugLevel = NetDebugOutput.Everything;
            //SteamNetworkingUtils.OnDebugOutput += (e1, e2) =>
            //{
            //    UnityEngine.Debug.Log(e1 + ":" + e2);
            //    _test += e1 + "::" + e2 + "\n";
            //};

            //Steamworks.Dispatch.OnDebugCallback = (type, str, server) =>
            //{
            //    UnityEngine.Debug.Log($"[Callback {type} {(server ? "server" : "client")}]");
            //    UnityEngine.Debug.Log(str);
            //    UnityEngine.Debug.Log($"");

            //    _test += $"[Callback {type} {(server ? "server" : "client")}]\n";
            //    _test += $"{str}\n";
            //    _test += $"\n\n";
            //};

            try
            {
                SteamClient.Init(Structure.AppId);
            }
            catch (System.Exception e)
            {
                ExceptionMessage = e.ToString();
                Debug.LogError(e.ToString());
                return;
            }

            if (!SteamApps.IsSubscribedToApp(Structure.AppId))
            {
                Application.Quit();
            }

            SteamNetworkingUtils.InitRelayNetworkAccess();

            Initialized = true;
        }
Beispiel #29
0
 public unsafe static bool Authorize()
 {
     if (!_initialized)
     {
         return(false);
     }
     // TODO: SteamApps.RequestAppProofOfPurchaseKey? SteamApps.BIsAppInstalled? SteamApps.BIsSubscribedApp?
     return(SteamApps.BIsSubscribedApp(SteamUtils.GetAppID()));
 }
Beispiel #30
0
 private void Start()
 {
     switch (SteamApps.GetCurrentGameLanguage())
     {
     case "schinese":
         GetComponent <Text>().text = TextCn.Replace("\\n", "\n");
         break;
     }
 }