static void Main() { // Mutex Mutex self = new Mutex(true, Application.StartupPath.GetHashCode().ToString(), out bool allow); if (!allow) { MessageBox.Show("已有一个CSI在运行中了 ...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(-1); } // Load local native Logging.Initialize(); // Load native steam binaries. SteamNative.Initialize(); // Check steam is running if (!SteamApi.IsSteamRunning()) { MessageBox.Show("请先运行Steam客户端.", "EZConfig4CSGO", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // Provide appId so it automatically creates a "steam_appid.txt" file. if (!SteamApi.Initialize(AppId)) { MessageBox.Show("初始化SteamApi失败.", "EZConfig4CSGO", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); }
public PCGamingWikiLocalizations(IPlayniteAPI PlayniteApi, string PluginUserDataPath) { _PlayniteApi = PlayniteApi; _PluginUserDataPath = PluginUserDataPath; steamApi = new SteamApi(_PluginUserDataPath); }
private static void Main(string[] args) { const int appId = 480; // Load native steam binaries. SteamNative.Initialize(); // Use steam stuff. if (SteamApi.IsSteamRunning()) { // Provide appId so it automatically creates a "steam_appid.txt" file. if (SteamApi.Initialize(appId)) { Console.WriteLine($"Logged in as: {SteamApi.SteamFriends.GetPersonaName()}"); } else { Console.WriteLine("SteamApi failed to initialize."); } } else { Console.WriteLine("Steam is not running."); } Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
/// <summary> /// update play time from steam library /// </summary> /// <param name="steamApiKey"></param> /// <param name="steamId"></param> static void UpdatePlayTimeFromSteamLibrary() { using (var tb = new TimedBlock("UpdatePlayTimeFromSteamLibrary()")) { try { var playTimes = SteamApi.ListPlayTimes(Settings.Default.SteamApiKey, Settings.Default.UserSteamId); foreach (var playTime in playTimes) { var steamAppId = playTime.Key; var game = Games.Values .SingleOrDefault(g => g.Data .SingleOrDefault(d => d is SteamDbInfoData && (d as SteamDbInfoData).AppId == steamAppId) != null); if (game == null) { continue; } var steamData = game.CustomData <SteamDbInfoData>(); if (steamData != null) { steamData.PlayTimeForEver = playTime.Value; } } } catch (Exception ex) { Log.WriteLine(ex.ToString()); } } }
private async void RunStatsRequestLoop() { var steamKey = Environment.GetEnvironmentVariable("STEAM_KEY"); SteamApi.Init(steamKey); var requestUri = BuildUri(); while (_running) { var apiResponse = await SteamApi.Request <SteamUserStatsForGameResponse>(requestUri, DefaultJsonOptions.Instance); var apiResponseContent = apiResponse.Content; var playerStats = apiResponseContent.PlayerStats; Logger.Info("Received stats of player {0} for {1}", playerStats.SteamId, playerStats.GameName); UpdateGameState(playerStats.Stats); var utcNow = DateTimeOffset.UtcNow; var offset = apiResponse.Expires.Subtract(utcNow); Logger.Trace("Next steam request in {0} (now: {1}, expires: {2})", offset, utcNow, apiResponse.Expires); await Task.Delay(offset); } SteamApi.Reset(); }
public LegionTdController(LegionTdContext context, SteamApi steamApi, IMemoryCache cache, IConfiguration configuration) { _db = context; _cache = cache; _steamApi = steamApi; _dedicatedServerKey = configuration["dedicatedServerKey"]; }
public RlCommands(SteamApi steam, ChannelCheck cc, IConfigurationRoot config) { _steam = steam; _cc = cc; _config = config; _rlStatsKey = $"{_config["RlStatsApi"]}"; _prefix = _config["prefix"]; _rlsClient = new RLSClient(_rlStatsKey); }
public InfoController( ISteamGameParser gameParser, ISteamProfileParser profileParser, SteamApi.ISteamApi steamApi) { this._gameParser = gameParser; this._profileParser = profileParser; this._steamApi = steamApi; this._cache = System.Web.HttpContext.Current.Cache; }
void FinalizeTransaction() { string orderId = web.Param("orderId"); string CustomerID = web.CustomerID(); // check that transaction was approved and get it transactionID SteamApi api = new SteamApi(); SteamXML.MicroTnxResponse resp = api.QueryTxn(orderId); //System.Diagnostics.Debug.WriteLine("@@@QueryTxn: " + api.lastData_); if (!ParseResponse(resp)) { return; } if (resp.params_.status != "Approved") { Response.Write("WO_5"); Response.Write(string.Format("bad status: {0}", resp.params_.status)); return; } // finalize transaction in steam. NOTE: f*****g steam give http error instead of valid answer here resp = api.FinalizeTxn(orderId); //System.Diagnostics.Debug.WriteLine("@@@FinalizeTxn: " + api.lastData_); if (!ParseResponse(resp)) { return; } // note: we can't pass transaction id as bigint here, because stream using *unsigned* int64. string transid = resp.params_.transid; // finalize transaction in DB and get new balance SqlCommand sqcmd = new SqlCommand(); sqcmd.CommandType = CommandType.StoredProcedure; sqcmd.CommandText = "WO_SteamFinishOrder"; sqcmd.Parameters.AddWithValue("@in_IP", LastIP); sqcmd.Parameters.AddWithValue("@in_CustomerID", CustomerID); sqcmd.Parameters.AddWithValue("@in_OrderID", orderId); sqcmd.Parameters.AddWithValue("@in_transid", transid); if (!CallWOApi(sqcmd)) { return; } // return new GP balance reader.Read(); int balance = getInt("Balance"); Response.Write("WO_0"); Response.Write(balance.ToString()); }
protected override void Execute() { string ticket = web.Param("ticket"); // get steam user id from auth ticket SteamApi api = new SteamApi(); string SteamID = api.GetSteamId(ticket); if (SteamID.Length == 0) { Response.Write("WO_5"); Response.Write(api.lastData_); return; } // try to login user based on his steamID SqlCommand sqcmd = new SqlCommand(); sqcmd.CommandType = CommandType.StoredProcedure; sqcmd.CommandText = "WO_SteamLogin"; sqcmd.Parameters.AddWithValue("@in_IP", LastIP); sqcmd.Parameters.AddWithValue("@in_SteamID", SteamID); if (!CallWOApi(sqcmd)) { return; } reader.Read(); int CustomerID = getInt("CustomerID");; int AccountStatus = getInt("AccountStatus"); int SessionID = 0; int IsDeveloper = 0; if (CustomerID > 0) { SessionID = getInt("SessionID"); IsDeveloper = getInt("IsDeveloper"); } // region lock if (IsDeveloper == 0 && IPLocationCheck.IsRegionLocked(LastIP, CustomerID)) { // special 600 code meaning we're IP locked. AccountStatus = 600; } Response.Write("WO_0"); Response.Write(string.Format("{0} {1} {2}", CustomerID, SessionID, AccountStatus)); return; }
public IEnumerable <Player> GetAllPlayers() { var query = new QueryBuilder <Player>(); var players = _mongoRepository.GetRepository <Player>().Collection.Find(query.Where(x => !x.IsRetired)).DistinctBy(x => x.SteamId).ToList(); var steamIds = string.Join(",", players.Select(x => x.SteamId).ToList()); var avatars = new SteamApi().GetAvatarUrlBySteamId(steamIds); foreach (var player in players) { player.ImagePath = avatars.FirstOrDefault(x => x.Key == player.SteamId).Value; } return(players); }
public string SteamId(string steamname) { var _steamApi = new SteamApi(); string steamid = ""; dynamic steamUser = _steamApi.getSteamUser(steamname); if (steamUser.response.success == 1) { steamid = steamUser.response.steamid; } else { steamid = steamname; } return(steamid); }
public static void Setup() { if (!Directory.Exists(AppEnvironment.DataPath)) { Directory.CreateDirectory(AppEnvironment.DataPath); } if (!Debugger.IsAttached) { ExceptionHandler.AddGlobalHandlers(); } Config.Load(); if (!Config.Instance.AppSettings.DisableSteamIntegration) { SteamApi.Init(); } }
void AuthTransaction() { string CustomerID = web.CustomerID(); string steamId = web.Param("steamId"); string gpItemId = web.Param("gpItemId"); string country = web.Param("country"); SqlCommand sqcmd = new SqlCommand(); sqcmd.CommandType = CommandType.StoredProcedure; sqcmd.CommandText = "WO_SteamStartOrder"; sqcmd.Parameters.AddWithValue("@in_IP", LastIP); sqcmd.Parameters.AddWithValue("@in_CustomerID", CustomerID); sqcmd.Parameters.AddWithValue("@in_SteamID", steamId); sqcmd.Parameters.AddWithValue("@in_SteamGPItemId", gpItemId); if (!CallWOApi(sqcmd)) { return; } reader.Read(); string GP = getString("GP"); string PriceUSDCents = getString("PriceUSD"); string OrderID = getString("OrderID"); string ItemName = getString("ItemName"); if (ItemName == null || ItemName == "") { ItemName = string.Format("{0} GP", GP); } SteamApi api = new SteamApi(); SteamXML.MicroTnxResponse resp = api.InitTxn( OrderID, steamId, "USD", PriceUSDCents, gpItemId, ItemName, "EN"); //System.Diagnostics.Debug.WriteLine("@@@InitTxn: " + api.lastData_); if (!ParseResponse(resp)) { return; } Response.Write("WO_0"); }
static void Main(string[] args) { JObject settings = JObject.Parse(File.ReadAllText("settings.txt")); Console.CursorVisible = false; Console.Title = "DS3 Connection Info V3.3"; SteamNative.Initialize(); mem = new MemoryManager(); Console.WriteLine("Dark Souls III: Closed"); do { try { mem.OpenProcess("DarkSoulsIII"); } catch { } Thread.Sleep(2000); } while (mem.ProcHandle == IntPtr.Zero); if (!SteamApi.Initialize(374320)) { Console.WriteLine("ERROR: Could not initalize SteamAPI."); Console.Read(); return; } ETWPingMonitor.Start(); if ((bool)settings["overlay"]) { Overlay.Enable(settings); } Console.Clear(); while (!mem.HasExited) { Player.UpdatePlayerList(); Player.UpdateInGameInfo(mem.Process); PrintConnInfo(); Thread.Sleep(1000); } Overlay.Disable(); ETWPingMonitor.Stop(); }
protected override void Execute() { string skey1 = web.Param("skey1"); if (skey1 != SERVER_API_KEY) { throw new ApiExitException("bad key"); } string CustomerID = web.CustomerID(); string SteamID = ""; int numAch = Convert.ToInt32(web.Param("NumAch")); for (int i = 0; i < numAch; ++i) { string AchID = web.Param(String.Format("AchID{0}", i)); string AchValue = web.Param(String.Format("AchVal{0}", i)); string AchUnlocked = web.Param(String.Format("AchUnl{0}", i)); int AchievUnlocked = Convert.ToInt32(AchUnlocked); SqlCommand sqcmd = new SqlCommand(); sqcmd.CommandType = CommandType.StoredProcedure; sqcmd.CommandText = "WO_UpdateAchievementStatus"; sqcmd.Parameters.AddWithValue("@in_CustomerID", CustomerID); sqcmd.Parameters.AddWithValue("@in_AchID", AchID); sqcmd.Parameters.AddWithValue("@in_AchValue", AchValue); sqcmd.Parameters.AddWithValue("@in_AchUnlocked", AchUnlocked); if (!CallWOApi(sqcmd)) { return; } reader.Read(); SteamID = getString("SteamID"); // do steam unlock of this achievement if (SteamID != "0" && AchievUnlocked > 0) { SteamApi api = new SteamApi(); api.MarkSteamAchievementAchieved(SteamID, AchID); } } Response.Write("WO_0"); }
public GameAchievements GetAchievementsLocal(string GameName, string apiKey) { List <Achievements> Achievements = new List <Achievements>(); bool HaveAchivements = false; int Total = 0; int Unlocked = 0; int Locked = 0; SteamApi steamApi = new SteamApi(_PluginUserDataPath); SteamId = steamApi.GetSteamId(GameName); Achievements = Get(SteamId, apiKey); if (Achievements.Count > 0) { HaveAchivements = true; for (int i = 0; i < Achievements.Count; i++) { if (Achievements[i].DateUnlocked == default(DateTime)) { Locked += 1; } else { Unlocked += 1; } } Total = Achievements.Count; } GameAchievements Result = new GameAchievements { Name = GameName, HaveAchivements = HaveAchivements, Total = Total, Unlocked = Unlocked, Locked = Locked, Progression = (Total != 0) ? (int)Math.Ceiling((double)(Unlocked * 100 / Total)) : 0, Achievements = Achievements }; return(Result); }
private static async Task<int> HandleNative(ISteamSessionLocator locator, bool inclRules, List<Tuple<string, string>> filter, Action<ArmaServerInfoModel> act) { var api = new SteamApi(locator); var degreeOfParallelism = inclRules ? 30 : 1; using (var bc = new BlockingCollection<ArmaServerInfoModel>()) { // TODO: better MT model var bcT = TaskExt.StartLongRunningTask(async () => { await Task.WhenAll(Enumerable.Range(1, degreeOfParallelism).Select(_ => Task.Run(async () => { foreach (var s in bc.GetConsumingEnumerable()) { await UpdateServerInfo(s, api, inclRules).ConfigureAwait(false); act(s); } }) )); }); var c2 = await api.GetServerInfo(locator.Session.AppId, x => { try { var ip = x.m_NetAdr.GetQueryAddressString().Split(':').First(); var ipAddress = IPAddress.Parse(ip); var map = x.GetMap(); var s = new ArmaServerInfoModel(new IPEndPoint(ipAddress, x.m_NetAdr.GetQueryPort())) { ConnectionEndPoint = new IPEndPoint(ipAddress, x.m_NetAdr.GetConnectionPort()), Name = x.GetServerName(), Tags = x.GetGameTags(), Mission = string.IsNullOrEmpty(map) ? null : x.GetGameDescription(), Map = map, Ping = x.m_nPing, MaxPlayers = x.m_nMaxPlayers, CurrentPlayers = x.m_nPlayers, RequirePassword = x.m_bPassword, IsVacEnabled = x.m_bSecure, ServerVersion = x.m_nServerVersion }; bc.Add(s); } catch (Exception ex) { Console.WriteLine(ex); } }, filter); bc.CompleteAdding(); await bcT; return c2; } }
public GameRequierements GetFromWeb(Game game) { GameRequierements gameRequierements = GetDefault(game); string SourceName = string.Empty; try { SourceName = PlayniteTools.GetSourceName(_PlayniteApi, game); // Search datas logger.Info($"SystemChecker - Try find with PCGamingWikiRequierements for {game.Name}"); gameRequierements = pCGamingWikiRequierements.GetRequirements(game); if (!pCGamingWikiRequierements.IsFind()) { logger.Info($"SystemChecker - Try find with SteamRequierements for {game.Name}"); switch (SourceName.ToLower()) { case "steam": gameRequierements = steamRequierements.GetRequirements(game); gameRequierements.Link = "https://store.steampowered.com/app/" + game.GameId; break; default: SteamApi steamApi = new SteamApi(PluginUserDataPath); int SteamID = steamApi.GetSteamId(game.Name); if (SteamID != 0) { gameRequierements = steamRequierements.GetRequirements(game, (uint)SteamID); gameRequierements.Link = "https://store.steampowered.com/app/" + SteamID; } break; } } gameRequierements = NormalizeRecommanded(gameRequierements); } catch (Exception ex) { Common.LogError(ex, "SystemChecker"); } return(gameRequierements); }
private void Window_Loaded(object sender, RoutedEventArgs e) { DetailsInformation detailsInformation = DetailsInformation.GetInstace(); BitmapImage imageSource = new BitmapImage(new Uri("https://steamcdn-a.akamaihd.net/steam/apps/" + detailsInformation.appid.ToString() + "/header.jpg")); imgHeder.Source = imageSource; tbTitle.Text = detailsInformation.name; Information information = Information.GetInstace(); var consumerkey = information.stkey; var userid = information.stid; var api = new SteamApi(consumerkey, userid); var review = api.GetReviewInfo(detailsInformation.appid); tbTotalReview.Text = review.query_summary.review_score_desc; tbPositive.Text = review.query_summary.total_positive.ToString(); tbNegative.Text = review.query_summary.total_negative.ToString(); tbTotal.Text = review.query_summary.num_reviews.ToString(); string voted; for (int i = 0; i < review.query_summary.num_reviews; i++) { if (review.reviews[i].voted_up == true) { voted = "おすすめ"; } else { voted = "おすすめしない"; } listView.Items.Add(new ReviewList { Id = review.reviews[i].author.steamid, PlayTime = review.reviews[i].author.playtime_forever / 60 + "時間", ReviewTime = voted, }); } }
public async Task GetPlayerProfile_ReturnsValidPersonModel() { var mockHandler = new Mock <IHttpClient>(); var response = "{\"response\":{\"players\":[{\"SteamId\":\"76561197960435530\",\"communityvisibilitystate\":3,\"profilestate\":1,\"PersonaName\":\"Robin\",\"lastlogoff\":1516019754,\"profileurl\":\"http://steamcommunity.com/id/robinwalker/\",\"avatar\":\"https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/f1/f1dd60a188883caf82d0cbfccfe6aba0af1732d4.jpg\",\"avatarmedium\":\"https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/f1/f1dd60a188883caf82d0cbfccfe6aba0af1732d4_medium.jpg\",\"AvatarFull\":\"https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/f1/f1dd60a188883caf82d0cbfccfe6aba0af1732d4_full.jpg\",\"personastate\":0,\"realname\":\"Robin Walker\",\"primaryclanid\":\"103582791429521412\",\"timecreated\":1063407589,\"personastateflags\":0,\"loccountrycode\":\"US\",\"locstatecode\":\"WA\",\"loccityid\":3961}]}}\r\n"; var request = $"http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key={_key}&steamids=76561197960435530"; mockHandler.Setup(mk => mk.GetStringAsync(request)).ReturnsAsync(response); var steamApi = new SteamApi(mockHandler.Object); var playerId = new[] { 76561197960435530 }; var model = await steamApi.GetPlayerProfilesAsync(playerId); Assert.AreEqual(model[76561197960435530].SteamId, "76561197960435530"); Assert.AreEqual(model[76561197960435530].PersonaName, "Robin"); Assert.AreEqual(model[76561197960435530].AvatarFull, "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/f1/f1dd60a188883caf82d0cbfccfe6aba0af1732d4_full.jpg"); }
private static async Task<int> HandleAlt(ISteamSessionLocator locator, List<Tuple<string, string>> filter, Action<ArmaServerInfoModel> act) { var api = new SteamApi(locator); var bc = new Subject<IPEndPoint>(); var dq = new DirectQuerier(); var t = dq.Load(page => { foreach (var i in page) { var r = (SourceParseResult) i.Settings; var s = r.MapTo<ArmaServerInfoModel>(); s.Ping = i.Ping; if (r.Rules != null) { try { var rules = SourceQueryParser.ParseRules(r.Rules); var mods = SourceQueryParser.GetList(rules, "modNames"); s.SignatureList = SourceQueryParser.GetList(rules, "sigNames").ToHashSet(); s.ModList = mods.Select(x => new ServerModInfo {Name = x}).ToList(); s.ReceivedRules = true; } catch (Exception ex) { Console.WriteLine(ex); } } act(s); } }, bc); var c2 = await api.GetServerInfo(locator.Session.AppId, x => { try { var ip = x.m_NetAdr.GetQueryAddressString().Split(':').First(); var ipAddress = IPAddress.Parse(ip); bc.OnNext(new IPEndPoint(ipAddress, x.m_NetAdr.GetQueryPort())); } catch (Exception ex) { Console.WriteLine(ex); } }, filter).ConfigureAwait(false); bc.OnCompleted(); await t; return c2; }
/// <summary> /// Constructor that does most of the work /// Probs bad stlye /// </summary> public ServerDataParser() { // Initialize Shared Dependencies var playerParser = new PlayerFileParser(); var tribeParser = new TribeFileParser(); var steamApi = new SteamApi(); var steamServer = new SteamServer(); // Parse Server Endpoint var Server = new IPEndPoint(IPAddress.Parse(IP), Port); // Slap It All Together Container = new Container(playerParser, tribeParser, steamApi, steamServer); //Container.LoadDirectory("$(SolutionDir)SavedArks"); // TODO: fix file pathing. // ffs ive tried so much shit whatever direct pathing for now Container.LoadDirectory(@"C:\Users\rpeti\Documents\visual studio 2017\Projects\ArkSite\SavedArks"); Container.LoadSteamData(Key); Container.LoadOnlinePlayers(Server); Container.LinkPlayersAndTribes(); OnlinePlayers = Container.Players.Where(p => p.Online); AverageLevel = Container.Players.Average(p => p.Level); }
/// <summary> /// Launches FFXIV with the supplied parameters. /// </summary> /// <param name="realsid">Real SessionID</param> /// <param name="language">language(0=japanese,1=english,2=french,3=german)</param> /// <param name="dx11">Runs the game in dx11 mode if true</param> /// <param name="steam">Initializes Steam library if true</param> /// <param name="expansionlevel">current level of expansions loaded(0=ARR/default,1=Heavensward)</param> public static void LaunchGame(string realsid, int language, bool dx11, bool steam, int expansionlevel) { try { if (steam) { SteamNative.Initialize(); if (SteamApi.IsSteamRunning()) { SteamApi.Initialize(39210); } } Process ffxivgame = new Process(); if (dx11) { ffxivgame.StartInfo.FileName = Settings.GetGamePath() + "/game/ffxiv_dx11.exe"; } else { ffxivgame.StartInfo.FileName = Settings.GetGamePath() + "/game/ffxiv.exe"; } ffxivgame.StartInfo.Arguments = $"DEV.TestSID={realsid} DEV.MaxEntitledExpansionID={expansionlevel} language={language} region=1"; ffxivgame.Start(); if (steam) { SteamApi.Uninitialize(); SteamNative.Uninitialize(); } } catch (Exception exc) { MessageBox.Show("Could not launch executable. Is your game path correct?\n\n" + exc, "Launch failed", MessageBoxButtons.OK); } }
static void Main() { if (!Debugger.IsAttached) { ExceptionHandler.AddGlobalHandlers(); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (!AppEnvironment.SettingValue("DisableSteamIntegration", false)) { try { SteamLoaded = SteamApi.Init(); } catch (Exception ex) { Console.WriteLine(ex.GetType().ToString() + "\r\n" + ex.Message, "A fatal Steam error was detected"); } } // create the application data path, if necessary try { if (!Directory.Exists(AppEnvironment.DataPath)) { Directory.CreateDirectory(AppEnvironment.DataPath); } } catch { // ignored } Application.Run(new Forms.MainWindow()); }
public override void Update() { // Update controllers api if using it. if (UsingControllers) { SteamApi.SteamController.RunFrame(); } // Add frame time to timer. _internalTimer += (float)Engine.RawFrameTime; // If enough time has passed update callbacks. if (!(_internalTimer > SteamUpdateTime)) { return; } _internalTimer -= SteamUpdateTime; SteamApi.RunCallbacks(); if (!Ready) { Ready = true; } }
/// <summary> /// remove the menu, resize the window, remove border, and maximize /// </summary> public static async Task MakeWindowBorderless(ProcessDetails processDetails, Form frmMain, IntPtr targetWindow, Rectangle targetFrame, Favorite favDetails) { if (NeedsDelay(targetWindow)) { await MakeWindowBorderlessDelayed(processDetails, frmMain, targetWindow, targetFrame, favDetails); } else { // Automatically match a window to favorite details, if that information is available. // Note: if one is not available, the default settings will be used as a new Favorite() object. // Automatically match this window to a process // Failsafe to prevent rapid switching, but also allow a few changes to the window handle (to be persistent) if (processDetails != null) { if (processDetails.MadeBorderless) { if (processDetails.MadeBorderlessAttempts > 3 || !await processDetails.WindowHasTargetableStyles()) { return; } } } // If no target frame was specified, assume the entire space on the primary screen if (targetFrame.Width == 0 || targetFrame.Height == 0) { targetFrame = Screen.FromHandle(targetWindow).Bounds; } // Get window styles var styleCurrentWindowStandard = Native.GetWindowLong(targetWindow, WindowLongIndex.Style); var styleCurrentWindowExtended = Native.GetWindowLong(targetWindow, WindowLongIndex.ExtendedStyle); // Compute new styles (XOR of the inverse of all the bits to filter) var styleNewWindowStandard = styleCurrentWindowStandard & ~( WindowStyleFlags.Caption // composite of Border and DialogFrame // | WindowStyleFlags.Border // | WindowStyleFlags.DialogFrame | WindowStyleFlags.ThickFrame | WindowStyleFlags.SystemMenu | WindowStyleFlags.MaximizeBox // same as TabStop | WindowStyleFlags.MinimizeBox // same as Group ); var styleNewWindowExtended = styleCurrentWindowExtended & ~( WindowStyleFlags.ExtendedDlgModalFrame | WindowStyleFlags.ExtendedComposited | WindowStyleFlags.ExtendedWindowEdge | WindowStyleFlags.ExtendedClientEdge | WindowStyleFlags.ExtendedLayered | WindowStyleFlags.ExtendedStaticEdge | WindowStyleFlags.ExtendedToolWindow | WindowStyleFlags.ExtendedAppWindow ); // Should have process details by now if (processDetails != null) { // Save original details on this window so that we have a chance at undoing the process processDetails.OriginalStyleFlagsStandard = styleCurrentWindowStandard; processDetails.OriginalStyleFlagsExtended = styleCurrentWindowExtended; Native.Rect rectTemp; Native.GetWindowRect(processDetails.WindowHandle, out rectTemp); processDetails.OriginalLocation = new Rectangle(rectTemp.Left, rectTemp.Top, rectTemp.Right - rectTemp.Left, rectTemp.Bottom - rectTemp.Top); } // remove the menu and menuitems and force a redraw if (favDetails.RemoveMenus) { // unfortunately, menus can't be re-added easily so they aren't removed by default anymore var menuHandle = Native.GetMenu(targetWindow); if (menuHandle != IntPtr.Zero) { var menuItemCount = Native.GetMenuItemCount(menuHandle); for (var i = 0; i < menuItemCount; i++) { Native.RemoveMenu(menuHandle, 0, MenuFlags.ByPosition | MenuFlags.Remove); } Native.DrawMenuBar(targetWindow); } } // auto-hide the Windows taskbar (do this before resizing the window) if (favDetails.HideWindowsTaskbar) { Native.ShowWindow(frmMain.Handle, WindowShowStyle.ShowNoActivate); if (frmMain.WindowState == FormWindowState.Minimized) { frmMain.WindowState = FormWindowState.Normal; } ToggleWindowsTaskbarVisibility(Boolstate.False); } // auto-hide the mouse cursor if (favDetails.HideMouseCursor) { ToggleMouseCursorVisibility(frmMain, Boolstate.False); } // update window styles Native.SetWindowLong(targetWindow, WindowLongIndex.Style, styleNewWindowStandard); Native.SetWindowLong(targetWindow, WindowLongIndex.ExtendedStyle, styleNewWindowExtended); // update window position if (favDetails.Size != FavoriteSize.NoChange) { if (favDetails.Size == FavoriteSize.FullScreen || favDetails.PositionW == 0 || favDetails.PositionH == 0) { // Set the window size to the biggest possible, using bounding adjustments Native.SetWindowPos ( targetWindow, 0, targetFrame.X + favDetails.OffsetL, targetFrame.Y + favDetails.OffsetT, targetFrame.Width - favDetails.OffsetL + favDetails.OffsetR, targetFrame.Height - favDetails.OffsetT + favDetails.OffsetB, SetWindowPosFlags.ShowWindow | SetWindowPosFlags.NoOwnerZOrder | SetWindowPosFlags.NoSendChanging ); // And auto-maximize if (favDetails.ShouldMaximize) { Native.ShowWindow(targetWindow, WindowShowStyle.Maximize); } } else { // Set the window size to the exact position specified by the user Native.SetWindowPos ( targetWindow, 0, favDetails.PositionX, favDetails.PositionY, favDetails.PositionW, favDetails.PositionH, SetWindowPosFlags.ShowWindow | SetWindowPosFlags.NoOwnerZOrder | SetWindowPosFlags.NoSendChanging ); } } // Set topmost if (favDetails.TopMost) { Native.SetWindowPos ( targetWindow, Native.HWND_TOPMOST, 0, 0, 0, 0, SetWindowPosFlags.ShowWindow | SetWindowPosFlags.NoMove | SetWindowPosFlags.NoSize | SetWindowPosFlags.NoSendChanging ); } } // Make a note that we attempted to make the window borderless if (processDetails != null) { processDetails.MadeBorderless = true; processDetails.MadeBorderlessAttempts++; } if (SteamApi.IsLoaded) { if (SteamApi.UnlockAchievement("FIRST_TIME_BORDERLESS")) { Console.WriteLine("Great!"); } } }
public PlayerModel(SteamApi steamApi, LegionTdContext db) { _db = db; _steamApi = steamApi; }
private static async Task UpdateServerInfo(ArmaServerInfoModel s, SteamApi api, bool inclRules) { s.GameTags = s.Tags == null ? null : GameTags.Parse(s.Tags); if (inclRules) { var rules = await api.GetServerRules(s.QueryEndPoint).ConfigureAwait(false); var mods = SourceQueryParser.GetList(rules, "modNames"); s.SignatureList = SourceQueryParser.GetList(rules, "sigNames").ToHashSet(); s.ModList = mods.Select(x => new ServerModInfo {Name = x}).ToList(); } }
private static Process LaunchGame(string sessionId, int region, int expansionLevel, bool isSteamIntegrationEnabled, bool isSteamServiceAccount, string additionalArguments, bool closeMutants = false) { try { if (isSteamIntegrationEnabled) { try { SteamNative.Initialize(); if (SteamApi.IsSteamRunning() && SteamApi.Initialize(SteamAppId)) { Log.Information("Steam initialized."); } } catch (Exception ex) { Log.Error(ex, "Could not initialize Steam."); } } var game = new Process { StartInfo = { UseShellExecute = false, RedirectStandardError = false, RedirectStandardInput = false, RedirectStandardOutput = false } }; if (Settings.IsDX11()) { game.StartInfo.FileName = Settings.GamePath + "/game/ffxiv_dx11.exe"; } else { game.StartInfo.FileName = Settings.GamePath + "/game/ffxiv.exe"; } game.StartInfo.Arguments = $"DEV.DataPathType=1 DEV.MaxEntitledExpansionID={expansionLevel} DEV.TestSID={sessionId} DEV.UseSqPack=1 SYS.Region={region} language={(int) Settings.GetLanguage()} ver={GetLocalGameVer()}"; game.StartInfo.Arguments += " " + additionalArguments; if (isSteamServiceAccount) { // These environment variable and arguments seems to be set when ffxivboot is started with "-issteam" (27.08.2019) game.StartInfo.Environment.Add("IS_FFXIV_LAUNCH_FROM_STEAM", "1"); game.StartInfo.Arguments += " IsSteam=1"; } /* * var ticks = (uint) Environment.TickCount; * var key = ticks & 0xFFF0_0000; * * var argumentBuilder = new ArgumentBuilder() * .Append("T", ticks.ToString()) * .Append("DEV.DataPathType", "1") * .Append("DEV.MaxEntitledExpansionID", expansionLevel.ToString()) * .Append("DEV.TestSID", sessionId) * .Append("DEV.UseSqPack", "1") * .Append("SYS.Region", region.ToString()) * .Append("language", ((int) Settings.GetLanguage()).ToString()) * .Append("ver", GetLocalGameVer()); * * game.StartInfo.Arguments = argumentBuilder.BuildEncrypted(key); */ game.StartInfo.WorkingDirectory = Path.Combine(Settings.GamePath.FullName, "game"); game.Start(); if (isSteamIntegrationEnabled) { try { SteamApi.Uninitialize(); SteamNative.Uninitialize(); } catch (Exception ex) { Log.Error(ex, "Could not uninitialize Steam."); } } for (var tries = 0; tries < 30; tries++) { game.Refresh(); // Something went wrong here, why even bother if (game.HasExited) { throw new Exception("Game exited prematurely"); } // Is the main window open? Let's wait so any addons won't run into nothing if (game.MainWindowHandle == IntPtr.Zero) { Thread.Sleep(1000); continue; } if (closeMutants) { CloseMutants(game); } break; } return(game); } catch (Exception ex) { new ErrorWindow(ex, "Your game path might not be correct. Please check in the settings.", "XG LaunchGame").ShowDialog(); } return(null); }
public static Process LaunchGame(string sessionId, int region, int expansionLevel, bool isSteamIntegrationEnabled, bool isSteamServiceAccount, string additionalArguments, DirectoryInfo gamePath, bool isDx11, ClientLanguage language, bool closeMutants = false) { Log.Information($"XivGame::LaunchGame(steamIntegration:{isSteamIntegrationEnabled}, steamServiceAccount:{isSteamServiceAccount}, args:{additionalArguments})"); try { if (isSteamIntegrationEnabled) { try { SteamNative.Initialize(); if (SteamApi.IsSteamRunning() && SteamApi.Initialize(SteamAppId)) { Log.Information("Steam initialized."); } } catch (Exception ex) { Log.Error(ex, "Could not initialize Steam."); } } var nativeLauncher = new Process { StartInfo = { UseShellExecute = false, RedirectStandardError = false, RedirectStandardInput = false, RedirectStandardOutput = true, CreateNoWindow = true } }; var exePath = gamePath + "/game/ffxiv_dx11.exe"; if (!isDx11) { exePath = gamePath + "/game/ffxiv.exe"; } if (!File.Exists("NativeLauncher.exe")) { MessageBox.Show( "Your Anti-Virus may have deleted a file necessary for XIVLauncher to function.\nPlease check its logs and reinstall XIVLauncher.", "XIVLauncher Error", MessageBoxButton.OK, MessageBoxImage.Error); return(null); } nativeLauncher.StartInfo.FileName = "NativeLauncher.exe"; nativeLauncher.StartInfo.Arguments = $"\"{exePath}\" \"DEV.DataPathType=1 DEV.MaxEntitledExpansionID={expansionLevel} DEV.TestSID={sessionId} DEV.UseSqPack=1 SYS.Region={region} language={(int) language} ver={GetLocalGameVer(gamePath)} {additionalArguments}"; if (isSteamServiceAccount) { // These environment variable and arguments seems to be set when ffxivboot is started with "-issteam" (27.08.2019) nativeLauncher.StartInfo.Environment.Add("IS_FFXIV_LAUNCH_FROM_STEAM", "1"); nativeLauncher.StartInfo.Arguments += " IsSteam=1"; } nativeLauncher.StartInfo.Arguments += "\""; /* * var ticks = (uint) Environment.TickCount; * var key = ticks & 0xFFF0_0000; * * var argumentBuilder = new ArgumentBuilder() * .Append("T", ticks.ToString()) * .Append("DEV.DataPathType", "1") * .Append("DEV.MaxEntitledExpansionID", expansionLevel.ToString()) * .Append("DEV.TestSID", sessionId) * .Append("DEV.UseSqPack", "1") * .Append("SYS.Region", region.ToString()) * .Append("language", ((int) Settings.GetLanguage()).ToString()) * .Append("ver", GetLocalGameVer()); * * game.StartInfo.Arguments = argumentBuilder.BuildEncrypted(key); */ nativeLauncher.StartInfo.WorkingDirectory = Path.Combine(gamePath.FullName, "game"); nativeLauncher.Start(); if (!nativeLauncher.WaitForExit(10000)) { MessageBox.Show( "Could not start the game correctly. Please report this error.", "XIVLauncher Error", MessageBoxButton.OK, MessageBoxImage.Error); return(null); } var pidStr = nativeLauncher.StandardOutput.ReadToEnd(); if (!int.TryParse(pidStr, out var gamePid)) { MessageBox.Show( "Could not start the game correctly. Please report this error.\n\n" + pidStr, "XIVLauncher Error", MessageBoxButton.OK, MessageBoxImage.Error); return(null); } var game = Process.GetProcessById(gamePid); if (isSteamIntegrationEnabled) { try { SteamApi.Uninitialize(); SteamNative.Uninitialize(); } catch (Exception ex) { Log.Error(ex, "Could not uninitialize Steam."); } } for (var tries = 0; tries < 30; tries++) { game.Refresh(); // Something went wrong here, why even bother if (game.HasExited) { throw new Exception("Game exited prematurely"); } // Is the main window open? Let's wait so any addons won't run into nothing if (game.MainWindowHandle == IntPtr.Zero) { Thread.Sleep(1000); continue; } if (closeMutants) { CloseMutants(game); } break; } return(game); } catch (Exception ex) { new ErrorWindow(ex, "Your game path might not be correct. Please check in the settings.", "XG LaunchGame").ShowDialog(); } return(null); }
private static Process LaunchGame(string sessionId, int region, int expansionLevel, bool isSteam, bool closeMutants = false) { try { if (isSteam) { SteamNative.Initialize(); if (SteamApi.IsSteamRunning() && SteamApi.Initialize(SteamAppId)) { Serilog.Log.Information("Steam initialized."); } } var game = new Process(); if (Settings.IsDX11()) { game.StartInfo.FileName = Settings.GetGamePath() + "/game/ffxiv_dx11.exe"; } else { game.StartInfo.FileName = Settings.GetGamePath() + "/game/ffxiv.exe"; } game.StartInfo.Arguments = $"DEV.DataPathType=1 DEV.MaxEntitledExpansionID={expansionLevel} DEV.TestSID={sessionId} DEV.UseSqPack=1 SYS.Region={region} language={(int)Settings.GetLanguage()} ver={GetLocalGameVer()}"; /* * var ticks = (uint) Environment.TickCount; * var key = ticks & 0xFFF0_0000; * * var argumentBuilder = new ArgumentBuilder() * .Append("T", ticks.ToString()) * .Append("DEV.DataPathType", "1") * .Append("DEV.MaxEntitledExpansionID", expansionLevel.ToString()) * .Append("DEV.TestSID", sessionId) * .Append("DEV.UseSqPack", "1") * .Append("SYS.Region", region.ToString()) * .Append("language", ((int) Settings.GetLanguage()).ToString()) * .Append("ver", GetLocalGameVer()); * * game.StartInfo.Arguments = argumentBuilder.BuildEncrypted(key); */ game.StartInfo.WorkingDirectory = Path.Combine(Settings.GetGamePath(), "game"); game.Start(); //Serilog.Log.Information("Starting game process with key ({1}): {0}", argumentBuilder.Build(), key); if (isSteam) { SteamApi.Uninitialize(); SteamNative.Uninitialize(); } for (var tries = 0; tries < 30; tries++) { game.Refresh(); // Something went wrong here, why even bother if (game.HasExited) { throw new Exception("Game exited prematurely"); } // Is the main window open? Let's wait so any addons won't run into nothing if (game.MainWindowHandle == IntPtr.Zero) { Thread.Sleep(1000); continue; } if (closeMutants) { CloseMutants(game); } break; } return(game); } catch (Exception ex) { new ErrorWindow(ex, "Your game path might not be correct. Please check in the settings.", "XG LaunchGame").Show(); } return(null); }
protected override void Execute() { string ticket = web.Param("ticket"); // get steam user id from auth ticket SteamApi api = new SteamApi(); string SteamID = api.GetSteamId(ticket); if (SteamID.Length == 0) { Response.Write("WO_5"); Response.Write(api.lastData_); return; } string apiAnswer = ""; bool Have_Game = false; int Have_227660 = 0; // old 15$ int Have_227661 = 0; // old 50$ int Have_267590 = 0; // 12-2013 15$ int Have_267591 = 0; // 12-2013 50$ SteamXML.appownershipAppsApp[] apps = api.GetPublisherAppOwnership(SteamID, ref apiAnswer); if (apps != null) { foreach (SteamXML.appownershipAppsApp app in apps) { if (app.ownsapp == false) { continue; } if (app.permanent == false && SteamID != "76561198043252597") // ignore that flag for denis steam acc (i have game as developer) { continue; } switch (app.appid) { case 226700: Have_Game = true; break; // base game case 227660: Have_227660 = app.appid; break; // 15$ case 227661: Have_227661 = app.appid; break; // 50$ case 267590: Have_267590 = app.appid; break; // new 15$ case 267591: Have_267591 = app.appid; break; // new 50$ } } } if (!Have_Game) { // special 1001 code for running under steam but without game. Response.Write("WO_0"); Response.Write(string.Format("{0} {1} {2}", 0, 0, 1001)); return; } string countryIP = ""; if (!String.IsNullOrEmpty(Request["HTTP_CF_IPCOUNTRY"])) { countryIP = Request["HTTP_CF_IPCOUNTRY"]; } // try to login user based on his steam id SqlCommand sqcmd = new SqlCommand(); sqcmd.CommandType = CommandType.StoredProcedure; sqcmd.CommandText = "WZ_SteamLogin"; sqcmd.Parameters.AddWithValue("@in_IP", LastIP); sqcmd.Parameters.AddWithValue("@in_SteamID", SteamID); sqcmd.Parameters.AddWithValue("@in_Country", countryIP); if (!CallWOApi(sqcmd)) { return; } reader.Read(); int CustomerID = getInt("CustomerID"); int AccountStatus = getInt("AccountStatus"); int SessionID = 0; int IsDeveloper = 0; if (CustomerID > 0) { SessionID = getInt("SessionID"); IsDeveloper = getInt("IsDeveloper"); } Response.Write("WO_0"); Response.Write(string.Format("{0} {1} {2}", CustomerID, SessionID, AccountStatus)); // DLC logic // because of totally retarded steam setup our bundles will look like this: // base: 226700 // 15$: 226700 & 227660 // 50$: 226700 & 227660 & 227661 // activate 1st DLC ONLY if we don't have second if (CustomerID > 0 && Have_227660 > 0 && Have_227661 == 0) { if (ActivateDLC(CustomerID, Have_227660, apiAnswer, SteamID)) { return; } } if (CustomerID > 0 && Have_227660 > 0 && Have_227661 > 0) { if (ActivateDLC(CustomerID, Have_227661, apiAnswer, SteamID)) { return; } } // NEW 12-2013 packages // activate 1st DLC ONLY if we don't have second if (CustomerID > 0 && Have_267590 > 0 && Have_267591 == 0) { if (ActivateDLC(CustomerID, Have_267590, apiAnswer, SteamID)) { return; } } if (CustomerID > 0 && Have_267590 > 0 && Have_267591 > 0) { if (ActivateDLC(CustomerID, Have_267591, apiAnswer, SteamID)) { return; } } return; }
public PCGamingWikiRequierements(IPlayniteAPI PlayniteApi, string PluginUserDataPath) { _PlayniteApi = PlayniteApi; steamApi = new SteamApi(PluginUserDataPath); }