public static Image GetIcon(CApp app) { string absolutePath; if (!string.IsNullOrEmpty(app.IconPath)) { absolutePath = CApp.GetAbsolutePath(app.IconPath); } else { absolutePath = CApp.GetAbsolutePath(app.Path); } Image result; try { result = Image.FromFile(absolutePath); } catch { try { result = Icon.ExtractAssociatedIcon(absolutePath).ToBitmap(); } catch { result = null; } } return(result); }
public int AddApp(CApp app) { m_Config.m_Apps.Add(app); EventAppAdded?.Invoke(this, new AppModifiedEventArgs { tag = null, app = app }); return(m_Config.m_Apps.Count - 1); }
private void btnManual_Click(object sender, EventArgs e) { try { SelectedApp = Apps[lstMulti.SelectedIndex]; } catch { } base.DialogResult = DialogResult.No; }
public void Copy(CApp other) { Tag = other.Tag; IconPath = other.IconPath; GameName = other.GameName; Category = other.Category; Path = other.Path; CommandLine = other.CommandLine; StartIn = other.StartIn; Persist = other.Persist; InjectDll = other.InjectDll; Use64Launcher = other.Use64Launcher; AvatarPath = other.AvatarPath; PersonaName = other.PersonaName; AppId = other.AppId; SteamIdGeneration = other.SteamIdGeneration; ManualSteamId = other.ManualSteamId; Language = other.Language; LowViolence = other.LowViolence; StorageOnAppdata = other.StorageOnAppdata; SeparateStorageByName = other.SeparateStorageByName; RemoteStoragePath = other.RemoteStoragePath; AutomaticallyJoinInvite = other.AutomaticallyJoinInvite; EnableHTTP = other.EnableHTTP; EnableInGameVoice = other.EnableInGameVoice; EnableLobbyFilter = other.EnableLobbyFilter; DisableFriendList = other.DisableFriendList; DisableLeaderboard = other.DisableLeaderboard; SecuredServer = other.SecuredServer; VR = other.VR; QuickJoinHotkey = other.QuickJoinHotkey; FailOnNonExistenceStats = other.FailOnNonExistenceStats; DisableGC = other.DisableGC; BroadcastAddress.AddRange(other.BroadcastAddress); ListenPort = other.ListenPort; MaximumPort = other.MaximumPort; DiscoveryInterval = other.DiscoveryInterval; MaximumConnection = other.MaximumConnection; DefaultDlcSubscribed = other.DefaultDlcSubscribed; DlcList.AddRange(other.DlcList); EnableDebugLogging = other.EnableDebugLogging; EnableOverlay = other.EnableOverlay; EnableOnlinePlay = other.EnableOnlinePlay; EnableHookRefCount = other.EnableHookRefCount; OnlineKey = other.OnlineKey; }
public static void WriteIniAndLaunch(CApp app, CConfig gconf, string extra_commandline = null) { var baseDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SmartSteamEmu"); var iniFilePath = Path.Combine(baseDirectory, "launcher.ini"); var emuLoaderPath = Path.Combine(baseDirectory, "SmartSteamLoader" + (app.Use64Launcher ? "_x64" : "") + ".exe"); bool lowViolence = (app.LowViolence == -1) ? gconf.LowViolence : Convert.ToBoolean(app.LowViolence); bool storageOnAppdata = (app.StorageOnAppdata == -1) ? gconf.StorageOnAppdata : Convert.ToBoolean(app.StorageOnAppdata); bool separateStorageByName = (app.SeparateStorageByName == -1) ? gconf.SeparateStorageByName : Convert.ToBoolean(app.SeparateStorageByName); bool automaticallyJoinInvite = (app.AutomaticallyJoinInvite == -1) ? gconf.AutomaticallyJoinInvite : Convert.ToBoolean(app.AutomaticallyJoinInvite); bool enableHTTP = (app.EnableHTTP == -1) ? gconf.EnableHTTP : Convert.ToBoolean(app.EnableHTTP); bool enableInGameVoice = (app.EnableInGameVoice == -1) ? gconf.EnableInGameVoice : Convert.ToBoolean(app.EnableInGameVoice); bool enableLobbyFilter = (app.EnableLobbyFilter == -1) ? gconf.EnableLobbyFilter : Convert.ToBoolean(app.EnableLobbyFilter); bool disableFriendList = (app.DisableFriendList == -1) ? gconf.DisableFriendList : Convert.ToBoolean(app.DisableFriendList); bool disableLeaderboard = (app.DisableLeaderboard == -1) ? gconf.DisableLeaderboard : Convert.ToBoolean(app.DisableLeaderboard); bool securedServer = (app.SecuredServer == -1) ? gconf.SecuredServer : Convert.ToBoolean(app.SecuredServer); bool enableVR = (app.VR == -1) ? gconf.EnableVR : Convert.ToBoolean(app.VR); bool offline = (app.Offline == -1) ? gconf.Offline : Convert.ToBoolean(app.Offline); bool enableOverlay = (app.EnableOverlay == -1) ? gconf.EnableOverlay : Convert.ToBoolean(app.EnableOverlay); bool enableOnlinePlay = (app.EnableOnlinePlay == -1) ? gconf.EnableOnlinePlay : Convert.ToBoolean(app.EnableOnlinePlay); bool enableLog = ((app.EnableDebugLogging == -1) ? gconf.EnableLog : Convert.ToBoolean(app.EnableDebugLogging)); long manualSteamID = (app.ManualSteamId == -1L) ? gconf.ManualSteamId : app.ManualSteamId; string avatarPath = string.IsNullOrEmpty(app.AvatarPath) ? ((gconf.AvatarPath == "avatar.png") ? gconf.AvatarPath : CApp.GetAbsolutePath(gconf.AvatarPath)) : CApp.GetAbsolutePath(app.AvatarPath); string personaName = string.IsNullOrEmpty(app.PersonaName) ? gconf.PersonaName : app.PersonaName; string steamIdGeneration = string.IsNullOrEmpty(app.SteamIdGeneration) ? gconf.SteamIdGeneration : app.SteamIdGeneration; string quickJoinHotkey = string.IsNullOrEmpty(app.QuickJoinHotkey) ? gconf.QuickJoinHotkey : app.QuickJoinHotkey; string language = string.IsNullOrEmpty(app.Language) ? gconf.Language : app.Language; string overlayLanguage = gconf.OverlayLanguage; string masterServerAddress = ""; foreach (var server in gconf.MasterServerAddress) { masterServerAddress += server + " "; } if (!string.IsNullOrWhiteSpace(overlayLanguage)) { if (language.Equals("Simplified Chinese", StringComparison.OrdinalIgnoreCase)) { language = "schinese"; } else if (language.Equals("Traditional Chinese", StringComparison.OrdinalIgnoreCase)) { language = "tchinese"; } } if (!string.IsNullOrWhiteSpace(overlayLanguage)) { if (overlayLanguage.Equals("Simplified Chinese", StringComparison.OrdinalIgnoreCase)) { overlayLanguage = "schinese"; } else if (overlayLanguage.Equals("Traditional Chinese", StringComparison.OrdinalIgnoreCase)) { overlayLanguage = "tchinese"; } } try { // Empty log file if (enableLog && gconf.CleanLog) { var logFile = Path.Combine(baseDirectory, "SmartSteamEmu.log"); if (File.Exists(logFile)) { using (new FileStream(logFile, FileMode.Truncate)) { } } } var fs = new FileStream(iniFilePath, FileMode.Create, FileAccess.ReadWrite); using (var sw = new StreamWriter(fs, Encoding.Unicode)) { sw.WriteLine("# This file is generated by and will be overwritten by SSELauncher"); sw.WriteLine("#"); sw.WriteLine(""); sw.WriteLine(""); sw.WriteLine("[Launcher]"); sw.WriteLine("Target = " + CApp.GetAbsolutePath(app.Path)); sw.WriteLine("StartIn = " + CApp.GetAbsolutePath(app.StartIn)); sw.WriteLine("CommandLine = " + app.CommandLine + (string.IsNullOrEmpty(extra_commandline) ? "" : extra_commandline)); sw.WriteLine("SteamClientPath = " + Path.Combine(baseDirectory, "SmartSteamEmu.dll")); sw.WriteLine("SteamClientPath64 = " + Path.Combine(baseDirectory, "SmartSteamEmu64.dll")); sw.WriteLine("Persist = " + (app.Persist ? 1 : 0)); sw.WriteLine("ParanoidMode = " + (gconf.ParanoidMode ? 1 : 0)); sw.WriteLine("InjectDll = " + (app.InjectDll ? 1 : 0)); sw.WriteLine(""); sw.WriteLine("[SmartSteamEmu]"); sw.WriteLine("AvatarFilename = " + avatarPath); sw.WriteLine("PersonaName = " + personaName); sw.WriteLine("AppId = " + app.AppId); sw.WriteLine("SteamIdGeneration = " + steamIdGeneration); sw.WriteLine("ManualSteamId = " + manualSteamID); sw.WriteLine("Language = " + language); sw.WriteLine("LowViolence = " + lowViolence.ToString()); sw.WriteLine("StorageOnAppdata = " + storageOnAppdata.ToString()); sw.WriteLine("SeparateStorageByName = " + separateStorageByName.ToString()); if (!string.IsNullOrEmpty(app.RemoteStoragePath) && !string.IsNullOrWhiteSpace(app.RemoteStoragePath)) { sw.WriteLine("RemoteStoragePath = " + CApp.GetAbsolutePath(app.RemoteStoragePath)); } sw.WriteLine("AutomaticallyJoinInvite = " + automaticallyJoinInvite.ToString()); sw.WriteLine("EnableHTTP = " + enableHTTP.ToString()); sw.WriteLine("EnableInGameVoice = " + enableInGameVoice.ToString()); sw.WriteLine("EnableLobbyFilter = " + enableLobbyFilter.ToString()); sw.WriteLine("DisableFriendList = " + disableFriendList.ToString()); sw.WriteLine("DisableLeaderboard = " + disableLeaderboard.ToString()); sw.WriteLine("DisableGC = " + app.DisableGC.ToString()); sw.WriteLine("SecuredServer = " + securedServer.ToString()); sw.WriteLine("VR = " + enableVR.ToString()); sw.WriteLine("Offline = " + offline.ToString()); sw.WriteLine("QuickJoinHotkey = " + quickJoinHotkey); sw.WriteLine("MasterServer = " + masterServerAddress); sw.WriteLine("MasterServerGoldSrc = " + masterServerAddress); sw.WriteLine(app.Extras); sw.WriteLine(""); sw.WriteLine("[Achievements]"); sw.WriteLine("FailOnNonExistenceStats = " + Convert.ToBoolean(app.FailOnNonExistenceStats).ToString()); sw.WriteLine(""); sw.WriteLine("[SSEOverlay]"); sw.WriteLine("DisableOverlay = " + (!Convert.ToBoolean(enableOverlay)).ToString()); sw.WriteLine("OnlineMode = " + Convert.ToBoolean(enableOnlinePlay).ToString()); sw.WriteLine("Language = " + overlayLanguage); sw.WriteLine("ScreenshotHotkey = " + gconf.OverlayScreenshotHotkey); sw.WriteLine("HookRefCount = " + app.EnableHookRefCount.ToString()); sw.WriteLine("OnlineKey = " + (string.IsNullOrWhiteSpace(app.OnlineKey) ? gconf.OnlineKey : app.OnlineKey)); sw.WriteLine(""); sw.WriteLine("[DirectPatch]"); foreach (var patch in app.DirectPatchList) { sw.WriteLine(patch); } sw.WriteLine(""); sw.WriteLine("[Debug]"); sw.WriteLine("EnableLog = " + enableLog.ToString()); sw.WriteLine("MarkLogHotkey = " + gconf.MarkLogHotkey); sw.WriteLine("LogFilter = " + gconf.LogFilter); sw.WriteLine("Minidump = " + gconf.Minidump.ToString()); sw.WriteLine(""); sw.WriteLine("[DLC]"); sw.WriteLine("Default = " + app.DefaultDlcSubscribed.ToString()); foreach (var dlc in app.DlcList) { if (!dlc.Disabled) { sw.WriteLine(dlc.DlcId + " = " + dlc.DlcName); } } sw.WriteLine(""); string broadcastAddress = ""; if (app.ListenPort == -1) { foreach (var address in gconf.BroadcastAddress) { broadcastAddress += address + " "; } } else { foreach (var address in app.BroadcastAddress) { broadcastAddress += address + " "; } } int num2 = (app.ListenPort == -1) ? gconf.ListenPort : app.ListenPort; int num3 = (app.MaximumPort == -1) ? gconf.MaximumPort : app.MaximumPort; int num4 = (app.DiscoveryInterval == -1) ? gconf.DiscoveryInterval : app.DiscoveryInterval; int num5 = (app.MaximumConnection == -1) ? gconf.MaximumConnection : app.MaximumConnection; sw.WriteLine("[Networking]"); sw.WriteLine("BroadcastAddress = " + broadcastAddress); sw.WriteLine("ListenPort = " + num2); sw.WriteLine("MaximumPort = " + num3); sw.WriteLine("DiscoveryInterval = " + num4); sw.WriteLine("MaximumConnection = " + num5); sw.WriteLine(""); sw.WriteLine("[PlayerManagement]"); sw.WriteLine("AllowAnyoneConnect = " + gconf.AllowAnyoneConnect.ToString()); sw.WriteLine("AdminPassword = "******" = 0"); } sw.WriteLine(""); // Now run the games! var startInfo = new ProcessStartInfo { CreateNoWindow = false, UseShellExecute = false, FileName = emuLoaderPath, WindowStyle = ProcessWindowStyle.Normal, Arguments = "\"" + iniFilePath + "\"" }; using (var exeProcess = Process.Start(startInfo)) { } } } catch (Exception ex) { MessageBox.Show(string.Concat(new string[] { ex.Message, "\n\nPath search by launcher:\n\n", iniFilePath, "\n\n", emuLoaderPath }), "Unable to launch games"); } }
private static void Main() { AppList = new CAppList(AppDomain.CurrentDomain.BaseDirectory); AppList.Load(); CApp cApp = null; List <string> extraArgList = new List <string>(); try { string[] commandLineArgs = Environment.GetCommandLineArgs(); int i = 1; while (i < commandLineArgs.Length) { if (commandLineArgs[i] == "-appid" && ++i < commandLineArgs.Length) { int AppID = Int32.Parse(commandLineArgs[i]); cApp = AppList.GetItems().Find(x => x.AppId == AppID); if (cApp == null) { MessageBox.Show(AppID.ToString(), "Unable to find appid"); break; } } else if (cApp != null) { extraArgList.Add(commandLineArgs[i]); } i++; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Failed parsing parameter"); } if (cApp != null) { string args = ""; foreach (var arg in extraArgList) { args += " " + arg; } FrmMain.WriteIniAndLaunch(cApp, AppList.GetConfig(), args); return; } if (Program.mutex.WaitOne(TimeSpan.Zero, true)) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FrmMain()); AppList.Save(); mutex.ReleaseMutex(); return; } NativeMethods.PostMessage((IntPtr)NativeMethods.HWND_BROADCAST, NativeMethods.WM_SHOWME, IntPtr.Zero, IntPtr.Zero); }
public CApp(CApp other) { Copy(other); }
public BgParam(string hashcode, CApp app) { HashCode = hashcode; App = app; AppIcon = null; }
public void SetConfig(CConfig config) { m_Conf = config; RepopulateLanguage(); // Basic Settings cmbEmuSteamId.SelectedIndex = -1; cmbEmuSteamId.Text = (String.Equals(config.SteamIdGeneration, "Manual", StringComparison.OrdinalIgnoreCase) ? config.ManualSteamId.ToString() : config.SteamIdGeneration); cmbEmuPersonaName.SelectedIndex = -1; cmbEmuPersonaName.Text = config.PersonaName; cmbEmuQuickJoin.SelectedIndex = -1; cmbEmuQuickJoin.Text = config.QuickJoinHotkey; m_TempAvatarPath = CApp.GetAbsolutePath(config.AvatarPath); cmbParanoidMode.Text = m_Conf.ParanoidMode.ToString(); chkHideToTray.Checked = m_Conf.HideToTray; cmbLang.Text = m_Conf.Language; cmbOverlay.Text = m_Conf.EnableOverlay.ToString(); cmbOnlinePlay.Text = m_Conf.EnableOnlinePlay.ToString(); cmbOverlayLang.Text = m_Conf.OverlayLanguage; cmbOverlayScreenshot.SelectedIndex = -1; cmbOverlayScreenshot.Text = m_Conf.OverlayScreenshotHotkey; try { if (config.AvatarPath == "avatar.png") { pbAvatar.Image = Image.FromFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"SmartSteamEmu\SmartSteamEmu\Common\" + config.AvatarPath)); } else { pbAvatar.Image = Image.FromFile(m_TempAvatarPath); } } catch { } // Advanced Settings cmbAutoJoinInvite.Text = config.AutomaticallyJoinInvite.ToString(); cmbStorageOnAppData.Text = config.StorageOnAppdata.ToString(); cmbSeparateStorageByName.Text = config.SeparateStorageByName.ToString(); cmbSecuredServer.Text = config.SecuredServer.ToString(); cmbDisableFriendList.Text = config.DisableFriendList.ToString(); cmbDisableLeaderboard.Text = config.DisableLeaderboard.ToString(); cmbEnableHttp.Text = config.EnableHTTP.ToString(); cmbEnableIngameVoice.Text = config.EnableInGameVoice.ToString(); cmbEnableLobbyFilter.Text = config.EnableLobbyFilter.ToString(); cmbEnableVR.Text = config.EnableVR.ToString(); cmbOffline.Text = config.Offline.ToString(); txtOnlineKey.Text = config.OnlineKey; foreach (string ipport in config.MasterServerAddress) { lstMasterServer.Items.Add(ipport); } // Debugging cmbEnableLog.Text = config.EnableLog.ToString(); chkCleanLog.Checked = config.CleanLog; // Networking numNetListenPort.Value = config.ListenPort; numNetMaxPort.Value = config.MaximumPort; numNetDiscoveryInterval.Value = config.DiscoveryInterval; numNetMaxConn.Value = config.MaximumConnection; foreach (string addr in config.BroadcastAddress) { lstNetBroadcast.Items.Add(addr); } // Player Management chkAllowAnyToConnect.Checked = config.AllowAnyoneConnect; txtAdminPass.Text = config.AdminPass; foreach (string steamid in config.BanList) { lstBan.Items.Add(steamid); } }
private void btnOK_Click(object sender, EventArgs e) { // Basic Settings if (String.Equals(cmbEmuSteamId.Text, "Static", StringComparison.OrdinalIgnoreCase) || String.Equals(cmbEmuSteamId.Text, "Random", StringComparison.OrdinalIgnoreCase) || String.Equals(cmbEmuSteamId.Text, "PersonaName", StringComparison.OrdinalIgnoreCase) || String.Equals(cmbEmuSteamId.Text, "ip", StringComparison.OrdinalIgnoreCase) || String.Equals(cmbEmuSteamId.Text, "GenerateRandom", StringComparison.OrdinalIgnoreCase)) { m_Conf.SteamIdGeneration = cmbEmuSteamId.Text; } else { try { m_Conf.ManualSteamId = Convert.ToInt64(cmbEmuSteamId.Text); m_Conf.SteamIdGeneration = "Manual"; } catch { MessageBox.Show("Invalid steam id!", "Invalid input"); } } m_Conf.PersonaName = cmbEmuPersonaName.Text; m_Conf.AvatarPath = CApp.MakeRelativePath(m_TempAvatarPath, false); m_Conf.QuickJoinHotkey = cmbEmuQuickJoin.Text; m_Conf.ParanoidMode = Convert.ToBoolean(cmbParanoidMode.Text); m_Conf.HideToTray = chkHideToTray.Checked; m_Conf.Language = cmbLang.Text; m_Conf.EnableOverlay = Convert.ToBoolean(cmbOverlay.Text); m_Conf.EnableOnlinePlay = Convert.ToBoolean(cmbOnlinePlay.Text); m_Conf.OverlayLanguage = cmbOverlayLang.Text; m_Conf.OverlayScreenshotHotkey = cmbOverlayScreenshot.Text; // Advanced Setting m_Conf.AutomaticallyJoinInvite = Convert.ToBoolean(cmbAutoJoinInvite.Text); m_Conf.StorageOnAppdata = Convert.ToBoolean(cmbStorageOnAppData.Text); m_Conf.SeparateStorageByName = Convert.ToBoolean(cmbSeparateStorageByName.Text); m_Conf.SecuredServer = Convert.ToBoolean(cmbSecuredServer.Text); m_Conf.DisableFriendList = Convert.ToBoolean(cmbDisableFriendList.Text); m_Conf.DisableLeaderboard = Convert.ToBoolean(cmbDisableLeaderboard.Text); m_Conf.EnableHTTP = Convert.ToBoolean(cmbEnableHttp.Text); m_Conf.EnableInGameVoice = Convert.ToBoolean(cmbEnableIngameVoice.Text); m_Conf.EnableLobbyFilter = Convert.ToBoolean(cmbEnableLobbyFilter.Text); m_Conf.EnableVR = Convert.ToBoolean(cmbEnableVR.Text); m_Conf.Offline = Convert.ToBoolean(cmbOffline.Text); m_Conf.OnlineKey = (String.IsNullOrWhiteSpace(txtOnlineKey.Text) ? null : txtOnlineKey.Text); m_Conf.MasterServerAddress.Clear(); foreach (string ipport in lstMasterServer.Items) { m_Conf.MasterServerAddress.Add(ipport); } // Debugging m_Conf.EnableLog = Convert.ToBoolean(cmbEnableLog.Text); m_Conf.CleanLog = chkCleanLog.Checked; // Network Setting m_Conf.ListenPort = Convert.ToInt32(numNetListenPort.Value); m_Conf.MaximumPort = Convert.ToInt32(numNetMaxPort.Value); m_Conf.DiscoveryInterval = Convert.ToInt32(numNetDiscoveryInterval.Value); m_Conf.MaximumConnection = Convert.ToInt32(numNetMaxConn.Value); m_Conf.BroadcastAddress.Clear(); foreach (string address in lstNetBroadcast.Items) { m_Conf.BroadcastAddress.Add(address); } // Player Management m_Conf.AllowAnyoneConnect = chkAllowAnyToConnect.Checked; m_Conf.AdminPass = txtAdminPass.Text; m_Conf.BanList.Clear(); foreach (string steamid in lstBan.Items) { m_Conf.BanList.Add(steamid); } this.DialogResult = DialogResult.OK; }