-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated examples, added custom_eventman example
- Loading branch information
1 parent
e70fc89
commit b36fd67
Showing
13 changed files
with
99 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System.Collections.Generic; | ||
using SFML.Graphics; | ||
using SFML.Window; | ||
namespace Program; | ||
|
||
public readonly struct SimpleEventPasser : IEventMan | ||
{ | ||
private readonly List<Event> _events; | ||
public SimpleEventPasser() => _events = new(); | ||
public readonly void HandleEvent(Event eve) | ||
{ | ||
switch (eve.Type) | ||
{ | ||
case EventType.Closed: | ||
case EventType.LostFocus: | ||
case EventType.GainedFocus: | ||
case EventType.KeyPressed: | ||
case EventType.KeyReleased: | ||
_events.Add(eve); | ||
break; | ||
default: // Filtering out all other events | ||
break; | ||
} | ||
} | ||
public readonly void PrepareFrame() => _events.Clear(); | ||
public IEnumerable<Event> ProcessEvents() => _events; | ||
} | ||
public static class Program | ||
{ | ||
public static void Main() | ||
{ | ||
var event_man = new SimpleEventPasser(); | ||
var window = new RenderWindow( | ||
new(640, 480), | ||
"Custom Event Manager example", | ||
Styles.Default, | ||
event_man | ||
); | ||
while (window.IsOpen) | ||
{ | ||
window.Clear(Color.Black); | ||
window.DispatchEvents(); | ||
window.Display(); | ||
foreach (var e in event_man.ProcessEvents()) | ||
{ | ||
System.Console.WriteLine(e.ToString()); | ||
if (e.Type == EventType.Closed) | ||
{ | ||
window.Close(); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\SFML.Net\SFML.Net.csproj" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>disable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters