summaryrefslogtreecommitdiff
path: root/src/menu/main.moon
diff options
context:
space:
mode:
authorAlexander M Pickering <alex@cogarr.net>2025-01-21 16:02:51 -0600
committerAlexander M Pickering <alex@cogarr.net>2025-01-21 16:02:51 -0600
commit0370d64b3bd7914be55358817e52bbc8a529a7d3 (patch)
treea717bb9582f8a4c8dc7caf0d455e25113c7b8704 /src/menu/main.moon
parentda9dd31f504d30f33922cdf362a7c01673a6b927 (diff)
downloadggj25-0370d64b3bd7914be55358817e52bbc8a529a7d3.tar.gz
ggj25-0370d64b3bd7914be55358817e52bbc8a529a7d3.tar.bz2
ggj25-0370d64b3bd7914be55358817e52bbc8a529a7d3.zip
work
Diffstat (limited to 'src/menu/main.moon')
-rw-r--r--src/menu/main.moon67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/menu/main.moon b/src/menu/main.moon
new file mode 100644
index 0000000..764ce28
--- /dev/null
+++ b/src/menu/main.moon
@@ -0,0 +1,67 @@
+ui = require("ui")
+router = require("router")
+world = require("world")
+menu = {}
+
+buttons = {}
+buttons_data = {
+ {
+ text: "Settings"
+ on: () =>
+ menu.destroy!
+ require("menu.settings").initalize!
+ }
+ {
+ text: "Join"
+ on: () =>
+ menu.destroy!
+ require("menu.join").initalize!
+ }
+ {
+ text: "Host"
+ on: () =>
+ print("Setting co...")
+ if not @node.co
+ @node.co = coroutine.create(() ->
+ server = router.Router!
+ server\initalize!
+ server
+ )
+ button = @
+ @node\action(() =>
+ print("In coroutine, menu is", menu)
+ if @co and coroutine.status(@co) ~= "dead"
+ succ, val = coroutine.resume(@co)
+ if not succ
+ error(debug.traceback(@co,val))
+ if type(val) == "string"
+ print("Setting text", val)
+ button.text.text = val
+ else
+ print("Returned router")
+ world.router = val
+ menu.destroy!
+ require("menu.playername").initalize(true)
+ )
+ }
+ {
+ text: "Tutorial"
+ on: () =>
+ menu.destroy!
+ print("Load tutorial level")
+ }
+}
+menu.initalize = () ->
+ starty = -200
+ for i = starty, ((#buttons_data-1) * (64 + 32)) + starty, 64 + 32
+ print("making button", #buttons + 1)
+ buttons[#buttons + 1] = ui.button(-100,i,200,64,buttons_data[#buttons + 1].text)
+ buttons[#buttons].on = buttons_data[#buttons].on
+
+ print("intalize")
+
+menu.destroy = () ->
+ for button in *buttons
+ ui.delete(button)
+
+menu