Skip to content

Commit

Permalink
Add support for games without titles (Killing Floor), Add support for…
Browse files Browse the repository at this point in the history
… Unreal Engine games, Clean up some code.
  • Loading branch information
Andrew Sampson committed Apr 9, 2017
1 parent 20bfc58 commit b533c0a
Show file tree
Hide file tree
Showing 19 changed files with 594 additions and 466 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,4 @@ Backup*/
UpgradeLog*.XML

Installer/*setup.exe
.vs/
33 changes: 17 additions & 16 deletions BorderlessGaming.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ public void Start()
/// </summary>
private void DoMainWork()
{
while (!this.workerTaskToken.IsCancellationRequested)
while (!workerTaskToken.IsCancellationRequested)
{
// update the processlist
this.UpdateProcesses();
UpdateProcesses();

if (this.AutoHandleFavorites)
if (AutoHandleFavorites)
{
// check favorites against the cache
foreach (var pd in _processDetails)
Expand All @@ -100,7 +100,7 @@ private void UpdateProcesses()

try
{
if (!this.AutoHandleFavorites)
if (!AutoHandleFavorites)
{
MainWindow frm = MainWindow.ext();

Expand All @@ -111,30 +111,30 @@ private void UpdateProcesses()
}
catch { } // swallow any exceptions in attempting to check window minimize/visibility state

lock (this.updateLock)
lock (updateLock)
{
// check existing processes for changes (auto-prune)
for (int i = 0; i < this._processDetails.Count;)
for (int i = 0; i < _processDetails.Count;)
{
try
{
ProcessDetails pd = this._processDetails[i];
var pd = _processDetails[i];

bool should_be_pruned = pd.ProcessHasExited;
var shouldBePruned = pd.ProcessHasExited;

if (!should_be_pruned)
if (!shouldBePruned)
{
string current_title = "";
var currentTitle = "";

if (!pd.NoAccess)
{
// 2 or 10 seconds until window title timeout, depending on slow-window detection mode
Tools.StartMethodMultithreadedAndWait(() => { current_title = Native.GetWindowTitle(pd.WindowHandle); }, (Utilities.AppEnvironment.SettingValue("SlowWindowDetection", false)) ? 10 : 2);
should_be_pruned = should_be_pruned || (pd.WindowTitle != current_title);
Tools.StartMethodMultithreadedAndWait(() => { currentTitle = Native.GetWindowTitle(pd.WindowHandle); }, (AppEnvironment.SettingValue("SlowWindowDetection", false)) ? 10 : 2);
shouldBePruned = shouldBePruned || (pd.WindowTitle != currentTitle);
}
}

if (should_be_pruned)
if (shouldBePruned)
{
if (pd.MadeBorderless)
HandlePrunedProcess(pd);
Expand All @@ -160,6 +160,7 @@ private void UpdateProcesses()
if (!_processDetails.Select(p => p.Proc.Id).Contains(pd.Proc.Id) ||
!_processDetails.Select(p => p.WindowTitle).Contains(pd.WindowTitle))
_processDetails.Add(pd);

}, _processDetails.WindowPtrSet);
}
catch { } // swallow any exceptions in attempting to add new windows
Expand All @@ -171,12 +172,12 @@ private void UpdateProcesses()

public Task RefreshProcesses()
{
lock (this.updateLock)
lock (updateLock)
{
this._processDetails.ClearProcesses();
_processDetails.ClearProcesses();
}

return Task.Factory.StartNew(this.UpdateProcesses);
return Task.Factory.StartNew(UpdateProcesses);
}

/// <summary>
Expand Down
40 changes: 34 additions & 6 deletions BorderlessGaming.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
# Visual Studio 15
VisualStudioVersion = 15.0.26228.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BorderlessGaming_Standalone_UserUAC", "BorderlessGaming_Standalone_UserUAC.csproj", "{25526352-8406-4773-BB5B-C2017E82FD65}"
EndProject
Expand All @@ -12,21 +12,49 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{25526352-8406-4773-BB5B-C2017E82FD64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD64}.Debug|Any CPU.Build.0 = Debug|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD64}.Release|Any CPU.ActiveCfg = Release|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD64}.Release|Any CPU.Build.0 = Release|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD65}.Debug|Any CPU.Build.0 = Debug|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD65}.Debug|x64.ActiveCfg = Debug|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD65}.Debug|x64.Build.0 = Debug|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD65}.Debug|x86.ActiveCfg = Debug|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD65}.Debug|x86.Build.0 = Debug|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD65}.Release|Any CPU.ActiveCfg = Release|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD65}.Release|Any CPU.Build.0 = Release|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD65}.Release|x64.ActiveCfg = Release|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD65}.Release|x64.Build.0 = Release|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD65}.Release|x86.ActiveCfg = Release|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD65}.Release|x86.Build.0 = Release|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD66}.Debug|Any CPU.Build.0 = Debug|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD66}.Debug|x64.ActiveCfg = Debug|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD66}.Debug|x64.Build.0 = Debug|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD66}.Debug|x86.ActiveCfg = Debug|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD66}.Debug|x86.Build.0 = Debug|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD66}.Release|Any CPU.ActiveCfg = Release|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD66}.Release|Any CPU.Build.0 = Release|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD66}.Release|x64.ActiveCfg = Release|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD66}.Release|x64.Build.0 = Release|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD66}.Release|x86.ActiveCfg = Release|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD66}.Release|x86.Build.0 = Release|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD64}.Debug|Any CPU.Build.0 = Debug|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD64}.Debug|x64.ActiveCfg = Debug|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD64}.Debug|x64.Build.0 = Debug|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD64}.Debug|x86.ActiveCfg = Debug|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD64}.Debug|x86.Build.0 = Debug|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD64}.Release|Any CPU.ActiveCfg = Release|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD64}.Release|Any CPU.Build.0 = Release|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD64}.Release|x64.ActiveCfg = Release|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD64}.Release|x64.Build.0 = Release|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD64}.Release|x86.ActiveCfg = Release|Any CPU
{25526352-8406-4773-BB5B-C2017E82FD64}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
62 changes: 33 additions & 29 deletions Common/Favorites.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Favorites : ObservableCollection<Favorites.Favorite>
public Favorites(string path)
{
this.path = path;
this.CollectionChanged += OnCollectionChanged;
CollectionChanged += OnCollectionChanged;
Load();
}

Expand Down Expand Up @@ -84,10 +84,7 @@ public void Load()

public bool CanAdd(string item)
{
foreach (var fav in this)
if (fav.SearchText == item)
return false;
return true;
return this.All(fav => fav.SearchText != item);
}

public bool CanRemove(string item)
Expand Down Expand Up @@ -153,30 +150,37 @@ public override string ToString() // so that the ListView control knows how to d
{
string extra_details = "";

if (this.Kind == FavoriteKinds.ByBinaryName)
extra_details += " [Process]";
else if (this.Kind == FavoriteKinds.ByRegexString)
extra_details += " [Regex]";
else if (this.Kind != FavoriteKinds.ByTitleText)
extra_details += " [?]";

extra_details += ((this.ShouldMaximize) ? " [Max]" : "");
extra_details += ((this.SizeMode == SizeModes.NoChange) ? " [NoSize]" : "");
extra_details += ((this.TopMost) ? " [Top]" : "");
extra_details += ((this.RemoveMenus) ? " [NoMenu]" : "");
extra_details += ((this.HideWindowsTaskbar) ? " [NoTaskbar]" : "");
extra_details += ((this.HideMouseCursor) ? " [NoMouse]" : "");
extra_details += ((this.DelayBorderless) ? " [Delay]" : "");

if (this.OffsetL != 0 || this.OffsetR != 0 || this.OffsetT != 0 || this.OffsetB != 0)
extra_details += " [" + this.OffsetL.ToString() + "L," + this.OffsetR.ToString() + "R," +
this.OffsetT.ToString() + "T," + this.OffsetB.ToString() + "B]";

if (this.PositionX != 0 || this.PositionY != 0 || this.PositionW != 0 || this.PositionH != 0)
extra_details += " [" + this.PositionX.ToString() + "x" + this.PositionY.ToString() + "-" +
(this.PositionX + this.PositionW).ToString() + "x" + (this.PositionY + this.PositionH).ToString() + "]";

return this.SearchText + extra_details;
switch (Kind)
{
case FavoriteKinds.ByBinaryName:
extra_details += " [Process]";
break;
case FavoriteKinds.ByRegexString:
extra_details += " [Regex]";
break;
default:
if (Kind != FavoriteKinds.ByTitleText)
extra_details += " [?]";
break;
}

extra_details += ((ShouldMaximize) ? " [Max]" : "");
extra_details += ((SizeMode == SizeModes.NoChange) ? " [NoSize]" : "");
extra_details += ((TopMost) ? " [Top]" : "");
extra_details += ((RemoveMenus) ? " [NoMenu]" : "");
extra_details += ((HideWindowsTaskbar) ? " [NoTaskbar]" : "");
extra_details += ((HideMouseCursor) ? " [NoMouse]" : "");
extra_details += ((DelayBorderless) ? " [Delay]" : "");

if (OffsetL != 0 || OffsetR != 0 || OffsetT != 0 || OffsetB != 0)
extra_details += " [" + OffsetL.ToString() + "L," + OffsetR.ToString() + "R," +
OffsetT.ToString() + "T," + OffsetB.ToString() + "B]";

if (PositionX != 0 || PositionY != 0 || PositionW != 0 || PositionH != 0)
extra_details += " [" + PositionX.ToString() + "x" + PositionY.ToString() + "-" +
(PositionX + PositionW).ToString() + "x" + (PositionY + PositionH).ToString() + "]";

return SearchText + extra_details;
}
catch { }

Expand Down
2 changes: 1 addition & 1 deletion Common/HiddenProcesses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public HiddenProcesses(string path)
alwaysHideSet = new HashSet<string>();
userHideSet = new HashSet<string>();
Init();
this.CollectionChanged += OnCollectionChanged;
CollectionChanged += OnCollectionChanged;
}

private void OnCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
Expand Down
Loading

0 comments on commit b533c0a

Please sign in to comment.