/// <summary>
/// Represents an application that have a GameWindow of OpenTK.
/// </summary>
- /// <since_tizen> 5 </since_tizen>
public class TizenGameApplication : CoreUIApplication
{
private TizenGameWindow window;
/// <summary>
/// Gets the GameWindow instance that created in OnCreate() method.
/// </summary>
- /// <since_tizen> 5 </since_tizen>
public IGameWindow Window => window;
/// <summary>
/// Gets the Window Attributes instance that include the window attributes could be changed by the user.
/// </summary>
- /// <since_tizen> 5 </since_tizen>
public ITizenWindowAttributes WindowAttributes => window;
/// <summary>
/// <summary>
/// Initializes the TizenGameApplication class.
/// </summary>
- /// <since_tizen> 5 </since_tizen>
public TizenGameApplication() : base(new TizenGameCoreBackend())
{
}
/// Overrides this method if you want to handle the behavior when the application is resumed.
/// If base.OnResume() is not called, the event 'Resumed' will not be emitted.
/// </summary>
- /// <since_tizen> 3 </since_tizen>
protected override void OnResume()
{
- window.Paused = false;
base.OnResume();
}
/// Overrides this method if you want to handle the behavior when the application is paused.
/// If base.OnPause() is not called, the event 'Paused' will not be emitted.
/// </summary>
- /// <since_tizen> 3 </since_tizen>
protected override void OnPause()
{
- window.Paused = true;
base.OnPause();
}
/// Runs the UI application's main loop. The GameWindow uses the maximum update rate.
/// </summary>
/// <param name="args">Arguments from the commandline.</param>
- /// <since_tizen> 3 </since_tizen>
public override void Run(string[] args)
{
Run(args, 0.0, 0.0);
/// </summary>
/// <param name="args">Arguments from the commandline.</param>
/// <param name="updatesPerSecond">The frequency of UpdateFrame events.</param>
- /// <since_tizen> 5 </since_tizen>
public void Run(string[] args, double updatesPerSecond)
{
Run(args, updatesPerSecond, 0.0);
/// <param name="args">Arguments from the commandline.</param>
/// <param name="updatesPerSecond">The frequency of UpdateFrame events.</param>
/// <param name="framesPerSecond">The frequency of RenderFrame events.</param>
- /// <since_tizen> 5 </since_tizen>
public void Run(string[] args, double updatesPerSecond, double framesPerSecond)
{
// Initialize SDL2
SDL2.SDL.SetMainReady();
Toolkit.Init();
- // Set Create Window
- Backend.AddEventHandler(TizenGameCoreBackend.WindowCreationEventType, () =>
+ // Set Internal Event Handlers
+ Backend.AddEventHandler(TizenGameCoreBackend.InternalCreateEventType, () =>
{
window = new TizenGameWindow(GraphicsMode, DisplayDevice.Default, GLMajor, GLMinor);
});
+ Backend.AddEventHandler(TizenGameCoreBackend.InternalTerminateEventType, () =>
+ {
+ window.Exit();
+ });
+
+ Backend.AddEventHandler(TizenGameCoreBackend.InternalResumeEventType, () =>
+ {
+ window.Paused = false;
+ });
+
+ Backend.AddEventHandler(TizenGameCoreBackend.InternalPauseEventType, () =>
+ {
+ window.Paused = true;
+ });
+
+
// Configure callbacks for application events
base.Run(args);
/// <summary>
/// Exits the main loop of the application.
/// </summary>
- /// <since_tizen> 3 </since_tizen>
public override void Exit()
{
window.Exit();
{
internal class TizenGameCoreBackend : DefaultCoreBackend
{
- internal readonly static string WindowCreationEventType = "WindowCreation";
+ internal static readonly string InternalCreateEventType = "_TGCB_CREATE_EVENT_TYPE_";
+ internal static readonly string InternalTerminateEventType = "_TGCB_TERMINATE_EVENT_TYPE_";
+ internal static readonly string InternalResumeEventType = "_TGCB_RESUME_EVENT_TYPE_";
+ internal static readonly string InternalPauseEventType = "_TGCB_PAUSE_EVENT_TYPE_";
private readonly SDL2.EventFilter EventFilterDelegate_GCUnsafe;
private readonly IntPtr EventFilterDelegate;
handler?.Invoke();
}
- if (Handlers.ContainsKey(WindowCreationEventType))
+ if (Handlers.ContainsKey(InternalCreateEventType))
{
- var handler = Handlers[WindowCreationEventType] as Action;
+ var handler = Handlers[InternalCreateEventType] as Action;
handler?.Invoke();
}
var handler = Handlers[EventType.Terminated] as Action;
handler?.Invoke();
}
+
+ if (Handlers.ContainsKey(InternalTerminateEventType))
+ {
+ var handler = Handlers[InternalTerminateEventType] as Action;
+ handler?.Invoke();
+ }
}
private void OnAppControlNative(IntPtr appControlHandle)
private void OnResumeNative()
{
+ if (Handlers.ContainsKey(InternalResumeEventType))
+ {
+ var handler = Handlers[InternalResumeEventType] as Action;
+ handler?.Invoke();
+ }
+
if (Handlers.ContainsKey(EventType.Resumed))
{
var handler = Handlers[EventType.Resumed] as Action;
private void OnPauseNative()
{
+ if (Handlers.ContainsKey(InternalPauseEventType))
+ {
+ var handler = Handlers[InternalPauseEventType] as Action;
+ handler?.Invoke();
+ }
+
if (Handlers.ContainsKey(EventType.Paused))
{
var handler = Handlers[EventType.Paused] as Action;