mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-19 04:06:10 +02:00
Bug squashing and translation mods (#311)
* audio timing stuff * bug fixes and translation additions * translation stuff * Update modkit.py * better asset resolution
This commit is contained in:
+25
-24
@@ -21,6 +21,7 @@ local Logger = require("src.core.Logger")
|
||||
local Protocol = require("src.link.Protocol")
|
||||
local Runtime = require("src.mods.Runtime")
|
||||
local TurnOrder = require("src.battle.TurnOrder")
|
||||
local Strings = require("src.core.Strings")
|
||||
|
||||
local LinkBattle = {}
|
||||
|
||||
@@ -177,18 +178,18 @@ function LinkBattle.new(game, net, opts)
|
||||
local theirName = opts.theirName or "FOE"
|
||||
|
||||
if not Handshake.battleAllowed(opts.verdict) then
|
||||
return nil, "Link battle needs\nthe same mods on\nboth games."
|
||||
return nil, Strings("Link battle needs\nthe same mods on\nboth games.")
|
||||
end
|
||||
|
||||
-- both parties pass through the same pack->unpack clamp on both
|
||||
-- machines, so the copies are identical everywhere
|
||||
local unpackOpts = { strict = opts.strict or false, forceLevel = opts.forceLevel }
|
||||
local myParty, myErr = unpackParty(game, opts.myParty, unpackOpts, function(p)
|
||||
return ("Your %s can't\nbattle on the\nother game."):format(tostring(p.species))
|
||||
return Strings("Your %s can't\nbattle on the\nother game.", tostring(p.species))
|
||||
end)
|
||||
if not myParty then return nil, myErr end
|
||||
local theirParty, theirErr = unpackParty(game, opts.theirParty, unpackOpts, function(p, why)
|
||||
return ("Their %s isn't\nin this game.\n(%s)"):format(tostring(p.species), tostring(why))
|
||||
return Strings("Their %s isn't\nin this game.\n(%s)", tostring(p.species), tostring(why))
|
||||
end)
|
||||
if not theirParty then return nil, theirErr end
|
||||
if #myParty == 0 or #theirParty == 0 then
|
||||
@@ -232,7 +233,7 @@ function LinkBattle.new(game, net, opts)
|
||||
self.enemyParty = theirParty
|
||||
self.playerParty = myParty -- intro ball row uses the clamped copies
|
||||
self.opponentName = theirName
|
||||
self.introText = ("%s wants\nto battle!"):format(theirName)
|
||||
self.introText = Strings("%s wants\nto battle!", theirName)
|
||||
self.remoteHashes = {}
|
||||
self.localHashes = {}
|
||||
self.remoteParts = {}
|
||||
@@ -292,7 +293,7 @@ function LinkBattle.new(game, net, opts)
|
||||
battle = s, side = s.sides[2], battler = s.enemy, previous = previous,
|
||||
})
|
||||
s.enemySendingOut = true
|
||||
s:sayNext(("%s sent\nout %s!"):format(theirName, s.enemy.name))
|
||||
s:sayNext(Strings("%s sent\nout %s!", theirName, s.enemy.name))
|
||||
s:actNext(function()
|
||||
s.enemySendingOut = false
|
||||
s:startGrowIn(s.enemy)
|
||||
@@ -315,8 +316,9 @@ function LinkBattle.new(game, net, opts)
|
||||
tostring(turn), component, tostring(localH), tostring(remoteH))
|
||||
Runtime.emit("link.desync", { turn = turn, component = component,
|
||||
localHash = localH, remoteHash = remoteH })
|
||||
endAsDraw(s, ("Link desync!\n%s differs.\fAre both games\nrunning the same\nmods?")
|
||||
:format(component))
|
||||
endAsDraw(s, Strings(
|
||||
"Link desync!\n%s differs.\fAre both games\nrunning the same\nmods?",
|
||||
component))
|
||||
end
|
||||
|
||||
-- a verified turn stays recorded: consuming it here left a finished
|
||||
@@ -349,7 +351,7 @@ function LinkBattle.new(game, net, opts)
|
||||
local function resolveLockstep(s, myMsg, theirMsg)
|
||||
if myMsg.kind == "run" or theirMsg.kind == "run" then
|
||||
local who = myMsg.kind == "run" and game.save.player.name or theirName
|
||||
endAsDraw(s, ("%s ran from\nthe battle!"):format(who))
|
||||
endAsDraw(s, Strings("%s ran from\nthe battle!", who))
|
||||
return
|
||||
end
|
||||
s.phase = "messages"
|
||||
@@ -479,9 +481,9 @@ function LinkBattle.new(game, net, opts)
|
||||
party = myParty,
|
||||
onSwitch = function(mon)
|
||||
if mon == s.player.mon then
|
||||
s:say(("%s is\nalready out!"):format(s.player.name))
|
||||
s:say(Strings("%s is\nalready out!", s.player.name))
|
||||
elseif mon.hp <= 0 then
|
||||
s:say("There's no will\nto fight!")
|
||||
s:say(Strings("There's no will\nto fight!"))
|
||||
else
|
||||
s:resolveSwitch(mon)
|
||||
end
|
||||
@@ -491,7 +493,7 @@ function LinkBattle.new(game, net, opts)
|
||||
end
|
||||
|
||||
self.openItems = function(s)
|
||||
s:say("Items can't be\nused in a link\nbattle!")
|
||||
s:say(Strings("Items can't be\nused in a link\nbattle!"))
|
||||
s.phase = "messages"
|
||||
s.afterQueue = "menu"
|
||||
end
|
||||
@@ -509,7 +511,7 @@ function LinkBattle.new(game, net, opts)
|
||||
return
|
||||
end
|
||||
end
|
||||
s:sayNext(("%s is out of\nPOKéMON!\f%s wins!"):format(game.save.player.name,
|
||||
s:sayNext(Strings("%s is out of\nPOKéMON!\f%s wins!", game.save.player.name,
|
||||
theirName))
|
||||
s.result = "lose"
|
||||
s.afterQueue = "finish"
|
||||
@@ -522,7 +524,7 @@ function LinkBattle.new(game, net, opts)
|
||||
return
|
||||
end
|
||||
end
|
||||
s:sayNext(("%s is out of\nPOKéMON!\f%s wins!"):format(theirName,
|
||||
s:sayNext(Strings("%s is out of\nPOKéMON!\f%s wins!", theirName,
|
||||
game.save.player.name))
|
||||
s.result = "win"
|
||||
s.afterQueue = "finish"
|
||||
@@ -543,13 +545,13 @@ function LinkBattle.new(game, net, opts)
|
||||
-- only a draw if our own simulation hasn't already decided
|
||||
-- (the winner's bye can arrive while we're still animating)
|
||||
if not s.result then
|
||||
endAsDraw(s, ("%s left the\nbattle."):format(theirName))
|
||||
endAsDraw(s, Strings("%s left the\nbattle.", theirName))
|
||||
end
|
||||
elseif msg.type == "forfeit" then
|
||||
-- the peer's own shot clock ran out; unlike a mutual RUN/desync
|
||||
-- draw, this has a definite winner (us)
|
||||
if not s.result then
|
||||
endWithResult(s, "win", ("%s ran out of\ntime!"):format(theirName))
|
||||
endWithResult(s, "win", Strings("%s ran out of\ntime!", theirName))
|
||||
end
|
||||
else
|
||||
-- a tournament control message (bracket_update, the next
|
||||
@@ -582,7 +584,7 @@ function LinkBattle.new(game, net, opts)
|
||||
if s.turnClock <= 0 then
|
||||
s.turnClockActive = false
|
||||
send({ type = "forfeit" })
|
||||
endWithResult(s, "lose", "Time's up! You\nforfeit the match.")
|
||||
endWithResult(s, "lose", Strings("Time's up! You\nforfeit the match."))
|
||||
end
|
||||
elseif opts.turnLimit then
|
||||
s.turnClockActive = false
|
||||
@@ -643,17 +645,16 @@ function LinkBattle.newSpectator(game, net, opts)
|
||||
local guestName = opts.guestName or "GUEST"
|
||||
|
||||
if not Handshake.battleAllowed(opts.verdict) then
|
||||
return nil, "Link battle needs\nthe same mods on\nboth games."
|
||||
return nil, Strings("Link battle needs\nthe same mods on\nboth games.")
|
||||
end
|
||||
|
||||
local unpackOpts = { strict = opts.strict or false, forceLevel = opts.forceLevel }
|
||||
local hostParty, hostErr = unpackParty(game, opts.hostParty, unpackOpts, function(p)
|
||||
return ("%s's %s can't\nbattle on this\ngame."):format(hostName, tostring(p.species))
|
||||
return Strings("%s's %s can't\nbattle on this\ngame.", hostName, tostring(p.species))
|
||||
end)
|
||||
if not hostParty then return nil, hostErr end
|
||||
local guestParty, guestErr = unpackParty(game, opts.guestParty, unpackOpts, function(p, why)
|
||||
return ("%s's %s can't\nbattle on this\ngame.\n(%s)"):format(
|
||||
guestName, tostring(p.species), tostring(why))
|
||||
return Strings("%s's %s can't\nbattle on this\ngame.\n(%s)", guestName, tostring(p.species), tostring(why))
|
||||
end)
|
||||
if not guestParty then return nil, guestErr end
|
||||
if #hostParty == 0 or #guestParty == 0 then
|
||||
@@ -672,7 +673,7 @@ function LinkBattle.newSpectator(game, net, opts)
|
||||
self.enemyParty = guestParty
|
||||
self.playerParty = hostParty
|
||||
self.opponentName = guestName
|
||||
self.introText = ("%s vs %s!"):format(hostName, guestName)
|
||||
self.introText = Strings("%s vs %s!", hostName, guestName)
|
||||
|
||||
local function orderMove(action)
|
||||
if action and action.id then return game.data.moves[action.id] end
|
||||
@@ -712,7 +713,7 @@ function LinkBattle.newSpectator(game, net, opts)
|
||||
battle = s, side = s.sides[2], battler = s.enemy, previous = previous,
|
||||
})
|
||||
s.enemySendingOut = true
|
||||
s:sayNext(("%s sent\nout %s!"):format(guestName, s.enemy.name))
|
||||
s:sayNext(Strings("%s sent\nout %s!", guestName, s.enemy.name))
|
||||
s:actNext(function()
|
||||
s.enemySendingOut = false
|
||||
s:startGrowIn(s.enemy)
|
||||
@@ -789,7 +790,7 @@ function LinkBattle.newSpectator(game, net, opts)
|
||||
return
|
||||
end
|
||||
end
|
||||
s:sayNext(("%s is out of\nPOKéMON!\f%s wins!"):format(hostName, guestName))
|
||||
s:sayNext(Strings("%s is out of\nPOKéMON!\f%s wins!", hostName, guestName))
|
||||
s.result = "guestWin"
|
||||
s.afterQueue = "finish"
|
||||
end
|
||||
@@ -801,7 +802,7 @@ function LinkBattle.newSpectator(game, net, opts)
|
||||
return
|
||||
end
|
||||
end
|
||||
s:sayNext(("%s is out of\nPOKéMON!\f%s wins!"):format(guestName, hostName))
|
||||
s:sayNext(Strings("%s is out of\nPOKéMON!\f%s wins!", guestName, hostName))
|
||||
s.result = "hostWin"
|
||||
s.afterQueue = "finish"
|
||||
end
|
||||
|
||||
+46
-45
@@ -11,6 +11,7 @@ local Protocol = require("src.link.Protocol")
|
||||
local Runtime = require("src.mods.Runtime")
|
||||
local Screens = require("src.ui.Screens")
|
||||
local TextBox = require("src.render.TextBox")
|
||||
local Strings = require("src.core.Strings")
|
||||
|
||||
local LinkState = {}
|
||||
LinkState.__index = LinkState
|
||||
@@ -90,7 +91,7 @@ function LinkState.newJoinOnline(game, code)
|
||||
self.stage = "onlineJoining"
|
||||
else
|
||||
self.stage = "menu" -- exitWith below needs a real stage to unwind from
|
||||
self:exitWith("Link error:\n" .. (self.net.error or "?"))
|
||||
self:exitWith(Strings("Link error:\n%s", self.net.error or "?"))
|
||||
end
|
||||
return self
|
||||
end
|
||||
@@ -174,7 +175,7 @@ function LinkState:update(dt)
|
||||
if self.net then
|
||||
self.net:update()
|
||||
if self.net.error and not PRE_CONNECT_STAGES[self.stage] then
|
||||
self:exitWith("Link error:\n" .. self.net.error:sub(1, 60))
|
||||
self:exitWith(Strings("Link error:\n%s", self.net.error:sub(1, 60)))
|
||||
return
|
||||
end
|
||||
-- the peer vanished without a bye (only once the inbox is drained,
|
||||
@@ -183,7 +184,7 @@ function LinkState:update(dt)
|
||||
and not PRE_CONNECT_STAGES[self.stage] and self.stage ~= "addrEntry"
|
||||
and self.stage ~= "codeEntry" and self.stage ~= "notice"
|
||||
and self.stage ~= "battleRunning" then
|
||||
self:exitWith("The link was\nbroken.")
|
||||
self:exitWith(Strings("The link was\nbroken."))
|
||||
return
|
||||
end
|
||||
end
|
||||
@@ -201,7 +202,7 @@ function LinkState:update(dt)
|
||||
self.index = 1
|
||||
elseif self.index == 2 or self.index == 3 then
|
||||
if not Handshake.onlineAllowed(self.game) then
|
||||
self:exitWith("Online play needs\nno mods enabled.\fDisable them in\nSTART > MODS.")
|
||||
self:exitWith(Strings("Online play needs\nno mods enabled.\fDisable them in\nSTART > MODS."))
|
||||
return
|
||||
end
|
||||
if self.index == 2 then
|
||||
@@ -227,7 +228,7 @@ function LinkState:update(dt)
|
||||
if self.net:host() then
|
||||
self.stage = "hosting"
|
||||
else
|
||||
self:exitWith("Link error:\n" .. (self.net.error or "?"))
|
||||
self:exitWith(Strings("Link error:\n%s", self.net.error or "?"))
|
||||
end
|
||||
else
|
||||
self.stage = "addrEntry"
|
||||
@@ -246,7 +247,7 @@ function LinkState:update(dt)
|
||||
if self.net:hostOnline() then
|
||||
self.stage = "onlineHosting"
|
||||
else
|
||||
self:exitWith("Link error:\n" .. (self.net.error or "?"))
|
||||
self:exitWith(Strings("Link error:\n%s", self.net.error or "?"))
|
||||
end
|
||||
else
|
||||
self.stage = "codeEntry"
|
||||
@@ -284,7 +285,7 @@ function LinkState:update(dt)
|
||||
if self.net:joinOnline(nil, code) then
|
||||
self.stage = "onlineJoining"
|
||||
else
|
||||
self:exitWith("Link error:\n" .. (self.net.error or "?"))
|
||||
self:exitWith(Strings("Link error:\n%s", self.net.error or "?"))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -323,7 +324,7 @@ function LinkState:update(dt)
|
||||
if self.net:join(table.concat(octets, ".")) then
|
||||
self.stage = "joining"
|
||||
else
|
||||
self:exitWith("Link error:\n" .. (self.net.error or "?"))
|
||||
self:exitWith(Strings("Link error:\n%s", self.net.error or "?"))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -433,7 +434,7 @@ function LinkState:update(dt)
|
||||
end
|
||||
if not battle then
|
||||
self.net:send({ type = "bye" })
|
||||
self:exitWith(why or "Link battle\ncan't start.", "error")
|
||||
self:exitWith(why or Strings("Link battle\ncan't start."), "error")
|
||||
return
|
||||
end
|
||||
self.game.stack:push(battle)
|
||||
@@ -491,8 +492,8 @@ function LinkState:updateTrade(input)
|
||||
local t = self.trade
|
||||
|
||||
if t.stage == "cancelled" then
|
||||
self:exitWith(t.error and ("The trade stopped:\n%s."):format(t.error)
|
||||
or "The trade was\ncancelled.")
|
||||
self:exitWith(t.error and Strings("The trade stopped:\n%s.", t.error)
|
||||
or Strings("The trade was\ncancelled."))
|
||||
return
|
||||
end
|
||||
if t.stage == "done" then
|
||||
@@ -520,7 +521,7 @@ function LinkState:updateTrade(input)
|
||||
enemyOtId = received.otId,
|
||||
onDone = function()
|
||||
game.stack:push(TextBox.new(game,
|
||||
("Trade completed!\f%s received\n%s!"):format(game.save.player.name, name),
|
||||
Strings("Trade completed!\f%s received\n%s!", game.save.player.name, name),
|
||||
function()
|
||||
if evoTo then
|
||||
-- via="TRADE": a trade evolution cannot be B-cancelled
|
||||
@@ -547,7 +548,7 @@ function LinkState:updateTrade(input)
|
||||
-- the trade) -- B is dead after that, matching the A branch's own
|
||||
-- self.confirmed == nil guard
|
||||
self.net:send({ type = "bye" })
|
||||
self:exitWith("The trade was\ncancelled.")
|
||||
self:exitWith(Strings("The trade was\ncancelled."))
|
||||
elseif t.stage == "picking" and input:wasPressed("a") then
|
||||
if t:canPick(self.index) then
|
||||
self.net:send(t:pick(self.index))
|
||||
@@ -574,30 +575,30 @@ end
|
||||
function LinkState:draw()
|
||||
if self.stage == "menu" then
|
||||
drawTitle("BOIS CLUB LIVE")
|
||||
Font.draw("LINK CABLE (LAN)", 32, 44)
|
||||
Font.draw("ONLINE MATCH", 32, 60)
|
||||
Font.draw("TOURNAMENT", 32, 76)
|
||||
Font.draw(Strings("LINK CABLE (LAN)"), 32, 44)
|
||||
Font.draw(Strings("ONLINE MATCH"), 32, 60)
|
||||
Font.draw(Strings("TOURNAMENT"), 32, 76)
|
||||
Font.drawCode(CURSOR, 24, 44 + (self.index - 1) * 16)
|
||||
|
||||
elseif self.stage == "lanMenu" then
|
||||
drawTitle("LINK CABLE (LAN)")
|
||||
Font.draw("HOST A GAME", 32, 48)
|
||||
Font.draw("JOIN A GAME", 32, 68)
|
||||
Font.draw(Strings("HOST A GAME"), 32, 48)
|
||||
Font.draw(Strings("JOIN A GAME"), 32, 68)
|
||||
Font.drawCode(CURSOR, 24, self.index == 1 and 48 or 68)
|
||||
Font.draw("UDP port " .. Net.defaultPort(), 8, 128)
|
||||
Font.draw(Strings("UDP port %s", Net.defaultPort()), 8, 128)
|
||||
|
||||
elseif self.stage == "onlineMenu" then
|
||||
drawTitle("ONLINE MATCH")
|
||||
Font.draw("HOST ONLINE", 32, 48)
|
||||
Font.draw("JOIN ONLINE", 32, 68)
|
||||
Font.draw(Strings("HOST ONLINE"), 32, 48)
|
||||
Font.draw(Strings("JOIN ONLINE"), 32, 68)
|
||||
Font.drawCode(CURSOR, 24, self.index == 1 and 48 or 68)
|
||||
|
||||
elseif self.stage == "onlineHosting" then
|
||||
drawTitle("HOSTING ONLINE")
|
||||
Font.draw("Tell your friend", 16, 40)
|
||||
Font.draw("the code:", 16, 52)
|
||||
Font.draw(Strings("Tell your friend"), 16, 40)
|
||||
Font.draw(Strings("the code:"), 16, 52)
|
||||
Font.draw(self.net.code or "??????", 32, 68)
|
||||
Font.draw("Waiting for join...", 8, 96)
|
||||
Font.draw(Strings("Waiting for join..."), 8, 96)
|
||||
|
||||
elseif self.stage == "codeEntry" then
|
||||
drawTitle("ENTER CODE")
|
||||
@@ -609,18 +610,18 @@ function LinkState:draw()
|
||||
Font.drawCode(0xEE, x, 76) -- ▼ under the active slot
|
||||
end
|
||||
end
|
||||
Font.draw("A: connect B: back", 8, 128)
|
||||
Font.draw(Strings("A: connect B: back"), 8, 128)
|
||||
|
||||
elseif self.stage == "onlineJoining" then
|
||||
drawTitle("CONNECTING...")
|
||||
Font.draw("Calling...", 8, 56)
|
||||
Font.draw(Strings("Calling..."), 8, 56)
|
||||
Font.draw(self.net.target or "", 8, 72)
|
||||
|
||||
elseif self.stage == "hosting" then
|
||||
drawTitle("HOSTING")
|
||||
Font.draw("Friend joins at:", 16, 48)
|
||||
Font.draw(Strings("Friend joins at:"), 16, 48)
|
||||
Font.draw(self.net.address or "?", 16, 64)
|
||||
Font.draw("Waiting for join...", 8, 96)
|
||||
Font.draw(Strings("Waiting for join..."), 8, 96)
|
||||
|
||||
elseif self.stage == "addrEntry" then
|
||||
drawTitle("ENTER HOST ADDRESS")
|
||||
@@ -635,34 +636,34 @@ function LinkState:draw()
|
||||
for octet = 1, 3 do
|
||||
Font.draw(".", 16 + octet * 32 - 8, 64)
|
||||
end
|
||||
Font.draw("Port: " .. Net.defaultPort(), 16, 96)
|
||||
Font.draw("A: connect B: back", 8, 128)
|
||||
Font.draw(Strings("Port: %s", Net.defaultPort()), 16, 96)
|
||||
Font.draw(Strings("A: connect B: back"), 8, 128)
|
||||
|
||||
elseif self.stage == "joining" then
|
||||
drawTitle("JOINING...")
|
||||
Font.draw("Calling...", 8, 56)
|
||||
Font.draw(Strings("Calling..."), 8, 56)
|
||||
Font.draw(self.net.target or "", 8, 72)
|
||||
|
||||
elseif self.stage == "modeSelect" then
|
||||
drawTitle("CONNECTED!")
|
||||
Font.draw("TRADE", 32, 48)
|
||||
Font.draw("BATTLE", 32, 68)
|
||||
Font.draw(Strings("TRADE"), 32, 48)
|
||||
Font.draw(Strings("BATTLE"), 32, 68)
|
||||
Font.drawCode(CURSOR, 24, self.index == 1 and 48 or 68)
|
||||
|
||||
elseif self.stage == "battleOptions" then
|
||||
drawTitle("BATTLE OPTIONS")
|
||||
Font.draw("LEVELS:", 16, 56)
|
||||
Font.draw(Strings("LEVELS:"), 16, 56)
|
||||
Font.draw(forceLevelLabel(self.levelChoice or ANY), 88, 56)
|
||||
Font.draw("A: continue B: back", 8, 128)
|
||||
Font.draw(Strings("A: continue B: back"), 8, 128)
|
||||
|
||||
elseif self.stage == "waitMode" or self.stage == "waitHello" then
|
||||
drawTitle("CONNECTED!")
|
||||
if self.stage == "waitHello" then
|
||||
Font.draw("Checking the", 16, 56)
|
||||
Font.draw("other game...", 16, 72)
|
||||
Font.draw(Strings("Checking the"), 16, 56)
|
||||
Font.draw(Strings("other game..."), 16, 72)
|
||||
else
|
||||
Font.draw("Waiting for the", 16, 56)
|
||||
Font.draw("host to choose...", 16, 72)
|
||||
Font.draw(Strings("Waiting for the"), 16, 56)
|
||||
Font.draw(Strings("host to choose..."), 16, 72)
|
||||
end
|
||||
|
||||
elseif self.stage == "notice" then
|
||||
@@ -671,12 +672,12 @@ function LinkState:draw()
|
||||
if i > 8 then break end -- what fits above the prompt row
|
||||
Font.draw(line, 8, 24 + (i - 1) * 12)
|
||||
end
|
||||
Font.draw(self.noticeExits and "A: back" or "A: trade anyway", 8, 128)
|
||||
Font.draw(self.noticeExits and "A: back" or Strings("A: trade anyway"), 8, 128)
|
||||
|
||||
elseif self.stage == "trade" then
|
||||
drawTitle("TRADE")
|
||||
local t = self.trade
|
||||
Font.draw("YOURS", 8, 20)
|
||||
Font.draw(Strings("YOURS"), 8, 20)
|
||||
for i, mon in ipairs(self.game.save.party) do
|
||||
local def = self.game.data.pokemon[mon.species]
|
||||
local label = (mon.nickname or def.name):sub(1, 8)
|
||||
@@ -684,7 +685,7 @@ function LinkState:draw()
|
||||
Font.draw(label, 16, 20 + i * 12)
|
||||
if i == self.index then Font.drawCode(CURSOR, 8, 20 + i * 12) end
|
||||
end
|
||||
Font.draw("THEIRS", 84, 20)
|
||||
Font.draw(Strings("THEIRS"), 84, 20)
|
||||
for i, mon in ipairs(t.theirParty or {}) do
|
||||
local def = self.game.data.pokemon[mon.species]
|
||||
Font.draw((mon.nickname or def.name):sub(1, 8), 92, 20 + i * 12)
|
||||
@@ -695,16 +696,16 @@ function LinkState:draw()
|
||||
elseif t.stage == "waitParty" then hint = "Exchanging data..."
|
||||
elseif t.stage == "picking" then
|
||||
hint = t:canPick(self.index) and "Pick one to trade"
|
||||
or "X: not on theirs"
|
||||
or Strings("X: not on theirs")
|
||||
elseif t.stage == "waitPick" then hint = "Waiting for them..."
|
||||
elseif t.stage == "confirming" then
|
||||
hint = self.confirmed and "Waiting..." or "A: trade B: cancel"
|
||||
hint = self.confirmed and "Waiting..." or Strings("A: trade B: cancel")
|
||||
end
|
||||
Font.draw(hint or "", 8, 132)
|
||||
|
||||
elseif self.stage == "battleWait" or self.stage == "battleRunning" then
|
||||
drawTitle("LINK BATTLE")
|
||||
Font.draw("Exchanging data...", 16, 64)
|
||||
Font.draw(Strings("Exchanging data..."), 16, 64)
|
||||
end
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
end
|
||||
|
||||
+13
-9
@@ -26,6 +26,7 @@
|
||||
|
||||
local Json = require("src.link.Json")
|
||||
local Logger = require("src.core.Logger")
|
||||
local Strings = require("src.core.Strings")
|
||||
|
||||
local hasEnet, enet = pcall(require, "enet")
|
||||
if not hasEnet then enet = nil end
|
||||
@@ -173,7 +174,7 @@ function Net:connectTCP(addr)
|
||||
tcp:settimeout(5)
|
||||
local ok, err = tcp:connect(host, port)
|
||||
if not ok then
|
||||
self.error = ("can't reach relay %s:%d\n(%s)"):format(host, port, tostring(err))
|
||||
self.error = Strings("can't reach relay %s:%d\n(%s)", host, port, tostring(err))
|
||||
return false
|
||||
end
|
||||
tcp:settimeout(0)
|
||||
@@ -236,11 +237,14 @@ local function handleGenericRelayControl(self, msg)
|
||||
self.paired = true
|
||||
return true
|
||||
elseif msg.type == "join_error" then
|
||||
self.error = ({
|
||||
not_found = "That code wasn't\nfound.",
|
||||
full = "That game already\nhas two players.",
|
||||
expired = "That code has\nexpired.",
|
||||
})[msg.reason] or ("Couldn't join:\n%s"):format(tostring(msg.reason))
|
||||
self.error = Strings(({
|
||||
not_found = Strings.source("That code wasn't\nfound."),
|
||||
full = Strings.source("That game already\nhas two players."),
|
||||
expired = Strings.source("That code has\nexpired."),
|
||||
})[msg.reason] or "")
|
||||
if self.error == "" then
|
||||
self.error = Strings("Couldn't join:\n%s", tostring(msg.reason))
|
||||
end
|
||||
self.closed = true
|
||||
return true
|
||||
elseif msg.type == "peer_gone" then
|
||||
@@ -328,7 +332,7 @@ function Net:update()
|
||||
-- an unreachable join target surfaces as a service error
|
||||
-- (ICMP unreachable on the connected UDP socket)
|
||||
if self.mode == "joining" and not self.paired then
|
||||
self.error = ("no answer from\n%s"):format(self.target or "the host")
|
||||
self.error = Strings("no answer from\n%s", self.target or "the host")
|
||||
else
|
||||
self.error = tostring(event)
|
||||
end
|
||||
@@ -358,14 +362,14 @@ function Net:update()
|
||||
self.closed = true
|
||||
if not self.paired then
|
||||
self.error = self.error or
|
||||
("no answer from\n%s"):format(self.target or "the host")
|
||||
Strings("no answer from\n%s", self.target or "the host")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if self.mode == "joining" and not self.paired
|
||||
and self.joinDeadline and now() > self.joinDeadline then
|
||||
self.error = ("no answer from\n%s"):format(self.target or "the host")
|
||||
self.error = Strings("no answer from\n%s", self.target or "the host")
|
||||
self.closed = true
|
||||
pcall(function() self.peer:disconnect_now() end)
|
||||
end
|
||||
|
||||
+35
-35
@@ -18,6 +18,7 @@ local Protocol = require("src.link.Protocol")
|
||||
local Runtime = require("src.mods.Runtime")
|
||||
local Sound = require("src.core.Sound")
|
||||
local TextBox = require("src.render.TextBox")
|
||||
local Strings = require("src.core.Strings")
|
||||
|
||||
local Tournament = {}
|
||||
Tournament.__index = Tournament
|
||||
@@ -128,7 +129,7 @@ end
|
||||
function Tournament:startHosting()
|
||||
self.net = Net.new()
|
||||
if not self.net:connectTCP(Net.defaultRelayAddress()) then
|
||||
self:exitWith("Link error:\n" .. (self.net.error or "?"))
|
||||
self:exitWith(Strings("Link error:\n%s", self.net.error or "?"))
|
||||
return
|
||||
end
|
||||
local size, minL, maxL = partyStats(self.game.save.party)
|
||||
@@ -151,7 +152,7 @@ end
|
||||
function Tournament:startJoining(code)
|
||||
self.net = Net.new()
|
||||
if not self.net:connectTCP(Net.defaultRelayAddress()) then
|
||||
self:exitWith("Link error:\n" .. (self.net.error or "?"))
|
||||
self:exitWith(Strings("Link error:\n%s", self.net.error or "?"))
|
||||
return
|
||||
end
|
||||
local size, minL, maxL = partyStats(self.game.save.party)
|
||||
@@ -171,9 +172,9 @@ end
|
||||
-- -------------------------------------------------------------------
|
||||
|
||||
local JOIN_ERROR_TEXT = {
|
||||
not_found = "That code wasn't\nfound.",
|
||||
already_started = "That tournament\nhas already begun.",
|
||||
expired = "That code has\nexpired.",
|
||||
not_found = Strings.source("That code wasn't\nfound."),
|
||||
already_started = Strings.source("That tournament\nhas already begun."),
|
||||
expired = Strings.source("That code has\nexpired."),
|
||||
}
|
||||
|
||||
function Tournament:handleMessage(msg)
|
||||
@@ -198,17 +199,17 @@ function Tournament:handleMessage(msg)
|
||||
end
|
||||
elseif msg.type == "tournament_host_error" then
|
||||
if msg.reason == "party_ineligible" then
|
||||
self:exitWith(("Can't host:\nneed %d Pokemon\nLv %s-%s."):format(
|
||||
msg.requiredPartySize, levelLabel(msg.minLevel), levelLabel(msg.maxLevel)))
|
||||
self:exitWith(Strings("Can't host:\nneed %d Pokemon\nLv %s-%s.", msg.requiredPartySize, levelLabel(msg.minLevel), levelLabel(msg.maxLevel)))
|
||||
else
|
||||
self:exitWith("Couldn't host\nthat tournament.")
|
||||
self:exitWith(Strings("Couldn't host\nthat tournament."))
|
||||
end
|
||||
elseif msg.type == "tournament_join_error" then
|
||||
if msg.reason == "party_ineligible" then
|
||||
self:exitWith(("Your party needs\n%d Pokemon, Lv\n%s-%s."):format(
|
||||
msg.requiredPartySize, levelLabel(msg.minLevel), levelLabel(msg.maxLevel)))
|
||||
self:exitWith(Strings("Your party needs\n%d Pokemon, Lv\n%s-%s.", msg.requiredPartySize, levelLabel(msg.minLevel), levelLabel(msg.maxLevel)))
|
||||
else
|
||||
self:exitWith(JOIN_ERROR_TEXT[msg.reason] or "Couldn't join\nthat tournament.")
|
||||
self:exitWith(JOIN_ERROR_TEXT[msg.reason]
|
||||
and Strings(JOIN_ERROR_TEXT[msg.reason])
|
||||
or Strings("Couldn't join\nthat tournament."))
|
||||
end
|
||||
elseif msg.type == "tournament_roster" then
|
||||
self.roster = msg.players
|
||||
@@ -281,7 +282,7 @@ function Tournament:beginMatchBattle()
|
||||
-- shouldn't happen (both sides already passed the online-play mods
|
||||
-- gate), but a mismatched engine/build is still possible -- bail out
|
||||
-- of just this match rather than crash the tournament
|
||||
self:exitWith("Link error:\nversion mismatch\nwith opponent.")
|
||||
self:exitWith(Strings("Link error:\nversion mismatch\nwith opponent."))
|
||||
return
|
||||
end
|
||||
self.linkSeed = self.isHost and love.math.random(1, 2 ^ 30) or nil
|
||||
@@ -351,11 +352,11 @@ function Tournament:update(dt)
|
||||
self.net:update()
|
||||
if self.net.error and self.stage ~= "menu" and self.stage ~= "hostSettings"
|
||||
and self.stage ~= "codeEntry" then
|
||||
self:exitWith("Link error:\n" .. self.net.error:sub(1, 60))
|
||||
self:exitWith(Strings("Link error:\n%s", self.net.error:sub(1, 60)))
|
||||
return
|
||||
end
|
||||
if self.net.closed and self.stage ~= "done" then
|
||||
self:exitWith("The tournament\nconnection was\nlost.")
|
||||
self:exitWith(Strings("The tournament\nconnection was\nlost."))
|
||||
return
|
||||
end
|
||||
end
|
||||
@@ -381,7 +382,7 @@ function Tournament:update(dt)
|
||||
and LinkBattle.newHost(self.game, self.net, self.pendingBattleOpts)
|
||||
or LinkBattle.newGuest(self.game, self.net, self.pendingBattleOpts)
|
||||
if not battle then
|
||||
self:exitWith(why or "Link battle\ncan't start.")
|
||||
self:exitWith(why or Strings("Link battle\ncan't start."))
|
||||
return
|
||||
end
|
||||
-- anything after `party` in this same batch belongs to the
|
||||
@@ -418,7 +419,7 @@ function Tournament:update(dt)
|
||||
forceLevel = levelForWire(self.settings.forceLevel),
|
||||
})
|
||||
if not battle then
|
||||
self:exitWith(why or "Can't watch this\nmatch.")
|
||||
self:exitWith(why or Strings("Can't watch this\nmatch."))
|
||||
return
|
||||
end
|
||||
for j = #msgs, i + 1, -1 do
|
||||
@@ -541,8 +542,8 @@ local SETTINGS_LABELS = { "POKEMON", "MIN LV", "MAX LV", "TIMER", "LEVELS", "PLA
|
||||
function Tournament:draw()
|
||||
if self.stage == "menu" then
|
||||
drawTitle("TOURNAMENT")
|
||||
Font.draw("HOST", 32, 48)
|
||||
Font.draw("JOIN", 32, 68)
|
||||
Font.draw(Strings("HOST"), 32, 48)
|
||||
Font.draw(Strings("JOIN"), 32, 68)
|
||||
Font.drawCode(CURSOR, 24, self.index == 1 and 48 or 68)
|
||||
|
||||
elseif self.stage == "hostSettings" then
|
||||
@@ -561,7 +562,7 @@ function Tournament:draw()
|
||||
Font.draw(values[i], 96, y)
|
||||
if i == self.settingsIndex then Font.drawCode(CURSOR, 8, y) end
|
||||
end
|
||||
Font.draw("START: create", 8, 128)
|
||||
Font.draw(Strings("START: create"), 8, 128)
|
||||
|
||||
elseif self.stage == "codeEntry" then
|
||||
drawTitle("ENTER CODE")
|
||||
@@ -573,28 +574,27 @@ function Tournament:draw()
|
||||
Font.drawCode(0xEE, x, 76)
|
||||
end
|
||||
end
|
||||
Font.draw("A: join B: back", 8, 128)
|
||||
Font.draw(Strings("A: join B: back"), 8, 128)
|
||||
|
||||
elseif self.stage == "registering" then
|
||||
drawTitle("CONNECTING...")
|
||||
Font.draw("B: cancel", 8, 128)
|
||||
Font.draw(Strings("B: cancel"), 8, 128)
|
||||
|
||||
elseif self.stage == "bracket" or self.stage == "matchHello"
|
||||
or self.stage == "matchWaitParty" or self.stage == "spectateWait" then
|
||||
drawTitle(("TOURNAMENT %s"):format(self.code or "??????"))
|
||||
drawTitle(Strings("TOURNAMENT %s", self.code or "??????"))
|
||||
if self.bracket then
|
||||
local y = 20
|
||||
for _, round in ipairs(self.bracket.rounds) do
|
||||
Font.draw(("ROUND %d"):format(round.round), 8, y)
|
||||
Font.draw(Strings("ROUND %d", round.round), 8, y)
|
||||
y = y + 10
|
||||
for _, m in ipairs(round.matches) do
|
||||
local line
|
||||
if m.bye then
|
||||
line = ("%s (bye)"):format(m.a or m.b or "?")
|
||||
line = Strings("%s (bye)", m.a or m.b or "?")
|
||||
else
|
||||
local mark = m.state == "live" and "*" or (m.winner and "" or "")
|
||||
line = ("%s%s vs %s%s"):format(
|
||||
m.winner == m.a and ">" or " ", m.a or "?",
|
||||
line = Strings("%s%s vs %s%s", m.winner == m.a and ">" or " ", m.a or "?",
|
||||
m.b or "?", m.winner == m.b and "<" or (mark == "*" and " *" or ""))
|
||||
end
|
||||
Font.draw(line, 12, y)
|
||||
@@ -604,11 +604,11 @@ function Tournament:draw()
|
||||
end
|
||||
else
|
||||
if self.participating == false then
|
||||
Font.draw("(organizing --", 16, 32)
|
||||
Font.draw("not playing)", 16, 42)
|
||||
Font.draw(Strings("(organizing --"), 16, 32)
|
||||
Font.draw(Strings("not playing)"), 16, 42)
|
||||
end
|
||||
Font.draw("Waiting for", 16, 48)
|
||||
Font.draw("players to join:", 16, 60)
|
||||
Font.draw(Strings("Waiting for"), 16, 48)
|
||||
Font.draw(Strings("players to join:"), 16, 60)
|
||||
local y = 60
|
||||
for i, name in ipairs(self.roster) do
|
||||
y = 60 + i * 10
|
||||
@@ -620,18 +620,18 @@ function Tournament:draw()
|
||||
end
|
||||
end
|
||||
if self.isCreator and #self.roster >= 2 and not self.bracket then
|
||||
Font.draw("A: START B: cancel", 8, 132)
|
||||
Font.draw(Strings("A: START B: cancel"), 8, 132)
|
||||
else
|
||||
Font.draw("B: cancel", 8, 132)
|
||||
Font.draw(Strings("B: cancel"), 8, 132)
|
||||
end
|
||||
|
||||
elseif self.stage == "done" then
|
||||
drawTitle("TOURNAMENT OVER")
|
||||
if self.champion then
|
||||
Font.draw(("%s is the"):format(self.champion), 16, 56)
|
||||
Font.draw("champion!", 16, 68)
|
||||
Font.draw(Strings("%s is the", self.champion), 16, 56)
|
||||
Font.draw(Strings("champion!"), 16, 68)
|
||||
end
|
||||
Font.draw("A: continue", 8, 128)
|
||||
Font.draw(Strings("A: continue"), 8, 128)
|
||||
end
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user