示例#1
0
        public void StartBigPicture()
        {
            string installPath = Steamworks.GetInstallPath();
            string steamEXE    = Path.Combine(installPath, @"steam.exe");

            Process.Start(steamEXE, "steam://open/bigpicture");
        }
示例#2
0
        public void InstallGame(UInt64 GameID)
        {
            CGameID gameID = new CGameID(GameID);

            switch (gameID.AppType)
            {
            // Basic Steam App
            case CGameID.EGameID.k_EGameIDTypeApp:
            {
                string InstallCommand = $"steam://install/{GameID}";
                string installPath    = Steamworks.GetInstallPath();
                string steamEXE       = Path.Combine(installPath, @"steam.exe");
                Process.Start(steamEXE, InstallCommand);
            }
            break;

            case CGameID.EGameID.k_EGameIDTypeGameMod:
                break;

            case CGameID.EGameID.k_EGameIDTypeShortcut:
                break;
            }
        }
示例#3
0
        public Steam()
        {
            _log = LogManager.GetLogger(this);

            _log.Info("Steam initializing...");

            if (!Steamworks.Load())
            {
                _log.Error("Failed to load Steamworks.");
                throw new SteamException("Failed to load Steamworks");
            }

            _log.Debug("Creating SteamClient012 interface...");

            SteamClient012 = Steamworks.CreateInterface <ISteamClient012>();

            if (SteamClient012 == null)
            {
                _log.Error("Failed to create SteamClient012 interface");
                throw new SteamException("Failed to create SteamClient012 interface");
            }

            _log.Debug("Creating steam pipe and connecting to global user...");

            _pipe = SteamClient012.CreateSteamPipe();

            if (_pipe == 0)
            {
                _log.Error("Failed to create Steam pipe");
                throw new SteamException("Failed to create Steam pipe");
            }

            _user = SteamClient012.ConnectToGlobalUser(_pipe);

            if (_user == 0)
            {
                _log.Error("Failed to connect user");
                throw new SteamException("Failed to connect to global user");
            }

            _log.Debug("Getting SteamUtils005 interface...");

            SteamUtils005 = SteamClient012.GetISteamUtils <ISteamUtils005>(_pipe);

            if (SteamUtils005 == null)
            {
                _log.Error("Failed to obtain Steam utils");
                throw new SteamException("Failed to obtain Steam utils");
            }

            _log.Debug("Getting SteamUser016 interface...");

            SteamUser016 = SteamClient012.GetISteamUser <ISteamUser016>(_user, _pipe);

            if (SteamUser016 == null)
            {
                _log.Error("Failed to obtain Steam user interface");
                throw new SteamException("Failed to obtain Steam user interface");
            }

            _log.Debug("Getting SteamFriends002 interface...");

            SteamFriends002 = SteamClient012.GetISteamFriends <ISteamFriends002>(_user, _pipe);

            if (SteamFriends002 == null)
            {
                _log.Error("Failed to obtain Steam friends (002)");
                throw new SteamException("Failed to obtain Steam friends (002)");
            }

            _log.Debug("Getting SteamFriends014 interface...");

            SteamFriends014 = SteamClient012.GetISteamFriends <ISteamFriends014>(_user, _pipe);

            if (SteamFriends014 == null)
            {
                _log.Error("Failed to obtain Steam friends (013)");
                throw new SteamException("Failed to obtain Steam friends (013)");
            }

            SteamApps001 = SteamClient012.GetISteamApps <ISteamApps001>(_user, _pipe);

            if (SteamApps001 == null)
            {
                _log.Error("Failed to obtain SteamApps006");
                throw new SteamException("Failed to obtain SteamApps006");
            }

            SteamApps006 = SteamClient012.GetISteamApps <ISteamApps006>(_user, _pipe);

            if (SteamApps006 == null)
            {
                _log.Error("Failed to obtain Steam apps (006)");
                throw new SteamException("Failed to obtain Steam apps (006)");
            }

            SteamInstallPath = Steamworks.GetInstallPath();
            SteamConfigPath  = Path.Combine(SteamInstallPath, "config", "config.vdf");

            _log.DebugFormat("Steam installed at {0}, config at {1}", SteamInstallPath, SteamConfigPath);

            // Set up callbacks
            _log.Debug("Setting up Steam callbacks...");
            _personaStateChange        = new Callback <PersonaStateChange_t>(HandlePersonaStateChange);
            _friendProfileInfoResponse = new Callback <FriendProfileInfoResponse_t>(HandleFriendProfileInfoResponse);
            _friendAdded         = new Callback <FriendAdded_t>(HandleFriendAdded);
            _friendChatMessage   = new Callback <FriendChatMsg_t>(HandleFriendChatMessage);
            _appEventStateChange = new Callback <AppEventStateChange_t>(HandleAppEventStateChange);

            LocalUser = new LocalUser(this);
            Friends   = new Friends(this);
            Apps      = new Apps(this);

            // Spawn dispatch thread
            CallbackDispatcher.SpawnDispatchThread(_pipe);
        }