Beispiel #1
0
        public static void RunCallbacks()
        {
            CallbackMsg_t callbackmsg;
            HSteamPipe    pipe = SteamAPI.GetHSteamPipe();

            while (NativeMethods.Steam_BGetCallback(pipe, out callbackmsg))
            {
                m_LastActivePipe = pipe;

                List <ICallbackBase> callbackList;
                if (m_RegisteredCallbacks.TryGetValue(callbackmsg.m_iCallback, out callbackList))
                {
                    foreach (ICallbackBase callback in callbackList)
                    {
                        callback.Run(callbackmsg.m_pubParam);
                    }
                }

                NativeMethods.Steam_FreeLastCallback(pipe);
            }

            // These need to be called every frame to process matchmaking results and poll the controller
            SteamUtils.RunFrame();
            SteamController.RunFrame();
        }
Beispiel #2
0
        public static void Init(uint appid)
        {
            if (IntPtr.Size != 8)
            {
                throw new System.Exception("Only 64bit processes are currently supported");
            }

            System.Environment.SetEnvironmentVariable("SteamAppId", appid.ToString());
            System.Environment.SetEnvironmentVariable("SteamGameId", appid.ToString());

            if (!SteamAPI.Init())
            {
                throw new System.Exception("SteamApi_Init returned false. Steam isn't running, couldn't find Steam, AppId is ureleased, Don't own AppId.");
            }

            AppId = appid;

            initialized = true;


            SteamApps.InstallEvents();
            SteamUtils.InstallEvents();
            SteamParental.InstallEvents();
            SteamMusic.InstallEvents();
            SteamVideo.InstallEvents();
            SteamUser.InstallEvents();
            SteamFriends.InstallEvents();
            SteamScreenshots.InstallEvents();
            SteamUserStats.InstallEvents();
            SteamInventory.InstallEvents();

            RunCallbacksAsync();
        }
        public static void Shutdown()
        {
            Event.DisposeAllClient();

            initialized = false;

            ShutdownInterfaces();
            SteamApps.Shutdown();
            SteamUtils.Shutdown();
            SteamParental.Shutdown();
            SteamMusic.Shutdown();
            SteamVideo.Shutdown();
            SteamUser.Shutdown();
            SteamFriends.Shutdown();
            SteamScreenshots.Shutdown();
            SteamUserStats.Shutdown();
            SteamInventory.Shutdown();
            SteamNetworking.Shutdown();
            SteamMatchmaking.Shutdown();
            SteamParties.Shutdown();
            SteamNetworkingUtils.Shutdown();
            SteamNetworkingSockets.Shutdown();
            ServerList.Base.Shutdown();

            SteamAPI.Shutdown();
        }
        public static void Init(uint appid)
        {
            System.Environment.SetEnvironmentVariable("SteamAppId", appid.ToString());
            System.Environment.SetEnvironmentVariable("SteamGameId", appid.ToString());

            if (!SteamAPI.Init())
            {
                throw new System.Exception("SteamApi_Init returned false. Steam isn't running, couldn't find Steam, AppId is ureleased, Don't own AppId.");
            }

            AppId = appid;

            initialized = true;

            SteamApps.InstallEvents();
            SteamUtils.InstallEvents();
            SteamParental.InstallEvents();
            SteamMusic.InstallEvents();
            SteamVideo.InstallEvents();
            SteamUser.InstallEvents();
            SteamFriends.InstallEvents();
            SteamScreenshots.InstallEvents();
            SteamUserStats.InstallEvents();
            SteamInventory.InstallEvents();
            SteamNetworking.InstallEvents();
            SteamMatchmaking.InstallEvents();
            SteamParties.InstallEvents();
            SteamNetworkingSockets.InstallEvents();
            SteamInput.InstallEvents();

            RunCallbacksAsync();
        }
        /// <summary>
        /// Gets the result. This is called internally by the async shit.
        /// </summary>
        public T?GetResult()
        {
            if (!SteamUtils.IsCallComplete(call, out var failed) || failed)
            {
                return(null);
            }

            var t    = default(T);
            var size = t.DataSize;
            var ptr  = Marshal.AllocHGlobal(size);

            try
            {
                if (!SteamUtils.Internal.GetAPICallResult(call, ptr, size, (int)t.CallbackType, ref failed) || failed)
                {
                    return(null);
                }

                return((T)Marshal.PtrToStructure(ptr, typeof(T)));
            }
            finally
            {
                Marshal.FreeHGlobal(ptr);
            }
        }
Beispiel #6
0
        public static async Task <Image?> GetLargeAvatarAsync(SteamId steamid)
        {
            int i;
            await SteamFriends.CacheUserInformationAsync(steamid, false);

            for (i = SteamFriends.Internal.GetLargeFriendAvatar(steamid); i == -1; i = SteamFriends.Internal.GetLargeFriendAvatar(steamid))
            {
                await Task.Delay(50);
            }
            return(SteamUtils.GetImage(i));
        }
        public static async Task <Data.Image?> GetLargeAvatarAsync(SteamId steamid)
        {
            await CacheUserInformationAsync(steamid, false);

            var imageid = Internal.GetLargeFriendAvatar(steamid);

            // Wait for the image to download
            while (imageid == -1)
            {
                await Task.Delay(50);

                imageid = Internal.GetLargeFriendAvatar(steamid);
            }

            return(SteamUtils.GetImage(imageid));
        }
Beispiel #8
0
        public static void Shutdown()
        {
            Event.DisposeAllClient();

            initialized = false;

            SteamApps.Shutdown();
            SteamUtils.Shutdown();
            SteamParental.Shutdown();
            SteamMusic.Shutdown();
            SteamVideo.Shutdown();
            SteamUser.Shutdown();
            SteamFriends.Shutdown();
            SteamScreenshots.Shutdown();
            SteamUserStats.Shutdown();
            SteamInventory.Shutdown();

            SteamAPI.Shutdown();
        }
Beispiel #9
0
        public static Image?GetImage(int image)
        {
            Image?nullable;
            Image?nullable1;

            if (image == -1)
            {
                nullable  = null;
                nullable1 = nullable;
            }
            else if (image != 0)
            {
                Image image1 = new Image();
                if (SteamUtils.GetImageSize(image, out image1.Width, out image1.Height))
                {
                    uint   width    = image1.Width * image1.Height * 4;
                    byte[] numArray = Helpers.TakeBuffer((int)width);
                    if (SteamUtils.Internal.GetImageRGBA(image, numArray, (int)width))
                    {
                        image1.Data = new Byte[width];
                        Array.Copy(numArray, (long)0, image1.Data, (long)0, (long)width);
                        nullable1 = new Image?(image1);
                    }
                    else
                    {
                        nullable  = null;
                        nullable1 = nullable;
                    }
                }
                else
                {
                    nullable  = null;
                    nullable1 = nullable;
                }
            }
            else
            {
                nullable  = null;
                nullable1 = nullable;
            }
            return(nullable1);
        }
        public static async Task <Data.Image?> GetMediumAvatarAsync(SteamId steamid)
        {
            await CacheUserInformationAsync(steamid, false);

            return(SteamUtils.GetImage(Internal.GetMediumFriendAvatar(steamid)));
        }
        public async Task CheckFileSignature()
        {
            var sig = await SteamUtils.CheckFileSignatureAsync("hl2.exe");

            Console.WriteLine($"{sig}");
        }
Beispiel #12
0
        public static async Task <Image?> GetSmallAvatarAsync(SteamId steamid)
        {
            await SteamFriends.CacheUserInformationAsync(steamid, false);

            return(SteamUtils.GetImage(SteamFriends.Internal.GetSmallFriendAvatar(steamid)));
        }