main_menu.gd 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. extends Panel
  2. func _on_start_pressed():
  3. get_node("/root/global").level = 1
  4. get_node("/root/global").spell_level = 1
  5. change_scenes("res://Scenes/intro.xscn")
  6. func _on_license_pressed():
  7. get_node("license_panel").popup()
  8. get_node("license_panel").get_node("button_close").grab_focus()
  9. func _on_credits_pressed():
  10. change_scenes("res://Scenes/credits.xscn")
  11. func _on_extra_pressed():
  12. get_node("extra_panel").get_node("instructions").set_text("Enter a secret word here!\n\n")
  13. get_node("extra_panel").get_node("entry_box").clear()
  14. get_node("extra_panel").popup()
  15. get_node("extra_panel").get_node("entry_box").grab_focus()
  16. func _on_quit_pressed():
  17. OS.get_main_loop().quit()
  18. func _on_close_license_pressed():
  19. get_node("license_panel").hide()
  20. get_node("button_license").grab_focus()
  21. func _on_accept_extra(entry):
  22. if (entry == "tabletennis"):
  23. print("tabletennis")
  24. elif (entry == "dogfight"):
  25. print("dogfight")
  26. else:
  27. get_node("extra_panel").get_node("instructions").set_text("Enter a secret word here!\n\nBeat the game to learn secrets!")
  28. func _on_accept_extra_pressed():
  29. _on_accept_extra(get_node("extra_panel").get_node("entry_box").get_text())
  30. func _on_close_extra_pressed():
  31. get_node("extra_panel").hide()
  32. get_node("button_extra").grab_focus()
  33. func _ready():
  34. get_node("button_start").grab_focus()
  35. get_node("button_start").connect("pressed", self, "_on_start_pressed")
  36. get_node("button_license").connect("pressed", self, "_on_license_pressed")
  37. get_node("button_credits").connect("pressed", self, "_on_credits_pressed")
  38. get_node("button_extra").connect("pressed", self, "_on_extra_pressed")
  39. get_node("button_quit").connect("pressed", self, "_on_quit_pressed")
  40. get_node("license_panel").get_node("button_close").connect("pressed", self, "_on_close_license_pressed")
  41. get_node("extra_panel").get_node("button_close").connect("pressed", self, "_on_close_extra_pressed")
  42. get_node("extra_panel").get_node("button_accept").connect("pressed", self, "_on_accept_extra_pressed")
  43. get_node("extra_panel").get_node("entry_box").connect("text_entered", self, "_on_accept_extra")
  44. var f = File.new()
  45. var err = f.open("res://gpl.txt", File.READ)
  46. var gpl_as_text = f.get_as_text()
  47. f.close()
  48. get_node("license_panel").get_node("licenses").get_node("Game License").push_align(0)
  49. get_node("license_panel").get_node("licenses").get_node("Game License").add_text(gpl_as_text)
  50. f = File.new()
  51. err = f.open("res://apache.txt", File.READ)
  52. var apache_as_text = f.get_as_text()
  53. get_node("license_panel").get_node("licenses").get_node("Fonts License").push_align(0)
  54. get_node("license_panel").get_node("licenses").get_node("Fonts License").add_text(apache_as_text)
  55. get_node("music").set_stream(load("res://Music/mainmenu.ogg"))
  56. get_node("music").play()
  57. get_node("music").set_loop(true)
  58. func change_scenes(next_scene):
  59. get_node("music").queue_free()
  60. get_node("/root/global").goto_scene(next_scene)