From 20b1ecf4aaa379d296f66ca1386352924e2158ac Mon Sep 17 00:00:00 2001 From: bryanthaboi Date: Fri, 28 Aug 2026 15:07:54 -0400 Subject: [PATCH] fixing trades again --- src/import/OnlinePanel.lua | 6 ++++++ src/import/online/Room.lua | 9 +++++++- src/import/online/TradeScreen.lua | 36 +++++++++++++++++++++---------- 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/import/OnlinePanel.lua b/src/import/OnlinePanel.lua index eb468106..e90ae172 100644 --- a/src/import/OnlinePanel.lua +++ b/src/import/OnlinePanel.lua @@ -1699,6 +1699,8 @@ ensureHooks = function() OnlinePanel._tourClosed = e.text elseif e.scope == "room" and e.reason == "resume_incomplete" then OnlinePanel._roomLost = Strings("Connection lost, left the room.") + elseif e.scope == "join" then + OnlinePanel._joinError = e.text end end) client.on("tour_over", function(payload) @@ -2832,6 +2834,10 @@ function OnlinePanel.update(imp, dt) OnlinePanel.go(imp, "play") st.status, st.statusOk = notice, false end + if OnlinePanel._joinError then + st.status, st.statusOk = tostring(OnlinePanel._joinError), false + OnlinePanel._joinError = nil + end if st.pending and st.pending.done then if st.pending.error then st.status, st.statusOk = tostring(st.pending.error), false diff --git a/src/import/online/Room.lua b/src/import/online/Room.lua index 547102e3..1addd862 100644 --- a/src/import/online/Room.lua +++ b/src/import/online/Room.lua @@ -56,8 +56,15 @@ function Room.draw(imp, x, y, w, availH, m) local btnH = math.max(m.btnH, Kit.tapMin()) if not room then + local pending = st.pending + local line = Strings("You are not in a room.") + if pending and not pending.done then + line = pending.code + and Strings("Joining room %s...", tostring(pending.code)) + or Strings("Creating the room...") + end local cy = y + Ui.header(imp, x, y, w, m, Strings("Room")) - Kit.emptyBox(x, cy, w, rowH * 2, Strings("You are not in a room.")) + Kit.emptyBox(x, cy, w, rowH * 2, line) return (cy - y) + rowH * 2 end diff --git a/src/import/online/TradeScreen.lua b/src/import/online/TradeScreen.lua index 2dfcdf34..7f6734b2 100644 --- a/src/import/online/TradeScreen.lua +++ b/src/import/online/TradeScreen.lua @@ -129,12 +129,24 @@ local function remoteTrade(imp, x, y, w, m) cy = cy + Kit.textWrapped("small", OnlinePanel.remoteStageText(stage), x, cy, w, PAL.heading, 2) + tiny local mine, theirs = OnlinePanel.remoteRows(tr.remote) + local peer = tr.peerName or Strings("The other trainer") + Ui.label(Strings("Your POKeMON"), x, cy) + cy = cy + Ui.label(Strings("%s's POKeMON", tostring(peer)), + x + colW + gap, cy) + tiny local left = column(imp, x, cy, colW, m, "mine", mine, function(ref) OnlinePanel.remotePick(imp, ref) end) local right = column(imp, x + colW + gap, cy, colW, m, "theirs", theirs, function() end) cy = cy + math.max(left, right) + local give, get + for _, row in ipairs(mine) do if row.picked then give = row.label end end + for _, row in ipairs(theirs) do if row.picked then get = row.label end end + if give or get then + cy = cy + Kit.textWrapped("small", + Strings("You give %s, you get %s", give or "...", get or "..."), + x, cy, w, PAL.muted, 2) + tiny + end local third = math.floor((w - 2 * gap) / 3) LV().btn(imp, x, cy, third, rowH, "online-trade-yes", Strings("Confirm"), { kind = "primary", font = "small", enabled = stage == "confirming", @@ -211,19 +223,21 @@ function TradeScreen.draw(imp, x, y, w, availH, m) return cy - y end - cy = cy + Ui.label(Strings("Trade with"), x, cy) + tiny - local half = math.floor((w - gap) / 2) - for i, mode in ipairs(MODES) do - local id = mode.id - if Kit.chip(x + (i - 1) * (half + gap), cy, half, rowH, - Strings(mode.title), tr.mode == id, PAL.lineStrong, - "online-trade-pick-" .. id) then - LV().queueAction(imp, "online-trade-pick-" .. id, function() - OnlinePanel.tradeMode(imp, id) - end) + if not tr.remote then + cy = cy + Ui.label(Strings("Trade with"), x, cy) + tiny + local half = math.floor((w - gap) / 2) + for i, mode in ipairs(MODES) do + local id = mode.id + if Kit.chip(x + (i - 1) * (half + gap), cy, half, rowH, + Strings(mode.title), tr.mode == id, PAL.lineStrong, + "online-trade-pick-" .. id) then + LV().queueAction(imp, "online-trade-pick-" .. id, function() + OnlinePanel.tradeMode(imp, id) + end) + end end + cy = cy + rowH + gap end - cy = cy + rowH + gap if tr.mode == "remote" then cy = cy + remoteTrade(imp, x, cy, w, m)