示例#1
0
        public static bool GetServers(Action <Networking.ServerInfo> onServerFound, Action <Networking.ServerInfo> onServerRulesReceived, Action onFinished)
        {
            if (instance == null || !instance.isInitialized)
            {
                return(false);
            }

            var filter = new ServerList.Filter
            {
                { "appid", AppID.ToString() },
                { "gamedir", "Barotrauma" },
                { "secure", "1" }
            };

            //include unresponsive servers in the server list

            //the response is queried using the server's query port, not the game port,
            //so it may be possible to play on the server even if it doesn't respond to server list queries
            var query = instance.client.ServerList.Internet(filter);

            query.OnUpdate  += () => { UpdateServerQuery(query, onServerFound, onServerRulesReceived, includeUnresponsive: true); };
            query.OnFinished = onFinished;

            var localQuery = instance.client.ServerList.Local(filter);

            localQuery.OnUpdate  += () => { UpdateServerQuery(localQuery, onServerFound, onServerRulesReceived, includeUnresponsive: true); };
            localQuery.OnFinished = onFinished;

            return(true);
        }
        private async void btnAdd_ClickAsync(object sender, EventArgs e)
        {
            int AppID;

            if (this.appidInput.Text != "" && int.TryParse(this.appidInput.Text, out AppID))
            {
                if (Settings.Default.AlwaysIdleList.IndexOf(AppID.ToString()) != -1)
                {
                    MessageBox.Show("This Game has already been added!");
                    return;
                }
                Settings.Default.AlwaysIdleList.Add(AppID.ToString());
                Settings.Default.EnabledAlwaysIdleList.Add(AppID.ToString());
                Settings.Default.Save();
                int    ItemIndex = this.checkedListBox1.Items.Add(AppID.ToString());
                Object tmpRef    = this.checkedListBox1.Items[ItemIndex];
                AppIDList.Add(AppID);
                string AppName = await GetAppNameByID(AppID);

                if (tmpRef == this.checkedListBox1.Items[ItemIndex])
                {
                    this.checkedListBox1.Items[ItemIndex] = AppName;
                }
            }
        }
示例#3
0
        private string FormBuild_BuildApp()
        {
            const String  ta = "<textarea style=\"width:100%;\" class=\"Field\" rows=\"10\" cols=\"52\" ";
            string        buffer;
            StringBuilder myHTML = new StringBuilder();

            if (_BuildDB)
            {
                myHTML.Append("<p align=center>");
                buffer = AppID.ToString();
                myHTML.Append(HTMLToolsLink(buffer, String.Empty));
            }
            if (_ShowXML)
            {
                myHTML.Append(HTMLFieldLabelResize("XML", "XML"));
                myHTML.Append(ta).Append("id=\"XML\">").Append(appXML).Append("</textarea>");
            }
            if (_ShowSQL)
            {
                myHTML.Append(HTMLFieldLabelResize("SQL", "SQL"));
                myHTML.Append(ta).Append("id=\"SQL\">").Append(appSQL).Append("</textarea>");
            }
            if (_ShowASPX)
            {
                myHTML.Append(HTMLFieldLabelResize("ASPX", "ASPX"));
                myHTML.Append(ta).Append("id=\"ASPX\">").Append(appASPX).Append("</textarea>");
            }
            return(myHTML.ToString());
        }
示例#4
0
        private string FormBuild_LayoutFields()
        {
            StringBuilder myHTML = new StringBuilder();
            string        buffer, buffer2, buffer3;
            bool          YesNo = false;

            ds = EvoDB.GetData(EvoDB.BuildSQL("ID,label,type,typepix", "EvoDico_xfield", string.Format("formID={0}", AppID), " fpos,id", 0), _SqlConnectionDico, ref ErrorMsg);
            DataTable t0 = ds.Tables[0];
            int       ml = t0.Rows.Count;

            for (int i = 0; i < ml; i++)
            {
                myHTML.Append(EvoUI.HTMLInputHidden(string.Format("f_id{0}", (i + 1)), t0.Rows[i]["id"].ToString()));
            }
            myHTML.Append(HTMLStepTableHeader(5));
            buffer = HTMLlov("EvoDico_panel WHERE formID=" + AppID.ToString(), 0, xAttribute.label);
            for (int i = 0; i < ml; i++)
            {
                buffer3 = ClassEvenOrOdd(YesNo);
                myHTML.Append("<tr").Append(buffer3).Append(" valign=\"top\"><td>");
                buffer2 = (i + 1).ToString();
                myHTML.Append(EvoUI.HTMLIcon(_PathPix, t0.Rows[i]["typepix"].ToString(), t0.Rows[i]["type"].ToString()));
                myHTML.Append(t0.Rows[i][xAttribute.label]).Append("</td>");
                myHTML.Append("<td><input type=\"text\" name=\"f_w").Append(buffer2).Append("\" value=\"100\" ").Append(buffer3).Append("></td><td>");
                if (!string.IsNullOrEmpty(buffer))
                {
                    myHTML.Append("<select name=\"f_ft").Append(buffer2).Append("\" ").Append(buffer3).Append(" style=\"width:100%\">");
                    myHTML.Append(buffer).Append("</select>");
                }
                else
                {
                    myHTML.Append(lang_NA);
                }
                myHTML.Append(tag_cTDcTR);
                YesNo = !YesNo;
            }
            myHTML.Append("</table></span>");
            return(myHTML.ToString());
        }
示例#5
0
        static void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            // Check to see if we've logged on successfully.
            if (callback.Result != EResult.OK)
            {
                if (callback.Result == EResult.AccountLogonDenied)
                {
                    // Account has Steam Guard enabled.
                    Console.WriteLine("Unable to logon to Steam: This account is SteamGuard protected.");
                    isRunning = false;
                    return;
                }

                Console.WriteLine(":: Unable to logon to Steam: {0} / {1}", callback.Result, callback.ExtendedResult);

                isRunning = false;
                return;
            }

            Console.WriteLine(":: Successfully logged on!");

            // Start playing a game.
            var playGame = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);

            // Convert application IDs to array.
            int[] GameAppIDs = AppIDs.ToArray();

            // Loop application IDs to add.
            foreach (int AppID in GameAppIDs)
            {
                Console.WriteLine(":: Now playing game '{0}'!", AppID.ToString());
                playGame.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed {
                    game_id = new GameID(AppID)
                });
            }

            steamClient.Send(playGame);
        }
示例#6
0
 public string GetKey()
 {
     return(AppID.ToString() + "-" + ActionType.ToString());
 }
示例#7
0
        /// <summary>
        /// Checks if the Steam Application is running or updating by checking certain registry keys and updates the fields IsUpdating and IsRunning accordingly. Also, sets the RunningProcess field if the process pertaining to the app is found.
        /// </summary>
        public void UpdateAppStatus()
        {
            string regPath             = SteamAppsManager.REG_STEAM + "\\" + SteamAppsManager.REG_APPS_KEY + "\\" + AppID.ToString(); //We can know if the application is running or updating by checking certain values under this registry key.
            int    isRunningOrUpdating = Helper.HKCU_RegGetKeyInt(regPath, SteamAppsManager.REG_RUNNING_KEY);                         //The first value we check is if the application is running. Retrieve the value on registry using our helper method.

            if (isRunningOrUpdating < 0)
            {
                throw new NullReferenceException("Running key under " + regPath + " registry path is not found!");
            }
            else if (isRunningOrUpdating > 0)
            {
                if (_runningProc == null)
                {
                    string tExeName = _exeName;                                  //For thread safety purposes. Cache the string value.
                    _runningProc = Helper.FindAppProcess(_InstallDir, tExeName); //Only perform the search helper method when the process hasn't been located yet as the execution is costly.
                }
                else
                {
                    _runningProc.Refresh();     //Refresh the information about the process.
                    if (_runningProc.HasExited) //If Running process has already exited then set the _runningProc to null. This should also fix problems for launcher apps being set as the RunningProcess and never being updated when the main app has been launched.
                    {
                        _runningProc = null;
                    }
                }
                _isRunning = true;
            }
            else
            {
                _isRunning   = false;
                _runningProc = null; //Make sure to set the RunningProcess field to nothing.
            }

            isRunningOrUpdating = Helper.HKCU_RegGetKeyInt(regPath, SteamAppsManager.REG_UPDATING_KEY); //The next thing that we need to check is if the app is being updated by steam.

            if (isRunningOrUpdating < 0)                                                                //This one is less complex than for the "app is running" check as we only need to set the IsUpdating field to true or false.
            {
                throw new NullReferenceException("Updating key under " + regPath + " registry path is not found!");
            }
            else if (isRunningOrUpdating > 0)
            {
                _isUpdating = true;
            }
            else
            {
                _isUpdating = false;
            }
        }