aboutsummaryrefslogtreecommitdiff
path: root/src/join_party_menu.moon
diff options
context:
space:
mode:
authorAlexander M Pickering <alex@cogarr.net>2024-01-29 16:20:10 -0600
committerAlexander M Pickering <alex@cogarr.net>2024-01-29 16:20:10 -0600
commitc2926c5ec74d7e37da395c8c32a7ff2b4cae7d06 (patch)
treeac2bb208dab1274cdc5e9059ffe014ae19181a4c /src/join_party_menu.moon
downloadfools_rush_in-c2926c5ec74d7e37da395c8c32a7ff2b4cae7d06.tar.gz
fools_rush_in-c2926c5ec74d7e37da395c8c32a7ff2b4cae7d06.tar.bz2
fools_rush_in-c2926c5ec74d7e37da395c8c32a7ff2b4cae7d06.zip
All the files
Diffstat (limited to 'src/join_party_menu.moon')
-rw-r--r--src/join_party_menu.moon62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/join_party_menu.moon b/src/join_party_menu.moon
new file mode 100644
index 0000000..3f7d309
--- /dev/null
+++ b/src/join_party_menu.moon
@@ -0,0 +1,62 @@
+
+main = require "main"
+world = require "world"
+color = require "color"
+bp = require "broadphase"
+ui = require "ui"
+import World from world
+
+mod = ...
+
+mod.node = am.group!
+mod.node\append(am.sprite("data/join.png"))
+default_text = "..."
+mod.load = () ->
+ mod.loaded = true
+ print("Loading join_party_menu")
+ main.root("screen")\append(mod.node)
+ mod.buttons = ui.create_join_input(mod.node)
+ mod.node\append(am.translate(0,-135)^ am.text(default_text, color.fg, "center","top")\tag("join_id"))
+ touch_indicator = am.group!
+ touch_cursor = am.sprite("data/cursor.png",vec4(1,1,1,1),"left","top")
+ backspace = ui.create_any_button(mod.node,2,2,150,-25)
+ backspace.node\append(am.translate(164,-41)^ am.scale(2)^ am.text("<-", color.fg, "left","top"))
+ touch_loc = am.translate(0,0)^ touch_cursor
+ touch_indicator\append(touch_loc)
+ mod.node\append(touch_indicator)
+ print("char selector:",char_selector)
+ mod.node\action(coroutine.create(() ->
+ while true
+ if #main.win\active_touches! > 0
+ touch = main.win\touch_position(1)
+ touch_cursor.color = vec4(1,1,1,1)
+ touch_loc.x = touch.x
+ touch_loc.y = touch.y
+ col_but = bp.check(touch.x, touch.y + 40)
+ n = mod.node("join_id")
+ if #col_but > 0
+ touch_cursor.color = vec4(0.5,0.5,0.5,0.5)
+ if main.win\touch_began(1)
+ for _, button in pairs(mod.buttons)
+ if col_but[1] == button
+ if n.text == default_text
+ n.text = ""
+ print("Found pressed button",button)
+ n.text = n.text .. button.text
+ if col_but[1] == backspace
+ n.text = n.text\sub(1,string.len(n.text)-1)
+ if #n.text > 5
+ print("Time to join!")
+ lobby = require("lobby_menu")
+ table.insert(main.action_queue,{lobby.load,{n.text}})
+ mod.unload!
+
+ coroutine.yield!
+ ))
+
+mod.unload = () ->
+ main.root("screen")\remove(mod.node)
+ for _, button in pairs(mod.buttons)
+ bp.remove(button)
+
+mod