Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / ui / setting / SettingPanel.cs
@小李xl 小李xl on 13 Oct 2023 1 KB 设置更新,添加左下角网站
  1. using Godot;
  2.  
  3. namespace UI.Setting;
  4.  
  5. public partial class SettingPanel : Setting
  6. {
  7.  
  8. public override void OnCreateUi()
  9. {
  10. if (PrevUi != null)
  11. {
  12. //返回上一级UI
  13. L_Back.Instance.Pressed += () =>
  14. {
  15. OpenPrevUi();
  16. };
  17. }
  18. //视频设置
  19. S_VideoItem.Instance.Pressed += () =>
  20. {
  21. S_SettingMenu.Instance.Visible = false;
  22. S_VideoSetting.Instance.Visible = true;
  23. };
  24. //键位设置
  25. S_InputItem.Instance.Pressed += () =>
  26. {
  27. S_SettingMenu.Instance.Visible = false;
  28. S_KeySetting.Instance.Visible = true;
  29. };
  30. //视频设置返回
  31. S_VideoSetting.L_Back.Instance.Pressed += () =>
  32. {
  33. S_SettingMenu.Instance.Visible = true;
  34. S_VideoSetting.Instance.Visible = false;
  35. };
  36. //键位设置返回
  37. S_KeySetting.L_Back.Instance.Pressed += () =>
  38. {
  39. S_SettingMenu.Instance.Visible = true;
  40. S_KeySetting.Instance.Visible = false;
  41. };
  42. //---------------------- 视频设置 -----------------------------
  43. //全屏属性
  44. S_FullScreen.L_CheckBox.Instance.ButtonPressed = DisplayServer.WindowGetMode() == DisplayServer.WindowMode.Fullscreen;
  45. S_FullScreen.L_CheckBox.Instance.Pressed += OnChangeFullScreen;
  46. //-----------------------------------------------------------
  47. }
  48.  
  49. public override void OnDestroyUi()
  50. {
  51. }
  52.  
  53. //切换全屏/非全屏
  54. private void OnChangeFullScreen()
  55. {
  56. var checkBox = S_FullScreen.L_CheckBox.Instance;
  57. if (checkBox.ButtonPressed)
  58. {
  59. DisplayServer.WindowSetMode(DisplayServer.WindowMode.Fullscreen);
  60. }
  61. else
  62. {
  63. DisplayServer.WindowSetMode(DisplayServer.WindowMode.Windowed);
  64. }
  65. }
  66.  
  67. }