Browse Source

Merge pull request #1312 from paulloz/csharp-pause-quit

Translate documentation on Pause and Quit Requests to C#
Chris Bradfield 7 years ago
parent
commit
246db5f415
2 changed files with 42 additions and 5 deletions
  1. 16 2
      tutorials/misc/handling_quit_requests.rst
  2. 26 3
      tutorials/misc/pausing_games.rst

+ 16 - 2
tutorials/misc/handling_quit_requests.rst

@@ -20,18 +20,32 @@ requested: MainLoop.NOTIFICATION_WM_QUIT.
 
 
 Handling it is done as follows (on any node):
 Handling it is done as follows (on any node):
 
 
-::
+.. tabs::
+ .. code-tab:: gdscript GDScript
 
 
     func _notification(what):
     func _notification(what):
         if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST:
         if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST:
             get_tree().quit() # default behavior
             get_tree().quit() # default behavior
 
 
+ .. code-tab:: csharp
+
+    public override void _Notification(int what)
+    {
+        if (what == MainLoop.NotificationWmQuitRequest)
+            GetTree().Quit(); // default behavior
+    }
+
 When developing mobile apps, quitting is not desired unless the user is
 When developing mobile apps, quitting is not desired unless the user is
 on the main screen, so the behavior can be changed.
 on the main screen, so the behavior can be changed.
 
 
 It is important to note that by default, Godot apps have the built-in
 It is important to note that by default, Godot apps have the built-in
 behavior to quit when quit is requested, this can be changed:
 behavior to quit when quit is requested, this can be changed:
 
 
-::
+.. tabs::
+ .. code-tab:: gdscript GDScript
 
 
     get_tree().set_auto_accept_quit(false)
     get_tree().set_auto_accept_quit(false)
+
+ .. code-tab:: csharp
+
+    GetTree().SetAutoAcceptQuit(false);

+ 26 - 3
tutorials/misc/pausing_games.rst

@@ -23,10 +23,15 @@ To set pause mode, the pause state must be set. This is done by assigning
 "true" to the :ref:`SceneTree.paused <class_SceneTree_paused>` member
 "true" to the :ref:`SceneTree.paused <class_SceneTree_paused>` member
 variable:
 variable:
 
 
-::
+.. tabs::
+ .. code-tab:: gdscript GDScript
 
 
     get_tree().paused = true
     get_tree().paused = true
 
 
+ .. code-tab:: csharp
+
+    GetTree().Paused = true;
+
 Doing so will have the following behavior:
 Doing so will have the following behavior:
 
 
 -  2D and 3D physics will be stopped.
 -  2D and 3D physics will be stopped.
@@ -78,19 +83,37 @@ scene tree will continue working when paused.
 Finally, make it so when a pause button is pressed (any button will do),
 Finally, make it so when a pause button is pressed (any button will do),
 enable the pause and show the pause screen.
 enable the pause and show the pause screen.
 
 
-::
+.. tabs::
+ .. code-tab:: gdscript GDScript
 
 
     func _on_pause_button_pressed():
     func _on_pause_button_pressed():
         get_tree().paused = true
         get_tree().paused = true
         $pause_popup.show()
         $pause_popup.show()
 
 
+ .. code-tab:: csharp
+
+    public void _on_pause_button_pressed()
+    {
+        GetTree().Paused = true;
+        ((Control)GetNode("pause_popup")).Show();
+    }
+
 To remove the pause, just do the opposite when the pause screen is
 To remove the pause, just do the opposite when the pause screen is
 closed:
 closed:
 
 
-::
+.. tabs::
+ .. code-tab:: gdscript GDScript
 
 
     func _on_pause_popup_close_pressed():
     func _on_pause_popup_close_pressed():
         $pause_popup.hide()
         $pause_popup.hide()
         get_tree().paused = false
         get_tree().paused = false
 
 
+ .. code-tab:: csharp
+
+    public void _on_pause_popup_close_pressed()
+    {
+        ((Control)GetNode("pause_popup")).Hide();
+        GetTree().Paused = false;
+    }
+
 And that should be all!
 And that should be all!