Beispiel #1
0
        public StatsAccessor( SteamClient008 client, SteamPipeHandle pipe, SteamUserHandle user, uint lgameID )
        {
            stats002 = ( SteamUserStats002 )client.GetISteamUserStats( user, pipe, SteamUserStats002.InterfaceVersion );
            stats004 = ( SteamUserStats004 )client.GetISteamUserStats( user, pipe, SteamUserStats004.InterfaceVersion );

            thisGameID = new GameID( lgameID );

            if ( stats002.RequestCurrentStats( thisGameID ) && stats004.RequestCurrentStats() )
            {
                bActive = true;
            }
        }
Beispiel #2
0
        public StatsAccessor(SteamClient008 client, SteamPipeHandle pipe, SteamUserHandle user, uint lgameID)
        {
            stats002 = ( SteamUserStats002 )client.GetISteamUserStats(user, pipe, SteamUserStats002.InterfaceVersion);
            stats004 = ( SteamUserStats004 )client.GetISteamUserStats(user, pipe, SteamUserStats004.InterfaceVersion);


            thisGameID = new GameID(lgameID);

            if (stats002.RequestCurrentStats(thisGameID) && stats004.RequestCurrentStats())
            {
                bActive = true;
            }
        }
Beispiel #3
0
        private void InitSteamworks()
        {
            int error;

            steamClient = ( SteamClient008 )Steamworks.CreateInterface(SteamClient008.InterfaceVersion, out error);

            if (error > 0 || steamClient == null)
            {
                Util.ShowFatalError(null, "Unable get SteamClient interface.");
                Initialized = false;
                return;
            }

            pipe = steamClient.CreateSteamPipe();
            if (pipe == SteamPipeHandle.InvalidHandle)
            {
                Util.ShowFatalError(null, "Unable to create steam pipe.\n\nPlease ensure steam is running.");
                Initialized = false;
                return;
            }

            user = steamClient.ConnectToGlobalUser(pipe);
            if (user == new SteamUserHandle(0))
            {
                Util.ShowFatalError(null, "Unable to connect to global user.\n\nPlease ensure you are logged into steam.");
                Initialized = false;
                return;
            }

            steamFriends = ( SteamFriends001 )steamClient.GetISteamFriends(user, pipe, SteamFriends001.InterfaceVersion);
            if (steamFriends == null)
            {
                Util.ShowFatalError(null, "Unable to get SteamFriends interface.");
                Initialized = false;
                return;
            }
        }
Beispiel #4
0
        private void MainForm_Load( object sender, EventArgs e )
        {
            ClassEditControl scout = new ClassEditControl( "Scout" );
            scout.ClassImage = Properties.Resources.scout;

            // heavy
            ClassEditControl heavy = new ClassEditControl( "Heavy" );
            heavy.ClassImage = Properties.Resources.heavy;

            // medic
            ClassEditControl medic = new ClassEditControl( "Medic" );
            medic.ClassImage = Properties.Resources.medic;

            // soldier
            ClassEditControl soldier = new ClassEditControl( "Soldier" );
            soldier.ClassImage = Properties.Resources.soldier;

            // engi
            ClassEditControl engineer = new ClassEditControl( "Engineer" );
            engineer.ClassImage = Properties.Resources.engineer;

            // spy
            ClassEditControl spy = new ClassEditControl( "Spy" );
            spy.ClassImage = Properties.Resources.spy;

            // sniper
            ClassEditControl sniper = new ClassEditControl( "Sniper" );
            sniper.ClassImage = Properties.Resources.sniper;

            // demo
            ClassEditControl demo = new ClassEditControl( "Demoman" );
            demo.ClassImage = Properties.Resources.demoman;

            // pyro
            ClassEditControl pyro = new ClassEditControl( "Pyro" );
            pyro.ClassImage = Properties.Resources.pyro;

            flowLayoutPanel1.Controls.Add( scout );
            flowLayoutPanel1.Controls.Add( heavy );
            flowLayoutPanel1.Controls.Add( medic );
            flowLayoutPanel1.Controls.Add( soldier );
            flowLayoutPanel1.Controls.Add( engineer );
            flowLayoutPanel1.Controls.Add( spy );
            flowLayoutPanel1.Controls.Add( sniper );
            flowLayoutPanel1.Controls.Add( demo );
            flowLayoutPanel1.Controls.Add( pyro );

            toolStripStatusLabel1.Text = "Initializing steamworks...";

            try
            {
                int error;
                client = ( SteamClient008 )Steamworks.CreateInterface( SteamClient008.InterfaceVersion, out error );

                if ( client == null )
                    throw new InvalidOperationException( "Unable to create ISteamClient." );

                pipe = client.CreateSteamPipe();
                if ( pipe == SteamPipeHandle.InvalidHandle )
                    throw new InvalidOperationException( "Unable to create steam pipe." );

                user = client.ConnectToGlobalUser( pipe );

                clientEngine = ( ClientEngine )Steamworks.CreateInterface( ClientEngine.InterfaceVersion, out error );

                if ( clientEngine == null )
                    throw new InvalidOperationException( "Unable to create IClientEngine." );
            }
            catch (Exception ex)
            {
                MessageBox.Show( this, "Unable to initialize steamworks. Please ensure the following:\n\n" +
                    " * steamclient.dll, tier0_s.dll, vstdlib_s.dll, are present in the running directory\n" +
                    " * You are logged into steam and are online.\n\nAdditional Details: " + ex.Message, "TF2 Stats Suite"
                );

                this.Close();
                return;
            }

            toolStripStatusLabel1.Text = "Loading stats...";

            statsAcc = new StatsAccessor( client, pipe, user, 440 );

            steamUser = ( SteamUser012 )client.GetISteamUser( user, pipe, SteamUser012.InterfaceVersion );
            clientUtils = ( ClientUtils )clientEngine.GetIClientUtils( pipe, ClientUtils.InterfaceVersion );

            clientUtils.SetAppIDForCurrentPipe( new AppID( 440 ) );

            foreach ( ClassEditControl cec in flowLayoutPanel1.Controls )
            {
                toolStripStatusLabel1.Text = "Loading stats for '" + cec.Class + "'...";
                cec.LoadStats( statsAcc );
                Application.DoEvents();
            }

            toolStripStatusLabel1.Text = "Stats fully loaded!";
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            int error;

            steamClient = (SteamClient008)Steamworks.CreateInterface(SteamClient008.InterfaceVersion, out error);
            if (steamClient == null)
            {
                Console.WriteLine("Unable to get SteamClient.");
                return;
            }

            pipe = steamClient.CreateSteamPipe();
            user = steamClient.ConnectToGlobalUser(pipe);


            _handler += new EventHandler(ConsoleEvent);
            SetConsoleCtrlHandler(_handler, true);

            steamFriends = ( SteamFriends001 )steamClient.GetISteamFriends(user, pipe, SteamFriends001.InterfaceVersion);
            steamUser    = (SteamUser012)steamClient.GetISteamUser(user, pipe, SteamUser012.InterfaceVersion);

            FriendsName = steamFriends.GetPersonaName();

            RelayTargets = new List <RelayUser>();

            ircClient = new IrcClient(RelayNick);
            ircClient.AlternateNickname = RelayNick + "`";

            ircClient.Debugger.Debugging = DebugMode.All;

            ConnectionParser connection = ircClient.ConnectionParser;
            MessageParser    message    = ircClient.MessageParser;

            connection.Connected   += new EventHandler <InfoEventArgs>(connection_Connected);
            message.ChannelMessage += new EventHandler <MessageEventArgs>(message_ChannelMessage);

            running = ircClient.Connect(RelayNetwork);

            DateTime lastUpdate = DateTime.Now;

            while (running)
            {
                ircClient.UpdateIn();

                if ((DateTime.Now - lastUpdate) >= RelayDelay && connected)
                {
                    ircClient.UpdateOut();
                    lastUpdate = DateTime.Now;
                }
                else
                {
                    ircClient.UpdateOut();
                }

                if (!connected)
                {
                    continue;
                }

                Callback        callback;
                SteamCallHandle steamCall;

                if (Steamworks.Steam_BGetCallback(pipe, out callback, out steamCall))
                {
                    Console.WriteLine("Callback: " + callback.CallbackNum);

                    if (callback.CallbackNum == FriendChatMsg.Callback)
                    {
                        FriendChatMsg chatMsg = ( FriendChatMsg )callback.CallbackObject;

                        SteamID sender   = new SteamID(chatMsg.Sender);
                        SteamID reciever = new SteamID(chatMsg.Reciever);

                        if (sender.Equals(steamUser.GetSteamID()))
                        {
                            Steamworks.Steam_FreeLastCallback(pipe);
                            continue;
                        }

                        string        msg;
                        FriendMsgType msgType;
                        steamFriends.GetChatMessage(reciever, ( int )chatMsg.ChatID, out msg, 400, out msgType);

                        if (msgType != FriendMsgType.Chat)
                        {
                            Steamworks.Steam_FreeLastCallback(pipe);
                            continue;
                        }

                        string senderStr = steamFriends.GetFriendPersonaName(sender);
                        msg = msg.Replace("\n", " ").Replace("\r", " ").Replace("DCC", "");

                        RelayUser ru = new RelayUser()
                        {
                            SteamID     = sender,
                            LastMessage = DateTime.Now.Subtract(TimeSpan.FromSeconds(1)),
                        };

                        if (!RelayTargets.Contains(ru))
                        {
                            RelayTargets.Add(ru);
                        }

                        RelayUser realUser = RelayTargets.Find(new Predicate <RelayUser>((ruser) => { return(ruser.SteamID.Equals(sender)); }));


                        if (msg.StartsWith("!relayon"))
                        {
                            realUser.RelayingIRC = true;
                            steamFriends.SendMsgToFriend(sender, FriendMsgType.ChatSent, "You are now added to the relay list.");
                        }
                        else if (msg.StartsWith("!relayoff"))
                        {
                            realUser.RelayingIRC = false;
                            steamFriends.SendMsgToFriend(sender, FriendMsgType.ChatSent, "You have been removed from the relay list.");
                        }
                        else
                        {
                            if (!realUser.RelayingIRC)
                            {
                                Steamworks.Steam_FreeLastCallback(pipe);
                                continue;
                            }

                            if ((DateTime.Now - realUser.LastMessage) >= TimeSpan.FromSeconds(1))
                            {
                                realUser.LastMessage = DateTime.Now;
                                ircClient.SendMessage(RelayChannel, senderStr + ": " + msg);
                            }
                            else
                            {
                                steamFriends.SendMsgToFriend(sender, FriendMsgType.ChatSent, "You are sending messages too fast.");
                            }
                        }
                    }

                    Steamworks.Steam_FreeLastCallback(pipe);
                }
            }
        }
Beispiel #6
0
        private void InitSteamworks()
        {
            int error;
            steamClient = ( SteamClient008 )Steamworks.CreateInterface( SteamClient008.InterfaceVersion, out error );

            if ( error > 0 || steamClient == null )
            {
                Util.ShowFatalError( null, "Unable get SteamClient interface." );
                Initialized = false;
                return;
            }

            pipe = steamClient.CreateSteamPipe();
            if ( pipe == SteamPipeHandle.InvalidHandle )
            {
                Util.ShowFatalError( null, "Unable to create steam pipe.\n\nPlease ensure steam is running." );
                Initialized = false;
                return;
            }

            user = steamClient.ConnectToGlobalUser( pipe );
            if ( user == new SteamUserHandle( 0 ) )
            {
                Util.ShowFatalError( null, "Unable to connect to global user.\n\nPlease ensure you are logged into steam." );
                Initialized = false;
                return;
            }

            steamFriends = ( SteamFriends001 )steamClient.GetISteamFriends( user, pipe, SteamFriends001.InterfaceVersion );
            if ( steamFriends == null )
            {
                Util.ShowFatalError( null, "Unable to get SteamFriends interface." );
                Initialized = false;
                return;
            }
        }
Beispiel #7
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            ClassEditControl scout = new ClassEditControl("Scout");

            scout.ClassImage = Properties.Resources.scout;

            // heavy
            ClassEditControl heavy = new ClassEditControl("Heavy");

            heavy.ClassImage = Properties.Resources.heavy;

            // medic
            ClassEditControl medic = new ClassEditControl("Medic");

            medic.ClassImage = Properties.Resources.medic;

            // soldier
            ClassEditControl soldier = new ClassEditControl("Soldier");

            soldier.ClassImage = Properties.Resources.soldier;

            // engi
            ClassEditControl engineer = new ClassEditControl("Engineer");

            engineer.ClassImage = Properties.Resources.engineer;

            // spy
            ClassEditControl spy = new ClassEditControl("Spy");

            spy.ClassImage = Properties.Resources.spy;

            // sniper
            ClassEditControl sniper = new ClassEditControl("Sniper");

            sniper.ClassImage = Properties.Resources.sniper;

            // demo
            ClassEditControl demo = new ClassEditControl("Demoman");

            demo.ClassImage = Properties.Resources.demoman;

            // pyro
            ClassEditControl pyro = new ClassEditControl("Pyro");

            pyro.ClassImage = Properties.Resources.pyro;

            flowLayoutPanel1.Controls.Add(scout);
            flowLayoutPanel1.Controls.Add(heavy);
            flowLayoutPanel1.Controls.Add(medic);
            flowLayoutPanel1.Controls.Add(soldier);
            flowLayoutPanel1.Controls.Add(engineer);
            flowLayoutPanel1.Controls.Add(spy);
            flowLayoutPanel1.Controls.Add(sniper);
            flowLayoutPanel1.Controls.Add(demo);
            flowLayoutPanel1.Controls.Add(pyro);


            toolStripStatusLabel1.Text = "Initializing steamworks...";

            try
            {
                int error;
                client = ( SteamClient008 )Steamworks.CreateInterface(SteamClient008.InterfaceVersion, out error);

                if (client == null)
                {
                    throw new InvalidOperationException("Unable to create ISteamClient.");
                }

                pipe = client.CreateSteamPipe();
                if (pipe == SteamPipeHandle.InvalidHandle)
                {
                    throw new InvalidOperationException("Unable to create steam pipe.");
                }

                user = client.ConnectToGlobalUser(pipe);

                clientEngine = ( ClientEngine )Steamworks.CreateInterface(ClientEngine.InterfaceVersion, out error);

                if (clientEngine == null)
                {
                    throw new InvalidOperationException("Unable to create IClientEngine.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Unable to initialize steamworks. Please ensure the following:\n\n" +
                                " * steamclient.dll, tier0_s.dll, vstdlib_s.dll, are present in the running directory\n" +
                                " * You are logged into steam and are online.\n\nAdditional Details: " + ex.Message, "TF2 Stats Suite"
                                );

                this.Close();
                return;
            }

            toolStripStatusLabel1.Text = "Loading stats...";

            statsAcc = new StatsAccessor(client, pipe, user, 440);

            steamUser   = ( SteamUser012 )client.GetISteamUser(user, pipe, SteamUser012.InterfaceVersion);
            clientUtils = ( ClientUtils )clientEngine.GetIClientUtils(pipe, ClientUtils.InterfaceVersion);

            clientUtils.SetAppIDForCurrentPipe(new AppID(440));

            foreach (ClassEditControl cec in flowLayoutPanel1.Controls)
            {
                toolStripStatusLabel1.Text = "Loading stats for '" + cec.Class + "'...";
                cec.LoadStats(statsAcc);
                Application.DoEvents();
            }

            toolStripStatusLabel1.Text = "Stats fully loaded!";
        }