コード例 #1
0
        void TimerOnElapsed(object sender)
        {
            try
            {
                if (tickCounter % 300 == 0)
                {
                    if (!IsOnline)
                    {
                        if (SteamAPI.Init() && SteamAPI.IsSteamRunning())
                        {
                            IsOnline = true;
                            SteamOnline();
                        }
                    }
                }
                if (IsOnline)
                {
                    if (SteamAPI.IsSteamRunning())
                    {
                        SteamAPI.RunCallbacks();
                    }
                    else
                    {
                        IsOnline = false;
                        SteamOffline();
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
            }

            tickCounter++;
        }
コード例 #2
0
ファイル: CoreSocialModule.cs プロジェクト: egshels/Sources
        public void Initialize()
        {
            //IL_000b: Unknown result type (might be due to invalid IL or missing references)
            _instance = this;
            if (SteamAPI.RestartAppIfNecessary(new AppId_t(105600u)))
            {
                Environment.Exit(1);
                return;
            }
            if (!SteamAPI.Init())
            {
                MessageBox.Show(Language.GetTextValue("Error.LaunchFromSteam"), Language.GetTextValue("Error.Error"));
                Environment.Exit(1);
            }
            IsSteamValid = true;
            Thread thread = new Thread(SteamCallbackLoop);

            thread.IsBackground = true;
            thread.Start();
            Thread thread2 = new Thread(SteamTickLoop);

            thread2.IsBackground = true;
            thread2.Start();
            Main.OnTickForThirdPartySoftwareOnly += PulseSteamTick;
            Main.OnTickForThirdPartySoftwareOnly += PulseSteamCallback;
            if (Platform.get_IsOSX())
            {
                _onOverlayActivated = Callback <GameOverlayActivated_t> .Create((DispatchDelegate <GameOverlayActivated_t>) OnOverlayActivated);
            }
        }
コード例 #3
0
ファイル: ModBuilder.cs プロジェクト: GergardDeadland/modkit
 public void Init()
 {
     if (!_init)
     {
         _init = SteamAPI.Init();
     }
 }
コード例 #4
0
        public void Initialize()
        {
            var gamePath = CoreContext.LaunchService.GamePath;

            if (gamePath == null)
            {
                MessageBox.Show("Soulstorm steam game not found");
                return;
            }

            if (SteamAPI.RestartAppIfNecessary(new AppId_t(9450)))
            {
                RestartAsSoulstormExe();
                return;
            }

            if (!SteamAPI.Init())
            {
                throw new Exception("Cant init SteamApi");
            }

            var appId = SteamUtils.GetAppID();

            if (appId.m_AppId != 9450)
            {
                throw new Exception("Wrong App Id!");
            }

            IsInitialized = true;
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: KidoHyde/OpenModManager
        static void Main()
        {
            bool steam = SteamAPI.Init();

            if (!steam)
            {
                MessageBox.Show("SteamAPI initialization failed! (is Steam running/installed?)");
                Environment.Exit(0);
            }

            if (!Environment.Is64BitOperatingSystem || !Environment.Is64BitProcess)
            {
                MessageBox.Show("This app needs 64-bit operating environment and operating system!");
                Environment.Exit(0);
            }

            Automation.AddAutomationEventHandler(
                eventId: WindowPattern.WindowOpenedEvent,
                element: AutomationElement.RootElement,
                scope: TreeScope.Children,
                eventHandler: OnWindowOpened);

            Directory.SetCurrentDirectory(Path.GetDirectoryName(Engine.GameFinder.FindGameDir()));
            Uploader = new ModUploader();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainWindow());
        }
コード例 #6
0
 static void Main(string[] args)
 {
     try{
         if (!SteamAPI.Init())
         {
             Console.WriteLine("SteamAPI Failed to initialize.");
             return;
         }
         else
         {
             WorkshopIndexer.Index();
             foreach (WorkshopLevel level in WorkshopIndexer.levels)
             {
                 level.getLeaderboard();
                 string path = "output/" + level.fileName + ".json";
                 string json = JsonConvert.SerializeObject(level, Formatting.Indented);
                 System.IO.File.WriteAllText(path, json);
             }
             SteamAPI.Shutdown();
         }
     }
     catch (DllNotFoundException e) {
         Console.WriteLine(e);
         return;
     }
 }
コード例 #7
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();
                }
            }
        }
コード例 #8
0
ファイル: SteamMgr.cs プロジェクト: shrubba/planetexplorers
    private void Awake()
    {
        steamId = CSteamID.Nil;
#if SteamVersion
        if (SteamAPI.RestartAppIfNecessary(new AppId_t(237870u)))
        {
            Debug.LogError("Steamworks does not start from steam.");
            Application.Quit();
            return;
        }

        m_bInitialized = SteamAPI.Init();
        if (!m_bInitialized)
        {
            Debug.LogError("[Steamworks] SteamAPI_Init() failed.");
            Application.Quit();
            return;
        }

        SteamClient.SetWarningMessageHook(new SteamAPIWarningMessageHook_t(SteamAPIDebugTextHook));
        SteamUtils.SetOverlayNotificationPosition(ENotificationPosition.k_EPositionTopRight);
        SteamRemoteStorage.SetCloudEnabledForApp(true);

        steamId = SteamUser.GetSteamID();
        if (LogFilter.logDebug)
        {
            Debug.LogFormat("<color=red>Steam id:[{0}]</color>", steamId);
        }

        enabled = true;
#else
        Destroy(gameObject);
#endif
    }
コード例 #9
0
        public static void Start()
        {
            if (SteamAPI.RestartAppIfNecessary(APP_ID))
            {
                return;
            }
            if (!SteamAPI.Init())
            {
                throw new Exception("SteamAPI.Init() failed");
            }
            bool userStatsReceived = false;

            Callback <UserStatsReceived_t> .Create(delegate
            {
                userStatsReceived = true;
            });

            if (!SteamUserStats.RequestCurrentStats())
            {
                throw new Exception("SteamUserStats.RequestCurrentStats() failed");
            }
            Achievements.OnUnlock += delegate(string name)
            {
                if (!userStatsReceived || !SteamUserStats.SetAchievement(name) || SteamUserStats.StoreStats())
                {
                    return;
                }
                throw new Exception("SteamUserStats.StoreStats() failed");
            };
            Platform.Init();
            using Game game = new Game();
            game.OnUpdate  += SteamAPI.RunCallbacks;
            game.RunGame();
            SteamAPI.Shutdown();
        }
コード例 #10
0
    public static void Initialize()
    {
        // Initializes the Steamworks API.
        // If this returns false then this indicates one of the following conditions:
        // [*] The Steam client isn't running. A running Steam client is required to provide implementations of the various Steamworks interfaces.
        // [*] The Steam client couldn't determine the App ID of game. If you're running your application from the executable or debugger directly then you must have a [code-inline]steam_appid.txt[/code-inline] in your game directory next to the executable, with your app ID in it and nothing else. Steam will look for this file in the current working directory. If you are running your executable from a different directory you may need to relocate the [code-inline]steam_appid.txt[/code-inline] file.
        // [*] Your application is not running under the same OS user context as the Steam client, such as a different user or administration access level.
        // [*] Ensure that you own a license for the App ID on the currently active Steam account. Your game must show up in your Steam library.
        // [*] Your App ID is not completely set up, i.e. in Release State: Unavailable, or it's missing default packages.
        // Valve's documentation for this is located here:
        // https://partner.steamgames.com/doc/sdk/api#initialization_and_shutdown
        failureReason = SteamAPI.Init();
        Initialized   = failureReason == FailureReason.None;
        if (!Initialized)
        {
            currentError = "[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information.\nFailure reason: " + failureReason;
            OnInitialized.Invoke(currentError, failureReason);
            return;
        }

        currentError      = null;
        s_EverInitialized = true;

        OnInitialized?.Invoke(currentError, failureReason);
    }
コード例 #11
0
 static void Main(string[] args)
 {
     try
     {
         long appId;
         if (args.Length == 0)
         {
             Application.EnableVisualStyles();
             SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
             Application.Run(new frmMain());
         }
         else
         {
             appId = long.Parse(args[0]);
             Environment.SetEnvironmentVariable("SteamAppId", appId.ToString());
             if (!SteamAPI.Init())
             {
                 return;
             }
             SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
             Application.Run();
             return;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return;
     }
 }
コード例 #12
0
        public static void InternalInit()
        {
            TxtEditor.MakeTextFile("steam_appid");
            TxtEditor.WriteAllLines("steam_appid", new string[] { appID.ToString() });
            TxtEditor.MakeTextFile("Logs", "SteamLog");

            if (!Packsize.Test())
            {
                throw new Exception("[Steamworks.NET] Packsize Test returned false, the wrong version of Steamworks.NET is being run in this platform.");
            }
            if (!DllCheck.Test())
            {
                throw new Exception("[Steamworks.NET] DllCheck Test returned false, One or more of the Steamworks binaries seems to be the wrong version.");
            }


            try
            {
                if (SteamAPI.RestartAppIfNecessary((AppId_t)appID))
                {
                    Game1.GameExit = true;
                }
            }
            catch (System.DllNotFoundException e)
            {
                Game1.GameExit = true;
                throw new Exception("[Steamworks.NET] Could not load [lib]steam_api.dll/so/dylib. It's likely not in the correct location. Refer to the README for more details.\n" + e);
            }
            SteamAPI.Init();
        }
コード例 #13
0
        protected override void Initialize()
        {
            try
            {
                if (!SteamAPI.Init())
                {
                    Console.WriteLine("SteamAPI.Init() failed!");
                }
                else
                {
                    IsSteamRunning = true;

                    SteamUtils.SetOverlayNotificationPosition(ENotificationPosition.k_EPositionBottomRight);

                    Exiting += Game1_Exiting;
                }
            }
            catch (DllNotFoundException e)
            {
                // We check this here as it will be the first instance of it.
                Console.WriteLine(e);
                Exit();
            }

            Window.Position = new Point(GraphicsDevice.DisplayMode.Width / 2 - graphics.PreferredBackBufferWidth / 2,
                                        GraphicsDevice.DisplayMode.Height / 2 - graphics.PreferredBackBufferHeight / 2 - 25);

            base.Initialize();
        }
コード例 #14
0
ファイル: SteamStarter.cs プロジェクト: Abishai2007/actools
        private static void InitializeInner()
        {
            var initialized = SteamAPI.InitSafe();

            for (var i = 0; i < 3 && !initialized; i++)
            {
                Logging.Debug($"Delayed Steam initialization, attempt #{i + 1} {(SteamAPI.IsSteamRunning() ? "" : "(Steam not running)")}");
                Thread.Sleep(150);

                try {
                    SteamAPI.Shutdown();
                } catch (Exception e) {
                    Logging.Debug("Steam API shutdown not required: " + e);
                }

                initialized = SteamAPI.Init();
            }

            if (!initialized)
            {
                Logging.Debug("Still not initialized…");

                if (!SteamAPI.RestartAppIfNecessary(new AppId_t(244210u)))
                {
                    MessageBox.Show("Steam can’t be initialized.", "Steam Inactive", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }

                Environment.Exit(0);
            }

            RunCallbacks().Forget();
            SteamUtils.SetOverlayNotificationPosition(ENotificationPosition.k_EPositionBottomLeft);
        }
コード例 #15
0
 private bool tryToGetSteamUID(bool showAlerts)
 {
     SteamAPI.Init();
     if (SteamAPI.IsSteamRunning())
     {
         startSteam.Text = "STEAM STARTED !";
         try
         {
             this.SteamUUID = SteamUser.GetSteamID().ToString();
             SteamAPI.Shutdown();
             this.DialogResult = DialogResult.OK;
             this.Close();
         }
         catch (Exception de)
         {
             if (showAlerts)
             {
                 MetroMessageBox.Show(this, "Veuillez vous connecter sur Steam.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
     else
     {
         if (showAlerts)
         {
             MetroMessageBox.Show(this, "Steam n'est toujours pas lancé...", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     return(false);
 }
コード例 #16
0
ファイル: Workshop.cs プロジェクト: barricade823/DSTEd-C
        public void Init()
        {
            if (!SteamAPI.Init() && !this.initalized)
            {
                Logger.Info("Steam-INIT FAILED! Retry in 5 Seconds...");
                return;
            }

            this.initalized = true;

            if (SteamAPI.IsSteamRunning() && !this.running)
            {
                this.running = true;

                Task.Run(() => {
                    while (true)
                    {
                        if (this.queue.Count >= 1)
                        {
                            Logger.Info("Enqueue Call!");
                            Action callback = this.queue[0];
                            callback();
                            this.queue.RemoveAt(0);
                            Thread.Sleep(100);
                        }

                        SteamAPI.RunCallbacks();
                        Thread.Sleep(100);
                    }
                });

                Logger.Info("ID: " + this.GetSteamID() + ", Name: " + this.GetUsername() + ", Account: " + this.GetAccountID());
            }
        }
コード例 #17
0
ファイル: SteamHelper.cs プロジェクト: s-yi/StardewValley
        public void Initialize()
        {
            try
            {
                active = SteamAPI.Init();
                Console.WriteLine("Steam logged on: " + SteamUser.BLoggedOn().ToString());
                if (active)
                {
                    Console.WriteLine("Initializing GalaxySDK");
                    GalaxyInstance.Init(new InitParams("48767653913349277", "58be5c2e55d7f535cf8c4b6bbc09d185de90b152c8c42703cc13502465f0d04a", "."));
                    encryptedAppTicketResponse = CallResult <EncryptedAppTicketResponse_t> .Create(onEncryptedAppTicketResponse);

                    galaxyAuthListener        = new GalaxyHelper.AuthListener(onGalaxyAuthSuccess, onGalaxyAuthFailure, onGalaxyAuthLost);
                    galaxyStateChangeListener = new GalaxyHelper.OperationalStateChangeListener(onGalaxyStateChange);
                    Console.WriteLine("Requesting Steam app ticket");
                    SteamAPICall_t handle = SteamUser.RequestEncryptedAppTicket(new byte[0], 0);
                    encryptedAppTicketResponse.Set(handle);
                    ConnectionProgress++;
                }
            }
            catch (Exception value)
            {
                Console.WriteLine(value);
                active             = false;
                ConnectionFinished = true;
            }
            if (active)
            {
                gameOverlayActivated = Callback <GameOverlayActivated_t> .Create(onGameOverlayActivated);

                gamepadTextInputDismissed = Callback <GamepadTextInputDismissed_t> .Create(OnKeyboardDismissed);
            }
        }
コード例 #18
0
        static void Main(string[] args)
        {
            if (!SteamAPI.Init())
            {
                ExitWithMessage(-1, "Could not init Steam API.");
            }

            try
            {
                InventoryDemo demo = new InventoryDemo();
                demo.RunDemo();
                while (!demo.IsDemoComplete)
                {
                    SteamAPI.RunCallbacks();
                    //System.Threading.Thread.Sleep(16);
                }
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey(true);
            }
            catch (Exception ex)
            {
                ExitWithMessage(-2, "Something failed: " + ex.Message);
            }
            finally
            {
                SteamAPI.Shutdown();
            }
        }
コード例 #19
0
        public void getGame()
        {
            if (!Program.asBot)
            {
                Environment.SetEnvironmentVariable("SteamAppId", "440");
                if (!SteamAPI.Init())
                {
                }
            }

            ArrayList games = Program.GetGames();

            SteamAPI.Shutdown();
            string[] gameList = new string[games.Count];
            for (int i = 0; i < games.Count; i++)
            {
                Game item = (Game)games[i];
                gameList[i] = item.Id + "`" + item.Name;
            }
            if (Program.asBot)
            {
                System.IO.File.WriteAllLines("bot-game-list.txt", gameList);
            }
            else
            {
                System.IO.File.WriteAllLines("game-list.txt", gameList);
            }
            Application.Exit();
        }
コード例 #20
0
        public SteamPlatform()
        {
            Log.info("Initializing Steam integration...");
            if (!SteamAPI.Init())
            {
                Log.warn("Failed to initialize Steam!");
                IPlatform.instance = new DummyPlatform(); // I don't even know if this will work how I want it
                return;
            }
            initSuccess = true;

            warningHook = new SteamAPIWarningMessageHook_t(onSteamWarning);
            SteamClient.SetWarningMessageHook(warningHook);

            overlayCallback = Callback <GameOverlayActivated_t> .Create(onOverlay);

            sessReqCallback = Callback <P2PSessionRequest_t> .Create(onP2PSessionRequest);

            sessConnFailCallback = Callback <P2PSessionConnectFail_t> .Create(onP2PConnectionFail);

            connUpdate = new Thread(() => { Log.debug("Starting steam listen thread.");  while (true)
                                            {
                                                SteamStream.update();
                                            }
                                    });
            connUpdate.Start();
        }
コード例 #21
0
 public static bool Init()
 {
     lock (Mutex)
     {
         return(SteamAPI.Init());
     }
 }
コード例 #22
0
ファイル: Surrounded.cs プロジェクト: Akrivus/Surrounded
        // The program's entry point.
        public static void Main(string[] args)
        {
            // Set the static game variables.
            Surrounded.Options = Options.Load(args.Length > 0 ? args[0] : "options");
            Surrounded.Icon    = new Image(Path.Combine(Environment.CurrentDirectory, "icon.png"));
            Surrounded.RNG     = new Random();

            // Check the Steam API.
            Surrounded.SteamOnline = SteamAPI.Init();
            if (Surrounded.SteamOnline)
            {
                Console.WriteLine("Steam is connected!");
                Console.Write("Username: "******"Steam is not connected.");
            }

            // Load up the other game stuff.
            Surrounded.Player = new Player();
            Surrounded.Map    = new Map(Surrounded.Player, "default");

            // Start the game.
            Surrounded.Instance = new Surrounded();
        }
コード例 #23
0
        public static void ConnectToSteam()
        {
            Environment.SetEnvironmentVariable("SteamAppID", TTS_APP_ID);
            bool initialized = SteamAPI.Init();

            if (!initialized)
            {
                // SteamAPI uses the app id from the environment variable, but if it's
                // not available, it uses a steam_appid file.
                try
                {
                    File.WriteAllText("steam_appid.txt", TTS_APP_ID);
                    initialized = SteamAPI.Init();
                    File.Delete("steam_appid.txt");
                }
                catch
                {
                    // Failure wriitng, maybe lack of privileges
                }
            }

            if (!initialized)
            {
                throw new Exception("Cannot connect to TTS with ID " + TTS_APP_ID + ". "
                                    + "Plese ensure the Steam Client is running with the same privileges and "
                                    + "account as the user who is launching the tts-cloud-manager.");
            }
        }
コード例 #24
0
        protected override void OnValidAwake()
        {
            base.OnValidAwake();

            if (s_everInialized)
            {
                // This is almost always an error.
                // The most common case where this happens is when SteamManager gets destroyed because of Application.Quit(),
                // and then some Steamworks code in some other OnDestroy gets called afterwards, creating a new SteamManager.
                // You should never call Steamworks functions in OnDestroy, always prefer OnDisable if possible.
                throw new System.Exception("Tried to Initialize the SteamAPI twice in one session!");
            }

            if (!Packsize.Test())
            {
                Debug.LogError("[Steamworks.NET] Packsize Test returned false, the wrong version of Steamworks.NET is being run in this platform.", this);
            }

            if (!DllCheck.Test())
            {
                Debug.LogError("[Steamworks.NET] DllCheck Test returned false, One or more of the Steamworks binaries seems to be the wrong version.", this);
            }

            try
            {
                // If Steam is not running or the game wasn't started through Steam, SteamAPI_RestartAppIfNecessary starts the
                // Steam client and also launches this game again if the User owns it. This can act as a rudimentary form of DRM.
                if (SteamAPI.RestartAppIfNecessary(APP_ID))
                {
                    Application.Quit();
                    return;
                }
            }
            catch (System.DllNotFoundException e)
            { // We catch this exception here, as it will be the first occurence of it.
                Debug.LogError("[Steamworks.NET] Could not load [lib]steam_api.dll/so/dylib. It's likely not in the correct location. Refer to the README for more details.\n" + e, this);

                Application.Quit();
                return;
            }

            // Initializes the Steamworks API.
            // If this returns false then this indicates one of the following conditions:
            // [*] The Steam client isn't running. A running Steam client is required to provide implementations of the various Steamworks interfaces.
            // [*] The Steam client couldn't determine the App ID of game. If you're running your application from the executable or debugger directly then you must have a [code-inline]steam_appid.txt[/code-inline] in your game directory next to the executable, with your app ID in it and nothing else. Steam will look for this file in the current working directory. If you are running your executable from a different directory you may need to relocate the [code-inline]steam_appid.txt[/code-inline] file.
            // [*] Your application is not running under the same OS user context as the Steam client, such as a different user or administration access level.
            // [*] Ensure that you own a license for the App ID on the currently active Steam account. Your game must show up in your Steam library.
            // [*] Your App ID is not completely set up, i.e. in [code-inline]Release State: Unavailable[/code-inline], or it's missing default packages.
            // Valve's documentation for this is located here:
            // https://partner.steamgames.com/doc/sdk/api#initialization_and_shutdown
            _initialized = SteamAPI.Init();
            if (!_initialized)
            {
                Debug.LogError("[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information.", this);

                return;
            }

            s_everInialized = true;
        }
コード例 #25
0
ファイル: NetworkSteam.cs プロジェクト: mahoep/BannerlordCoop
        public bool Connect()
        {
            if (!IsConnected)
            {
                try
                {
                    IsConnected = SteamAPI.Init();
                    if (!IsConnected)
                    {
                        Logger.Error("Steam API failed to Initialize");
                    }
                    else
                    {
                        SteamClient.SetWarningMessageHook(
                            (severity, text) => Console.WriteLine(text.ToString()));
                    }
                }
                catch (Exception e)
                {
                    Logger.Error(e);
                }
            }

            return(IsConnected);
        }
コード例 #26
0
 protected void InitializeSteam()
 {
     if (!SteamAPI.Init())
     {
         throw new Exception("Could not initialize SteamAPI");
     }
 }
コード例 #27
0
ファイル: SteamService.cs プロジェクト: gordon861/Torch
        public SteamService(bool isDedicated, uint appId)
            : base(true, appId)
        {
            SteamServerAPI.Instance.Dispose();
            _steamServerAPISetter.Invoke(this, null);
            _steamGameServerSetter.Invoke(this, null);
            _steamAppIdSetter.Invoke(this, appId);

            if (isDedicated)
            {
                _steamServerAPISetter.Invoke(this, null);
                _steamGameServerSetter.Invoke(this, new MySteamGameServer());
            }
            else
            {
                SteamAPI steamApi = SteamAPI.Instance;
                _steamApiSetter.Invoke(this, steamApi);
                _steamIsActiveSetter.Invoke(this, steamApi.Init());

                if (IsActive)
                {
                    _steamUserIdSetter.Invoke(this, steamApi.GetSteamUserId());
                    _steamUserNameSetter.Invoke(this, steamApi.GetSteamName());
                    _steamOwnsGameSetter.Invoke(this, steamApi.HasGame());
                    _steamUserUniverseSetter.Invoke(this, (MyGameServiceUniverse)steamApi.GetSteamUserUniverse());
                    _steamBranchNameSetter.Invoke(this, steamApi.GetBranchName());
                    steamApi.LoadStats();

                    _steamInventoryAPISetter.Invoke(this, new MySteamInventory());
                    RegisterCallbacks(this);
                }
            }

            _steamPeer2PeerSetter.Invoke(this, new MySteamPeer2Peer());
        }
コード例 #28
0
        private void Start()
        {
#if !STEAMWORKS
            Debug.LogError("Missing STEAMWORKS define. This menu will not work without it");
            throw new SystemException("Missing STEAMWORKS define. This menu will not work without it");
#endif

            SteamAPI.Init();

            GetPlayerSteamInformation();

            for (int i = 0; i < ToggledButtons.Length; ++i)
            {
                Button btn = ToggledButtons[i].GetComponent <Button>();
                if (btn != null)
                {
                    _uiButtons.Add(btn);
                }
            }

            if (useMainThreadManagerForRPCs)
            {
                Rpc.MainThreadRunner = MainThreadManager.Instance;
            }
        }
コード例 #29
0
 private void Awake()
 {
     if (s_instance != null)
     {
         Object.Destroy(base.gameObject);
     }
     else
     {
         s_instance = this;
         Object.DontDestroyOnLoad(base.gameObject);
         if (!Packsize.Test())
         {
             Debug.LogError("[Steamworks.NET] Packsize Test returned false, the wrong version of Steamworks.NET is being run in this platform.", this);
         }
         if (!DllCheck.Test())
         {
             Debug.LogError("[Steamworks.NET] DllCheck Test returned false, One or more of the Steamworks binaries seems to be the wrong version.", this);
         }
         m_bInitialized = SteamAPI.Init();
         if (!m_bInitialized)
         {
             Debug.LogError("[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information.", this);
         }
     }
 }
コード例 #30
0
        }                                        //Checking the last time that the games list with names has been updated and pushing an update if needed

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                //Start of Initialization shit
                SteamAPI.Init(); //Must initialise SteamApi before using steamwork functions
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                FreeGamesListFnc();
                Steamnamesuptodatecheck();
                steamid = SteamUser.GetSteamID().ToString();
                string name        = SteamFriends.GetPersonaName();
                string steamlevel  = SteamUser.GetPlayerSteamLevel().ToString();
                int    friendCount = SteamFriends.GetFriendCount(EFriendFlags.k_EFriendFlagImmediate);
                SteamFriendCountBox.Text = friendCount.ToString();
                SteamNameBox.Text        = name;
                SteamLevelBox.Text       = steamlevel;
                SteamIDBox.Text          = steamid;
                GetOwnedSteamGames(steamid, OwnedGamesLBox);
                OwnedGamesBox.Text = OwnedGamesLBox.Items.Count.ToString();
                //End of initialization shit
            }
            catch (Exception)
            {
                MessageBox.Show("Steam not running!" + "\n" + "Terminating program", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); //Error messagebox
                Application.Exit();                                                                                                        //Used to Exit program
            }
        }                                                                                                                                  //Initializing everything