• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Go で書き直した Ikemen


Commit MetaInfo

修订版237d812d32dfc4bca2405b9bc05bd73d4b754fea (tree)
时间2019-09-01 12:36:56
作者neatunsou <sisiy4excite@gmai...>
Commiterneatunsou

Log Message

scriptファイルを含めるようにした

更改概述

差异

--- /dev/null
+++ b/script/debug.lua
@@ -0,0 +1,122 @@
1+--One-time load of the json routines
2+json = (loadfile 'script/dkjson.lua')()
3+
4+-- Data loading from config.json
5+local file = io.open("save/config.json","r")
6+config = json.decode(file:read("*all"))
7+file:close()
8+-- This is done to get the AI level config
9+
10+if getAllowDebugKeys() then
11+ addHotkey('c', true, false, false, 'toggleClsnDraw()')
12+ addHotkey('d', true, false, false, 'toggleDebugDraw()')
13+ addHotkey('s', true, false, false, 'changeSpeed()')
14+ addHotkey('l', true, false, false, 'toggleStatusDraw()')
15+ addHotkey('1', true, false, false, 'toggleAI(1)')
16+ addHotkey('2', true, false, false, 'toggleAI(2)')
17+ addHotkey('3', true, false, false, 'toggleAI(3)')
18+ addHotkey('4', true, false, false, 'toggleAI(4)')
19+ addHotkey('5', true, false, false, 'toggleAI(5)')
20+ addHotkey('6', true, false, false, 'toggleAI(6)')
21+ addHotkey('7', true, false, false, 'toggleAI(7)')
22+ addHotkey('8', true, false, false, 'toggleAI(8)')
23+ addHotkey('F1', false, false, false, 'kill(2);kill(4);kill(6);kill(8)')
24+ addHotkey('F1', true, false, false, 'kill(1);kill(3);kill(5);kill(7)')
25+ addHotkey('F2', false, false, false, 'kill(1,1);kill(2,1);kill(3,1);kill(4,1);kill(5,1);kill(6,1);kill(7,1);kill(8,1)')
26+ addHotkey('F2', true, false, false, 'kill(1,1);kill(3,1);kill(5,1);kill(7,1)')
27+ addHotkey('F2', false, false, true, 'kill(2,1);kill(4,1);kill(6,1);kill(8,1)')
28+ addHotkey('F3', false, false, false, 'powMax(1);powMax(2)')
29+ addHotkey('F4', false, false, false, 'roundReset()')
30+ addHotkey('F4', false, false, true, 'reload()')
31+ addHotkey('F5', false, false, false, 'setTime(0)')
32+ addHotkey(
33+ 'SPACE', false, false, false,
34+ 'full(1);full(2);full(3);full(4);full(5);full(6);full(7);full(8);setTime(getRoundTime())')
35+ addHotkey('i', true, false, false, 'stand(1);stand(2);stand(3);stand(4);stand(5);stand(6);stand(7);stand(8)')
36+end
37+addHotkey('PAUSE', false, false, false, 'togglePause()')
38+addHotkey('SCROLLLOCK', false, false, false, 'step()')
39+
40+
41+speed = 1.0
42+
43+function changeSpeed()
44+ if speed >= 4 then
45+ speed = 0.25
46+ else
47+ speed = speed*2.0
48+ end
49+ setAccel(speed)
50+end
51+
52+function toggleAI(p)
53+ local oldid = id()
54+ if player(p) then
55+ if ailevel() > 0 then
56+ setAILevel(0)
57+ else
58+ setAILevel(config.Difficulty)
59+ end
60+ playerid(oldid)
61+ end
62+end
63+
64+function kill(p, ...)
65+ local oldid = id()
66+ if player(p) then
67+ local n = ...
68+ if not n then n = 0 end
69+ setLife(n)
70+ playerid(oldid)
71+ end
72+end
73+
74+function powMax(p)
75+ local oldid = id()
76+ if player(p) then
77+ setPower(powermax())
78+ playerid(oldid)
79+ end
80+end
81+
82+function full(p)
83+ local oldid = id()
84+ if player(p) then
85+ setLife(lifemax())
86+ setPower(powermax())
87+ playerid(oldid)
88+ end
89+end
90+
91+function stand(p)
92+ local oldid = id()
93+ if player(p) then
94+ selfState(0)
95+ playerid(oldid)
96+ end
97+end
98+
99+function info()
100+ puts(
101+ string.format(
102+ 'name:%s state:%d>%d %s move:%s physics:%s',
103+ name(), prevstateno(), stateno(), statetype(), movetype(), physics()))
104+ puts(
105+ string.format(
106+ 'anim:%d %d elem:%d %d pos:%.3f,%.3f vel:%.3f,%.3f',
107+ anim(), animtime(), animelemno(0), animelemtime(animelemno(0)),
108+ posX(), posY(), velX(), velY()))
109+end
110+
111+function status(p)
112+ local oldid = id()
113+ if not player(p) then return false end
114+ ret =
115+ string.format(
116+ 'STA:%s%s%s%6d(%d) ANI:%6d(%d)%2d LIF:%5d POW:%5d TIM:%d',
117+ statetype(), movetype(), physics(), stateno(), stateOwner(),
118+ anim(), animOwner(), animelemno(0), life(), power(), time())
119+ playerid(oldid)
120+ return ret;
121+end
122+
--- /dev/null
+++ b/script/dkjson.lua
@@ -0,0 +1,714 @@
1+-- Module options:
2+local always_try_using_lpeg = true
3+local register_global_module_table = false
4+local global_module_name = 'json'
5+
6+--[==[
7+
8+David Kolf's JSON module for Lua 5.1/5.2
9+
10+Version 2.5
11+
12+
13+For the documentation see the corresponding readme.txt or visit
14+<http://dkolf.de/src/dkjson-lua.fsl/>.
15+
16+You can contact the author by sending an e-mail to 'david' at the
17+domain 'dkolf.de'.
18+
19+
20+Copyright (C) 2010-2013 David Heiko Kolf
21+
22+Permission is hereby granted, free of charge, to any person obtaining
23+a copy of this software and associated documentation files (the
24+"Software"), to deal in the Software without restriction, including
25+without limitation the rights to use, copy, modify, merge, publish,
26+distribute, sublicense, and/or sell copies of the Software, and to
27+permit persons to whom the Software is furnished to do so, subject to
28+the following conditions:
29+
30+The above copyright notice and this permission notice shall be
31+included in all copies or substantial portions of the Software.
32+
33+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
34+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
35+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
36+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
37+BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
38+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
39+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
40+SOFTWARE.
41+
42+--]==]
43+
44+-- global dependencies:
45+local pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset =
46+ pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset
47+local error, require, pcall, select = error, require, pcall, select
48+local floor, huge = math.floor, math.huge
49+local strrep, gsub, strsub, strbyte, strchar, strfind, strlen, strformat =
50+ string.rep, string.gsub, string.sub, string.byte, string.char,
51+ string.find, string.len, string.format
52+local strmatch = string.match
53+local concat = table.concat
54+
55+local json = { version = "dkjson 2.5" }
56+
57+if register_global_module_table then
58+ _G[global_module_name] = json
59+end
60+
61+local _ENV = nil -- blocking globals in Lua 5.2
62+
63+pcall (function()
64+ -- Enable access to blocked metatables.
65+ -- Don't worry, this module doesn't change anything in them.
66+ local debmeta = require "debug".getmetatable
67+ if debmeta then getmetatable = debmeta end
68+end)
69+
70+json.null = setmetatable ({}, {
71+ __tojson = function () return "null" end
72+})
73+
74+local function isarray (tbl)
75+ local max, n, arraylen = 0, 0, 0
76+ for k,v in pairs (tbl) do
77+ if k == 'n' and type(v) == 'number' then
78+ arraylen = v
79+ if v > max then
80+ max = v
81+ end
82+ else
83+ if type(k) ~= 'number' or k < 1 or floor(k) ~= k then
84+ return false
85+ end
86+ if k > max then
87+ max = k
88+ end
89+ n = n + 1
90+ end
91+ end
92+ if max > 10 and max > arraylen and max > n * 2 then
93+ return false -- don't create an array with too many holes
94+ end
95+ return true, max
96+end
97+
98+local escapecodes = {
99+ ["\""] = "\\\"", ["\\"] = "\\\\", ["\b"] = "\\b", ["\f"] = "\\f",
100+ ["\n"] = "\\n", ["\r"] = "\\r", ["\t"] = "\\t"
101+}
102+
103+local function escapeutf8 (uchar)
104+ local value = escapecodes[uchar]
105+ if value then
106+ return value
107+ end
108+ local a, b, c, d = strbyte (uchar, 1, 4)
109+ a, b, c, d = a or 0, b or 0, c or 0, d or 0
110+ if a <= 0x7f then
111+ value = a
112+ elseif 0xc0 <= a and a <= 0xdf and b >= 0x80 then
113+ value = (a - 0xc0) * 0x40 + b - 0x80
114+ elseif 0xe0 <= a and a <= 0xef and b >= 0x80 and c >= 0x80 then
115+ value = ((a - 0xe0) * 0x40 + b - 0x80) * 0x40 + c - 0x80
116+ elseif 0xf0 <= a and a <= 0xf7 and b >= 0x80 and c >= 0x80 and d >= 0x80 then
117+ value = (((a - 0xf0) * 0x40 + b - 0x80) * 0x40 + c - 0x80) * 0x40 + d - 0x80
118+ else
119+ return ""
120+ end
121+ if value <= 0xffff then
122+ return strformat ("\\u%.4x", value)
123+ elseif value <= 0x10ffff then
124+ -- encode as UTF-16 surrogate pair
125+ value = value - 0x10000
126+ local highsur, lowsur = 0xD800 + floor (value/0x400), 0xDC00 + (value % 0x400)
127+ return strformat ("\\u%.4x\\u%.4x", highsur, lowsur)
128+ else
129+ return ""
130+ end
131+end
132+
133+local function fsub (str, pattern, repl)
134+ -- gsub always builds a new string in a buffer, even when no match
135+ -- exists. First using find should be more efficient when most strings
136+ -- don't contain the pattern.
137+ if strfind (str, pattern) then
138+ return gsub (str, pattern, repl)
139+ else
140+ return str
141+ end
142+end
143+
144+local function quotestring (value)
145+ -- based on the regexp "escapable" in https://github.com/douglascrockford/JSON-js
146+ value = fsub (value, "[%z\1-\31\"\\\127]", escapeutf8)
147+ if strfind (value, "[\194\216\220\225\226\239]") then
148+ value = fsub (value, "\194[\128-\159\173]", escapeutf8)
149+ value = fsub (value, "\216[\128-\132]", escapeutf8)
150+ value = fsub (value, "\220\143", escapeutf8)
151+ value = fsub (value, "\225\158[\180\181]", escapeutf8)
152+ value = fsub (value, "\226\128[\140-\143\168-\175]", escapeutf8)
153+ value = fsub (value, "\226\129[\160-\175]", escapeutf8)
154+ value = fsub (value, "\239\187\191", escapeutf8)
155+ value = fsub (value, "\239\191[\176-\191]", escapeutf8)
156+ end
157+ return "\"" .. value .. "\""
158+end
159+json.quotestring = quotestring
160+
161+local function replace(str, o, n)
162+ local i, j = strfind (str, o, 1, true)
163+ if i then
164+ return strsub(str, 1, i-1) .. n .. strsub(str, j+1, -1)
165+ else
166+ return str
167+ end
168+end
169+
170+-- locale independent num2str and str2num functions
171+local decpoint, numfilter
172+
173+local function updatedecpoint ()
174+ decpoint = strmatch(tostring(0.5), "([^05+])")
175+ -- build a filter that can be used to remove group separators
176+ numfilter = "[^0-9%-%+eE" .. gsub(decpoint, "[%^%$%(%)%%%.%[%]%*%+%-%?]", "%%%0") .. "]+"
177+end
178+
179+updatedecpoint()
180+
181+local function num2str (num)
182+ return replace(fsub(tostring(num), numfilter, ""), decpoint, ".")
183+end
184+
185+local function str2num (str)
186+ local num = tonumber(replace(str, ".", decpoint))
187+ if not num then
188+ updatedecpoint()
189+ num = tonumber(replace(str, ".", decpoint))
190+ end
191+ return num
192+end
193+
194+local function addnewline2 (level, buffer, buflen)
195+ buffer[buflen+1] = "\n"
196+ buffer[buflen+2] = strrep (" ", level)
197+ buflen = buflen + 2
198+ return buflen
199+end
200+
201+function json.addnewline (state)
202+ if state.indent then
203+ state.bufferlen = addnewline2 (state.level or 0,
204+ state.buffer, state.bufferlen or #(state.buffer))
205+ end
206+end
207+
208+local encode2 -- forward declaration
209+
210+local function addpair (key, value, prev, indent, level, buffer, buflen, tables, globalorder, state)
211+ local kt = type (key)
212+ if kt ~= 'string' and kt ~= 'number' then
213+ return nil, "type '" .. kt .. "' is not supported as a key by JSON."
214+ end
215+ if prev then
216+ buflen = buflen + 1
217+ buffer[buflen] = ","
218+ end
219+ if indent then
220+ buflen = addnewline2 (level, buffer, buflen)
221+ end
222+ buffer[buflen+1] = quotestring (key)
223+ buffer[buflen+2] = ":"
224+ return encode2 (value, indent, level, buffer, buflen + 2, tables, globalorder, state)
225+end
226+
227+local function appendcustom(res, buffer, state)
228+ local buflen = state.bufferlen
229+ if type (res) == 'string' then
230+ buflen = buflen + 1
231+ buffer[buflen] = res
232+ end
233+ return buflen
234+end
235+
236+local function exception(reason, value, state, buffer, buflen, defaultmessage)
237+ defaultmessage = defaultmessage or reason
238+ local handler = state.exception
239+ if not handler then
240+ return nil, defaultmessage
241+ else
242+ state.bufferlen = buflen
243+ local ret, msg = handler (reason, value, state, defaultmessage)
244+ if not ret then return nil, msg or defaultmessage end
245+ return appendcustom(ret, buffer, state)
246+ end
247+end
248+
249+function json.encodeexception(reason, value, state, defaultmessage)
250+ return quotestring("<" .. defaultmessage .. ">")
251+end
252+
253+encode2 = function (value, indent, level, buffer, buflen, tables, globalorder, state)
254+ local valtype = type (value)
255+ local valmeta = getmetatable (value)
256+ valmeta = type (valmeta) == 'table' and valmeta -- only tables
257+ local valtojson = valmeta and valmeta.__tojson
258+ if valtojson then
259+ if tables[value] then
260+ return exception('reference cycle', value, state, buffer, buflen)
261+ end
262+ tables[value] = true
263+ state.bufferlen = buflen
264+ local ret, msg = valtojson (value, state)
265+ if not ret then return exception('custom encoder failed', value, state, buffer, buflen, msg) end
266+ tables[value] = nil
267+ buflen = appendcustom(ret, buffer, state)
268+ elseif value == nil then
269+ buflen = buflen + 1
270+ buffer[buflen] = "null"
271+ elseif valtype == 'number' then
272+ local s
273+ if value ~= value or value >= huge or -value >= huge then
274+ -- This is the behaviour of the original JSON implementation.
275+ s = "null"
276+ else
277+ s = num2str (value)
278+ end
279+ buflen = buflen + 1
280+ buffer[buflen] = s
281+ elseif valtype == 'boolean' then
282+ buflen = buflen + 1
283+ buffer[buflen] = value and "true" or "false"
284+ elseif valtype == 'string' then
285+ buflen = buflen + 1
286+ buffer[buflen] = quotestring (value)
287+ elseif valtype == 'table' then
288+ if tables[value] then
289+ return exception('reference cycle', value, state, buffer, buflen)
290+ end
291+ tables[value] = true
292+ level = level + 1
293+ local isa, n = isarray (value)
294+ if n == 0 and valmeta and valmeta.__jsontype == 'object' then
295+ isa = false
296+ end
297+ local msg
298+ if isa then -- JSON array
299+ buflen = buflen + 1
300+ buffer[buflen] = "["
301+ for i = 1, n do
302+ buflen, msg = encode2 (value[i], indent, level, buffer, buflen, tables, globalorder, state)
303+ if not buflen then return nil, msg end
304+ if i < n then
305+ buflen = buflen + 1
306+ buffer[buflen] = ","
307+ end
308+ end
309+ buflen = buflen + 1
310+ buffer[buflen] = "]"
311+ else -- JSON object
312+ local prev = false
313+ buflen = buflen + 1
314+ buffer[buflen] = "{"
315+ local order = valmeta and valmeta.__jsonorder or globalorder
316+ if order then
317+ local used = {}
318+ n = #order
319+ for i = 1, n do
320+ local k = order[i]
321+ local v = value[k]
322+ if v then
323+ used[k] = true
324+ buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder, state)
325+ prev = true -- add a seperator before the next element
326+ end
327+ end
328+ for k,v in pairs (value) do
329+ if not used[k] then
330+ buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder, state)
331+ if not buflen then return nil, msg end
332+ prev = true -- add a seperator before the next element
333+ end
334+ end
335+ else -- unordered
336+ for k,v in pairs (value) do
337+ buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder, state)
338+ if not buflen then return nil, msg end
339+ prev = true -- add a seperator before the next element
340+ end
341+ end
342+ if indent then
343+ buflen = addnewline2 (level - 1, buffer, buflen)
344+ end
345+ buflen = buflen + 1
346+ buffer[buflen] = "}"
347+ end
348+ tables[value] = nil
349+ else
350+ return exception ('unsupported type', value, state, buffer, buflen,
351+ "type '" .. valtype .. "' is not supported by JSON.")
352+ end
353+ return buflen
354+end
355+
356+function json.encode (value, state)
357+ state = state or {}
358+ local oldbuffer = state.buffer
359+ local buffer = oldbuffer or {}
360+ state.buffer = buffer
361+ updatedecpoint()
362+ local ret, msg = encode2 (value, state.indent, state.level or 0,
363+ buffer, state.bufferlen or 0, state.tables or {}, state.keyorder, state)
364+ if not ret then
365+ error (msg, 2)
366+ elseif oldbuffer == buffer then
367+ state.bufferlen = ret
368+ return true
369+ else
370+ state.bufferlen = nil
371+ state.buffer = nil
372+ return concat (buffer)
373+ end
374+end
375+
376+local function loc (str, where)
377+ local line, pos, linepos = 1, 1, 0
378+ while true do
379+ pos = strfind (str, "\n", pos, true)
380+ if pos and pos < where then
381+ line = line + 1
382+ linepos = pos
383+ pos = pos + 1
384+ else
385+ break
386+ end
387+ end
388+ return "line " .. line .. ", column " .. (where - linepos)
389+end
390+
391+local function unterminated (str, what, where)
392+ return nil, strlen (str) + 1, "unterminated " .. what .. " at " .. loc (str, where)
393+end
394+
395+local function scanwhite (str, pos)
396+ while true do
397+ pos = strfind (str, "%S", pos)
398+ if not pos then return nil end
399+ local sub2 = strsub (str, pos, pos + 1)
400+ if sub2 == "\239\187" and strsub (str, pos + 2, pos + 2) == "\191" then
401+ -- UTF-8 Byte Order Mark
402+ pos = pos + 3
403+ elseif sub2 == "//" then
404+ pos = strfind (str, "[\n\r]", pos + 2)
405+ if not pos then return nil end
406+ elseif sub2 == "/*" then
407+ pos = strfind (str, "*/", pos + 2)
408+ if not pos then return nil end
409+ pos = pos + 2
410+ else
411+ return pos
412+ end
413+ end
414+end
415+
416+local escapechars = {
417+ ["\""] = "\"", ["\\"] = "\\", ["/"] = "/", ["b"] = "\b", ["f"] = "\f",
418+ ["n"] = "\n", ["r"] = "\r", ["t"] = "\t"
419+}
420+
421+local function unichar (value)
422+ if value < 0 then
423+ return nil
424+ elseif value <= 0x007f then
425+ return strchar (value)
426+ elseif value <= 0x07ff then
427+ return strchar (0xc0 + floor(value/0x40),
428+ 0x80 + (floor(value) % 0x40))
429+ elseif value <= 0xffff then
430+ return strchar (0xe0 + floor(value/0x1000),
431+ 0x80 + (floor(value/0x40) % 0x40),
432+ 0x80 + (floor(value) % 0x40))
433+ elseif value <= 0x10ffff then
434+ return strchar (0xf0 + floor(value/0x40000),
435+ 0x80 + (floor(value/0x1000) % 0x40),
436+ 0x80 + (floor(value/0x40) % 0x40),
437+ 0x80 + (floor(value) % 0x40))
438+ else
439+ return nil
440+ end
441+end
442+
443+local function scanstring (str, pos)
444+ local lastpos = pos + 1
445+ local buffer, n = {}, 0
446+ while true do
447+ local nextpos = strfind (str, "[\"\\]", lastpos)
448+ if not nextpos then
449+ return unterminated (str, "string", pos)
450+ end
451+ if nextpos > lastpos then
452+ n = n + 1
453+ buffer[n] = strsub (str, lastpos, nextpos - 1)
454+ end
455+ if strsub (str, nextpos, nextpos) == "\"" then
456+ lastpos = nextpos + 1
457+ break
458+ else
459+ local escchar = strsub (str, nextpos + 1, nextpos + 1)
460+ local value
461+ if escchar == "u" then
462+ value = tonumber (strsub (str, nextpos + 2, nextpos + 5), 16)
463+ if value then
464+ local value2
465+ if 0xD800 <= value and value <= 0xDBff then
466+ -- we have the high surrogate of UTF-16. Check if there is a
467+ -- low surrogate escaped nearby to combine them.
468+ if strsub (str, nextpos + 6, nextpos + 7) == "\\u" then
469+ value2 = tonumber (strsub (str, nextpos + 8, nextpos + 11), 16)
470+ if value2 and 0xDC00 <= value2 and value2 <= 0xDFFF then
471+ value = (value - 0xD800) * 0x400 + (value2 - 0xDC00) + 0x10000
472+ else
473+ value2 = nil -- in case it was out of range for a low surrogate
474+ end
475+ end
476+ end
477+ value = value and unichar (value)
478+ if value then
479+ if value2 then
480+ lastpos = nextpos + 12
481+ else
482+ lastpos = nextpos + 6
483+ end
484+ end
485+ end
486+ end
487+ if not value then
488+ value = escapechars[escchar] or escchar
489+ lastpos = nextpos + 2
490+ end
491+ n = n + 1
492+ buffer[n] = value
493+ end
494+ end
495+ if n == 1 then
496+ return buffer[1], lastpos
497+ elseif n > 1 then
498+ return concat (buffer), lastpos
499+ else
500+ return "", lastpos
501+ end
502+end
503+
504+local scanvalue -- forward declaration
505+
506+local function scantable (what, closechar, str, startpos, nullval, objectmeta, arraymeta)
507+ local len = strlen (str)
508+ local tbl, n = {}, 0
509+ local pos = startpos + 1
510+ if what == 'object' then
511+ setmetatable (tbl, objectmeta)
512+ else
513+ setmetatable (tbl, arraymeta)
514+ end
515+ while true do
516+ pos = scanwhite (str, pos)
517+ if not pos then return unterminated (str, what, startpos) end
518+ local char = strsub (str, pos, pos)
519+ if char == closechar then
520+ return tbl, pos + 1
521+ end
522+ local val1, err
523+ val1, pos, err = scanvalue (str, pos, nullval, objectmeta, arraymeta)
524+ if err then return nil, pos, err end
525+ pos = scanwhite (str, pos)
526+ if not pos then return unterminated (str, what, startpos) end
527+ char = strsub (str, pos, pos)
528+ if char == ":" then
529+ if val1 == nil then
530+ return nil, pos, "cannot use nil as table index (at " .. loc (str, pos) .. ")"
531+ end
532+ pos = scanwhite (str, pos + 1)
533+ if not pos then return unterminated (str, what, startpos) end
534+ local val2
535+ val2, pos, err = scanvalue (str, pos, nullval, objectmeta, arraymeta)
536+ if err then return nil, pos, err end
537+ tbl[val1] = val2
538+ pos = scanwhite (str, pos)
539+ if not pos then return unterminated (str, what, startpos) end
540+ char = strsub (str, pos, pos)
541+ else
542+ n = n + 1
543+ tbl[n] = val1
544+ end
545+ if char == "," then
546+ pos = pos + 1
547+ end
548+ end
549+end
550+
551+scanvalue = function (str, pos, nullval, objectmeta, arraymeta)
552+ pos = pos or 1
553+ pos = scanwhite (str, pos)
554+ if not pos then
555+ return nil, strlen (str) + 1, "no valid JSON value (reached the end)"
556+ end
557+ local char = strsub (str, pos, pos)
558+ if char == "{" then
559+ return scantable ('object', "}", str, pos, nullval, objectmeta, arraymeta)
560+ elseif char == "[" then
561+ return scantable ('array', "]", str, pos, nullval, objectmeta, arraymeta)
562+ elseif char == "\"" then
563+ return scanstring (str, pos)
564+ else
565+ local pstart, pend = strfind (str, "^%-?[%d%.]+[eE]?[%+%-]?%d*", pos)
566+ if pstart then
567+ local number = str2num (strsub (str, pstart, pend))
568+ if number then
569+ return number, pend + 1
570+ end
571+ end
572+ pstart, pend = strfind (str, "^%a%w*", pos)
573+ if pstart then
574+ local name = strsub (str, pstart, pend)
575+ if name == "true" then
576+ return true, pend + 1
577+ elseif name == "false" then
578+ return false, pend + 1
579+ elseif name == "null" then
580+ return nullval, pend + 1
581+ end
582+ end
583+ return nil, pos, "no valid JSON value at " .. loc (str, pos)
584+ end
585+end
586+
587+local function optionalmetatables(...)
588+ if select("#", ...) > 0 then
589+ return ...
590+ else
591+ return {__jsontype = 'object'}, {__jsontype = 'array'}
592+ end
593+end
594+
595+function json.decode (str, pos, nullval, ...)
596+ local objectmeta, arraymeta = optionalmetatables(...)
597+ return scanvalue (str, pos, nullval, objectmeta, arraymeta)
598+end
599+
600+function json.use_lpeg ()
601+ local g = require ("lpeg")
602+
603+ if g.version() == "0.11" then
604+ error "due to a bug in LPeg 0.11, it cannot be used for JSON matching"
605+ end
606+
607+ local pegmatch = g.match
608+ local P, S, R = g.P, g.S, g.R
609+
610+ local function ErrorCall (str, pos, msg, state)
611+ if not state.msg then
612+ state.msg = msg .. " at " .. loc (str, pos)
613+ state.pos = pos
614+ end
615+ return false
616+ end
617+
618+ local function Err (msg)
619+ return g.Cmt (g.Cc (msg) * g.Carg (2), ErrorCall)
620+ end
621+
622+ local SingleLineComment = P"//" * (1 - S"\n\r")^0
623+ local MultiLineComment = P"/*" * (1 - P"*/")^0 * P"*/"
624+ local Space = (S" \n\r\t" + P"\239\187\191" + SingleLineComment + MultiLineComment)^0
625+
626+ local PlainChar = 1 - S"\"\\\n\r"
627+ local EscapeSequence = (P"\\" * g.C (S"\"\\/bfnrt" + Err "unsupported escape sequence")) / escapechars
628+ local HexDigit = R("09", "af", "AF")
629+ local function UTF16Surrogate (match, pos, high, low)
630+ high, low = tonumber (high, 16), tonumber (low, 16)
631+ if 0xD800 <= high and high <= 0xDBff and 0xDC00 <= low and low <= 0xDFFF then
632+ return true, unichar ((high - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000)
633+ else
634+ return false
635+ end
636+ end
637+ local function UTF16BMP (hex)
638+ return unichar (tonumber (hex, 16))
639+ end
640+ local U16Sequence = (P"\\u" * g.C (HexDigit * HexDigit * HexDigit * HexDigit))
641+ local UnicodeEscape = g.Cmt (U16Sequence * U16Sequence, UTF16Surrogate) + U16Sequence/UTF16BMP
642+ local Char = UnicodeEscape + EscapeSequence + PlainChar
643+ local String = P"\"" * g.Cs (Char ^ 0) * (P"\"" + Err "unterminated string")
644+ local Integer = P"-"^(-1) * (P"0" + (R"19" * R"09"^0))
645+ local Fractal = P"." * R"09"^0
646+ local Exponent = (S"eE") * (S"+-")^(-1) * R"09"^1
647+ local Number = (Integer * Fractal^(-1) * Exponent^(-1))/str2num
648+ local Constant = P"true" * g.Cc (true) + P"false" * g.Cc (false) + P"null" * g.Carg (1)
649+ local SimpleValue = Number + String + Constant
650+ local ArrayContent, ObjectContent
651+
652+ -- The functions parsearray and parseobject parse only a single value/pair
653+ -- at a time and store them directly to avoid hitting the LPeg limits.
654+ local function parsearray (str, pos, nullval, state)
655+ local obj, cont
656+ local npos
657+ local t, nt = {}, 0
658+ repeat
659+ obj, cont, npos = pegmatch (ArrayContent, str, pos, nullval, state)
660+ if not npos then break end
661+ pos = npos
662+ nt = nt + 1
663+ t[nt] = obj
664+ until cont == 'last'
665+ return pos, setmetatable (t, state.arraymeta)
666+ end
667+
668+ local function parseobject (str, pos, nullval, state)
669+ local obj, key, cont
670+ local npos
671+ local t = {}
672+ repeat
673+ key, obj, cont, npos = pegmatch (ObjectContent, str, pos, nullval, state)
674+ if not npos then break end
675+ pos = npos
676+ t[key] = obj
677+ until cont == 'last'
678+ return pos, setmetatable (t, state.objectmeta)
679+ end
680+
681+ local Array = P"[" * g.Cmt (g.Carg(1) * g.Carg(2), parsearray) * Space * (P"]" + Err "']' expected")
682+ local Object = P"{" * g.Cmt (g.Carg(1) * g.Carg(2), parseobject) * Space * (P"}" + Err "'}' expected")
683+ local Value = Space * (Array + Object + SimpleValue)
684+ local ExpectedValue = Value + Space * Err "value expected"
685+ ArrayContent = Value * Space * (P"," * g.Cc'cont' + g.Cc'last') * g.Cp()
686+ local Pair = g.Cg (Space * String * Space * (P":" + Err "colon expected") * ExpectedValue)
687+ ObjectContent = Pair * Space * (P"," * g.Cc'cont' + g.Cc'last') * g.Cp()
688+ local DecodeValue = ExpectedValue * g.Cp ()
689+
690+ function json.decode (str, pos, nullval, ...)
691+ local state = {}
692+ state.objectmeta, state.arraymeta = optionalmetatables(...)
693+ local obj, retpos = pegmatch (DecodeValue, str, pos, nullval, state)
694+ if state.msg then
695+ return nil, state.pos, state.msg
696+ else
697+ return obj, retpos
698+ end
699+ end
700+
701+ -- use this function only once:
702+ json.use_lpeg = function () return json end
703+
704+ json.using_lpeg = true
705+
706+ return json -- so you can get the module using json = require "dkjson".use_lpeg()
707+end
708+
709+if always_try_using_lpeg then
710+ pcall (json.use_lpeg)
711+end
712+
713+return json
714+
--- /dev/null
+++ b/script/localcoord.lua
@@ -0,0 +1,8 @@
1+-- Screenpack Localcoord
2+main.SP_Localcoord[0] = 320
3+main.SP_Localcoord[1] = 240
4+main.SP_Center = 0
5+
6+-- Lifebar Localcoord
7+main.LB_Localcoord[0] = 320
8+main.LB_Localcoord[1] = 240
\ No newline at end of file
--- /dev/null
+++ b/script/main.lua
@@ -0,0 +1,2202 @@
1+-- Disable GC during the initial load so it does not crash.
2+SetGCPercent(-1)
3+-------------------------------------------------------------
4+main = {}
5+
6+refresh()
7+math.randomseed(os.time())
8+
9+--;===========================================================
10+--; COMMON SECTION
11+--;===========================================================
12+
13+--One-time load of the json routines
14+json = (loadfile 'script/dkjson.lua')()
15+
16+-- Data loading from config.json
17+local file = io.open("save/config.json","r")
18+config = json.decode(file:read("*all"))
19+file:close()
20+
21+-- Int localcoord
22+require "script/screenpack"
23+main.IntLocalcoordValues()
24+require "script/localcoord"
25+main.CalculateLocalcoordValues()
26+main.IntLifebarScale()
27+main.SetScaleValues()
28+
29+main.p1In = 1
30+main.p2In = 2
31+--main.inputDialog = inputDialogNew()
32+
33+function main.f_setCommand(c)
34+ commandAdd(c, 'u', '$U')
35+ commandAdd(c, 'd', '$D')
36+ commandAdd(c, 'l', '$B')
37+ commandAdd(c, 'r', '$F')
38+ commandAdd(c, 'a', 'a')
39+ commandAdd(c, 'b', 'b')
40+ commandAdd(c, 'c', 'c')
41+ commandAdd(c, 'x', 'x')
42+ commandAdd(c, 'y', 'y')
43+ commandAdd(c, 'z', 'z')
44+ commandAdd(c, 's', 's')
45+ commandAdd(c, 'v', 'v')
46+ commandAdd(c, 'w', 'w')
47+ commandAdd(c, 'holds', '/s')
48+ commandAdd(c, 'su', '/s, U')
49+ commandAdd(c, 'sd', '/s, D')
50+end
51+
52+main.p1Cmd = commandNew()
53+main.f_setCommand(main.p1Cmd)
54+
55+main.p2Cmd = commandNew()
56+main.f_setCommand(main.p2Cmd)
57+
58+function main.f_cmdInput()
59+ commandInput(main.p1Cmd, main.p1In)
60+ commandInput(main.p2Cmd, main.p2In)
61+end
62+
63+--returns value depending on button pressed (a = 1; a + start = 7 etc.)
64+function main.f_btnPalNo(cmd)
65+ local s = 0
66+ if commandGetState(cmd, 'holds') then s = 6 end
67+ if commandGetState(cmd, 'a') then return 1 + s end
68+ if commandGetState(cmd, 'b') then return 2 + s end
69+ if commandGetState(cmd, 'c') then return 3 + s end
70+ if commandGetState(cmd, 'x') then return 4 + s end
71+ if commandGetState(cmd, 'y') then return 5 + s end
72+ if commandGetState(cmd, 'z') then return 6 + s end
73+ if commandGetState(cmd, 'v') then return 1 + s end
74+ if commandGetState(cmd, 'w') then return 2 + s end
75+ return 0
76+end
77+
78+--animDraw at specified coordinates
79+function main.f_animPosDraw(a, x, y)
80+ animSetPos(a, x, y)
81+ animUpdate(a)
82+ animDraw(a)
83+end
84+
85+--textImgDraw at specified coordinates
86+function main.f_textImgPosDraw(ti, x, y, align)
87+ align = align or 0
88+ textImgSetAlign(ti, align)
89+ if align == -1 then x = x + 1 end --fix for wrong offset after flipping text
90+ textImgSetPos(ti, x, y)
91+ textImgDraw(ti)
92+end
93+
94+--shortcut for creating new text with several parameters
95+function main.f_createTextImg(font, bank, align, text, x, y, scaleX, scaleY, colorR, colorG, colorB)
96+ local ti = textImgNew()
97+ if font ~= nil then
98+ textImgSetFont(ti, font)
99+ textImgSetBank(ti, bank)
100+ textImgSetAlign(ti, align)
101+ textImgSetText(ti, text)
102+ if colorR ~= nil and colorG ~= nil and colorB ~= nil then
103+ textImgSetColor(ti, colorR, colorG, colorB)
104+ end
105+ if align == -1 then x = x + 1 end --fix for wrong offset after flipping text
106+ textImgSetPos(ti, x, y)
107+ textImgSetScale(ti, scaleX, scaleY)
108+ end
109+ return ti
110+end
111+
112+--shortcut for updating text with several parameters
113+function main.f_updateTextImg(animName, font, bank, align, text, x, y, scaleX, scaleY, colorR, colorG, colorB)
114+ if font ~= nil then
115+ textImgSetFont(animName, font)
116+ textImgSetBank(animName, bank)
117+ textImgSetAlign(animName, align)
118+ textImgSetText(animName, text)
119+ if colorR ~= nil and colorG ~= nil and colorB ~= nil then
120+ textImgSetColor(animName, colorR, colorG, colorB)
121+ end
122+ if align == -1 then x = x + 1 end --fix for wrong offset after flipping text
123+ textImgSetPos(animName, x, y)
124+ textImgSetScale(animName, scaleX, scaleY)
125+ end
126+ return animName
127+end
128+
129+--dynamically adjusts alpha blending each time called based on specified values
130+local alpha1cur = 0
131+local alpha2cur = 0
132+local alpha1add = true
133+local alpha2add = true
134+function main.f_dynamicAlpha(animName, r1min, r1max, r1step, r2min, r2max, r2step)
135+ if r1step == 0 then alpha1cur = r1max end
136+ if alpha1cur < r1max and alpha1add then
137+ alpha1cur = alpha1cur + r1step
138+ if alpha1cur >= r1max then
139+ alpha1add = false
140+ end
141+ elseif alpha1cur > r1min and not alpha1add then
142+ alpha1cur = alpha1cur - r1step
143+ if alpha1cur <= r1min then
144+ alpha1add = true
145+ end
146+ end
147+ if r2step == 0 then alpha2cur = r2max end
148+ if alpha2cur < r2max and alpha2add then
149+ alpha2cur = alpha2cur + r2step
150+ if alpha2cur >= r2max then
151+ alpha2add = false
152+ end
153+ elseif alpha2cur > r2min and not alpha2add then
154+ alpha2cur = alpha2cur - r2step
155+ if alpha2cur <= r2min then
156+ alpha2add = true
157+ end
158+ end
159+ animSetAlpha(animName, alpha1cur, alpha2cur)
160+end
161+
162+--generate fading animation
163+--currently only black when average of RGB <= 128 and white if >128 colors supported
164+function main.f_fadeAnim(fadeType, ticks, r, g, b)
165+ local anim = ''
166+ if (r + g + b)/3 > 128 then --white
167+ if fadeType == 0 then --fadeout
168+ for i = 1, ticks do
169+ anim = anim .. '0,1, 0,0, 1, 0, AS' .. math.floor(256 / ticks * i) .. 'D256\n'
170+ end
171+ anim = anim .. '0,1, 0,0, -1, 0, AS256D256'
172+ elseif fadeType == 1 then --fadein
173+ for i = ticks, 1, -1 do
174+ anim = anim .. '0,1, 0,0, 1, 0, AS' .. math.floor(256 / ticks * i) .. 'D256\n'
175+ end
176+ anim = anim .. '0,1, 0,0, -1, 0, AS0D256'
177+ end
178+ else --black
179+ if fadeType == 0 then --fadeout
180+ for i = ticks, 1, -1 do
181+ anim = anim .. '0,0, 0,0, 1, 0, AS256D' .. math.floor(256 / ticks * i) .. '\n'
182+ end
183+ anim = anim .. '0,0, 0,0, -1, 0, AS256D0'
184+ elseif fadeType == 1 then --fadein
185+ for i = 1, ticks do
186+ anim = anim .. '0,0, 0,0, 1, 0, AS256D' .. math.floor(256 / ticks * i) .. '\n'
187+ end
188+ anim = anim .. '0,0, 0,0, -1, 0, AS256D256'
189+ end
190+ end
191+ anim = animNew(main.fadeSff, anim)
192+ animUpdate(anim)
193+ return anim, ticks
194+end
195+
196+--generate clearcolor animation
197+--currently only black when average of RGB <= 128 and white if >128 colors supported
198+function main.f_clearColor(r, g, b)
199+ local anim = ''
200+ if (r + g + b)/3 > 128 then
201+ anim = '0,1, 0,0, -1' --white
202+ else
203+ anim = '0,0, 0,0, -1' --black
204+ end
205+ anim = animNew(main.fadeSff, anim)
206+ animUpdate(anim)
207+ return anim
208+end
209+
210+--generate anim from table
211+function main.f_animFromTable(t, sff, x, y, scaleX, scaleY, facing, infFrame)
212+ x = x or 0
213+ y = y or 0
214+ scaleX = scaleX or 1.0
215+ scaleY = scaleY or 1.0
216+ facing = facing or '0'
217+ infFrame = infFrame or 1
218+ local facing_sav = ''
219+ local anim = ''
220+ local length = 0
221+ for i = 1, #t do
222+ local t_anim = {}
223+ for j, c in ipairs(main.f_strsplit(',', t[i])) do --split using "," delimiter
224+ t_anim[#t_anim + 1] = c
225+ end
226+ if #t_anim > 1 then
227+ --required parameters
228+ t_anim[3] = tonumber(t_anim[3]) + x
229+ t_anim[4] = tonumber(t_anim[4]) + y
230+ if tonumber(t_anim[5]) == -1 then
231+ length = length + infFrame
232+ else
233+ length = length + tonumber(t_anim[5])
234+ end
235+ --optional parameters
236+ if t_anim[6] ~= nil and not t_anim[6]:match(facing) then --flip parameter not negated by repeated flipping
237+ if t_anim[6]:match('[Hh]') then t_anim[3] = t_anim[3] + 1 end --fix for wrong offset after flipping sprites
238+ if t_anim[6]:match('[Vv]') then t_anim[4] = t_anim[4] + 1 end --fix for wrong offset after flipping sprites
239+ t_anim[6] = facing .. t_anim[6]
240+ end
241+ end
242+ for j = 1, #t_anim do
243+ if j == 1 then
244+ anim = anim .. t_anim[j]
245+ else
246+ anim = anim .. ', ' .. t_anim[j]
247+ end
248+ end
249+ anim = anim .. '\n'
250+ end
251+ local data = animNew(sff, anim)
252+ animSetScale(data, scaleX, scaleY)
253+ animUpdate(data)
254+ return data, length
255+end
256+
257+--Convert number to name and get rid of the ""
258+function main.f_getName(cell)
259+ local tmp = getCharName(cell)
260+ tmp = tmp:gsub('^["%s]*(.-)["%s]*$', '%1') --needed for s-size ikemen
261+ if main.t_selChars[cell + 1].hidden == 3 then
262+ tmp = 'Random'
263+ elseif main.t_selChars[cell + 1].hidden == 2 then
264+ tmp = ''
265+ end
266+ return tmp
267+end
268+
269+--randomizes table content
270+function main.f_shuffleTable(t)
271+ local rand = math.random
272+ assert(t, "main.f_shuffleTable() expected a table, got nil")
273+ local iterations = #t
274+ local j
275+ for i = iterations, 2, -1 do
276+ j = rand(i)
277+ t[i], t[j] = t[j], t[i]
278+ end
279+end
280+
281+--iterate over the table in order
282+-- basic usage, just sort by the keys:
283+--for k, v in main.f_sortKeys(t) do
284+-- print(k,v)
285+--end
286+-- this uses an custom sorting function ordering by score descending
287+--for k, v in main.f_sortKeys(t, function(t,a,b) return t[b] < t[a] end) do
288+-- print(k,v)
289+--end
290+function main.f_sortKeys(t, order)
291+ -- collect the keys
292+ local keys = {}
293+ for k in pairs(t) do keys[#keys + 1] = k end
294+ -- if order function given, sort it by passing the table and keys a, b,
295+ -- otherwise just sort the keys
296+ if order then
297+ table.sort(keys, function(a,b) return order(t, a, b) end)
298+ else
299+ table.sort(keys)
300+ end
301+ -- return the iterator function
302+ local i = 0
303+ return function()
304+ i = i + 1
305+ if keys[i] then
306+ return keys[i], t[keys[i]]
307+ end
308+ end
309+end
310+
311+--prints "t" table content into "toFile" file
312+function main.f_printTable(t, toFile)
313+ local toFile = toFile or 'debug/table_print.txt'
314+ local txt = ''
315+ local print_t_cache = {}
316+ local function sub_print_t(t, indent)
317+ if print_t_cache[tostring(t)] then
318+ txt = txt .. indent .. '*' .. tostring(t) .. '\n'
319+ else
320+ print_t_cache[tostring(t)] = true
321+ if type(t) == 'table' then
322+ for pos, val in pairs(t) do
323+ if type(val) == 'table' then
324+ txt = txt .. indent .. '[' .. pos .. '] => ' .. tostring(t) .. ' {' .. '\n'
325+ sub_print_t(val, indent .. string.rep(' ', string.len(tostring(pos)) + 8))
326+ txt = txt .. indent .. string.rep(' ', string.len(tostring(pos)) + 6) .. '}' .. '\n'
327+ elseif type(val) == 'string' then
328+ txt = txt .. indent .. '[' .. pos .. '] => "' .. val .. '"' .. '\n'
329+ else
330+ txt = txt .. indent .. '[' .. pos .. '] => ' .. tostring(val) ..'\n'
331+ end
332+ end
333+ else
334+ txt = txt .. indent .. tostring(t) .. '\n'
335+ end
336+ end
337+ end
338+ if type(t) == 'table' then
339+ txt = txt .. tostring(t) .. ' {' .. '\n'
340+ sub_print_t(t, ' ')
341+ txt = txt .. '}' .. '\n'
342+ else
343+ sub_print_t(t, ' ')
344+ end
345+ local file = io.open(toFile,"w+")
346+ if file == nil then return end
347+ file:write(txt)
348+ file:close()
349+end
350+
351+--prints "v" variable into "toFile" file
352+function main.f_printVar(v, toFile)
353+ local toFile = toFile or 'debug/var_print.txt'
354+ local file = io.open(toFile,"w+")
355+ file:write(v)
356+ file:close()
357+end
358+
359+--remove duplicated string pattern
360+function main.f_uniq(str, pattern, subpattern)
361+ local out = {}
362+ for s in str:gmatch(pattern) do
363+ local s2 = s:match(subpattern)
364+ if not main.f_contains(out, s2) then out[#out + 1] = s end
365+ end
366+ return table.concat(out)
367+end
368+
369+function main.f_contains(t, val)
370+ for k, v in pairs(t) do
371+ --if v == val then
372+ if v:match(val) then
373+ return true
374+ end
375+ end
376+ return false
377+end
378+
379+--- Draw string letter by letter + wrap lines.
380+-- @data: text data
381+-- @str: string (text you want to draw)
382+-- @counter: external counter (values should be increased each frame by 1 starting from 1)
383+-- @x: first line X position
384+-- @y: first line Y position
385+-- @spacing: spacing between lines (rendering Y position increase for each line)
386+-- @delay (optional): ticks (frames) delay between each letter is rendered, defaults to 0 (all text rendered immediately)
387+-- @limit (optional): maximum line length (string wraps when reached), if omitted line wraps only if string contains '\n'
388+function main.f_textRender(data, str, counter, x, y, spacing, delay, limit)
389+ local delay = delay or 0
390+ local limit = limit or -1
391+ str = tostring(str)
392+ if limit == -1 then
393+ str = str:gsub('\\n', '\n')
394+ else
395+ str = str:gsub('%s*\\n%s*', ' ')
396+ if math.floor(#str / limit) + 1 > 1 then
397+ str = main.f_wrap(str, limit, indent, indent1)
398+ end
399+ end
400+ local subEnd = math.floor(#str - (#str - counter / delay))
401+ local t = {}
402+ for line in str:gmatch('([^\r\n]*)[\r\n]?') do
403+ t[#t + 1] = line
404+ end
405+ local lengthCnt = 0
406+ for i = 1, #t do
407+ if subEnd < #str then
408+ local length = #t[i]
409+ if i > 1 and i <= #t then
410+ length = length + 1
411+ end
412+ lengthCnt = lengthCnt + length
413+ if subEnd < lengthCnt then
414+ t[i] = t[i]:sub(0, subEnd - lengthCnt)
415+ end
416+ end
417+ textImgSetText(data, t[i])
418+ textImgSetPos(data, x, y + spacing * (i - 1))
419+ textImgDraw(data)
420+ end
421+end
422+
423+--- Wrap a long string.
424+-- source: http://lua-users.org/wiki/StringRecipes
425+-- @str: string to wrap
426+-- @limit: maximum line length
427+-- @indent: regular indentation
428+-- @indent1: indentation of first line
429+function main.f_wrap(str, limit, indent, indent1)
430+ indent = indent or ''
431+ indent1 = indent1 or indent
432+ limit = limit or 72
433+ local here = 1 - #indent1
434+ return indent1 .. str:gsub("(%s+)()(%S+)()",
435+ function(sp, st, word, fi)
436+ if fi - here > limit then
437+ here = st - #indent
438+ return '\n' .. indent .. word
439+ end
440+ end
441+ )
442+end
443+
444+--Convert DEF string to table (each line = next item; %i, %s swapped with variable values)
445+function main.f_extractText(txt, v1, v2, v3, v4)
446+ local t = {v1 or '', v2 or '', v3 or '', v4 or ''}
447+ local tmp = ''
448+ txt = txt:gsub('%%[is]', '%%')
449+ for i, c in ipairs(main.f_strsplit('%%', txt)) do --split string using "%" delimiter
450+ if t[i] == '' then
451+ c = c:gsub('%s$', '')
452+ end
453+ tmp = tmp .. c .. t[i]
454+ end
455+ t = {}
456+ for i, c in ipairs(main.f_strsplit('\n', tmp)) do --split string using "\n" delimiter
457+ t[i] = c
458+ end
459+ if #t == 0 then
460+ t[1] = tmp
461+ end
462+ return t
463+end
464+
465+--ensure that correct data type is set
466+function main.f_dataType(arg)
467+ arg = arg:gsub('^%s*(.-)%s*$', '%1')
468+ if tonumber(arg) then
469+ arg = tonumber(arg)
470+ elseif arg == 'true' then
471+ arg = true
472+ elseif arg == 'false' then
473+ arg = false
474+ else
475+ arg = tostring(arg)
476+ end
477+ return arg
478+end
479+
480+--merge 2 tables into 1 overwriting values
481+function main.f_tableMerge(t1, t2)
482+ for k, v in pairs(t2) do
483+ if type(v) == "table" then
484+ if type(t1[k] or false) == "table" then
485+ main.f_tableMerge(t1[k] or {}, t2[k] or {})
486+ else
487+ t1[k] = v
488+ end
489+ elseif type(t1[k] or false) == "table" then
490+ t1[k][1] = v
491+ else
492+ t1[k] = v
493+ end
494+ end
495+ return t1
496+end
497+
498+--check if file exists
499+function main.f_fileExists(name)
500+ local f = io.open(name,'r')
501+ if f ~= nil then
502+ io.close(f)
503+ return true
504+ else
505+ return false
506+ end
507+end
508+
509+--split strings
510+function main.f_strsplit(delimiter, text)
511+ local list = {}
512+ local pos = 1
513+ if string.find('', delimiter, 1) then
514+ if string.len(text) == 0 then
515+ table.insert(list, text)
516+ else
517+ for i = 1, string.len(text) do
518+ table.insert(list, string.sub(text, i, i))
519+ end
520+ end
521+ else
522+ while true do
523+ local first, last = string.find(text, delimiter, pos)
524+ if first then
525+ table.insert(list, string.sub(text, pos, first - 1))
526+ pos = last + 1
527+ else
528+ table.insert(list, string.sub(text, pos))
529+ break
530+ end
531+ end
532+ end
533+ return list
534+end
535+
536+--expand background table with background controllers data
537+function main.f_ctrlBG(t_bg, t_ctrl)
538+ local t = {}
539+ for k, v in pairs(t_ctrl) do
540+ local t1 = t_ctrl[k].ctrl
541+ for i = 1, #t1 do
542+ for k2, v2 in pairs(t1[i].ctrlid) do
543+ local t2 = t1[i].type
544+ if t1[i].ctrlid[k2] == t_bg.id and t2 ~= 'null' then
545+ if t[t2] == nil then
546+ t[t2] = {}
547+ end
548+ t[t2][#t[t2] + 1] = {}
549+ local t3 = t[t2][#t[t2]]
550+ t3.time = {t1[i].time[1], t1[i].time[2], t1[i].time[3]}
551+ t3.timer = {t1[i].time[1], t1[i].time[2], t1[i].time[3]}
552+ if t2 == 'visible' or t2 == 'enable' or t2 == 'anim' or t2 == 'gamemode' then
553+ t3.value = t1[i].value
554+ elseif t2 == 'sinx' or t2 == 'siny' then
555+ t3.value = {t1[i].value[1], t1[i].value[2], t1[i].value[3]}
556+ elseif t2 == 'velset' or t2 == 'veladd' or t2 == 'posset' or t2 == 'posadd' then
557+ if t1[i].x ~= nil then
558+ t3.x = t1[i].x
559+ end
560+ if t1[i].y ~= nil then
561+ t3.y = t1[i].y
562+ end
563+ end
564+ end
565+ end
566+ end
567+ end
568+ return t
569+end
570+
571+--draw background layers
572+function main.f_drawBG(data, info, layerno, timer)
573+ timer = timer or 0
574+ --loop through all backgrounds
575+ for i = 1, #data do
576+ --skip if layerno is not matched
577+ if info[i].layerno == layerno then
578+ local x = 0
579+ local y = 0
580+ --loop through controllers
581+ for k, v in pairs(info[i].ctrl) do
582+ for j = 1, #info[i].ctrl[k] do
583+ local t = info[i].ctrl[k][j]
584+ --reset internal timer
585+ if t.time[3] ~= -1 and timer >= t.timer[3] then
586+ t.timer[1] = timer + t.time[1]
587+ t.timer[2] = timer + t.time[2]
588+ t.timer[3] = timer + t.time[3]
589+ end
590+ --check if time condition allows controller to run
591+ if timer >= t.timer[1] and timer <= t.timer[2] then
592+ x = 0
593+ y = 0
594+ if k == 'gamemode' then --Ikemen feature
595+ for m = 1, #t.enabled do
596+ info[i].ctrl_flags.enabled = 0
597+ if t.enabled[m] == main.gameMode then
598+ info[i].ctrl_flags.enabled = 1
599+ m = #t.enabled
600+ end
601+ end
602+ elseif k == 'visible' then
603+ info[i].ctrl_flags.visible = t.value
604+ elseif k == 'enable' then
605+ info[i].ctrl_flags.enabled = t.value
606+ elseif k == 'velset' or k == 'posset' then
607+ if t.x ~= nil then
608+ info[i].ctrl_flags.velx = 0 - info[i].velocity[1] + t.x
609+ end
610+ if t.y ~= nil then
611+ info[i].ctrl_flags.vely = 0 - info[i].velocity[2] + t.y
612+ end
613+ elseif k == 'veladd' or k == 'posadd' then
614+ if t.x ~= nil then
615+ info[i].ctrl_flags.velx = info[i].ctrl_flags.velx + t.x
616+ end
617+ if t.y ~= nil then
618+ info[i].ctrl_flags.vely = info[i].ctrl_flags.vely + t.y
619+ end
620+ --[[elseif k == 'posset' then
621+ if t.x ~= nil then
622+ x = t.x
623+ else
624+ x = info[i].start[1]
625+ end
626+ if t.y == nil then
627+ y = t.y
628+ else
629+ y = info[i].start[2]
630+ end
631+ animSetPos(data[i], x, y)
632+ animAddPos(data[i], 160, 0) --for some reason needed in ikemen
633+ elseif k == 'posadd' then
634+ if t.x ~= nil then x = t.x end
635+ if t.y ~= nil then y = t.y end
636+ animAddPos(data[i], x, y)]]
637+ --elseif k == 'anim' then --not supported yet
638+ --elseif k == 'sinx' then --not supported yet
639+ --elseif k == 'siny' then --not supported yet
640+ end
641+ end
642+ end
643+ end
644+ --animation
645+ if info[i].ctrl_flags.enabled == 1 then
646+ x = (info[i].ctrl_flags.velx + info[i].velocity[1]) * info[i].delta[1]
647+ y = (info[i].ctrl_flags.vely + info[i].velocity[2]) * info[i].delta[2]
648+ info[i].ctrl_flags.x = info[i].ctrl_flags.x + x
649+ info[i].ctrl_flags.y = info[i].ctrl_flags.y + y
650+ animAddPos(data[i], x, y)
651+ animUpdate(data[i])
652+ if info[i].ctrl_flags.visible == 1 then
653+ animDraw(data[i])
654+ end
655+ end
656+ end
657+ end
658+end
659+
660+--reset screenpack data
661+function main.f_resetBG(info, bgdef, bgm)
662+ bgm = bgm or nil
663+ animReset(info.fadein_data)
664+ animUpdate(info.fadein_data)
665+ animReset(info.fadeout_data)
666+ animUpdate(info.fadeout_data)
667+ bgdef.timer = 0
668+ for i = 1, #bgdef.bg do
669+ bgdef.bg[i].ctrl_flags.visible = 1
670+ bgdef.bg[i].ctrl_flags.enabled = 1
671+ bgdef.bg[i].ctrl_flags.velx = 0
672+ bgdef.bg[i].ctrl_flags.vely = 0
673+ animReset(bgdef.bg_data[i])
674+ animAddPos(bgdef.bg_data[i], 0 - bgdef.bg[i].ctrl_flags.x, 0 - bgdef.bg[i].ctrl_flags.y)
675+ animUpdate(bgdef.bg_data[i])
676+ bgdef.bg[i].ctrl_flags.x = 0
677+ bgdef.bg[i].ctrl_flags.y = 0
678+ for k, v in pairs(bgdef.bg[i].ctrl) do
679+ for j = 1, #bgdef.bg[i].ctrl[k] do
680+ bgdef.bg[i].ctrl[k][j].timer[1] = bgdef.bg[i].ctrl[k][j].time[1]
681+ bgdef.bg[i].ctrl[k][j].timer[2] = bgdef.bg[i].ctrl[k][j].time[2]
682+ bgdef.bg[i].ctrl[k][j].timer[3] = bgdef.bg[i].ctrl[k][j].time[3]
683+ end
684+ end
685+ end
686+ if bgm ~= nil then
687+ playBGM(bgm)
688+ end
689+end
690+
691+--return table with reversed keys
692+function main.f_reversedTable(t)
693+ local reversedTable = {}
694+ local itemCount = #t
695+ for k, v in ipairs(t) do
696+ reversedTable[itemCount + 1 - k] = v
697+ end
698+ return reversedTable
699+end
700+
701+--return table without rows disabled in screenpack
702+function main.f_cleanTable(t)
703+ local t_clean = {}
704+ for i = 1, #t do
705+ if t[i].displayname ~= '' then
706+ t_clean[#t_clean + 1] = t[i]
707+ end
708+ end
709+ return t_clean
710+end
711+
712+--warning display
713+local txt_warning = textImgNew()
714+function main.f_warning(t, info, background, font_info, title, box)
715+ font_info = font_info or motif.warning_info
716+ title = title or main.txt_warningTitle
717+ box = box or main.warningBox
718+ main.f_cmdInput()
719+ box = box or false
720+ while true do
721+ if main.f_btnPalNo(main.p1Cmd) > 0 or esc() then
722+ sndPlay(motif.files.snd_data, info.cursor_move_snd[1], info.cursor_move_snd[2])
723+ break
724+ end
725+ --draw clearcolor
726+ animDraw(background.bgclearcolor_data)
727+ --draw layerno = 0 backgrounds
728+ main.f_drawBG(background.bg_data, background.bg, 0, background.timer)
729+ --draw layerno = 1 backgrounds
730+ main.f_drawBG(background.bg_data, background.bg, 1, background.timer)
731+ --draw menu box
732+ animDraw(box)
733+ --draw title
734+ textImgDraw(title)
735+ --draw text
736+ for i = 1, #t do
737+ main.f_updateTextImg(
738+ txt_warning,
739+ motif.font_data[font_info.text_font[1]],
740+ font_info.text_font[2],
741+ font_info.text_font[3],
742+ t[i],
743+ font_info.text_pos[1],
744+ font_info.text_pos[2] - font_info.text_spacing[2] + i * font_info.text_spacing[2],
745+ font_info.text_font_scale[1],
746+ font_info.text_font_scale[2],
747+ font_info.text_font[4],
748+ font_info.text_font[5],
749+ font_info.text_font[6]
750+ )
751+ textImgDraw(txt_warning)
752+ end
753+ --update timer
754+ background.timer = background.timer + 1
755+ --end loop
756+ main.f_cmdInput()
757+ refresh()
758+ end
759+end
760+
761+--input display
762+local txt_input = textImgNew()
763+function main.f_input(t, info, background, type)
764+ main.f_cmdInput()
765+ type = type or 'string'
766+ if type == 'string' then
767+ t[#t + 1] = ''
768+ end
769+ local input = ''
770+ resetKey()
771+ while true do
772+ if esc() then
773+ input = ''
774+ break
775+ end
776+ if type == 'key' then
777+ input = getKey()
778+ if input ~= '' then
779+ main.f_cmdInput()
780+ break
781+ end
782+ else --string
783+ if getKey() == 'RETURN' then
784+ main.f_cmdInput()
785+ break
786+ elseif getKey() == 'BACKSPACE' then
787+ input = input:match('^(.-).?$')
788+ else
789+ input = input .. getKeyText()
790+ end
791+ t[#t] = input
792+ resetKey()
793+ end
794+ --draw clearcolor
795+ animDraw(background.bgclearcolor_data)
796+ --draw layerno = 0 backgrounds
797+ main.f_drawBG(background.bg_data, background.bg, 0, background.timer)
798+ --draw layerno = 1 backgrounds
799+ main.f_drawBG(background.bg_data, background.bg, 1, background.timer)
800+ --draw menu box
801+ animDraw(main.warningBox)
802+ --draw text
803+ for i = 1, #t do
804+ main.f_updateTextImg(
805+ txt_input,
806+ motif.font_data[motif.warning_info.text_font[1]],
807+ motif.warning_info.text_font[2],
808+ motif.warning_info.text_font[3],
809+ t[i],
810+ motif.warning_info.text_pos[1],
811+ motif.warning_info.text_pos[2] - motif.warning_info.text_spacing[2] + i * motif.warning_info.text_spacing[2],
812+ motif.warning_info.text_font_scale[1],
813+ motif.warning_info.text_font_scale[2],
814+ motif.warning_info.text_font[4],
815+ motif.warning_info.text_font[5],
816+ motif.warning_info.text_font[6]
817+ )
818+ textImgDraw(txt_input)
819+ end
820+ --update timer
821+ background.timer = background.timer + 1
822+ --end loop
823+ main.f_cmdInput()
824+ refresh()
825+ end
826+ return input
827+end
828+
829+main.nextRefresh = os.clock() + 0.02
830+function main.loadingRefresh(txt)
831+ if os.clock() >= main.nextRefresh then
832+ if txt ~= nil then
833+ textImgDraw(txt)
834+ end
835+ refresh()
836+ main.nextRefresh = os.clock() + 0.02
837+ end
838+end
839+
840+--;===========================================================
841+--; COMMAND LINE QUICK VS
842+--;===========================================================
843+main.flags = getCommandLineFlags()
844+if main.flags['-p1'] ~= nil and main.flags['-p2'] ~= nil then
845+ --load lifebar
846+ local sp = config.Motif
847+ if main.flags['-r'] ~= nil then
848+ if main.f_fileExists(main.flags['-r']) then
849+ sp = main.flags['-r']
850+ elseif main.f_fileExists('data/' .. main.flags['-r'] .. '/system.def') then
851+ sp = 'data/' .. main.flags['-r'] .. '/system.def'
852+ end
853+ end
854+ local fileDir = sp:match('^(.-)[^/\\]+$')
855+ local file = io.open(sp,"r")
856+ local s = file:read("*all")
857+ file:close()
858+ local lifebar = s:match('fight%s*=%s*(.-%.def)%s*')
859+ if main.f_fileExists(lifebar) then
860+ loadLifebar(lifebar)
861+ elseif main.f_fileExists(fileDir .. lifebar) then
862+ loadLifebar(fileDir .. lifebar)
863+ elseif main.f_fileExists('data/' .. lifebar) then
864+ loadLifebar('data/' .. lifebar)
865+ else
866+ loadLifebar('data/fight.def')
867+ end
868+ refresh()
869+ --add chars
870+ local p1NumChars = 0
871+ local p2NumChars = 0
872+ local t = {}
873+ for k, v in pairs(main.flags) do
874+ if k:match('^-p[1-8]$') then
875+ addChar(v)
876+ local num = tonumber(k:match('^-p([1-8])'))
877+ local player = 1
878+ if num % 2 == 0 then --even value
879+ player = 2
880+ p2NumChars = p2NumChars + 1
881+ else
882+ p1NumChars = p1NumChars + 1
883+ end
884+ local pal = 1
885+ if main.flags['-p' .. num .. '.pal'] ~= nil then
886+ pal = main.flags['-p' .. num .. '.pal']
887+ end
888+ local ai = 0
889+ if main.flags['-p' .. num .. '.ai'] ~= nil then
890+ ai = main.flags['-p' .. num .. '.ai']
891+ end
892+ t[#t + 1] = {player = player, num = num - 1, pal = tonumber(pal), ai = tonumber(ai)}
893+ refresh()
894+ end
895+ end
896+ local p1TeamMode = 0
897+ if p1NumChars > 1 then
898+ p1TeamMode = 1
899+ end
900+ local p2TeamMode = 0
901+ if p2NumChars > 1 then
902+ p2TeamMode = 1
903+ end
904+ --add stage
905+ local stage = 'stages/stage0.def'
906+ if main.flags['-s'] ~= nil then
907+ if main.f_fileExists(main.flags['-s']) then
908+ stage = main.flags['-s']
909+ elseif main.f_fileExists('stages/' .. main.flags['-s'] .. '.def') then
910+ stage = 'stages/' .. main.flags['-s'] .. '.def'
911+ end
912+ end
913+ addStage(stage)
914+ --load data
915+ loadDebugFont('font/f-6x9.fnt')
916+ setDebugScript('script/debug.lua')
917+ setMatchNo(1)
918+ selectStart()
919+ setStage(0)
920+ selectStage(0)
921+ setTeamMode(1, p1TeamMode, p1NumChars)
922+ setTeamMode(2, p2TeamMode, p2NumChars)
923+ for i = 1, #t do
924+ selectChar(t[i].player, t[i].num, t[i].pal)
925+ setCom(t[i].player, t[i].ai)
926+ end
927+ local winner, t_gameStats = game()
928+ if main.flags['-log'] ~= nil then
929+ main.f_printTable(t_gameStats, main.flags['-log'])
930+ end
931+ --exit ikemen
932+ return
933+end
934+
935+--;===========================================================
936+--; LOAD DATA
937+--;===========================================================
938+main.fadeSff = sffNew('data/fade.sff')
939+
940+motif = require('script.motif')
941+
942+setPortrait(motif.select_info.p1_face_spr[1], motif.select_info.p1_face_spr[2], 1) --Big portrait
943+setPortrait(motif.select_info.portrait_spr[1], motif.select_info.portrait_spr[2], 2) --Small portrait
944+setPortrait(motif.vs_screen.p1_spr[1], motif.vs_screen.p1_spr[2], 3) --Versus portrait
945+setPortrait(motif.victory_screen.p1_spr[1], motif.victory_screen.p1_spr[2], 4) --Victory portrait
946+
947+main.cursorBox = animNew(main.fadeSff, '0,1, 0,0, -1')
948+animSetTile(main.cursorBox, 1, 1)
949+animUpdate(main.cursorBox)
950+
951+main.warningBox = animNew(main.fadeSff, '0,0, 0,0, -1')
952+animSetTile(main.warningBox, 1, 1)
953+animSetAlpha(main.warningBox, motif.warning_info.background_alpha[1], motif.warning_info.background_alpha[2])
954+animSetWindow(main.warningBox, 0, 0, motif.info.localcoord[1], motif.info.localcoord[2])
955+animUpdate(main.warningBox)
956+
957+main.infoBox = animNew(main.fadeSff, '0,0, 0,0, -1')
958+animSetTile(main.infoBox, 1, 1)
959+animSetAlpha(main.infoBox, motif.infobox.background_alpha[1], motif.infobox.background_alpha[2])
960+animSetWindow(main.infoBox, 0, 0, motif.info.localcoord[1], motif.info.localcoord[2])
961+animUpdate(main.infoBox)
962+
963+
964+main.txt_warningTitle = main.f_createTextImg(
965+ motif.font_data[motif.warning_info.title_font[1]],
966+ motif.warning_info.title_font[2],
967+ motif.warning_info.title_font[3],
968+ motif.warning_info.title,
969+ motif.warning_info.title_pos[1],
970+ motif.warning_info.title_pos[2],
971+ motif.warning_info.title_font_scale[1],
972+ motif.warning_info.title_font_scale[2],
973+ motif.warning_info.title_font[4],
974+ motif.warning_info.title_font[5],
975+ motif.warning_info.title_font[6]
976+)
977+
978+main.SetDefaultScale()
979+
980+local footerBox = animNew(main.fadeSff, '0,2, 0,0, -1')
981+animSetTile(footerBox, 1, 1)
982+animSetWindow(
983+ footerBox,
984+ motif.title_info.footer_boxbackground_coords[1],
985+ motif.title_info.footer_boxbackground_coords[2],
986+ motif.title_info.footer_boxbackground_coords[3] - motif.title_info.footer_boxbackground_coords[1] + 1,
987+ motif.title_info.footer_boxbackground_coords[4] - motif.title_info.footer_boxbackground_coords[2] + 1
988+)
989+animSetAlpha(footerBox, motif.title_info.footer_boxbackground_alpha[1], motif.title_info.footer_boxbackground_alpha[2])
990+animUpdate(footerBox)
991+
992+main.SetScaleValues()
993+
994+--add characters and stages using select.def instead of select.lua
995+local txt_loading = main.f_createTextImg(
996+ motif.font_data[motif.title_info.loading_font[1]],
997+ motif.title_info.loading_font[2],
998+ motif.title_info.loading_font[3],
999+ motif.title_info.loading_text,
1000+ motif.title_info.loading_offset[1],
1001+ motif.title_info.loading_offset[2],
1002+ motif.title_info.loading_font_scale[1],
1003+ motif.title_info.loading_font_scale[2],
1004+ motif.title_info.loading_font[4],
1005+ motif.title_info.loading_font[5],
1006+ motif.title_info.loading_font[6]
1007+)
1008+textImgDraw(txt_loading)
1009+refresh()
1010+
1011+function main.f_addChar(line, row)
1012+ local tmp = ''
1013+ local order = false
1014+ local hidden = 0
1015+ for i, c in ipairs(main.f_strsplit(',', line)) do
1016+ c = c:match('^%s*(.-)%s*$')
1017+ if i == 1 then
1018+ c = c:gsub('\\', '/')
1019+ c = tostring(c)
1020+ main.t_selChars[row] = {}
1021+ addChar(c)
1022+ tmp = getCharName(row - 1):match('^["%s]*(.-)["%s]*$') --needed for s-size ikemen
1023+ if tmp == '' then
1024+ break
1025+ end
1026+ main.t_charDef[c] = row - 1
1027+ main.t_selChars[row].char = c
1028+ if tmp ~= 'Random' then
1029+ main.t_selChars[row].displayname = tmp
1030+ main.t_selChars[row].def = getCharFileName(row - 1)
1031+ main.t_selChars[row].dir = main.t_selChars[row].def:gsub('[^/]+%.def$', '')
1032+ main.t_selChars[row].pal = getCharPalettes(row - 1)
1033+ if tmp ~= 'Training' then
1034+ tmp = getCharIntro(row - 1)
1035+ if tmp ~= '' then
1036+ main.t_selChars[row].intro = main.t_selChars[row].dir .. tmp:gsub('\\', '/')
1037+ end
1038+ tmp = getCharEnding(row - 1)
1039+ if tmp ~= '' then
1040+ main.t_selChars[row].ending = main.t_selChars[row].dir .. tmp:gsub('\\', '/')
1041+ end
1042+ main.t_selChars[row].order = 1
1043+ order = true
1044+ end
1045+ else
1046+ break
1047+ end
1048+ elseif c:match('music%s*=%s*') then
1049+ c = c:gsub('\\', '/')
1050+ local bgmvolume = c:match('%s([0-9]+)$')
1051+ if bgmvolume == nil then
1052+ bgmvolume = 100
1053+ else
1054+ bgmvolume = tonumber(bgmvolume)
1055+ c = c:gsub('%s*[0-9]+$','')
1056+ end
1057+ local bgmusic = c:match('^music%s*=%s*(.-)%s*$')
1058+ if main.t_selChars[row].music == nil then
1059+ main.t_selChars[row].music = {}
1060+ end
1061+ main.t_selChars[row].music[#main.t_selChars[row].music + 1] = {}
1062+ main.t_selChars[row].music[#main.t_selChars[row].music].bgmusic = bgmusic
1063+ main.t_selChars[row].music[#main.t_selChars[row].music].bgmvolume = bgmvolume
1064+ elseif c:match('[0-9]+%s*=%s*[^%s]') then
1065+ local var1, var2 = c:match('([0-9]+)%s*=%s*(.+)%s*$')
1066+ main.t_selChars[row][tonumber(var1)] = var2:lower()
1067+ elseif c:match('%.def') or c:match('^random$') then
1068+ c = c:gsub('\\', '/')
1069+ if main.t_selChars[row].stage == nil then
1070+ main.t_selChars[row].stage = {}
1071+ end
1072+ main.t_selChars[row].stage[#main.t_selChars[row].stage + 1] = c
1073+ else
1074+ local param, value = c:match('^(.-)%s*=%s*(.-)$')
1075+ if param ~= '' and value ~= '' and param ~= nil and value ~= nil then
1076+ main.t_selChars[row][param] = tonumber(value)
1077+ end
1078+ end
1079+ end
1080+ if main.t_selChars[row].exclude == nil then
1081+ main.t_selChars[row].hidden = hidden
1082+ end
1083+ if order then
1084+ if main.t_orderChars[main.t_selChars[row].order] == nil then
1085+ main.t_orderChars[main.t_selChars[row].order] = {}
1086+ end
1087+ main.t_orderChars[main.t_selChars[row].order][#main.t_orderChars[main.t_selChars[row].order] + 1] = row - 1
1088+ end
1089+ main.loadingRefresh(txt_loading)
1090+end
1091+
1092+--start_time = os.time()
1093+main.t_includeStage = {}
1094+main.t_orderChars = {}
1095+main.t_stageDef = {['random'] = 0}
1096+main.t_charDef = {}
1097+local t_exlude = {}
1098+local chars = 0
1099+local stages = 0
1100+local tmp = ''
1101+local section = 0
1102+local row = 0
1103+local file = io.open(motif.files.select,"r")
1104+local content = file:read("*all")
1105+file:close()
1106+content = content:gsub('([^\r\n;]*)%s*;[^\r\n]*', '%1')
1107+content = content:gsub('\n%s*\n', '\n')
1108+for line in content:gmatch('[^\r\n]+') do
1109+--for line in io.lines("data/select.def") do
1110+ line = line:lower()
1111+ if line:match('^%s*%[%s*characters%s*%]') then
1112+ main.t_selChars = {}
1113+ row = 0
1114+ section = 1
1115+ elseif line:match('^%s*%[%s*extrastages%s*%]') then
1116+ main.t_selStages = {}
1117+ row = 0
1118+ section = 2
1119+ elseif line:match('^%s*%[%s*options%s*%]') then
1120+ main.t_selOptions = {
1121+ arcadestart = {wins = 0, offset = 0},
1122+ arcadeend = {wins = 0, offset = 0},
1123+ teamstart = {wins = 0, offset = 0},
1124+ teamend = {wins = 0, offset = 0},
1125+ survivalstart = {wins = 0, offset = 0},
1126+ survivalend = {wins = 0, offset = 0},
1127+ }
1128+ row = 0
1129+ section = 3
1130+ elseif section == 1 then --[Characters]
1131+ if line:match(',%s*exclude%s*=%s*1') then --character should be added after all slots are filled
1132+ t_exlude[#t_exlude + 1] = line
1133+ else
1134+ chars = chars + 1
1135+ main.f_addChar(line, chars)
1136+ end
1137+ elseif section == 2 then --[ExtraStages]
1138+ row = #main.t_selStages + 1
1139+ for i, c in ipairs(main.f_strsplit(',', line)) do
1140+ c = c:gsub('^%s*(.-)%s*$', '%1')
1141+ if i == 1 then
1142+ c = c:gsub('\\', '/')
1143+ if not main.f_fileExists(c) or c:match('^stages/$') then
1144+ break
1145+ end
1146+ addStage(c)
1147+ tmp = getStageName(row):match('^["%s]*(.-)["%s]*$') --needed for s-size ikemen
1148+ if tmp == '' then
1149+ break
1150+ end
1151+ main.t_selStages[row] = {name = tmp, stage = c}
1152+ local zoomout, zoomin, bgmusic, bgmvolume = getStageInfo(row)
1153+ if zoomout ~= '' then
1154+ main.t_selStages[row].zoommin = tonumber(zoomout)
1155+ end
1156+ if zoomin ~= '' then
1157+ main.t_selStages[row].zoommax = tonumber(zoomin)
1158+ end
1159+ if bgmusic ~= '' then
1160+ bgmusic = bgmusic:gsub('\\', '/')
1161+ main.t_selStages[row].music = {[1] = {bgmusic = bgmusic, bgmvolume = tonumber(bgmvolume)}}
1162+ end
1163+ main.t_includeStage[#main.t_includeStage + 1] = row
1164+ main.t_stageDef[c] = row
1165+ elseif c:match('music%s*=%s*') then
1166+ c = c:gsub('\\', '/')
1167+ local bgmvolume = c:match('%s([0-9]+)$')
1168+ if bgmvolume == nil then
1169+ bgmvolume = 100
1170+ else
1171+ bgmvolume = tonumber(bgmvolume)
1172+ c = c:gsub('%s*[0-9]+$','')
1173+ end
1174+ local bgmusic = c:match('^music%s*=%s*(.-)%s*$')
1175+ if main.t_selStages[row].music == nil then
1176+ main.t_selStages[row].music = {}
1177+ end
1178+ main.t_selStages[row].music[#main.t_selStages[row].music+1] = {bgmusic = bgmusic, bgmvolume = bgmvolume}
1179+ else
1180+ local param, value = c:match('^(.-)%s*=%s*(.-)$')
1181+ main.t_selStages[row][param] = tonumber(value)
1182+ end
1183+ end
1184+ elseif section == 3 then --[Options]
1185+ if line:match('^%s*.-%.maxmatches%s*=%s*') then
1186+ local rowName, line = line:match('^%s*(.-)%.maxmatches%s*=%s*(.+)')
1187+ main.t_selOptions[rowName .. 'maxmatches'] = {}
1188+ for i, c in ipairs(main.f_strsplit(',', line:gsub('%s*(.-)%s*', '%1'))) do
1189+ main.t_selOptions[rowName .. 'maxmatches'][i] = tonumber(c)
1190+ end
1191+ elseif line:match('^%s*.-%.airamp%..-%s*=%s*') then
1192+ local rowName, rowName2, wins, offset = line:match('^%s*(.-)%.airamp%.(.-)%s*=%s*([0-9]+)%s*,%s*([0-9-]+)')
1193+ main.t_selOptions[rowName .. rowName2] = {wins = tonumber(wins), offset = tonumber(offset)}
1194+ end
1195+ end
1196+end
1197+--main.f_printVar(os.difftime(os.time(), start_time))
1198+
1199+--add excluded characters once all slots are filled
1200+for i = chars, (motif.select_info.rows + motif.select_info.rows_scrolling) * motif.select_info.columns - 1 do
1201+ chars = chars + 1
1202+ main.t_selChars[chars] = {}
1203+ addChar('dummyChar')
1204+end
1205+for i = 1, #t_exlude do
1206+ chars = chars + 1
1207+ main.f_addChar(t_exlude[i], chars)
1208+end
1209+--add Training by stupa if not included in select.def
1210+if main.t_charDef.training == nil and main.f_fileExists('chars/training/training.def') then
1211+ chars = chars + 1
1212+ main.f_addChar('training, exclude = 1', chars)
1213+end
1214+
1215+--add remaining character parameters
1216+main.t_bossChars = {}
1217+main.t_bonusChars = {}
1218+main.t_randomChars = {}
1219+--for each character loaded
1220+for i = 1, #main.t_selChars do
1221+ if main.t_selChars[i].stage ~= nil then
1222+ for j = 1, #main.t_selChars[i].stage do
1223+ if main.t_stageDef[main.t_selChars[i].stage[j]] == nil then
1224+ row = #main.t_selStages + 1
1225+ addStage(main.t_selChars[i].stage[j])
1226+ tmp = getStageName(row):match('^["%s]*(.-)["%s]*$') --needed for s-size ikemen
1227+ if tmp == '' then
1228+ break
1229+ end
1230+ main.t_selStages[row] = {name = tmp, stage = main.t_selChars[i].stage[j]}
1231+ local zoomout, zoomin, bgmusic, bgmvolume = getStageInfo(row)
1232+ if zoomout ~= '' then
1233+ main.t_selStages[row].zoommin = tonumber(zoomout)
1234+ end
1235+ if zoomin ~= '' then
1236+ main.t_selStages[row].zoommax = tonumber(zoomin)
1237+ end
1238+ if bgmusic ~= '' then
1239+ bgmusic = bgmusic:gsub('\\', '/')
1240+ main.t_selStages[row].music = {}
1241+ main.t_selStages[row].music[1] = {bgmusic = bgmusic, bgmvolume = tonumber(bgmvolume)}
1242+ end
1243+ if main.t_selChars[i].includestage == nil or main.t_selChars[i].includestage == 1 then
1244+ main.t_includeStage[#main.t_includeStage + 1] = row
1245+ end
1246+ main.t_selChars[i].stage[j] = row
1247+ --main.t_stageDef[main.t_selChars[i].stage[j]] = row
1248+ else
1249+ main.t_selChars[i].stage[j] = main.t_stageDef[main.t_selChars[i].stage[j]]
1250+ end
1251+ end
1252+ end
1253+ --if character's name has been stored
1254+ if main.t_selChars[i].displayname ~= nil then
1255+ --generate table for boss rush mode
1256+ if main.t_selChars[i].boss ~= nil and main.t_selChars[i].boss == 1 then
1257+ main.t_bossChars[#main.t_bossChars + 1] = i - 1
1258+ end
1259+ --generate table for bonus games mode
1260+ if main.t_selChars[i].bonus ~= nil and main.t_selChars[i].bonus == 1 then
1261+ main.t_bonusChars[#main.t_bonusChars + 1] = i - 1
1262+ end
1263+ --generate table with characters allowed to be random selected
1264+ if main.t_selChars[i].hidden ~= nil and main.t_selChars[i].hidden <= 1 then
1265+ main.t_randomChars[#main.t_randomChars + 1] = i - 1
1266+ end
1267+ end
1268+end
1269+
1270+--Save debug tables
1271+main.f_printTable(main.t_selChars, "debug/t_selChars.txt")
1272+main.f_printTable(main.t_selStages, "debug/t_selStages.txt")
1273+main.f_printTable(main.t_selOptions, "debug/t_selOptions.txt")
1274+main.f_printTable(main.t_orderChars, "debug/t_orderChars.txt")
1275+main.f_printTable(main.t_randomChars, "debug/t_randomChars.txt")
1276+main.f_printTable(main.t_bossChars, "debug/t_bossChars.txt")
1277+main.f_printTable(main.t_bonusChars, "debug/t_bonusChars.txt")
1278+main.f_printTable(main.t_stageDef, "debug/t_stageDef.txt")
1279+main.f_printTable(main.t_charDef, "debug/t_charDef.txt")
1280+main.f_printTable(main.t_includeStage, "debug/t_includeStage.txt")
1281+
1282+--Debug stuff
1283+loadDebugFont(motif.files.debug_font)
1284+setDebugScript(motif.files.debug_script)
1285+
1286+--Assign Lifebar
1287+textImgDraw(txt_loading)
1288+refresh()
1289+loadLifebar(motif.files.fight)
1290+main.loadingRefresh(txt_loading)
1291+
1292+--warnings
1293+if main.t_charDef.training == nil then
1294+ main.f_warning(main.f_extractText(motif.warning_info.text_training), motif.title_info, motif.titlebgdef)
1295+ os.exit()
1296+end
1297+
1298+if #main.t_includeStage == 0 then
1299+ main.f_warning(main.f_extractText(motif.warning_info.text_stages), motif.title_info, motif.titlebgdef)
1300+ os.exit()
1301+end
1302+
1303+local t = {'arcademaxmatches', 'teammaxmatches'}
1304+for i = 1, #t do
1305+ local orderOK = false
1306+ for j = 1, #main.t_selOptions[t[i]] do
1307+ if main.t_selOptions[t[i]][j] > 0 and main.t_orderChars[j] ~= nil and #main.t_orderChars[j] > 0 then
1308+ orderOK = true
1309+ break
1310+ end
1311+ end
1312+ if not orderOK then
1313+ main.f_warning(main.f_extractText(motif.warning_info.text_order), motif.title_info, motif.titlebgdef)
1314+ os.exit()
1315+ end
1316+end
1317+
1318+--Load additional scripts
1319+randomtest = require('script.randomtest')
1320+options = require('script.options')
1321+select = require('script.select')
1322+storyboard = require('script.storyboard')
1323+
1324+--;===========================================================
1325+--; MAIN MENU
1326+--;===========================================================
1327+
1328+--Disable screenpack scale on the text for showing them corectly.
1329+main.SetDefaultScale()
1330+
1331+local txt_titleFooter1 = main.f_createTextImg(
1332+ motif.font_data[motif.title_info.footer1_font[1]],
1333+ motif.title_info.footer1_font[2],
1334+ motif.title_info.footer1_font[3],
1335+ motif.title_info.footer1_text,
1336+ motif.title_info.footer1_offset[1],
1337+ motif.title_info.footer1_offset[2],
1338+ motif.title_info.footer1_font_scale[1],
1339+ motif.title_info.footer1_font_scale[2],
1340+ motif.title_info.footer1_font[4],
1341+ motif.title_info.footer1_font[5],
1342+ motif.title_info.footer1_font[6]
1343+)
1344+local txt_titleFooter2 = main.f_createTextImg(
1345+ motif.font_data[motif.title_info.footer2_font[1]],
1346+ motif.title_info.footer2_font[2],
1347+ motif.title_info.footer2_font[3],
1348+ motif.title_info.footer2_text,
1349+ motif.title_info.footer2_offset[1],
1350+ motif.title_info.footer2_offset[2],
1351+ motif.title_info.footer2_font_scale[1],
1352+ motif.title_info.footer2_font_scale[2],
1353+ motif.title_info.footer2_font[4],
1354+ motif.title_info.footer2_font[5],
1355+ motif.title_info.footer2_font[6]
1356+)
1357+local txt_titleFooter3 = main.f_createTextImg(
1358+ motif.font_data[motif.title_info.footer3_font[1]],
1359+ motif.title_info.footer3_font[2],
1360+ motif.title_info.footer3_font[3],
1361+ motif.title_info.footer3_text,
1362+ motif.title_info.footer3_offset[1],
1363+ motif.title_info.footer3_offset[2],
1364+ motif.title_info.footer3_font_scale[1],
1365+ motif.title_info.footer3_font_scale[2],
1366+ motif.title_info.footer3_font[4],
1367+ motif.title_info.footer3_font[5],
1368+ motif.title_info.footer3_font[6]
1369+)
1370+local txt_infoboxTitle = main.f_createTextImg(
1371+ motif.font_data[motif.infobox.title_font[1]],
1372+ motif.infobox.title_font[2],
1373+ motif.infobox.title_font[3],
1374+ motif.infobox.title,
1375+ motif.infobox.title_pos[1],
1376+ motif.infobox.title_pos[2],
1377+ motif.infobox.title_font_scale[1],
1378+ motif.infobox.title_font_scale[2],
1379+ motif.infobox.title_font[4],
1380+ motif.infobox.title_font[5],
1381+ motif.infobox.title_font[6]
1382+)
1383+
1384+--Enable screenpack scale again.
1385+main.SetScaleValues()
1386+
1387+main.txt_mainSelect = main.f_createTextImg(
1388+ motif.font_data[motif.select_info.title_font[1]],
1389+ motif.select_info.title_font[2],
1390+ motif.select_info.title_font[3],
1391+ '',
1392+ motif.select_info.title_offset[1],
1393+ motif.select_info.title_offset[2],
1394+ motif.select_info.title_font_scale[1],
1395+ motif.select_info.title_font_scale[2],
1396+ motif.select_info.title_font[4],
1397+ motif.select_info.title_font[5],
1398+ motif.select_info.title_font[6]
1399+)
1400+
1401+--itemname: names used to distinguish modes in lua code (keep it as it is)
1402+--displayname: names for each of the items in the menu
1403+--selectname: names that will show up in select screen
1404+local t_mainMenu = {
1405+ {data = textImgNew(), itemname = 'arcade', displayname = motif.title_info.menu_itemname_arcade, selectname = motif.select_info.title_text_arcade},
1406+ {data = textImgNew(), itemname = 'versus', displayname = motif.title_info.menu_itemname_versus, selectname = motif.select_info.title_text_versus},
1407+ {data = textImgNew(), itemname = 'online', displayname = motif.title_info.menu_itemname_online},
1408+ {data = textImgNew(), itemname = 'teamcoop', displayname = motif.title_info.menu_itemname_teamcoop, selectname = motif.select_info.title_text_teamcoop},
1409+ {data = textImgNew(), itemname = 'survival', displayname = motif.title_info.menu_itemname_survival, selectname = motif.select_info.title_text_survival},
1410+ {data = textImgNew(), itemname = 'survivalcoop', displayname = motif.title_info.menu_itemname_survivalcoop, selectname = motif.select_info.title_text_survivalcoop},
1411+ --{data = textImgNew(), itemname = 'storymode', displayname = motif.title_info.menu_itemname_storymode, selectname = motif.select_info.title_text_storymode},
1412+ --{data = textImgNew(), itemname = 'timeattack', displayname = motif.title_info.menu_itemname_timeattack, selectname = motif.select_info.title_text_timeattack},
1413+ --{data = textImgNew(), itemname = 'tournament', displayname = motif.title_info.menu_itemname_tournament},
1414+ {data = textImgNew(), itemname = 'training', displayname = motif.title_info.menu_itemname_training, selectname = motif.select_info.title_text_training},
1415+ {data = textImgNew(), itemname = 'watch', displayname = motif.title_info.menu_itemname_watch, selectname = motif.select_info.title_text_watch},
1416+ {data = textImgNew(), itemname = 'extras', displayname = motif.title_info.menu_itemname_extras},
1417+ {data = textImgNew(), itemname = 'options', displayname = motif.title_info.menu_itemname_options},
1418+ {data = textImgNew(), itemname = 'exit', displayname = motif.title_info.menu_itemname_exit},
1419+}
1420+t_mainMenu = main.f_cleanTable(t_mainMenu)
1421+
1422+function main.f_default()
1423+ setAutoLevel(false) --generate autolevel.txt in game dir
1424+ setHomeTeam(2) --P2 side considered the home team: http://mugenguild.com/forum/topics/ishometeam-triggers-169132.0.html
1425+ resetRemapInput()
1426+ --settings adjustable via options
1427+ setAutoguard(1, config.AutoGuard)
1428+ setAutoguard(2, config.AutoGuard)
1429+ setPowerShare(1, config.TeamPowerShare)
1430+ setPowerShare(2, config.TeamPowerShare)
1431+ setLifeShare(config.TeamLifeShare)
1432+ setRoundTime(config.RoundTime * options.framespercount)
1433+ setLifeMul(config.LifeMul / 100)
1434+ setTeam1VS2Life(config.Team1VS2Life / 100)
1435+ setTurnsRecoveryRate(1.0 / config.TurnsRecoveryRate)
1436+ --default values for all modes
1437+ main.p1Char = nil --no predefined P1 character (assigned via table: {X, Y, (...)})
1438+ main.p2Char = nil --no predefined P2 character (assigned via table: {X, Y, (...)})
1439+ main.p1TeamMenu = nil --no predefined P1 team mode (assigned via table: {mode = X, chars = Y})
1440+ main.p2TeamMenu = nil --no predefined P2 team mode (assigned via table: {mode = X, chars = Y})
1441+ main.aiFight = false --AI = config.Difficulty for all characters disabled
1442+ main.stageMenu = false --stage selection disabled
1443+ main.p2Faces = false --additional window with P2 select screen small portraits (faces) disabled
1444+ main.coop = false --P2 fighting on P1 side disabled
1445+ main.p2SelectMenu = true --P2 character selection enabled
1446+ main.versusScreen = true --versus screen enabled
1447+ main.p1In = 1 --P1 controls P1 side of the select screen
1448+ main.p2In = 2 --P2 controls P2 side of the select screen
1449+ main.gameMode = '' --additional variable used to distinguish modes in select screen
1450+end
1451+
1452+function main.f_menuCommon1(cursorPosY, moveTxt, item, t)
1453+ if commandGetState(main.p1Cmd, 'u') or commandGetState(main.p2Cmd, 'u') then
1454+ sndPlay(motif.files.snd_data, motif.title_info.cursor_move_snd[1], motif.title_info.cursor_move_snd[2])
1455+ item = item - 1
1456+ elseif commandGetState(main.p1Cmd, 'd') or commandGetState(main.p2Cmd, 'd') then
1457+ sndPlay(motif.files.snd_data, motif.title_info.cursor_move_snd[1], motif.title_info.cursor_move_snd[2])
1458+ item = item + 1
1459+ end
1460+ --cursor position calculation
1461+ if item < 1 then
1462+ item = #t
1463+ if #t > motif.title_info.menu_window_visibleitems then
1464+ cursorPosY = motif.title_info.menu_window_visibleitems
1465+ else
1466+ cursorPosY = #t
1467+ end
1468+ elseif item > #t then
1469+ item = 1
1470+ cursorPosY = 1
1471+ elseif (commandGetState(main.p1Cmd, 'u') or commandGetState(main.p2Cmd, 'u') ) and cursorPosY > 1 then
1472+ cursorPosY = cursorPosY - 1
1473+ elseif (commandGetState(main.p1Cmd, 'd') or commandGetState(main.p2Cmd, 'd') ) and cursorPosY < motif.title_info.menu_window_visibleitems then
1474+ cursorPosY = cursorPosY + 1
1475+ end
1476+ if cursorPosY == motif.title_info.menu_window_visibleitems then
1477+ moveTxt = (item - motif.title_info.menu_window_visibleitems) * motif.title_info.menu_item_spacing[2]
1478+ elseif cursorPosY == 1 then
1479+ moveTxt = (item - 1) * motif.title_info.menu_item_spacing[2]
1480+ end
1481+ return cursorPosY, moveTxt, item
1482+end
1483+
1484+function main.f_menuCommon2(cursorPosY, moveTxt, item, t)
1485+ --draw clearcolor
1486+ animDraw(motif.titlebgdef.bgclearcolor_data)
1487+ --draw layerno = 0 backgrounds
1488+ main.f_drawBG(motif.titlebgdef.bg_data, motif.titlebgdef.bg, 0, motif.titlebgdef.timer)
1489+ --draw menu items
1490+ local items_shown = item + motif.title_info.menu_window_visibleitems - cursorPosY
1491+ if motif.title_info.menu_window_margins_y[2] ~= 0 and items_shown < #t then
1492+ items_shown = items_shown + 1
1493+ end
1494+ if items_shown > #t then
1495+ items_shown = #t
1496+ end
1497+ for i = 1, items_shown do
1498+ if i > item - cursorPosY then
1499+ if i == item then
1500+ textImgDraw(main.f_updateTextImg(
1501+ t[i].data,
1502+ motif.font_data[motif.title_info.menu_item_active_font[1]],
1503+ motif.title_info.menu_item_active_font[2],
1504+ motif.title_info.menu_item_active_font[3],
1505+ t[i].displayname,
1506+ motif.title_info.menu_pos[1],
1507+ motif.title_info.menu_pos[2] + (i - 1) * motif.title_info.menu_item_spacing[2] - moveTxt,
1508+ motif.title_info.menu_item_active_font_scale[1],
1509+ motif.title_info.menu_item_active_font_scale[2],
1510+ motif.title_info.menu_item_active_font[4],
1511+ motif.title_info.menu_item_active_font[5],
1512+ motif.title_info.menu_item_active_font[6]
1513+ ))
1514+ else
1515+ textImgDraw(main.f_updateTextImg(
1516+ t[i].data,
1517+ motif.font_data[motif.title_info.menu_item_font[1]],
1518+ motif.title_info.menu_item_font[2],
1519+ motif.title_info.menu_item_font[3],
1520+ t[i].displayname,
1521+ motif.title_info.menu_pos[1],
1522+ motif.title_info.menu_pos[2] + (i - 1) * motif.title_info.menu_item_spacing[2] - moveTxt,
1523+ motif.title_info.menu_item_font_scale[1],
1524+ motif.title_info.menu_item_font_scale[2],
1525+ motif.title_info.menu_item_font[4],
1526+ motif.title_info.menu_item_font[5],
1527+ motif.title_info.menu_item_font[6]
1528+ ))
1529+ end
1530+ end
1531+ end
1532+ --draw menu cursor
1533+ if motif.title_info.menu_boxcursor_visible == 1 then
1534+ animSetWindow(
1535+ main.cursorBox,
1536+ motif.title_info.menu_pos[1] + motif.title_info.menu_boxcursor_coords[1],
1537+ motif.title_info.menu_pos[2] + motif.title_info.menu_boxcursor_coords[2] + (cursorPosY - 1) * motif.title_info.menu_item_spacing[2],
1538+ motif.title_info.menu_boxcursor_coords[3] - motif.title_info.menu_boxcursor_coords[1] + 1,
1539+ motif.title_info.menu_boxcursor_coords[4] - motif.title_info.menu_boxcursor_coords[2] + 1
1540+ )
1541+ main.f_dynamicAlpha(main.cursorBox, 10,40,2, 255,255,0)
1542+ animDraw(main.cursorBox)
1543+ end
1544+ --draw layerno = 1 backgrounds
1545+ main.f_drawBG(motif.titlebgdef.bg_data, motif.titlebgdef.bg, 1, motif.titlebgdef.timer)
1546+ --footer draw
1547+ if motif.title_info.footer_boxbackground_visible == 1 then
1548+ animDraw(footerBox)
1549+ end
1550+ textImgDraw(txt_titleFooter1)
1551+ textImgDraw(txt_titleFooter2)
1552+ textImgDraw(txt_titleFooter3)
1553+ --draw fadein
1554+ animDraw(motif.title_info.fadein_data)
1555+ animUpdate(motif.title_info.fadein_data)
1556+ --update timer
1557+ motif.titlebgdef.timer = motif.titlebgdef.timer + 1
1558+ --end loop
1559+ main.f_cmdInput()
1560+ refresh()
1561+end
1562+
1563+function main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
1564+ --[[for i = 1, motif.title_info.fadeout_time do
1565+ main.f_menuCommon2(cursorPosY, moveTxt, item, t)
1566+ animDraw(motif.title_info.fadeout_data)
1567+ animUpdate(motif.title_info.fadeout_data)
1568+ end]]
1569+end
1570+
1571+function main.f_mainMenu()
1572+ main.f_cmdInput()
1573+ local cursorPosY = 1
1574+ local moveTxt = 0
1575+ local item = 1
1576+ local t = t_mainMenu
1577+ if motif.files.logo_storyboard ~= '' then
1578+ storyboard.f_storyboard(motif.files.logo_storyboard)
1579+ end
1580+ if motif.files.intro_storyboard ~= '' then
1581+ storyboard.f_storyboard(motif.files.intro_storyboard)
1582+ end
1583+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
1584+ while true do
1585+ cursorPosY, moveTxt, item = main.f_menuCommon1(cursorPosY, moveTxt, item, t)
1586+ if esc() then
1587+ break
1588+ elseif getKey() == 'F1' then
1589+ main.SetDefaultScale()
1590+ main.f_warning(main.f_extractText(motif.infobox.text), motif.title_info, motif.titlebgdef, motif.infobox, txt_infoboxTitle, main.infoBox)
1591+ main.SetScaleValues()
1592+ elseif main.f_btnPalNo(main.p1Cmd) > 0 then
1593+ main.f_default()
1594+ --ARCADE
1595+ if t[item].itemname == 'arcade' then
1596+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
1597+ main.p2In = 1 --P1 controls P2 side of the select screen
1598+ main.p2SelectMenu = false --P2 character selection disabled
1599+ main.credits = config.Credits - 1 --amount of continues
1600+ main.gameMode = t[item].itemname --mode recognized in select screen as 'arcade'
1601+ textImgSetText(main.txt_mainSelect, t[item].selectname) --message displayed on top of select screen
1602+ main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
1603+ select.f_selectAdvance() --start f_selectAdvance() function from script/select.lua
1604+ end
1605+ --VS MODE
1606+ if t[item].itemname == 'versus' then
1607+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
1608+ setHomeTeam(1) --P1 side considered the home team
1609+ main.p2In = 2 --P2 controls P2 side of the select screen
1610+ main.stageMenu = true --stage selection enabled
1611+ main.p2Faces = true --additional window with P2 select screen small portraits (faces) enabled
1612+ textImgSetText(main.txt_mainSelect, t[item].selectname)
1613+ main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
1614+ select.f_selectSimple() --start f_selectSimple() function from script/select.lua
1615+ end
1616+ --ONLINE
1617+ if t[item].itemname == 'online' then
1618+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
1619+ main.f_mainNetplay()
1620+ end
1621+ --TEAM CO-OP
1622+ if t[item].itemname == 'teamcoop' then
1623+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
1624+ main.p2In = 2
1625+ main.p2Faces = true
1626+ main.coop = true --P2 fighting on P1 side enabled
1627+ main.credits = config.Credits - 1
1628+ main.gameMode = t[item].itemname
1629+ textImgSetText(main.txt_mainSelect, t[item].selectname)
1630+ main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
1631+ select.f_selectAdvance()
1632+ end
1633+ --SURVIVAL
1634+ if t[item].itemname == 'survival' then
1635+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
1636+ main.p2In = 1
1637+ main.p2SelectMenu = false
1638+ main.credits = 0
1639+ main.gameMode = t[item].itemname
1640+ textImgSetText(main.txt_mainSelect, t[item].selectname)
1641+ main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
1642+ select.f_selectAdvance()
1643+ end
1644+ --SURVIVAL CO-OP
1645+ if t[item].itemname == 'survivalcoop' then
1646+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
1647+ main.p2In = 2
1648+ main.p2Faces = true
1649+ main.coop = true
1650+ main.credits = 0
1651+ main.gameMode = t[item].itemname
1652+ textImgSetText(main.txt_mainSelect, t[item].selectname)
1653+ main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
1654+ select.f_selectAdvance()
1655+ end
1656+ --TOURNAMENT
1657+ if t[item].itemname == 'tournament' then
1658+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
1659+ main.f_mainTournament()
1660+ end
1661+ --TRAINING
1662+ if t[item].itemname == 'training' then
1663+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
1664+ setRoundTime(-1) --round time disabled
1665+ main.p2In = 2
1666+ main.stageMenu = true
1667+ main.versusScreen = false --versus screen disabled
1668+ main.p2TeamMenu = {mode = 0, chars = 1} --predefined P2 team mode as Single, 1 Character
1669+ main.p2Char = {main.t_charDef.training} --predefined P2 character as Training by stupa
1670+ main.gameMode = t[item].itemname
1671+ textImgSetText(main.txt_mainSelect, t[item].selectname)
1672+ main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
1673+ select.f_selectSimple()
1674+ end
1675+ --WATCH
1676+ if t[item].itemname == 'watch' then
1677+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
1678+ main.p2In = 1
1679+ main.aiFight = true --AI = config.Difficulty for all characters enabled
1680+ main.stageMenu = true
1681+ main.p2Faces = true
1682+ textImgSetText(main.txt_mainSelect, t[item].selectname)
1683+ main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
1684+ select.f_selectSimple()
1685+ end
1686+ --EXTRAS
1687+ if t[item].itemname == 'extras' then
1688+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
1689+ main.f_mainExtras()
1690+ end
1691+ --OPTIONS
1692+ if t[item].itemname == 'options' then
1693+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
1694+ main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
1695+ --Disable screenpack scale on the menu text for showing the menu corectly.
1696+ main.SetDefaultScale()
1697+ options.f_mainCfg() --start f_mainCfg() function from script/options.lua
1698+ --Enable screenpack scale again.
1699+ main.SetScaleValues()
1700+ end
1701+ --EXIT
1702+ if t[item].itemname == 'exit' then
1703+ break
1704+ end
1705+ end
1706+ main.f_menuCommon2(cursorPosY, moveTxt, item, t)
1707+ end
1708+end
1709+
1710+--;===========================================================
1711+--; NETPLAY MENU
1712+--;===========================================================
1713+local txt_connection = main.f_createTextImg(
1714+ motif.font_data[motif.title_info.connecting_font[1]],
1715+ motif.title_info.connecting_font[2],
1716+ motif.title_info.connecting_font[3],
1717+ "",
1718+ motif.title_info.connecting_offset[1],
1719+ motif.title_info.connecting_offset[2],
1720+ motif.title_info.connecting_font_scale[1],
1721+ motif.title_info.connecting_font_scale[2],
1722+ motif.title_info.connecting_font[4],
1723+ motif.title_info.connecting_font[5],
1724+ motif.title_info.connecting_font[6]
1725+)
1726+function main.f_connect(server, t)
1727+ local cancel = false
1728+ enterNetPlay(server)
1729+ while not connected() do
1730+ if esc() then
1731+ sndPlay(motif.files.snd_data, motif.title_info.cancel_snd[1], motif.title_info.cancel_snd[2])
1732+ cancel = true
1733+ break
1734+ end
1735+ --draw clearcolor
1736+ animDraw(motif.titlebgdef.bgclearcolor_data)
1737+ --draw layerno = 0 backgrounds
1738+ main.f_drawBG(motif.titlebgdef.bg_data, motif.titlebgdef.bg, 0, motif.titlebgdef.timer)
1739+ --draw layerno = 1 backgrounds
1740+ main.f_drawBG(motif.titlebgdef.bg_data, motif.titlebgdef.bg, 1, motif.titlebgdef.timer)
1741+ --draw menu box
1742+ animDraw(main.warningBox)
1743+ --draw text
1744+ for i = 1, #t do
1745+ textImgSetText(txt_connection, t[i])
1746+ textImgDraw(txt_connection)
1747+ end
1748+ --update timer
1749+ motif.titlebgdef.timer = motif.titlebgdef.timer + 1
1750+ --end loop
1751+ refresh()
1752+ end
1753+ main.f_cmdInput()
1754+ if not cancel then
1755+ synchronize()
1756+ math.randomseed(sszRandom())
1757+ main.f_netplayMode()
1758+ end
1759+end
1760+
1761+local t_mainNetplay = {
1762+ {data = textImgNew(), itemname = 'serverhost', displayname = motif.title_info.menu_itemname_serverhost},
1763+ {data = textImgNew(), itemname = 'serverjoin', displayname = motif.title_info.menu_itemname_serverjoin},
1764+ {data = textImgNew(), itemname = 'serverback', displayname = motif.title_info.menu_itemname_serverback},
1765+}
1766+t_mainNetplay = main.f_cleanTable(t_mainNetplay)
1767+
1768+function main.f_mainNetplay()
1769+ main.f_cmdInput()
1770+ local cursorPosY = 1
1771+ local moveTxt = 0
1772+ local item = 1
1773+ local t = t_mainNetplay
1774+ while true do
1775+ cursorPosY, moveTxt, item = main.f_menuCommon1(cursorPosY, moveTxt, item, t)
1776+ if esc() then
1777+ sndPlay(motif.files.snd_data, motif.title_info.cancel_snd[1], motif.title_info.cancel_snd[2])
1778+ break
1779+ elseif main.f_btnPalNo(main.p1Cmd) > 0 then
1780+ main.f_default()
1781+ --HOST
1782+ if t[item].itemname == 'serverhost' then
1783+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
1784+ main.f_connect("", main.f_extractText(motif.title_info.connecting_host, getListenPort()))
1785+ exitNetPlay()
1786+ exitReplay()
1787+
1788+ -- Save replay with a new name
1789+ tpmFileRpl1 = io.open("save/replays/netplay.replay","r")
1790+ tpmFileRpl1C = tpmFileRpl1:read("*all")
1791+ io.close(tpmFileRpl1)
1792+
1793+ tpmFileRpl2name = os.date("%Y-%m(%b)-%d %I-%M%p-%Ss")
1794+ tpmFileRpl2 = io.open("save/replays/" .. tpmFileRpl2name .. ".replay","w+")
1795+ tpmFileRpl2:write(tpmFileRpl1C)
1796+ io.close(tpmFileRpl2)
1797+ end
1798+ --JOIN
1799+ if t[item].itemname == 'serverjoin' then
1800+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
1801+ main.f_netplayJoin()
1802+ end
1803+ --BACK
1804+ if t[item].itemname == 'serverback' then
1805+ sndPlay(motif.files.snd_data, motif.title_info.cancel_snd[1], motif.title_info.cancel_snd[2])
1806+ break
1807+ end
1808+ end
1809+ main.f_menuCommon2(cursorPosY, moveTxt, item, t)
1810+ end
1811+end
1812+
1813+--;===========================================================
1814+--; NETPLAY JOIN
1815+--;===========================================================
1816+local t_netplayJoin = {}
1817+t_netplayJoin[#t_netplayJoin + 1] = {data = textImgNew(), itemname = 'joinadd', displayname = motif.title_info.menu_itemname_joinadd}
1818+for k, v in pairs(config.IP) do
1819+ t_netplayJoin[#t_netplayJoin + 1] = {
1820+ data = textImgNew(),
1821+ itemname = k,
1822+ displayname = k,
1823+ address = v
1824+ }
1825+end
1826+t_netplayJoin[#t_netplayJoin + 1] = {data = textImgNew(), itemname = 'joinback', displayname = motif.title_info.menu_itemname_joinback}
1827+
1828+function main.f_netplayJoin()
1829+ main.f_cmdInput()
1830+ local cursorPosY = 1
1831+ local moveTxt = 0
1832+ local item = 1
1833+ local t = t_netplayJoin
1834+ local t_tmp = {}
1835+ while true do
1836+ cursorPosY, moveTxt, item = main.f_menuCommon1(cursorPosY, moveTxt, item, t)
1837+ if esc() then
1838+ sndPlay(motif.files.snd_data, motif.title_info.cancel_snd[1], motif.title_info.cancel_snd[2])
1839+ break
1840+ --DELETE ENTRY
1841+ elseif getKey() == 'DELETE' and item ~= 1 and item ~= #t then
1842+ sndPlay(motif.files.snd_data, motif.title_info.cancel_snd[1], motif.title_info.cancel_snd[2])
1843+ resetKey()
1844+ config.IP[t[item].itemname] = nil
1845+ t_tmp = {}
1846+ for i = 1, #t do
1847+ if i ~= item then
1848+ t_tmp[#t_tmp + 1] = t[i]
1849+ end
1850+ end
1851+ t_netplayJoin = t_tmp
1852+ t = t_netplayJoin
1853+ local file = io.open("save/config.json","w+")
1854+ file:write(json.encode(config, {indent = true}))
1855+ file:close()
1856+ elseif main.f_btnPalNo(main.p1Cmd) > 0 then
1857+ main.f_default()
1858+ --NEW ADDRESS
1859+ if t[item].itemname == 'joinadd' then
1860+ sndPlay(motif.files.snd_data, motif.title_info.cursor_move_snd[1], motif.title_info.cursor_move_snd[2])
1861+ local name = main.f_input(main.f_extractText(motif.title_info.input_ip_name), motif.title_info, motif.titlebgdef, 'string')
1862+ if name ~= '' then
1863+ sndPlay(motif.files.snd_data, motif.title_info.cursor_move_snd[1], motif.title_info.cursor_move_snd[2])
1864+ local address = main.f_input(main.f_extractText(motif.title_info.input_ip_address), motif.title_info, motif.titlebgdef, 'string')
1865+ if address:match('^[0-9%.]+$') then
1866+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
1867+ config.IP[name] = address
1868+ t_tmp = {}
1869+ for i = 1, #t do
1870+ if i < #t then
1871+ t_tmp[i] = t[i]
1872+ else
1873+ t_tmp[i] = {data = textImgNew(), itemname = name, displayname = name, address = address}
1874+ t_tmp[i + 1] = t[i]
1875+ end
1876+ end
1877+ t_netplayJoin = t_tmp
1878+ t = t_netplayJoin
1879+ local file = io.open("save/config.json","w+")
1880+ file:write(json.encode(config, {indent = true}))
1881+ file:close()
1882+ else
1883+ sndPlay(motif.files.snd_data, motif.title_info.cancel_snd[1], motif.title_info.cancel_snd[2])
1884+ end
1885+ else
1886+ sndPlay(motif.files.snd_data, motif.title_info.cancel_snd[1], motif.title_info.cancel_snd[2])
1887+ end
1888+ --BACK
1889+ elseif t[item].itemname == 'joinback' then
1890+ sndPlay(motif.files.snd_data, motif.title_info.cancel_snd[1], motif.title_info.cancel_snd[2])
1891+ break
1892+ --CONNECTION
1893+ else
1894+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
1895+ main.f_connect(t[item].address, main.f_extractText(motif.title_info.connecting_join, t[item].name, t[item].address))
1896+ exitNetPlay()
1897+ exitReplay()
1898+ end
1899+ end
1900+ main.f_menuCommon2(cursorPosY, moveTxt, item, t)
1901+ end
1902+end
1903+
1904+--;===========================================================
1905+--; NETPLAY MODE
1906+--;===========================================================
1907+local t_netplayMode = {
1908+ {data = textImgNew(), itemname = 'netplayversus', displayname = motif.title_info.menu_itemname_netplayversus, selectname = motif.select_info.title_text_netplayversus},
1909+ {data = textImgNew(), itemname = 'netplayteamcoop', displayname = motif.title_info.menu_itemname_netplayteamcoop, selectname = motif.select_info.title_text_netplayteamcoop},
1910+ {data = textImgNew(), itemname = 'netplaysurvivalcoop', displayname = motif.title_info.menu_itemname_netplaysurvivalcoop, selectname = motif.select_info.title_text_netplaysurvivalcoop},
1911+ {data = textImgNew(), itemname = 'netplayback', displayname = motif.title_info.menu_itemname_netplayback},
1912+}
1913+t_netplayMode = main.f_cleanTable(t_netplayMode)
1914+
1915+function main.f_netplayMode()
1916+ main.f_cmdInput()
1917+ local cursorPosY = 1
1918+ local moveTxt = 0
1919+ local item = 1
1920+ local t = t_netplayMode
1921+ while true do
1922+ cursorPosY, moveTxt, item = main.f_menuCommon1(cursorPosY, moveTxt, item, t)
1923+ if esc() then
1924+ sndPlay(motif.files.snd_data, motif.title_info.cancel_snd[1], motif.title_info.cancel_snd[2])
1925+ break
1926+ elseif main.f_btnPalNo(main.p1Cmd) > 0 then
1927+ main.f_default()
1928+ --VS MODE
1929+ if t[item].itemname == 'netplayversus' then
1930+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
1931+ setHomeTeam(1)
1932+ main.p2In = 2
1933+ main.stageMenu = true
1934+ main.p2Faces = true
1935+ textImgSetText(main.txt_mainSelect, t[item].selectname)
1936+ select.f_selectSimple()
1937+ end
1938+ --TEAM CO-OP
1939+ if t[item].itemname == 'netplayteamcoop' then
1940+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
1941+ main.p2In = 2
1942+ main.p2Faces = true
1943+ main.coop = true
1944+ main.credits = config.Credits - 1
1945+ main.gameMode = t[item].itemname
1946+ textImgSetText(main.txt_mainSelect, t[item].selectname)
1947+ select.f_selectAdvance()
1948+ end
1949+ --SURVIVAL CO-OP
1950+ if t[item].itemname == 'netplaysurvivalcoop' then
1951+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
1952+ main.p2In = 2
1953+ main.p2Faces = true
1954+ main.coop = true
1955+ main.credits = 0
1956+ main.gameMode = t[item].itemname
1957+ textImgSetText(main.txt_mainSelect, t[item].selectname)
1958+ select.f_selectAdvance()
1959+ end
1960+ --BACK
1961+ if t[item].itemname == 'netplayback' then
1962+ sndPlay(motif.files.snd_data, motif.title_info.cancel_snd[1], motif.title_info.cancel_snd[2])
1963+ break
1964+ end
1965+ end
1966+ main.f_menuCommon2(cursorPosY, moveTxt, item, t)
1967+ end
1968+end
1969+
1970+--;===========================================================
1971+--; EXTRAS MENU
1972+--;===========================================================
1973+local t_mainExtras = {
1974+ {data = textImgNew(), itemname = 'freebattle', displayname = motif.title_info.menu_itemname_freebattle, selectname = motif.select_info.title_text_freebattle},
1975+ --{data = textImgNew(), itemname = 'timechallenge', displayname = motif.title_info.menu_itemname_timechallenge, selectname = motif.select_info.title_text_timechallenge},
1976+ --{data = textImgNew(), itemname = 'scorechallenge', displayname = motif.title_info.menu_itemname_scorechallenge, selectname = motif.select_info.title_text_scorechallenge},
1977+ {data = textImgNew(), itemname = '100kumite', displayname = motif.title_info.menu_itemname_100kumite, selectname = motif.select_info.title_text_100kumite},
1978+ {data = textImgNew(), itemname = 'bossrush', displayname = motif.title_info.menu_itemname_bossrush, selectname = motif.select_info.title_text_bossrush},
1979+ {data = textImgNew(), itemname = 'bonusgames', displayname = motif.title_info.menu_itemname_bonusgames},
1980+ --{data = textImgNew(), itemname = 'scoreranking', displayname = motif.title_info.menu_itemname_scoreranking},
1981+ {data = textImgNew(), itemname = 'replay', displayname = motif.title_info.menu_itemname_replay, selectname = motif.select_info.title_text_replay},
1982+ {data = textImgNew(), itemname = 'demo', displayname = motif.title_info.menu_itemname_demo},
1983+ {data = textImgNew(), itemname = 'extrasback', displayname = motif.title_info.menu_itemname_extrasback},
1984+}
1985+for i = 1, #t_mainExtras do
1986+ if t_mainExtras[i].itemname == 'bossrush' and #main.t_bossChars == 0 then
1987+ t_mainExtras[i].displayname = ''
1988+ elseif t_mainExtras[i].itemname == 'bonusgames' and #main.t_bonusChars == 0 then
1989+ t_mainExtras[i].displayname = ''
1990+ elseif t_mainExtras[i].itemname == 'demo' and #main.t_randomChars < 2 then
1991+ t_mainExtras[i].displayname = ''
1992+ end
1993+end
1994+t_mainExtras = main.f_cleanTable(t_mainExtras)
1995+
1996+function main.f_mainExtras()
1997+ main.f_cmdInput()
1998+ local cursorPosY = 1
1999+ local moveTxt = 0
2000+ local item = 1
2001+ local t = t_mainExtras
2002+ while true do
2003+ cursorPosY, moveTxt, item = main.f_menuCommon1(cursorPosY, moveTxt, item, t)
2004+ if esc() then
2005+ sndPlay(motif.files.snd_data, motif.title_info.cancel_snd[1], motif.title_info.cancel_snd[2])
2006+ break
2007+ elseif main.f_btnPalNo(main.p1Cmd) > 0 then
2008+ main.f_default()
2009+ --FREE BATTLE
2010+ if t[item].itemname == 'freebattle' then
2011+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
2012+ main.p2In = 1
2013+ main.stageMenu = true
2014+ main.p2Faces = true
2015+ textImgSetText(main.txt_mainSelect, t[item].selectname)
2016+ main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
2017+ select.f_selectSimple()
2018+ end
2019+ --VS 100 KUMITE
2020+ if t[item].itemname == '100kumite' then
2021+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
2022+ main.p2In = 1
2023+ main.p2SelectMenu = false
2024+ main.gameMode = t[item].itemname
2025+ textImgSetText(main.txt_mainSelect, t[item].selectname)
2026+ main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
2027+ select.f_selectAdvance()
2028+ end
2029+ --BOSS RUSH
2030+ if t[item].itemname == 'bossrush' then
2031+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
2032+ main.p2In = 1
2033+ main.p2SelectMenu = false
2034+ main.credits = 0
2035+ main.gameMode = t[item].itemname
2036+ textImgSetText(main.txt_mainSelect, t[item].selectname)
2037+ main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
2038+ select.f_selectAdvance()
2039+ end
2040+ --BONUS GAMES
2041+ if t[item].itemname == 'bonusgames' then
2042+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
2043+ main.f_bonusExtras()
2044+ end
2045+ --REPLAY
2046+ if t[item].itemname == 'replay' then
2047+ if main.f_fileExists('save/replays/netplay.replay') then
2048+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
2049+ enterReplay('save/replays/netplay.replay')
2050+ synchronize()
2051+ math.randomseed(sszRandom())
2052+ main.f_netplayMode()
2053+ exitNetPlay()
2054+ exitReplay()
2055+ end
2056+ end
2057+ --DEMO
2058+ if t[item].itemname == 'demo' then
2059+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
2060+ main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
2061+ randomtest.run()
2062+ end
2063+ --BACK
2064+ if t[item].itemname == 'extrasback' then
2065+ sndPlay(motif.files.snd_data, motif.title_info.cancel_snd[1], motif.title_info.cancel_snd[2])
2066+ break
2067+ end
2068+ end
2069+ main.f_menuCommon2(cursorPosY, moveTxt, item, t)
2070+ end
2071+end
2072+
2073+--;===========================================================
2074+--; BONUS GAMES
2075+--;===========================================================
2076+local t_bonusExtras = {}
2077+for i = 1, #main.t_bonusChars do
2078+ local name = getCharName(main.t_bonusChars[i])
2079+ t_bonusExtras[i] = {
2080+ data = textImgNew(),
2081+ itemname = name,
2082+ displayname = name:upper(),
2083+ selectname = name
2084+ }
2085+end
2086+if motif.title_info.menu_itemname_bonusback ~= '' then
2087+ t_bonusExtras[#t_bonusExtras + 1] = {data = textImgNew(), itemname = 'bonusback', displayname = motif.title_info.menu_itemname_bonusback}
2088+end
2089+
2090+function main.f_bonusExtras()
2091+ main.f_cmdInput()
2092+ local cursorPosY = 1
2093+ local moveTxt = 0
2094+ local item = 1
2095+ local t = t_bonusExtras
2096+ while true do
2097+ cursorPosY, moveTxt, item = main.f_menuCommon1(cursorPosY, moveTxt, item, t)
2098+ if esc() then
2099+ sndPlay(motif.files.snd_data, motif.title_info.cancel_snd[1], motif.title_info.cancel_snd[2])
2100+ break
2101+ elseif main.f_btnPalNo(main.p1Cmd) > 0 then
2102+ main.f_default()
2103+ --BACK
2104+ if t[item].itemname == 'bonusback' then
2105+ sndPlay(motif.files.snd_data, motif.title_info.cancel_snd[1], motif.title_info.cancel_snd[2])
2106+ break
2107+ --BONUS CHAR NAME
2108+ else
2109+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
2110+ main.versusScreen = false
2111+ main.p1TeamMenu = {mode = 0, chars = 1}
2112+ main.p2TeamMenu = {mode = 0, chars = 1}
2113+ main.p2Char = {main.t_bonusChars[item]}
2114+ textImgSetText(main.txt_mainSelect, t[item].selectname)
2115+ main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
2116+ select.f_selectSimple()
2117+ end
2118+ end
2119+ main.f_menuCommon2(cursorPosY, moveTxt, item, t)
2120+ end
2121+end
2122+
2123+--;===========================================================
2124+--; TOURNAMENT MENU
2125+--;===========================================================
2126+local t_mainTournament = {
2127+ {data = textImgNew(), itemname = 'tourney32', displayname = motif.title_info.menu_itemname_tourney32, selectname = motif.select_info.title_text_tourney32},
2128+ {data = textImgNew(), itemname = 'tourney16', displayname = motif.title_info.menu_itemname_tourney16, selectname = motif.select_info.title_text_tourney16},
2129+ {data = textImgNew(), itemname = 'tourney8', displayname = motif.title_info.menu_itemname_tourney8, selectname = motif.select_info.title_text_tourney8},
2130+ {data = textImgNew(), itemname = 'tourney4', displayname = motif.title_info.menu_itemname_tourney4, selectname = motif.select_info.title_text_tourney4},
2131+ {data = textImgNew(), itemname = 'tourneyback', displayname = motif.title_info.menu_itemname_tourneyback},
2132+}
2133+t_mainTournament = main.f_cleanTable(t_mainTournament)
2134+
2135+function main.f_mainTournament()
2136+ main.f_cmdInput()
2137+ local cursorPosY = 1
2138+ local moveTxt = 0
2139+ local item = 1
2140+ local t = t_mainTournament
2141+ while true do
2142+ cursorPosY, moveTxt, item = main.f_menuCommon1(cursorPosY, moveTxt, item, t)
2143+ if esc() then
2144+ sndPlay(motif.files.snd_data, motif.title_info.cancel_snd[1], motif.title_info.cancel_snd[2])
2145+ break
2146+ elseif main.f_btnPalNo(main.p1Cmd) > 0 then
2147+ main.f_default()
2148+ --ROUND OF 32
2149+ if t[item].itemname == 'tourney32' then
2150+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
2151+ main.gameMode = t[item].itemname
2152+ textImgSetText(main.txt_mainSelect, t[item].selectname)
2153+ main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
2154+ select.f_selectTournament()
2155+ end
2156+ --ROUND OF 16
2157+ if t[item].itemname == 'tourney16' then
2158+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
2159+ main.gameMode = t[item].itemname
2160+ textImgSetText(main.txt_mainSelect, t[item].selectname)
2161+ main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
2162+ select.f_selectTournament()
2163+ end
2164+ --QUARTERFINALS
2165+ if t[item].itemname == 'tourney8' then
2166+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
2167+ main.gameMode = t[item].itemname
2168+ textImgSetText(main.txt_mainSelect, t[item].selectname)
2169+ main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
2170+ select.f_selectTournament()
2171+ end
2172+ --SEMIFINALS
2173+ if t[item].itemname == 'tourney4' then
2174+ sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
2175+ main.gameMode = t[item].itemname
2176+ textImgSetText(main.txt_mainSelect, t[item].selectname)
2177+ main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
2178+ select.f_selectTournament()
2179+ end
2180+ --BACK
2181+ if t[item].itemname == 'tourneyback' then
2182+ sndPlay(motif.files.snd_data, motif.title_info.cancel_snd[1], motif.title_info.cancel_snd[2])
2183+ break
2184+ end
2185+ end
2186+ main.f_menuCommon2(cursorPosY, moveTxt, item, t)
2187+ end
2188+end
2189+
2190+--;===========================================================
2191+--; INITIALIZE LOOPS
2192+--;===========================================================
2193+
2194+-- Now that everithig is loaded we can enable GC back.
2195+SetGCPercent(100)
2196+-------------------------------------------------------------
2197+
2198+main.f_mainMenu()
2199+
2200+
2201+-- Debug Info
2202+main.f_printTable(main, "debug/t_main.txt")
--- /dev/null
+++ b/script/motif.lua
@@ -0,0 +1,1774 @@
1+--;===========================================================
2+--; DEFAULT VALUES
3+--;===========================================================
4+--This pre-made table (3/4 of the whole file) contains all default values used in screenpack. New table from parsed DEF file is merged on top of this one.
5+--This is important because there are more params available in Ikemen. Whole screenpack code refers to these values.
6+local motif =
7+{
8+ info =
9+ {
10+ name = 'Default',
11+ author = 'Elecbyte',
12+ versiondate = '09,01,2009',
13+ mugenversion = '1.0',
14+ localcoord = {320, 240},
15+ },
16+ files =
17+ {
18+ spr = 'data/system.sff',
19+ snd = 'data/system.snd',
20+ continue_snd = 'data/continue.snd', --Ikemen feature (optional separate entry for better compatibility with existing screenpacks)
21+ logo_storyboard = '',
22+ intro_storyboard = '',
23+ select = 'data/select.def',
24+ fight = 'data/fight.def',
25+ debug_font = 'font/f-6x9.fnt', --Ikemen feature
26+ debug_script = 'script/debug.lua', --Ikemen feature
27+ font = --FNT v2 fonts not supported yet
28+ {
29+ [1] = 'font/f-4x6.fnt',
30+ [2] = 'font/f-6x9.fnt',
31+ [3] = 'font/jg.fnt',
32+ },
33+ font_height = --Truetype fonts not supported yet
34+ {
35+ [1] = nil,
36+ [2] = nil,
37+ [3] = nil,
38+ },
39+ },
40+ ja_files = {}, --not used in Ikemen
41+ music =
42+ {
43+ title_bgm = '',
44+ title_bgm_volume = 100,
45+ title_bgm_loop = 1, --not supported yet
46+ title_bgm_loopstart = nil, --not supported yet
47+ title_bgm_loopend = nil, --not supported yet
48+ select_bgm = '',
49+ select_bgm_volume = 100,
50+ select_bgm_loop = 1, --not supported yet
51+ select_bgm_loopstart = nil, --not supported yet
52+ select_bgm_loopend = nil, --not supported yet
53+ vs_bgm = '',
54+ vs_bgm_volume = 100,
55+ vs_bgm_loop = 1, --not supported yet
56+ vs_bgm_loopstart = nil, --not supported yet
57+ vs_bgm_loopend = nil, --not supported yet
58+ victory_bgm = '',
59+ victory_bgm_volume = 100,
60+ victory_bgm_loop = 1, --not supported yet
61+ victory_bgm_loopstart = nil, --not supported yet
62+ victory_bgm_loopend = nil, --not supported yet
63+ continue_bgm = 'sound/CONTINUE.ogg', --Ikemen feature
64+ continue_bgm_volume = 100, --Ikemen feature (not supported yet)
65+ continue_bgm_loop = 1, --Ikemen feature (not supported yet)
66+ continue_bgm_loopstart = nil, --Ikemen feature (not supported yet)
67+ continue_bgm_loopend = nil, --Ikemen feature (not supported yet)
68+ continue_end_bgm = 'sound/GAME_OVER.ogg', --Ikemen feature
69+ continue_end_volume = 100, --Ikemen feature (not supported yet)
70+ continue_end_loop = 0, --Ikemen feature (not supported yet)
71+ continue_end_loopstart = nil, --Ikemen feature (not supported yet)
72+ continue_end_loopend = nil, --Ikemen feature (not supported yet)
73+ results_bgm = '', --Ikemen feature
74+ results_bgm_loop = 1, --Ikemen feature (not supported yet)
75+ results_bgm_loopstart = nil, --Ikemen feature (not supported yet)
76+ results_bgm_loopend = nil, --Ikemen feature (not supported yet)
77+ tournament_bgm = '', --Ikemen feature
78+ tournament_bgm_loop = 1, --Ikemen feature (not supported yet)
79+ tournament_bgm_loopstart = nil, --Ikemen feature (not supported yet)
80+ tournament_bgm_loopend = nil, --Ikemen feature (not supported yet)
81+ },
82+ title_info =
83+ {
84+ fadein_time = 10,
85+ fadein_col = {0, 0, 0}, --Ikemen feature
86+ fadeout_time = 10,
87+ fadeout_col = {0, 0, 0}, --Ikemen feature
88+ loading_offset = {310, 230}, --Ikemen feature
89+ loading_font = {'font/f-4x6.fnt', 7, -1, nil, nil, nil}, --Ikemen feature
90+ loading_font_scale = {1.0, 1.0}, --Ikemen feature
91+ loading_text = 'LOADING...', --Ikemen feature
92+ footer1_offset = {2, 240}, --Ikemen feature
93+ footer1_font = {'font/f-4x6.fnt', 7, 1, nil, nil, nil}, --Ikemen feature
94+ footer1_font_scale = {1.0, 1.0}, --Ikemen feature
95+ footer1_text = 'I.K.E.M.E.N. by SUEHIRO', --Ikemen feature
96+ footer2_offset = {160, 240}, --Ikemen feature
97+ footer2_font = {'font/f-4x6.fnt', 7, 0, nil, nil, nil}, --Ikemen feature
98+ footer2_font_scale = {1.0, 1.0}, --Ikemen feature
99+ footer2_text = '', --Ikemen feature
100+ footer3_offset = {319, 240}, --Ikemen feature
101+ footer3_font = {'font/f-4x6.fnt', 7, -1, nil, nil, nil}, --Ikemen feature
102+ footer3_font_scale = {1.0, 1.0}, --Ikemen feature
103+ footer3_text = 'https://osdn.net/users/supersuehiro/', --Ikemen feature
104+ footer_boxbackground_visible = 1, --Ikemen feature
105+ footer_boxbackground_coords = {0, 233, 319, 239}, --Ikemen feature
106+ footer_boxbackground_alpha = {255, 100}, --Ikemen feature
107+ connecting_offset = {10, 40}, --Ikemen feature
108+ connecting_font = {'font/f-6x9.fnt', 0, 1, nil, nil, nil}, --Ikemen feature
109+ connecting_font_scale = {1.0, 1.0}, --Ikemen feature
110+ connecting_host = 'Waiting for player 2... (%s)', --Ikemen feature
111+ connecting_join = 'Now connecting... (%s)', --Ikemen feature
112+ input_ip_name = 'Enter Host display name, e.g. John.\nExisting entries can be removed with DELETE button.', --Ikemen feature
113+ input_ip_address = 'Enter Host IP address, e.g. 127.0.0.1\nCopied text can be pasted with INSERT button.', --Ikemen feature
114+ menu_pos = {159, 158},
115+ menu_item_font = {'font/f-6x9.fnt', 7, 0, nil, nil, nil},
116+ menu_item_font_scale = {1.0, 1.0},
117+ menu_item_active_font = {'font/f-6x9.fnt', 0, 0, nil, nil, nil},
118+ menu_item_active_font_scale = {1.0, 1.0},
119+ menu_item_spacing = {0, 13},
120+ menu_itemname_arcade = 'ARCADE',
121+ menu_itemname_versus = 'VS MODE',
122+ menu_itemname_online = 'NETWORK', --Ikemen feature
123+ menu_itemname_teamarcade = 'TEAM ARCADE', --not used in Ikemen (same as ARCADE)
124+ menu_itemname_teamversus = 'TEAM VS', --not used in Ikemen (same as VS MODE)
125+ menu_itemname_teamcoop = 'TEAM CO-OP',
126+ menu_itemname_survival = 'SURVIVAL',
127+ menu_itemname_survivalcoop = 'SURVIVAL CO-OP',
128+ menu_itemname_storymode = 'STORY MODE', --Ikemen feature (not implemented yet)
129+ menu_itemname_timeattack = 'TIME ATTACK', --Ikemen feature (not implemented yet)
130+ menu_itemname_tournament = 'TOURNAMENT', --Ikemen feature
131+ menu_itemname_training = 'TRAINING',
132+ menu_itemname_watch = 'WATCH',
133+ menu_itemname_extras = 'EXTRAS', --Ikemen feature
134+ menu_itemname_options = 'OPTIONS',
135+ menu_itemname_exit = 'EXIT',
136+ menu_itemname_netplayversus = 'VS MODE', --Ikemen feature
137+ menu_itemname_netplayteamcoop = 'TEAM CO-OP', --Ikemen feature
138+ menu_itemname_netplaysurvivalcoop = 'SURVIVAL CO-OP', --Ikemen feature
139+ menu_itemname_netplayback = 'BACK', --Ikemen feature
140+ menu_itemname_freebattle = 'FREE BATTLE', --Ikemen feature
141+ menu_itemname_timechallenge = 'TIME CHALLENGE', --Ikemen feature (not implemented yet)
142+ menu_itemname_scorechallenge = 'SCORE CHALLENGE', --Ikemen feature (not implemented yet)
143+ menu_itemname_100kumite = 'VS 100 KUMITE', --Ikemen feature
144+ menu_itemname_bossrush = 'BOSS RUSH', --Ikemen feature
145+ menu_itemname_bonusgames = 'BONUS GAMES', --Ikemen feature
146+ menu_itemname_scoreranking = 'SCORE RANKING', --Ikemen feature (not implemented yet)
147+ menu_itemname_replay = 'REPLAY', --Ikemen feature
148+ menu_itemname_demo = 'DEMO', --Ikemen feature
149+ menu_itemname_extrasback = 'BACK', --Ikemen feature
150+ menu_itemname_bonusback = 'BACK', --Ikemen feature
151+ menu_itemname_tourney32 = 'ROUND OF 32', --Ikemen feature
152+ menu_itemname_tourney16 = 'ROUND OF 16', --Ikemen feature
153+ menu_itemname_tourney8 = 'QUARTERFINALS', --Ikemen feature
154+ menu_itemname_tourney4 = 'SEMIFINALS', --Ikemen feature
155+ menu_itemname_tourneyback = 'BACK', --Ikemen feature
156+ menu_itemname_serverhost = 'HOST GAME', --Ikemen feature
157+ menu_itemname_serverjoin = 'JOIN GAME', --Ikemen feature
158+ menu_itemname_serverback = 'BACK', --Ikemen feature
159+ menu_itemname_joinadd = 'NEW ADDRESS', --Ikemen feature
160+ menu_itemname_joinback = 'BACK', --Ikemen feature
161+ menu_window_margins_y = {12, 8}, --only partial support for now (menu_window_visibleitems + 1 displayed if y value > 0)
162+ menu_window_visibleitems = 5,
163+ menu_boxcursor_visible = 1,
164+ menu_boxcursor_coords = {-40, -10, 39, 2},
165+ cursor_move_snd = {100, 0},
166+ cursor_done_snd = {100, 1},
167+ cancel_snd = {100, 2},
168+ },
169+ titlebgdef =
170+ {
171+ spr = '',
172+ bgclearcolor = {0, 0, 0},
173+ bg = {},
174+ timer = 0, --Ikemen feature
175+ },
176+ infobox =
177+ {
178+ title = 'I.K.E.M.E.N', --Ikemen feature
179+ title_pos = {159, 13}, --Ikemen feature
180+ title_font = {'font/f-6x9.fnt', 0, 0, nil, nil, nil}, --Ikemen feature
181+ title_font_scale = {1.0, 1.0}, --Ikemen feature
182+ text = "Welcome to I.K.E.M.E.N beta!\n* This is a public development release, for testing purposes.\n* This build isn't stable and may contain bugs and incomplete features.\n* Your help and cooperation are appreciated!\n* Source code: https://osdn.net/users/supersuehiro/\n* Ikemen Plus feedback:\n http://mugenguild.com/forum/topics/ikemen-plus-181972.200.html", --Ikemen feature (requires new 'text = ' entry under [Infobox] section)
183+ text_pos = {25, 30}, --Ikemen feature
184+ text_font = {'font/f-4x6.fnt', 7, 1, nil, nil, nil}, --Ikemen feature
185+ text_font_scale = {1.0, 1.0}, --Ikemen feature
186+ text_spacing = {0, 10}, --Ikemen feature
187+ background_alpha = {20, 100}, --Ikemen feature
188+ },
189+ infobox_text = '', --not used in Ikemen
190+ ja_infobox_text = '', --not used in Ikemen
191+ select_info =
192+ {
193+ fadein_time = 10,
194+ fadein_col = {0, 0, 0}, --Ikemen feature
195+ fadeout_time = 10,
196+ fadeout_col = {0, 0, 0}, --Ikemen feature
197+ rows = 2,
198+ columns = 5,
199+ rows_scrolling = 0, --Ikemen feature
200+ wrapping = 0,
201+ wrapping_x = 1, --Ikemen feature
202+ wrapping_y = 1, --Ikemen feature
203+ pos = {90, 170},
204+ double_select = 0, --Ikemen feature
205+ pos_p1_double_select = {10, 170}, --Ikemen feature
206+ pos_p2_double_select = {169, 170}, --Ikemen feature
207+ showemptyboxes = 0,
208+ moveoveremptyboxes = 0,
209+ searchemptyboxesup = 0, --Ikemen feature
210+ searchemptyboxesdown = 0, --Ikemen feature
211+ cell_size = {27, 27},
212+ cell_spacing = 2,
213+ --cell_bg_anim = nil,
214+ cell_bg_spr = {},
215+ cell_bg_offset = {0, 0},
216+ cell_bg_facing = 1,
217+ cell_bg_scale = {1.0, 1.0},
218+ --cell_bg_alpha = {}, --Ikemen feature (not implemented yet)
219+ --cell_random_anim = nil,
220+ cell_random_spr = {},
221+ cell_random_offset = {0, 0},
222+ cell_random_facing = 1,
223+ cell_random_scale = {1.0, 1.0},
224+ --cell_random_alpha = {}, --Ikemen feature (not implemented yet)
225+ cell_random_switchtime = 4,
226+ p1_cursor_startcell = {0, 0},
227+ --p1_cursor_active_anim = nil,
228+ p1_cursor_active_spr = {},
229+ p1_cursor_active_offset = {0, 0},
230+ p1_cursor_active_facing = 1,
231+ p1_cursor_active_scale = {1.0, 1.0},
232+ --p1_cursor_done_anim = nil,
233+ p1_cursor_done_spr = {},
234+ p1_cursor_done_offset = {0, 0},
235+ p1_cursor_done_facing = 1,
236+ p1_cursor_done_scale = {1.0, 1.0},
237+ p1_cursor_move_snd = {100, 0},
238+ p1_cursor_done_snd = {100, 1},
239+ p1_random_move_snd = {100, 0},
240+ p2_cursor_startcell = {0, 4},
241+ --p2_cursor_active_anim = nil,
242+ p2_cursor_active_spr = {},
243+ p2_cursor_active_offset = {0, 0},
244+ p2_cursor_active_facing = 1,
245+ p2_cursor_active_scale = {1.0, 1.0},
246+ --p2_cursor_done_anim = nil,
247+ p2_cursor_done_spr = {},
248+ p2_cursor_done_offset = {0, 0},
249+ p2_cursor_done_facing = 1,
250+ p2_cursor_done_scale = {1.0, 1.0},
251+ p2_cursor_blink = 1,
252+ p2_cursor_move_snd = {100, 0},
253+ p2_cursor_done_snd = {100, 1},
254+ p2_random_move_snd = {100, 0},
255+ random_move_snd_cancel = 0, --not supported yet (needs a function that checks sound length)
256+ stage_move_snd = {100, 0},
257+ stage_done_snd = {100, 1},
258+ cancel_snd = {100, 2},
259+ portrait_spr = {9000, 0},
260+ portrait_offset = {0, 0}, --not supported yet
261+ portrait_scale = {1.0, 1.0},
262+ title_offset = {0, 0},
263+ title_font = {'font/jg.fnt', 0, 0, nil, nil, nil},
264+ title_font_scale = {1.0, 1.0},
265+ title_text_arcade = 'Arcade', --Ikemen feature
266+ title_text_versus = 'Versus Mode', --Ikemen feature
267+ title_text_teamcoop = 'Team Cooperative', --Ikemen feature
268+ title_text_survival = 'Survival', --Ikemen feature
269+ title_text_survivalcoop = 'Survival Cooperative', --Ikemen feature
270+ title_text_storymode = 'Story Mode', --Ikemen feature (not implemented yet)
271+ title_text_timeattack = 'Time Attack', --Ikemen feature (not implemented yet)
272+ title_text_training = 'Training Mode', --Ikemen feature
273+ title_text_watch = 'Watch Mode', --Ikemen feature
274+ title_text_netplayversus = 'Online Versus', --Ikemen feature
275+ title_text_netplayteamcoop = 'Online Cooperative', --Ikemen feature
276+ title_text_netplaysurvivalcoop = 'Online Survival', --Ikemen feature
277+ title_text_freebattle = 'Free Battle', --Ikemen feature
278+ title_text_timechallenge = 'Time Challenge', --Ikemen feature (not implemented yet)
279+ title_text_scorechallenge = 'Score Challenge', --Ikemen feature (not implemented yet)
280+ title_text_100kumite = 'VS 100 Kumite', --Ikemen feature
281+ title_text_bossrush = 'Boss Rush', --Ikemen feature
282+ title_text_replay = 'Replay', --Ikemen feature
283+ title_text_tourney32 = 'Tournament Mode', --Ikemen feature
284+ title_text_tourney16 = 'Tournament Mode', --Ikemen feature
285+ title_text_tourney8 = 'Tournament Mode', --Ikemen feature
286+ title_text_tourney4 = 'Tournament Mode', --Ikemen feature
287+ p1_face_spr = {9000, 1},
288+ p1_face_offset = {0, 0},
289+ p1_face_facing = 1,
290+ p1_face_scale = {1.0, 1.0},
291+ p1_face_window = {0, 0, 0, 0},
292+ p1_face_spacing = {0, 0}, --Ikemen feature
293+ p1_face_num = 1, --Ikemen feature
294+ p2_face_spr = {9000, 1},
295+ p2_face_offset = {0, 0},
296+ p2_face_facing = -1,
297+ p2_face_scale = {1.0, 1.0},
298+ p2_face_window = {0, 0, 0, 0},
299+ p2_face_spacing = {0, 0}, --Ikemen feature
300+ p2_face_num = 1, --Ikemen feature
301+ p1_name_offset = {0, 0},
302+ p1_name_font = {'font/jg.fnt', 4, 1, nil, nil, nil},
303+ p1_name_font_scale = {1.0, 1.0},
304+ p1_name_spacing = {0, 14},
305+ p2_name_offset = {0, 0},
306+ p2_name_font = {'font/jg.fnt', 1, -1, nil, nil, nil},
307+ p2_name_font_scale = {1.0, 1.0},
308+ p2_name_spacing = {0, 14},
309+ stage_pos = {0, 0},
310+ stage_active_font = {'font/f-4x6.fnt', 0, 0, nil, nil, nil},
311+ stage_active_font_scale = {1.0, 1.0},
312+ stage_active2_font = {'font/f-4x6.fnt', 0, 0, nil, nil, nil},
313+ stage_active2_font_scale = {1.0, 1.0},
314+ stage_done_font = {'font/f-4x6.fnt', 0, 0, nil, nil, nil},
315+ stage_done_font_scale = {1.0, 1.0},
316+ stage_text = 'Stage %i: %s', --Ikemen feature
317+ stage_text_spacing = {0, 14}, --Ikemen feature
318+ teammenu_move_wrapping = 1,
319+ teammenu_itemname_single = 'Single', --Ikemen feature
320+ teammenu_itemname_simul = 'Simul', --Ikemen feature
321+ teammenu_itemname_turns = 'Turns', --Ikemen feature
322+ teammenu_itemname_tag = 'Tag', --Ikemen feature
323+ p1_teammenu_pos = {0, 0},
324+ --p1_teammenu_bg_anim = nil,
325+ p1_teammenu_bg_spr = {},
326+ p1_teammenu_bg_offset = {0, 0},
327+ p1_teammenu_bg_facing = 1,
328+ p1_teammenu_bg_scale = {1.0, 1.0},
329+ --p1_teammenu_selftitle_anim = nil,
330+ p1_teammenu_selftitle_spr = {},
331+ p1_teammenu_selftitle_offset = {0, 0},
332+ p1_teammenu_selftitle_facing = 1,
333+ p1_teammenu_selftitle_scale = {1.0, 1.0},
334+ p1_teammenu_selftitle_font = {'font/jg.fnt', 0, 1, nil, nil, nil},
335+ p1_teammenu_selftitle_font_scale = {1.0, 1.0},
336+ p1_teammenu_selftitle_text = '',
337+ --p1_teammenu_enemytitle_anim = nil,
338+ p1_teammenu_enemytitle_spr = {},
339+ p1_teammenu_enemytitle_offset = {0, 0},
340+ p1_teammenu_enemytitle_facing = 1,
341+ p1_teammenu_enemytitle_scale = {1.0, 1.0},
342+ p1_teammenu_enemytitle_font = {'font/jg.fnt', 0, 1, nil, nil, nil},
343+ p1_teammenu_enemytitle_font_scale = {1.0, 1.0},
344+ p1_teammenu_enemytitle_text = '',
345+ p1_teammenu_move_snd = {100, 0},
346+ p1_teammenu_value_snd = {100, 0},
347+ p1_teammenu_done_snd = {100, 1},
348+ p1_teammenu_item_offset = {0, 0},
349+ p1_teammenu_item_spacing = {0, 15},
350+ p1_teammenu_item_font_offset = {0, 0}, --Ikemen feature
351+ p1_teammenu_item_font = {'font/jg.fnt', 0, 1, nil, nil, nil},
352+ p1_teammenu_item_font_scale = {1.0, 1.0},
353+ p1_teammenu_item_active_font = {'font/jg.fnt', 3, 1, nil, nil, nil},
354+ p1_teammenu_item_active_font_scale = {1.0, 1.0},
355+ p1_teammenu_item_active2_font = {'font/jg.fnt', 0, 1, nil, nil, nil},
356+ p1_teammenu_item_active2_font_scale = {1.0, 1.0},
357+ --p1_teammenu_item_cursor_anim = nil,
358+ p1_teammenu_item_cursor_spr = {},
359+ p1_teammenu_item_cursor_offset = {0, 0},
360+ p1_teammenu_item_cursor_facing = 1,
361+ p1_teammenu_item_cursor_scale = {1.0, 1.0},
362+ --p1_teammenu_value_icon_anim = nil,
363+ p1_teammenu_value_icon_spr = {},
364+ p1_teammenu_value_icon_offset = {0, 0},
365+ p1_teammenu_value_icon_facing = 1,
366+ p1_teammenu_value_icon_scale = {1.0, 1.0},
367+ --p1_teammenu_value_empty_icon_anim = nil,
368+ p1_teammenu_value_empty_icon_spr = {},
369+ p1_teammenu_value_empty_icon_offset = {0, 0},
370+ p1_teammenu_value_empty_icon_facing = 1,
371+ p1_teammenu_value_empty_icon_scale = {1.0, 1.0},
372+ p1_teammenu_value_spacing = {6, 0},
373+ p2_teammenu_pos = {0, 0},
374+ --p2_teammenu_bg_anim = nil,
375+ p2_teammenu_bg_spr = {},
376+ p2_teammenu_bg_offset = {0, 0},
377+ p2_teammenu_bg_facing = 1,
378+ p2_teammenu_bg_scale = {1.0, 1.0},
379+ --p2_teammenu_selftitle_anim = nil,
380+ p2_teammenu_selftitle_spr = {},
381+ p2_teammenu_selftitle_offset = {0, 0},
382+ p2_teammenu_selftitle_facing = 1,
383+ p2_teammenu_selftitle_scale = {1.0, 1.0},
384+ p2_teammenu_selftitle_font = {'font/jg.fnt', 0, -1, nil, nil, nil},
385+ p2_teammenu_selftitle_font_scale = {1.0, 1.0},
386+ p2_teammenu_selftitle_text = '',
387+ --p2_teammenu_enemytitle_anim = nil,
388+ p2_teammenu_enemytitle_spr = {},
389+ p2_teammenu_enemytitle_offset = {0, 0},
390+ p2_teammenu_enemytitle_facing = 1,
391+ p2_teammenu_enemytitle_scale = {1.0, 1.0},
392+ p2_teammenu_enemytitle_font = {'font/jg.fnt', 0, -1, nil, nil, nil},
393+ p2_teammenu_enemytitle_font_scale = {1.0, 1.0},
394+ p2_teammenu_enemytitle_text = '',
395+ p2_teammenu_move_snd = {100, 0},
396+ p2_teammenu_value_snd = {100, 0},
397+ p2_teammenu_done_snd = {100, 1},
398+ p2_teammenu_item_offset = {0, 0},
399+ p2_teammenu_item_spacing = {0, 15},
400+ p2_teammenu_item_font_offset = {0, 0}, --Ikemen feature
401+ p2_teammenu_item_font = {'font/jg.fnt', 0, -1, nil, nil, nil},
402+ p2_teammenu_item_font_scale = {1.0, 1.0},
403+ p2_teammenu_item_active_font = {'font/jg.fnt', 1, -1, nil, nil, nil},
404+ p2_teammenu_item_active_font_scale = {1.0, 1.0},
405+ p2_teammenu_item_active2_font = {'font/jg.fnt', 0, -1, nil, nil, nil},
406+ p2_teammenu_item_active2_font_scale = {1.0, 1.0},
407+ --p2_teammenu_item_cursor_anim = nil,
408+ p2_teammenu_item_cursor_spr = {},
409+ p2_teammenu_item_cursor_offset = {0, 0},
410+ p2_teammenu_item_cursor_facing = 1,
411+ p2_teammenu_item_cursor_scale = {1.0, 1.0},
412+ --p2_teammenu_value_icon_anim = nil,
413+ p2_teammenu_value_icon_spr = {},
414+ p2_teammenu_value_icon_offset = {0, 0},
415+ p2_teammenu_value_icon_facing = 1,
416+ p2_teammenu_value_icon_scale = {1.0, 1.0},
417+ --p2_teammenu_value_empty_icon_anim = nil,
418+ p2_teammenu_value_empty_icon_spr = {},
419+ p2_teammenu_value_empty_icon_offset = {0, 0},
420+ p2_teammenu_value_empty_icon_facing = 1,
421+ p2_teammenu_value_empty_icon_scale = {1.0, 1.0},
422+ p2_teammenu_value_spacing = {-6, 0},
423+ },
424+ selectbgdef =
425+ {
426+ spr = '',
427+ bgclearcolor = {0, 0, 0},
428+ bg = {},
429+ timer = 0, --Ikemen feature
430+ },
431+ vs_screen =
432+ {
433+ fadein_time = 15,
434+ fadein_col = {0, 0, 0}, --Ikemen feature
435+ fadeout_time = 15,
436+ fadeout_col = {0, 0, 0}, --Ikemen feature
437+ time = 150,
438+ time_order = 60, --Ikemen feature
439+ match_text = 'Match %i',
440+ match_offset = {159, 12},
441+ match_font = {'font/jg.fnt', 0, 0, nil, nil, nil},
442+ match_font_scale = {1.0, 1.0},
443+ p1_pos = {0, 0},
444+ p1_spr = {9000, 1},
445+ p1_offset = {0, 0},
446+ p1_facing = 1,
447+ p1_scale = {1.0, 1.0},
448+ p1_window = {0, 0, 0, 0},
449+ p1_spacing = {0, 0}, --Ikemen feature
450+ p1_num = 1, --Ikemen feature
451+ p2_pos = {0, 0},
452+ p2_spr = {9000, 1},
453+ p2_offset = {0, 0},
454+ p2_facing = -1,
455+ p2_scale = {1.0, 1.0},
456+ p2_window = {0, 0, 0, 0},
457+ p2_spacing = {0, 0}, --Ikemen feature
458+ p2_num = 1, --Ikemen feature
459+ p1_name_pos = {0, 0},
460+ p1_name_offset = {0, 0},
461+ p1_name_font = {'font/jg.fnt', 0, 0, nil, nil, nil},
462+ p1_name_font_scale = {1.0, 1.0},
463+ p1_name_spacing = {0, 14},
464+ p2_name_pos = {0, 0},
465+ p2_name_offset = {0, 0},
466+ p2_name_font = {'font/jg.fnt', 0, 0, nil, nil, nil},
467+ p2_name_font_scale = {1.0, 1.0},
468+ p2_name_spacing = {0, 14},
469+ --p1_name_active_font = {'font/jg.fnt', 0, 0, nil, nil, nil}, --Ikemen feature
470+ --p1_name_active_font_scale = {1.0, 1.0}, --Ikemen feature
471+ --p2_name_active_font = {'font/jg.fnt', 0, 0, nil, nil, nil}, --Ikemen feature
472+ --p2_name_active_font_scale = {1.0, 1.0}, --Ikemen feature
473+ p1_cursor_move_snd = {100, 0}, --Ikemen feature
474+ p1_cursor_done_snd = {100, 1}, --Ikemen feature
475+ p2_cursor_move_snd = {100, 0}, --Ikemen feature
476+ p2_cursor_done_snd = {100, 1}, --Ikemen feature
477+ },
478+ versusbgdef =
479+ {
480+ spr = '',
481+ bgclearcolor = {0, 0, 0},
482+ bg = {},
483+ timer = 0, --Ikemen feature
484+ },
485+ demo_mode =
486+ {
487+ enabled = 1, --not supported yet
488+ select_enabled = 0, --not supported yet
489+ vsscreen_enabled = 0, --not supported yet
490+ title_waittime = 600, --not supported yet
491+ fight_endtime = 1500, --not supported yet
492+ fight_playbgm = 0, --not supported yet
493+ fight_stopbgm = 1, --not supported yet
494+ fight_bars_display = 0, --not supported yet
495+ intro_waitcycles = 1, --not supported yet
496+ debuginfo = 0, --not supported yet
497+ },
498+ continue_screen =
499+ {
500+ external_gameover = 0, --Ikemen feature
501+ fadein_time = 30, --Ikemen feature
502+ fadein_col = {0, 0, 0}, --Ikemen feature
503+ fadeout_time = 30, --Ikemen feature
504+ fadeout_col = {0, 0, 0}, --Ikemen feature
505+ endtime = 1593, --Ikemen feature
506+ continue_starttime = 0, --Ikemen feature
507+ continue_anim = 9000, --Ikemen feature
508+ continue_offset = {0, 0}, --Ikemen feature
509+ continue_scale = {1.0, 1.0}, --Ikemen feature
510+ continue_skipstart = 71, --Ikemen feature
511+ continue_9_skiptime = 135, --Ikemen feature
512+ continue_9_snd = {0, 9}, --Ikemen feature
513+ continue_8_skiptime = 262, --Ikemen feature
514+ continue_8_snd = {0, 8}, --Ikemen feature
515+ continue_7_skiptime = 389, --Ikemen feature
516+ continue_7_snd = {0, 7}, --Ikemen feature
517+ continue_6_skiptime = 516, --Ikemen feature
518+ continue_6_snd = {0, 6}, --Ikemen feature
519+ continue_5_skiptime = 643, --Ikemen feature
520+ continue_5_snd = {0, 5}, --Ikemen feature
521+ continue_4_skiptime = 770, --Ikemen feature
522+ continue_4_snd = {0, 4}, --Ikemen feature
523+ continue_3_skiptime = 897, --Ikemen feature
524+ continue_3_snd = {0, 3}, --Ikemen feature
525+ continue_2_skiptime = 1024, --Ikemen feature
526+ continue_2_snd = {0, 2}, --Ikemen feature
527+ continue_1_skiptime = 1151, --Ikemen feature
528+ continue_1_snd = {0, 1}, --Ikemen feature
529+ continue_0_skiptime = 1278, --Ikemen feature
530+ continue_0_snd = {0, 0}, --Ikemen feature
531+ continue_end_skiptime = 1366, --Ikemen feature
532+ continue_end_snd = {1, 0}, --Ikemen feature
533+ credits_text = 'Credits: %i', --Ikemen feature
534+ credits_offset = {20, 30}, --Ikemen feature
535+ credits_font = {'font/jg.fnt', 0, 1, nil, nil, nil}, --Ikemen feature
536+ credits_font_scale = {1.0, 1.0}, --Ikemen feature
537+ --enabled = 1, --not used in Ikemen
538+ --pos = {160, 240}, --not used in Ikemen
539+ --continue_text = 'CONTINUE?', --not used in Ikemen
540+ --continue_font = {'font/f-4x6.fnt', 0, 0, nil, nil, nil}, --not used in Ikemen
541+ --continue_font_scale = {1.0, 1.0}, --not used in Ikemen
542+ --continue_offset = {0, 0}, --not used in Ikemen
543+ --yes_text = 'YES', --not used in Ikemen
544+ --yes_font = {'font/f-4x6.fnt', 0, 0, 128, 128, 128}, --not used in Ikemen
545+ --yes_font_scale = {1.0, 1.0}, --not used in Ikemen
546+ --yes_offset = {-80, 60}, --not used in Ikemen
547+ --yes_active_text = 'YES', --not used in Ikemen
548+ --yes_active_font = {'font/f-4x6.fnt', 3, 0, nil, nil, nil}, --not used in Ikemen
549+ --yes_active_font_scale = {1.0, 1.0}, --not used in Ikemen
550+ --yes_active_offset = {-80, 60}, --not used in Ikemen
551+ --no_text = 'NO', --not used in Ikemen
552+ --no_font = {'font/f-4x6.fnt', 0, 0, 128, 128, 128}, --not used in Ikemen
553+ --no_font_scale = {1.0, 1.0}, --not used in Ikemen
554+ --no_offset = {80, 60}, --not used in Ikemen
555+ --no_active_text = 'NO', --not used in Ikemen
556+ --no_active_font = {'font/f-4x6.fnt', 3, 0, nil, nil, nil}, --not used in Ikemen
557+ --no_active_font_scale = {1.0, 1.0}, --not used in Ikemen
558+ --no_active_offset = {80, 60}, --not used in Ikemen
559+ },
560+ continuebgdef =
561+ {
562+ spr = 'data/continue.sff', --Ikemen feature
563+ bgclearcolor = {0, 0, 0}, --Ikemen feature
564+ bg = {},
565+ timer = 0, --Ikemen feature
566+ },
567+ game_over_screen =
568+ {
569+ enabled = 1,
570+ storyboard = '',
571+ },
572+ victory_screen =
573+ {
574+ enabled = 1,
575+ time = 300,
576+ fadein_time = 8,
577+ fadein_col = {0, 0, 0}, --Ikemen feature
578+ fadeout_time = 15,
579+ fadeout_col = {0, 0, 0}, --Ikemen feature
580+ p1_spr = {9000, 2},
581+ p1_offset = {100, 20},
582+ p1_facing = 1,
583+ p1_scale = {1.0, 1.0},
584+ p1_window = {0, 0, 319, 160},
585+ p1_name_offset = {20, 180},
586+ p1_name_font = {'font/jg.fnt', 0, 1, nil, nil, nil},
587+ p1_name_font_scale = {1.0, 1.0},
588+ p2_display = 0, --Ikemen feature
589+ p2_spr = {9000, 2}, --Ikemen feature
590+ p2_offset = {100, 20}, --Ikemen feature
591+ p2_facing = -1, --Ikemen feature
592+ p2_scale = {1.0, 1.0}, --Ikemen feature
593+ p2_window = {0, 0, 319, 160}, --Ikemen feature
594+ p2_name_offset = {20, 180}, --Ikemen feature
595+ p2_name_font = {'font/jg.fnt', 0, 1, nil, nil, nil}, --Ikemen feature
596+ p2_name_font_scale = {1.0, 1.0},
597+ winquote_text = 'Winner!',
598+ winquote_offset = {20, 192},
599+ winquote_font = {'font/f-6x9.fnt', 0, 1, nil, nil, nil},
600+ winquote_font_scale = {1.0, 1.0},
601+ winquote_spacing = {0, 15}, --Ikemen feature
602+ winquote_delay = 2, --Ikemen feature
603+ winquote_length = 50, --Ikemen feature
604+ winquote_window = {18, 171, 301, 228},
605+ --winquote_textwrap = 'w', --not used in Ikemen
606+ },
607+ victorybgdef =
608+ {
609+ spr = '',
610+ bgclearcolor = {0, 0, 0},
611+ bg = {},
612+ timer = 0, --Ikemen feature
613+ },
614+ win_screen =
615+ {
616+ enabled = 1,
617+ fadein_time = 32,
618+ fadein_col = {0, 0, 0}, --Ikemen feature
619+ fadeout_time = 64,
620+ fadeout_col = {0, 0, 0}, --Ikemen feature
621+ pose_time = 300,
622+ wintext_text = 'Congratulations!',
623+ wintext_offset = {159, 70},
624+ wintext_font = {'font/f-6x9.fnt', 0, 0, nil, nil, nil},
625+ wintext_font_scale = {1.0, 1.0},
626+ wintext_displaytime = -1,
627+ wintext_layerno = 2,
628+ },
629+ default_ending =
630+ {
631+ enabled = 0,
632+ storyboard = '',
633+ },
634+ end_credits =
635+ {
636+ enabled = 0,
637+ storyboard = '',
638+ },
639+ survival_results_screen =
640+ {
641+ enabled = 1,
642+ fadein_time = 32,
643+ fadein_col = {0, 0, 0}, --Ikemen feature
644+ fadeout_time = 64,
645+ fadeout_col = {0, 0, 0}, --Ikemen feature
646+ show_time = 300,
647+ winstext_text = 'Rounds survived: %i',
648+ winstext_offset = {159, 70},
649+ winstext_font = {'font/jg.fnt', 0, 0, nil, nil, nil},
650+ winstext_font_scale = {1.0, 1.0},
651+ winstext_spacing = {0, 15}, --Ikemen feature
652+ winstext_displaytime = -1,
653+ winstext_layerno = 2,
654+ roundstowin = 5,
655+ },
656+ vs100kumite_results_screen =
657+ {
658+ enabled = 1, --Ikemen feature
659+ fadein_time = 32, --Ikemen feature
660+ fadein_col = {0, 0, 0}, --Ikemen feature
661+ fadeout_time = 64, --Ikemen feature
662+ fadeout_col = {0, 0, 0}, --Ikemen feature
663+ show_time = 300, --Ikemen feature
664+ winstext_text = 'Wins: %i\nLoses: %i', --Ikemen feature
665+ winstext_offset = {159, 70}, --Ikemen feature
666+ winstext_font = {'font/jg.fnt', 0, 0, nil, nil, nil}, --Ikemen feature
667+ winstext_font_scale = {1.0, 1.0}, --Ikemen feature
668+ winstext_spacing = {0, 15}, --Ikemen feature
669+ winstext_displaytime = -1, --Ikemen feature
670+ winstext_layerno = 2, --Ikemen feature
671+ roundstowin = 51, --Ikemen feature
672+ },
673+ resultsbgdef =
674+ {
675+ spr = '', --Ikemen feature
676+ bgclearcolor = {0, 0, 0}, --Ikemen feature (disabled to not cover game screen)
677+ bg = {},
678+ timer = 0, --Ikemen feature
679+ },
680+ option_info =
681+ {
682+ fadein_time = 10, --check winmugen values
683+ fadein_col = {0, 0, 0}, --Ikemen feature
684+ fadeout_time = 10, --check winmugen values
685+ fadeout_col = {0, 0, 0}, --Ikemen feature
686+ title_offset = {159, 19},
687+ title_font = {'font/f-6x9.fnt', 0, 0, nil, nil, nil},
688+ title_font_scale = {1.0, 1.0},
689+ title_text_main = 'OPTIONS', --Ikemen feature
690+ title_text_arcade = 'ARCADE SETTINGS', --Ikemen feature
691+ title_text_gameplay = 'GAMEPLAY SETTINGS', --Ikemen feature
692+ title_text_advgameplay = 'ADVANCED GAMEPLAY SETTINGS', --Ikemen feature
693+ title_text_video = 'VIDEO SETTINGS', --Ikemen feature
694+ title_text_audio = 'AUDIO SETTINGS', --Ikemen feature
695+ title_text_engine = 'ENGINE SETTINGS', --Ikemen feature
696+ title_text_res = 'RESOLUTION SETTINGS', --Ikemen feature
697+ title_text_input = 'INPUT SETTINGS', --Ikemen feature
698+ title_text_key = 'KEY SETTINGS', --Ikemen feature
699+ menu_pos = {85, 33}, --Ikemen feature
700+ menu_item_font = {'font/f-6x9.fnt', 7, 1, nil, nil, nil}, --Ikemen feature
701+ menu_item_font_scale = {1.0, 1.0}, --Ikemen feature
702+ menu_item_active_font = {'font/f-6x9.fnt', 0, 1, nil, nil, nil}, --Ikemen feature
703+ menu_item_active_font_scale = {1.0, 1.0}, --Ikemen feature
704+ menu_item_value_font = {'font/f-6x9.fnt', 7, -1, nil, nil, nil}, --Ikemen feature
705+ menu_item_value_font_scale = {1.0, 1.0}, --Ikemen feature
706+ menu_item_value_active_font = {'font/f-6x9.fnt', 0, -1, nil, nil, nil}, --Ikemen feature
707+ menu_item_value_active_font_scale = {1.0, 1.0}, --Ikemen feature
708+ menu_item_value_conflict_font = {'font/f-6x9.fnt', 1, -1, nil, nil, nil}, --Ikemen feature
709+ menu_item_value_conflict_font_scale = {1.0, 1.0}, --Ikemen feature
710+ menu_item_spacing = {150, 13}, --Ikemen feature
711+ menu_window_visibleitems = 16, --Ikemen feature
712+ menu_boxcursor_visible = 1, --Ikemen feature
713+ menu_boxcursor_coords = {-5, -9, 154, 3}, --Ikemen feature
714+ menu_boxbackground_visible = 1, --Ikemen feature
715+ menu_boxbackground_alpha = {20, 100}, --Ikemen feature
716+ menu_itemname_main_arcade = 'Arcade Settings', --Ikemen feature
717+ menu_itemname_main_gameplay = 'Gameplay Settings', --Ikemen feature
718+ menu_itemname_main_engine = "Engine Settings", --Ikemen feature
719+ menu_itemname_main_video = 'Video Settings', --Ikemen feature
720+ menu_itemname_main_audio = 'Audio Settings', --Ikemen feature
721+ menu_itemname_main_input = 'Input Settings', --Ikemen feature
722+ menu_itemname_main_port = 'Port Change', --Ikemen feature
723+ menu_itemname_main_default = 'Default Values', --Ikemen feature
724+ menu_itemname_main_back = 'Return Without Saving', --Ikemen feature
725+ menu_itemname_arcade_roundstowin = 'Rounds to Win', --Ikemen feature
726+ menu_itemname_arcade_roundtime = 'Round Time', --Ikemen feature
727+ menu_itemname_arcade_difficulty = 'Difficulty level', --Ikemen feature
728+ menu_itemname_arcade_credits = 'Credits', --Ikemen feature
729+ menu_itemname_arcade_charchange = 'Char change at Continue', --Ikemen feature
730+ menu_itemname_arcade_airamping = 'AI ramping', --Ikemen feature
731+ menu_itemname_arcade_back = 'Back', --Ikemen feature
732+ menu_itemname_gameplay_lifemul = 'Life', --Ikemen feature
733+ menu_itemname_gameplay_autoguard = 'Auto-Guard', --Ikemen feature
734+ menu_itemname_gameplay_attackpowermul = 'Attack.LifeToPowerMul', --Ikemen feature
735+ menu_itemname_gameplay_gethitpowermul = 'GetHit.LifeToPowerMul', --Ikemen feature
736+ menu_itemname_gameplay_superdefencemul = 'Super.TargetDefenceMul', --Ikemen feature
737+ menu_itemname_gameplay_team1vs2life = '1P Vs Team Life', --Ikemen feature
738+ menu_itemname_gameplay_turnsrecoveryrate = 'Turns HP Recovery', --Ikemen feature
739+ menu_itemname_gameplay_teampowershare = 'Team Power Share', --Ikemen feature
740+ menu_itemname_gameplay_teamlifeshare = 'Team Life Share', --Ikemen feature
741+ menu_itemname_gameplay_singlemode = 'Single Mode', --Ikemen feature
742+ menu_itemname_gameplay_numturns = 'Turns Limit', --Ikemen feature
743+ menu_itemname_gameplay_numsimul = 'Simul Limit', --Ikemen feature
744+ menu_itemname_gameplay_numtag = 'Tag Limit', --Ikemen features
745+ menu_itemname_gameplay_simulmode = 'Legacy Tag Mode', --Ikemen feature
746+ menu_itemname_gameplay_simulmode_simul = 'Disabled', --Ikemen feature
747+ menu_itemname_gameplay_simulmode_tag = 'Enabled', --Ikemen feature
748+ menu_itemname_gameplay_advanced = 'Advanced Settings', --Ikemen feature
749+ menu_itemname_gameplay_back = 'Back', --Ikemen feature
750+ menu_itemname_video_resolution = 'Resolution', --Ikemen feature
751+ menu_itemname_video_fullscreen = 'Fullscreen', --Ikemen feature
752+ menu_itemname_video_msaa = 'MSAA', --Ikemen feature
753+ menu_itemname_video_helpermax = 'HelperMax', --Ikemen feature
754+ menu_itemname_video_playerprojectilemax = 'PlayerProjectileMax', --Ikemen feature
755+ menu_itemname_video_explodmax = 'ExplodMax', --Ikemen feature
756+ menu_itemname_video_afterimagemax = 'AfterImageMax', --Ikemen feature
757+ menu_itemname_video_zoomactive = 'Zoom Active', --Ikemen feature
758+ menu_itemname_video_maxzoomout = 'Default Max Zoom Out', --Ikemen feature
759+ menu_itemname_video_maxzoomin = 'Default Max Zoom In', --Ikemen feature
760+ menu_itemname_video_zoomspeed = 'Default Zoom Speed', --Ikemen feature
761+ menu_itemname_video_lifebarfontscale = 'Default Lifebar Font Scale', --Ikemen feature
762+ menu_itemname_video_aipalette = 'AI Palette', --Ikemen feature
763+ menu_itemname_video_aipalette_random = 'Random', --Ikemen feature
764+ menu_itemname_video_aipalette_default = 'Default', --Ikemen feature
765+ menu_itemname_video_back = 'Back', --Ikemen feature
766+ menu_itemname_res_320x240 = '320x240 (4:3 QVGA)', --Ikemen feature
767+ menu_itemname_res_640x480 = '640x480 (4:3 VGA)', --Ikemen feature
768+ menu_itemname_res_1280x960 = '1280x960 (4:3 Quad-VGA)', --Ikemen feature
769+ menu_itemname_res_1600x1200 = '1600x1200 (4:3 UXGA)', --Ikemen feature
770+ menu_itemname_res_960x720 = '960x720 (4:3 HD)', --Ikemen feature
771+ menu_itemname_res_1200x900 = '1200x900 (4:3 HD+)', --Ikemen feature
772+ menu_itemname_res_1440x1080 = '1440x1080 (4:3 FHD)', --Ikemen feature
773+ menu_itemname_res_1280x720 = '1280x720 (16:9 HD)', --Ikemen feature
774+ menu_itemname_res_1600x900 = '1600x900 (16:9 HD+)', --Ikemen feature
775+ menu_itemname_res_1920x1080 = '1920x1080 (16:9 FHD)', --Ikemen feature
776+ menu_itemname_res_2560x1440 = '2560x1440 (16:9 2K)', --Ikemen feature
777+ menu_itemname_res_3840x2160 = '3840x2160 (16:9 4K)', --Ikemen feature
778+ menu_itemname_res_custom = 'Custom', --Ikemen feature
779+ menu_itemname_res_back = 'Back', --Ikemen feature
780+ menu_itemname_input_p1keyboard = 'P1 Keyboard', --Ikemen feature
781+ menu_itemname_input_p1gamepad = 'P1 Gamepad', --Ikemen feature
782+ menu_itemname_input_p2keyboard = 'P2 Keyboard', --Ikemen feature
783+ menu_itemname_input_p2gamepad = 'P2 Gamepad', --Ikemen feature
784+ menu_itemname_input_default = 'Default Values', --Ikemen feature
785+ menu_itemname_input_back = 'Back', --Ikemen feature
786+ menu_itemname_key_up = 'Up', --Ikemen feature
787+ menu_itemname_key_down = 'Down', --Ikemen feature
788+ menu_itemname_key_left = 'Left', --Ikemen feature
789+ menu_itemname_key_right = 'Right', --Ikemen feature
790+ menu_itemname_key_a = 'A', --Ikemen feature
791+ menu_itemname_key_b = 'B', --Ikemen feature
792+ menu_itemname_key_c = 'C', --Ikemen feature
793+ menu_itemname_key_x = 'X', --Ikemen feature
794+ menu_itemname_key_y = 'Y', --Ikemen feature
795+ menu_itemname_key_z = 'Z', --Ikemen feature
796+ menu_itemname_key_start = 'Start', --Ikemen feature
797+ menu_itemname_key_v = 'D', --Ikemen feature
798+ menu_itemname_key_w = 'W', --Ikemen feature
799+ menu_itemname_key_back = 'Back', --Ikemen feature
800+ menu_itemname_yes = 'Yes', --Ikemen feature
801+ menu_itemname_no = 'No', --Ikemen feature
802+ menu_itemname_main_save = 'Save and Return', --Ikemen feature
803+ menu_itemname_enabled = 'Enabled', --Ikemen feature
804+ menu_itemname_disabled = 'Disabled', --Ikemen feature
805+ menu_itemname_audio_mastervolume = 'Master Volume', --Ikemen feature
806+ menu_itemname_audio_sfxvolume = 'SFX Volume', --Ikemen feature
807+ menu_itemname_audio_bgmvolume = 'BGM Volume', --Ikemen feature
808+ menu_itemname_audio_audioducking = 'Audio Ducking', --Ikemen feature
809+ menu_itemname_engine_quicklaunch = 'Quick Launch', --Ikemen feature
810+ menu_itemname_engine_allowdebugkeys = 'Debug Keys', --Ikemen feature
811+ input_text_port = 'Type in Host Port, e.g. 7500.\nPress ENTER to accept.\nPress ESC to cancel.', --Ikemen feature
812+ input_text_reswidth = 'Type in screen width.\nPress ENTER to accept.\nPress ESC to cancel.', --Ikemen feature
813+ input_text_resheight = 'Type in screen height.\nPress ENTER to accept.\nPress ESC to cancel.', --Ikemen feature
814+ input_text_key = 'Press a key to assign to entry.\nPress ESC to cancel.', --Ikemen feature
815+ cursor_move_snd = {100, 0},
816+ cursor_done_snd = {100, 1},
817+ cancel_snd = {100, 2},
818+ },
819+ optionbgdef =
820+ {
821+ spr = '',
822+ bgclearcolor = {0, 0, 0},
823+ bg = {},
824+ timer = 0, --Ikemen feature
825+ },
826+ tournament_info =
827+ {
828+ fadein_time = 15, --Ikemen feature
829+ fadein_col = {0, 0, 0}, --Ikemen feature
830+ fadeout_time = 15, --Ikemen feature
831+ fadeout_col = {0, 0, 0}, --Ikemen feature
832+ },
833+ tournamentbgdef =
834+ {
835+ spr = 'data/tournament.sff', --Ikemen feature
836+ bgclearcolor = {0, 0, 0}, --Ikemen feature
837+ bg = {}, --Ikemen feature
838+ timer = 0, --Ikemen feature
839+ },
840+ warning_info =
841+ {
842+ title = 'WARNING', --Ikemen feature
843+ title_pos = {159, 19}, --Ikemen feature
844+ title_font = {'font/f-6x9.fnt', 0, 0, nil, nil, nil}, --Ikemen feature
845+ title_font_scale = {1.0, 1.0}, --Ikemen feature
846+ text_stages = 'No stages in select.def available for random selection.\nPress any key to exit the program.', --Ikemen feature
847+ text_order = "No characters in select.def correspond to 'maxmatches'\nsettings. Check [Characters] section and 'order' parameters.\nPress any key to exit the program.", --Ikemen feature
848+ text_training = "Training character ('chars/Training/Training.def') not found.\nPress any key to exit the program.", --Ikemen feature
849+ text_reload = 'Some selected options require Ikemen to be restarted.\nPress any key to exit the program.', --Ikemen feature
850+ text_res = 'Non 4:3 resolutions require stages coded for different\naspect ratio. Change it back to 4:3 if stages look off.', --Ikemen feature
851+ text_pos = {25, 33}, --Ikemen feature
852+ text_font = {'font/f-6x9.fnt', 0, 1, nil, nil, nil}, --Ikemen feature
853+ text_font_scale = {1.0, 1.0}, --Ikemen feature
854+ text_spacing = {0, 13}, --Ikemen feature
855+ background_alpha = {20, 100}, --Ikemen feature
856+ },
857+ anim =
858+ {
859+ [9000] = { --Ikemen feature
860+ '2,0, -60,8, 1', --1 (count 9 start - initial animation)
861+ '2,1, -60,8, 1', --2
862+ '2,2, -60,8, 1', --3
863+ '2,3, -60,8, 3', --6
864+ '2,4, -60,8, 3', --9
865+ '2,5, -60,8, 1', --10
866+ '2,6, -60,8, 3', --13
867+ '2,7, -60,8, 2', --15
868+ '2,8, -60,8, 2', --17
869+ '2,9, -60,8, 2', --19
870+ '2,10, -60,8, 1', --20
871+ '2,11, -60,8, 5', --25
872+ '2,12, -60,8, 5', --30
873+ '2,13, -60,8, 1', --31
874+ '2,14, -60,8, 1', --32
875+ '2,15, -60,8, 3', --35
876+ '2,16, -60,8, 3', --38
877+ '2,17, -60,8, 1', --39
878+ '2,18, -60,8, 5', --44
879+ '2,19, -60,8, 1', --45
880+ '2,20, -60,8, 4', --49
881+ '2,21, -60,8, 1', --50
882+ '2,22, -60,8, 1', --51
883+ '2,23, -60,8, 1', --52
884+ '2,24, -60,8, 2', --54
885+ '2,25, -60,8, 1', --55
886+ '2,26, -60,8, 5', --60
887+ '2,27, -60,8, 5', --65
888+ '2,28, -60,8, 1', --66
889+ '2,29, -60,8, 3', --69
890+ '2,30, -60,8, 2', --71
891+ '3,0, -60,8, 6', --77 (count 9 - actual counter)
892+ '3,1, -60,8, 54', --131
893+ '3,2, -60,8, 4', --135
894+ '3,3, -60,8, 4', --139
895+ '3,4, -60,8, 4', --143
896+ '3,5, -60,8, 4', --147
897+ '3,6, -60,8, 44', --191
898+ '3,7, -60,8, 9', --200
899+ '3,8, -60,8, 4', --204
900+ '3,9, -60,8, 3', --207
901+ '3,10, -60,8, 2', --209
902+ '3,11, -60,8, 2', --211
903+ '3,12, -60,8, 1', --212
904+ '3,13, -60,8, 2', --214
905+ '3,14, -60,8, 1', --215
906+ '3,15, -60,8, 1', --216
907+ '3,16, -60,8, 2', --218
908+ '3,17, -60,8, 1', --219
909+ '3,18, -60,8, 1', --220
910+ '3,19, -60,8, 1', --221 (count 9 end)
911+ '4,0, -60,8, 1', --222 (count 8 start)
912+ '4,1, -60,8, 2', --224
913+ '4,2, -60,8, 2', --226
914+ '4,3, -60,8, 2', --228
915+ '4,4, -60,8, 2', --230
916+ '4,5, -60,8, 2', --232
917+ '4,6, -60,8, 2', --234
918+ '4,7, -60,8, 1', --235
919+ '4,8, -60,8, 2', --237
920+ '4,9, -60,8, 3', --240
921+ '4,10, -60,8, 4', --244
922+ '4,11, -60,8, 9', --253
923+ '4,12, -60,8, 5', --258
924+ '4,13, -60,8, 4', --262
925+ '4,14, -60,8, 4', --266
926+ '4,15, -60,8, 4', --270
927+ '4,16, -60,8, 4', --274
928+ '4,17, -60,8, 44', --318
929+ '4,18, -60,8, 9', --327
930+ '4,19, -60,8, 4', --331
931+ '4,20, -60,8, 3', --334
932+ '4,21, -60,8, 2', --336
933+ '4,22, -60,8, 2', --338
934+ '4,23, -60,8, 1', --339
935+ '4,24, -60,8, 2', --341
936+ '4,25, -60,8, 1', --342
937+ '4,26, -60,8, 1', --343
938+ '4,27, -60,8, 2', --345
939+ '4,28, -60,8, 1', --346
940+ '4,29, -60,8, 1', --347
941+ '4,30, -60,8, 1', --348 (count 8 end)
942+ '5,0, -60,8, 1', --349 (count 7 start)
943+ '5,1, -60,8, 2', --351
944+ '5,2, -60,8, 2', --353
945+ '5,3, -60,8, 2', --355
946+ '5,4, -60,8, 2', --357
947+ '5,5, -60,8, 2', --359
948+ '5,6, -60,8, 2', --361
949+ '5,7, -60,8, 1', --362
950+ '5,8, -60,8, 2', --364
951+ '5,9, -60,8, 3', --367
952+ '5,10, -60,8, 4', --371
953+ '5,11, -60,8, 9', --380
954+ '5,12, -60,8, 5', --385
955+ '5,13, -60,8, 4', --389
956+ '5,14, -60,8, 4', --393
957+ '5,15, -60,8, 4', --397
958+ '5,16, -60,8, 4', --401
959+ '5,17, -60,8, 44', --445
960+ '5,18, -60,8, 9', --454
961+ '5,19, -60,8, 4', --458
962+ '5,20, -60,8, 3', --461
963+ '5,21, -60,8, 2', --463
964+ '5,22, -60,8, 2', --465
965+ '5,23, -60,8, 1', --466
966+ '5,24, -60,8, 2', --468
967+ '5,25, -60,8, 1', --469
968+ '5,26, -60,8, 1', --470
969+ '5,27, -60,8, 2', --472
970+ '5,28, -60,8, 1', --473
971+ '5,29, -60,8, 1', --474
972+ '5,30, -60,8, 1', --475 (count 7 end)
973+ '6,0, -60,8, 1', --476 (count 6 start)
974+ '6,1, -60,8, 2', --478
975+ '6,2, -60,8, 2', --480
976+ '6,3, -60,8, 2', --482
977+ '6,4, -60,8, 2', --484
978+ '6,5, -60,8, 2', --486
979+ '6,6, -60,8, 2', --488
980+ '6,7, -60,8, 1', --489
981+ '6,8, -60,8, 2', --491
982+ '6,9, -60,8, 3', --494
983+ '6,10, -60,8, 4', --498
984+ '6,11, -60,8, 9', --507
985+ '6,12, -60,8, 5', --512
986+ '6,13, -60,8, 4', --516
987+ '6,14, -60,8, 4', --520
988+ '6,15, -60,8, 4', --524
989+ '6,16, -60,8, 4', --528
990+ '6,17, -60,8, 44', --572
991+ '6,18, -60,8, 9', --581
992+ '6,19, -60,8, 4', --585
993+ '6,20, -60,8, 3', --588
994+ '6,21, -60,8, 2', --590
995+ '6,22, -60,8, 2', --592
996+ '6,23, -60,8, 1', --593
997+ '6,24, -60,8, 2', --595
998+ '6,25, -60,8, 1', --596
999+ '6,26, -60,8, 1', --597
1000+ '6,27, -60,8, 2', --599
1001+ '6,28, -60,8, 1', --600
1002+ '6,29, -60,8, 1', --601
1003+ '6,30, -60,8, 1', --602 (count 6 end)
1004+ '7,0, -60,8, 1', --603 (count 5 start)
1005+ '7,1, -60,8, 2', --605
1006+ '7,2, -60,8, 2', --607
1007+ '7,3, -60,8, 2', --609
1008+ '7,4, -60,8, 2', --611
1009+ '7,5, -60,8, 2', --613
1010+ '7,6, -60,8, 2', --615
1011+ '7,7, -60,8, 1', --616
1012+ '7,8, -60,8, 2', --618
1013+ '7,9, -60,8, 3', --621
1014+ '7,10, -60,8, 4', --625
1015+ '7,11, -60,8, 9', --634
1016+ '7,12, -60,8, 5', --639
1017+ '7,13, -60,8, 4', --643
1018+ '7,14, -60,8, 4', --647
1019+ '7,15, -60,8, 4', --651
1020+ '7,16, -60,8, 4', --655
1021+ '7,17, -60,8, 44', --699
1022+ '7,18, -60,8, 9', --708
1023+ '7,19, -60,8, 4', --712
1024+ '7,20, -60,8, 3', --715
1025+ '7,21, -60,8, 2', --717
1026+ '7,22, -60,8, 2', --719
1027+ '7,23, -60,8, 1', --720
1028+ '7,24, -60,8, 2', --722
1029+ '7,25, -60,8, 1', --723
1030+ '7,26, -60,8, 1', --724
1031+ '7,27, -60,8, 2', --726
1032+ '7,28, -60,8, 1', --727
1033+ '7,29, -60,8, 1', --728
1034+ '7,30, -60,8, 1', --729 (count 5 end)
1035+ '8,0, -60,8, 1', --730 (count 4 start)
1036+ '8,1, -60,8, 2', --732
1037+ '8,2, -60,8, 2', --734
1038+ '8,3, -60,8, 2', --736
1039+ '8,4, -60,8, 2', --738
1040+ '8,5, -60,8, 2', --740
1041+ '8,6, -60,8, 2', --742
1042+ '8,7, -60,8, 1', --743
1043+ '8,8, -60,8, 2', --745
1044+ '8,9, -60,8, 3', --748
1045+ '8,10, -60,8, 4', --752
1046+ '8,11, -60,8, 9', --761
1047+ '8,12, -60,8, 5', --766
1048+ '8,13, -60,8, 4', --770
1049+ '8,14, -60,8, 4', --774
1050+ '8,15, -60,8, 4', --778
1051+ '8,16, -60,8, 4', --782
1052+ '8,17, -60,8, 44', --826
1053+ '8,18, -60,8, 9', --835
1054+ '8,19, -60,8, 4', --839
1055+ '8,20, -60,8, 3', --842
1056+ '8,21, -60,8, 2', --844
1057+ '8,22, -60,8, 2', --846
1058+ '8,23, -60,8, 1', --847
1059+ '8,24, -60,8, 2', --849
1060+ '8,25, -60,8, 1', --850
1061+ '8,26, -60,8, 1', --851
1062+ '8,27, -60,8, 2', --853
1063+ '8,28, -60,8, 1', --854
1064+ '8,29, -60,8, 1', --855
1065+ '8,30, -60,8, 1', --856 (count 4 end)
1066+ '9,0, -60,8, 1', --857 (count 3 start)
1067+ '9,1, -60,8, 2', --859
1068+ '9,2, -60,8, 2', --861
1069+ '9,3, -60,8, 2', --863
1070+ '9,4, -60,8, 2', --865
1071+ '9,5, -60,8, 2', --867
1072+ '9,6, -60,8, 2', --869
1073+ '9,7, -60,8, 1', --870
1074+ '9,8, -60,8, 2', --872
1075+ '9,9, -60,8, 3', --875
1076+ '9,10, -60,8, 4', --879
1077+ '9,11, -60,8, 9', --888
1078+ '9,12, -60,8, 5', --893
1079+ '9,13, -60,8, 4', --897
1080+ '9,14, -60,8, 4', --901
1081+ '9,15, -60,8, 4', --905
1082+ '9,16, -60,8, 4', --909
1083+ '9,17, -60,8, 44', --953
1084+ '9,18, -60,8, 9', --962
1085+ '9,19, -60,8, 4', --966
1086+ '9,20, -60,8, 3', --969
1087+ '9,21, -60,8, 2', --971
1088+ '9,22, -60,8, 2', --973
1089+ '9,23, -60,8, 1', --974
1090+ '9,24, -60,8, 2', --976
1091+ '9,25, -60,8, 1', --977
1092+ '9,26, -60,8, 1', --978
1093+ '9,27, -60,8, 2', --980
1094+ '9,28, -60,8, 1', --981
1095+ '9,29, -60,8, 1', --982
1096+ '9,30, -60,8, 1', --983 (count 3 end)
1097+ '1-60,8, -60,8, 1', --984 (count 2 start)
1098+ '10,1, -60,8, 2', --986
1099+ '10,2, -60,8, 2', --988
1100+ '10,3, -60,8, 2', --990
1101+ '10,4, -60,8, 2', --992
1102+ '10,5, -60,8, 2', --994
1103+ '10,6, -60,8, 2', --996
1104+ '10,7, -60,8, 1', --997
1105+ '10,8, -60,8, 2', --999
1106+ '10,9, -60,8, 3', --1002
1107+ '10,10, -60,8, 4', --1006
1108+ '10,11, -60,8, 9', --1015
1109+ '10,12, -60,8, 5', --1020
1110+ '10,13, -60,8, 4', --1024
1111+ '10,14, -60,8, 4', --1028
1112+ '10,15, -60,8, 4', --1032
1113+ '10,16, -60,8, 4', --1036
1114+ '10,17, -60,8, 44', --1080
1115+ '10,18, -60,8, 9', --1089
1116+ '10,19, -60,8, 4', --1093
1117+ '10,20, -60,8, 3', --1096
1118+ '10,21, -60,8, 2', --1098
1119+ '10,22, -60,8, 2', --1100
1120+ '10,23, -60,8, 1', --1101
1121+ '10,24, -60,8, 2', --1103
1122+ '10,25, -60,8, 1', --1104
1123+ '10,26, -60,8, 1', --1105
1124+ '10,27, -60,8, 2', --1107
1125+ '10,28, -60,8, 1', --1108
1126+ '10,29, -60,8, 1', --1109
1127+ '10,30, -60,8, 1', --1110 (count 2 end)
1128+ '11,0, -60,8, 1', --1111 (count 1 start)
1129+ '11,1, -60,8, 2', --1113
1130+ '11,2, -60,8, 2', --1115
1131+ '11,3, -60,8, 2', --1117
1132+ '11,4, -60,8, 2', --1119
1133+ '11,5, -60,8, 2', --1121
1134+ '11,6, -60,8, 2', --1123
1135+ '11,7, -60,8, 1', --1124
1136+ '11,8, -60,8, 2', --1126
1137+ '11,9, -60,8, 3', --1129
1138+ '11,10, -60,8, 4', --1133
1139+ '11,11, -60,8, 9', --1142
1140+ '11,12, -60,8, 5', --1147
1141+ '11,13, -60,8, 4', --1151
1142+ '11,14, -60,8, 4', --1155
1143+ '11,15, -60,8, 4', --1159
1144+ '11,16, -60,8, 4', --1163
1145+ '11,17, -60,8, 44', --1207
1146+ '11,18, -60,8, 9', --1216
1147+ '11,19, -60,8, 4', --1220
1148+ '11,20, -60,8, 3', --1223
1149+ '11,21, -60,8, 2', --1225
1150+ '11,22, -60,8, 2', --1227
1151+ '11,23, -60,8, 1', --1228
1152+ '11,24, -60,8, 2', --1230
1153+ '11,25, -60,8, 1', --1231
1154+ '11,26, -60,8, 1', --1232
1155+ '11,27, -60,8, 2', --1234
1156+ '11,28, -60,8, 1', --1235
1157+ '11,29, -60,8, 1', --1236
1158+ '11,30, -60,8, 1', --1237 (count 1 end)
1159+ '12,0, -60,8, 1', --1238 (count 0 start)
1160+ '12,1, -60,8, 2', --1240
1161+ '12,2, -60,8, 2', --1242
1162+ '12,3, -60,8, 2', --1244
1163+ '12,4, -60,8, 2', --1246
1164+ '12,5, -60,8, 2', --1248
1165+ '12,6, -60,8, 2', --1250
1166+ '12,7, -60,8, 1', --1251
1167+ '12,8, -60,8, 2', --1253
1168+ '12,9, -60,8, 3', --1256
1169+ '12,10, -60,8, 4', --1260
1170+ '12,11, -60,8, 9', --1269
1171+ '12,12, -60,8, 5', --1274
1172+ '12,13, -60,8, 4', --1278
1173+ '12,14, -60,8, 4', --1282
1174+ '12,15, -60,8, 4', --1286
1175+ '12,16, -60,8, 4', --1290
1176+ '12,17, -60,8, 75', --1365
1177+ '12,18, -60,8, 1', --1366 (count 0 end)
1178+ '10-32,8, -32,8, 1', --1367 (1) (game over start)
1179+ '100,1, -32,8, 1', --1368 (2)
1180+ '100,2, -32,8, 1', --1369 (3)
1181+ '100,3, -32,8, 1', --1370 (4)
1182+ '100,4, -32,8, 1', --1371 (5)
1183+ '100,5, -32,8, 1', --1372 (6)
1184+ '100,6, -32,8, 1', --1373 (7)
1185+ '100,7, -32,8, 1', --1374 (8)
1186+ '100,8, -32,8, 1', --1375 (9)
1187+ '100,9, -32,8, 1', --1376 (10)
1188+ '100,10, -32,8, 1', --1377 (11)
1189+ '100,11, -32,8, 1', --1378 (12)
1190+ '100,12, -32,8, 1', --1379 (13)
1191+ '100,13, -32,8, 1', --1380 (14)
1192+ '100,14, -32,8, 1', --1381 (15)
1193+ '100,15, -32,8, 1', --1382 (16)
1194+ '100,16, -32,8, 1', --1383 (17)
1195+ '100,17, -32,8, 1', --1384 (18)
1196+ '100,18, -32,8, 1', --1385 (19)
1197+ '100,19, -32,8, 1', --1386 (20)
1198+ '100,20, -32,8, 1', --1387 (21)
1199+ '100,21, -32,8, 1', --1388 (22)
1200+ '100,22, -32,8, 1', --1389 (23)
1201+ '100,23, -32,8, 1', --1390 (24)
1202+ '100,24, -32,8, 1', --1391 (25)
1203+ '100,25, -32,8, 1', --1392 (26)
1204+ '100,26, -32,8, 1', --1393 (27)
1205+ '100,27, -32,8, 1', --1394 (28)
1206+ '100,28, -32,8, 1', --1395 (29)
1207+ '100,29, -32,8, 1', --1396 (30)
1208+ '100,30, -32,8, 1', --1397 (31)
1209+ '100,31, -32,8, 1', --1398 (32)
1210+ '101,0, -32,8, 1', --1399 (33)
1211+ '101,1, -32,8, 1', --1400 (34)
1212+ '101,2, -32,8, 1', --1401 (35)
1213+ '101,3, -32,8, 1', --1402 (36)
1214+ '101,4, -32,8, 1', --1403 (37)
1215+ '101,5, -32,8, 1', --1404 (38)
1216+ '101,6, -32,8, 1', --1405 (39)
1217+ '101,7, -32,8, 1', --1406 (40)
1218+ '101,8, -32,8, 1', --1407 (41)
1219+ '101,9, -32,8, 1', --1408 (42)
1220+ '101,10, -32,8, 1', --1409 (43)
1221+ '101,11, -32,8, 1', --1410 (44)
1222+ '101,12, -32,8, 1', --1411 (45)
1223+ '101,13, -32,8, 1', --1412 (46)
1224+ '101,14, -32,8, 1', --1413 (47)
1225+ '101,15, -32,8, 1', --1414 (48)
1226+ '101,16, -32,8, 1', --1415 (49)
1227+ '101,17, -32,8, 1', --1416 (50)
1228+ '101,18, -32,8, 1', --1417 (51)
1229+ '101,19, -32,8, 1', --1418 (52)
1230+ '101,20, -32,8, 1', --1419 (53)
1231+ '101,21, -32,8, 1', --1420 (54)
1232+ '101,22, -32,8, 1', --1421 (55)
1233+ '101,23, -32,8, 1', --1422 (56)
1234+ '101,24, -32,8, 1', --1423 (57)
1235+ '101,25, -32,8, 1', --1424 (58)
1236+ '101,26, -32,8, 1', --1425 (59)
1237+ '101,27, -32,8, 1', --1426 (60)
1238+ '101,28, -32,8, 1', --1427 (61)
1239+ '101,29, -32,8, 1', --1428 (62)
1240+ '101,30, -32,8, 1', --1429 (63)
1241+ '101,31, -32,8, 1', --1430 (64)
1242+ '101,32, -32,8, 1', --1431 (65)
1243+ '101,33, -32,8, 1', --1432 (66)
1244+ '101,34, -32,8, 1', --1433 (67)
1245+ '101,35, -32,8, 1', --1434 (68)
1246+ '101,36, -32,8, 1', --1435 (69)
1247+ '101,37, -32,8, 1', --1436 (70)
1248+ '101,38, -32,8, 1', --1437 (71)
1249+ '101,39, -32,8, 1', --1438 (72)
1250+ '101,40, -32,8, 1', --1439 (73)
1251+ '101,41, -32,8, 1', --1440 (74)
1252+ '101,42, -32,8, 1', --1441 (75)
1253+ '101,43, -32,8, 1', --1442 (76)
1254+ '101,44, -32,8, 1', --1443 (77)
1255+ '101,45, -32,8, 1', --1444 (78)
1256+ '101,46, -32,8, 1', --1445 (79)
1257+ '101,47, -32,8, 1', --1446 (80)
1258+ '101,48, -32,8, 1', --1447 (81)
1259+ '101,49, -32,8, 1', --1448 (82)
1260+ '101,50, -32,8, 1', --1449 (83)
1261+ '101,51, -32,8, 1', --1450 (84)
1262+ '101,52, -32,8, 1', --1451 (85)
1263+ '101,53, -32,8, 1', --1452 (86)
1264+ '101,54, -32,8, 1', --1453 (87)
1265+ '101,55, -32,8, 1', --1454 (88)
1266+ '101,56, -32,8, 1', --1455 (89)
1267+ '101,57, -32,8, 1', --1456 (90)
1268+ '101,58, -32,8, 1', --1457 (91)
1269+ '101,59, -32,8, 1', --1458 (92)
1270+ '101,60, -32,8, 1', --1459 (93)
1271+ '101,61, -32,8, 1', --1460 (94)
1272+ '101,62, -32,8, 1', --1461 (95)
1273+ '101,63, -32,8, 1', --1462 (96)
1274+ '101,64, -32,8, 1', --1463 (97)
1275+ '101,65, -32,8, 1', --1464 (98)
1276+ '101,66, -32,8, 1', --1465 (99)
1277+ '101,67, -32,8, 1', --1466 (100)
1278+ '101,68, -32,8, 1', --1467 (101)
1279+ '101,69, -32,8, 1', --1468 (102)
1280+ '101,70, -32,8, 1', --1469 (103)
1281+ '101,71, -32,8, 1', --1470 (104)
1282+ '101,72, -32,8, 1', --1471 (105)
1283+ '101,73, -32,8, 1', --1472 (106)
1284+ '101,74, -32,8, 1', --1473 (107)
1285+ '101,75, -32,8, 119', --1592 (226)
1286+ '101,75, -32,8, -1', --1593+
1287+ },
1288+ },
1289+ ctrldef = {
1290+ titlebgdef = {},
1291+ selectbgdef = {},
1292+ versusbgdef = {},
1293+ optionbgdef = {},
1294+ continuebgdef = {},
1295+ victorybgdef = {},
1296+ resultsbgdef = {},
1297+ tournamentbgdef = {},
1298+ }
1299+}
1300+
1301+--;===========================================================
1302+--; PARSE SCREENPACK
1303+--;===========================================================
1304+--here starts proper screenpack DEF file parsing
1305+local sp = config.Motif
1306+if main.flags['-r'] ~= nil then
1307+ if main.f_fileExists(main.flags['-r']) then
1308+ sp = main.flags['-r']
1309+ elseif main.f_fileExists('data/' .. main.flags['-r'] .. '/system.def') then
1310+ sp = 'data/' .. main.flags['-r'] .. '/system.def'
1311+ end
1312+end
1313+local file = io.open(sp, 'r')
1314+local fileDir, fileName = sp:match('^(.-)([^/\\]+)$')
1315+local t = {}
1316+local pos = t
1317+local def_pos = motif
1318+t.anim = {}
1319+t.font_data = {['font/f-4x6.fnt'] = fontNew('font/f-4x6.fnt'), ['font/f-6x9.fnt'] = fontNew('font/f-6x9.fnt'), ['font/jg.fnt'] = fontNew('font/jg.fnt')}
1320+t.ctrldef = {}
1321+t.fileDir = fileDir
1322+t.fileName = fileName
1323+local bgdef = 'dummyUntilSet'
1324+local bgctrl = ''
1325+local bgctrl_match = 'dummyUntilSet'
1326+local tmp = ''
1327+for line in file:lines() do
1328+ line = line:gsub('%s*;.*$', '')
1329+ if line:match('^%s*%[.-%s*%]%s*$') then --matched [] group
1330+ line = line:match('^%s*%[(.-)%s*%]%s*$') --match text between []
1331+ line = line:gsub('[%. ]', '_') --change . and space to _
1332+ line = line:lower() --lowercase line
1333+ local row = tostring(line:lower()) --just in case it's a number (not really needed)
1334+ if row:match('.+ctrldef') then --matched ctrldef start
1335+ bgctrl = row
1336+ bgctrl_match = bgctrl:match('^(.-ctrl)def')
1337+ t.ctrldef[bgdef .. 'def'][bgctrl] = {}
1338+ t.ctrldef[bgdef .. 'def'][bgctrl].ctrl = {}
1339+ pos = t.ctrldef[bgdef .. 'def'][bgctrl]
1340+ motif.ctrldef[bgdef .. 'def'][bgctrl] = {
1341+ looptime = -1,
1342+ ctrlid = {0},
1343+ ctrl = {}
1344+ }
1345+ elseif row:match('^' .. bgctrl_match) then --matched ctrldef content
1346+ tmp = t.ctrldef[bgdef .. 'def'][bgctrl].ctrl
1347+ tmp[#tmp + 1] = {}
1348+ pos = tmp[#tmp]
1349+ motif.ctrldef[bgdef .. 'def'][bgctrl].ctrl[#tmp] = {
1350+ type = 'null',
1351+ time = {0, -1, -1},
1352+ ctrlid = {}
1353+ }
1354+ elseif row:match('.+bgdef$') then --matched bgdef start
1355+ t[row] = {}
1356+ pos = t[row]
1357+ t[row].bg = {}
1358+ bgdef = row:match('(.+)def$')
1359+ t.ctrldef[bgdef .. 'def'] = {}
1360+ elseif row:match('^' .. bgdef) then --matched bgdef content
1361+ tmp = t[bgdef .. 'def']
1362+ tmp.bg[#tmp.bg + 1] = {}
1363+ pos = tmp.bg[#tmp.bg]
1364+ motif[bgdef .. 'def'].bg[#tmp.bg] =
1365+ {
1366+ type = 'normal',
1367+ spriteno = {0, 0},
1368+ id = 0,
1369+ layerno = 0,
1370+ start = {0, 0},
1371+ delta = {1, 1},
1372+ trans = '',
1373+ mask = 0,
1374+ tile = {0, 0},
1375+ tilespacing = {0, nil},
1376+ --window = {0, 0, 0, 0},
1377+ --windowdelta = {0, 0}, --not supported yet
1378+ --width = {0, 0}, --not supported yet (parallax)
1379+ --xscale = {1.0, 1.0}, --not supported yet (parallax)
1380+ --yscalestart = 100, --not supported yet (parallax)
1381+ --yscaledelta = 1, --not supported yet (parallax)
1382+ positionlink = 0,
1383+ velocity = {0, 0},
1384+ --sin_x = {0, 0, 0}, --not supported yet
1385+ --sin_y = {0, 0, 0}, --not supported yet
1386+ ctrl = {},
1387+ ctrl_flags = {
1388+ visible = 1,
1389+ enabled = 1,
1390+ velx = 0,
1391+ vely = 0,
1392+ x = 0,
1393+ y = 0
1394+ }
1395+ }
1396+ elseif row:match('^begin_action_[0-9]+$') then --matched anim
1397+ row = tonumber(row:match('^begin_action_([0-9]+)$'))
1398+ t.anim[row] = {}
1399+ pos = t.anim[row]
1400+ else --matched other []
1401+ t[row] = {}
1402+ pos = t[row]
1403+ def_pos = motif[row]
1404+ end
1405+ else --matched non [] line
1406+ local param, value = line:match('^%s*([^=]-)%s*=%s*(.-)%s*$')
1407+ if param ~= nil then
1408+ param = param:gsub('[%. ]', '_') --change param . and space to _
1409+ param = param:lower() --lowercase param
1410+ if value == '' and (type(def_pos[param]) == 'number' or type(def_pos[param]) == 'table') then --text should remain empty
1411+ value = '0'
1412+ end
1413+ end
1414+ if param ~= nil and value ~= nil then --param = value pattern matched
1415+ value = value:gsub('"', '') --remove brackets from value
1416+ value = value:gsub('^(%.[0-9])', '0%1') --add 0 before dot if missing at the beginning of matched string
1417+ value = value:gsub('([^0-9])(%.[0-9])', '%10%2') --add 0 before dot if missing anywhere else
1418+ if param:match('^font[0-9]+$') then --font declaration param matched
1419+ local num = tonumber(param:match('font([0-9]+)'))
1420+ if param:match('_height$') then
1421+ if pos.font_height == nil then
1422+ pos.font_height = {}
1423+ end
1424+ pos.font_height[num] = main.f_dataType(value)
1425+ else
1426+ value = value:lower()
1427+ value = value:gsub('\\', '/')
1428+ if t.font_data[value] == nil then
1429+ if not value:match('^data/') then
1430+ if main.f_fileExists(fileDir .. value) then
1431+ value = fileDir .. value
1432+ elseif main.f_fileExists('font/' .. value) then
1433+ value = 'font/' .. value
1434+ elseif main.f_fileExists(t.files.fight:match('^(.-)[^/\\]+$') .. value) then
1435+ value = t.files.fight:match('^(.-)[^/\\]+$') .. value
1436+ end
1437+ end
1438+ t.font_data[value] = fontNew(value)
1439+ wait = true
1440+ end
1441+ if pos.font == nil then
1442+ pos.font = {}
1443+ end
1444+ pos.font[num] = tostring(value)
1445+ end
1446+ elseif pos[param] == nil then --mugen takes into account only first occurrence
1447+ if value:match('.+,.+') then --multiple values
1448+ for i, c in ipairs(main.f_strsplit(',', value)) do --split value using "," delimiter
1449+ if param:match('_anim$') then --mugen recognizes animations even if there are more values
1450+ pos[param] = main.f_dataType(c)
1451+ break
1452+ elseif i == 1 then
1453+ pos[param] = {}
1454+ if param:match('_font$') then
1455+ c = t.files.font[tonumber(c)]
1456+ end
1457+ end
1458+ if c == nil or c == '' then
1459+ pos[param][#pos[param] + 1] = 0
1460+ else
1461+ pos[param][#pos[param] + 1] = main.f_dataType(c)
1462+ end
1463+ end
1464+ else --single value
1465+ pos[param] = main.f_dataType(value)
1466+ end
1467+ end
1468+ else --only valid lines left are animations
1469+ line = line:lower()
1470+ local value = line:match('^%s*([0-9%-]+%s*,%s*[0-9%-]+%s*,%s*[0-9%-]+%s*,%s*[0-9%-]+%s*,%s*[0-9%-]+.-)[,%s]*$') or line:match('^%s*loopstart')
1471+ if value ~= nil then
1472+ value = value:gsub(',%s*,', ',0,') --add missing values
1473+ value = value:gsub(',%s*$', '')
1474+ pos[#pos + 1] = value
1475+ end
1476+ end
1477+ end
1478+ main.loadingRefresh()
1479+end
1480+file:close()
1481+
1482+--;===========================================================
1483+--; FIX REFERENCES, LOAD DATA
1484+--;===========================================================
1485+local anim = ''
1486+local facing = ''
1487+
1488+--merge tables
1489+motif = main.f_tableMerge(motif, t)
1490+
1491+--general paths
1492+local t_dir = {
1493+ {t = {'files', 'spr'}, skip = {'^data/'}, dirs = {motif.fileDir .. motif.files.spr, 'data/' .. motif.files.spr}},
1494+ {t = {'files', 'snd'}, skip = {'^data/', '^$'}, dirs = {motif.fileDir .. motif.files.snd, 'data/' .. motif.files.snd}},
1495+ {t = {'files', 'continue_snd'}, skip = {'^data/', '^$'}, dirs = {motif.fileDir .. motif.files.continue_snd, 'data/' .. motif.files.continue_snd}},
1496+ {t = {'files', 'logo_storyboard'}, skip = {'^data/', '^$'}, dirs = {motif.fileDir .. motif.files.logo_storyboard, 'data/' .. motif.files.logo_storyboard}},
1497+ {t = {'files', 'intro_storyboard'}, skip = {'^data/', '^$'}, dirs = {motif.fileDir .. motif.files.intro_storyboard, 'data/' .. motif.files.intro_storyboard}},
1498+ {t = {'files', 'select'}, skip = {'^data/'}, dirs = {motif.fileDir .. motif.files.select, 'data/' .. motif.files.select}},
1499+ {t = {'files', 'fight'}, skip = {'^data/'}, dirs = {motif.fileDir .. motif.files.fight, 'data/' .. motif.files.fight}},
1500+ {t = {'music', 'title_bgm'}, skip = {'^music/', '^$'}, dirs = {motif.fileDir .. motif.music.title_bgm, 'music/' .. motif.music.title_bgm}},
1501+ {t = {'music', 'select_bgm'}, skip = {'^music/', '^$'}, dirs = {motif.fileDir .. motif.music.select_bgm, 'music/' .. motif.music.select_bgm}},
1502+ {t = {'music', 'vs_bgm'}, skip = {'^music/', '^$'}, dirs = {motif.fileDir .. motif.music.vs_bgm, 'music/' .. motif.music.vs_bgm}},
1503+ {t = {'music', 'victory_bgm'}, skip = {'^music/', '^$'}, dirs = {motif.fileDir .. motif.music.victory_bgm, 'music/' .. motif.music.victory_bgm}},
1504+ {t = {'default_ending', 'storyboard'}, skip = {'^data/', '^$'}, dirs = {motif.fileDir .. motif.default_ending.storyboard, 'data/' .. motif.default_ending.storyboard}},
1505+ {t = {'end_credits', 'storyboard'}, skip = {'^data/', '^$'}, dirs = {motif.fileDir .. motif.end_credits.storyboard, 'data/' .. motif.end_credits.storyboard}},
1506+ {t = {'game_over_screen', 'storyboard'}, skip = {'^data/', '^$'}, dirs = {motif.fileDir .. motif.game_over_screen.storyboard, 'data/' .. motif.game_over_screen.storyboard}},
1507+}
1508+for i = 1, #t_dir do
1509+ local skip = false
1510+ for j = 1, #t_dir[i].skip do
1511+ if motif[t_dir[i].t[1]][t_dir[i].t[2]]:match(t_dir[i].skip[j]) then
1512+ skip = true
1513+ break
1514+ end
1515+ end
1516+ if not skip then
1517+ for j = 1, #t_dir[i].dirs do
1518+ if main.f_fileExists(t_dir[i].dirs[j]) then
1519+ motif[t_dir[i].t[1]][t_dir[i].t[2]] = t_dir[i].dirs[j]
1520+ break
1521+ end
1522+ end
1523+ end
1524+end
1525+
1526+motif.files.spr_data = sffNew(motif.files.spr)
1527+main.loadingRefresh()
1528+motif.files.snd_data = sndNew(motif.files.snd)
1529+main.loadingRefresh()
1530+motif.files.continue_snd_data = sndNew(motif.files.continue_snd)
1531+main.loadingRefresh()
1532+
1533+--fadein / fadeout data
1534+t_dir = {'title_info', 'select_info', 'vs_screen', 'victory_screen', 'win_screen', 'survival_results_screen', 'vs100kumite_results_screen', 'option_info', 'tournament_info', 'continue_screen'}
1535+for i = 1, #t_dir do
1536+ motif[t_dir[i]].fadein_data = main.f_fadeAnim(1, motif[t_dir[i]].fadein_time, motif[t_dir[i]].fadein_col[1], motif[t_dir[i]].fadein_col[2], motif[t_dir[i]].fadein_col[3])
1537+ animSetWindow(motif[t_dir[i]].fadein_data, main.screenOverscan, 0, motif.info.localcoord[1], motif.info.localcoord[2])
1538+ motif[t_dir[i]].fadeout_data = main.f_fadeAnim(0, motif[t_dir[i]].fadeout_time, motif[t_dir[i]].fadeout_col[1], motif[t_dir[i]].fadeout_col[2], motif[t_dir[i]].fadeout_col[3])
1539+ animSetWindow(motif[t_dir[i]].fadeout_data, main.screenOverscan, 0, motif.info.localcoord[1], motif.info.localcoord[2])
1540+end
1541+
1542+--other entries
1543+t_dir = {'titlebgdef', 'selectbgdef', 'versusbgdef', 'optionbgdef', 'continuebgdef', 'victorybgdef', 'resultsbgdef', 'tournamentbgdef'}
1544+for i = 1, #t_dir do
1545+ --ctrldef table adjustment
1546+ for k, v in pairs(motif.ctrldef[t_dir[i]]) do
1547+ tmp = motif.ctrldef[t_dir[i]][k].ctrl
1548+ for j = 1, #tmp do
1549+ --if END_TIME is omitted it should default to the same value as START_TIME
1550+ if tmp[j].time[2] == -1 then
1551+ tmp[j].time[2] = tmp[j].time[1]
1552+ end
1553+ --if LOOPTIME is omitted or set to -1, the background controller will not reset its own timer. In such case use GLOBAL_LOOPTIME
1554+ if tmp[j].time[3] == -1 then
1555+ tmp[j].time[3] = motif.ctrldef[t_dir[i]][k].looptime
1556+ end
1557+ --lowercase type name
1558+ tmp[j].type = tmp[j].type:lower()
1559+ --this list, if specified, overrides the default list specified in the BGCtrlDef
1560+ if #tmp[j].ctrlid == 0 then
1561+ for z = 1, #motif.ctrldef[t_dir[i]][k].ctrlid do
1562+ tmp[j].ctrlid[#tmp[j].ctrlid + 1] = motif.ctrldef[t_dir[i]][k].ctrlid[z]
1563+ end
1564+ end
1565+ end
1566+ end
1567+ --optional sff paths and data
1568+ if motif[t_dir[i]].spr ~= '' then
1569+ if not motif[t_dir[i]].spr:match('^data/') then
1570+ if main.f_fileExists(motif.fileDir .. motif[t_dir[i]].spr) then
1571+ motif[t_dir[i]].spr = motif.fileDir .. motif[t_dir[i]].spr
1572+ elseif main.f_fileExists('data/' .. motif[t_dir[i]].spr) then
1573+ motif[t_dir[i]].spr = 'data/' .. motif[t_dir[i]].spr
1574+ end
1575+ end
1576+ motif[t_dir[i]].spr_data = sffNew(motif[t_dir[i]].spr)
1577+ main.loadingRefresh()
1578+ elseif motif[t_dir[i]].spr ~= 'continuebgdef' and motif[t_dir[i]].spr ~= 'tournamentbgdef' then
1579+ motif[t_dir[i]].spr = motif.files.spr
1580+ motif[t_dir[i]].spr_data = motif.files.spr_data
1581+ end
1582+ --clearcolor data
1583+ motif[t_dir[i]].bgclearcolor_data = main.f_clearColor(motif[t_dir[i]].bgclearcolor[1], motif[t_dir[i]].bgclearcolor[2], motif[t_dir[i]].bgclearcolor[3])
1584+ animSetWindow(motif[t_dir[i]].bgclearcolor_data, main.screenOverscan, 0, motif.info.localcoord[1], motif.info.localcoord[2])
1585+ --background data
1586+ motif[t_dir[i]].bg_data = {}
1587+ local t_bgdef = motif[t_dir[i]].bg
1588+ local prev_k = ''
1589+ for k, v in pairs(t_bgdef) do --loop through table keys
1590+ t_bgdef[k].type = t_bgdef[k].type:lower()
1591+ --mugen ignores delta = 0 (defaults to 1)
1592+ if t_bgdef[k].delta[1] == 0 then t_bgdef[k].delta[1] = 1 end
1593+ if t_bgdef[k].delta[2] == 0 then t_bgdef[k].delta[2] = 1 end
1594+ --add ctrl data
1595+ motif[t_dir[i]].bg[k].ctrl = main.f_ctrlBG(t_bgdef[k], motif.ctrldef[t_dir[i]])
1596+ --positionlink adjustment
1597+ if t_bgdef[k].positionlink == 1 and prev_k ~= '' then
1598+ t_bgdef[k].start[1] = t_bgdef[prev_k].start[1]
1599+ t_bgdef[k].start[2] = t_bgdef[prev_k].start[2]
1600+ t_bgdef[k].delta[1] = t_bgdef[prev_k].delta[1]
1601+ t_bgdef[k].delta[2] = t_bgdef[prev_k].delta[2]
1602+ end
1603+ prev_k = k
1604+ --generate anim data
1605+ local sizeX, sizeY, offsetX, offsetY = 0, 0, 0, 0
1606+ if t_bgdef[k].type == 'anim' then
1607+ anim = main.f_animFromTable(motif.anim[t_bgdef[k].actionno], motif[t_dir[i]].spr_data, (t_bgdef[k].start[1] + main.normalSpriteCenter), t_bgdef[k].start[2])
1608+ else --normal, parallax
1609+ anim = t_bgdef[k].spriteno[1] .. ', ' .. t_bgdef[k].spriteno[2] .. ', ' .. (t_bgdef[k].start[1] + main.normalSpriteCenter) .. ', ' .. t_bgdef[k].start[2] .. ', ' .. -1
1610+ anim = animNew(motif[t_dir[i]].spr_data, anim)
1611+ sizeX, sizeY, offsetX, offsetY = getSpriteInfo(motif[t_dir[i]].spr, t_bgdef[k].spriteno[1], t_bgdef[k].spriteno[2])
1612+ end
1613+ if t_bgdef[k].trans == 'add1' then
1614+ animSetAlpha(anim, 255, 128)
1615+ elseif t_bgdef[k].trans == 'add' then
1616+ animSetAlpha(anim, 255, 255)
1617+ elseif t_bgdef[k].trans == 'sub' then
1618+ animSetAlpha(anim, 1, 255)
1619+ end
1620+ animAddPos(anim, 160, 0) --for some reason needed in ikemen
1621+ if t_bgdef[k].window ~= nil then
1622+ animSetWindow(
1623+ anim,
1624+ t_bgdef[k].window[1],
1625+ t_bgdef[k].window[2],
1626+ t_bgdef[k].window[3] - t_bgdef[k].window[1] + 1,
1627+ t_bgdef[k].window[4] - t_bgdef[k].window[2] + 1
1628+ )
1629+ else
1630+ animSetWindow(anim, main.screenOverscan, 0, motif.info.localcoord[1], motif.info.localcoord[2])
1631+ end
1632+ if t_bgdef[k].tilespacing[2] == nil then t_bgdef[k].tilespacing[2] = t_bgdef[k].tilespacing[1] end
1633+ if t_bgdef[k].type == 'parallax' then
1634+ animSetTile(anim, t_bgdef[k].tile[1], 0, t_bgdef[k].tilespacing[1] + sizeX, t_bgdef[k].tilespacing[2] + sizeY)
1635+ else
1636+ animSetTile(anim, t_bgdef[k].tile[1], t_bgdef[k].tile[2], t_bgdef[k].tilespacing[1] + sizeX, t_bgdef[k].tilespacing[2] + sizeY)
1637+ end
1638+ if t_bgdef[k].mask == 1 or t_bgdef[k].type ~= 'normal' or (t_bgdef[k].trans ~= '' and t_bgdef[k].trans ~= 'none') then
1639+ animSetColorKey(anim, 0)
1640+ else
1641+ animSetColorKey(anim, -1)
1642+ end
1643+
1644+ -- Scale non animated sprites
1645+ animUpdate(anim)
1646+ animSetScale(anim, 1 ,1)
1647+
1648+ motif[t_dir[i]].bg_data[k] = anim
1649+ main.loadingRefresh()
1650+ end
1651+end
1652+
1653+local function f_facing(var)
1654+ if var == -1 then
1655+ return 'H'
1656+ else
1657+ return nil
1658+ end
1659+end
1660+
1661+local function f_alphaToTable(var) --not used yet
1662+ var = var:match('^%s*(.-)%s*$')
1663+ var = var:lower()
1664+ if var:match('^a$') then
1665+ return {255, 255} --AS256D256
1666+ elseif var:match('^a1$') then
1667+ return {255, 128} --AS256D128
1668+ elseif var:match('^s$') then
1669+ return {1, 255} --AS0D256
1670+ elseif var:match('^s1$') then
1671+ return {1, 128} --are these values correct for S1?
1672+ elseif var:match('^as[0-9]+d[0-9]+$') then
1673+ local tabl = {}
1674+ tabl[1] = tonumber(var:match('^as([0-9]+)'))
1675+ tabl[2] = tonumber(var:match('d([0-9]+)$'))
1676+ return tabl
1677+ else
1678+ return nil
1679+ end
1680+end
1681+
1682+t = motif.select_info
1683+t_dir = {
1684+ {s = 'cell_bg_', x = 0, y = 0},
1685+ {s = 'cell_random_', x = 0, y = 0},
1686+ {s = 'p1_cursor_active_', x = 0, y = 0},
1687+ {s = 'p1_cursor_done_', x = 0, y = 0},
1688+ {s = 'p2_cursor_active_', x = 0, y = 0},
1689+ {s = 'p2_cursor_done_', x = 0, y = 0},
1690+ {s = 'p1_teammenu_bg_', x = t.p1_teammenu_pos[1], y = t.p1_teammenu_pos[2]},
1691+ {s = 'p1_teammenu_selftitle_', x = t.p1_teammenu_pos[1], y = t.p1_teammenu_pos[2]},
1692+ {s = 'p1_teammenu_enemytitle_', x = t.p1_teammenu_pos[1], y = t.p1_teammenu_pos[2]},
1693+ {s = 'p1_teammenu_item_cursor_', x = t.p1_teammenu_pos[1] + t.p1_teammenu_item_offset[1], y = t.p1_teammenu_pos[2] + t.p1_teammenu_item_offset[2]},
1694+ {s = 'p1_teammenu_value_icon_', x = t.p1_teammenu_pos[1] + t.p1_teammenu_item_offset[1], y = t.p1_teammenu_pos[2] + t.p1_teammenu_item_offset[2]},
1695+ {s = 'p1_teammenu_value_empty_icon_', x = t.p1_teammenu_pos[1] + t.p1_teammenu_item_offset[1], y = t.p1_teammenu_pos[2] + t.p1_teammenu_item_offset[2]},
1696+ {s = 'p2_teammenu_bg_', x = t.p2_teammenu_pos[1], y = t.p2_teammenu_pos[2]},
1697+ {s = 'p2_teammenu_selftitle_', x = t.p2_teammenu_pos[1], y = t.p2_teammenu_pos[2]},
1698+ {s = 'p2_teammenu_enemytitle_', x = t.p2_teammenu_pos[1], y = t.p2_teammenu_pos[2]},
1699+ {s = 'p2_teammenu_item_cursor_', x = t.p2_teammenu_pos[1] + t.p2_teammenu_item_offset[1], y = t.p2_teammenu_pos[2] + t.p2_teammenu_item_offset[2]},
1700+ {s = 'p2_teammenu_value_icon_', x = t.p2_teammenu_pos[1] + t.p2_teammenu_item_offset[1], y = t.p2_teammenu_pos[2] + t.p2_teammenu_item_offset[2]},
1701+ {s = 'p2_teammenu_value_empty_icon_', x = t.p2_teammenu_pos[1] + t.p2_teammenu_item_offset[1], y = t.p2_teammenu_pos[2] + t.p2_teammenu_item_offset[2]},
1702+}
1703+for i = 1, #t_dir do
1704+ --if i <= 2 and #t[t_dir[i].s .. 'spr'] == 0 and t[t_dir[i].s .. 'anim'] ~= nil and motif.anim[t[t_dir[i].s .. 'anim']] ~= nil then --cell_bg_, cell_random_
1705+ -- for j = 1, #motif.anim[t[t_dir[i].s .. 'anim']] do
1706+ -- for k, c in ipairs(main.f_strsplit(',', motif.anim[t[t_dir[i].s .. 'anim']][j])) do
1707+ -- if c:match('loopstart') then
1708+ -- break
1709+ -- elseif k <= 2 then
1710+ -- t[t_dir[i].s .. 'spr'][k] = tonumber(c)
1711+ -- elseif k == 7 and type(c) == 'string' then
1712+ -- t[t_dir[i].s .. 'alpha'] = f_alphaToTable(c)
1713+ -- end
1714+ -- end
1715+ -- end
1716+ --end
1717+ if #t[t_dir[i].s .. 'spr'] > 0 then --create sprite data
1718+ if #t[t_dir[i].s .. 'spr'] == 1 then --fix values
1719+ if type(t[t_dir[i].s .. 'spr'][1]) == 'string' then
1720+ t[t_dir[i].s .. 'spr'] = {tonumber(t[t_dir[i].s .. 'spr'][1]:match('^([0-9]+)')), 0}
1721+ else
1722+ t[t_dir[i].s .. 'spr'] = {t[t_dir[i].s .. 'spr'][1], 0}
1723+ end
1724+ end
1725+ if t[t_dir[i].s .. 'facing'] == -1 then facing = ', H' else facing = '' end
1726+ anim = t[t_dir[i].s .. 'spr'][1] .. ', ' .. t[t_dir[i].s .. 'spr'][2] .. ', ' .. t[t_dir[i].s .. 'offset'][1] + t_dir[i].x .. ', ' .. t[t_dir[i].s .. 'offset'][2] + t_dir[i].y .. ', -1' .. facing
1727+ t[t_dir[i].s .. 'data'] = animNew(motif.selectbgdef.spr_data, anim)
1728+ animSetScale(t[t_dir[i].s .. 'data'], t[t_dir[i].s .. 'scale'][1], t[t_dir[i].s .. 'scale'][2])
1729+ animUpdate(t[t_dir[i].s .. 'data'])
1730+ elseif t[t_dir[i].s .. 'anim'] ~= nil and motif.anim[t[t_dir[i].s .. 'anim']] ~= nil then --create animation data
1731+ t[t_dir[i].s .. 'data'] = main.f_animFromTable(
1732+ motif.anim[t[t_dir[i].s .. 'anim']],
1733+ motif.selectbgdef.spr_data,
1734+ t[t_dir[i].s .. 'offset'][1] + t_dir[i].x,
1735+ t[t_dir[i].s .. 'offset'][2] + t_dir[i].y,
1736+ t[t_dir[i].s .. 'scale'][1],
1737+ t[t_dir[i].s .. 'scale'][2],
1738+ f_facing(t[t_dir[i].s .. 'facing'])
1739+ )
1740+ else --create dummy data
1741+ t[t_dir[i].s .. 'data'] = animNew(motif.selectbgdef.spr_data, '-1, -1, 0, 0, -1')
1742+ animUpdate(t[t_dir[i].s .. 'data'])
1743+ end
1744+ animSetWindow(t[t_dir[i].s .. 'data'], main.screenOverscan, 0, motif.info.localcoord[1], motif.info.localcoord[2])
1745+ --animAddPos(t[t_dir[i].s .. 'data'], 160, 0) --for some reason needed in ikemen (but not in this case)
1746+ main.loadingRefresh()
1747+end
1748+
1749+t = motif.continue_screen
1750+if motif.anim[t.continue_anim] ~= nil then
1751+ t.continue_anim_data = main.f_animFromTable(
1752+ motif.anim[t.continue_anim],
1753+ motif.continuebgdef.spr_data,
1754+ t.continue_offset[1],
1755+ t.continue_offset[2],
1756+ t.continue_scale[1],
1757+ t.continue_scale[2]
1758+ )
1759+ animSetWindow(t.continue_anim_data, main.screenOverscan, 0, motif.info.localcoord[1], motif.info.localcoord[2])
1760+end
1761+
1762+if motif.vs_screen.p1_name_active_font == nil then
1763+ motif.vs_screen.p1_name_active_font = {motif.vs_screen.p1_name_font[1], motif.vs_screen.p1_name_font[2], motif.vs_screen.p1_name_font[3]}
1764+ motif.vs_screen.p1_name_active_font_scale = {motif.vs_screen.p1_name_font_scale[1], motif.vs_screen.p1_name_font_scale[2]}
1765+end
1766+if motif.vs_screen.p2_name_active_font == nil then
1767+ motif.vs_screen.p2_name_active_font = {motif.vs_screen.p2_name_font[1], motif.vs_screen.p2_name_font[2], motif.vs_screen.p2_name_font[3]}
1768+ motif.vs_screen.p2_name_active_font_scale = {motif.vs_screen.p2_name_font_scale[1], motif.vs_screen.p2_name_font_scale[2]}
1769+end
1770+
1771+--motif.ctrldef = nil
1772+main.f_printTable(motif, "debug/t_motif.txt")
1773+
1774+return motif
--- /dev/null
+++ b/script/options.lua
@@ -0,0 +1,1474 @@
1+
2+local options = {}
3+
4+--;===========================================================
5+--; LOAD DATA
6+--;===========================================================
7+
8+-- Data loading from lifebar
9+local file = io.open(motif.files.fight,"r")
10+local s_lifebar = file:read("*all")
11+file:close()
12+local roundsNum = tonumber(s_lifebar:match('match.wins%s*=%s*(%d+)'))
13+options.framespercount = tonumber(s_lifebar:match('framespercount%s*=%s*(%d+)'))
14+
15+main.f_printTable(config, "debug/config.txt")
16+
17+--;===========================================================
18+--; COMMON
19+--;===========================================================
20+local modified = 0
21+local modifiedlifebar = 0
22+local needReload = 0
23+
24+local windowBox = animNew(main.fadeSff, '0,0, 0,0, -1')
25+animSetTile(windowBox, 1, 1)
26+animSetAlpha(windowBox, motif.option_info.menu_boxbackground_alpha[1], motif.option_info.menu_boxbackground_alpha[2])
27+animUpdate(windowBox)
28+
29+--return string depending on bool
30+function options.f_boolDisplay(bool, t, f)
31+ t = t or motif.option_info.menu_itemname_yes
32+ f = f or motif.option_info.menu_itemname_no
33+ if bool == true then
34+ return t
35+ else
36+ return f
37+ end
38+end
39+
40+--return string depending on int
41+function options.f_intDisplay(bool, t, f)
42+ t = t or motif.option_info.menu_itemname_yes
43+ f = f or motif.option_info.menu_itemname_no
44+ if bool == 1 then
45+ return t
46+ else
47+ return f
48+ end
49+end
50+
51+--return correct precision
52+function options.f_precision(v, decimal)
53+ return tonumber(string.format(decimal, v))
54+end
55+
56+function options.f_saveCfg()
57+ --Data saving to config.json
58+ local file = io.open("save/config.json","w+")
59+ file:write(json.encode(config, {indent = true}))
60+ file:close()
61+ --Data saving to lifebar
62+ if modifiedlifebar == 1 then
63+ s_lifebar = s_lifebar:gsub('match.wins%s*=%s*%d+', 'match.wins = ' .. roundsNum)
64+ file = io.open(motif.files.fight,"w+")
65+ file:write(s_lifebar)
66+ file:close()
67+ --Reload lifebar
68+ loadLifebar(motif.files.fight)
69+ end
70+ --Reload game if needed
71+ if needReload == 1 then
72+ main.f_warning(main.f_extractText(motif.warning_info.text_reload), motif.option_info, motif.optionbgdef)
73+ os.exit()
74+ end
75+end
76+
77+function options.f_keyDefault()
78+ config.KeyConfig[1].Buttons[1] = 'UP'
79+ config.KeyConfig[1].Buttons[2] = 'DOWN'
80+ config.KeyConfig[1].Buttons[3] = 'LEFT'
81+ config.KeyConfig[1].Buttons[4] = 'RIGHT'
82+ config.KeyConfig[1].Buttons[5] = 'z'
83+ config.KeyConfig[1].Buttons[6] = 'x'
84+ config.KeyConfig[1].Buttons[7] = 'c'
85+ config.KeyConfig[1].Buttons[8] = 'a'
86+ config.KeyConfig[1].Buttons[9] = 's'
87+ config.KeyConfig[1].Buttons[10] = 'd'
88+ config.KeyConfig[1].Buttons[11] = 'RETURN'
89+ config.KeyConfig[1].Buttons[12] = 'q'
90+ config.KeyConfig[1].Buttons[13] = 'w'
91+ config.KeyConfig[2].Buttons[1] = 't'
92+ config.KeyConfig[2].Buttons[2] = 'g'
93+ config.KeyConfig[2].Buttons[3] = 'f'
94+ config.KeyConfig[2].Buttons[4] = 'h'
95+ config.KeyConfig[2].Buttons[5] = 'j'
96+ config.KeyConfig[2].Buttons[6] = 'k'
97+ config.KeyConfig[2].Buttons[7] = 'l'
98+ config.KeyConfig[2].Buttons[8] = 'u'
99+ config.KeyConfig[2].Buttons[9] = 'i'
100+ config.KeyConfig[2].Buttons[10] = 'o'
101+ config.KeyConfig[2].Buttons[11] = 'RSHIFT'
102+ config.KeyConfig[2].Buttons[12] = 'LEFTBRACKET'
103+ config.KeyConfig[2].Buttons[13] = 'RIGHTBRACKET'
104+ config.JoystickConfig[1].Buttons[1] = '-7'
105+ config.JoystickConfig[1].Buttons[2] = '-8'
106+ config.JoystickConfig[1].Buttons[3] = '-5'
107+ config.JoystickConfig[1].Buttons[4] = '-6'
108+ config.JoystickConfig[1].Buttons[5] = '0'
109+ config.JoystickConfig[1].Buttons[6] = '1'
110+ config.JoystickConfig[1].Buttons[7] = '4'
111+ config.JoystickConfig[1].Buttons[8] = '2'
112+ config.JoystickConfig[1].Buttons[9] = '3'
113+ config.JoystickConfig[1].Buttons[10] = '5'
114+ config.JoystickConfig[1].Buttons[11] = '7'
115+ config.JoystickConfig[1].Buttons[12] = '6'
116+ config.JoystickConfig[1].Buttons[13] = '8'
117+ config.JoystickConfig[2].Buttons[1] = '-7'
118+ config.JoystickConfig[2].Buttons[2] = '-8'
119+ config.JoystickConfig[2].Buttons[3] = '-5'
120+ config.JoystickConfig[2].Buttons[4] = '-6'
121+ config.JoystickConfig[2].Buttons[5] = '0'
122+ config.JoystickConfig[2].Buttons[6] = '1'
123+ config.JoystickConfig[2].Buttons[7] = '4'
124+ config.JoystickConfig[2].Buttons[8] = '2'
125+ config.JoystickConfig[2].Buttons[9] = '3'
126+ config.JoystickConfig[2].Buttons[10] = '5'
127+ config.JoystickConfig[2].Buttons[11] = '7'
128+ config.JoystickConfig[2].Buttons[12] = '6'
129+ config.JoystickConfig[2].Buttons[13] = '8'
130+end
131+
132+function options.f_menuCommon1(cursorPosY, moveTxt, item, t)
133+ if commandGetState(main.p1Cmd, 'u') then
134+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
135+ item = item - 1
136+ if t[item] ~= nil and t[item].itemname == 'empty' then
137+ item = item - 1
138+ end
139+ elseif commandGetState(main.p1Cmd, 'd') then
140+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
141+ item = item + 1
142+ if t[item] ~= nil and t[item].itemname == 'empty' then
143+ item = item + 1
144+ end
145+ end
146+ --cursor position calculation
147+ if item < 1 then
148+ item = #t
149+ if #t > motif.option_info.menu_window_visibleitems then
150+ cursorPosY = motif.option_info.menu_window_visibleitems
151+ else
152+ cursorPosY = #t
153+ end
154+ elseif item > #t then
155+ item = 1
156+ cursorPosY = 1
157+ elseif commandGetState(main.p1Cmd, 'u') and cursorPosY > 1 then
158+ cursorPosY = cursorPosY - 1
159+ if t[cursorPosY] ~= nil and t[cursorPosY].itemname == 'empty' then
160+ cursorPosY = cursorPosY - 1
161+ end
162+ elseif commandGetState(main.p1Cmd, 'd') and cursorPosY < motif.option_info.menu_window_visibleitems then
163+ cursorPosY = cursorPosY + 1
164+ if t[cursorPosY] ~= nil and t[cursorPosY].itemname == 'empty' then
165+ cursorPosY = cursorPosY + 1
166+ end
167+ end
168+ if cursorPosY == motif.option_info.menu_window_visibleitems then
169+ moveTxt = (item - motif.option_info.menu_window_visibleitems) * motif.option_info.menu_item_spacing[2]
170+ elseif cursorPosY == 1 then
171+ moveTxt = (item - 1) * motif.option_info.menu_item_spacing[2]
172+ end
173+ return cursorPosY, moveTxt, item
174+end
175+
176+local txt_title = main.f_createTextImg(
177+ motif.font_data[motif.option_info.title_font[1]],
178+ motif.option_info.title_font[2],
179+ motif.option_info.title_font[3],
180+ "",
181+ motif.option_info.title_offset[1],
182+ motif.option_info.title_offset[2],
183+ motif.option_info.title_font_scale[1],
184+ motif.option_info.title_font_scale[2],
185+ motif.option_info.title_font[4],
186+ motif.option_info.title_font[5],
187+ motif.option_info.title_font[6]
188+)
189+function options.f_menuCommon2(cursorPosY, moveTxt, item, t)
190+ --draw clearcolor
191+ animDraw(motif.optionbgdef.bgclearcolor_data)
192+ --draw layerno = 0 backgrounds
193+ main.f_drawBG(motif.optionbgdef.bg_data, motif.optionbgdef.bg, 0, motif.optionbgdef.timer)
194+ --draw menu box
195+ if motif.option_info.menu_boxbackground_visible == 1 then
196+ if #t > motif.option_info.menu_window_visibleitems and moveTxt == (#t - motif.option_info.menu_window_visibleitems) * motif.option_info.menu_item_spacing[2] then
197+ animSetWindow(
198+ windowBox,
199+ motif.option_info.menu_pos[1] + motif.option_info.menu_boxcursor_coords[1],
200+ motif.option_info.menu_pos[2] + motif.option_info.menu_boxcursor_coords[2],
201+ motif.option_info.menu_boxcursor_coords[3] - motif.option_info.menu_boxcursor_coords[1] + 1,
202+ motif.option_info.menu_window_visibleitems * (motif.option_info.menu_boxcursor_coords[4] - motif.option_info.menu_boxcursor_coords[2] + 1)
203+ )
204+ else
205+ animSetWindow(
206+ windowBox,
207+ motif.option_info.menu_pos[1] + motif.option_info.menu_boxcursor_coords[1],
208+ motif.option_info.menu_pos[2] + motif.option_info.menu_boxcursor_coords[2],
209+ motif.option_info.menu_boxcursor_coords[3] - motif.option_info.menu_boxcursor_coords[1] + 1,
210+ #t * (motif.option_info.menu_boxcursor_coords[4] - motif.option_info.menu_boxcursor_coords[2] + 1)
211+ )
212+ end
213+ animDraw(windowBox)
214+ end
215+ --draw title
216+ textImgDraw(txt_title)
217+ --draw menu items
218+ for i = 1, #t do
219+ if i > item - cursorPosY then
220+ if i == item then
221+ textImgDraw(main.f_updateTextImg(
222+ t[i].data,
223+ motif.font_data[motif.option_info.menu_item_active_font[1]],
224+ motif.option_info.menu_item_active_font[2],
225+ motif.option_info.menu_item_active_font[3],
226+ t[i].displayname,
227+ motif.option_info.menu_pos[1],
228+ motif.option_info.menu_pos[2] + (i - 1) * motif.option_info.menu_item_spacing[2] - moveTxt,
229+ motif.option_info.menu_item_active_font_scale[1],
230+ motif.option_info.menu_item_active_font_scale[2],
231+ motif.option_info.menu_item_active_font[4],
232+ motif.option_info.menu_item_active_font[5],
233+ motif.option_info.menu_item_active_font[6]
234+ ))
235+ if t[i].vardata ~= nil then
236+ textImgDraw(main.f_updateTextImg(
237+ t[i].vardata,
238+ motif.font_data[motif.option_info.menu_item_value_active_font[1]],
239+ motif.option_info.menu_item_value_active_font[2],
240+ motif.option_info.menu_item_value_active_font[3],
241+ t[i].vardisplay,
242+ motif.option_info.menu_pos[1] + motif.option_info.menu_item_spacing[1],
243+ motif.option_info.menu_pos[2] + (i - 1) * motif.option_info.menu_item_spacing[2] - moveTxt,
244+ motif.option_info.menu_item_value_active_font_scale[1],
245+ motif.option_info.menu_item_value_active_font_scale[2],
246+ motif.option_info.menu_item_value_active_font[4],
247+ motif.option_info.menu_item_value_active_font[5],
248+ motif.option_info.menu_item_value_active_font[6]
249+ ))
250+ end
251+ else
252+ textImgDraw(main.f_updateTextImg(
253+ t[i].data,
254+ motif.font_data[motif.option_info.menu_item_font[1]],
255+ motif.option_info.menu_item_font[2],
256+ motif.option_info.menu_item_font[3],
257+ t[i].displayname,
258+ motif.option_info.menu_pos[1],
259+ motif.option_info.menu_pos[2] + (i - 1) * motif.option_info.menu_item_spacing[2] - moveTxt,
260+ motif.option_info.menu_item_font_scale[1],
261+ motif.option_info.menu_item_font_scale[2],
262+ motif.option_info.menu_item_font[4],
263+ motif.option_info.menu_item_font[5],
264+ motif.option_info.menu_item_font[6]
265+ ))
266+ if t[i].vardata ~= nil then
267+ textImgDraw(main.f_updateTextImg(
268+ t[i].vardata,
269+ motif.font_data[motif.option_info.menu_item_value_font[1]],
270+ motif.option_info.menu_item_value_font[2],
271+ motif.option_info.menu_item_value_font[3],
272+ t[i].vardisplay,
273+ motif.option_info.menu_pos[1] + motif.option_info.menu_item_spacing[1],
274+ motif.option_info.menu_pos[2] + (i - 1) * motif.option_info.menu_item_spacing[2] - moveTxt,
275+ motif.option_info.menu_item_value_font_scale[1],
276+ motif.option_info.menu_item_value_font_scale[2],
277+ motif.option_info.menu_item_value_font[4],
278+ motif.option_info.menu_item_value_font[5],
279+ motif.option_info.menu_item_value_font[6]
280+ ))
281+ end
282+ end
283+ end
284+ end
285+ --draw menu cursor
286+ if motif.option_info.menu_boxcursor_visible == 1 then
287+ animSetWindow(
288+ main.cursorBox,
289+ motif.option_info.menu_pos[1] + motif.option_info.menu_boxcursor_coords[1],
290+ motif.option_info.menu_pos[2] + motif.option_info.menu_boxcursor_coords[2] + (cursorPosY - 1) * motif.option_info.menu_item_spacing[2],
291+ motif.option_info.menu_boxcursor_coords[3] - motif.option_info.menu_boxcursor_coords[1] + 1,
292+ motif.option_info.menu_boxcursor_coords[4] - motif.option_info.menu_boxcursor_coords[2] + 1
293+ )
294+ main.f_dynamicAlpha(main.cursorBox, 10,40,2, 255,255,0)
295+ animDraw(main.cursorBox)
296+ end
297+ --draw layerno = 1 backgrounds
298+ main.f_drawBG(motif.optionbgdef.bg_data, motif.optionbgdef.bg, 1, motif.optionbgdef.timer)
299+ --draw fadein
300+ animDraw(motif.option_info.fadein_data)
301+ animUpdate(motif.option_info.fadein_data)
302+ --update timer
303+ motif.optionbgdef.timer = motif.optionbgdef.timer + 1
304+ --end loop
305+ main.f_cmdInput()
306+ refresh()
307+end
308+
309+--;===========================================================
310+--; MAIN LOOP
311+--;===========================================================
312+local t_mainCfg = {
313+ {data = textImgNew(), itemname = 'arcadesettings', displayname = motif.option_info.menu_itemname_main_arcade},
314+ {data = textImgNew(), itemname = 'videosettings', displayname = motif.option_info.menu_itemname_main_video},
315+ {data = textImgNew(), itemname = 'audiosettings', displayname = motif.option_info.menu_itemname_main_audio},
316+ {data = textImgNew(), itemname = 'inputsettings', displayname = motif.option_info.menu_itemname_main_input},
317+ {data = textImgNew(), itemname = 'gameplaysettings', displayname = motif.option_info.menu_itemname_main_gameplay},
318+ {data = textImgNew(), itemname = 'enginesettings', displayname = motif.option_info.menu_itemname_main_engine},
319+ {data = textImgNew(), itemname = 'empty', displayname = ' '},
320+ {data = textImgNew(), itemname = 'quicklaunch', displayname = motif.option_info.menu_itemname_engine_quicklaunch, vardata = textImgNew(), vardisplay = options.f_intDisplay(config.QuickLaunch, motif.option_info.menu_itemname_yes, motif.option_info.menu_itemname_no)},
321+ {data = textImgNew(), itemname = 'portchange', displayname = motif.option_info.menu_itemname_main_port, vardata = textImgNew(), vardisplay = getListenPort()},
322+ {data = textImgNew(), itemname = 'defaultvalues', displayname = motif.option_info.menu_itemname_main_default},
323+ {data = textImgNew(), itemname = 'empty', displayname = ' '},
324+ {data = textImgNew(), itemname = 'save', displayname = motif.option_info.menu_itemname_main_save},
325+ {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_main_back},
326+}
327+t_mainCfg = main.f_cleanTable(t_mainCfg)
328+
329+function options.f_mainCfg()
330+ main.f_cmdInput()
331+ local cursorPosY = 1
332+ local moveTxt = 0
333+ local item = 1
334+ local t = t_mainCfg
335+ textImgSetText(txt_title, motif.option_info.title_text_main)
336+ main.f_resetBG(motif.option_info, motif.optionbgdef)
337+ while true do
338+ cursorPosY, moveTxt, item = options.f_menuCommon1(cursorPosY, moveTxt, item, t)
339+ if esc() then
340+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
341+ main.f_resetBG(motif.title_info, motif.titlebgdef)
342+ break
343+ --Port Change
344+ elseif t[item].itemname == 'portchange' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
345+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
346+ local port = main.f_input(main.f_extractText(motif.option_info.input_text_port), motif.option_info, motif.optionbgdef, 'string')
347+ if tonumber(port) ~= nil then
348+ sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
349+ setListenPort(port)
350+ else
351+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
352+ end
353+ t[item].vardisplay = getListenPort()
354+ modified = 1
355+ -- Quick Launch
356+ elseif t[item].itemname == 'quicklaunch' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
357+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
358+ if config.QuickLaunch == 1 then
359+ config.QuickLaunch = 0
360+ else
361+ config.QuickLaunch = 1
362+ end
363+ t[item].vardisplay = options.f_intDisplay(config.QuickLaunch, motif.option_info.menu_itemname_yes, motif.option_info.menu_itemname_no)
364+ modified = 1
365+ elseif main.f_btnPalNo(main.p1Cmd) > 0 then
366+ --Arcade Settings
367+ if t[item].itemname == 'arcadesettings' then
368+ sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
369+ options.f_arcadeCfg()
370+ --Gameplay Settings
371+ elseif t[item].itemname == 'gameplaysettings' then
372+ sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
373+ options.f_gameplayCfg()
374+ --Video Settings
375+ elseif t[item].itemname == 'videosettings' then
376+ sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
377+ options.f_videoCfg()
378+ elseif t[item].itemname == 'audiosettings' then
379+ sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
380+ options.f_audioCfg()
381+ --Engine Settings
382+ elseif t[item].itemname == 'enginesettings' then
383+ sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
384+ options.f_engineCfg()
385+ --Input Settings
386+ elseif t[item].itemname == 'inputsettings' then
387+ sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
388+ options.f_inputCfg()
389+ --Default Values
390+ elseif t[item].itemname == 'defaultvalues' then
391+ sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
392+ config.HelperMax = 56
393+ config.PlayerProjectileMax = 50
394+ config.ExplodMax = 256
395+ config.AfterImageMax = 8
396+ config['Attack.LifeToPowerMul'] = 0.7
397+ config['GetHit.LifeToPowerMul'] = 0.6
398+ config.Width = 640
399+ config.Height = 480
400+ config['Super.TargetDefenceMul'] = 1.5
401+ config.LifebarFontScale = 1
402+ --config.System = 'script/main.lua'
403+ options.f_keyDefault()
404+ --config.Motif = 'data/system.def'
405+ config.SimulMode = true
406+ config.LifeMul = 100
407+ config.Team1VS2Life = 120
408+ config.TurnsRecoveryRate = 300
409+ config.ZoomActive = false
410+ config.ZoomMin = 0.75
411+ config.ZoomMax = 1.1
412+ config.ZoomSpeed = 1.0
413+ config.AIRandomColor = true
414+ config.RoundTime = 99
415+ config.SingleTeamMode = true
416+ config.NumTurns = 4
417+ config.NumSimul = 4
418+ config.NumTag = 4
419+ config.Difficulty = 8
420+ config.Credits = 10
421+ setListenPort(7500)
422+ config.ContSelection = true
423+ config.AIRamping = true
424+ config.AutoGuard = false
425+ config.TeamPowerShare = false
426+ config.TeamLifeShare = false
427+ config.Fullscreen = false
428+ --lifebar
429+ roundsNum = 2
430+ modified = 1
431+ needReload = 1
432+ -- Save
433+ elseif t[item].itemname == 'save' then
434+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
435+ if modified == 1 then
436+ options.f_saveCfg()
437+ end
438+ main.f_resetBG(motif.title_info, motif.titlebgdef)
439+ break
440+ -- Back
441+ elseif t[item].itemname == 'back' then
442+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
443+ main.f_resetBG(motif.title_info, motif.titlebgdef)
444+ break
445+ end
446+ end
447+ options.f_menuCommon2(cursorPosY, moveTxt, item, t)
448+ end
449+end
450+
451+--;===========================================================
452+--; ARCADE SETTINGS
453+--;===========================================================
454+local t_arcadeCfg = {
455+ {data = textImgNew(), itemname = 'roundstowin', displayname = motif.option_info.menu_itemname_arcade_roundstowin, vardata = textImgNew(), vardisplay = roundsNum},
456+ {data = textImgNew(), itemname = 'roundtime', displayname = motif.option_info.menu_itemname_arcade_roundtime, vardata = textImgNew(), vardisplay = config.RoundTime},
457+ {data = textImgNew(), itemname = 'difficulty', displayname = motif.option_info.menu_itemname_arcade_difficulty, vardata = textImgNew(), vardisplay = config.Difficulty},
458+ {data = textImgNew(), itemname = 'credits', displayname = motif.option_info.menu_itemname_arcade_credits, vardata = textImgNew(), vardisplay = config.Credits},
459+ {data = textImgNew(), itemname = 'charchange', displayname = motif.option_info.menu_itemname_arcade_charchange, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.ContSelection)},
460+ {data = textImgNew(), itemname = 'airamping', displayname = motif.option_info.menu_itemname_arcade_airamping, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.AIRamping)},
461+ {data = textImgNew(), itemname = 'empty', displayname = ' '},
462+ {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_arcade_back},
463+}
464+t_arcadeCfg = main.f_cleanTable(t_arcadeCfg)
465+
466+function options.f_arcadeCfg()
467+ main.f_cmdInput()
468+ local cursorPosY = 1
469+ local moveTxt = 0
470+ local item = 1
471+ local t = t_arcadeCfg
472+ textImgSetText(txt_title, motif.option_info.title_text_arcade)
473+ while true do
474+ cursorPosY, moveTxt, item = options.f_menuCommon1(cursorPosY, moveTxt, item, t)
475+ if esc() then
476+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
477+ textImgSetText(txt_title, motif.option_info.title_text_main)
478+ break
479+ --Rounds to Win
480+ elseif t[item].itemname == 'roundstowin' then
481+ if commandGetState(main.p1Cmd, 'r') and roundsNum < 10 then
482+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
483+ roundsNum = roundsNum + 1
484+ t[item].vardisplay = roundsNum
485+ modifiedlifebar = 1
486+ modified = 1
487+ elseif commandGetState(main.p1Cmd, 'l') and roundsNum > 1 then
488+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
489+ roundsNum = roundsNum - 1
490+ t[item].vardisplay = roundsNum
491+ modifiedlifebar = 1
492+ modified = 1
493+ end
494+ --Round Time
495+ elseif t[item].itemname == 'roundtime' then
496+ if commandGetState(main.p1Cmd, 'r') and config.RoundTime < 1000 then
497+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
498+ config.RoundTime = config.RoundTime + 1
499+ t[item].vardisplay = config.RoundTime
500+ modified = 1
501+ elseif commandGetState(main.p1Cmd, 'l') and config.RoundTime > -2 then
502+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
503+ config.RoundTime = config.RoundTime - 1
504+ t[item].vardisplay = config.RoundTime
505+ modified = 1
506+ end
507+ --Difficulty level
508+ elseif t[item].itemname == 'difficulty' then
509+ if commandGetState(main.p1Cmd, 'r') and config.Difficulty < 8 then
510+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
511+ config.Difficulty = config.Difficulty + 1
512+ t[item].vardisplay = config.Difficulty
513+ modified = 1
514+ elseif commandGetState(main.p1Cmd, 'l') and config.Difficulty > 1 then
515+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
516+ config.Difficulty = config.Difficulty - 1
517+ t[item].vardisplay = config.Difficulty
518+ modified = 1
519+ end
520+ --Credits
521+ elseif t[item].itemname == 'credits' then
522+ if commandGetState(main.p1Cmd, 'r') and config.Credits < 99 then
523+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
524+ config.Credits = config.Credits + 1
525+ t[item].vardisplay = config.Credits
526+ modified = 1
527+ elseif commandGetState(main.p1Cmd, 'l') and config.Credits > 1 then
528+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
529+ config.Credits = config.Credits - 1
530+ t[item].vardisplay = config.Credits
531+ modified = 1
532+ end
533+ --Char change at Continue
534+ elseif t[item].itemname == 'charchange' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
535+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
536+ if config.ContSelection then
537+ config.ContSelection = false
538+ else
539+ config.ContSelection = true
540+ end
541+ t[item].vardisplay = options.f_boolDisplay(config.ContSelection)
542+ modified = 1
543+ --AI ramping
544+ elseif t[item].itemname == 'airamping' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
545+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
546+ if config.AIRamping then
547+ config.AIRamping = false
548+ else
549+ config.AIRamping = true
550+ end
551+ t[item].vardisplay = options.f_boolDisplay(config.AIRamping)
552+ modified = 1
553+ --Back
554+ elseif t[item].itemname == 'back' and main.f_btnPalNo(main.p1Cmd) > 0 then
555+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
556+ textImgSetText(txt_title, motif.option_info.title_text_main)
557+ break
558+ end
559+ options.f_menuCommon2(cursorPosY, moveTxt, item, t)
560+ end
561+end
562+
563+--;===========================================================
564+--; GAMEPLAY SETTINGS
565+--;===========================================================
566+local t_gameplayCfg = {
567+ {data = textImgNew(), itemname = 'lifemul', displayname = motif.option_info.menu_itemname_gameplay_lifemul, vardata = textImgNew(), vardisplay = config.LifeMul .. '%'},
568+ {data = textImgNew(), itemname = 'autoguard', displayname = motif.option_info.menu_itemname_gameplay_autoguard, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.AutoGuard)},
569+ {data = textImgNew(), itemname = 'team1vs2life', displayname = motif.option_info.menu_itemname_gameplay_team1vs2life, vardata = textImgNew(), vardisplay = config.Team1VS2Life},
570+ {data = textImgNew(), itemname = 'turnsrecoveryrate', displayname = motif.option_info.menu_itemname_gameplay_turnsrecoveryrate, vardata = textImgNew(), vardisplay = config.TurnsRecoveryRate},
571+ {data = textImgNew(), itemname = 'teampowershare', displayname = motif.option_info.menu_itemname_gameplay_teampowershare, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.TeamPowerShare)},
572+ {data = textImgNew(), itemname = 'teamlifeshare', displayname = motif.option_info.menu_itemname_gameplay_teamlifeshare, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.TeamLifeShare)},
573+ {data = textImgNew(), itemname = 'empty', displayname = ' '},
574+ {data = textImgNew(), itemname = 'advancedGameplaySettings', displayname = motif.option_info.menu_itemname_gameplay_advanced},
575+ {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_gameplay_back},
576+}
577+t_gameplayCfg = main.f_cleanTable(t_gameplayCfg)
578+
579+function options.f_gameplayCfg()
580+ main.f_cmdInput()
581+ local cursorPosY = 1
582+ local moveTxt = 0
583+ local item = 1
584+ local t = t_gameplayCfg
585+ textImgSetText(txt_title, motif.option_info.title_text_gameplay)
586+ while true do
587+ cursorPosY, moveTxt, item = options.f_menuCommon1(cursorPosY, moveTxt, item, t)
588+ if esc() then
589+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
590+ textImgSetText(txt_title, motif.option_info.title_text_main)
591+ break
592+ --Life
593+ elseif t[item].itemname == 'lifemul' then
594+ if commandGetState(main.p1Cmd, 'r') and config.LifeMul < 300 then
595+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
596+ config.LifeMul = config.LifeMul + 10
597+ t[item].vardisplay = config.LifeMul .. '%'
598+ modified = 1
599+ elseif commandGetState(main.p1Cmd, 'l') and config.LifeMul > 10 then
600+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
601+ config.LifeMul = config.LifeMul - 10
602+ t[item].vardisplay = config.LifeMul .. '%'
603+ modified = 1
604+ end
605+ --Auto-Guard
606+ elseif t[item].itemname == 'autoguard' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
607+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
608+ if config.AutoGuard then
609+ config.AutoGuard = false
610+ else
611+ config.AutoGuard = true
612+ end
613+ t[item].vardisplay = options.f_boolDisplay(config.AutoGuard)
614+ modified = 1
615+ --1P Vs Team Life
616+ elseif t[item].itemname == 'team1vs2life' then
617+ if commandGetState(main.p1Cmd, 'r') and config.Team1VS2Life < 3000 then
618+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
619+ config.Team1VS2Life = config.Team1VS2Life + 10
620+ t[item].vardisplay = config.Team1VS2Life
621+ modified = 1
622+ elseif commandGetState(main.p1Cmd, 'l') and config.Team1VS2Life > 10 then
623+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
624+ config.Team1VS2Life = config.Team1VS2Life - 10
625+ t[item].vardisplay = config.Team1VS2Life
626+ modified = 1
627+ end
628+ --Turns HP Recovery
629+ elseif t[item].itemname == 'turnsrecoveryrate' then
630+ if commandGetState(main.p1Cmd, 'r') and config.TurnsRecoveryRate < 3000 then
631+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
632+ config.TurnsRecoveryRate = config.TurnsRecoveryRate + 10
633+ t[item].vardisplay = config.TurnsRecoveryRate
634+ modified = 1
635+ elseif commandGetState(main.p1Cmd, 'l') and config.TurnsRecoveryRate > 10 then
636+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
637+ config.TurnsRecoveryRate = config.TurnsRecoveryRate - 10
638+ t[item].vardisplay = config.TurnsRecoveryRate
639+ modified = 1
640+ end
641+ --Team Power Share
642+ elseif t[item].itemname == 'teampowershare' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
643+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
644+ if config.TeamPowerShare then
645+ config.TeamPowerShare = false
646+ else
647+ config.TeamPowerShare = true
648+ end
649+ t[item].vardisplay = options.f_boolDisplay(config.TeamPowerShare)
650+ modified = 1
651+ --Team Life Share
652+ elseif t[item].itemname == 'teamlifeshare' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
653+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
654+ if config.TeamLifeShare then
655+ config.TeamLifeShare = false
656+ else
657+ config.TeamLifeShare = true
658+ end
659+ t[item].vardisplay = options.f_boolDisplay(config.TeamLifeShare)
660+ modified = 1
661+ -- Advanced settings
662+ elseif t[item].itemname == 'advancedGameplaySettings' and main.f_btnPalNo(main.p1Cmd) > 0 then
663+ sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
664+ options.f_advGameplayCfg()
665+ --Back
666+ elseif t[item].itemname == 'back' and main.f_btnPalNo(main.p1Cmd) > 0 then
667+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
668+ textImgSetText(txt_title, motif.option_info.title_text_main)
669+ break
670+ end
671+ options.f_menuCommon2(cursorPosY, moveTxt, item, t)
672+ end
673+end
674+
675+
676+--;===========================================================
677+--; ADVANCED GAMEPLAY SETTINGS
678+--;===========================================================
679+function options.f_checkTeamAmount(arg1, arg2, arg3)
680+ ret = arg1
681+ if arg1 <= arg2 then
682+ ret = arg3
683+ end
684+
685+ return ret
686+end
687+
688+local t_advGameplayCfg = {
689+ {data = textImgNew(), itemname = 'attackpowermul', displayname = motif.option_info.menu_itemname_gameplay_attackpowermul, vardata = textImgNew(), vardisplay = config['Attack.LifeToPowerMul']},
690+ {data = textImgNew(), itemname = 'gethitpowermul', displayname = motif.option_info.menu_itemname_gameplay_gethitpowermul, vardata = textImgNew(), vardisplay = config['GetHit.LifeToPowerMul']},
691+ {data = textImgNew(), itemname = 'superdefencemul', displayname = motif.option_info.menu_itemname_gameplay_superdefencemul, vardata = textImgNew(), vardisplay = config['Super.TargetDefenceMul']},
692+ {data = textImgNew(), itemname = 'empty', displayname = ' '},
693+ {data = textImgNew(), itemname = 'singlemode', displayname = motif.option_info.menu_itemname_gameplay_singlemode, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.SingleTeamMode, motif.option_info.menu_itemname_enabled, motif.option_info.menu_itemname_disabled)},
694+ {data = textImgNew(), itemname = 'numturns', displayname = motif.option_info.menu_itemname_gameplay_numturns, vardata = textImgNew(), vardisplay = options.f_checkTeamAmount(config.NumTurns, 1, motif.option_info.menu_itemname_disabled)},
695+ {data = textImgNew(), itemname = 'numsimul', displayname = motif.option_info.menu_itemname_gameplay_numsimul, vardata = textImgNew(), vardisplay = options.f_checkTeamAmount(config.NumSimul, 1, motif.option_info.menu_itemname_disabled)},
696+ {data = textImgNew(), itemname = 'numtag', displayname = motif.option_info.menu_itemname_gameplay_numtag, vardata = textImgNew(), vardisplay = options.f_checkTeamAmount(config.NumTag, 1, motif.option_info.menu_itemname_disabled)},
697+ {data = textImgNew(), itemname = 'empty', displayname = ' '},
698+ {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_gameplay_back},
699+}
700+t_advGameplayCfg = main.f_cleanTable(t_advGameplayCfg)
701+
702+function options.f_advGameplayCfg()
703+ main.f_cmdInput()
704+ local cursorPosY = 1
705+ local moveTxt = 0
706+ local item = 1
707+ local t = t_advGameplayCfg
708+ textImgSetText(txt_title, motif.option_info.title_text_advgameplay)
709+ while true do
710+ cursorPosY, moveTxt, item = options.f_menuCommon1(cursorPosY, moveTxt, item, t)
711+ if esc() then
712+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
713+ textImgSetText(txt_title, motif.option_info.title_text_gameplay)
714+ break
715+ --Life
716+ elseif t[item].itemname == 'lifemul' then
717+ if commandGetState(main.p1Cmd, 'r') and config.LifeMul < 300 then
718+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
719+ config.LifeMul = config.LifeMul + 10
720+ t[item].vardisplay = config.LifeMul .. '%'
721+ modified = 1
722+ elseif commandGetState(main.p1Cmd, 'l') and config.LifeMul > 10 then
723+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
724+ config.LifeMul = config.LifeMul - 10
725+ t[item].vardisplay = config.LifeMul .. '%'
726+ modified = 1
727+ end
728+ --Auto-Guard
729+ elseif t[item].itemname == 'autoguard' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
730+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
731+ if config.AutoGuard then
732+ config.AutoGuard = false
733+ else
734+ config.AutoGuard = true
735+ end
736+ t[item].vardisplay = options.f_boolDisplay(config.AutoGuard)
737+ modified = 1
738+ --Attack.LifeToPowerMul
739+ elseif t[item].itemname == 'attackpowermul' then
740+ if commandGetState(main.p1Cmd, 'r') then
741+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
742+ config['Attack.LifeToPowerMul'] = options.f_precision(config['Attack.LifeToPowerMul'] + 0.1, '%.01f')
743+ t[item].vardisplay = config['Attack.LifeToPowerMul']
744+ modified = 1
745+ needReload = 1
746+ elseif commandGetState(main.p1Cmd, 'l') and config['Attack.LifeToPowerMul'] > 0.1 then
747+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
748+ config['Attack.LifeToPowerMul'] = options.f_precision(config['Attack.LifeToPowerMul'] - 0.1, '%.01f')
749+ t[item].vardisplay = config['Attack.LifeToPowerMul']
750+ modified = 1
751+ needReload = 1
752+ end
753+ --GetHit.LifeToPowerMul
754+ elseif t[item].itemname == 'gethitpowermul' then
755+ if commandGetState(main.p1Cmd, 'r') then
756+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
757+ config['GetHit.LifeToPowerMul'] = options.f_precision(config['GetHit.LifeToPowerMul'] + 0.1, '%.01f')
758+ t[item].vardisplay = config['GetHit.LifeToPowerMul']
759+ modified = 1
760+ needReload = 1
761+ elseif commandGetState(main.p1Cmd, 'l') and config['GetHit.LifeToPowerMul'] > 0.1 then
762+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
763+ config['GetHit.LifeToPowerMul'] = options.f_precision(config['GetHit.LifeToPowerMul'] - 0.1, '%.01f')
764+ t[item].vardisplay = config['GetHit.LifeToPowerMul']
765+ modified = 1
766+ needReload = 1
767+ end
768+ --Super.TargetDefenceMul
769+ elseif t[item].itemname == 'superdefencemul' then
770+ if commandGetState(main.p1Cmd, 'r') then
771+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
772+ config['Super.TargetDefenceMul'] = options.f_precision(config['Super.TargetDefenceMul'] + 0.1, '%.01f')
773+ t[item].vardisplay = config['Super.TargetDefenceMul']
774+ modified = 1
775+ needReload = 1
776+ elseif commandGetState(main.p1Cmd, 'l') and config['Super.TargetDefenceMul'] > 0.1 then
777+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
778+ config['Super.TargetDefenceMul'] = options.f_precision(config['Super.TargetDefenceMul'] - 0.1, '%.01f')
779+ t[item].vardisplay = config['Super.TargetDefenceMul']
780+ modified = 1
781+ needReload = 1
782+ end
783+ --1P Vs Team Life
784+ elseif t[item].itemname == 'team1vs2life' then
785+ if commandGetState(main.p1Cmd, 'r') and config.Team1VS2Life < 3000 then
786+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
787+ config.Team1VS2Life = config.Team1VS2Life + 10
788+ t[item].vardisplay = config.Team1VS2Life
789+ modified = 1
790+ elseif commandGetState(main.p1Cmd, 'l') and config.Team1VS2Life > 10 then
791+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
792+ config.Team1VS2Life = config.Team1VS2Life - 10
793+ t[item].vardisplay = config.Team1VS2Life
794+ modified = 1
795+ end
796+ --Turns HP Recovery
797+ elseif t[item].itemname == 'turnsrecoveryrate' then
798+ if commandGetState(main.p1Cmd, 'r') and config.TurnsRecoveryRate < 3000 then
799+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
800+ config.TurnsRecoveryRate = config.TurnsRecoveryRate + 10
801+ t[item].vardisplay = config.TurnsRecoveryRate
802+ modified = 1
803+ elseif commandGetState(main.p1Cmd, 'l') and config.TurnsRecoveryRate > 10 then
804+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
805+ config.TurnsRecoveryRate = config.TurnsRecoveryRate - 10
806+ t[item].vardisplay = config.TurnsRecoveryRate
807+ modified = 1
808+ end
809+ --Team Power Share
810+ elseif t[item].itemname == 'teampowershare' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
811+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
812+ if config.TeamPowerShare then
813+ config.TeamPowerShare = false
814+ else
815+ config.TeamPowerShare = true
816+ end
817+ t[item].vardisplay = options.f_boolDisplay(config.TeamPowerShare)
818+ modified = 1
819+ --Team Life Share
820+ elseif t[item].itemname == 'teamlifeshare' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
821+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
822+ if config.TeamLifeShare then
823+ config.TeamLifeShare = false
824+ else
825+ config.TeamLifeShare = true
826+ end
827+ t[item].vardisplay = options.f_boolDisplay(config.TeamLifeShare)
828+ modified = 1
829+ -- Singke mode
830+ elseif t[item].itemname == 'singlemode' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
831+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
832+ if config.SingleTeamMode then
833+ config.SingleTeamMode = false
834+ else
835+ config.SingleTeamMode = true
836+ end
837+ t[item].vardisplay = options.f_boolDisplay(config.SingleTeamMode, motif.option_info.menu_itemname_enabled, motif.option_info.menu_itemname_disabled)
838+ modified = 1
839+ needReload = 1
840+ --Turns Limit
841+ elseif t[item].itemname == 'numturns' then
842+ if commandGetState(main.p1Cmd, 'r') and config.NumTurns < 8 then
843+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
844+ config.NumTurns = config.NumTurns + 1
845+ t[item].vardisplay = config.NumTurns
846+ modified = 1
847+ elseif commandGetState(main.p1Cmd, 'l') and config.NumTurns > 1 then
848+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
849+ config.NumTurns = config.NumTurns - 1
850+ t[item].vardisplay = options.f_checkTeamAmount(config.NumTurns, 1, motif.option_info.menu_itemname_disabled)
851+ modified = 1
852+ end
853+ -- Disable check
854+ if config.NumTurns < 2 then
855+ needReload = 1
856+ end
857+ --Simul Limit
858+ elseif t[item].itemname == 'numsimul' then
859+ if commandGetState(main.p1Cmd, 'r') and config.NumSimul < 8 then
860+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
861+ config.NumSimul = config.NumSimul + 1
862+ t[item].vardisplay = config.NumSimul
863+ modified = 1
864+ elseif commandGetState(main.p1Cmd, 'l') and config.NumSimul > 1 then
865+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
866+ config.NumSimul = config.NumSimul - 1
867+ t[item].vardisplay = options.f_checkTeamAmount(config.NumSimul, 1, motif.option_info.menu_itemname_disabled)
868+ modified = 1
869+ end
870+ -- Disable check
871+ if config.NumSimul < 2 then
872+ needReload = 1
873+ end
874+ --Tag Limit
875+ elseif t[item].itemname == 'numtag' then
876+ if commandGetState(main.p1Cmd, 'r') and config.NumTag < 8 then
877+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
878+ config.NumTag = config.NumTag + 1
879+ t[item].vardisplay = config.NumTag
880+ modified = 1
881+ elseif commandGetState(main.p1Cmd, 'l') and config.NumTag > 1 then
882+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
883+ config.NumTag = config.NumTag - 1
884+ t[item].vardisplay = options.f_checkTeamAmount(config.NumTag, 1, motif.option_info.menu_itemname_disabled)
885+ modified = 1
886+ end
887+ -- Disable check
888+ if config.NumTag < 2 then
889+ needReload = 1
890+ end
891+ --Back
892+ elseif t[item].itemname == 'back' and main.f_btnPalNo(main.p1Cmd) > 0 then
893+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
894+ textImgSetText(txt_title, motif.option_info.title_text_gameplay)
895+ break
896+ end
897+ options.f_menuCommon2(cursorPosY, moveTxt, item, t)
898+ end
899+end
900+
901+--;===========================================================
902+--; VIDEO SETTINGS
903+--;===========================================================
904+local t_shaderNames = {}
905+t_shaderNames[0] = "No shader"
906+t_shaderNames[1] = "hqx2"
907+t_shaderNames[2] = "hqx4"
908+t_shaderNames[3] = "scanline"
909+
910+local t_videoCfg = {
911+ {data = textImgNew(), itemname = 'resolution', displayname = motif.option_info.menu_itemname_video_resolution, vardata = textImgNew(), vardisplay = config.Width .. 'x' .. config.Height},
912+ {data = textImgNew(), itemname = 'fullscreen', displayname = motif.option_info.menu_itemname_video_fullscreen, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.Fullscreen)},
913+ {data = textImgNew(), itemname = 'msaa', displayname = motif.option_info.menu_itemname_video_msaa, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.MSAA, motif.option_info.menu_itemname_enabled, motif.option_info.menu_itemname_disabled)},
914+ {data = textImgNew(), itemname = 'airandomcolor', displayname = motif.option_info.menu_itemname_video_aipalette, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.AIRandomColor, motif.option_info.menu_itemname_video_aipalette_random, motif.option_info.menu_itemname_video_aipalette_default)},
915+ {data = textImgNew(), itemname = 'postprocessingshader', displayname = "Shader", vardata = textImgNew(), vardisplay = t_shaderNames[config.PostProcessingShader]},
916+ {data = textImgNew(), itemname = 'empty', displayname = ' '},
917+ {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_video_back},
918+}
919+t_videoCfg = main.f_cleanTable(t_videoCfg)
920+
921+function options.f_videoCfg()
922+ main.f_cmdInput()
923+ local cursorPosY = 1
924+ local moveTxt = 0
925+ local item = 1
926+ local t = t_videoCfg
927+ textImgSetText(txt_title, motif.option_info.title_text_video)
928+ while true do
929+ cursorPosY, moveTxt, item = options.f_menuCommon1(cursorPosY, moveTxt, item, t)
930+ if esc() then
931+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
932+ textImgSetText(txt_title, motif.option_info.title_text_main)
933+ break
934+ --Resolution
935+ elseif t[item].itemname == 'resolution' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
936+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
937+ options.f_resCfg()
938+ t[item].vardisplay = config.Width .. 'x' .. config.Height
939+ --Fullscreen
940+ elseif t[item].itemname == 'fullscreen' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
941+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
942+ if config.Fullscreen then
943+ config.Fullscreen = false
944+ else
945+ config.Fullscreen = true
946+ end
947+ t[item].vardisplay = options.f_boolDisplay(config.Fullscreen)
948+ modified = 1
949+ needReload = 1
950+ elseif t[item].itemname == 'msaa' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
951+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
952+ if config.MSAA then
953+ config.MSAA = false
954+ else
955+ config.MSAA = true
956+ end
957+ t[item].vardisplay = options.f_boolDisplay(config.MSAA, motif.option_info.menu_itemname_enabled, motif.option_info.menu_itemname_disabled)
958+ modified = 1
959+ needReload = 1
960+ --AI Palette
961+ elseif t[item].itemname == 'airandomcolor' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
962+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
963+ if config.AIRandomColor then
964+ config.AIRandomColor = false
965+ else
966+ config.AIRandomColor = true
967+ end
968+ t[item].vardisplay = options.f_boolDisplay(config.AIRandomColor, motif.option_info.menu_itemname_video_aipalette_random, motif.option_info.menu_itemname_video_aipalette_default)
969+ modified = 1
970+ -- Postprocessing
971+ elseif t[item].itemname == 'postprocessingshader' then
972+ if commandGetState(main.p1Cmd, 'r') and config.PostProcessingShader < #t_shaderNames then
973+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
974+ config.PostProcessingShader = config.PostProcessingShader + 1
975+ modified = 1
976+ needReload = 1
977+ elseif commandGetState(main.p1Cmd, 'l') and config.PostProcessingShader > 0 then
978+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
979+ config.PostProcessingShader = config.PostProcessingShader - 1
980+ modified = 1
981+ needReload = 1
982+ end
983+ t[item].vardisplay = t_shaderNames[config.PostProcessingShader]
984+ -- Back
985+ elseif t[item].itemname == 'back' and main.f_btnPalNo(main.p1Cmd) > 0 then
986+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
987+ textImgSetText(txt_title, motif.option_info.title_text_main)
988+ break
989+ end
990+ options.f_menuCommon2(cursorPosY, moveTxt, item, t)
991+ end
992+end
993+
994+--;===========================================================
995+--; RESOLUTION SETTINGS
996+--;===========================================================
997+local t_resCfg = {
998+ {data = textImgNew(), x = 320, y = 240, displayname = motif.option_info.menu_itemname_res_320x240},
999+ {data = textImgNew(), x = 640, y = 480, displayname = motif.option_info.menu_itemname_res_640x480},
1000+ {data = textImgNew(), x = 1280, y = 960, displayname = motif.option_info.menu_itemname_res_1280x960},
1001+ {data = textImgNew(), x = 1600, y = 1200, displayname = motif.option_info.menu_itemname_res_1600x1200},
1002+ {data = textImgNew(), x = 960, y = 720, displayname = motif.option_info.menu_itemname_res_960x720},
1003+ {data = textImgNew(), x = 1200, y = 900, displayname = motif.option_info.menu_itemname_res_1200x900},
1004+ {data = textImgNew(), x = 1440, y = 1080, displayname = motif.option_info.menu_itemname_res_1440x1080},
1005+ {data = textImgNew(), x = 1280, y = 720, displayname = motif.option_info.menu_itemname_res_1280x720},
1006+ {data = textImgNew(), x = 1600, y = 900, displayname = motif.option_info.menu_itemname_res_1600x900},
1007+ {data = textImgNew(), x = 1920, y = 1080, displayname = motif.option_info.menu_itemname_res_1920x1080},
1008+ {data = textImgNew(), x = 2560, y = 1440, displayname = motif.option_info.menu_itemname_res_2560x1440},
1009+ {data = textImgNew(), x = 3840, y = 2160, displayname = motif.option_info.menu_itemname_res_3840x2160},
1010+ {data = textImgNew(), itemname = 'empty', displayname = ' '},
1011+ {data = textImgNew(), itemname = 'custom', displayname = motif.option_info.menu_itemname_res_custom},
1012+ {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_res_back},
1013+}
1014+t_resCfg = main.f_cleanTable(t_resCfg)
1015+
1016+function options.f_resCfg()
1017+ main.f_cmdInput()
1018+ local cursorPosY = 1
1019+ local moveTxt = 0
1020+ local item = 1
1021+ local t = t_resCfg
1022+ textImgSetText(txt_title, motif.option_info.title_text_res)
1023+ while true do
1024+ cursorPosY, moveTxt, item = options.f_menuCommon1(cursorPosY, moveTxt, item, t)
1025+ if esc() then
1026+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1027+ textImgSetText(txt_title, motif.option_info.title_text_video)
1028+ break
1029+ elseif main.f_btnPalNo(main.p1Cmd) > 0 then
1030+ --Back
1031+ if t[item].itemname == 'back' then
1032+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1033+ textImgSetText(txt_title, motif.option_info.title_text_video)
1034+ break
1035+ --Custom
1036+ elseif t[item].itemname == 'custom' then
1037+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1038+ local width = tonumber(main.f_input(main.f_extractText(motif.option_info.input_text_reswidth), motif.option_info, motif.optionbgdef, 'string'))
1039+ if width ~= nil then
1040+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1041+ local height = tonumber(main.f_input(main.f_extractText(motif.option_info.input_text_resheight), motif.option_info, motif.optionbgdef, 'string'))
1042+ if height ~= nil then
1043+ config.Width = width
1044+ config.Height = height
1045+ sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
1046+ if (height / 3 * 4) ~= width then
1047+ main.f_warning(main.f_extractText(motif.warning_info.text_res), motif.option_info, motif.optionbgdef)
1048+ end
1049+ modified = 1
1050+ needReload = 1
1051+ else
1052+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1053+ end
1054+ else
1055+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1056+ end
1057+ break
1058+ --Resolution
1059+ else
1060+ sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
1061+ config.Width = t[item].x
1062+ config.Height = t[item].y
1063+ if (config.Height / 3 * 4) ~= config.Width then
1064+ main.f_warning(main.f_extractText(motif.warning_info.text_res), motif.option_info, motif.optionbgdef)
1065+ end
1066+ modified = 1
1067+ needReload = 1
1068+ break
1069+ end
1070+ end
1071+ options.f_menuCommon2(cursorPosY, moveTxt, item, t)
1072+ end
1073+end
1074+
1075+--;===========================================================
1076+--; ENGINE SETTINGS
1077+--;===========================================================
1078+local t_engineCfg = {
1079+ {data = textImgNew(), itemname = 'allowdebugkeys', displayname = motif.option_info.menu_itemname_engine_allowdebugkeys, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.AllowDebugKeys, motif.option_info.menu_itemname_enabled, motif.option_info.menu_itemname_disabled)},
1080+ {data = textImgNew(), itemname = 'simulmode', displayname = motif.option_info.menu_itemname_gameplay_simulmode, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.SimulMode, motif.option_info.menu_itemname_disabled, motif.option_info.menu_itemname_enabled)},
1081+ {data = textImgNew(), itemname = 'empty', displayname = ' '},
1082+ {data = textImgNew(), itemname = 'helpermax', displayname = motif.option_info.menu_itemname_video_helpermax, vardata = textImgNew(), vardisplay = config.HelperMax},
1083+ {data = textImgNew(), itemname = 'playerprojectilemax', displayname = motif.option_info.menu_itemname_video_playerprojectilemax, vardata = textImgNew(), vardisplay = config.PlayerProjectileMax},
1084+ {data = textImgNew(), itemname = 'explodmax', displayname = motif.option_info.menu_itemname_video_explodmax, vardata = textImgNew(), vardisplay = config.ExplodMax},
1085+ {data = textImgNew(), itemname = 'afterimagemax', displayname = motif.option_info.menu_itemname_video_afterimagemax, vardata = textImgNew(), vardisplay = config.AfterImageMax},
1086+ {data = textImgNew(), itemname = 'empty', displayname = ' '},
1087+ {data = textImgNew(), itemname = 'zoomactive', displayname = motif.option_info.menu_itemname_video_zoomactive, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.ZoomActive)},
1088+ {data = textImgNew(), itemname = 'maxzoomout', displayname = motif.option_info.menu_itemname_video_maxzoomout, vardata = textImgNew(), vardisplay = config.ZoomMin},
1089+ {data = textImgNew(), itemname = 'maxzoomin', displayname = motif.option_info.menu_itemname_video_maxzoomin, vardata = textImgNew(), vardisplay = config.ZoomMax},
1090+ {data = textImgNew(), itemname = 'zoomspeed', displayname = motif.option_info.menu_itemname_video_zoomspeed, vardata = textImgNew(), vardisplay = config.ZoomSpeed},
1091+ {data = textImgNew(), itemname = 'empty', displayname = ' '},
1092+ {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_video_back},
1093+}
1094+t_engineCfg = main.f_cleanTable(t_engineCfg)
1095+
1096+function options.f_engineCfg()
1097+ main.f_cmdInput()
1098+ local cursorPosY = 1
1099+ local moveTxt = 0
1100+ local item = 1
1101+ local t = t_engineCfg
1102+ textImgSetText(txt_title, motif.option_info.title_text_engine)
1103+ while true do
1104+ cursorPosY, moveTxt, item = options.f_menuCommon1(cursorPosY, moveTxt, item, t)
1105+ if esc() then
1106+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1107+ textImgSetText(txt_title, motif.option_info.title_text_main)
1108+ break
1109+ --HelperMax
1110+ elseif t[item].itemname == 'helpermax' then
1111+ if commandGetState(main.p1Cmd, 'r') then
1112+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1113+ config.HelperMax = config.HelperMax + 10
1114+ t[item].vardisplay = config.HelperMax
1115+ modified = 1
1116+ needReload = 1
1117+ elseif commandGetState(main.p1Cmd, 'l') and config.HelperMax > 10 then
1118+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1119+ config.HelperMax = config.HelperMax - 10
1120+ t[item].vardisplay = config.HelperMax
1121+ modified = 1
1122+ needReload = 1
1123+ end
1124+ --PlayerProjectileMax
1125+ elseif t[item].itemname == 'playerprojectilemax' then
1126+ if commandGetState(main.p1Cmd, 'r') then
1127+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1128+ config.PlayerProjectileMax = config.PlayerProjectileMax + 10
1129+ t[item].vardisplay = config.PlayerProjectileMax
1130+ modified = 1
1131+ needReload = 1
1132+ elseif commandGetState(main.p1Cmd, 'l') and config.PlayerProjectileMax > 10 then
1133+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1134+ config.PlayerProjectileMax = config.PlayerProjectileMax - 10
1135+ t[item].vardisplay = config.PlayerProjectileMax
1136+ modified = 1
1137+ needReload = 1
1138+ end
1139+ --ExplodMax
1140+ elseif t[item].itemname == 'explodmax' then
1141+ if commandGetState(main.p1Cmd, 'r') then
1142+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1143+ config.ExplodMax = config.ExplodMax + 10
1144+ t[item].vardisplay = config.ExplodMax
1145+ modified = 1
1146+ needReload = 1
1147+ elseif commandGetState(main.p1Cmd, 'l') and config.ExplodMax > 10 then
1148+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1149+ config.ExplodMax = config.ExplodMax - 10
1150+ t[item].vardisplay = config.ExplodMax
1151+ modified = 1
1152+ needReload = 1
1153+ end
1154+ --AfterImageMax
1155+ elseif t[item].itemname == 'afterimagemax' then
1156+ if commandGetState(main.p1Cmd, 'r') then
1157+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1158+ config.AfterImageMax = config.AfterImageMax + 1
1159+ t[item].vardisplay = config.AfterImageMax
1160+ modified = 1
1161+ needReload = 1
1162+ elseif commandGetState(main.p1Cmd, 'l') and config.AfterImageMax > 1 then
1163+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1164+ config.AfterImageMax = config.AfterImageMax - 1
1165+ t[item].vardisplay = config.AfterImageMax
1166+ modified = 1
1167+ needReload = 1
1168+ end
1169+ --Zoom Active
1170+ elseif t[item].itemname == 'zoomactive' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
1171+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1172+ if config.ZoomActive then
1173+ config.ZoomActive = false
1174+ else
1175+ config.ZoomActive = true
1176+ end
1177+ t[item].vardisplay = options.f_boolDisplay(config.ZoomActive)
1178+ modified = 1
1179+ --Default Max Zoom Out
1180+ elseif t[item].itemname == 'maxzoomout' then
1181+ if commandGetState(main.p1Cmd, 'r') and config.ZoomMin < 10 then
1182+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1183+ config.ZoomMin = options.f_precision(config.ZoomMin + 0.05, '%.02f')
1184+ t[item].vardisplay = config.ZoomMin
1185+ modified = 1
1186+ elseif commandGetState(main.p1Cmd, 'l') and config.ZoomMin > 0.05 then
1187+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1188+ config.ZoomMin = options.f_precision(config.ZoomMin - 0.05, '%.02f')
1189+ t[item].vardisplay = config.ZoomMin
1190+ modified = 1
1191+ end
1192+ --Default Max Zoom In
1193+ elseif t[item].itemname == 'maxzoomin' then
1194+ if commandGetState(main.p1Cmd, 'r') and config.ZoomMax < 10 then
1195+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1196+ config.ZoomMax = options.f_precision(config.ZoomMax + 0.05, '%.02f')
1197+ t[item].vardisplay = config.ZoomMax
1198+ modified = 1
1199+ elseif commandGetState(main.p1Cmd, 'l') and config.ZoomMax > 0.05 then
1200+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1201+ config.ZoomMax = options.f_precision(config.ZoomMax - 0.05, '%.02f')
1202+ t[item].vardisplay = config.ZoomMax
1203+ modified = 1
1204+ end
1205+ --Default Zoom Speed
1206+ elseif t[item].itemname == 'zoomspeed' then
1207+ if commandGetState(main.p1Cmd, 'r') and config.ZoomSpeed < 10 then
1208+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1209+ config.ZoomSpeed = options.f_precision(config.ZoomSpeed + 0.1, '%.01f')
1210+ t[item].vardisplay = config.ZoomSpeed
1211+ modified = 1
1212+ elseif commandGetState(main.p1Cmd, 'l') and config.ZoomSpeed > 0.1 then
1213+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1214+ config.ZoomSpeed = options.f_precision(config.ZoomSpeed - 0.1, '%.01f')
1215+ t[item].vardisplay = config.ZoomSpeed
1216+ modified = 1
1217+ end
1218+ -- Leagcy TAG Mode
1219+ elseif t[item].itemname == 'simulmode' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
1220+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1221+ if config.SimulMode then
1222+ config.SimulMode = false
1223+ else
1224+ config.SimulMode = true
1225+ end
1226+ t[item].vardisplay = options.f_boolDisplay(config.SimulMode, motif.option_info.menu_itemname_disabled, motif.option_info.menu_itemname_enabled)
1227+ modified = 1
1228+ needReload = 1
1229+ -- Allow Debug Keys
1230+ elseif t[item].itemname == 'allowdebugkeys' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
1231+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1232+ if config.AllowDebugKeys then
1233+ config.AllowDebugKeys = false
1234+ else
1235+ config.AllowDebugKeys = true
1236+ end
1237+ t[item].vardisplay = options.f_boolDisplay(config.AllowDebugKeys, motif.option_info.menu_itemname_enabled, motif.option_info.menu_itemname_disabled)
1238+ modified = 1
1239+ needReload = 1
1240+ --Back
1241+ elseif t[item].itemname == 'back' and main.f_btnPalNo(main.p1Cmd) > 0 then
1242+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1243+ textImgSetText(txt_title, motif.option_info.title_text_main)
1244+ break
1245+ end
1246+ options.f_menuCommon2(cursorPosY, moveTxt, item, t)
1247+ end
1248+end
1249+
1250+--;===========================================================
1251+--; INPUT SETTINGS
1252+--;===========================================================
1253+local t_inputCfg = {
1254+ {data = textImgNew(), itemname = 'p1keyboard', displayname = motif.option_info.menu_itemname_input_p1keyboard},
1255+ {data = textImgNew(), itemname = 'p1gamepad', displayname = motif.option_info.menu_itemname_input_p1gamepad},
1256+ {data = textImgNew(), itemname = 'p2keyboard', displayname = motif.option_info.menu_itemname_input_p2keyboard},
1257+ {data = textImgNew(), itemname = 'p2gamepad', displayname = motif.option_info.menu_itemname_input_p2gamepad},
1258+ {data = textImgNew(), itemname = 'empty', displayname = ' '},
1259+ {data = textImgNew(), itemname = 'defaultvalues', displayname = motif.option_info.menu_itemname_input_default},
1260+ {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_input_back},
1261+}
1262+t_inputCfg = main.f_cleanTable(t_inputCfg)
1263+
1264+function options.f_inputCfg()
1265+ main.f_cmdInput()
1266+ local cursorPosY = 1
1267+ local moveTxt = 0
1268+ local item = 1
1269+ local t = t_inputCfg
1270+ textImgSetText(txt_title, motif.option_info.title_text_input)
1271+ while true do
1272+ cursorPosY, moveTxt, item = options.f_menuCommon1(cursorPosY, moveTxt, item, t)
1273+ if esc() then
1274+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1275+ textImgSetText(txt_title, motif.option_info.title_text_main)
1276+ break
1277+ elseif main.f_btnPalNo(main.p1Cmd) > 0 then
1278+ --P1 Keyboard
1279+ if t[item].itemname == 'p1keyboard' then
1280+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1281+ options.f_keyCfg(1, -1)
1282+ --P1 Gamepad
1283+ elseif t[item].itemname == 'p1gamepad' then
1284+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1285+ options.f_keyCfg(1, 0)
1286+ --P2 Keyboard
1287+ elseif t[item].itemname == 'p2keyboard' then
1288+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1289+ options.f_keyCfg(2, -1)
1290+ --P2 Gamepad
1291+ elseif t[item].itemname == 'p2gamepad' then
1292+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1293+ options.f_keyCfg(2, 1)
1294+ --Default Values
1295+ elseif t[item].itemname == 'defaultvalues' then
1296+ sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
1297+ options.f_keyDefault()
1298+ modified = 1
1299+ needReload = 1
1300+ --Back
1301+ elseif t[item].itemname == 'back' then
1302+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1303+ textImgSetText(txt_title, motif.option_info.title_text_main)
1304+ break
1305+ end
1306+ end
1307+ options.f_menuCommon2(cursorPosY, moveTxt, item, t)
1308+ end
1309+end
1310+
1311+--;===========================================================
1312+--; KEY SETTINGS
1313+--;===========================================================
1314+local t_keyCfg = {
1315+ {data = textImgNew(), itemname = 'up', displayname = motif.option_info.menu_itemname_key_up, vardata = textImgNew(), vardisplay = ''},
1316+ {data = textImgNew(), itemname = 'down', displayname = motif.option_info.menu_itemname_key_down, vardata = textImgNew(), vardisplay = ''},
1317+ {data = textImgNew(), itemname = 'left', displayname = motif.option_info.menu_itemname_key_left, vardata = textImgNew(), vardisplay = ''},
1318+ {data = textImgNew(), itemname = 'right', displayname = motif.option_info.menu_itemname_key_right, vardata = textImgNew(), vardisplay = ''},
1319+ {data = textImgNew(), itemname = 'a', displayname = motif.option_info.menu_itemname_key_a, vardata = textImgNew(), vardisplay = ''},
1320+ {data = textImgNew(), itemname = 'b', displayname = motif.option_info.menu_itemname_key_b, vardata = textImgNew(), vardisplay = ''},
1321+ {data = textImgNew(), itemname = 'c', displayname = motif.option_info.menu_itemname_key_c, vardata = textImgNew(), vardisplay = ''},
1322+ {data = textImgNew(), itemname = 'x', displayname = motif.option_info.menu_itemname_key_x, vardata = textImgNew(), vardisplay = ''},
1323+ {data = textImgNew(), itemname = 'y', displayname = motif.option_info.menu_itemname_key_y, vardata = textImgNew(), vardisplay = ''},
1324+ {data = textImgNew(), itemname = 'z', displayname = motif.option_info.menu_itemname_key_z, vardata = textImgNew(), vardisplay = ''},
1325+ {data = textImgNew(), itemname = 'start', displayname = motif.option_info.menu_itemname_key_start, vardata = textImgNew(), vardisplay = ''},
1326+ {data = textImgNew(), itemname = 'v', displayname = motif.option_info.menu_itemname_key_v, vardata = textImgNew(), vardisplay = ''},
1327+ {data = textImgNew(), itemname = 'w', displayname = motif.option_info.menu_itemname_key_w, vardata = textImgNew(), vardisplay = ''},
1328+ {data = textImgNew(), itemname = 'empty', displayname = ' '},
1329+ {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_key_back},
1330+}
1331+t_keyCfg = main.f_cleanTable(t_keyCfg)
1332+
1333+function options.f_keyCfg(playerNo, controller)
1334+ main.f_cmdInput()
1335+ local cursorPosY = 1
1336+ local moveTxt = 0
1337+ local item = 1
1338+ local t = t_keyCfg
1339+ textImgSetText(txt_title, motif.option_info.title_text_key)
1340+ for i = 1, #t_keyCfg do
1341+ if controller == -1 then
1342+ t_keyCfg[i].vardisplay = config.KeyConfig[playerNo].Buttons[i]
1343+ else
1344+ t_keyCfg[i].vardisplay = config.JoystickConfig[playerNo].Buttons[i]
1345+ end
1346+ end
1347+ while true do
1348+ cursorPosY, moveTxt, item = options.f_menuCommon1(cursorPosY, moveTxt, item, t)
1349+ if esc() then
1350+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1351+ textImgSetText(txt_title, motif.option_info.title_text_input)
1352+ break
1353+ elseif main.f_btnPalNo(main.p1Cmd) > 0 then
1354+ --Back
1355+ if t[item].itemname == 'back' then
1356+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1357+ textImgSetText(txt_title, motif.option_info.title_text_input)
1358+ break
1359+ --Buttons
1360+ else
1361+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1362+ local key = main.f_input(main.f_extractText(motif.option_info.input_text_key), motif.option_info, motif.optionbgdef, 'key')
1363+ if (controller == -1 and key ~= '') or (controller ~= -1 and tonumber(key) ~= nil) then
1364+ sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
1365+ t[item].vardisplay = key
1366+ if controller == -1 then
1367+ config.KeyConfig[playerNo].Buttons[item] = key
1368+ else
1369+ config.JoystickConfig[playerNo].Buttons[item] = key
1370+ end
1371+ else
1372+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1373+ end
1374+ end
1375+ modified = 1
1376+ needReload = 1
1377+ end
1378+ options.f_menuCommon2(cursorPosY, moveTxt, item, t)
1379+ end
1380+end
1381+
1382+--;===========================================================
1383+--; AUDIO SETTINGS
1384+--;===========================================================
1385+local t_audioCfg = {
1386+ {data = textImgNew(), itemname = 'mastervolume', displayname = motif.option_info.menu_itemname_audio_mastervolume, vardata = textImgNew(), vardisplay = config.MasterVolume .. '%'},
1387+ {data = textImgNew(), itemname = 'bgmvolume', displayname = motif.option_info.menu_itemname_audio_bgmvolume, vardata = textImgNew(), vardisplay = config.BgmVolume .. '%'},
1388+ {data = textImgNew(), itemname = 'sfxvolume', displayname = motif.option_info.menu_itemname_audio_sfxvolume, vardata = textImgNew(), vardisplay = config.WavVolume .. '%'},
1389+ {data = textImgNew(), itemname = 'audioducking', displayname = motif.option_info.menu_itemname_audio_audioducking, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.AudioDucking, motif.option_info.menu_itemname_enabled, motif.option_info.menu_itemname_disabled)},
1390+ {data = textImgNew(), itemname = 'empty', displayname = ' '},
1391+ {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_video_back},
1392+}
1393+t_audioCfg = main.f_cleanTable(t_audioCfg)
1394+
1395+function options.f_audioCfg()
1396+ main.f_cmdInput()
1397+ local cursorPosY = 1
1398+ local moveTxt = 0
1399+ local item = 1
1400+ local t = t_audioCfg
1401+ textImgSetText(txt_title, motif.option_info.title_text_audio)
1402+ while true do
1403+ cursorPosY, moveTxt, item = options.f_menuCommon1(cursorPosY, moveTxt, item, t)
1404+ if esc() then
1405+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1406+ textImgSetText(txt_title, motif.option_info.title_text_main)
1407+ break
1408+ -- Master Volume
1409+ elseif t[item].itemname == 'mastervolume' then
1410+ if commandGetState(main.p1Cmd, 'r') and config.MasterVolume < 200 then
1411+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1412+ config.MasterVolume = config.MasterVolume + 1
1413+ t[item].vardisplay = config.MasterVolume .. '%'
1414+ modified = 1
1415+ needReload = 1
1416+ elseif commandGetState(main.p1Cmd, 'l') and config.MasterVolume > 0 then
1417+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1418+ config.MasterVolume = config.MasterVolume - 1
1419+ t[item].vardisplay = config.MasterVolume .. '%'
1420+ modified = 1
1421+ needReload = 1
1422+ end
1423+ -- BGM Volume
1424+ elseif t[item].itemname == 'bgmvolume' then
1425+ if commandGetState(main.p1Cmd, 'r') and config.BgmVolume < 100 then
1426+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1427+ config.BgmVolume = config.BgmVolume + 1
1428+ t[item].vardisplay = config.BgmVolume .. '%'
1429+ modified = 1
1430+ needReload = 1
1431+ elseif commandGetState(main.p1Cmd, 'l') and config.BgmVolume > 0 then
1432+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1433+ config.BgmVolume = config.BgmVolume - 1
1434+ t[item].vardisplay = config.BgmVolume .. '%'
1435+ modified = 1
1436+ needReload = 1
1437+ end
1438+ -- SFX Volume
1439+ elseif t[item].itemname == 'sfxvolume' then
1440+ if commandGetState(main.p1Cmd, 'r') and config.WavVolume < 100 then
1441+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1442+ config.WavVolume = config.WavVolume + 1
1443+ t[item].vardisplay = config.WavVolume .. '%'
1444+ modified = 1
1445+ needReload = 1
1446+ elseif commandGetState(main.p1Cmd, 'l') and config.WavVolume > 0 then
1447+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1448+ config.WavVolume = config.WavVolume - 1
1449+ t[item].vardisplay = config.WavVolume .. '%'
1450+ modified = 1
1451+ needReload = 1
1452+ end
1453+ -- Audio Ducking
1454+ elseif t[item].itemname == 'audioducking' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
1455+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1456+ if config.AudioDucking then
1457+ config.AudioDucking = false
1458+ else
1459+ config.AudioDucking = true
1460+ end
1461+ t[item].vardisplay = options.f_boolDisplay(config.AudioDucking, motif.option_info.menu_itemname_enabled, motif.option_info.menu_itemname_disabled)
1462+ modified = 1
1463+ needReload = 1
1464+ --Back
1465+ elseif t[item].itemname == 'back' and main.f_btnPalNo(main.p1Cmd) > 0 then
1466+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1467+ textImgSetText(txt_title, motif.option_info.title_text_main)
1468+ break
1469+ end
1470+ options.f_menuCommon2(cursorPosY, moveTxt, item, t)
1471+ end
1472+end
1473+
1474+return options
--- /dev/null
+++ b/script/randomtest.lua
@@ -0,0 +1,273 @@
1+-- Used for demo mode and generates AI rank data
2+-- Demo mode uses AutoLevel a GO function that ranks characters based on his number of loses vs wins
3+-- AutoLevel is pallete dependent so if a char has a 12th pallete OP mode that mode can have more rank than his normal one
4+
5+local randomtest = {}
6+
7+function randomtest.strtrim(s)
8+ return string.match(s,'^()%s*$') and '' or string.match(s,'^%s*(.*%S)')
9+end
10+
11+function randomtest.map(func, table)
12+ local dest = {}
13+ for k, v in pairs(table) do
14+ dest[k] = func(v)
15+ end
16+ return dest
17+end
18+
19+-- Ints variables
20+local tuyoiBorder = 0
21+local juuni = 12
22+local moudeta = {}
23+local rank = 0
24+local saikyou = false
25+local roster = {}
26+local debugText = ''
27+local numChars = 0
28+local nextChar = 1
29+
30+function randomtest.addMoudeta(rank)
31+ moudeta[#moudeta + 1] = rank
32+ local max =
33+ math.floor(
34+ numChars / (math.min(numChars / (juuni*10) + 3, juuni)*juuni))
35+ while #moudeta > max do
36+ table.remove(moudeta, 1)
37+ end
38+end
39+
40+
41+function randomtest.randRank()
42+ local r = 0
43+ while true do
44+ r = math.random(1, tuyoiBorder + juuni - 2);
45+ local notbroken = true
46+ for i = 1, #moudeta do
47+ if math.abs(moudeta[i] - r) <= math.floor(juuni/3) then
48+ notbroken = false
49+ break
50+ end
51+ end
52+ if notbroken then
53+ break
54+ end
55+ end
56+ return r
57+end
58+
59+function randomtest.eachAllChars(f)
60+ for cel = 1, #main.t_randomChars do
61+ f(cel-1)
62+ end
63+end
64+
65+function randomtest.rakuBenry()
66+ local alf = 'save/autolevel.save'
67+ local veljnz = {}
68+ local winct = {}
69+ local buf = '\239\187\191'
70+ local fp = io.open(alf, 'r')
71+ if fp then
72+ for line in fp:lines() do
73+ local tmp = main.f_strsplit(',', line)
74+ if #tmp >= 2 then
75+ for i = 1, 4 do
76+ if i == 4 then
77+ tmp[1] = string.sub(tmp[1], 4)
78+ else
79+ if string.byte(tmp[1], i) ~= string.byte(buf, i) then break end
80+ end
81+ end
82+ winct[tmp[1]] = randomtest.map(tonumber, main.f_strsplit(' ', randomtest.strtrim(tmp[2])))
83+ end
84+ end
85+ io.close(fp)
86+ end
87+ numChars = 0
88+ randomtest.eachAllChars(function(cel)
89+ numChars = numChars + 1
90+ end)
91+ local tuyoninzu = math.floor(numChars / (juuni*10))
92+ if tuyoninzu < juuni - 1 then
93+ tuyoiBorder = math.floor(numChars / (tuyoninzu + 1))
94+ tuyoninzu = juuni - 1
95+ else
96+ tuyoiBorder = math.floor(numChars / juuni)
97+ end
98+ local total = 0
99+ local zero ={}
100+ local tsuyoshi = {}
101+ local rand = {}
102+ local kai = {}
103+ local bimyou = {}
104+ local tuyocnt = 0
105+ local ran = randomtest.randRank()
106+ randomtest.eachAllChars(function(cel)
107+ if #veljnz < cel*12 then
108+ for i = #veljnz + 1, cel*12 do
109+ veljnz[i] = 0
110+ end
111+ end
112+ local wins = winct[getCharFileName(cel)]
113+ local tmp = 0
114+ for j = 1, 12 do
115+ if wins and j <= #wins then
116+ total = total + wins[j]
117+ veljnz[cel*12 + j] = wins[j]
118+ tmp = tmp + wins[j]
119+ else
120+ veljnz[cel*12 + j] = 0
121+ end
122+ end
123+ if tmp >= tuyoiBorder then tuyocnt = tuyocnt + 1 end
124+ if tmp >= tuyoiBorder - juuni then table.insert(tsuyoshi, cel) end
125+ if tmp >= 1 and tmp <= juuni then table.insert(bimyou, cel) end
126+ if tmp > ran-juuni and tmp <= ran then table.insert(rand, cel) end
127+ if tmp == 0 then table.insert(zero, cel) end
128+ if tmp < 0 then table.insert(kai, cel) end
129+ end)
130+ function charAdd(cList, numAdd)
131+ if numAdd <= 0 then return end
132+ for i = 1, numAdd do
133+ if #cList == 0 then break end
134+ local cidx = math.random(1, #cList)
135+ table.insert(roster, cList[cidx])
136+ table.remove(cList, cidx)
137+ end
138+ end
139+ roster = {}
140+ nextChar = 1
141+ debugText = ''
142+ local numZero = #zero
143+ if numZero > 0 then
144+ charAdd(zero, numZero)
145+ charAdd(kai, tuyoninzu - numZero)
146+ rank = 0
147+ elseif #bimyou >= math.max(tuyoninzu*20, math.floor((numChars*3)/20)) then
148+ charAdd(bimyou, #bimyou)
149+ rank = juuni
150+ else
151+ for n = 1, 3 do
152+ if #rand >= tuyoninzu then break end
153+ rand = {}
154+ ran = randomtest.randRank()
155+ randomtest.eachAllChars(function(cel)
156+ local tmp = 0
157+ for j = 1, 12 do
158+ tmp = tmp + veljnz[cel*12 + j]
159+ end
160+ if tmp > ran-juuni and tmp <= ran then table.insert(rand, cel) end
161+ end)
162+ end
163+ debugText = ran .. ' ' .. #rand
164+ if #rand >= tuyoninzu then
165+ charAdd(rand, #rand)
166+ rank = ran
167+ randomtest.addMoudeta(rank)
168+ elseif tuyocnt >= tuyoninzu then
169+ charAdd(tsuyoshi, #tsuyoshi)
170+ rank = tuyoiBorder+juuni-1
171+ else
172+ randomtest.addMoudeta(tuyoiBorder + (juuni-2) - math.floor(juuni/3))
173+ charAdd(kai, #kai)
174+ rank = -1
175+ end
176+ end
177+ if numZero == 0 then
178+ while total ~= 0 do
179+ local i = math.random(1, #veljnz)
180+ if total > 0 then
181+ veljnz[i] = veljnz[i] - 1
182+ total = total - 1
183+ else
184+ veljnz[i] = veljnz[i] + 1
185+ total = total + 1
186+ end
187+ end
188+ end
189+ randomtest.eachAllChars(function(cel)
190+ buf = buf .. getCharFileName(cel) .. ','
191+ for j = 1, 12 do
192+ buf = buf .. ' ' .. veljnz[cel*12 + j]
193+ end
194+ buf = buf .. '\r\n'
195+ end)
196+ local alv = io.open(alf, 'wb')
197+ alv:write(buf)
198+ io.close(alv)
199+end
200+
201+function randomtest.randSel(pno, winner)
202+ if winner > 0 and (pno == winner) == not saikyou then return end
203+ local team
204+ if rank == 0 or rank == 12 or saikyou then
205+ team = 0
206+ elseif rank < 0 then
207+ team = math.random(0, 2)
208+ else
209+ team = math.random(0, 1)*2
210+ end
211+ setTeamMode(pno, team, math.random(1, 4))
212+ local tmp = 0
213+ while tmp < 2 do
214+ tmp = selectChar(pno, roster[nextChar], getCharRandomPalette(roster[nextChar]))
215+ nextChar = nextChar + 1
216+ if nextChar > #roster then nextChar = 1 end
217+ end
218+end
219+
220+-- Writes the ranked AI levels to a save file
221+-- This file is not used by AutoLevel
222+function randomtest.rosterTxt()
223+ local str = "Rank: " .. rank .. ' ' .. debugText
224+ for i = 1, #roster do
225+ str = str .. '\n' .. getCharFileName(roster[i])
226+ end
227+ local dscr = io.open('save/AI_Rank.save', 'w')
228+ dscr:write(str)
229+ io.close(dscr)
230+end
231+
232+-- Sets AIs to level 8 (MAX level) and ints AutoLevel
233+function randomtest.init()
234+ for i = 1, 8 do
235+ setCom(i, 8)
236+ end
237+ setAutoLevel(true)
238+ setMatchNo(1)
239+ selectStage(0)
240+ randomtest.rakuBenry()
241+ winner = 0
242+ wins = 0
243+ randomtest.rosterTxt()
244+ nextChar = 1
245+ saikyou = rank == tuyoiBorder+juuni-1
246+end
247+
248+-- This is executed first
249+function randomtest.run()
250+ randomtest.init()
251+ refresh()
252+ while not esc() do
253+ randomtest.randSel(1, winner)
254+ randomtest.randSel(2, winner)
255+ loadStart()
256+ local oldwinner = winner
257+ winner = game()
258+ if winner < 0 or esc() then break end
259+ oldwins = wins
260+ wins = wins + 1
261+ if winner ~= oldwinner then
262+ wins = 1
263+ setHomeTeam(winner == 1 and 2 or 1)
264+ end
265+ setMatchNo(wins)
266+ if winner <= 0 or wins >= 20 or wins == oldwins then
267+ randomtest.init()
268+ end
269+ refresh()
270+ end
271+end
272+
273+return randomtest
--- /dev/null
+++ b/script/screenpack.lua
@@ -0,0 +1,75 @@
1+-- Screenpack config file
2+
3+function main.IntLocalcoordValues()
4+
5+main.SP_Localcoord = {}
6+main.LB_Localcoord = {}
7+main.SP_Localcoord43 = {}
8+main.LB_Localcoord43 = {}
9+
10+main.SP_Localcoord[0] = 320
11+main.SP_Localcoord[1] = 240
12+main.LB_Localcoord[0] = 320
13+main.LB_Localcoord[1] = 240
14+
15+main.LB_ScreenWidth = 320
16+main.LB_ScreenDiference = 0
17+
18+main.screenOverscan = 0
19+main.normalSpriteCenter = 0
20+
21+main.SP_Localcoord43[0] = 320
22+main.LB_Localcoord43[0] = 240
23+
24+main.SP_Center = 0
25+
26+end
27+
28+function main.CalculateLocalcoordValues()
29+ if main.SP_Localcoord[0] >= main.SP_Localcoord[1] then
30+ main.SP_Localcoord43[0] = (main.SP_Localcoord[1] / 3) * 4
31+ else
32+ main.SP_Localcoord43[0] = (main.SP_Localcoord[0] / 4) * 3
33+ end
34+
35+ if main.LB_Localcoord[0] >= main.LB_Localcoord[1] then
36+ main.LB_Localcoord43[0] = (main.LB_Localcoord[1] / 3) * 4
37+ else
38+ main.LB_Localcoord43[0] = (main.LB_Localcoord[0] / 4) * 3
39+ end
40+
41+ main.SP_Localcoord_X_Dif = -math.floor( (( main.SP_Localcoord[0] / (main.SP_Localcoord43[0] / 320) ) - 320) / 2 )
42+
43+ main.LB_ScreenWidth = config.Width / (config.Height / 240)
44+ main.LB_ScreenDiference = (main.LB_ScreenWidth - 320) / (main.LB_ScreenWidth / 320)
45+
46+end
47+
48+function main.IntLifebarScale()
49+ if config.LocalcoordScalingType == 0 then
50+ setLifebarOffsetX( - main.LB_ScreenDiference / 2)
51+ setLuaLifebarScale(main.LB_ScreenWidth / main.LB_Localcoord43[0])
52+ else
53+ setLifebarOffsetX((main.LB_Localcoord43[0] - main.LB_Localcoord[0]) / 2)
54+ setLuaLifebarScale(320 / main.LB_Localcoord43[0])
55+ end
56+end
57+
58+function main.SetScaleValues()
59+ setLuaSpriteScale(main.SP_Localcoord43[0] / 320)
60+ setLuaSpriteOffsetX(main.SP_Localcoord_X_Dif)
61+ setLuaSmallPortraitScale(main.SP_Localcoord43[0] / main.SP_Localcoord[0])
62+ setLuaBigPortraitScale(main.SP_Localcoord43[0] / main.SP_Localcoord[0])
63+ main.normalSpriteCenter = main.SP_Center
64+ main.screenOverscan = 0
65+end
66+
67+
68+function main.SetDefaultScale()
69+ setLuaSpriteScale(1)
70+ setLuaSpriteOffsetX(0)
71+ setLuaSmallPortraitScale(1)
72+ setLuaBigPortraitScale(1)
73+ main.normalSpriteCenter = 0
74+ main.screenOverscan = 0
75+end
\ No newline at end of file
--- /dev/null
+++ b/script/select.lua
@@ -0,0 +1,2603 @@
1+
2+local select = {}
3+
4+setSelColRow(motif.select_info.columns, motif.select_info.rows)
5+
6+--not used for now
7+--setShowEmptyCells(motif.select_info.showemptyboxes)
8+--setRandomSpr(motif.selectbgdef.spr_data, motif.select_info.cell_random_spr[1], motif.select_info.cell_random_spr[2], motif.select_info.cell_random_scale[1], motif.select_info.cell_random_scale[2])
9+--setCellSpr(motif.selectbgdef.spr_data, motif.select_info.cell_bg_spr[1], motif.select_info.cell_bg_spr[2], motif.select_info.cell_bg_scale[1], motif.select_info.cell_bg_scale[2])
10+
11+setSelCellSize(motif.select_info.cell_size[1] + motif.select_info.cell_spacing, motif.select_info.cell_size[2] + motif.select_info.cell_spacing)
12+setSelCellScale(motif.select_info.portrait_scale[1], motif.select_info.portrait_scale[2])
13+
14+--default team count after starting the game
15+local p1NumTurns = 2
16+local p1NumSimul = 2
17+local p1NumTag = 2
18+local p2NumTurns = 2
19+local p2NumSimul = 2
20+local p2NumTag = 2
21+--default team mode after starting the game
22+local p1TeamMenu = 1
23+local p2TeamMenu = 1
24+--let cursor wrap around
25+local wrappingX = false
26+local wrappingY = false
27+if motif.select_info.wrapping == 1 then
28+ if motif.select_info.wrapping_x == 1 then
29+ wrappingX = true
30+ end
31+ if motif.select_info.wrapping_y == 1 then
32+ wrappingY = true
33+ end
34+end
35+--initialize other local variables
36+local t_p1Selected = {}
37+local t_p2Selected = {}
38+local t_roster = {}
39+local t_aiRamp = {}
40+local continue = false
41+local p1Cell = false
42+local p2Cell = false
43+local p1TeamEnd = false
44+local p1SelEnd = false
45+local p2TeamEnd = false
46+local p2SelEnd = false
47+local selScreenEnd = false
48+local stageEnd = false
49+local coopEnd = false
50+local restoreTeam = false
51+local resetgrid = false
52+local teamMode = 0
53+local numChars = 0
54+local p1NumChars = 0
55+local p2NumChars = 0
56+local matchNo = 0
57+local p1SelX = 0
58+local p1SelY = 0
59+local p2SelX = 0
60+local p2SelY = 0
61+local p1FaceOffset = 0
62+local p2FaceOffset = 0
63+local p1RowOffset = 0
64+local p2RowOffset = 0
65+local winner = 0
66+local t_gameStats = {}
67+local winCnt = 0
68+local looseCnt = 0
69+local p1FaceX = 0
70+local p1FaceY = 0
71+local p2FaceX = 0
72+local p2FaceY = 0
73+local p1TeamMode = 0
74+local p2TeamMode = 0
75+local lastMatch = 0
76+local stageNo = 0
77+local stageList = 0
78+
79+local cnt = motif.select_info.columns + 1
80+local row = 1
81+local col = 0
82+local t_grid = {}
83+t_grid[row] = {}
84+for i = 1, (motif.select_info.rows + motif.select_info.rows_scrolling) * motif.select_info.columns do
85+ if i == cnt then
86+ row = row + 1
87+ cnt = cnt + motif.select_info.columns
88+ t_grid[row] = {}
89+ end
90+ col = #t_grid[row] + 1
91+ t_grid[row][col] = {num = i - 1, x = (col - 1) * (motif.select_info.cell_size[1] + motif.select_info.cell_spacing), y = (row - 1) * (motif.select_info.cell_size[2] + motif.select_info.cell_spacing)}
92+ if main.t_selChars[i].char ~= nil then
93+ t_grid[row][col].char = main.t_selChars[i].char
94+ t_grid[row][col].hidden = main.t_selChars[i].hidden
95+ main.t_selChars[i].row = row
96+ main.t_selChars[i].col = col
97+ end
98+end
99+
100+--;===========================================================
101+--; COMMON FUNCTIONS
102+--;===========================================================
103+function select.f_setZoom()
104+ local zoom = config.ZoomActive
105+ if main.t_selChars[t_p2Selected[1].cel + 1].zoom ~= nil then
106+ if main.t_selChars[t_p2Selected[1].cel + 1].zoom == 1 then
107+ zoom = true
108+ else
109+ zoom = false
110+ end
111+ elseif main.t_selStages[stageNo] ~= nil and main.t_selStages[stageNo].zoom ~= nil then
112+ if main.t_selChars[stageNo].zoom == 1 then
113+ zoom = true
114+ else
115+ zoom = false
116+ end
117+ end
118+ setZoom(zoom)
119+ local zoomMin = config.ZoomMin
120+ if main.t_selStages[stageNo].zoommin ~= nil then
121+ zoomMin = main.t_selStages[stageNo].zoommin
122+ end
123+ setZoomMin(zoomMin)
124+ local zoomMax = config.ZoomMax
125+ if main.t_selStages[stageNo].zoommax ~= nil then
126+ zoomMax = main.t_selStages[stageNo].zoommax
127+ end
128+ setZoomMax(zoomMax)
129+ local zoomSpeed = config.ZoomSpeed
130+ if main.t_selStages[stageNo].zoomspeed ~= nil then
131+ zoomSpeed = main.t_selStages[stageNo].zoomspeed
132+ end
133+ setZoomSpeed(zoomSpeed)
134+end
135+
136+function select.f_makeRoster()
137+ t_roster = {}
138+ local t = {}
139+ local cnt = 0
140+ --Arcade
141+ if main.gameMode == 'arcade' or main.gameMode == 'teamcoop' or main.gameMode == 'netplayteamcoop' then
142+ if p2TeamMode == 0 then --Single
143+ t = main.t_selOptions.arcademaxmatches
144+ else --Team
145+ t = main.t_selOptions.teammaxmatches
146+ end
147+ for i = 1, #t do --for each order number
148+ cnt = t[i] * p2NumChars --set amount of matches to get from the table
149+ if cnt > 0 and main.t_orderChars[i] ~= nil then --if it's more than 0 and there are characters with such order
150+ while cnt > 0 do --do the following until amount of matches for particular order is reached
151+ main.f_shuffleTable(main.t_orderChars[i]) --randomize characters table
152+ for j = 1, #main.t_orderChars[i] do --loop through chars associated with that particular order
153+ t_roster[#t_roster + 1] = main.t_orderChars[i][j] --and add such character into new table
154+ cnt = cnt - 1
155+ if cnt == 0 then --but only if amount of matches for particular order has not been reached yet
156+ break
157+ end
158+ end
159+ end
160+ end
161+ end
162+ --Survival / Boss Rush / VS 100 Kumite
163+ else
164+ if main.gameMode == 'survival' or main.gameMode == 'survivalcoop' or main.gameMode == 'netplaysurvivalcoop' then
165+ t = main.t_randomChars
166+ cnt = #t
167+ local i = 0
168+ while cnt / p2NumChars ~= math.ceil(cnt / p2NumChars) do --not integer
169+ i = i + 1
170+ cnt = #t + i
171+ end
172+ elseif main.gameMode == 'bossrush' then
173+ t = main.t_bossChars
174+ cnt = #t
175+ local i = 0
176+ while cnt / p2NumChars ~= math.ceil(cnt / p2NumChars) do
177+ i = i + 1
178+ cnt = #t + i
179+ end
180+ elseif main.gameMode == '100kumite' then
181+ t = main.t_randomChars
182+ cnt = 100 * p2NumChars
183+ end
184+ while cnt > 0 do
185+ main.f_shuffleTable(t)
186+ for i = 1, #t do
187+ t_roster[#t_roster + 1] = t[i]
188+ cnt = cnt - 1
189+ if cnt == 0 then
190+ break
191+ end
192+ end
193+ end
194+ end
195+ main.f_printTable(t_roster, 'debug/t_roster.txt')
196+end
197+
198+function select.f_aiRamp()
199+ local start_match = 0
200+ local start_diff = 0
201+ local end_match = 0
202+ local end_diff = 0
203+ t_aiRamp = {}
204+ --Arcade
205+ if main.gameMode == 'arcade' or main.gameMode == 'teamcoop' or main.gameMode == 'netplayteamcoop' then
206+ if p2TeamMode == 0 then --Single
207+ start_match = main.t_selOptions.arcadestart.wins
208+ start_diff = main.t_selOptions.arcadestart.offset
209+ end_match = main.t_selOptions.arcadeend.wins
210+ end_diff = main.t_selOptions.arcadeend.offset
211+ else --Team
212+ start_match = main.t_selOptions.teamstart.wins
213+ start_diff = main.t_selOptions.teamstart.offset
214+ end_match = main.t_selOptions.teamend.wins
215+ end_diff = main.t_selOptions.teamend.offset
216+ end
217+ elseif main.gameMode == 'survival' or main.gameMode == 'survivalcoop' or main.gameMode == 'netplaysurvivalcoop' then
218+ start_match = main.t_selOptions.survivalstart.wins
219+ start_diff = main.t_selOptions.survivalstart.offset
220+ end_match = main.t_selOptions.survivalend.wins
221+ end_diff = main.t_selOptions.survivalend.offset
222+ end
223+ local startAI = config.Difficulty + start_diff
224+ if startAI > 8 then
225+ startAI = 8
226+ elseif startAI < 1 then
227+ startAI = 1
228+ end
229+ local endAI = config.Difficulty + end_diff
230+ if endAI > 8 then
231+ endAI = 8
232+ elseif endAI < 1 then
233+ endAI = 1
234+ end
235+ for i = 1, lastMatch do
236+ if i - 1 <= start_match then
237+ t_aiRamp[#t_aiRamp + 1] = startAI
238+ elseif i - 1 <= end_match then
239+ local curMatch = i - (start_match + 1)
240+ t_aiRamp[#t_aiRamp + 1] = math.floor(curMatch * (endAI - startAI) / (end_match - start_match) + startAI)
241+ else
242+ t_aiRamp[#t_aiRamp + 1] = endAI
243+ end
244+ end
245+ main.f_printTable(t_aiRamp, 'debug/t_aiRamp.txt')
246+end
247+
248+function select.f_difficulty(player, offset)
249+ local t = {}
250+ if player % 2 ~= 0 then --odd value
251+ local pos = math.floor(player / 2 + 0.5)
252+ t = main.t_selChars[t_p1Selected[pos].cel + 1]
253+ else --even value
254+ local pos = math.floor(player / 2)
255+ t = main.t_selChars[t_p2Selected[pos].cel + 1]
256+ end
257+ if t.ai ~= nil then
258+ return t.ai
259+ else
260+ return config.Difficulty + offset
261+ end
262+end
263+
264+function select.f_aiLevel()
265+ --Offset
266+ local offset = 0
267+ if config.AIRamping and main.gameMode == 'arcade' or main.gameMode == 'teamcoop' or main.gameMode == 'netplayteamcoop' or main.gameMode == 'survival' or main.gameMode == 'survivalcoop' or main.gameMode == 'netplaysurvivalcoop' then
268+ offset = t_aiRamp[matchNo] - config.Difficulty
269+ end
270+ --Player 1
271+ if main.coop then
272+ setCom(1, 0)
273+ setCom(3, 0)
274+ elseif p1TeamMode == 0 then --Single
275+ if main.p1In == 1 and not main.aiFight then
276+ setCom(1, 0)
277+ else
278+ setCom(1, select.f_difficulty(1, offset))
279+ end
280+ elseif p1TeamMode == 1 and config.SimulMode then --Simul
281+ if main.p1In == 1 and not main.aiFight then
282+ setCom(1, 0)
283+ else
284+ setCom(1, select.f_difficulty(1, offset))
285+ end
286+ for i = 3, p1NumChars * 2 do
287+ if i % 2 ~= 0 then --odd value
288+ setCom(i, select.f_difficulty(i, offset))
289+ end
290+ end
291+ -- Legcy TAG
292+ elseif p1TeamMode == 1 and config.SimulMode == false then
293+ for i = 1, p1NumChars * 2 do
294+ if i % 2 ~= 0 then --odd value
295+ if main.p1In == 1 and not main.aiFight then
296+ setCom(i, 0)
297+ else
298+ setCom(i, select.f_difficulty(i, offset))
299+ end
300+ end
301+ end
302+ elseif p1TeamMode == 2 then --Turns
303+ for i = 1, p1NumChars * 2 do
304+ if i % 2 ~= 0 then
305+ if main.p1In == 1 and not main.aiFight then
306+ setCom(i, 0)
307+ else
308+ setCom(i, select.f_difficulty(i, offset))
309+ end
310+ end
311+ end
312+ else --Tag
313+ for i = 1, p1NumChars * 2 do
314+ if i % 2 ~= 0 then --odd value
315+ if main.p1In == 1 and not main.aiFight then
316+ setCom(i, 0)
317+ else
318+ setCom(i, select.f_difficulty(i, offset))
319+ end
320+ end
321+ end
322+ end
323+ --Player 2
324+ if p2TeamMode == 0 then --Single
325+ if main.p2In == 2 and not main.aiFight and not main.coop then
326+ setCom(2, 0)
327+ else
328+ setCom(2, select.f_difficulty(2, offset))
329+ end
330+ elseif p2TeamMode == 1 and config.SimulMode then --Simul
331+ if main.p2In == 2 and not main.aiFight and not main.coop then
332+ setCom(2, 0)
333+ else
334+ setCom(2, select.f_difficulty(2, offset))
335+ end
336+ for i = 4, p2NumChars * 2 do
337+ if i % 2 == 0 then --even value
338+ setCom(i, select.f_difficulty(i, offset))
339+ end
340+ end
341+ -- Legcy TAG
342+ elseif p2TeamMode == 1 and config.SimulMode == false then --Tag
343+ for i = 2, p2NumChars * 2 do
344+ if i % 2 == 0 then --even value
345+ if main.p2In == 2 and not main.aiFight and not main.coop then
346+ setCom(i, 0)
347+ else
348+ setCom(i, select.f_difficulty(i, offset))
349+ end
350+ end
351+ end
352+ elseif p2TeamMode == 2 then --Turns
353+ for i = 2, p2NumChars * 2 do
354+ if i % 2 == 0 then
355+ if main.p2In == 2 and not main.aiFight and not main.coop then
356+ setCom(i, 0)
357+ else
358+ setCom(i, select.f_difficulty(i, offset))
359+ end
360+ end
361+ end
362+ else --Tag
363+ for i = 2, p2NumChars * 2 do
364+ if i % 2 == 0 then --even value
365+ if main.p2In == 2 and not main.aiFight and not main.coop then
366+ setCom(i, 0)
367+ else
368+ setCom(i, select.f_difficulty(i, offset))
369+ end
370+ end
371+ end
372+ end
373+end
374+
375+function select.f_assignMusic()
376+ local track = ''
377+ if main.stageMenu then
378+ if main.t_selStages[stageNo].music ~= nil then
379+ track = math.random(1, #main.t_selStages[stageNo].music)
380+ track = main.t_selStages[stageNo].music[track].bgmusic
381+ end
382+ else
383+ if main.t_selChars[t_p2Selected[1].cel + 1].music ~= nil then
384+ track = math.random(1, #main.t_selChars[t_p2Selected[1].cel + 1].music)
385+ track = main.t_selChars[t_p2Selected[1].cel + 1].music[track].bgmusic
386+ elseif main.t_selStages[stageNo].music ~= nil then
387+ track = math.random(1, #main.t_selStages[stageNo].music)
388+ track = main.t_selStages[stageNo].music[track].bgmusic
389+ end
390+ stageEnd = true
391+ end
392+ playBGM(track)
393+end
394+
395+function select.f_selectStage()
396+ if main.t_selChars[t_p2Selected[1].cel + 1].stage ~= nil then
397+ stageNo = math.random(1, #main.t_selChars[t_p2Selected[1].cel + 1].stage)
398+ stageNo = main.t_selChars[t_p2Selected[1].cel + 1].stage[stageNo]
399+ else
400+ stageNo = main.t_includeStage[math.random(1, #main.t_includeStage)]
401+ end
402+ setStage(stageNo)
403+ selectStage(stageNo)
404+end
405+
406+function select.f_randomPal(cell)
407+ --table with pal numbers already assigned
408+ local t = {}
409+ for i = 1, #t_p1Selected do
410+ if t_p1Selected[i].cel == cell then
411+ t[#t + 1] = t_p1Selected[i].pal
412+ end
413+ end
414+ for i = 1, #t_p2Selected do
415+ if t_p2Selected[i].cel == cell then
416+ t[#t + 1] = t_p2Selected[i].pal
417+ end
418+ end
419+ --table with pal numbers not assigned yet (or all if there are not enough pals for unique appearance of all characters)
420+ local t2 = {}
421+ for i = 1, #main.t_selChars[cell + 1].pal do
422+ if t[main.t_selChars[cell + 1].pal[i]] == nil or #t >= #main.t_selChars[cell + 1].pal then
423+ t2[#t2 + 1] = main.t_selChars[cell + 1].pal[i]
424+ end
425+ end
426+ return t2[math.random(1, #t2)]
427+end
428+
429+function select.f_drawName(t, data, font, offsetX, offsetY, scaleX, scaleY, spacingX, spacingY, active_font, active_row)
430+ for i = 1, #t do
431+ local x = offsetX
432+ local f = font
433+ if active_font ~= nil and active_row ~= nil then
434+ if i == active_row then
435+ f = active_font
436+ else
437+ f = font
438+ end
439+ end
440+ if motif.font_data[f[1]] ~= -1 then
441+ main.f_updateTextImg(
442+ data,
443+ motif.font_data[f[1]],
444+ f[2],
445+ f[3],
446+ main.f_getName(t[i].cel),
447+ x + (i - 1) * spacingX,
448+ offsetY + (i - 1) * spacingY,
449+ scaleX,
450+ scaleY,
451+ f[4],
452+ f[5],
453+ f[6]
454+ )
455+ textImgDraw(data)
456+ end
457+ end
458+end
459+
460+function select.f_drawPortrait(t, offsetX, offsetY, facing, scaleX, scaleY, spacingX, spacingY, limit, func)
461+ if facing == -1 then offsetX = offsetX + 1 end --fix for wrong offset after flipping sprites
462+ for i = #t, 1, -1 do
463+ if i <= limit then
464+ if func == 'select' then
465+ drawPortrait(t[i].cel, offsetX + (i - 1) * spacingX, offsetY + (i - 1) * spacingY, facing * scaleX, scaleY)
466+ elseif func == 'versus' then
467+ drawVersusPortrait(t[i].cel, offsetX + (i - 1) * spacingX, offsetY + (i - 1) * spacingY, facing * scaleX, scaleY)
468+ elseif func == 'victory' then
469+ drawVictoryPortrait(t[i].cel, offsetX + (i - 1) * spacingX, offsetY + (i - 1) * spacingY, facing * scaleX, scaleY)
470+ end
471+ end
472+ end
473+end
474+
475+function select.f_cellMovement(selX, selY, cmd, faceOffset, rowOffset, snd)
476+ local tmpX = selX
477+ local tmpY = selY
478+ local tmpFace = faceOffset
479+ local tmpRow = rowOffset
480+ local found = false
481+ if commandGetState(cmd, 'u') then
482+ for i = 1, motif.select_info.rows + motif.select_info.rows_scrolling do
483+ selY = selY - 1
484+ if selY < 0 then
485+ if wrappingY then
486+ faceOffset = motif.select_info.rows_scrolling * motif.select_info.columns
487+ rowOffset = motif.select_info.rows_scrolling
488+ selY = motif.select_info.rows + motif.select_info.rows_scrolling - 1
489+ else
490+ faceOffset = tmpFace
491+ rowOffset = tmpRow
492+ selY = tmpY
493+ end
494+ elseif selY < rowOffset then
495+ faceOffset = faceOffset - motif.select_info.columns
496+ rowOffset = rowOffset - 1
497+ end
498+ if (t_grid[selY + 1][selX + 1].char ~= nil and t_grid[selY + 1][selX + 1].hidden ~= 2)
499+ or motif.select_info.moveoveremptyboxes == 1 then
500+ break
501+ elseif motif.select_info.searchemptyboxesup ~= 0 then
502+ found, selX = select.f_searchEmptyBoxes(motif.select_info.searchemptyboxesup, selX, selY)
503+ if found then
504+ break
505+ end
506+ end
507+ end
508+ elseif commandGetState(cmd, 'd') then
509+ for i = 1, motif.select_info.rows + motif.select_info.rows_scrolling do
510+ selY = selY + 1
511+ if selY >= motif.select_info.rows + motif.select_info.rows_scrolling then
512+ if wrappingY then
513+ faceOffset = 0
514+ rowOffset = 0
515+ selY = 0
516+ else
517+ faceOffset = tmpFace
518+ rowOffset = tmpRow
519+ selY = tmpY
520+ end
521+ elseif selY >= motif.select_info.rows + rowOffset then
522+ faceOffset = faceOffset + motif.select_info.columns
523+ rowOffset = rowOffset + 1
524+ end
525+ if (t_grid[selY + 1][selX + 1].char ~= nil and t_grid[selY + 1][selX + 1].hidden ~= 2)
526+ or motif.select_info.moveoveremptyboxes == 1 then
527+ break
528+ elseif motif.select_info.searchemptyboxesdown ~= 0 then
529+ found, selX = select.f_searchEmptyBoxes(motif.select_info.searchemptyboxesdown, selX, selY)
530+ if found then
531+ break
532+ end
533+ end
534+ end
535+ elseif commandGetState(cmd, 'l') then
536+ for i = 1, motif.select_info.columns do
537+ selX = selX - 1
538+ if selX < 0 then
539+ if wrappingX then
540+ selX = motif.select_info.columns - 1
541+ else
542+ selX = tmpX
543+ end
544+ end
545+ if (t_grid[selY + 1][selX + 1].char ~= nil and t_grid[selY + 1][selX + 1].hidden ~= 2)
546+ or motif.select_info.moveoveremptyboxes == 1 then
547+ break
548+ end
549+ end
550+ elseif commandGetState(cmd, 'r') then
551+ for i = 1, motif.select_info.columns do
552+ selX = selX + 1
553+ if selX >= motif.select_info.columns then
554+ if wrappingX then
555+ selX = 0
556+ else
557+ selX = tmpX
558+ end
559+ end
560+ if (t_grid[selY + 1][selX + 1].char ~= nil and t_grid[selY + 1][selX + 1].hidden ~= 2)
561+ or motif.select_info.moveoveremptyboxes == 1 then
562+ break
563+ end
564+ end
565+ end
566+ if tmpX ~= selX or tmpY ~= selY then
567+ resetgrid = true
568+ --if tmpRow ~= rowOffset then
569+ --select.f_resetGrid()
570+ --end
571+ sndPlay(motif.files.snd_data, snd[1], snd[2])
572+ end
573+ return selX, selY, faceOffset, rowOffset
574+end
575+
576+function select.f_searchEmptyBoxes(direction, x, y)
577+ local selX = x
578+ local selY = y
579+ local tmpX = x
580+ local found = false
581+ if direction > 0 then --right
582+ while true do
583+ x = x + 1
584+ if x >= motif.select_info.columns then
585+ x = tmpX
586+ break
587+ elseif t_grid[y + 1][x + 1].char ~= nil and t_grid[selY + 1][selX + 1].hidden ~= 2 then
588+ found = true
589+ break
590+ end
591+ end
592+ elseif direction < 0 then --left
593+ while true do
594+ x = x - 1
595+ if x < 0 then
596+ x = tmpX
597+ break
598+ elseif t_grid[y + 1][x + 1].char ~= nil and t_grid[selY + 1][selX + 1].hidden ~= 2 then
599+ found = true
600+ break
601+ end
602+ end
603+ end
604+ return found, x
605+end
606+
607+function select.f_unlockChar(char, flag)
608+ --setHiddenFlag(char, flag) --not used for now
609+ main.t_selChars[char + 1].hidden = flag
610+ t_grid[main.t_selChars[char + 1].row][main.t_selChars[char + 1].col].hidden = flag
611+ select.f_resetGrid()
612+end
613+
614+function select.f_resetGrid()
615+ select.t_drawFace = {}
616+ for row = 1, motif.select_info.rows do
617+ for col = 1, motif.select_info.columns do
618+ --1Pのランダムセル表示位置 / 1P random cell display position
619+ if t_grid[row + p1RowOffset][col].char == 'randomselect' or t_grid[row + p1RowOffset][col].hidden == 3 then
620+ select.t_drawFace[#select.t_drawFace + 1] = {d = 1, p1 = t_grid[row + p1RowOffset][col].num, p2 = t_grid[row + p2RowOffset][col].num, x1 = p1FaceX + t_grid[row][col].x, x2 = p2FaceX + t_grid[row][col].x, y1 = p1FaceY + t_grid[row][col].y, y2 = p2FaceY + t_grid[row][col].y}
621+ --2Pのランダムセル表示位置 / 2P random cell display position
622+ elseif t_grid[row + p2RowOffset][col].char == 'randomselect' or t_grid[row + p2RowOffset][col].hidden == 3 then
623+ select.t_drawFace[#select.t_drawFace + 1] = {d = 11, p1 = t_grid[row + p1RowOffset][col].num, p2 = t_grid[row + p2RowOffset][col].num, x1 = p1FaceX + t_grid[row][col].x, x2 = p2FaceX + t_grid[row][col].x, y1 = p1FaceY + t_grid[row][col].y, y2 = p2FaceY + t_grid[row][col].y}
624+ --1Pのキャラ表示位置 / 1P character display position
625+ elseif t_grid[row + p1RowOffset][col].char ~= nil and t_grid[row + p1RowOffset][col].hidden == 0 then
626+ select.t_drawFace[#select.t_drawFace + 1] = {d = 2, p1 = t_grid[row + p1RowOffset][col].num, p2 = t_grid[row + p2RowOffset][col].num, x1 = p1FaceX + t_grid[row][col].x, x2 = p2FaceX + t_grid[row][col].x, y1 = p1FaceY + t_grid[row][col].y, y2 = p2FaceY + t_grid[row][col].y}
627+ --2Pのキャラ表示位置 / 2P character display position
628+ elseif t_grid[row + p2RowOffset][col].char ~= nil and t_grid[row + p2RowOffset][col].hidden == 0 then
629+ select.t_drawFace[#select.t_drawFace + 1] = {d = 12, p1 = t_grid[row + p1RowOffset][col].num, p2 = t_grid[row + p2RowOffset][col].num, x1 = p1FaceX + t_grid[row][col].x, x2 = p2FaceX + t_grid[row][col].x, y1 = p1FaceY + t_grid[row][col].y, y2 = p2FaceY + t_grid[row][col].y}
630+ elseif motif.select_info.showemptyboxes == 1 then
631+ select.t_drawFace[#select.t_drawFace + 1] = {d = 0, p1 = t_grid[row + p1RowOffset][col].num, p2 = t_grid[row + p2RowOffset][col].num, x1 = p1FaceX + t_grid[row][col].x, x2 = p2FaceX + t_grid[row][col].x, y1 = p1FaceY + t_grid[row][col].y, y2 = p2FaceY + t_grid[row][col].y}
632+ end
633+ end
634+ end
635+end
636+
637+function select.f_selectReset()
638+ if main.p2Faces and motif.select_info.double_select == 1 then
639+ p1FaceX = motif.select_info.pos_p1_double_select[1]
640+ p1FaceY = motif.select_info.pos_p1_double_select[2]
641+ p2FaceX = motif.select_info.pos_p2_double_select[1]
642+ p2FaceY = motif.select_info.pos_p2_double_select[2]
643+ else
644+ p1FaceX = motif.select_info.pos[1]
645+ p1FaceY = motif.select_info.pos[2]
646+ p2FaceX = motif.select_info.pos[1]
647+ p2FaceY = motif.select_info.pos[2]
648+ end
649+ select.f_resetGrid()
650+ if main.gameMode == 'netplayversus' or main.gameMode == 'netplayteamcoop' or main.gameMode == 'netplaysurvivalcoop' then
651+ p1TeamMode = 0
652+ p2TeamMode = 0
653+ stageNo = 0
654+ stageList = 0
655+ end
656+ p1Cell = nil
657+ p2Cell = nil
658+ t_p1Selected = {}
659+ t_p2Selected = {}
660+ p1TeamEnd = false
661+ p1SelEnd = false
662+ p2TeamEnd = false
663+ p2SelEnd = false
664+ if main.p2In == 1 then
665+ p2TeamEnd = true
666+ p2SelEnd = true
667+ elseif main.coop then
668+ p1TeamEnd = true
669+ p2TeamEnd = true
670+ end
671+ if not main.p2SelectMenu then
672+ p2SelEnd = true
673+ end
674+ selScreenEnd = false
675+ stageEnd = false
676+ coopEnd = false
677+ restoreTeam = false
678+ p1NumChars = 1
679+ p2NumChars = 1
680+ matchNo = 0
681+ setMatchNo(matchNo)
682+end
683+
684+--;===========================================================
685+--; SIMPLE LOOP (VS MODE, TRAINING, WATCH, BONUS GAMES)
686+--;===========================================================
687+function select.f_selectSimple()
688+ p1SelX = motif.select_info.p1_cursor_startcell[2]
689+ p1SelY = motif.select_info.p1_cursor_startcell[1]
690+ p2SelX = motif.select_info.p2_cursor_startcell[2]
691+ p2SelY = motif.select_info.p2_cursor_startcell[1]
692+ p1FaceOffset = 0
693+ p2FaceOffset = 0
694+ p1RowOffset = 0
695+ p2RowOffset = 0
696+ stageList = 0
697+ main.f_cmdInput()
698+ while true do
699+ main.f_resetBG(motif.select_info, motif.selectbgdef, motif.music.select_bgm)
700+ select.f_selectReset()
701+ selectStart()
702+ while not selScreenEnd do
703+ if esc() then
704+ sndPlay(motif.files.snd_data, motif.select_info.cancel_snd[1], motif.select_info.cancel_snd[2])
705+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
706+ return
707+ end
708+ select.f_selectScreen()
709+ end
710+ select.f_aiLevel()
711+ if not main.stageMenu then
712+ select.f_selectStage()
713+ end
714+ select.f_selectVersus()
715+ if esc() then break end
716+ select.f_setZoom()
717+ select.f_assignMusic()
718+ loadStart()
719+ winner, t_gameStats = game()
720+ main.f_cmdInput()
721+ refresh()
722+ end
723+end
724+
725+--;===========================================================
726+--; ADVANCE LOOP (ARCADE, TEAM CO-OP, SURVIVAL, SURVIVAL CO-OP, VS 100 KUMITE, BOSS RUSH)
727+--;===========================================================
728+function select.f_selectAdvance()
729+getSpriteInfo('chars/kfm/kfm.sff', 0, 1)
730+ p1SelX = motif.select_info.p1_cursor_startcell[2]
731+ p1SelY = motif.select_info.p1_cursor_startcell[1]
732+ p2SelX = motif.select_info.p2_cursor_startcell[2]
733+ p2SelY = motif.select_info.p2_cursor_startcell[1]
734+ p1FaceOffset = 0
735+ p2FaceOffset = 0
736+ p1RowOffset = 0
737+ p2RowOffset = 0
738+ winner = 0
739+ winCnt = 0
740+ looseCnt = 0
741+ main.f_cmdInput()
742+ select.f_selectReset()
743+ stageEnd = true
744+ while true do
745+ main.f_resetBG(motif.select_info, motif.selectbgdef, motif.music.select_bgm)
746+ selectStart()
747+ while not selScreenEnd do
748+ if esc() then
749+ sndPlay(motif.files.snd_data, motif.select_info.cancel_snd[1], motif.select_info.cancel_snd[2])
750+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
751+ return
752+ end
753+ select.f_selectScreen()
754+ end
755+ --first match
756+ if matchNo == 0 then
757+ --coop swap
758+ if main.coop then
759+ p1TeamMode = 1
760+ p1NumChars = 2
761+ setTeamMode(1, p1TeamMode, p1NumChars)
762+ t_p1Selected[2] = {cel = t_p2Selected[1].cel, pal = t_p2Selected[1].pal}
763+ end
764+ --generate roster
765+ select.f_makeRoster()
766+ lastMatch = #t_roster / p2NumChars
767+ matchNo = 1
768+ --generate AI ramping table
769+ select.f_aiRamp()
770+ --intro
771+ if main.gameMode == 'arcade' or main.gameMode == 'teamcoop' or main.gameMode == 'netplayteamcoop' then
772+ local tPos = main.t_selChars[t_p1Selected[1].cel + 1]
773+ if tPos.intro ~= nil and main.f_fileExists(tPos.intro) then
774+ storyboard.f_storyboard(tPos.intro)
775+ end
776+ end
777+ --player exit the match via ESC in VS 100 Kumite mode
778+ elseif winner == -1 and main.gameMode == '100kumite' then
779+ --counter
780+ looseCnt = looseCnt + 1
781+ --result
782+ select.f_result('lost')
783+ --game over
784+ if motif.game_over_screen.enabled == 1 and motif.game_over_screen.storyboard ~= '' then
785+ storyboard.f_storyboard(motif.game_over_screen.storyboard)
786+ end
787+ --intro
788+ if motif.files.intro_storyboard ~= '' then
789+ storyboard.f_storyboard(motif.files.intro_storyboard)
790+ end
791+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
792+ return
793+ --player won (also if lost in VS 100 Kumite)
794+ elseif winner == 1 or main.gameMode == '100kumite' then
795+ --counter
796+ if winner == 1 then
797+ winCnt = winCnt + 1
798+ else --only true in VS 100 Kumite mode
799+ looseCnt = looseCnt + 1
800+ end
801+ --victory screen
802+ if main.gameMode == 'arcade' or main.gameMode == 'teamcoop' or main.gameMode == 'netplayteamcoop' then
803+ if main.t_selChars[t_p2Selected[1].cel + 1].winscreen == nil or main.t_selChars[t_p2Selected[1].cel + 1].winscreen == 1 then
804+ select.f_selectVictory()
805+ end
806+ end
807+ --no more matches left
808+ if matchNo == lastMatch then
809+ --ending
810+ if main.gameMode == 'arcade' or main.gameMode == 'teamcoop' or main.gameMode == 'netplayteamcoop' then
811+ local tPos = main.t_selChars[t_p1Selected[1].cel + 1]
812+ if tPos.ending ~= nil and main.f_fileExists(tPos.ending) then
813+ storyboard.f_storyboard(tPos.ending)
814+ elseif motif.default_ending.enabled == 1 and motif.default_ending.storyboard ~= '' then
815+ storyboard.f_storyboard(motif.default_ending.storyboard)
816+ end
817+ end
818+ --result
819+ select.f_result(true)
820+ --credits
821+ if motif.end_credits.enabled == 1 and motif.end_credits.storyboard ~= '' then
822+ storyboard.f_storyboard(motif.end_credits.storyboard)
823+ end
824+ --game over
825+ if motif.game_over_screen.enabled == 1 and motif.game_over_screen.storyboard ~= '' then
826+ storyboard.f_storyboard(motif.game_over_screen.storyboard)
827+ end
828+ --intro
829+ if motif.files.intro_storyboard ~= '' then
830+ storyboard.f_storyboard(motif.files.intro_storyboard)
831+ end
832+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
833+ return
834+ --next match available
835+ else
836+ matchNo = matchNo + 1
837+ end
838+ --player lost and doesn't have any credits left
839+ elseif main.credits == 0 then
840+ --counter
841+ looseCnt = looseCnt + 1
842+ --victory screen
843+ if main.gameMode == 'arcade' or main.gameMode == 'teamcoop' or main.gameMode == 'netplayteamcoop' then
844+ if winner >= 1 and (main.t_selChars[t_p2Selected[1].cel + 1].winscreen == nil or main.t_selChars[t_p2Selected[1].cel + 1].winscreen == 1) then
845+ select.f_selectVictory()
846+ end
847+ end
848+ --result
849+ select.f_result(false)
850+ --game over
851+ if motif.game_over_screen.enabled == 1 and motif.game_over_screen.storyboard ~= '' then
852+ storyboard.f_storyboard(motif.game_over_screen.storyboard)
853+ end
854+ --intro
855+ if motif.files.intro_storyboard ~= '' then
856+ storyboard.f_storyboard(motif.files.intro_storyboard)
857+ end
858+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
859+ return
860+ --player lost but can continue
861+ else
862+ --counter
863+ looseCnt = looseCnt + 1
864+ --victory screen
865+ if winner >= 1 and (main.t_selChars[t_p2Selected[1].cel + 1].winscreen == nil or main.t_selChars[t_p2Selected[1].cel + 1].winscreen == 1) then
866+ select.f_selectVictory()
867+ end
868+ --continue screen
869+ select.f_continue()
870+ if not continue then
871+ --game over
872+ if motif.continue_screen.external_gameover == 1 and motif.game_over_screen.storyboard ~= '' then
873+ storyboard.f_storyboard(motif.game_over_screen.storyboard)
874+ end
875+ --intro
876+ if motif.files.intro_storyboard ~= '' then
877+ storyboard.f_storyboard(motif.files.intro_storyboard)
878+ end
879+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
880+ return
881+ end
882+ if config.ContSelection then --true if 'Char change at Continue' option is enabled
883+ t_p1Selected = {}
884+ p1SelEnd = false
885+ if main.coop then
886+ p1NumChars = 1
887+ numChars = p2NumChars
888+ p2NumChars = 1
889+ t_p2Selected = {}
890+ p2SelEnd = false
891+ end
892+ selScreenEnd = false
893+ while not selScreenEnd do
894+ if esc() then
895+ sndPlay(motif.files.snd_data, motif.select_info.cancel_snd[1], motif.select_info.cancel_snd[2])
896+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
897+ return
898+ end
899+ select.f_selectScreen()
900+ end
901+ elseif esc() then
902+ sndPlay(motif.files.snd_data, motif.select_info.cancel_snd[1], motif.select_info.cancel_snd[2])
903+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
904+ return
905+ end
906+ end
907+ --coop swap
908+ if main.coop then
909+ remapInput(3,2) --P2 controls assigned to P3 character
910+ if winner == -1 or winner == 2 then
911+ p1NumChars = 2
912+ p2NumChars = numChars
913+ t_p1Selected[2] = {cel = t_p2Selected[1].cel, pal = t_p2Selected[1].pal}
914+ end
915+ end
916+ --assign enemy team
917+ t_p2Selected = {}
918+ local shuffle = true
919+ for i = 1, p2NumChars do
920+ if i == 1 and (main.gameMode == 'arcade' or main.gameMode == 'teamcoop' or main.gameMode == 'netplayteamcoop') and main.t_selChars[t_p1Selected[1].cel + 1][matchNo] ~= nil then
921+ p2Cell = main.t_charDef[main.t_selChars[t_p1Selected[1].cel + 1][matchNo]]
922+ shuffle = false
923+ else
924+ p2Cell = t_roster[matchNo * p2NumChars - i + 1]
925+ end
926+ local updateAnim = true
927+ for j = 1, #t_p2Selected do
928+ if t_p2Selected[j].cel == p2Cell then
929+ updateAnim = false
930+ end
931+ end
932+ t_p2Selected[#t_p2Selected + 1] = {cel = p2Cell, pal = select.f_randomPal(p2Cell), up = updateAnim}
933+ if shuffle then
934+ main.f_shuffleTable(t_p2Selected)
935+ end
936+ end
937+ --Team conversion to Single match if bonus paramvalue on any opponents is detected
938+ if p2NumChars > 1 then
939+ for i = 1, #t_p2Selected do
940+ if main.t_selChars[t_p2Selected[i].cel + 1].bonus ~= nil and main.t_selChars[t_p2Selected[i].cel + 1].bonus == 1 then
941+ teamMode = p2TeamMode
942+ numChars = p2NumChars
943+ p2TeamMode = 0
944+ p2NumChars = 1
945+ setTeamMode(2, 0, 1)
946+ p2Cell = main.t_charDef[main.t_selChars[t_p2Selected[i].cel + 1].char]
947+ t_p2Selected = {}
948+ t_p2Selected[1] = {cel = p2Cell, pal = select.f_randomPal(p2Cell), up = true}
949+ restoreTeam = true
950+ break
951+ end
952+ end
953+ end
954+ setMatchNo(matchNo)
955+ select.f_aiLevel()
956+ if not main.stageMenu then
957+ select.f_selectStage()
958+ end
959+ select.f_selectVersus()
960+ if esc() then break end
961+ select.f_setZoom()
962+ select.f_assignMusic()
963+ loadStart()
964+ winner, t_gameStats = game()
965+ --restore P2 Team settings if needed
966+ if restoreTeam then
967+ p2TeamMode = teamMode
968+ p2NumChars = numChars
969+ setTeamMode(2, p2TeamMode, p2NumChars)
970+ restoreTeam = false
971+ end
972+ resetRemapInput()
973+ main.f_cmdInput()
974+ --main.f_printTable(_G)
975+ refresh()
976+ end
977+end
978+
979+--;===========================================================
980+--; TOURNAMENT LOOP
981+--;===========================================================
982+function select.f_selectTournament()
983+ p1SelX = motif.select_info.p1_cursor_startcell[2]
984+ p1SelY = motif.select_info.p1_cursor_startcell[1]
985+ p2SelX = motif.select_info.p2_cursor_startcell[2]
986+ p2SelY = motif.select_info.p2_cursor_startcell[1]
987+ p1FaceOffset = 0
988+ p2FaceOffset = 0
989+ p1RowOffset = 0
990+ p2RowOffset = 0
991+ stageList = 0
992+ main.f_cmdInput()
993+ while true do
994+ main.f_resetBG(motif.tournament_info, motif.tournamentbgdef, motif.music.tournament_bgm)
995+ select.f_selectReset()
996+ while not selScreenEnd do
997+ if esc() then
998+ sndPlay(motif.files.snd_data, motif.select_info.cancel_snd[1], motif.select_info.cancel_snd[2])
999+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
1000+ return
1001+ end
1002+ select.f_selectTournamentScreen()
1003+ end
1004+ select.f_aiLevel()
1005+ select.f_selectVersus()
1006+ select.f_setZoom()
1007+ select.f_assignMusic()
1008+ loadStart()
1009+ winner, t_gameStats = game()
1010+ main.f_cmdInput()
1011+ refresh()
1012+ end
1013+end
1014+
1015+--;===========================================================
1016+--; TOURNAMENT SCREEN
1017+--;===========================================================
1018+function select.f_selectTournamentScreen()
1019+ --draw clearcolor
1020+ animDraw(motif.tournamentbgdef.bgclearcolor_data)
1021+ --draw layerno = 0 backgrounds
1022+ main.f_drawBG(motif.tournamentbgdef.bg_data, motif.tournamentbgdef.bg, 0, motif.tournamentbgdef.timer)
1023+
1024+ --draw layerno = 1 backgrounds
1025+ main.f_drawBG(motif.tournamentbgdef.bg_data, motif.tournamentbgdef.bg, 1, motif.tournamentbgdef.timer)
1026+ --draw fadein
1027+ animDraw(motif.tournament_info.fadein_data)
1028+ animUpdate(motif.tournament_info.fadein_data)
1029+ --update timer
1030+ motif.tournamentbgdef.timer = motif.tournamentbgdef.timer + 1
1031+ --end loop
1032+ main.f_cmdInput()
1033+ refresh()
1034+end
1035+
1036+--;===========================================================
1037+--; SELECT SCREEN
1038+--;===========================================================
1039+local txt_p1Name = main.f_createTextImg(
1040+ motif.font_data[motif.select_info.p1_name_font[1]],
1041+ motif.select_info.p1_name_font[2],
1042+ motif.select_info.p1_name_font[3],
1043+ '',
1044+ 0,
1045+ 0,
1046+ motif.select_info.p1_name_font_scale[1],
1047+ motif.select_info.p1_name_font_scale[2],
1048+ motif.select_info.p1_name_font[4],
1049+ motif.select_info.p1_name_font[5],
1050+ motif.select_info.p1_name_font[6]
1051+)
1052+
1053+local p1RandomCount = 0
1054+local p1RandomPortrait = 0
1055+if #main.t_randomChars > 0 then p1RandomPortrait = main.t_randomChars[math.random(1, #main.t_randomChars)] end
1056+local txt_p2Name = main.f_createTextImg(
1057+ motif.font_data[motif.select_info.p2_name_font[1]],
1058+ motif.select_info.p2_name_font[2],
1059+ motif.select_info.p2_name_font[3],
1060+ '',
1061+ 0,
1062+ 0,
1063+ motif.select_info.p2_name_font_scale[1],
1064+ motif.select_info.p2_name_font_scale[2],
1065+ motif.select_info.p2_name_font[4],
1066+ motif.select_info.p2_name_font[5],
1067+ motif.select_info.p2_name_font[6]
1068+)
1069+local p2RandomCount = 0
1070+local p2RandomPortrait = 0
1071+if #main.t_randomChars > 0 then p2RandomPortrait = main.t_randomChars[math.random(1, #main.t_randomChars)] end
1072+
1073+function select.f_selectScreen()
1074+ --draw clearcolor
1075+ animDraw(motif.selectbgdef.bgclearcolor_data)
1076+ --draw layerno = 0 backgrounds
1077+ main.f_drawBG(motif.selectbgdef.bg_data, motif.selectbgdef.bg, 0, motif.selectbgdef.timer)
1078+ --draw title
1079+ textImgDraw(main.txt_mainSelect)
1080+ if p1Cell then
1081+ --draw p1 portrait
1082+ local t_portrait = {}
1083+ if #t_p1Selected < p1NumChars then
1084+ if main.t_selChars[p1Cell + 1].char == 'randomselect' or main.t_selChars[p1Cell + 1].hidden == 3 then
1085+ if p1RandomCount < motif.select_info.cell_random_switchtime then
1086+ p1RandomCount = p1RandomCount + 1
1087+ elseif #main.t_randomChars > 0 then
1088+ p1RandomPortrait = main.t_randomChars[math.random(1, #main.t_randomChars)]
1089+ p1RandomCount = 0
1090+ end
1091+ sndPlay(motif.files.snd_data, motif.select_info.p1_random_move_snd[1], motif.select_info.p1_random_move_snd[2])
1092+ t_portrait[1] = {cel = p1RandomPortrait}
1093+ elseif main.t_selChars[p1Cell + 1].hidden ~= 2 then
1094+ t_portrait[1] = {cel = p1Cell}
1095+ end
1096+ end
1097+ for i = #t_p1Selected, 1, -1 do
1098+ if motif.select_info.p1_face_num > #t_portrait then
1099+ t_portrait[#t_portrait + 1] = {cel = t_p1Selected[i].cel}
1100+ end
1101+ end
1102+ select.f_drawPortrait(
1103+ main.f_reversedTable(t_portrait),
1104+ motif.select_info.p1_face_offset[1],
1105+ motif.select_info.p1_face_offset[2],
1106+ motif.select_info.p1_face_facing,
1107+ motif.select_info.p1_face_scale[1],
1108+ motif.select_info.p1_face_scale[2],
1109+ motif.select_info.p1_face_spacing[1],
1110+ motif.select_info.p1_face_spacing[2],
1111+ #t_portrait,
1112+ 'select'
1113+ )
1114+ end
1115+ if p2Cell then
1116+ --draw p2 portrait
1117+ local t_portrait = {}
1118+ if #t_p2Selected < p2NumChars then
1119+ if main.t_selChars[p2Cell + 1].char == 'randomselect' or main.t_selChars[p2Cell + 1].hidden == 3 then
1120+ if p2RandomCount < motif.select_info.cell_random_switchtime then
1121+ p2RandomCount = p2RandomCount + 1
1122+ elseif #main.t_randomChars > 0 then
1123+ p2RandomPortrait = main.t_randomChars[math.random(1, #main.t_randomChars)]
1124+ p2RandomCount = 0
1125+ end
1126+ sndPlay(motif.files.snd_data, motif.select_info.p2_random_move_snd[1], motif.select_info.p2_random_move_snd[2])
1127+ t_portrait[1] = {cel = p2RandomPortrait}
1128+ elseif main.t_selChars[p2Cell + 1].hidden ~= 2 then
1129+ t_portrait[1] = {cel = p2Cell}
1130+ end
1131+ end
1132+ for i = #t_p2Selected, 1, -1 do
1133+ if motif.select_info.p2_face_num > #t_portrait then
1134+ t_portrait[#t_portrait + 1] = {cel = t_p2Selected[i].cel}
1135+ end
1136+ end
1137+ select.f_drawPortrait(
1138+ main.f_reversedTable(t_portrait),
1139+ motif.select_info.p2_face_offset[1],
1140+ motif.select_info.p2_face_offset[2],
1141+ motif.select_info.p2_face_facing,
1142+ motif.select_info.p2_face_scale[1],
1143+ motif.select_info.p2_face_scale[2],
1144+ motif.select_info.p2_face_spacing[1],
1145+ motif.select_info.p2_face_spacing[2],
1146+ #t_portrait,
1147+ 'select'
1148+ )
1149+ end
1150+ --draw cell art (slow for large rosters, this will be likely moved to 'drawFace' function in future)
1151+ for i = 1, #select.t_drawFace do
1152+ main.f_animPosDraw(motif.select_info.cell_bg_data, select.t_drawFace[i].x1, select.t_drawFace[i].y1) --draw cell background
1153+ if select.t_drawFace[i].d == 1 then --draw random cell
1154+ main.f_animPosDraw(motif.select_info.cell_random_data, select.t_drawFace[i].x1, select.t_drawFace[i].y1)
1155+ elseif select.t_drawFace[i].d == 2 then --draw face cell
1156+ drawSmallPortrait(select.t_drawFace[i].p1, select.t_drawFace[i].x1, select.t_drawFace[i].y1, motif.select_info.portrait_scale[1], motif.select_info.portrait_scale[2])
1157+ end
1158+ if main.p2Faces and motif.select_info.double_select == 1 then --P2 side grid enabled
1159+ main.f_animPosDraw(motif.select_info.cell_bg_data, select.t_drawFace[i].x2, select.t_drawFace[i].y2) --draw cell background
1160+ if select.t_drawFace[i].d == 11 then --draw random cell
1161+ main.f_animPosDraw(motif.select_info.cell_random_data, select.t_drawFace[i].x2, select.t_drawFace[i].y2)
1162+ elseif select.t_drawFace[i].d == 12 then --draw face cell
1163+ drawSmallPortrait(select.t_drawFace[i].p2, select.t_drawFace[i].x2, select.t_drawFace[i].y2, motif.select_info.portrait_scale[1], motif.select_info.portrait_scale[2])
1164+ end
1165+ end
1166+ end
1167+ --drawFace(p1FaceX, p1FaceY, p1FaceOffset)
1168+ --if main.p2Faces and motif.select_info.double_select == 1 then
1169+ -- drawFace(p2FaceX, p2FaceY, p2FaceOffset)
1170+ --end
1171+ --draw p1 done cursor
1172+ for i = 1, #t_p1Selected do
1173+ if t_p1Selected[i].cursor ~= nil then
1174+ main.f_animPosDraw(motif.select_info.p1_cursor_done_data, t_p1Selected[i].cursor[1], t_p1Selected[i].cursor[2])
1175+ end
1176+ end
1177+ --draw p2 done cursor
1178+ for i = 1, #t_p2Selected do
1179+ if t_p2Selected[i].cursor ~= nil then
1180+ main.f_animPosDraw(motif.select_info.p2_cursor_done_data, t_p2Selected[i].cursor[1], t_p2Selected[i].cursor[2])
1181+ end
1182+ end
1183+ --Player1 team menu
1184+ if not p1TeamEnd then
1185+ select.f_p1TeamMenu()
1186+ --Player1 select
1187+ elseif main.p1In > 0 or main.p1Char ~= nil then
1188+ select.f_p1SelectMenu()
1189+ end
1190+ --Player2 team menu
1191+ if not p2TeamEnd then
1192+ select.f_p2TeamMenu()
1193+ --Player2 select
1194+ elseif main.p2In > 0 or main.p2Char ~= nil then
1195+ select.f_p2SelectMenu()
1196+ end
1197+ if p1Cell then
1198+ --draw p1 name
1199+ if #t_p1Selected < p1NumChars then
1200+ textImgSetText(txt_p1Name, main.f_getName(p1Cell))
1201+ main.f_textImgPosDraw(
1202+ txt_p1Name,
1203+ motif.select_info.p1_name_offset[1] + #t_p1Selected * motif.select_info.p1_name_spacing[1],
1204+ motif.select_info.p1_name_offset[2] + #t_p1Selected * motif.select_info.p1_name_spacing[2],
1205+ motif.select_info.p1_name_font[3]
1206+ )
1207+ end
1208+ select.f_drawName(
1209+ t_p1Selected,
1210+ txt_p1Name,
1211+ motif.select_info.p1_name_font,
1212+ motif.select_info.p1_name_offset[1],
1213+ motif.select_info.p1_name_offset[2],
1214+ motif.select_info.p1_name_font_scale[1],
1215+ motif.select_info.p1_name_font_scale[2],
1216+ motif.select_info.p1_name_spacing[1],
1217+ motif.select_info.p1_name_spacing[2]
1218+ )
1219+ end
1220+ if p2Cell then
1221+ --draw p2 name
1222+ if #t_p2Selected < p2NumChars then
1223+ textImgSetText(txt_p2Name, main.f_getName(p2Cell))
1224+ main.f_textImgPosDraw(
1225+ txt_p2Name,
1226+ motif.select_info.p2_name_offset[1] + #t_p2Selected * motif.select_info.p2_name_spacing[1],
1227+ motif.select_info.p2_name_offset[2] + #t_p2Selected * motif.select_info.p2_name_spacing[2],
1228+ motif.select_info.p2_name_font[3]
1229+ )
1230+ end
1231+ select.f_drawName(
1232+ t_p2Selected,
1233+ txt_p2Name,
1234+ motif.select_info.p2_name_font,
1235+ motif.select_info.p2_name_offset[1],
1236+ motif.select_info.p2_name_offset[2],
1237+ motif.select_info.p2_name_font_scale[1],
1238+ motif.select_info.p2_name_font_scale[2],
1239+ motif.select_info.p2_name_spacing[1],
1240+ motif.select_info.p2_name_spacing[2]
1241+ )
1242+ end
1243+ if p1SelEnd and p2SelEnd and p1TeamEnd and p2TeamEnd then
1244+ if main.stageMenu and not stageEnd then --Stage select
1245+ select.f_stageMenu()
1246+ elseif main.coop and not coopEnd then
1247+ coopEnd = true
1248+ p2TeamEnd = false
1249+ else
1250+ selScreenEnd = true
1251+ end
1252+ end
1253+ --draw layerno = 1 backgrounds
1254+ main.f_drawBG(motif.selectbgdef.bg_data, motif.selectbgdef.bg, 1, motif.selectbgdef.timer)
1255+ --draw fadein
1256+ animDraw(motif.select_info.fadein_data)
1257+ animUpdate(motif.select_info.fadein_data)
1258+ --update timer
1259+ motif.selectbgdef.timer = motif.selectbgdef.timer + 1
1260+ --end loop
1261+ main.f_cmdInput()
1262+ refresh()
1263+end
1264+
1265+--;===========================================================
1266+--; PLAYER 1 TEAM MENU
1267+--;===========================================================
1268+local txt_p1TeamSelfTitle = main.f_createTextImg(
1269+ motif.font_data[motif.select_info.p1_teammenu_selftitle_font[1]],
1270+ motif.select_info.p1_teammenu_selftitle_font[2],
1271+ motif.select_info.p1_teammenu_selftitle_font[3],
1272+ motif.select_info.p1_teammenu_selftitle_text,
1273+ motif.select_info.p1_teammenu_pos[1] + motif.select_info.p1_teammenu_selftitle_offset[1],
1274+ motif.select_info.p1_teammenu_pos[2] + motif.select_info.p1_teammenu_selftitle_offset[2],
1275+ motif.select_info.p1_teammenu_selftitle_font_scale[1],
1276+ motif.select_info.p1_teammenu_selftitle_font_scale[2],
1277+ motif.select_info.p1_teammenu_selftitle_font[4],
1278+ motif.select_info.p1_teammenu_selftitle_font[5],
1279+ motif.select_info.p1_teammenu_selftitle_font[6]
1280+)
1281+local txt_p1TeamEnemyTitle = main.f_createTextImg(
1282+ motif.font_data[motif.select_info.p1_teammenu_enemytitle_font[1]],
1283+ motif.select_info.p1_teammenu_enemytitle_font[2],
1284+ motif.select_info.p1_teammenu_enemytitle_font[3],
1285+ motif.select_info.p1_teammenu_enemytitle_text,
1286+ motif.select_info.p1_teammenu_pos[1] + motif.select_info.p1_teammenu_enemytitle_offset[1],
1287+ motif.select_info.p1_teammenu_pos[2] + motif.select_info.p1_teammenu_enemytitle_offset[2],
1288+ motif.select_info.p1_teammenu_enemytitle_font_scale[1],
1289+ motif.select_info.p1_teammenu_enemytitle_font_scale[2],
1290+ motif.select_info.p1_teammenu_enemytitle_font[4],
1291+ motif.select_info.p1_teammenu_enemytitle_font[5],
1292+ motif.select_info.p1_teammenu_enemytitle_font[6]
1293+)
1294+
1295+-- Legacy TAG check and mode enabing
1296+function main.GetTeamMenu()
1297+ local temptag789TeamMenu = {}
1298+ local tempPos = 1
1299+
1300+ -- Single mode check
1301+ if config.SingleTeamMode == true then
1302+ temptag789TeamMenu[1] = {data = textImgNew(), itemname = 'single', displayname = motif.select_info.teammenu_itemname_single}
1303+ tempPos = tempPos + 1
1304+ end
1305+
1306+ if config.SimulMode then
1307+ -- Simul mode check
1308+ if config.NumSimul > 1 then
1309+ temptag789TeamMenu[tempPos] = {data = textImgNew(), itemname = 'simul', displayname = motif.select_info.teammenu_itemname_simul}
1310+ tempPos = tempPos + 1
1311+ end
1312+ -- Tag mode check
1313+ if config.NumTag > 1 then
1314+ temptag789TeamMenu[tempPos] = {data = textImgNew(), itemname = 'tag', displayname = motif.select_info.teammenu_itemname_tag}
1315+ tempPos = tempPos + 1
1316+ end
1317+ else
1318+ -- Legacy Tag mode enable
1319+ temptag789TeamMenu[tempPos] = {data = textImgNew(), itemname = 'simul', displayname = motif.select_info.teammenu_itemname_tag}
1320+ tempPos = tempPos + 1
1321+ end
1322+
1323+ -- Turns mode check
1324+ if config.NumTurns > 1 then
1325+ temptag789TeamMenu[tempPos] = {data = textImgNew(), itemname = 'turns', displayname = motif.select_info.teammenu_itemname_turns}
1326+ end
1327+
1328+ return temptag789TeamMenu
1329+end
1330+
1331+-- Set tag mode
1332+local t_p1TeamMenu = main.GetTeamMenu()
1333+t_p1TeamMenu = main.f_cleanTable(t_p1TeamMenu)
1334+
1335+local p1TeamActiveCount = 0
1336+local p1TeamActiveFont = 'p1_teammenu_item_active_font'
1337+
1338+function select.f_p1TeamMenu()
1339+ if main.p1TeamMenu ~= nil then --Predefined team
1340+ p1NumChars = main.p1TeamMenu.chars
1341+ p1TeamMode = main.p1TeamMenu.mode
1342+ setTeamMode(1, p1TeamMode, p1NumChars)
1343+ p1TeamEnd = true
1344+ else
1345+ --Calculate team cursor position
1346+ if commandGetState(main.p1Cmd, 'u') then
1347+ if p1TeamMenu - 1 >= 1 then
1348+ sndPlay(motif.files.snd_data, motif.select_info.p1_teammenu_move_snd[1], motif.select_info.p1_teammenu_move_snd[2])
1349+ p1TeamMenu = p1TeamMenu - 1
1350+ elseif motif.select_info.teammenu_move_wrapping == 1 then
1351+ sndPlay(motif.files.snd_data, motif.select_info.p1_teammenu_move_snd[1], motif.select_info.p1_teammenu_move_snd[2])
1352+ p1TeamMenu = #t_p1TeamMenu
1353+ end
1354+ elseif commandGetState(main.p1Cmd, 'd') then
1355+ if p1TeamMenu + 1 <= #t_p1TeamMenu then
1356+ sndPlay(motif.files.snd_data, motif.select_info.p1_teammenu_move_snd[1], motif.select_info.p1_teammenu_move_snd[2])
1357+ p1TeamMenu = p1TeamMenu + 1
1358+ elseif motif.select_info.teammenu_move_wrapping == 1 then
1359+ sndPlay(motif.files.snd_data, motif.select_info.p1_teammenu_move_snd[1], motif.select_info.p1_teammenu_move_snd[2])
1360+ p1TeamMenu = 1
1361+ end
1362+ elseif t_p1TeamMenu[p1TeamMenu].itemname == 'simul' then
1363+ if commandGetState(main.p1Cmd, 'l') then
1364+ if p1NumSimul - 1 >= 2 then
1365+ sndPlay(motif.files.snd_data, motif.select_info.p1_teammenu_value_snd[1], motif.select_info.p1_teammenu_value_snd[2])
1366+ p1NumSimul = p1NumSimul - 1
1367+ end
1368+ elseif commandGetState(main.p1Cmd, 'r') then
1369+ if p1NumSimul + 1 <= config.NumSimul then
1370+ sndPlay(motif.files.snd_data, motif.select_info.p1_teammenu_value_snd[1], motif.select_info.p1_teammenu_value_snd[2])
1371+ p1NumSimul = p1NumSimul + 1
1372+ end
1373+ end
1374+ elseif t_p1TeamMenu[p1TeamMenu].itemname == 'turns' then
1375+ if commandGetState(main.p1Cmd, 'l') then
1376+ if p1NumTurns - 1 >= 2 then
1377+ sndPlay(motif.files.snd_data, motif.select_info.p1_teammenu_value_snd[1], motif.select_info.p1_teammenu_value_snd[2])
1378+ p1NumTurns = p1NumTurns - 1
1379+ end
1380+ elseif commandGetState(main.p1Cmd, 'r') then
1381+ if p1NumTurns + 1 <= config.NumTurns then
1382+ sndPlay(motif.files.snd_data, motif.select_info.p1_teammenu_value_snd[1], motif.select_info.p1_teammenu_value_snd[2])
1383+ p1NumTurns = p1NumTurns + 1
1384+ end
1385+ end
1386+ elseif t_p1TeamMenu[p1TeamMenu].itemname == 'tag' then
1387+ if commandGetState(main.p1Cmd, 'l') then
1388+ if p1NumTag - 1 >= 2 then
1389+ sndPlay(motif.files.snd_data, motif.select_info.p1_teammenu_value_snd[1], motif.select_info.p1_teammenu_value_snd[2])
1390+ p1NumTag = p1NumTag - 1
1391+ end
1392+ elseif commandGetState(main.p1Cmd, 'r') then
1393+ if p1NumTag + 1 <= config.NumTag then
1394+ sndPlay(motif.files.snd_data, motif.select_info.p1_teammenu_value_snd[1], motif.select_info.p1_teammenu_value_snd[2])
1395+ p1NumTag = p1NumTag + 1
1396+ end
1397+ end
1398+ end
1399+ --Draw team background
1400+ animUpdate(motif.select_info.p1_teammenu_bg_data)
1401+ animDraw(motif.select_info.p1_teammenu_bg_data)
1402+ --Draw team cursor
1403+ main.f_animPosDraw(
1404+ motif.select_info.p1_teammenu_item_cursor_data,
1405+ (p1TeamMenu - 1) * motif.select_info.p1_teammenu_item_spacing[1],
1406+ (p1TeamMenu - 1) * motif.select_info.p1_teammenu_item_spacing[2]
1407+ )
1408+ --Draw team title
1409+ animUpdate(motif.select_info.p1_teammenu_selftitle_data)
1410+ animDraw(motif.select_info.p1_teammenu_selftitle_data)
1411+ textImgDraw(txt_p1TeamSelfTitle)
1412+ for i = 1, #t_p1TeamMenu do
1413+ if i == p1TeamMenu then
1414+ if p1TeamActiveCount < 2 then --delay change
1415+ p1TeamActiveCount = p1TeamActiveCount + 1
1416+ elseif p1TeamActiveFont == 'p1_teammenu_item_active_font' then
1417+ p1TeamActiveFont = 'p1_teammenu_item_active2_font'
1418+ p1TeamActiveCount = 0
1419+ else
1420+ p1TeamActiveFont = 'p1_teammenu_item_active_font'
1421+ p1TeamActiveCount = 0
1422+ end
1423+ --Draw team active font
1424+ textImgDraw(main.f_updateTextImg(
1425+ t_p1TeamMenu[i].data,
1426+ motif.font_data[motif.select_info[p1TeamActiveFont][1]],
1427+ motif.select_info[p1TeamActiveFont][2],
1428+ motif.select_info.p1_teammenu_item_font[3], --mugen ignores active font facing
1429+ t_p1TeamMenu[i].displayname,
1430+ motif.select_info.p1_teammenu_pos[1] + motif.select_info.p1_teammenu_item_offset[1] + motif.select_info.p1_teammenu_item_font_offset[1] + (i - 1) * motif.select_info.p1_teammenu_item_spacing[1],
1431+ motif.select_info.p1_teammenu_pos[2] + motif.select_info.p1_teammenu_item_offset[2] + motif.select_info.p1_teammenu_item_font_offset[2] + (i - 1) * motif.select_info.p1_teammenu_item_spacing[2],
1432+ motif.select_info[p1TeamActiveFont .. '_scale'][1],
1433+ motif.select_info[p1TeamActiveFont .. '_scale'][2],
1434+ motif.select_info[p1TeamActiveFont][4],
1435+ motif.select_info[p1TeamActiveFont][5],
1436+ motif.select_info[p1TeamActiveFont][6]
1437+ ))
1438+ else
1439+ --Draw team not active font
1440+ textImgDraw(main.f_updateTextImg(
1441+ t_p1TeamMenu[i].data,
1442+ motif.font_data[motif.select_info.p1_teammenu_item_font[1]],
1443+ motif.select_info.p1_teammenu_item_font[2],
1444+ motif.select_info.p1_teammenu_item_font[3],
1445+ t_p1TeamMenu[i].displayname,
1446+ motif.select_info.p1_teammenu_pos[1] + motif.select_info.p1_teammenu_item_offset[1] + motif.select_info.p1_teammenu_item_font_offset[1] + (i - 1) * motif.select_info.p1_teammenu_item_spacing[1],
1447+ motif.select_info.p1_teammenu_pos[2] + motif.select_info.p1_teammenu_item_offset[2] + motif.select_info.p1_teammenu_item_font_offset[2] + (i - 1) * motif.select_info.p1_teammenu_item_spacing[2],
1448+ motif.select_info.p1_teammenu_item_font_scale[1],
1449+ motif.select_info.p1_teammenu_item_font_scale[2],
1450+ motif.select_info.p1_teammenu_item_font[4],
1451+ motif.select_info.p1_teammenu_item_font[5],
1452+ motif.select_info.p1_teammenu_item_font[6]
1453+ ))
1454+ end
1455+ --Draw team icons
1456+ if t_p1TeamMenu[i].itemname == 'simul' then
1457+ for j = 1, config.NumSimul do
1458+ if j <= p1NumSimul then
1459+ main.f_animPosDraw(
1460+ motif.select_info.p1_teammenu_value_icon_data,
1461+ (i - 1) * motif.select_info.p1_teammenu_item_spacing[1] + (j - 1) * motif.select_info.p1_teammenu_value_spacing[1],
1462+ (i - 1) * motif.select_info.p1_teammenu_item_spacing[2] + (j - 1) * motif.select_info.p1_teammenu_value_spacing[2]
1463+ )
1464+ else
1465+ main.f_animPosDraw(
1466+ motif.select_info.p1_teammenu_value_empty_icon_data,
1467+ (i - 1) * motif.select_info.p1_teammenu_item_spacing[1] + (j - 1) * motif.select_info.p1_teammenu_value_spacing[1],
1468+ (i - 1) * motif.select_info.p1_teammenu_item_spacing[2] + (j - 1) * motif.select_info.p1_teammenu_value_spacing[2]
1469+ )
1470+ end
1471+ end
1472+ elseif t_p1TeamMenu[i].itemname == 'turns' then
1473+ for j = 1, config.NumTurns do
1474+ if j <= p1NumTurns then
1475+ main.f_animPosDraw(
1476+ motif.select_info.p1_teammenu_value_icon_data,
1477+ (i - 1) * motif.select_info.p1_teammenu_item_spacing[1] + (j - 1) * motif.select_info.p1_teammenu_value_spacing[1],
1478+ (i - 1) * motif.select_info.p1_teammenu_item_spacing[2] + (j - 1) * motif.select_info.p1_teammenu_value_spacing[2]
1479+ )
1480+ else
1481+ main.f_animPosDraw(
1482+ motif.select_info.p1_teammenu_value_empty_icon_data,
1483+ (i - 1) * motif.select_info.p1_teammenu_item_spacing[1] + (j - 1) * motif.select_info.p1_teammenu_value_spacing[1],
1484+ (i - 1) * motif.select_info.p1_teammenu_item_spacing[2] + (j - 1) * motif.select_info.p1_teammenu_value_spacing[2]
1485+ )
1486+ end
1487+ end
1488+ elseif t_p1TeamMenu[i].itemname == 'tag' then
1489+ for j = 1, config.NumTag do
1490+ if j <= p1NumTag then
1491+ main.f_animPosDraw(
1492+ motif.select_info.p1_teammenu_value_icon_data,
1493+ (i - 1) * motif.select_info.p1_teammenu_item_spacing[1] + (j - 1) * motif.select_info.p1_teammenu_value_spacing[1],
1494+ (i - 1) * motif.select_info.p1_teammenu_item_spacing[2] + (j - 1) * motif.select_info.p1_teammenu_value_spacing[2]
1495+ )
1496+ else
1497+ main.f_animPosDraw(
1498+ motif.select_info.p1_teammenu_value_empty_icon_data,
1499+ (i - 1) * motif.select_info.p1_teammenu_item_spacing[1] + (j - 1) * motif.select_info.p1_teammenu_value_spacing[1],
1500+ (i - 1) * motif.select_info.p1_teammenu_item_spacing[2] + (j - 1) * motif.select_info.p1_teammenu_value_spacing[2]
1501+ )
1502+ end
1503+ end
1504+ end
1505+ end
1506+ --Confirmed team selection
1507+ if main.f_btnPalNo(main.p1Cmd) > 0 then
1508+ sndPlay(motif.files.snd_data, motif.select_info.p1_teammenu_done_snd[1], motif.select_info.p1_teammenu_done_snd[2])
1509+ if t_p1TeamMenu[p1TeamMenu].itemname == 'single' then
1510+ p1TeamMode = 0
1511+ p1NumChars = 1
1512+ elseif t_p1TeamMenu[p1TeamMenu].itemname == 'simul' then
1513+ p1TeamMode = 1
1514+ p1NumChars = p1NumSimul
1515+ elseif t_p1TeamMenu[p1TeamMenu].itemname == 'turns' then
1516+ p1TeamMode = 2
1517+ p1NumChars = p1NumTurns
1518+ elseif t_p1TeamMenu[p1TeamMenu].itemname == 'tag' then
1519+ p1TeamMode = 3
1520+ p1NumChars = p1NumTag
1521+ end
1522+ setTeamMode(1, p1TeamMode, p1NumChars)
1523+ p1TeamEnd = true
1524+ main.f_cmdInput()
1525+ end
1526+ end
1527+end
1528+
1529+--;===========================================================
1530+--; PLAYER 2 TEAM MENU
1531+--;===========================================================
1532+local txt_p2TeamSelfTitle = main.f_createTextImg(
1533+ motif.font_data[motif.select_info.p2_teammenu_selftitle_font[1]],
1534+ motif.select_info.p2_teammenu_selftitle_font[2],
1535+ motif.select_info.p2_teammenu_selftitle_font[3],
1536+ motif.select_info.p2_teammenu_selftitle_text,
1537+ motif.select_info.p2_teammenu_pos[1] + motif.select_info.p2_teammenu_selftitle_offset[1],
1538+ motif.select_info.p2_teammenu_pos[2] + motif.select_info.p2_teammenu_selftitle_offset[2],
1539+ motif.select_info.p2_teammenu_selftitle_font_scale[1],
1540+ motif.select_info.p2_teammenu_selftitle_font_scale[2],
1541+ motif.select_info.p2_teammenu_selftitle_font[4],
1542+ motif.select_info.p2_teammenu_selftitle_font[5],
1543+ motif.select_info.p2_teammenu_selftitle_font[6]
1544+)
1545+local txt_p2TeamEnemyTitle = main.f_createTextImg(
1546+ motif.font_data[motif.select_info.p2_teammenu_enemytitle_font[1]],
1547+ motif.select_info.p2_teammenu_enemytitle_font[2],
1548+ motif.select_info.p2_teammenu_enemytitle_font[3],
1549+ motif.select_info.p2_teammenu_enemytitle_text,
1550+ motif.select_info.p2_teammenu_pos[1] + motif.select_info.p2_teammenu_enemytitle_offset[1],
1551+ motif.select_info.p2_teammenu_pos[2] + motif.select_info.p2_teammenu_enemytitle_offset[2],
1552+ motif.select_info.p2_teammenu_enemytitle_font_scale[1],
1553+ motif.select_info.p2_teammenu_enemytitle_font_scale[2],
1554+ motif.select_info.p2_teammenu_enemytitle_font[4],
1555+ motif.select_info.p2_teammenu_enemytitle_font[5],
1556+ motif.select_info.p2_teammenu_enemytitle_font[6]
1557+)
1558+
1559+-- Set tag mode
1560+local t_p2TeamMenu = main.GetTeamMenu()
1561+t_p2TeamMenu = main.f_cleanTable(t_p2TeamMenu)
1562+
1563+local p2TeamActiveCount = 0
1564+local p2TeamActiveFont = 'p2_teammenu_item_active_font'
1565+
1566+function select.f_p2TeamMenu()
1567+ if main.p2TeamMenu ~= nil then --Predefined team
1568+ p2NumChars = main.p2TeamMenu.chars
1569+ p2TeamMode = main.p2TeamMenu.mode
1570+ setTeamMode(2, p2TeamMode, p2NumChars)
1571+ p2TeamEnd = true
1572+ else
1573+ --Command swap
1574+ local cmd = main.p2Cmd
1575+ if main.coop then
1576+ cmd = main.p1Cmd
1577+ end
1578+ --Calculate team cursor position
1579+ if commandGetState(cmd, 'u') then
1580+ if p2TeamMenu - 1 >= 1 then
1581+ sndPlay(motif.files.snd_data, motif.select_info.p2_teammenu_move_snd[1], motif.select_info.p2_teammenu_move_snd[2])
1582+ p2TeamMenu = p2TeamMenu - 1
1583+ elseif motif.select_info.teammenu_move_wrapping == 1 then
1584+ sndPlay(motif.files.snd_data, motif.select_info.p2_teammenu_move_snd[1], motif.select_info.p2_teammenu_move_snd[2])
1585+ p2TeamMenu = #t_p2TeamMenu
1586+ end
1587+ elseif commandGetState(cmd, 'd') then
1588+ if p2TeamMenu + 1 <= #t_p2TeamMenu then
1589+ sndPlay(motif.files.snd_data, motif.select_info.p2_teammenu_move_snd[1], motif.select_info.p2_teammenu_move_snd[2])
1590+ p2TeamMenu = p2TeamMenu + 1
1591+ elseif motif.select_info.teammenu_move_wrapping == 1 then
1592+ sndPlay(motif.files.snd_data, motif.select_info.p2_teammenu_move_snd[1], motif.select_info.p2_teammenu_move_snd[2])
1593+ p2TeamMenu = 1
1594+ end
1595+ elseif t_p2TeamMenu[p2TeamMenu].itemname == 'simul' then
1596+ if commandGetState(cmd, 'r') then
1597+ if p2NumSimul - 1 >= 2 then
1598+ sndPlay(motif.files.snd_data, motif.select_info.p2_teammenu_value_snd[1], motif.select_info.p2_teammenu_value_snd[2])
1599+ p2NumSimul = p2NumSimul - 1
1600+ end
1601+ elseif commandGetState(cmd, 'l') then
1602+ if p2NumSimul + 1 <= config.NumSimul then
1603+ sndPlay(motif.files.snd_data, motif.select_info.p2_teammenu_value_snd[1], motif.select_info.p2_teammenu_value_snd[2])
1604+ p2NumSimul = p2NumSimul + 1
1605+ end
1606+ end
1607+ elseif t_p2TeamMenu[p2TeamMenu].itemname == 'turns' then
1608+ if commandGetState(cmd, 'r') then
1609+ if p2NumTurns - 1 >= 2 then
1610+ sndPlay(motif.files.snd_data, motif.select_info.p2_teammenu_value_snd[1], motif.select_info.p2_teammenu_value_snd[2])
1611+ p2NumTurns = p2NumTurns - 1
1612+ end
1613+ elseif commandGetState(cmd, 'l') then
1614+ if p2NumTurns + 1 <= config.NumTurns then
1615+ sndPlay(motif.files.snd_data, motif.select_info.p2_teammenu_value_snd[1], motif.select_info.p2_teammenu_value_snd[2])
1616+ p2NumTurns = p2NumTurns + 1
1617+ end
1618+ end
1619+ elseif t_p2TeamMenu[p2TeamMenu].itemname == 'tag' then
1620+ if commandGetState(cmd, 'r') then
1621+ if p2NumTag - 1 >= 2 then
1622+ sndPlay(motif.files.snd_data, motif.select_info.p2_teammenu_value_snd[1], motif.select_info.p2_teammenu_value_snd[2])
1623+ p2NumTag = p2NumTag - 1
1624+ end
1625+ elseif commandGetState(cmd, 'l') then
1626+ if p2NumTag + 1 <= config.NumTag then
1627+ sndPlay(motif.files.snd_data, motif.select_info.p2_teammenu_value_snd[1], motif.select_info.p2_teammenu_value_snd[2])
1628+ p2NumTag = p2NumTag + 1
1629+ end
1630+ end
1631+ end
1632+ --Draw team background
1633+ animUpdate(motif.select_info.p2_teammenu_bg_data)
1634+ animDraw(motif.select_info.p2_teammenu_bg_data)
1635+ --Draw team cursor
1636+ main.f_animPosDraw(
1637+ motif.select_info.p2_teammenu_item_cursor_data,
1638+ (p2TeamMenu - 1) * motif.select_info.p2_teammenu_item_spacing[1],
1639+ (p2TeamMenu - 1) * motif.select_info.p2_teammenu_item_spacing[2]
1640+ )
1641+ --Draw team title
1642+ if main.coop or main.p2In == 1 then
1643+ animUpdate(motif.select_info.p2_teammenu_enemytitle_data)
1644+ animDraw(motif.select_info.p2_teammenu_enemytitle_data)
1645+ textImgDraw(txt_p2TeamEnemyTitle)
1646+ else
1647+ animUpdate(motif.select_info.p2_teammenu_selftitle_data)
1648+ animDraw(motif.select_info.p2_teammenu_selftitle_data)
1649+ textImgDraw(txt_p2TeamSelfTitle)
1650+ end
1651+ for i = 1, #t_p2TeamMenu do
1652+ if i == p2TeamMenu then
1653+ if p2TeamActiveCount < 2 then --delay change
1654+ p2TeamActiveCount = p2TeamActiveCount + 1
1655+ elseif p2TeamActiveFont == 'p2_teammenu_item_active_font' then
1656+ p2TeamActiveFont = 'p2_teammenu_item_active2_font'
1657+ p2TeamActiveCount = 0
1658+ else
1659+ p2TeamActiveFont = 'p2_teammenu_item_active_font'
1660+ p2TeamActiveCount = 0
1661+ end
1662+ --Draw team active font
1663+ textImgDraw(main.f_updateTextImg(
1664+ t_p2TeamMenu[i].data,
1665+ motif.font_data[motif.select_info[p2TeamActiveFont][1]],
1666+ motif.select_info[p2TeamActiveFont][2],
1667+ motif.select_info.p2_teammenu_item_font[3], --mugen ignores active font facing
1668+ t_p2TeamMenu[i].displayname,
1669+ motif.select_info.p2_teammenu_pos[1] + motif.select_info.p2_teammenu_item_offset[1] + motif.select_info.p2_teammenu_item_font_offset[1] + (i - 1) * motif.select_info.p2_teammenu_item_spacing[1],
1670+ motif.select_info.p2_teammenu_pos[2] + motif.select_info.p2_teammenu_item_offset[2] + motif.select_info.p2_teammenu_item_font_offset[2] + (i - 1) * motif.select_info.p2_teammenu_item_spacing[2],
1671+ motif.select_info[p2TeamActiveFont .. '_scale'][1],
1672+ motif.select_info[p2TeamActiveFont .. '_scale'][2],
1673+ motif.select_info[p2TeamActiveFont][4],
1674+ motif.select_info[p2TeamActiveFont][5],
1675+ motif.select_info[p2TeamActiveFont][6]
1676+ ))
1677+ else
1678+ --Draw team not active font
1679+ textImgDraw(main.f_updateTextImg(
1680+ t_p2TeamMenu[i].data,
1681+ motif.font_data[motif.select_info.p2_teammenu_item_font[1]],
1682+ motif.select_info.p2_teammenu_item_font[2],
1683+ motif.select_info.p2_teammenu_item_font[3],
1684+ t_p2TeamMenu[i].displayname,
1685+ motif.select_info.p2_teammenu_pos[1] + motif.select_info.p2_teammenu_item_offset[1] + motif.select_info.p2_teammenu_item_font_offset[1] + (i - 1) * motif.select_info.p2_teammenu_item_spacing[1],
1686+ motif.select_info.p2_teammenu_pos[2] + motif.select_info.p2_teammenu_item_offset[2] + motif.select_info.p2_teammenu_item_font_offset[2] + (i - 1) * motif.select_info.p2_teammenu_item_spacing[2],
1687+ motif.select_info.p2_teammenu_item_font_scale[1],
1688+ motif.select_info.p2_teammenu_item_font_scale[2],
1689+ motif.select_info.p2_teammenu_item_font[4],
1690+ motif.select_info.p2_teammenu_item_font[5],
1691+ motif.select_info.p2_teammenu_item_font[6]
1692+ ))
1693+ end
1694+ --Draw team icons
1695+ if t_p2TeamMenu[i].itemname == 'simul' then
1696+ for j = 1, config.NumSimul do
1697+ if j <= p2NumSimul then
1698+ main.f_animPosDraw(
1699+ motif.select_info.p2_teammenu_value_icon_data,
1700+ (i - 1) * motif.select_info.p2_teammenu_item_spacing[1] + (j - 1) * motif.select_info.p2_teammenu_value_spacing[1],
1701+ (i - 1) * motif.select_info.p2_teammenu_item_spacing[2] + (j - 1) * motif.select_info.p2_teammenu_value_spacing[2]
1702+ )
1703+ else
1704+ main.f_animPosDraw(
1705+ motif.select_info.p2_teammenu_value_empty_icon_data,
1706+ (i - 1) * motif.select_info.p2_teammenu_item_spacing[1] + (j - 1) * motif.select_info.p2_teammenu_value_spacing[1],
1707+ (i - 1) * motif.select_info.p2_teammenu_item_spacing[2] + (j - 1) * motif.select_info.p2_teammenu_value_spacing[2]
1708+ )
1709+ end
1710+ end
1711+ elseif t_p2TeamMenu[i].itemname == 'turns' then
1712+ for j = 1, config.NumTurns do
1713+ if j <= p2NumTurns then
1714+ main.f_animPosDraw(
1715+ motif.select_info.p2_teammenu_value_icon_data,
1716+ (i - 1) * motif.select_info.p2_teammenu_item_spacing[1] + (j - 1) * motif.select_info.p2_teammenu_value_spacing[1],
1717+ (i - 1) * motif.select_info.p2_teammenu_item_spacing[2] + (j - 1) * motif.select_info.p2_teammenu_value_spacing[2]
1718+ )
1719+ else
1720+ main.f_animPosDraw(
1721+ motif.select_info.p2_teammenu_value_empty_icon_data,
1722+ (i - 1) * motif.select_info.p2_teammenu_item_spacing[1] + (j - 1) * motif.select_info.p2_teammenu_value_spacing[1],
1723+ (i - 1) * motif.select_info.p2_teammenu_item_spacing[2] + (j - 1) * motif.select_info.p2_teammenu_value_spacing[2]
1724+ )
1725+ end
1726+ end
1727+ elseif t_p2TeamMenu[i].itemname == 'tag' then
1728+ for j = 1, config.NumTag do
1729+ if j <= p2NumTag then
1730+ main.f_animPosDraw(
1731+ motif.select_info.p2_teammenu_value_icon_data,
1732+ (i - 1) * motif.select_info.p2_teammenu_item_spacing[1] + (j - 1) * motif.select_info.p2_teammenu_value_spacing[1],
1733+ (i - 1) * motif.select_info.p2_teammenu_item_spacing[2] + (j - 1) * motif.select_info.p2_teammenu_value_spacing[2]
1734+ )
1735+ else
1736+ main.f_animPosDraw(
1737+ motif.select_info.p2_teammenu_value_empty_icon_data,
1738+ (i - 1) * motif.select_info.p2_teammenu_item_spacing[1] + (j - 1) * motif.select_info.p2_teammenu_value_spacing[1],
1739+ (i - 1) * motif.select_info.p2_teammenu_item_spacing[2] + (j - 1) * motif.select_info.p2_teammenu_value_spacing[2]
1740+ )
1741+ end
1742+ end
1743+ end
1744+ end
1745+ --Confirmed team selection
1746+ if main.f_btnPalNo(cmd) > 0 then
1747+ sndPlay(motif.files.snd_data, motif.select_info.p2_teammenu_done_snd[1], motif.select_info.p2_teammenu_done_snd[2])
1748+ if t_p2TeamMenu[p2TeamMenu].itemname == 'single' then
1749+ p2TeamMode = 0
1750+ p2NumChars = 1
1751+ elseif t_p2TeamMenu[p2TeamMenu].itemname == 'simul' then
1752+ p2TeamMode = 1
1753+ p2NumChars = p2NumSimul
1754+ elseif t_p2TeamMenu[p2TeamMenu].itemname == 'turns' then
1755+ p2TeamMode = 2
1756+ p2NumChars = p2NumTurns
1757+ elseif t_p2TeamMenu[p2TeamMenu].itemname == 'tag' then
1758+ p2TeamMode = 3
1759+ p2NumChars = p2NumTag
1760+ end
1761+ setTeamMode(2, p2TeamMode, p2NumChars)
1762+ p2TeamEnd = true
1763+ main.f_cmdInput()
1764+ end
1765+ end
1766+end
1767+
1768+--;===========================================================
1769+--; PLAYER 1 SELECT MENU
1770+--;===========================================================
1771+function select.f_p1SelectMenu()
1772+ --predefined selection
1773+ if main.p1Char ~= nil then
1774+ local t = {}
1775+ for i = 1, #main.p1Char do
1776+ if t[main.p1Char[i]] == nil then
1777+ t[main.p1Char[i]] = ''
1778+ end
1779+ t_p1Selected[i] = {cel = main.p1Char[i], pal = select.f_randomPal(main.p1Char[i])}
1780+ end
1781+ p1SelEnd = true
1782+ return
1783+ --manual selection
1784+ elseif not p1SelEnd then
1785+ resetgrid = false
1786+ --cell movement
1787+ p1SelX, p1SelY, p1FaceOffset, p1RowOffset = select.f_cellMovement(p1SelX, p1SelY, main.p1Cmd, p1FaceOffset, p1RowOffset, motif.select_info.p1_cursor_move_snd)
1788+ p1Cell = p1SelX + motif.select_info.columns * p1SelY
1789+ --draw active cursor
1790+ local cursorX = p1FaceX + p1SelX * (motif.select_info.cell_size[1] + motif.select_info.cell_spacing)
1791+ local cursorY = p1FaceY + (p1SelY - p1RowOffset) * (motif.select_info.cell_size[2] + motif.select_info.cell_spacing)
1792+ if resetgrid == true then
1793+ select.f_resetGrid()
1794+ end
1795+ if main.t_selChars[p1Cell + 1].hidden ~= 1 then
1796+ main.f_animPosDraw(motif.select_info.p1_cursor_active_data, cursorX, cursorY)
1797+ end
1798+ --cell selected
1799+ if main.f_btnPalNo(main.p1Cmd) > 0 and main.t_selChars[p1Cell + 1].char ~= nil and main.t_selChars[p1Cell + 1].hidden ~= 2 and #main.t_randomChars > 0 then
1800+ sndPlay(motif.files.snd_data, motif.select_info.p1_cursor_done_snd[1], motif.select_info.p1_cursor_done_snd[2])
1801+ local selected = p1Cell
1802+ if main.t_selChars[selected + 1].char == 'randomselect' or main.t_selChars[selected + 1].hidden == 3 then
1803+ selected = main.t_randomChars[math.random(1, #main.t_randomChars)]
1804+ end
1805+ t_p1Selected[#t_p1Selected + 1] = {cel = selected, pal = main.f_btnPalNo(main.p1Cmd), cursor = {cursorX, cursorY, p1RowOffset}}
1806+ if #t_p1Selected == p1NumChars then
1807+ if main.p2In == 1 and matchNo == 0 then
1808+ p2TeamEnd = false
1809+ p2SelEnd = false
1810+ --commandBufReset(main.p2Cmd)
1811+ end
1812+ p1SelEnd = true
1813+ end
1814+ main.f_cmdInput()
1815+ end
1816+ end
1817+end
1818+
1819+--;===========================================================
1820+--; PLAYER 2 SELECT MENU
1821+--;===========================================================
1822+function select.f_p2SelectMenu()
1823+ --predefined selection
1824+ if main.p2Char ~= nil then
1825+ local t = {}
1826+ for i = 1, #main.p2Char do
1827+ if t[main.p2Char[i]] == nil then
1828+ t[main.p2Char[i]] = ''
1829+ end
1830+ t_p2Selected[i] = {cel = main.p2Char[i], pal = select.f_randomPal(main.p2Char[i])}
1831+ end
1832+ p2SelEnd = true
1833+ return
1834+ --p2 selection disabled
1835+ elseif not main.p2SelectMenu then
1836+ p2SelEnd = true
1837+ return
1838+ --manual selection
1839+ elseif not p2SelEnd then
1840+ resetgrid = false
1841+ --cell movement
1842+ p2SelX, p2SelY, p2FaceOffset, p2RowOffset = select.f_cellMovement(p2SelX, p2SelY, main.p2Cmd, p2FaceOffset, p2RowOffset, motif.select_info.p2_cursor_move_snd)
1843+ p2Cell = p2SelX + motif.select_info.columns * p2SelY
1844+ --draw active cursor
1845+ local cursorX = p2FaceX + p2SelX * (motif.select_info.cell_size[1] + motif.select_info.cell_spacing)
1846+ local cursorY = p2FaceY + (p2SelY - p2RowOffset) * (motif.select_info.cell_size[2] + motif.select_info.cell_spacing)
1847+ if resetgrid == true then
1848+ select.f_resetGrid()
1849+ end
1850+ main.f_animPosDraw(motif.select_info.p2_cursor_active_data, cursorX, cursorY)
1851+ --cell selected
1852+ if main.f_btnPalNo(main.p2Cmd) > 0 and main.t_selChars[p2Cell + 1].char ~= nil and main.t_selChars[p2Cell + 1].hidden ~= 2 and #main.t_randomChars > 0 then
1853+ sndPlay(motif.files.snd_data, motif.select_info.p2_cursor_done_snd[1], motif.select_info.p2_cursor_done_snd[2])
1854+ local selected = p2Cell
1855+ if main.t_selChars[selected + 1].char == 'randomselect' or main.t_selChars[selected + 1].hidden == 3 then
1856+ selected = main.t_randomChars[math.random(1, #main.t_randomChars)]
1857+ end
1858+ t_p2Selected[#t_p2Selected + 1] = {cel = selected, pal = main.f_btnPalNo(main.p2Cmd), cursor = {cursorX, cursorY, p2RowOffset}}
1859+ if #t_p2Selected == p2NumChars then
1860+ p2SelEnd = true
1861+ end
1862+ main.f_cmdInput()
1863+ end
1864+ end
1865+end
1866+
1867+--;===========================================================
1868+--; STAGE MENU
1869+--;===========================================================
1870+local txt_selStage = textImgNew()
1871+
1872+local stageActiveCount = 0
1873+local stageActiveFont = 'stage_active_font'
1874+
1875+function select.f_stageMenu()
1876+ if commandGetState(main.p1Cmd, 'l') then
1877+ sndPlay(motif.files.snd_data, motif.select_info.stage_move_snd[1], motif.select_info.stage_move_snd[2])
1878+ stageList = stageList - 1
1879+ if stageList < 0 then stageList = #main.t_includeStage end
1880+ elseif commandGetState(main.p1Cmd, 'r') then
1881+ sndPlay(motif.files.snd_data, motif.select_info.stage_move_snd[1], motif.select_info.stage_move_snd[2])
1882+ stageList = stageList + 1
1883+ if stageList > #main.t_includeStage then stageList = 0 end
1884+ elseif commandGetState(main.p1Cmd, 'u') then
1885+ sndPlay(motif.files.snd_data, motif.select_info.stage_move_snd[1], motif.select_info.stage_move_snd[2])
1886+ for i = 1, 10 do
1887+ stageList = stageList - 1
1888+ if stageList < 0 then stageList = #main.t_includeStage end
1889+ end
1890+ elseif commandGetState(main.p1Cmd, 'd') then
1891+ sndPlay(motif.files.snd_data, motif.select_info.stage_move_snd[1], motif.select_info.stage_move_snd[2])
1892+ for i = 1, 10 do
1893+ stageList = stageList + 1
1894+ if stageList > #main.t_includeStage then stageList = 0 end
1895+ end
1896+ end
1897+ if main.f_btnPalNo(main.p1Cmd) > 0 then
1898+ sndPlay(motif.files.snd_data, motif.select_info.stage_done_snd[1], motif.select_info.stage_done_snd[2])
1899+ if stageList == 0 then
1900+ stageNo = main.t_includeStage[math.random(1, #main.t_includeStage)]
1901+ setStage(stageNo)
1902+ selectStage(stageNo)
1903+ else
1904+ stageNo = main.t_includeStage[stageList]
1905+ setStage(stageNo)
1906+ selectStage(stageNo)
1907+ end
1908+ stageActiveFont = 'stage_done_font'
1909+ stageEnd = true
1910+ main.f_cmdInput()
1911+ else
1912+ if stageActiveCount < 2 then --delay change
1913+ stageActiveCount = stageActiveCount + 1
1914+ elseif stageActiveFont == 'stage_active_font' then
1915+ stageActiveFont = 'stage_active2_font'
1916+ stageActiveCount = 0
1917+ else
1918+ stageActiveFont = 'stage_active_font'
1919+ stageActiveCount = 0
1920+ end
1921+ end
1922+ local t_txt = {}
1923+ if stageList == 0 then
1924+ t_txt = main.f_extractText(motif.select_info.stage_text, '', 'Random')
1925+ else
1926+ t_txt = main.f_extractText(motif.select_info.stage_text, stageList, getStageName(main.t_includeStage[stageList]):match('^["%s]*(.-)["%s]*$'))
1927+ end
1928+ for i = 1, #t_txt do
1929+ textImgDraw(main.f_updateTextImg(
1930+ txt_selStage,
1931+ motif.font_data[motif.select_info[stageActiveFont][1]],
1932+ motif.select_info[stageActiveFont][2],
1933+ motif.select_info[stageActiveFont][3],
1934+ t_txt[i],
1935+ motif.select_info.stage_pos[1] + (i - 1) * motif.select_info.stage_text_spacing[1],
1936+ motif.select_info.stage_pos[2] + (i - 1) * motif.select_info.stage_text_spacing[2],
1937+ motif.select_info[stageActiveFont .. '_scale'][1],
1938+ motif.select_info[stageActiveFont .. '_scale'][2],
1939+ motif.select_info[stageActiveFont][4],
1940+ motif.select_info[stageActiveFont][5],
1941+ motif.select_info[stageActiveFont][6]
1942+ ))
1943+ end
1944+end
1945+
1946+--;===========================================================
1947+--; VERSUS SCREEN
1948+--;===========================================================
1949+local txt_p1NameVS = main.f_createTextImg(
1950+ motif.font_data[motif.vs_screen.p1_name_font[1]],
1951+ motif.vs_screen.p1_name_font[2],
1952+ motif.vs_screen.p1_name_font[3],
1953+ '',
1954+ 0,
1955+ 0,
1956+ motif.vs_screen.p1_name_font_scale[1],
1957+ motif.vs_screen.p1_name_font_scale[2],
1958+ motif.vs_screen.p1_name_font[4],
1959+ motif.vs_screen.p1_name_font[5],
1960+ motif.vs_screen.p1_name_font[6]
1961+)
1962+local txt_p2NameVS = main.f_createTextImg(
1963+ motif.font_data[motif.vs_screen.p2_name_font[1]],
1964+ motif.vs_screen.p2_name_font[2],
1965+ motif.vs_screen.p2_name_font[3],
1966+ '',
1967+ 0,
1968+ 0,
1969+ motif.vs_screen.p2_name_font_scale[1],
1970+ motif.vs_screen.p2_name_font_scale[2],
1971+ motif.vs_screen.p2_name_font[4],
1972+ motif.vs_screen.p2_name_font[5],
1973+ motif.vs_screen.p2_name_font[6]
1974+)
1975+local txt_matchNo = main.f_createTextImg(
1976+ motif.font_data[motif.vs_screen.match_font[1]],
1977+ motif.vs_screen.match_font[2],
1978+ motif.vs_screen.match_font[3],
1979+ '',
1980+ motif.vs_screen.match_offset[1],
1981+ motif.vs_screen.match_offset[2],
1982+ motif.vs_screen.match_font_scale[1],
1983+ motif.vs_screen.match_font_scale[2],
1984+ motif.vs_screen.match_font[4],
1985+ motif.vs_screen.match_font[5],
1986+ motif.vs_screen.match_font[6]
1987+)
1988+
1989+function select.f_selectVersus()
1990+ local text = main.f_extractText(motif.vs_screen.match_text, matchNo)
1991+ textImgSetText(txt_matchNo, text[1])
1992+ local delay = 0
1993+ local minTime = 15 --let's reserve few extra ticks in case selectChar function needs time to load data, also prevents sound from being interrupted
1994+ main.f_resetBG(motif.vs_screen, motif.versusbgdef, motif.music.vs_bgm)
1995+ if not main.versusScreen then
1996+ delay = minTime
1997+ select.f_selectChar(1, t_p1Selected)
1998+ select.f_selectChar(2, t_p2Selected)
1999+ while true do
2000+ if delay > 0 then
2001+ delay = delay - 1
2002+ else
2003+ main.f_cmdInput()
2004+ break
2005+ end
2006+ main.f_cmdInput()
2007+ refresh()
2008+ end
2009+ else
2010+ local p1Confirmed = false
2011+ local p2Confirmed = false
2012+ local p1Row = 1
2013+ local p2Row = 1
2014+ local t_tmp = {}
2015+ local orderTime = motif.vs_screen.time
2016+ if main.p1In == 1 and main.p2In == 2 and (#t_p1Selected > 1 or #t_p2Selected > 1) and not main.coop then
2017+ orderTime = orderTime + (math.max(#t_p1Selected, #t_p2Selected) - 1) * motif.vs_screen.time_order
2018+ if #t_p1Selected == 1 then
2019+ select.f_selectChar(1, t_p1Selected)
2020+ p1Confirmed = true
2021+ end
2022+ if #t_p2Selected == 1 then
2023+ select.f_selectChar(2, t_p2Selected)
2024+ p2Confirmed = true
2025+ end
2026+ elseif #t_p1Selected > 1 and not main.coop then
2027+ orderTime = orderTime + (#t_p1Selected - 1) * motif.vs_screen.time_order
2028+ else
2029+ select.f_selectChar(1, t_p1Selected)
2030+ p1Confirmed = true
2031+ select.f_selectChar(2, t_p2Selected)
2032+ p2Confirmed = true
2033+ delay = motif.vs_screen.time
2034+ orderTime = -1
2035+ end
2036+ main.f_cmdInput()
2037+ while true do
2038+ if esc() then
2039+ sndPlay(motif.files.snd_data, motif.select_info.cancel_snd[1], motif.select_info.cancel_snd[2])
2040+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
2041+ break
2042+ elseif p1Confirmed and p2Confirmed then
2043+ if orderTime == -1 and main.f_btnPalNo(main.p1Cmd) > 0 and delay > motif.versusbgdef.timer + minTime then
2044+ delay = motif.versusbgdef.timer + minTime
2045+ elseif delay < motif.versusbgdef.timer then
2046+ break
2047+ end
2048+ elseif orderTime <= motif.versusbgdef.timer then
2049+ if not p1Confirmed then
2050+ select.f_selectChar(1, t_p1Selected)
2051+ p1Confirmed = true
2052+ delay = motif.versusbgdef.timer + minTime
2053+ end
2054+ if not p2Confirmed then
2055+ select.f_selectChar(2, t_p2Selected)
2056+ p2Confirmed = true
2057+ delay = motif.versusbgdef.timer + minTime
2058+ end
2059+ else
2060+ local sndRef = ''
2061+ --if Player1 has not confirmed the order yet
2062+ if not p1Confirmed then
2063+ if main.f_btnPalNo(main.p1Cmd) > 0 then
2064+ if not p1Confirmed then
2065+ sndRef = 'p1_cursor_done_snd'
2066+ select.f_selectChar(1, t_p1Selected)
2067+ p1Confirmed = true
2068+ end
2069+ if main.p2In ~= 2 then
2070+ if not p2Confirmed then
2071+ select.f_selectChar(2, t_p2Selected)
2072+ p2Confirmed = true
2073+ end
2074+ end
2075+ elseif commandGetState(main.p1Cmd, 'u') then
2076+ if #t_p1Selected > 1 then
2077+ sndRef = 'p1_cursor_move_snd'
2078+ p1Row = p1Row - 1
2079+ if p1Row == 0 then p1Row = #t_p1Selected end
2080+ end
2081+ elseif commandGetState(main.p1Cmd, 'd') then
2082+ if #t_p1Selected > 1 then
2083+ sndRef = 'p1_cursor_move_snd'
2084+ p1Row = p1Row + 1
2085+ if p1Row > #t_p1Selected then p1Row = 1 end
2086+ end
2087+ elseif commandGetState(main.p1Cmd, 'l') then
2088+ if p1Row - 1 > 0 then
2089+ sndRef = 'p1_cursor_move_snd'
2090+ p1Row = p1Row - 1
2091+ t_tmp = {}
2092+ t_tmp[p1Row] = t_p1Selected[p1Row + 1]
2093+ for i = 1, #t_p1Selected do
2094+ for j = 1, #t_p1Selected do
2095+ if t_tmp[j] == nil and i ~= p1Row + 1 then
2096+ t_tmp[j] = t_p1Selected[i]
2097+ break
2098+ end
2099+ end
2100+ end
2101+ t_p1Selected = t_tmp
2102+ end
2103+ elseif commandGetState(main.p1Cmd, 'r') then
2104+ if p1Row + 1 <= #t_p1Selected then
2105+ sndRef = 'p1_cursor_move_snd'
2106+ p1Row = p1Row + 1
2107+ t_tmp = {}
2108+ t_tmp[p1Row] = t_p1Selected[p1Row - 1]
2109+ for i = 1, #t_p1Selected do
2110+ for j = 1, #t_p1Selected do
2111+ if t_tmp[j] == nil and i ~= p1Row - 1 then
2112+ t_tmp[j] = t_p1Selected[i]
2113+ break
2114+ end
2115+ end
2116+ end
2117+ t_p1Selected = t_tmp
2118+ end
2119+ end
2120+ end
2121+ --if Player2 has not confirmed the order yet and is not controlled by Player1
2122+ if not p2Confirmed and main.p2In ~= 1 then
2123+ if main.f_btnPalNo(main.p2Cmd) > 0 then
2124+ if not p2Confirmed then
2125+ sndRef = 'p2_cursor_done_snd'
2126+ select.f_selectChar(2, t_p2Selected)
2127+ p2Confirmed = true
2128+ end
2129+ elseif commandGetState(main.p2Cmd, 'u') then
2130+ if #t_p2Selected > 1 then
2131+ sndRef = 'p2_cursor_move_snd'
2132+ p2Row = p2Row - 1
2133+ if p2Row == 0 then p2Row = #t_p2Selected end
2134+ end
2135+ elseif commandGetState(main.p2Cmd, 'd') then
2136+ if #t_p2Selected > 1 then
2137+ sndRef = 'p2_cursor_move_snd'
2138+ p2Row = p2Row + 1
2139+ if p2Row > #t_p2Selected then p2Row = 1 end
2140+ end
2141+ elseif commandGetState(main.p2Cmd, 'l') then
2142+ if p2Row + 1 <= #t_p2Selected then
2143+ sndRef = 'p2_cursor_move_snd'
2144+ p2Row = p2Row + 1
2145+ t_tmp = {}
2146+ t_tmp[p2Row] = t_p2Selected[p2Row - 1]
2147+ for i = 1, #t_p2Selected do
2148+ for j = 1, #t_p2Selected do
2149+ if t_tmp[j] == nil and i ~= p2Row - 1 then
2150+ t_tmp[j] = t_p2Selected[i]
2151+ break
2152+ end
2153+ end
2154+ end
2155+ t_p2Selected = t_tmp
2156+ end
2157+ elseif commandGetState(main.p2Cmd, 'r') then
2158+ if p2Row - 1 > 0 then
2159+ sndRef = 'p2_cursor_move_snd'
2160+ p2Row = p2Row - 1
2161+ t_tmp = {}
2162+ t_tmp[p2Row] = t_p2Selected[p2Row + 1]
2163+ for i = 1, #t_p2Selected do
2164+ for j = 1, #t_p2Selected do
2165+ if t_tmp[j] == nil and i ~= p2Row + 1 then
2166+ t_tmp[j] = t_p2Selected[i]
2167+ break
2168+ end
2169+ end
2170+ end
2171+ t_p2Selected = t_tmp
2172+ end
2173+ end
2174+ end
2175+ --sndPlay separated to not play more than 1 sound at once
2176+ if sndRef ~= '' then
2177+ sndPlay(motif.files.snd_data, motif.vs_screen[sndRef][1], motif.vs_screen[sndRef][2])
2178+ delay = motif.versusbgdef.timer + minTime
2179+ end
2180+ end
2181+ --draw clearcolor
2182+ animDraw(motif.versusbgdef.bgclearcolor_data)
2183+ --draw clearcolor
2184+ animDraw(motif.versusbgdef.bgclearcolor_data)
2185+ --draw layerno = 0 backgrounds
2186+ main.f_drawBG(motif.versusbgdef.bg_data, motif.versusbgdef.bg, 0, motif.versusbgdef.timer)
2187+ --draw portraits
2188+ select.f_drawPortrait(
2189+ t_p1Selected,
2190+ motif.vs_screen.p1_pos[1] + motif.vs_screen.p1_offset[1],
2191+ motif.vs_screen.p1_pos[2] + motif.vs_screen.p1_offset[2],
2192+ motif.vs_screen.p1_facing,
2193+ motif.vs_screen.p1_scale[1],
2194+ motif.vs_screen.p1_scale[2],
2195+ motif.vs_screen.p1_spacing[1],
2196+ motif.vs_screen.p1_spacing[2],
2197+ motif.vs_screen.p1_num,
2198+ 'versus'
2199+ )
2200+ select.f_drawPortrait(
2201+ t_p2Selected,
2202+ motif.vs_screen.p2_pos[1] + motif.vs_screen.p2_offset[1],
2203+ motif.vs_screen.p2_pos[2] + motif.vs_screen.p2_offset[2],
2204+ motif.vs_screen.p2_facing,
2205+ motif.vs_screen.p2_scale[1],
2206+ motif.vs_screen.p2_scale[2],
2207+ motif.vs_screen.p2_spacing[1],
2208+ motif.vs_screen.p2_spacing[2],
2209+ motif.vs_screen.p2_num,
2210+ 'versus'
2211+ )
2212+ --draw names
2213+ select.f_drawName(
2214+ t_p1Selected,
2215+ txt_p1NameVS,
2216+ motif.vs_screen.p1_name_font,
2217+ motif.vs_screen.p1_name_pos[1] + motif.vs_screen.p1_name_offset[1],
2218+ motif.vs_screen.p1_name_pos[2] + motif.vs_screen.p1_name_offset[2],
2219+ motif.vs_screen.p1_name_font_scale[1],
2220+ motif.vs_screen.p1_name_font_scale[2],
2221+ motif.vs_screen.p1_name_spacing[1],
2222+ motif.vs_screen.p1_name_spacing[2],
2223+ motif.vs_screen.p1_name_active_font,
2224+ p1Row
2225+ )
2226+ select.f_drawName(
2227+ t_p2Selected,
2228+ txt_p2NameVS,
2229+ motif.vs_screen.p2_name_font,
2230+ motif.vs_screen.p2_name_pos[1] + motif.vs_screen.p2_name_offset[1],
2231+ motif.vs_screen.p2_name_pos[2] + motif.vs_screen.p2_name_offset[2],
2232+ motif.vs_screen.p2_name_font_scale[1],
2233+ motif.vs_screen.p2_name_font_scale[2],
2234+ motif.vs_screen.p2_name_spacing[1],
2235+ motif.vs_screen.p2_name_spacing[2],
2236+ motif.vs_screen.p2_name_active_font,
2237+ p2Row
2238+ )
2239+ --draw match counter
2240+ if matchNo > 0 then
2241+ textImgDraw(txt_matchNo)
2242+ end
2243+ --draw layerno = 1 backgrounds
2244+ main.f_drawBG(motif.versusbgdef.bg_data, motif.versusbgdef.bg, 1, motif.versusbgdef.timer)
2245+ --draw fadein
2246+ animDraw(motif.vs_screen.fadein_data)
2247+ animUpdate(motif.vs_screen.fadein_data)
2248+ --update timer
2249+ motif.versusbgdef.timer = motif.versusbgdef.timer + 1
2250+ --end loop
2251+ main.f_cmdInput()
2252+ refresh()
2253+ end
2254+ end
2255+end
2256+
2257+function select.f_selectChar(player, t)
2258+ for i = 1, #t do
2259+ selectChar(player, t[i].cel, t[i].pal)
2260+ end
2261+end
2262+
2263+--;===========================================================
2264+--; RESULT SCREEN
2265+--;===========================================================
2266+local txt_resultSurvival = main.f_createTextImg(
2267+ motif.font_data[motif.survival_results_screen.winstext_font[1]],
2268+ motif.survival_results_screen.winstext_font[2],
2269+ motif.survival_results_screen.winstext_font[3],
2270+ '',
2271+ motif.survival_results_screen.winstext_offset[1],
2272+ motif.survival_results_screen.winstext_offset[2],
2273+ motif.survival_results_screen.winstext_font_scale[1],
2274+ motif.survival_results_screen.winstext_font_scale[2],
2275+ motif.survival_results_screen.winstext_font[4],
2276+ motif.survival_results_screen.winstext_font[5],
2277+ motif.survival_results_screen.winstext_font[6]
2278+)
2279+local txt_resultVS100 = main.f_createTextImg(
2280+ motif.font_data[motif.vs100kumite_results_screen.winstext_font[1]],
2281+ motif.vs100kumite_results_screen.winstext_font[2],
2282+ motif.vs100kumite_results_screen.winstext_font[3],
2283+ '',
2284+ motif.vs100kumite_results_screen.winstext_offset[1],
2285+ motif.vs100kumite_results_screen.winstext_offset[2],
2286+ motif.vs100kumite_results_screen.winstext_font_scale[1],
2287+ motif.vs100kumite_results_screen.winstext_font_scale[2],
2288+ motif.survival_results_screen.winstext_font[4],
2289+ motif.survival_results_screen.winstext_font[5],
2290+ motif.survival_results_screen.winstext_font[6]
2291+)
2292+
2293+function select.f_result(state)
2294+ --if state == true then --win
2295+ --elseif state == false then --loose
2296+ --end
2297+ local t = {}
2298+ local t_resultText = {}
2299+ local txt = ''
2300+ if main.gameMode == 'survival' or main.gameMode == 'survivalcoop' or main.gameMode == 'netplaysurvivalcoop' then
2301+ t = motif.survival_results_screen
2302+ t_resultText = main.f_extractText(t.winstext_text, winCnt)
2303+ txt = txt_resultSurvival
2304+ elseif main.gameMode == '100kumite' then
2305+ t = motif.vs100kumite_results_screen
2306+ t_resultText = main.f_extractText(t.winstext_text, winCnt, looseCnt)
2307+ txt = txt_resultVS100
2308+ else
2309+ return
2310+ end
2311+ main.f_resetBG(t, motif.resultsbgdef, motif.music.results_bgm)
2312+ main.f_cmdInput()
2313+ while true do
2314+ if esc() or main.f_btnPalNo(main.p1Cmd) > 0 then
2315+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
2316+ break
2317+ elseif motif.resultsbgdef.timer >= t.show_time then
2318+ --add fadeout code here
2319+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
2320+ break
2321+ end
2322+ --draw clearcolor
2323+ --animDraw(motif.resultsbgdef.bgclearcolor_data) --disabled to not cover game screen
2324+ --draw layerno = 0 backgrounds
2325+ main.f_drawBG(motif.resultsbgdef.bg_data, motif.resultsbgdef.bg, 0, motif.resultsbgdef.timer)
2326+ --draw text
2327+ for i = 1, #t_resultText do
2328+ textImgSetText(txt, t_resultText[i])
2329+ textImgSetPos(
2330+ txt,
2331+ t.winstext_offset[1] - t.winstext_spacing[1] + i * t.winstext_spacing[1],
2332+ t.winstext_offset[2] - t.winstext_spacing[2] + i * t.winstext_spacing[2]
2333+ )
2334+ textImgDraw(txt)
2335+ end
2336+ --draw layerno = 1 backgrounds
2337+ main.f_drawBG(motif.resultsbgdef.bg_data, motif.resultsbgdef.bg, 1, motif.resultsbgdef.timer)
2338+ --draw fadein
2339+ animDraw(t.fadein_data)
2340+ animUpdate(t.fadein_data)
2341+ --update timer
2342+ motif.resultsbgdef.timer = motif.resultsbgdef.timer + 1
2343+ --end loop
2344+ main.f_cmdInput()
2345+ refresh()
2346+ end
2347+end
2348+
2349+--;===========================================================
2350+--; VICTORY SCREEN
2351+--;===========================================================
2352+local txt_winquote = main.f_createTextImg(
2353+ motif.font_data[motif.victory_screen.winquote_font[1]],
2354+ motif.victory_screen.winquote_font[2],
2355+ motif.victory_screen.winquote_font[3],
2356+ '',
2357+ 0,
2358+ 0,
2359+ motif.victory_screen.winquote_font_scale[1],
2360+ motif.victory_screen.winquote_font_scale[2],
2361+ motif.victory_screen.winquote_font[4],
2362+ motif.victory_screen.winquote_font[5],
2363+ motif.victory_screen.winquote_font[6]
2364+)
2365+local txt_p1_winquoteName = main.f_createTextImg(
2366+ motif.font_data[motif.victory_screen.p1_name_font[1]],
2367+ motif.victory_screen.p1_name_font[2],
2368+ motif.victory_screen.p1_name_font[3],
2369+ '',
2370+ motif.victory_screen.p1_name_offset[1],
2371+ motif.victory_screen.p1_name_offset[2],
2372+ motif.victory_screen.p1_name_font_scale[1],
2373+ motif.victory_screen.p1_name_font_scale[2],
2374+ motif.victory_screen.p1_name_font[4],
2375+ motif.victory_screen.p1_name_font[5],
2376+ motif.victory_screen.p1_name_font[6]
2377+)
2378+local txt_p2_winquoteName = main.f_createTextImg(
2379+ motif.font_data[motif.victory_screen.p2_name_font[1]],
2380+ motif.victory_screen.p2_name_font[2],
2381+ motif.victory_screen.p2_name_font[3],
2382+ '',
2383+ motif.victory_screen.p2_name_offset[1],
2384+ motif.victory_screen.p2_name_offset[2],
2385+ motif.victory_screen.p2_name_font_scale[1],
2386+ motif.victory_screen.p2_name_font_scale[2],
2387+ motif.victory_screen.p2_name_font[4],
2388+ motif.victory_screen.p2_name_font[5],
2389+ motif.victory_screen.p2_name_font[6]
2390+)
2391+
2392+function select.f_selectVictory()
2393+ if motif.music.victory_bgm == '' then
2394+ main.f_resetBG(motif.victory_screen, motif.victorybgdef)
2395+ else
2396+ main.f_resetBG(motif.victory_screen, motif.victorybgdef, motif.music.victory_bgm)
2397+ end
2398+ local winquote = ''
2399+ local winnerNum = 0
2400+ local p1Num = t_gameStats.chars[t_gameStats.lastRound][1].selectNo
2401+ local p2Num = t_gameStats.chars[t_gameStats.lastRound][2].selectNo
2402+ local txt_winquoteName = ''
2403+ if winner == 1 then
2404+ winquote = getCharVictoryQuote(1)
2405+ txt_winquoteName = txt_p1_winquoteName
2406+ winnerNum = p1Num
2407+ else
2408+ winquote = getCharVictoryQuote(2)
2409+ txt_winquoteName = txt_p2_winquoteName
2410+ winnerNum = p2Num
2411+ end
2412+ if winquote == nil or winquote == '' then
2413+ winquote = motif.victory_screen.winquote_text
2414+ end
2415+ textImgSetText(txt_p1_winquoteName, main.f_getName(p1Num))
2416+ textImgSetText(txt_p2_winquoteName, main.f_getName(p2Num))
2417+ local i = 0
2418+ main.f_cmdInput()
2419+ while true do
2420+ if esc() or main.f_btnPalNo(main.p1Cmd) > 0 then
2421+ main.f_cmdInput()
2422+ break
2423+ elseif motif.victorybgdef.timer >= motif.victory_screen.time then
2424+ --add fadeout code here
2425+ main.f_cmdInput()
2426+ break
2427+ end
2428+ --draw clearcolor
2429+ animDraw(motif.victorybgdef.bgclearcolor_data)
2430+ --draw layerno = 0 backgrounds
2431+ main.f_drawBG(motif.victorybgdef.bg_data, motif.victorybgdef.bg, 0, motif.victorybgdef.timer)
2432+ --draw portraits
2433+ if motif.victory_screen.p2_display == 0 then
2434+ drawVictoryPortrait(
2435+ winnerNum,
2436+ motif.victory_screen.p1_offset[1],
2437+ motif.victory_screen.p1_offset[2],
2438+ motif.victory_screen.p1_facing,
2439+ motif.victory_screen.p1_scale[1],
2440+ motif.victory_screen.p1_scale[2]
2441+ )
2442+ else
2443+ drawVictoryPortrait(
2444+ p1Num,
2445+ motif.victory_screen.p1_offset[1],
2446+ motif.victory_screen.p1_offset[2],
2447+ motif.victory_screen.p1_facing,
2448+ motif.victory_screen.p1_scale[1],
2449+ motif.victory_screen.p1_scale[2]
2450+ )
2451+ drawVictoryPortrait(
2452+ p2Num,
2453+ motif.victory_screen.p2_offset[1],
2454+ motif.victory_screen.p2_offset[2],
2455+ motif.victory_screen.p2_facing,
2456+ motif.victory_screen.p2_scale[1],
2457+ motif.victory_screen.p2_scale[2]
2458+ )
2459+ end
2460+ --draw winner's name
2461+ textImgDraw(txt_winquoteName)
2462+ --draw winquote
2463+ i = i + 1
2464+ main.f_textRender(
2465+ txt_winquote,
2466+ winquote,
2467+ i,
2468+ motif.victory_screen.winquote_offset[1],
2469+ motif.victory_screen.winquote_offset[2],
2470+ motif.victory_screen.winquote_spacing[2],
2471+ motif.victory_screen.winquote_delay,
2472+ motif.victory_screen.winquote_length
2473+ )
2474+ --draw layerno = 1 backgrounds
2475+ main.f_drawBG(motif.victorybgdef.bg_data, motif.victorybgdef.bg, 1, motif.victorybgdef.timer)
2476+ --draw fadein
2477+ animDraw(motif.victory_screen.fadein_data)
2478+ animUpdate(motif.victory_screen.fadein_data)
2479+ --update timer
2480+ motif.victorybgdef.timer = motif.victorybgdef.timer + 1
2481+ --end loop
2482+ main.f_cmdInput()
2483+ refresh()
2484+ end
2485+end
2486+
2487+--;===========================================================
2488+--; CONTINUE SCREEN
2489+--;===========================================================
2490+local txt_credits = main.f_createTextImg(
2491+ motif.font_data[motif.continue_screen.credits_font[1]],
2492+ motif.continue_screen.credits_font[2],
2493+ motif.continue_screen.credits_font[3],
2494+ '',
2495+ motif.continue_screen.credits_offset[1],
2496+ motif.continue_screen.credits_offset[2],
2497+ motif.continue_screen.credits_font_scale[1],
2498+ motif.continue_screen.credits_font_scale[2],
2499+ motif.continue_screen.credits_font[4],
2500+ motif.continue_screen.credits_font[5],
2501+ motif.continue_screen.credits_font[6]
2502+)
2503+
2504+function select.f_continue()
2505+ main.f_resetBG(motif.continue_screen, motif.continuebgdef, motif.music.continue_bgm)
2506+ animReset(motif.continue_screen.continue_anim_data)
2507+ animUpdate(motif.continue_screen.continue_anim_data)
2508+ continue = false
2509+ local text = main.f_extractText(motif.continue_screen.credits_text, main.credits)
2510+ textImgSetText(txt_credits, text[1])
2511+ main.f_cmdInput()
2512+ while true do
2513+ --draw clearcolor (disabled to not cover area)
2514+ --animDraw(motif.continuebgdef.bgclearcolor_data)
2515+ --draw layerno = 0 backgrounds
2516+ main.f_drawBG(motif.continuebgdef.bg_data, motif.continuebgdef.bg, 0, motif.continuebgdef.timer)
2517+ --continue screen state
2518+ if esc() or motif.continuebgdef.timer > motif.continue_screen.endtime then
2519+ main.f_cmdInput()
2520+ break
2521+ elseif motif.continuebgdef.timer < motif.continue_screen.continue_end_skiptime then
2522+ if commandGetState(main.p1Cmd, 'holds') then
2523+ continue = true
2524+ main.credits = main.credits - 1
2525+ text = main.f_extractText(motif.continue_screen.credits_text, main.credits)
2526+ textImgSetText(txt_credits, text[1])
2527+ main.f_cmdInput()
2528+ main.f_resetBG(motif.select_info, motif.selectbgdef, motif.music.select_bgm)
2529+ break
2530+ elseif main.f_btnPalNo(main.p1Cmd) > 0 and motif.continuebgdef.timer >= motif.continue_screen.continue_starttime + motif.continue_screen.continue_skipstart then
2531+ local cnt = 0
2532+ if motif.continuebgdef.timer < motif.continue_screen.continue_9_skiptime then
2533+ cnt = motif.continue_screen.continue_9_skiptime
2534+ elseif motif.continuebgdef.timer <= motif.continue_screen.continue_8_skiptime then
2535+ cnt = motif.continue_screen.continue_8_skiptime
2536+ elseif motif.continuebgdef.timer < motif.continue_screen.continue_7_skiptime then
2537+ cnt = motif.continue_screen.continue_7_skiptime
2538+ elseif motif.continuebgdef.timer < motif.continue_screen.continue_6_skiptime then
2539+ cnt = motif.continue_screen.continue_6_skiptime
2540+ elseif motif.continuebgdef.timer < motif.continue_screen.continue_5_skiptime then
2541+ cnt = motif.continue_screen.continue_5_skiptime
2542+ elseif motif.continuebgdef.timer < motif.continue_screen.continue_4_skiptime then
2543+ cnt = motif.continue_screen.continue_4_skiptime
2544+ elseif motif.continuebgdef.timer < motif.continue_screen.continue_3_skiptime then
2545+ cnt = motif.continue_screen.continue_3_skiptime
2546+ elseif motif.continuebgdef.timer < motif.continue_screen.continue_2_skiptime then
2547+ cnt = motif.continue_screen.continue_2_skiptime
2548+ elseif motif.continuebgdef.timer < motif.continue_screen.continue_1_skiptime then
2549+ cnt = motif.continue_screen.continue_1_skiptime
2550+ elseif motif.continuebgdef.timer < motif.continue_screen.continue_0_skiptime then
2551+ cnt = motif.continue_screen.continue_0_skiptime
2552+ end
2553+ while motif.continuebgdef.timer < cnt do
2554+ motif.continuebgdef.timer = motif.continuebgdef.timer + 1
2555+ animUpdate(motif.continue_screen.continue_anim_data)
2556+ end
2557+ end
2558+ if motif.continuebgdef.timer == motif.continue_screen.continue_9_skiptime then
2559+ sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_9_snd[1], motif.continue_screen.continue_9_snd[2])
2560+ elseif motif.continuebgdef.timer == motif.continue_screen.continue_8_skiptime then
2561+ sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_8_snd[1], motif.continue_screen.continue_8_snd[2])
2562+ elseif motif.continuebgdef.timer == motif.continue_screen.continue_7_skiptime then
2563+ sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_7_snd[1], motif.continue_screen.continue_7_snd[2])
2564+ elseif motif.continuebgdef.timer == motif.continue_screen.continue_6_skiptime then
2565+ sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_6_snd[1], motif.continue_screen.continue_6_snd[2])
2566+ elseif motif.continuebgdef.timer == motif.continue_screen.continue_5_skiptime then
2567+ sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_5_snd[1], motif.continue_screen.continue_5_snd[2])
2568+ elseif motif.continuebgdef.timer == motif.continue_screen.continue_4_skiptime then
2569+ sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_4_snd[1], motif.continue_screen.continue_4_snd[2])
2570+ elseif motif.continuebgdef.timer == motif.continue_screen.continue_3_skiptime then
2571+ sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_3_snd[1], motif.continue_screen.continue_3_snd[2])
2572+ elseif motif.continuebgdef.timer == motif.continue_screen.continue_2_skiptime then
2573+ sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_2_snd[1], motif.continue_screen.continue_2_snd[2])
2574+ elseif motif.continuebgdef.timer == motif.continue_screen.continue_1_skiptime then
2575+ sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_1_snd[1], motif.continue_screen.continue_1_snd[2])
2576+ elseif motif.continuebgdef.timer == motif.continue_screen.continue_0_skiptime then
2577+ sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_0_snd[1], motif.continue_screen.continue_0_snd[2])
2578+ end
2579+ elseif motif.continuebgdef.timer == motif.continue_screen.continue_end_skiptime then
2580+ playBGM(motif.music.continue_end_bgm)
2581+ sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_end_snd[1], motif.continue_screen.continue_end_snd[2])
2582+ end
2583+ --draw credits text
2584+ if motif.continuebgdef.timer >= motif.continue_screen.continue_skipstart then --show when counter starts counting down
2585+ textImgDraw(txt_credits)
2586+ end
2587+ --draw counter
2588+ animUpdate(motif.continue_screen.continue_anim_data)
2589+ animDraw(motif.continue_screen.continue_anim_data)
2590+ --draw layerno = 1 backgrounds
2591+ main.f_drawBG(motif.continuebgdef.bg_data, motif.continuebgdef.bg, 1, motif.continuebgdef.timer)
2592+ --draw fadein
2593+ animDraw(motif.continue_screen.fadein_data)
2594+ animUpdate(motif.continue_screen.fadein_data)
2595+ --update timer
2596+ motif.continuebgdef.timer = motif.continuebgdef.timer + 1
2597+ --end loop
2598+ main.f_cmdInput()
2599+ refresh()
2600+ end
2601+end
2602+
2603+return select
--- /dev/null
+++ b/script/storyboard.lua
@@ -0,0 +1,561 @@
1+
2+local storyboard = {}
3+
4+--http://www.elecbyte.com/mugendocs/storyboard.html
5+
6+storyboard.t_storyboard = {} --stores all parsed storyboards (we parse each of them only once)
7+
8+local function f_reset(t)
9+ for k, v in pairs(t.scene) do
10+ if t.scene[k].fadein_data ~= nil then
11+ animReset(t.scene[k].fadein_data)
12+ animUpdate(t.scene[k].fadein_data)
13+ end
14+ if t.scene[k].fadeout_data ~= nil then
15+ animReset(t.scene[k].fadeout_data)
16+ animUpdate(t.scene[k].fadeout_data)
17+ end
18+ if t.scene[k].bg_name ~= '' then
19+ local t_bgdef = t[t.scene[k].bg_name .. 'def']
20+ for i = 1, #t_bgdef do
21+ t_bgdef[i].ctrl_flags.visible = 1
22+ t_bgdef[i].ctrl_flags.enabled = 1
23+ t_bgdef[i].ctrl_flags.velx = 0
24+ t_bgdef[i].ctrl_flags.vely = 0
25+ animReset(t.scene[k].bg_data[i])
26+ animAddPos(t.scene[k].bg_data[i], 0 - t_bgdef[i].ctrl_flags.x, 0 - t_bgdef[i].ctrl_flags.y)
27+ animUpdate(t.scene[k].bg_data[i])
28+ t_bgdef[i].ctrl_flags.x = 0
29+ t_bgdef[i].ctrl_flags.y = 0
30+ for k2, v2 in pairs(t_bgdef[i].ctrl) do
31+ for j = 1, #t_bgdef[i].ctrl[k2] do
32+ t_bgdef[i].ctrl[k2][j].timer[1] = t_bgdef[i].ctrl[k2][j].time[1]
33+ t_bgdef[i].ctrl[k2][j].timer[2] = t_bgdef[i].ctrl[k2][j].time[2]
34+ t_bgdef[i].ctrl[k2][j].timer[3] = t_bgdef[i].ctrl[k2][j].time[3]
35+ end
36+ end
37+ end
38+ end
39+ for k2, v2 in pairs(t.scene[k].layer) do
40+ if t.scene[k].layer[k2].anim_data ~= nil then
41+ animReset(t.scene[k].layer[k2].anim_data)
42+ animUpdate(t.scene[k].layer[k2].anim_data)
43+ end
44+ t.scene[k].layer[k2].text_timer = 0
45+ end
46+ end
47+end
48+
49+local function f_play(t)
50+ main.f_printTable(t, 'debug/t_storyboard.txt')
51+ --loop through scenes in order
52+ for k, v in main.f_sortKeys(t.scene) do
53+ --scene >= startscene
54+ if k >= t.scenedef.startscene then
55+ for i = 0, t.scene[k].end_time do
56+ --end storyboard
57+ if esc() or main.f_btnPalNo(main.p1Cmd) > 0 then
58+ main.f_cmdInput()
59+ refresh()
60+ return
61+ end
62+ --play bgm
63+ if i == 0 and t.scene[k].bgm ~= nil then
64+ playBGM(t.scene[k].bgm)
65+ end
66+ --play snd
67+ if t.scenedef.snd_data ~= nil then
68+ for j = 1, #t.scene[k].sound do
69+ if i == t.scene[k].sound[j].starttime then
70+ sndPlay(t.scenedef.snd_data, t.scene[k].sound[j].value[1], t.scene[k].sound[j].value[2])
71+ end
72+ end
73+ end
74+ --clearcolor
75+ animDraw(t.scene[k].clearcolor_data)
76+ --draw layerno = 0 backgrounds
77+ if t.scene[k].bg_name ~= '' then
78+ main.f_drawBG(t.scene[k].bg_data, t[t.scene[k].bg_name .. 'def'], 0, i)
79+ end
80+ --loop through layers in order
81+ for k2, v2 in main.f_sortKeys(t.scene[k].layer) do
82+ if i >= t.scene[k].layer[k2].starttime and i <= t.scene[k].layer[k2].endtime then
83+ --layer anim
84+ if t.scene[k].layer[k2].anim_data ~= nil then
85+ animDraw(t.scene[k].layer[k2].anim_data)
86+ animUpdate(t.scene[k].layer[k2].anim_data)
87+ end
88+ --layer text
89+ if t.scene[k].layer[k2].text_data ~= nil then
90+ t.scene[k].layer[k2].text_timer = t.scene[k].layer[k2].text_timer + 1
91+ main.f_textRender(
92+ t.scene[k].layer[k2].text_data,
93+ t.scene[k].layer[k2].text,
94+ t.scene[k].layer[k2].text_timer,
95+ t.scene[k].layerall_pos[1] + t_layer[k2].offset[1],
96+ t.scene[k].layerall_pos[2] + t_layer[k2].offset[2],
97+ t.scene[k].layer[k2].text_spacing,
98+ t.scene[k].layer[k2].text_delay,
99+ t.scene[k].layer[k2].text_length
100+ )
101+ end
102+ end
103+ end
104+ --draw layerno = 1 backgrounds
105+ if t.scene[k].bg_name ~= '' then
106+ main.f_drawBG(t.scene[k].bg_data, t[t.scene[k].bg_name .. 'def'], 1, i)
107+ end
108+ --fadein
109+ if i <= t.scene[k].fadein_time then
110+ animDraw(t.scene[k].fadein_data)
111+ animUpdate(t.scene[k].fadein_data)
112+ end
113+ --fadeout
114+ if i >= t.scene[k].end_time - t.scene[k].fadeout_time then
115+ animDraw(t.scene[k].fadeout_data)
116+ animUpdate(t.scene[k].fadeout_data)
117+ end
118+ main.f_cmdInput()
119+ refresh()
120+ end
121+ end
122+ end
123+ playBGM('')
124+end
125+
126+local function f_parse(path)
127+ -- Intro haves his own localcoord function
128+ -- So we disable it
129+ main.SetDefaultScale()
130+
131+ local file = io.open(path, 'r')
132+ local fileDir, fileName = path:match('^(.-)([^/\\]+)$')
133+ local t = {}
134+ local pos = t
135+ local pos_default = {}
136+ local pos_val = {}
137+ t.anim = {}
138+ t.ctrldef = {}
139+ t.scene = {}
140+ t.fileDir = fileDir
141+ t.fileName = fileName
142+ local bgdef = 'dummyUntilSet'
143+ local bgctrl = ''
144+ local bgctrl_match = 'dummyUntilSet'
145+ local tmp = ''
146+ local t_default =
147+ {
148+ info = {localcoord = {320, 240}},
149+ scenedef = {spr = '', snd = '', font = {[1] = 'font/f-6x9.fnt'}, font_height = {}, startscene = 0, font_data = {}},
150+ scene = {},
151+ ctrldef = {}
152+ }
153+ for line in file:lines() do
154+ line = line:gsub('%s*;.*$', '')
155+ if line:match('^%s*%[.-%s*%]%s*$') then --matched [] group
156+ line = line:match('^%s*%[(.-)%s*%]%s*$') --match text between []
157+ line = line:gsub('[%. ]', '_') --change . and space to _
158+ line = line:lower() --lowercase line
159+ local row = tostring(line:lower()) --just in case it's a number (not really needed)
160+ if row:match('.+ctrldef') then --matched ctrldef start
161+ bgctrl = row
162+ bgctrl_match = bgctrl:match('^(.-ctrl)def')
163+ t.ctrldef[bgdef .. 'def'][bgctrl] = {}
164+ t.ctrldef[bgdef .. 'def'][bgctrl].ctrl = {}
165+ pos = t.ctrldef[bgdef .. 'def'][bgctrl]
166+ t_default.ctrldef[bgdef .. 'def'][bgctrl] = {
167+ looptime = -1,
168+ ctrlid = {0},
169+ ctrl = {}
170+ }
171+ elseif row:match('^' .. bgctrl_match) then --matched ctrldef content
172+ tmp = t.ctrldef[bgdef .. 'def'][bgctrl].ctrl
173+ tmp[#tmp + 1] = {}
174+ pos = tmp[#tmp]
175+ t_default.ctrldef[bgdef .. 'def'][bgctrl].ctrl[#tmp] = {
176+ type = 'null',
177+ time = {0, -1, -1},
178+ ctrlid = {}
179+ }
180+ elseif row:match('.+def$') and not row:match('^scenedef$') --[[and not row:match('^' .. bgdef .. '.*$')]] then --matched bgdef start
181+ t[row] = {}
182+ pos = t[row]
183+ bgdef = row:match('(.+)def$')
184+ t_default[row] = {}
185+ t.ctrldef[bgdef .. 'def'] = {}
186+ t_default.ctrldef[bgdef .. 'def'] = {}
187+ elseif row:match('^' .. bgdef) then --matched bgdef content
188+ tmp = t[bgdef .. 'def']
189+ tmp[#tmp + 1] = {}
190+ pos = tmp[#tmp]
191+ t_default[bgdef .. 'def'][#tmp] =
192+ {
193+ type = 'normal',
194+ spriteno = {0, 0},
195+ id = 0,
196+ layerno = 0,
197+ start = {0, 0},
198+ delta = {1, 1},
199+ trans = '',
200+ mask = 0,
201+ tile = {0, 0},
202+ tilespacing = {0, nil},
203+ --window = {0, 0, 0, 0},
204+ --windowdelta = {0, 0}, --not supported yet
205+ --width = {0, 0}, --not supported yet (parallax)
206+ --xscale = {1.0, 1.0}, --not supported yet (parallax)
207+ --yscalestart = 100, --not supported yet (parallax)
208+ --yscaledelta = 1, --not supported yet (parallax)
209+ positionlink = 0,
210+ velocity = {0, 0},
211+ --sin_x = {0, 0, 0}, --not supported yet
212+ --sin_y = {0, 0, 0}, --not supported yet
213+ ctrl = {},
214+ ctrl_flags = {
215+ visible = 1,
216+ enabled = 1,
217+ velx = 0,
218+ vely = 0,
219+ x = 0,
220+ y = 0
221+ }
222+ }
223+ elseif row:match('^scene_[0-9]+$') then --matched scene
224+ row = tonumber(row:match('^scene_([0-9]+)$'))
225+ t.scene[row] = {}
226+ pos = t.scene[row]
227+ pos.layer = {}
228+ t_default.scene[row] =
229+ {
230+ end_time = 0,
231+ fadein_time = 0,
232+ fadein_col = {0, 0, 0},
233+ fadeout_time = 0,
234+ fadeout_col = {0, 0, 0},
235+ clearcolor = {},
236+ layerall_pos = {},
237+ layer = {},
238+ sound = {},
239+ --bgm = '',
240+ bgm_loop = 0,
241+ --window = {0, 0, 0, 0},
242+ bg_name = ''
243+ }
244+ pos_default = t_default.scene[row]
245+ elseif row:match('^begin_action_[0-9]+$') then --matched anim
246+ row = tonumber(row:match('^begin_action_([0-9]+)$'))
247+ t.anim[row] = {}
248+ pos = t.anim[row]
249+ else --matched other []
250+ t[row] = {}
251+ pos = t[row]
252+ end
253+ else --matched non [] line
254+ local param, value = line:match('^%s*([^=]-)%s*=%s*(.-)%s*$')
255+ if param ~= nil and value ~= nil and not value:match('^%s*$') then --param = value pattern matched
256+ param = param:gsub('[%. ]', '_') --change param . and space to _
257+ param = param:lower() --lowercase param
258+ value = value:gsub('"', '') --remove brackets from value
259+ value = value:gsub('^(%.[0-9])', '0%1') --add 0 before dot if missing at the beginning of matched string
260+ value = value:gsub('([^0-9])(%.[0-9])', '%10%2') --add 0 before dot if missing anywhere else
261+ if param:match('^font[0-9]+$') then --font param matched
262+ local num = tonumber(param:match('font([0-9]+)'))
263+ if param:match('_height$') then
264+ if pos.font_height == nil then
265+ pos.font_height = {}
266+ end
267+ pos.font_height[num] = main.f_dataType(value)
268+ else
269+ if pos.font == nil then
270+ pos.font = {}
271+ end
272+ pos.font[num] = tostring(value)
273+ end
274+ else
275+ if param:match('^layer[0-9]+_') then --scene layer param matched
276+ local num = tonumber(param:match('^layer([0-9]+)_'))
277+ param = param:gsub('layer[0-9]+_', '')
278+ if pos.layer[num] == nil then
279+ pos.layer[num] = {}
280+ pos_default.layer[num] =
281+ {
282+ anim = -1,
283+ text = '',
284+ font = {1, 0, 1, nil, nil, nil},
285+ text_spacing = {0, 15}, --Ikemen feature
286+ text_delay = 2, --Ikemen feature
287+ text_length = 50, --Ikemen feature
288+ text_timer = 0, --Ikemen feature
289+ offset = {0, 0},
290+ starttime = 0,
291+ --endtime = 0
292+ }
293+ end
294+ pos_val = pos.layer[num]
295+ elseif param:match('^sound[0-9]+_') then --sound param matched
296+ local num = tonumber(param:match('^sound([0-9]+)_'))
297+ param = param:gsub('sound[0-9]+_', '')
298+ if pos.sound[num] == nil then
299+ pos.sound[num] = {}
300+ pos_default.sound[num] =
301+ {
302+ value = {-1, -1},
303+ starttime = 0,
304+ volumescale = 100, --not supported yet
305+ pan = 0 --not supported yet
306+ }
307+ end
308+ pos_val = pos.sound[num]
309+ else
310+ pos_val = pos
311+ end
312+ if pos_val[param] == nil then --mugen takes into account only first occurrence
313+ if value:match('.+,.+') then --multiple values
314+ for i, c in ipairs(main.f_strsplit(',', value)) do --split value using "," delimiter
315+ if pos_val[param] == nil then
316+ pos_val[param] = {}
317+ end
318+ if c == '' then
319+ pos_val[param][#pos_val[param] + 1] = 0
320+ else
321+ pos_val[param][#pos_val[param] + 1] = main.f_dataType(c)
322+ end
323+ end
324+ else --single value
325+ pos_val[param] = main.f_dataType(value)
326+ end
327+ end
328+ end
329+ else --only valid lines left are animations
330+ line = line:lower()
331+ local value = line:match('^%s*([0-9%-]+%s*,%s*[0-9%-]+%s*,%s*[0-9%-]+%s*,%s*[0-9%-]+%s*,%s*[0-9%-]+.-)[,%s]*$') or line:match('^%s*loopstart')
332+ if value ~= nil then
333+ value = value:gsub(',%s*,', ',0,') --add missing values
334+ value = value:gsub(',%s*$', '')
335+ pos[#pos + 1] = value
336+ end
337+ end
338+ end
339+ end
340+ file:close()
341+ --;===========================================================
342+ --; FIX REFERENCES, LOAD DATA
343+ --;===========================================================
344+ --merge tables
345+ t = main.f_tableMerge(t_default, t)
346+ --ctrldef table adjustment
347+ for k, v in pairs(t.ctrldef) do
348+ for k2, v2 in pairs(t.ctrldef[k]) do
349+ tmp = t.ctrldef[k][k2].ctrl
350+ for i = 1, #tmp do
351+ --if END_TIME is omitted it should default to the same value as START_TIME
352+ if tmp[i].time[2] == -1 then
353+ tmp[i].time[2] = tmp[i].time[1]
354+ end
355+ --if LOOPTIME is omitted or set to -1, the background controller will not reset its own timer. In such case use GLOBAL_LOOPTIME
356+ if tmp[i].time[3] == -1 then
357+ tmp[i].time[3] = t.ctrldef[k][k2].looptime
358+ end
359+ --lowercase type name
360+ tmp[i].type = tmp[i].type:lower()
361+ --this list, if specified, overrides the default list specified in the BGCtrlDef
362+ if #tmp[i].ctrlid == 0 then
363+ for j = 1, #t.ctrldef[k][k2].ctrlid do
364+ tmp[i].ctrlid[#tmp[i].ctrlid + 1] = t.ctrldef[k][k2].ctrlid[j]
365+ end
366+ end
367+ end
368+ end
369+ end
370+ --scenedef spr
371+ if not t.scenedef.spr:match('^data/') then
372+ if main.f_fileExists(t.fileDir .. t.scenedef.spr) then
373+ t.scenedef.spr = t.fileDir .. t.scenedef.spr
374+ elseif main.f_fileExists('data/' .. t.scenedef.spr) then
375+ t.scenedef.spr = 'data/' .. t.scenedef.spr
376+ end
377+ end
378+ t.scenedef.spr_data = sffNew(t.scenedef.spr)
379+ --scenedef snd
380+ if t.scenedef.snd ~= '' then
381+ if not t.scenedef.snd:match('^data/') then
382+ if main.f_fileExists(t.fileDir .. t.scenedef.snd) then
383+ t.scenedef.snd = t.fileDir .. t.scenedef.snd
384+ elseif main.f_fileExists('data/' .. t.scenedef.snd) then
385+ t.scenedef.snd = 'data/' .. t.scenedef.snd
386+ end
387+ end
388+ t.scenedef.snd_data = sndNew(t.scenedef.snd)
389+ end
390+ --scenedef fonts
391+ for k, v in pairs(t.scenedef.font) do --loop through table keys
392+ if t.scenedef.font[k] ~= '' then
393+ if not t.scenedef.font[k]:match('^data/') then
394+ if main.f_fileExists(t.fileDir .. t.scenedef.font[k]) then
395+ t.scenedef.font[k] = t.fileDir .. t.scenedef.font[k]
396+ elseif main.f_fileExists('font/' .. t.scenedef.font[k]) then
397+ t.scenedef.font[k] = 'font/' .. t.scenedef.font[k]
398+ end
399+ end
400+ t.scenedef.font_data[k] = fontNew(t.scenedef.font[k])
401+ end
402+ end
403+ --loop through scenes
404+ local prev_k = ''
405+ for k, v in main.f_sortKeys(t.scene) do
406+ --bgm
407+ if t.scene[k].bgm ~= nil and not t.scene[k].bgm:match('^data/') then
408+ if main.f_fileExists(t.fileDir .. t.scene[k].bgm) then
409+ t.scene[k].bgm = t.fileDir .. t.scene[k].bgm
410+ elseif main.f_fileExists('music/' .. t.scene[k].bgm) then
411+ t.scene[k].bgm = 'music/' .. t.scene[k].bgm
412+ end
413+ end
414+ --default values
415+ if #t.scene[k].clearcolor == 0 then
416+ if prev_k ~= '' and #t.scene[prev_k].clearcolor > 0 then
417+ t.scene[k].clearcolor[1], t.scene[k].clearcolor[2], t.scene[k].clearcolor[3] = t.scene[prev_k].clearcolor[1], t.scene[prev_k].clearcolor[2], t.scene[prev_k].clearcolor[3]
418+ else
419+ t.scene[k].clearcolor[1], t.scene[k].clearcolor[2], t.scene[k].clearcolor[3] = 0, 0, 0
420+ end
421+ end
422+ if #t.scene[k].layerall_pos == 0 then
423+ if prev_k ~= '' and #t.scene[prev_k].layerall_pos > 0 then
424+ t.scene[k].layerall_pos[1], t.scene[k].layerall_pos[2] = t.scene[prev_k].layerall_pos[1], t.scene[prev_k].layerall_pos[2]
425+ else
426+ t.scene[k].layerall_pos[1], t.scene[k].layerall_pos[2] = 0, 0
427+ end
428+ end
429+ prev_k = k
430+ --backgrounds data
431+ local anim = ''
432+ if t.scene[k].bg_name ~= '' then
433+ t.scene[k].bg_data = {}
434+ t.scene[k].bg_name = t.scene[k].bg_name:lower()
435+ local t_bgdef = t[t.scene[k].bg_name .. 'def']
436+ local prev_k2 = ''
437+ for k2, v2 in pairs(t_bgdef) do --loop through table keys
438+ if t_bgdef[k2].type ~= nil then
439+ t_bgdef[k2].type = t_bgdef[k2].type:lower()
440+ --mugen ignores delta = 0 (defaults to 1)
441+ if t_bgdef[k2].delta[1] == 0 then t_bgdef[k2].delta[1] = 1 end
442+ if t_bgdef[k2].delta[2] == 0 then t_bgdef[k2].delta[2] = 1 end
443+ --add ctrl data
444+ t[t.scene[k].bg_name .. 'def'][k2].ctrl = main.f_ctrlBG(t_bgdef[k2], t.ctrldef[t.scene[k].bg_name .. 'def'])
445+ --positionlink adjustment
446+ if t_bgdef[k2].positionlink == 1 and prev_k2 ~= '' then
447+ t_bgdef[k2].start[1] = t_bgdef[prev_k2].start[1]
448+ t_bgdef[k2].start[2] = t_bgdef[prev_k2].start[2]
449+ t_bgdef[k2].delta[1] = t_bgdef[prev_k2].delta[1]
450+ t_bgdef[k2].delta[2] = t_bgdef[prev_k2].delta[2]
451+ end
452+ prev_k2 = k2
453+ --generate anim data
454+ local sizeX, sizeY, offsetX, offsetY = 0, 0, 0, 0
455+ if t_bgdef[k2].type == 'anim' then
456+ anim = main.f_animFromTable(t.anim[t_bgdef[k2].actionno], t.scenedef.spr_data, t_bgdef[k2].start[1], t_bgdef[k2].start[2])
457+ else --normal, parallax
458+ anim = t_bgdef[k2].spriteno[1] .. ', ' .. t_bgdef[k2].spriteno[2] .. ', ' .. t_bgdef[k2].start[1] .. ', ' .. t_bgdef[k2].start[2] .. ', ' .. -1
459+ anim = animNew(t.scenedef.spr_data, anim)
460+ sizeX, sizeY, offsetX, offsetY = getSpriteInfo(t.scenedef.spr, t_bgdef[k2].spriteno[1], t_bgdef[k2].spriteno[2])
461+ end
462+ if t_bgdef[k2].trans == 'add1' then
463+ animSetAlpha(anim, 255, 128)
464+ elseif t_bgdef[k2].trans == 'add' then
465+ animSetAlpha(anim, 255, 255)
466+ elseif t_bgdef[k2].trans == 'sub' then
467+ animSetAlpha(anim, 1, 255)
468+ end
469+ animAddPos(anim, 160, 0) --for some reason needed in ikemen
470+ if t_bgdef[k2].window ~= nil then
471+ animSetWindow(
472+ anim,
473+ t_bgdef[k2].window[1],
474+ t_bgdef[k2].window[2],
475+ t_bgdef[k2].window[3] - t_bgdef[k2].window[1] + 1,
476+ t_bgdef[k2].window[4] - t_bgdef[k2].window[2] + 1
477+ )
478+ else
479+ animSetWindow(anim, 0, 0, t.info.localcoord[1], t.info.localcoord[2])
480+ end
481+ if t_bgdef[k2].tilespacing[2] == nil then t_bgdef[k2].tilespacing[2] = t_bgdef[k2].tilespacing[1] end
482+ if t_bgdef[k2].type == 'parallax' then
483+ animSetTile(anim, t_bgdef[k2].tile[1], 0, t_bgdef[k2].tilespacing[1] + sizeX, t_bgdef[k2].tilespacing[2] + sizeY)
484+ else
485+ animSetTile(anim, t_bgdef[k2].tile[1], t_bgdef[k2].tile[2], t_bgdef[k2].tilespacing[1] + sizeX, t_bgdef[k2].tilespacing[2] + sizeY)
486+ end
487+ animSetScale(anim, 320/t.info.localcoord[1], 240/t.info.localcoord[2])
488+ if t_bgdef[k2].mask == 1 or t_bgdef[k2].type ~= 'normal' or (t_bgdef[k2].trans ~= '' and t_bgdef[k2].trans ~= 'none') then
489+ animSetColorKey(anim, 0)
490+ else
491+ animSetColorKey(anim, -1)
492+ end
493+ --animUpdate(anim)
494+ t.scene[k].bg_data[k2] = anim
495+ end
496+ end
497+ end
498+ --clearcolor data
499+ t.scene[k].clearcolor_data = main.f_clearColor(t.scene[k].clearcolor[1], t.scene[k].clearcolor[2], t.scene[k].clearcolor[3])
500+ animSetWindow(t.scene[k].clearcolor_data, 0, 0, t.info.localcoord[1], t.info.localcoord[2])
501+ --fadein data
502+ t.scene[k].fadein_data = main.f_fadeAnim(1, t.scene[k].fadein_time, t.scene[k].fadein_col[1], t.scene[k].fadein_col[2], t.scene[k].fadein_col[3])
503+ animSetWindow(t.scene[k].fadein_data, 0, 0, t.info.localcoord[1], t.info.localcoord[2])
504+ --fadeout data
505+ t.scene[k].fadeout_data = main.f_fadeAnim(0, t.scene[k].fadeout_time, t.scene[k].fadeout_col[1], t.scene[k].fadeout_col[2], t.scene[k].fadeout_col[3])
506+ animSetWindow(t.scene[k].fadeout_data, 0, 0, t.info.localcoord[1], t.info.localcoord[2])
507+ --loop through scene layers
508+ local t_layer = t.scene[k].layer
509+ for k2, v2 in pairs(t_layer) do
510+ --anim
511+ if t_layer[k2].anim ~= -1 and t.anim[t_layer[k2].anim] ~= nil then
512+ t.scene[k].layer[k2].anim_data = main.f_animFromTable(
513+ t.anim[t_layer[k2].anim],
514+ t.scenedef.spr_data,
515+ t.scene[k].layerall_pos[1] + t_layer[k2].offset[1],
516+ t.scene[k].layerall_pos[2] + t_layer[k2].offset[2]
517+ )
518+ animSetScale(t.scene[k].layer[k2].anim_data, 320/t.info.localcoord[1], 240/t.info.localcoord[2])
519+ end
520+ --text
521+ if t_layer[k2].text ~= '' then
522+ t.scene[k].layer[k2].text_data = main.f_createTextImg(
523+ t.scenedef.font_data[t.scenedef.font[t_layer[k2].font][1]],
524+ t.scenedef.font[t_layer[k2].font][2],
525+ t.scenedef.font[t_layer[k2].font][3],
526+ t_layer[k2].text,
527+ t.scene[k].layerall_pos[1] + t_layer[k2].offset[1],
528+ t.scene[k].layerall_pos[2] + t_layer[k2].offset[2],
529+ 320/t.info.localcoord[1],
530+ 240/t.info.localcoord[2],
531+ t.scenedef.font[t_layer[k2].font][4],
532+ t.scenedef.font[t_layer[k2].font][5],
533+ t.scenedef.font[t_layer[k2].font][6]
534+ )
535+ end
536+ --endtime
537+ if t_layer[k2].endtime == nil then
538+ t_layer[k2].endtime = t.scene[k].end_time
539+ end
540+ end
541+ end
542+ --t.ctrldef = nil
543+
544+ -- Finished loading intro
545+ -- Re-enabled custom scaling
546+ main.SetScaleValues()
547+
548+ return t
549+end
550+
551+function storyboard.f_storyboard(path)
552+ path = path:gsub('\\', '/')
553+ if storyboard.t_storyboard[path] == nil then
554+ storyboard.t_storyboard[path] = f_parse(path)
555+ else
556+ f_reset(storyboard.t_storyboard[path])
557+ end
558+ f_play(storyboard.t_storyboard[path])
559+end
560+
561+return storyboard