• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

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

Go で書き直した Ikemen


コミットメタ情報

リビジョン0132d66580f9c76ac8af6ab41fef17c962f3f4ed (tree)
日時2020-01-15 01:44:06
作者neatunsou <sisiy4excite@gmai...>
コミッターneatunsou

ログメッセージ

K4thos氏の更新に合流
変更点が多いので注意

変更サマリ

差分

--- a/get.sh
+++ b/get.sh
@@ -10,4 +10,6 @@ go get -u github.com/faiface/beep
1010 go get -u github.com/hajimehoshi/oto
1111 go get -u github.com/hajimehoshi/go-mp3
1212 go get -u github.com/pkg/errors
13-go get -u github.com/jfreymuth/oggvorbis
\ No newline at end of file
13+go get -u github.com/jfreymuth/oggvorbis
14+go get -u github.com/kbinani/screenshot
15+go get -u github.com/sqweek/dialog
\ No newline at end of file
--- a/script/main.lua
+++ b/script/main.lua
@@ -1,29 +1,30 @@
1--------------------------------------------------------------
2--- Disable GC during the initial load so it does not crash.
1+--;===========================================================
2+--; INITIALIZE DATA
3+--;===========================================================
4+--Disable GC during the initial load so it does not crash
35 SetGCPercent(-1)
4--------------------------------------------------------------
6+
7+--nClock = os.clock()
8+--print("Elapsed time: " .. os.clock() - nClock)
9+
510 main = {}
611
712 refresh()
813 math.randomseed(os.time())
914
10---;===========================================================
11---; COMMON SECTION
12---;===========================================================
13-
1415 --One-time load of the json routines
1516 json = (loadfile 'script/dkjson.lua')()
1617
17--- Data loading from config.json
18+--Data loading from config.json
1819 local file = io.open("save/config.json","r")
1920 config = json.decode(file:read("*all"))
2021 file:close()
2122
23+--Input stuff
2224 main.p1In = 1
2325 main.p2In = 2
2426 --main.inputDialog = inputDialogNew()
2527
26--------------------------------------------------------------
2728 function main.f_setCommand(c)
2829 commandAdd(c, 'u', '$U')
2930 commandAdd(c, 'd', '$D')
@@ -49,6 +50,15 @@ main.f_setCommand(main.p1Cmd)
4950 main.p2Cmd = commandNew()
5051 main.f_setCommand(main.p2Cmd)
5152
53+main.p3Cmd = commandNew()
54+main.f_setCommand(main.p3Cmd)
55+
56+main.p4Cmd = commandNew()
57+main.f_setCommand(main.p4Cmd)
58+
59+--;===========================================================
60+--; COMMON FUNCTIONS
61+--;===========================================================
5262 function main.f_cmdInput()
5363 commandInput(main.p1Cmd, main.p1In)
5464 commandInput(main.p2Cmd, main.p2In)
@@ -69,96 +79,6 @@ function main.f_btnPalNo(cmd)
6979 return 0
7080 end
7181
72--- Check if files exists.
73-function main.file_exists(name)
74- local f=io.open(name,"r")
75- if f~=nil then io.close(f) return true else return false end
76-end
77-
78---prints "t" table content into "toFile" file
79-function main.f_printTable(t, toFile)
80- local toFile = toFile or 'debug/table_print.txt'
81- local txt = ''
82- local print_t_cache = {}
83- local function sub_print_t(t, indent)
84- if print_t_cache[tostring(t)] then
85- txt = txt .. indent .. '*' .. tostring(t) .. '\n'
86- else
87- print_t_cache[tostring(t)] = true
88- if type(t) == 'table' then
89- for pos, val in pairs(t) do
90- if type(val) == 'table' then
91- txt = txt .. indent .. '[' .. pos .. '] => ' .. tostring(t) .. ' {' .. '\n'
92- sub_print_t(val, indent .. string.rep(' ', string.len(tostring(pos)) + 8))
93- txt = txt .. indent .. string.rep(' ', string.len(tostring(pos)) + 6) .. '}' .. '\n'
94- elseif type(val) == 'string' then
95- txt = txt .. indent .. '[' .. pos .. '] => "' .. val .. '"' .. '\n'
96- else
97- txt = txt .. indent .. '[' .. pos .. '] => ' .. tostring(val) ..'\n'
98- end
99- end
100- else
101- txt = txt .. indent .. tostring(t) .. '\n'
102- end
103- end
104- end
105- if type(t) == 'table' then
106- txt = txt .. tostring(t) .. ' {' .. '\n'
107- sub_print_t(t, ' ')
108- txt = txt .. '}' .. '\n'
109- else
110- sub_print_t(t, ' ')
111- end
112- local file = io.open(toFile,"w+")
113- if file == nil then return end
114- file:write(txt)
115- file:close()
116-end
117-
118--- Prints "v" variable into "toFile" file
119-function main.f_printVar(v, toFile)
120- local toFile = toFile or 'debug/var_print.txt'
121- local file = io.open(toFile,"w+")
122- file:write(v)
123- file:close()
124-end
125-
126--- Split strings.
127-function main.f_strsplit(delimiter, text)
128- local list = {}
129- local pos = 1
130- if string.find('', delimiter, 1) then
131- if string.len(text) == 0 then
132- table.insert(list, text)
133- else
134- for i = 1, string.len(text) do
135- table.insert(list, string.sub(text, i, i))
136- end
137- end
138- else
139- while true do
140- local first, last = string.find(text, delimiter, pos)
141- if first then
142- table.insert(list, string.sub(text, pos, first - 1))
143- pos = last + 1
144- else
145- table.insert(list, string.sub(text, pos))
146- break
147- end
148- end
149- end
150- return list
151-end
152-
153--------------------------------------------------------------
154--- Int localcoord
155-require "script/screenpack"
156-main.IntLocalcoordValues()
157-main.CalculateLocalcoordValues()
158-main.IntLifebarScale()
159-main.SetScaleValues()
160--------------------------------------------------------------
161-
16282 --animDraw at specified coordinates
16383 function main.f_animPosDraw(a, x, y)
16484 animSetPos(a, x, y)
@@ -176,16 +96,14 @@ function main.f_textImgPosDraw(ti, x, y, align)
17696 end
17797
17898 --shortcut for creating new text with several parameters
179-function main.f_createTextImg(font, bank, align, text, x, y, scaleX, scaleY, colorR, colorG, colorB)
99+function main.f_createTextImg(font, bank, align, text, x, y, scaleX, scaleY, r, g, b, src, dst)
180100 local ti = textImgNew()
181101 if font ~= nil then
182102 textImgSetFont(ti, font)
183103 textImgSetBank(ti, bank)
184104 textImgSetAlign(ti, align)
185105 textImgSetText(ti, text)
186- if colorR ~= nil and colorG ~= nil and colorB ~= nil then
187- textImgSetColor(ti, colorR, colorG, colorB)
188- end
106+ textImgSetColor(ti, r, g, b, src, dst)
189107 if align == -1 then x = x + 1 end --fix for wrong offset after flipping text
190108 textImgSetPos(ti, x, y)
191109 textImgSetScale(ti, scaleX, scaleY)
@@ -194,20 +112,18 @@ function main.f_createTextImg(font, bank, align, text, x, y, scaleX, scaleY, col
194112 end
195113
196114 --shortcut for updating text with several parameters
197-function main.f_updateTextImg(animName, font, bank, align, text, x, y, scaleX, scaleY, colorR, colorG, colorB)
115+function main.f_updateTextImg(ti, font, bank, align, text, x, y, scaleX, scaleY, r, g, b, src, dst)
198116 if font ~= nil then
199- textImgSetFont(animName, font)
200- textImgSetBank(animName, bank)
201- textImgSetAlign(animName, align)
202- textImgSetText(animName, text)
203- if colorR ~= nil and colorG ~= nil and colorB ~= nil then
204- textImgSetColor(animName, colorR, colorG, colorB)
205- end
117+ textImgSetFont(ti, font)
118+ textImgSetBank(ti, bank)
119+ textImgSetAlign(ti, align)
120+ textImgSetText(ti, text)
121+ textImgSetColor(ti, r, g, b, src, dst)
206122 if align == -1 then x = x + 1 end --fix for wrong offset after flipping text
207- textImgSetPos(animName, x, y)
208- textImgSetScale(animName, scaleX, scaleY)
123+ textImgSetPos(ti, x, y)
124+ textImgSetScale(ti, scaleX, scaleY)
209125 end
210- return animName
126+ return ti
211127 end
212128
213129 --dynamically adjusts alpha blending each time called based on specified values
@@ -215,7 +131,7 @@ local alpha1cur = 0
215131 local alpha2cur = 0
216132 local alpha1add = true
217133 local alpha2add = true
218-function main.f_dynamicAlpha(animName, r1min, r1max, r1step, r2min, r2max, r2step)
134+function main.f_boxcursorAlpha(r1min, r1max, r1step, r2min, r2max, r2step)
219135 if r1step == 0 then alpha1cur = r1max end
220136 if alpha1cur < r1max and alpha1add then
221137 alpha1cur = alpha1cur + r1step
@@ -240,55 +156,7 @@ function main.f_dynamicAlpha(animName, r1min, r1max, r1step, r2min, r2max, r2ste
240156 alpha2add = true
241157 end
242158 end
243- animSetAlpha(animName, alpha1cur, alpha2cur)
244-end
245-
246---generate fading animation
247---currently only black when average of RGB <= 128 and white if >128 colors supported
248-function main.f_fadeAnim(fadeType, ticks, r, g, b)
249- local anim = ''
250- if (r + g + b)/3 > 128 then --white
251- if fadeType == 0 then --fadeout
252- for i = 1, ticks do
253- anim = anim .. '0,1, 0,0, 1, 0, AS' .. math.floor(256 / ticks * i) .. 'D256\n'
254- end
255- anim = anim .. '0,1, 0,0, -1, 0, AS256D256'
256- elseif fadeType == 1 then --fadein
257- for i = ticks, 1, -1 do
258- anim = anim .. '0,1, 0,0, 1, 0, AS' .. math.floor(256 / ticks * i) .. 'D256\n'
259- end
260- anim = anim .. '0,1, 0,0, -1, 0, AS0D256'
261- end
262- else --black
263- if fadeType == 0 then --fadeout
264- for i = ticks, 1, -1 do
265- anim = anim .. '0,0, 0,0, 1, 0, AS256D' .. math.floor(256 / ticks * i) .. '\n'
266- end
267- anim = anim .. '0,0, 0,0, -1, 0, AS256D0'
268- elseif fadeType == 1 then --fadein
269- for i = 1, ticks do
270- anim = anim .. '0,0, 0,0, 1, 0, AS256D' .. math.floor(256 / ticks * i) .. '\n'
271- end
272- anim = anim .. '0,0, 0,0, -1, 0, AS256D256'
273- end
274- end
275- anim = animNew(main.fadeSff, anim)
276- animUpdate(anim)
277- return anim, ticks
278-end
279-
280---generate clearcolor animation
281---currently only black when average of RGB <= 128 and white if >128 colors supported
282-function main.f_clearColor(r, g, b)
283- local anim = ''
284- if (r + g + b)/3 > 128 then
285- anim = '0,1, 0,0, -1' --white
286- else
287- anim = '0,0, 0,0, -1' --black
288- end
289- anim = animNew(main.fadeSff, anim)
290- animUpdate(anim)
291- return anim
159+ return alpha1cur, alpha2cur
292160 end
293161
294162 --generate anim from table
@@ -305,7 +173,7 @@ function main.f_animFromTable(t, sff, x, y, scaleX, scaleY, facing, infFrame)
305173 for i = 1, #t do
306174 local t_anim = {}
307175 for j, c in ipairs(main.f_strsplit(',', t[i])) do --split using "," delimiter
308- t_anim[#t_anim + 1] = c
176+ table.insert(t_anim, c)
309177 end
310178 if #t_anim > 1 then
311179 --required parameters
@@ -341,15 +209,28 @@ end
341209 --Convert number to name and get rid of the ""
342210 function main.f_getName(cell)
343211 local tmp = getCharName(cell)
344- tmp = tmp:gsub('^["%s]*(.-)["%s]*$', '%1') --needed for s-size ikemen
345212 if main.t_selChars[cell + 1].hidden == 3 then
346213 tmp = 'Random'
347- elseif main.t_selChars[cell + 1].hidden == 2 or main.t_selChars[cell + 1].hidden == 1 then
214+ elseif main.t_selChars[cell + 1].hidden == 2 then
348215 tmp = ''
349216 end
350217 return tmp
351218 end
352219
220+--copy table content into new table
221+function main.f_copyTable(t)
222+ t = t or {}
223+ local t2 = {}
224+ for k, v in pairs(t) do
225+ if type(v) == "table" then
226+ t2[k] = main.f_copyTable(v)
227+ else
228+ t2[k] = v
229+ end
230+ end
231+ return t2
232+end
233+
353234 --randomizes table content
354235 function main.f_shuffleTable(t)
355236 local rand = math.random
@@ -374,7 +255,7 @@ end
374255 function main.f_sortKeys(t, order)
375256 -- collect the keys
376257 local keys = {}
377- for k in pairs(t) do keys[#keys + 1] = k end
258+ for k in pairs(t) do table.insert(keys, k) end
378259 -- if order function given, sort it by passing the table and keys a, b,
379260 -- otherwise just sort the keys
380261 if order then
@@ -392,12 +273,60 @@ function main.f_sortKeys(t, order)
392273 end
393274 end
394275
276+--prints "t" table content into "toFile" file
277+function main.f_printTable(t, toFile)
278+ local toFile = toFile or 'debug/table_print.txt'
279+ local txt = ''
280+ local print_t_cache = {}
281+ local function sub_print_t(t, indent)
282+ if print_t_cache[tostring(t)] then
283+ txt = txt .. indent .. '*' .. tostring(t) .. '\n'
284+ else
285+ print_t_cache[tostring(t)] = true
286+ if type(t) == 'table' then
287+ for pos, val in pairs(t) do
288+ if type(val) == 'table' then
289+ txt = txt .. indent .. '[' .. pos .. '] => ' .. tostring(t) .. ' {' .. '\n'
290+ sub_print_t(val, indent .. string.rep(' ', string.len(tostring(pos)) + 8))
291+ txt = txt .. indent .. string.rep(' ', string.len(tostring(pos)) + 6) .. '}' .. '\n'
292+ elseif type(val) == 'string' then
293+ txt = txt .. indent .. '[' .. pos .. '] => "' .. val .. '"' .. '\n'
294+ else
295+ txt = txt .. indent .. '[' .. pos .. '] => ' .. tostring(val) ..'\n'
296+ end
297+ end
298+ else
299+ txt = txt .. indent .. tostring(t) .. '\n'
300+ end
301+ end
302+ end
303+ if type(t) == 'table' then
304+ txt = txt .. tostring(t) .. ' {' .. '\n'
305+ sub_print_t(t, ' ')
306+ txt = txt .. '}' .. '\n'
307+ else
308+ sub_print_t(t, ' ')
309+ end
310+ local file = io.open(toFile,"w+")
311+ if file == nil then return end
312+ file:write(txt)
313+ file:close()
314+end
315+
316+--prints "v" variable into "toFile" file
317+function main.f_printVar(v, toFile)
318+ local toFile = toFile or 'debug/var_print.txt'
319+ local file = io.open(toFile,"w+")
320+ file:write(v)
321+ file:close()
322+end
323+
395324 --remove duplicated string pattern
396325 function main.f_uniq(str, pattern, subpattern)
397326 local out = {}
398327 for s in str:gmatch(pattern) do
399328 local s2 = s:match(subpattern)
400- if not main.f_contains(out, s2) then out[#out + 1] = s end
329+ if not main.f_contains(out, s2) then table.insert(out, s) end
401330 end
402331 return table.concat(out)
403332 end
@@ -436,7 +365,7 @@ function main.f_textRender(data, str, counter, x, y, spacing, delay, limit)
436365 local subEnd = math.floor(#str - (#str - counter / delay))
437366 local t = {}
438367 for line in str:gmatch('([^\r\n]*)[\r\n]?') do
439- t[#t + 1] = line
368+ table.insert(t, line)
440369 end
441370 local lengthCnt = 0
442371 for i = 1, #t do
@@ -569,165 +498,6 @@ function main.f_strsplit(delimiter, text)
569498 return list
570499 end
571500
572---expand background table with background controllers data
573-function main.f_ctrlBG(t_bg, t_ctrl)
574- local t = {}
575- for k, v in pairs(t_ctrl) do
576- local t1 = t_ctrl[k].ctrl
577- for i = 1, #t1 do
578- for k2, v2 in pairs(t1[i].ctrlid) do
579- local t2 = t1[i].type
580- if t1[i].ctrlid[k2] == t_bg.id and t2 ~= 'null' then
581- if t[t2] == nil then
582- t[t2] = {}
583- end
584- t[t2][#t[t2] + 1] = {}
585- local t3 = t[t2][#t[t2]]
586- t3.time = {t1[i].time[1], t1[i].time[2], t1[i].time[3]}
587- t3.timer = {t1[i].time[1], t1[i].time[2], t1[i].time[3]}
588- if t2 == 'visible' or t2 == 'enable' or t2 == 'anim' or t2 == 'gamemode' then
589- t3.value = t1[i].value
590- elseif t2 == 'sinx' or t2 == 'siny' then
591- t3.value = {t1[i].value[1], t1[i].value[2], t1[i].value[3]}
592- elseif t2 == 'velset' or t2 == 'veladd' or t2 == 'posset' or t2 == 'posadd' then
593- if t1[i].x ~= nil then
594- t3.x = t1[i].x
595- end
596- if t1[i].y ~= nil then
597- t3.y = t1[i].y
598- end
599- end
600- end
601- end
602- end
603- end
604- return t
605-end
606-
607---draw background layers
608-function main.f_drawBG(data, info, layerno, timer, localcoord)
609- timer = timer or 0
610- --loop through all backgrounds
611- for i = 1, #data do
612- --skip if layerno is not matched
613- if info[i].layerno == layerno then
614- local x = 0
615- local y = 0
616- --loop through controllers
617- for k, v in pairs(info[i].ctrl) do
618- for j = 1, #info[i].ctrl[k] do
619- local t = info[i].ctrl[k][j]
620- --reset internal timer
621- if t.time[3] ~= -1 and timer >= t.timer[3] then
622- t.timer[1] = timer + t.time[1]
623- t.timer[2] = timer + t.time[2]
624- t.timer[3] = timer + t.time[3]
625- end
626- --check if time condition allows controller to run
627- if timer >= t.timer[1] and timer <= t.timer[2] then
628- x = 0
629- y = 0
630- if k == 'gamemode' then --Ikemen feature
631- for m = 1, #t.enabled do
632- info[i].ctrl_flags.enabled = 0
633- if t.enabled[m] == main.gameMode then
634- info[i].ctrl_flags.enabled = 1
635- m = #t.enabled
636- end
637- end
638- elseif k == 'visible' then
639- info[i].ctrl_flags.visible = t.value
640- elseif k == 'enable' then
641- info[i].ctrl_flags.enabled = t.value
642- elseif k == 'velset' or k == 'posset' then
643- if t.x ~= nil then
644- info[i].ctrl_flags.velx = 0 - info[i].velocity[1] + t.x * 320/localcoord[1]
645- end
646- if t.y ~= nil then
647- info[i].ctrl_flags.vely = 0 - info[i].velocity[2] + t.y * 240/localcoord[2]
648- end
649- elseif k == 'veladd' then --or k == 'posadd' then
650- if t.x ~= nil then
651- info[i].ctrl_flags.velx = info[i].ctrl_flags.velx + t.x * 320/localcoord[1]
652- end
653- if t.y ~= nil then
654- info[i].ctrl_flags.vely = info[i].ctrl_flags.vely + t.y * 240/localcoord[2]
655- end
656- elseif k == 'posadd' then
657- if t.x ~= nil then x = t.x * 320/localcoord[1] end
658- if t.y ~= nil then y = t.y * 240/localcoord[2] end
659- animAddPos(data[i], x, y)
660- --[[elseif k == 'posset' then
661- if t.x ~= nil then
662- x = t.x * 320/localcoord[1]
663- else
664- x = info[i].start[1]
665- end
666- if t.y ~= nil then
667- y = t.y * 240/localcoord[2]
668- else
669- y = info[i].start[2]
670- end
671- animSetPos(data[i], x, y)
672- animAddPos(data[i], 160, 0) --for some reason needed in ikemen
673- elseif k == 'posadd' then
674- if t.x ~= nil then x = t.x * 320/localcoord[1] end
675- if t.y ~= nil then y = t.y * 240/localcoord[2] end
676- animAddPos(data[i], x, y)]]
677- --elseif k == 'anim' then --not supported yet
678- --elseif k == 'sinx' then --not supported yet
679- --elseif k == 'siny' then --not supported yet
680- end
681- end
682- end
683- end
684- --animation
685- if info[i].ctrl_flags.enabled == 1 then
686- x = (info[i].ctrl_flags.velx + info[i].velocity[1]) * info[i].delta[1]
687- y = (info[i].ctrl_flags.vely + info[i].velocity[2]) * info[i].delta[2]
688- info[i].ctrl_flags.x = info[i].ctrl_flags.x + x
689- info[i].ctrl_flags.y = info[i].ctrl_flags.y + y
690- animAddPos(data[i], x, y)
691- animUpdate(data[i])
692- if info[i].ctrl_flags.visible == 1 then
693- animDraw(data[i])
694- end
695- end
696- end
697- end
698-end
699-
700---reset screenpack data
701-function main.f_resetBG(info, bgdef, bgm, bgmLoop, bgmVolume, bgmloopstart, bgmloopend)
702- bgm = bgm or nil
703- animReset(info.fadein_data)
704- animUpdate(info.fadein_data)
705- animReset(info.fadeout_data)
706- animUpdate(info.fadeout_data)
707- bgdef.timer = 0
708- for i = 1, #bgdef.bg do
709- bgdef.bg[i].ctrl_flags.visible = 1
710- bgdef.bg[i].ctrl_flags.enabled = 1
711- bgdef.bg[i].ctrl_flags.velx = 0
712- bgdef.bg[i].ctrl_flags.vely = 0
713- animReset(bgdef.bg_data[i])
714- animAddPos(bgdef.bg_data[i], 0 - bgdef.bg[i].ctrl_flags.x, 0 - bgdef.bg[i].ctrl_flags.y)
715- animUpdate(bgdef.bg_data[i])
716- bgdef.bg[i].ctrl_flags.x = 0
717- bgdef.bg[i].ctrl_flags.y = 0
718- for k, v in pairs(bgdef.bg[i].ctrl) do
719- for j = 1, #bgdef.bg[i].ctrl[k] do
720- bgdef.bg[i].ctrl[k][j].timer[1] = bgdef.bg[i].ctrl[k][j].time[1]
721- bgdef.bg[i].ctrl[k][j].timer[2] = bgdef.bg[i].ctrl[k][j].time[2]
722- bgdef.bg[i].ctrl[k][j].timer[3] = bgdef.bg[i].ctrl[k][j].time[3]
723- end
724- end
725- end
726- if bgm ~= nil then
727- playBGM(bgm, true, bgmLoop, bgmVolume, bgmloopstart or "0", bgmloopend or "0")
728- end
729-end
730-
731501 --return table with reversed keys
732502 function main.f_reversedTable(t)
733503 local reversedTable = {}
@@ -738,38 +508,60 @@ function main.f_reversedTable(t)
738508 return reversedTable
739509 end
740510
741---return table without rows disabled in screenpack
742-function main.f_cleanTable(t)
511+--return table with proper order and without rows disabled in screenpack
512+function main.f_cleanTable(t, t_sort)
743513 local t_clean = {}
514+ local t_added = {}
515+ --first we add all entries existing in screenpack file in correct order
516+ for i = 1, #t_sort do
517+ for j = 1, #t do
518+ if t_sort[i] == t[j].itemname and t[j].displayname ~= '' then
519+ table.insert(t_clean, t[j])
520+ t_added[t[j].itemname] = 1
521+ break
522+ end
523+ end
524+ end
525+ --then we add remaining default entries if not existing yet and not disabled (by default or via screenpack)
744526 for i = 1, #t do
745- if t[i].displayname ~= '' then
746- t_clean[#t_clean + 1] = t[i]
527+ if t_added[t[i].itemname] == nil and t[i].displayname ~= '' then
528+ table.insert(t_clean, t[i])
747529 end
748530 end
749531 return t_clean
750532 end
751533
534+--odd value rounding
535+function main.f_oddRounding(v)
536+ if v % 2 ~= 0 then
537+ return 1
538+ else
539+ return 0
540+ end
541+end
542+
752543 --warning display
753544 local txt_warning = textImgNew()
754-function main.f_warning(t, info, background, font_info, title, box)
545+function main.f_warning(t, info, background, font_info, title, coords, col, alpha)
755546 font_info = font_info or motif.warning_info
756547 title = title or main.txt_warningTitle
757- box = box or main.warningBox
548+ coords = coords or motif.warning_info.boxbg_coords
549+ col = col or motif.warning_info.boxbg_col
550+ alpha = alpha or motif.warning_info.boxbg_alpha
758551 main.f_cmdInput()
759- box = box or false
760552 while true do
761553 if main.f_btnPalNo(main.p1Cmd) > 0 or esc() then
762554 sndPlay(motif.files.snd_data, info.cursor_move_snd[1], info.cursor_move_snd[2])
763555 break
764556 end
765557 --draw clearcolor
766- animDraw(background.bgclearcolor_data)
558+ clearColor(background.bgclearcolor[1], background.bgclearcolor[2], background.bgclearcolor[3])
767559 --draw layerno = 0 backgrounds
768- main.f_drawBG(background.bg_data, background.bg, 0, background.timer, {320,240})
560+ bgDraw(background.bg, false)
769561 --draw layerno = 1 backgrounds
770- main.f_drawBG(background.bg_data, background.bg, 1, background.timer, {320,240})
562+ bgDraw(background.bg, true)
771563 --draw menu box
772- animDraw(box)
564+ fillRect(coords[1], coords[2], coords[3] - coords[1] + 1, coords[4] - coords[2] + 1, col[1], col[2], col[3], alpha[1], alpha[2])
773565 --draw title
774566 textImgDraw(title)
775567 --draw text
@@ -786,12 +578,12 @@ function main.f_warning(t, info, background, font_info, title, box)
786578 font_info.text_font_scale[2],
787579 font_info.text_font[4],
788580 font_info.text_font[5],
789- font_info.text_font[6]
581+ font_info.text_font[6],
582+ font_info.text_font[7],
583+ font_info.text_font[8]
790584 )
791585 textImgDraw(txt_warning)
792586 end
793- --update timer
794- background.timer = background.timer + 1
795587 --end loop
796588 main.f_cmdInput()
797589 refresh()
@@ -800,25 +592,47 @@ end
800592
801593 --input display
802594 local txt_input = textImgNew()
803-function main.f_input(t, info, background, type)
595+function main.f_input(t, info, background, category, controllerNo, keyBreak)
804596 main.f_cmdInput()
805- type = type or 'string'
806- if type == 'string' then
807- t[#t + 1] = ''
597+ category = category or 'string'
598+ controllerNo = controllerNo or 0
599+ keyBreak = keyBreak or ''
600+ if category == 'string' then
601+ table.insert(t, '')
808602 end
809603 local input = ''
604+ local btnReleased = 0
810605 resetKey()
811606 while true do
812607 if esc() then
813608 input = ''
814609 break
815610 end
816- if type == 'key' then
611+ if category == 'keyboard' then
817612 input = getKey()
818613 if input ~= '' then
819614 main.f_cmdInput()
820615 break
821616 end
617+ elseif category == 'gamepad' then
618+ if getJoystickPresent(controllerNo) == false then
619+ break
620+ end
621+ if getKey() == keyBreak then
622+ input = keyBreak
623+ break
624+ end
625+ local tmp = getKey()
626+ if tonumber(tmp) == nil then --button released
627+ if btnReleased == 0 then
628+ btnReleased = 1
629+ elseif btnReleased == 2 then
630+ break
631+ end
632+ elseif btnReleased == 1 then --button pressed after releasing button once
633+ input = tmp
634+ btnReleased = 2
635+ end
822636 else --string
823637 if getKey() == 'RETURN' then
824638 main.f_cmdInput()
@@ -832,33 +646,43 @@ function main.f_input(t, info, background, type)
832646 resetKey()
833647 end
834648 --draw clearcolor
835- animDraw(background.bgclearcolor_data)
649+ clearColor(background.bgclearcolor[1], background.bgclearcolor[2], background.bgclearcolor[3])
836650 --draw layerno = 0 backgrounds
837- main.f_drawBG(background.bg_data, background.bg, 0, background.timer, {320,240})
651+ bgDraw(background.bg, false)
838652 --draw layerno = 1 backgrounds
839- main.f_drawBG(background.bg_data, background.bg, 1, background.timer, {320,240})
653+ bgDraw(background.bg, true)
840654 --draw menu box
841- animDraw(main.warningBox)
655+ fillRect(
656+ motif.infobox.boxbg_coords[1],
657+ motif.infobox.boxbg_coords[2],
658+ motif.infobox.boxbg_coords[3] - motif.infobox.boxbg_coords[1] + 1,
659+ motif.infobox.boxbg_coords[4] - motif.infobox.boxbg_coords[2] + 1,
660+ motif.infobox.boxbg_col[1],
661+ motif.infobox.boxbg_col[2],
662+ motif.infobox.boxbg_col[3],
663+ motif.infobox.boxbg_alpha[1],
664+ motif.infobox.boxbg_alpha[2]
665+ )
842666 --draw text
843667 for i = 1, #t do
844668 main.f_updateTextImg(
845669 txt_input,
846- motif.font_data[motif.warning_info.text_font[1]],
847- motif.warning_info.text_font[2],
848- motif.warning_info.text_font[3],
670+ motif.font_data[motif.infobox.text_font[1]],
671+ motif.infobox.text_font[2],
672+ motif.infobox.text_font[3],
849673 t[i],
850- motif.warning_info.text_pos[1],
851- motif.warning_info.text_pos[2] - motif.warning_info.text_spacing[2] + i * motif.warning_info.text_spacing[2],
852- motif.warning_info.text_font_scale[1],
853- motif.warning_info.text_font_scale[2],
854- motif.warning_info.text_font[4],
855- motif.warning_info.text_font[5],
856- motif.warning_info.text_font[6]
674+ motif.infobox.text_pos[1],
675+ motif.infobox.text_pos[2] - motif.infobox.text_spacing[2] + i * motif.infobox.text_spacing[2],
676+ motif.infobox.text_font_scale[1],
677+ motif.infobox.text_font_scale[2],
678+ motif.infobox.text_font[4],
679+ motif.infobox.text_font[5],
680+ motif.infobox.text_font[6],
681+ motif.infobox.text_font[7],
682+ motif.infobox.text_font[8]
857683 )
858684 textImgDraw(txt_input)
859685 end
860- --update timer
861- background.timer = background.timer + 1
862686 --end loop
863687 main.f_cmdInput()
864688 refresh()
@@ -866,6 +690,7 @@ function main.f_input(t, info, background, type)
866690 return input
867691 end
868692
693+--refresh screen every 0.02 during initial loading
869694 main.nextRefresh = os.clock() + 0.02
870695 function main.loadingRefresh(txt)
871696 if os.clock() >= main.nextRefresh then
@@ -878,21 +703,33 @@ function main.loadingRefresh(txt)
878703 end
879704
880705 --;===========================================================
706+--; LOCALCOORD
707+--;===========================================================
708+require('script.screenpack')
709+main.IntLocalcoordValues()
710+main.CalculateLocalcoordValues()
711+main.IntLifebarScale()
712+main.SetScaleValues()
713+
714+--;===========================================================
881715 --; COMMAND LINE QUICK VS
882716 --;===========================================================
883717 main.flags = getCommandLineFlags()
884718 if main.flags['-p1'] ~= nil and main.flags['-p2'] ~= nil then
885719 --load lifebar
886- local sp = config.Motif
720+ local def = config.Motif
887721 if main.flags['-r'] ~= nil then
888- if main.f_fileExists(main.flags['-r']) then
889- sp = main.flags['-r']
722+ local case = main.flags['-r']:lower()
723+ if case:match('^data[/\\]') and main.f_fileExists(main.flags['-r']) then
724+ def = main.flags['-r']
725+ elseif case:match('%.def$') and main.f_fileExists('data/' .. main.flags['-r']) then
726+ def = 'data/' .. main.flags['-r']
890727 elseif main.f_fileExists('data/' .. main.flags['-r'] .. '/system.def') then
891- sp = 'data/' .. main.flags['-r'] .. '/system.def'
728+ def = 'data/' .. main.flags['-r'] .. '/system.def'
892729 end
893730 end
894- local fileDir = sp:match('^(.-)[^/\\]+$')
895- local file = io.open(sp,"r")
731+ local fileDir = def:match('^(.-)[^/\\]+$')
732+ local file = io.open(def,"r")
896733 local s = file:read("*all")
897734 file:close()
898735 local lifebar = s:match('fight%s*=%s*(.-%.def)%s*')
@@ -906,6 +743,16 @@ if main.flags['-p1'] ~= nil and main.flags['-p2'] ~= nil then
906743 loadLifebar('data/fight.def')
907744 end
908745 refresh()
746+ --set settings
747+ setAutoguard(1, config.AutoGuard)
748+ setAutoguard(2, config.AutoGuard)
749+ setPowerShare(1, config.TeamPowerShare)
750+ setPowerShare(2, config.TeamPowerShare)
751+ setLifeShare(config.TeamLifeShare)
752+ setRoundTime(math.max(-1, config.RoundTime * getFramesPerCount()))
753+ setLifeMul(config.LifeMul / 100)
754+ setTeam1VS2Life(config.Team1VS2Life / 100)
755+ setTurnsRecoveryRate(config.TurnsRecoveryBase / 100, config.TurnsRecoveryBonus / 100)
909756 --add chars
910757 local p1NumChars = 0
911758 local p2NumChars = 0
@@ -923,14 +770,36 @@ if main.flags['-p1'] ~= nil and main.flags['-p2'] ~= nil then
923770 end
924771 local pal = 1
925772 if main.flags['-p' .. num .. '.pal'] ~= nil then
926- pal = main.flags['-p' .. num .. '.pal']
773+ pal = tonumber(main.flags['-p' .. num .. '.pal'])
927774 end
928775 local ai = 0
929776 if main.flags['-p' .. num .. '.ai'] ~= nil then
930- ai = main.flags['-p' .. num .. '.ai']
777+ ai = tonumber(main.flags['-p' .. num .. '.ai'])
778+ end
779+ table.insert(t, {character = v, player = player, num = num, pal = pal, ai = ai, overwrite = {}})
780+ if main.flags['-p' .. num .. '.power'] ~= nil then
781+ t[#t].overwrite['power'] = tonumber(main.flags['-p' .. num .. '.power'])
782+ end
783+ if main.flags['-p' .. num .. '.life'] ~= nil then
784+ t[#t].overwrite['life'] = tonumber(main.flags['-p' .. num .. '.life'])
785+ end
786+ if main.flags['-p' .. num .. '.lifeMax'] ~= nil then
787+ t[#t].overwrite['lifeMax'] = tonumber(main.flags['-p' .. num .. '.lifeMax'])
788+ end
789+ if main.flags['-p' .. num .. '.lifeRatio'] ~= nil then
790+ t[#t].overwrite['lifeRatio'] = tonumber(main.flags['-p' .. num .. '.lifeRatio'])
791+ end
792+ if main.flags['-p' .. num .. '.attackRatio'] ~= nil then
793+ t[#t].overwrite['attackRatio'] = tonumber(main.flags['-p' .. num .. '.attackRatio'])
794+ end
795+ if main.flags['-p' .. num .. '.defenceRatio'] ~= nil then
796+ t[#t].overwrite['defenceRatio'] = tonumber(main.flags['-p' .. num .. '.defenceRatio'])
931797 end
932- t[#t + 1] = {player = player, num = num - 1, pal = tonumber(pal), ai = tonumber(ai)}
933798 refresh()
799+ elseif k:match('^-rounds$') then
800+ setMatchWins(tonumber(v))
801+ elseif k:match('^-draws$') then
802+ setMatchMaxDrawGames(tonumber(v))
934803 end
935804 end
936805 local p1TeamMode = 0
@@ -952,17 +821,20 @@ if main.flags['-p1'] ~= nil and main.flags['-p2'] ~= nil then
952821 end
953822 addStage(stage)
954823 --load data
955- loadDebugFont('font/f-6x9.fnt')
824+ loadDebugFont('f-6x9.fnt')
956825 setDebugScript('script/debug.lua')
957- setMatchNo(1)
958826 selectStart()
827+ setMatchNo(1)
959828 setStage(0)
960829 selectStage(0)
961830 setTeamMode(1, p1TeamMode, p1NumChars)
962831 setTeamMode(2, p2TeamMode, p2NumChars)
963- for i = 1, #t do
964- selectChar(t[i].player, t[i].num, t[i].pal)
965- setCom(t[i].player, t[i].ai)
832+ main.f_printTable(t, 'debug/t_quickvs.txt')
833+ --iterate over the table in -p order ascending
834+ for k, v in main.f_sortKeys(t, function(t, a, b) return t[b].num > t[a].num end) do
835+ selectChar(v.player, k - 1, v.pal)
836+ setCom(v.num, v.ai)
837+ overwriteCharData(v.num, v.overwrite)
966838 end
967839 local winner, t_gameStats = game()
968840 if main.flags['-log'] ~= nil then
@@ -975,31 +847,14 @@ end
975847 --;===========================================================
976848 --; LOAD DATA
977849 --;===========================================================
978-main.fadeSff = sffNew('data/fade.sff')
979-
980850 motif = require('script.motif')
981851
852+setMotifDir(motif.fileDir)
982853 setPortrait(motif.select_info.p1_face_spr[1], motif.select_info.p1_face_spr[2], 1) --Big portrait
983854 setPortrait(motif.select_info.portrait_spr[1], motif.select_info.portrait_spr[2], 2) --Small portrait
984855 setPortrait(motif.vs_screen.p1_spr[1], motif.vs_screen.p1_spr[2], 3) --Versus portrait
985856 setPortrait(motif.victory_screen.p1_spr[1], motif.victory_screen.p1_spr[2], 4) --Victory portrait
986-
987-main.cursorBox = animNew(main.fadeSff, '0,1, 0,0, -1')
988-animSetTile(main.cursorBox, 1, 1)
989-animUpdate(main.cursorBox)
990-
991-main.warningBox = animNew(main.fadeSff, '0,0, 0,0, -1')
992-animSetTile(main.warningBox, 1, 1)
993-animSetAlpha(main.warningBox, motif.warning_info.background_alpha[1], motif.warning_info.background_alpha[2])
994-animSetWindow(main.warningBox, 0, 0, motif.info.localcoord[1], motif.info.localcoord[2])
995-animUpdate(main.warningBox)
996-
997-main.infoBox = animNew(main.fadeSff, '0,0, 0,0, -1')
998-animSetTile(main.infoBox, 1, 1)
999-animSetAlpha(main.infoBox, motif.infobox.background_alpha[1], motif.infobox.background_alpha[2])
1000-animSetWindow(main.infoBox, 0, 0, motif.info.localcoord[1], motif.info.localcoord[2])
1001-animUpdate(main.infoBox)
1002-
857+setPortrait(motif.select_info.stage_portrait_spr[1], motif.select_info.stage_portrait_spr[2], 5) --Stage portrait
1003858
1004859 main.txt_warningTitle = main.f_createTextImg(
1005860 motif.font_data[motif.warning_info.title_font[1]],
@@ -1012,25 +867,11 @@ main.txt_warningTitle = main.f_createTextImg(
1012867 motif.warning_info.title_font_scale[2],
1013868 motif.warning_info.title_font[4],
1014869 motif.warning_info.title_font[5],
1015- motif.warning_info.title_font[6]
870+ motif.warning_info.title_font[6],
871+ motif.warning_info.title_font[7],
872+ motif.warning_info.title_font[8]
1016873 )
1017874
1018-main.SetDefaultScale()
1019-
1020-local footerBox = animNew(main.fadeSff, '0,2, 0,0, -1')
1021-animSetTile(footerBox, 1, 1)
1022-animSetWindow(
1023- footerBox,
1024- motif.title_info.footer_boxbackground_coords[1],
1025- motif.title_info.footer_boxbackground_coords[2],
1026- motif.title_info.footer_boxbackground_coords[3] - motif.title_info.footer_boxbackground_coords[1] + 1,
1027- motif.title_info.footer_boxbackground_coords[4] - motif.title_info.footer_boxbackground_coords[2] + 1
1028-)
1029-animSetAlpha(footerBox, motif.title_info.footer_boxbackground_alpha[1], motif.title_info.footer_boxbackground_alpha[2])
1030-animUpdate(footerBox)
1031-
1032-main.SetScaleValues()
1033-
1034875 --add characters and stages using select.def instead of select.lua
1035876 local txt_loading = main.f_createTextImg(
1036877 motif.font_data[motif.title_info.loading_font[1]],
@@ -1043,101 +884,175 @@ local txt_loading = main.f_createTextImg(
1043884 motif.title_info.loading_font_scale[2],
1044885 motif.title_info.loading_font[4],
1045886 motif.title_info.loading_font[5],
1046- motif.title_info.loading_font[6]
887+ motif.title_info.loading_font[6],
888+ motif.title_info.loading_font[7],
889+ motif.title_info.loading_font[8]
1047890 )
1048891 textImgDraw(txt_loading)
1049892 refresh()
1050893
1051-function main.f_addChar(line, row)
894+function main.f_charParam(t, c)
895+ if c:match('music[al]?[li]?[tf]?[e]?%s*=') then --music / musicalt / musiclife
896+ local bgmvolume, bgmloopstart, bgmloopend = 100, 0, 0
897+ c = c:gsub('%s+([0-9%s]+)$', function(m1)
898+ for i, c in ipairs(main.f_strsplit('%s+', m1)) do --split using whitespace delimiter
899+ if i == 1 then
900+ bgmvolume = tonumber(c)
901+ elseif i == 2 then
902+ bgmloopstart = tonumber(c)
903+ elseif i == 3 then
904+ bgmloopend = tonumber(c)
905+ else
906+ break
907+ end
908+ end
909+ return ''
910+ end)
911+ c = c:gsub('\\', '/')
912+ local bgtype, bgmusic = c:match('^(music[al]?[li]?[tf]?[e]?)%s*=%s*(.-)%s*$')
913+ if t[bgtype] == nil then t[bgtype] = {} end
914+ table.insert(t[bgtype], {bgmusic = bgmusic, bgmvolume = bgmvolume, bgmloopstart = bgmloopstart, bgmloopend = bgmloopend})
915+ elseif c:match('lifebar%s*=') then --lifebar
916+ if t.lifebar == nil then
917+ t.lifebar = c:match('=%s*(.-)%s*$')
918+ end
919+ elseif c:match('[0-9]+%s*=%s*[^%s]') then --num = string (unused)
920+ local var1, var2 = c:match('([0-9]+)%s*=%s*(.+)%s*$')
921+ t[tonumber(var1)] = var2
922+ elseif c:match('%.[Dd][Ee][Ff]') or c:match('^random$') then --stage
923+ c = c:gsub('\\', '/')
924+ if t.stage == nil then
925+ t.stage = {}
926+ end
927+ table.insert(t.stage, c)
928+ else --param = value
929+ local param, value = c:match('^(.-)%s*=%s*(.-)$')
930+ if param ~= nil and value ~= nil and param ~= '' and value ~= '' then
931+ t[param] = tonumber(value)
932+ if t[param] == nil then
933+ t[param] = value
934+ end
935+ end
936+ end
937+end
938+
939+function main.f_addChar(line, row, playable)
1052940 local tmp = ''
1053- local order = false
1054- local hidden = 0
1055- for i, c in ipairs(main.f_strsplit(',', line)) do
941+ main.t_selChars[row] = {}
942+ --parse 'rivals' param and get rid of it if exists
943+ for num, str in line:gmatch('([0-9]+)%s*=%s*{([^%}]-)}') do
944+ num = tonumber(num)
945+ if main.t_selChars[row].rivals == nil then
946+ main.t_selChars[row].rivals = {}
947+ end
948+ for i, c in ipairs(main.f_strsplit(',', str)) do --split using "," delimiter
949+ c = c:match('^%s*(.-)%s*$')
950+ if i == 1 then
951+ c = c:gsub('\\', '/')
952+ c = tostring(c)
953+ main.t_selChars[row].rivals[num] = {char = c}
954+ else
955+ main.f_charParam(main.t_selChars[row].rivals[num], c)
956+ end
957+ end
958+ line = line:gsub(',%s*' .. num .. '%s*=%s*{([^%}]-)}', '')
959+ end
960+ --parse rest of the line
961+ for i, c in ipairs(main.f_strsplit(',', line)) do --split using "," delimiter
1056962 c = c:match('^%s*(.-)%s*$')
1057963 if i == 1 then
1058964 c = c:gsub('\\', '/')
1059965 c = tostring(c)
1060- main.t_selChars[row] = {}
1061966 addChar(c)
1062- tmp = getCharName(row - 1):match('^["%s]*(.-)["%s]*$') --needed for s-size ikemen
967+ tmp = getCharName(row - 1)
1063968 if tmp == '' then
969+ playable = false
1064970 break
1065971 end
1066- main.t_charDef[c] = row - 1
972+ main.t_charDef[c:lower()] = row - 1
1067973 main.t_selChars[row].char = c
1068- if tmp ~= 'Random' then
1069- main.t_selChars[row].displayname = tmp
1070- main.t_selChars[row].def = getCharFileName(row - 1)
1071- main.t_selChars[row].dir = main.t_selChars[row].def:gsub('[^/]+%.def$', '')
1072- main.t_selChars[row].pal = getCharPalettes(row - 1)
1073- if tmp ~= 'Training' then
1074- tmp = getCharIntro(row - 1)
1075- if tmp ~= '' then
1076- main.t_selChars[row].intro = main.t_selChars[row].dir .. tmp:gsub('\\', '/')
1077- end
1078- tmp = getCharEnding(row - 1)
1079- if tmp ~= '' then
1080- main.t_selChars[row].ending = main.t_selChars[row].dir .. tmp:gsub('\\', '/')
1081- end
1082- main.t_selChars[row].order = 1
1083- order = true
1084- end
1085- else
974+ if tmp == 'Random' then
975+ playable = false
1086976 break
1087977 end
1088- elseif c:match('music%s*=%s*') then
1089- c = c:gsub('\\', '/')
1090- local bgmvolume = c:match('%s([0-9]+)$')
1091- if bgmvolume == nil then
1092- bgmvolume = 100
1093- else
1094- bgmvolume = tonumber(bgmvolume)
1095- c = c:gsub('%s*[0-9]+$','')
1096- end
1097- local bgmusic = c:match('^music%s*=%s*(.-)%s*$')
1098- if main.t_selChars[row].music == nil then
1099- main.t_selChars[row].music = {}
1100- end
1101- main.t_selChars[row].music[#main.t_selChars[row].music + 1] = {}
1102- main.t_selChars[row].music[#main.t_selChars[row].music].bgmusic = bgmusic
1103- main.t_selChars[row].music[#main.t_selChars[row].music].bgmvolume = bgmvolume
1104- elseif c:match('[0-9]+%s*=%s*[^%s]') then
1105- local var1, var2 = c:match('([0-9]+)%s*=%s*(.+)%s*$')
1106- main.t_selChars[row][tonumber(var1)] = var2:lower()
1107- elseif c:match('%.def') or c:match('^random$') then
1108- c = c:gsub('\\', '/')
1109- if main.t_selChars[row].stage == nil then
1110- main.t_selChars[row].stage = {}
978+ main.t_selChars[row].playable = playable
979+ main.t_selChars[row].displayname = tmp
980+ main.t_selChars[row].def = getCharFileName(row - 1)
981+ main.t_selChars[row].dir = main.t_selChars[row].def:gsub('[^/]+%.def$', '')
982+ main.t_selChars[row].pal, main.t_selChars[row].pal_defaults, main.t_selChars[row].pal_keymap = getCharPalettes(row - 1)
983+ if playable then
984+ tmp = getCharIntro(row - 1)
985+ if tmp ~= '' then
986+ main.t_selChars[row].intro = main.t_selChars[row].dir .. tmp:gsub('\\', '/')
987+ end
988+ tmp = getCharEnding(row - 1)
989+ if tmp ~= '' then
990+ main.t_selChars[row].ending = main.t_selChars[row].dir .. tmp:gsub('\\', '/')
991+ end
992+ main.t_selChars[row].order = 1
1111993 end
1112- main.t_selChars[row].stage[#main.t_selChars[row].stage + 1] = c
1113994 else
1114- local param, value = c:match('^(.-)%s*=%s*(.-)$')
1115- if param ~= '' and value ~= '' and param ~= nil and value ~= nil then
1116- main.t_selChars[row][param] = tonumber(value)
1117- end
995+ main.f_charParam(main.t_selChars[row], c)
1118996 end
1119997 end
1120998 if main.t_selChars[row].hidden == nil then
1121- main.t_selChars[row].hidden = hidden
1122- end
1123- if main.t_selChars[row].exclude == nil then
1124- main.t_selChars[row].exclude = 0
999+ main.t_selChars[row].hidden = 0
11251000 end
1126- if order then
1001+ if playable then
1002+ --order param
11271003 if main.t_orderChars[main.t_selChars[row].order] == nil then
11281004 main.t_orderChars[main.t_selChars[row].order] = {}
11291005 end
1130- main.t_orderChars[main.t_selChars[row].order][#main.t_orderChars[main.t_selChars[row].order] + 1] = row - 1
1006+ table.insert(main.t_orderChars[main.t_selChars[row].order], row - 1)
1007+ --ordersurvival param
1008+ local num = 1
1009+ if main.t_selChars[row].ordersurvival ~= nil then
1010+ num = main.t_selChars[row].ordersurvival
1011+ end
1012+ if main.t_orderSurvival[num] == nil then
1013+ main.t_orderSurvival[num] = {}
1014+ end
1015+ table.insert(main.t_orderSurvival[num], row - 1)
11311016 end
11321017 main.loadingRefresh(txt_loading)
11331018 end
11341019
1135---start_time = os.time()
1136-main.t_includeStage = {}
1020+function main.f_addStage(file)
1021+ file = file:gsub('\\', '/')
1022+ --if not main.f_fileExists(file) or file:match('^stages/$') then
1023+ -- return #main.t_selStages
1024+ --end
1025+ addStage(file)
1026+ local stageNo = #main.t_selStages + 1
1027+ local tmp = getStageName(stageNo)
1028+ --if tmp == '' then
1029+ -- return stageNo
1030+ --end
1031+ main.t_stageDef[file:lower()] = stageNo
1032+ main.t_selStages[stageNo] = {name = tmp, stage = file}
1033+ local _, _, t_bgmusic = getStageInfo(stageNo)
1034+ for k = 1, #t_bgmusic do
1035+ if t_bgmusic[k].bgmusic ~= '' then
1036+ if k == 1 then
1037+ tmp = 'music'
1038+ elseif k == 2 then
1039+ tmp = 'musicalt'
1040+ else
1041+ tmp = 'musiclife'
1042+ end
1043+ main.t_selStages[stageNo][tmp] = {[1] = {bgmusic = t_bgmusic[k].bgmusic:gsub('\\', '/'), bgmvolume = t_bgmusic[k].bgmvolume, bgmloopstart = t_bgmusic[k].bgmloopstart, bgmloopend = t_bgmusic[k].bgmloopend}}
1044+ end
1045+ end
1046+ return stageNo
1047+end
1048+
1049+main.t_includeStage = {{}, {}} --includestage = 1, includestage = -1
11371050 main.t_orderChars = {}
1051+main.t_orderStages = {}
1052+main.t_orderSurvival = {}
11381053 main.t_stageDef = {['random'] = 0}
11391054 main.t_charDef = {}
1140-local t_exlude = {}
1055+local t_addExluded = {}
11411056 local chars = 0
11421057 local stages = 0
11431058 local tmp = ''
@@ -1149,20 +1064,20 @@ file:close()
11491064 content = content:gsub('([^\r\n;]*)%s*;[^\r\n]*', '%1')
11501065 content = content:gsub('\n%s*\n', '\n')
11511066 for line in content:gmatch('[^\r\n]+') do
1067+--for line in io.lines("data/select.def") do
11521068 if chars + stages == 100 then
11531069 SetGCPercent(100)
11541070 end
1155---for line in io.lines("data/select.def") do
1156- line = line:lower()
1157- if line:match('^%s*%[%s*characters%s*%]') then
1071+ local lineCase = line:lower()
1072+ if lineCase:match('^%s*%[%s*characters%s*%]') then
11581073 main.t_selChars = {}
11591074 row = 0
11601075 section = 1
1161- elseif line:match('^%s*%[%s*extrastages%s*%]') then
1076+ elseif lineCase:match('^%s*%[%s*extrastages%s*%]') then
11621077 main.t_selStages = {}
11631078 row = 0
11641079 section = 2
1165- elseif line:match('^%s*%[%s*options%s*%]') then
1080+ elseif lineCase:match('^%s*%[%s*options%s*%]') then
11661081 main.t_selOptions = {
11671082 arcadestart = {wins = 0, offset = 0},
11681083 arcadeend = {wins = 0, offset = 0},
@@ -1174,73 +1089,71 @@ for line in content:gmatch('[^\r\n]+') do
11741089 row = 0
11751090 section = 3
11761091 elseif section == 1 then --[Characters]
1177- if line:match(',%s*exclude%s*=%s*1') then --character should be added after all slots are filled
1178- t_exlude[#t_exlude + 1] = line
1092+ if lineCase:match(',%s*exclude%s*=%s*1') then --character should be added after all slots are filled
1093+ table.insert(t_addExluded, line)
11791094 else
11801095 chars = chars + 1
1181- main.f_addChar(line, chars)
1096+ main.f_addChar(line, chars, true)
11821097 end
11831098 elseif section == 2 then --[ExtraStages]
1184- row = #main.t_selStages + 1
1185- for i, c in ipairs(main.f_strsplit(',', line)) do
1099+ for i, c in ipairs(main.f_strsplit(',', line)) do --split using "," delimiter
11861100 c = c:gsub('^%s*(.-)%s*$', '%1')
11871101 if i == 1 then
1102+ row = main.f_addStage(c)
1103+ table.insert(main.t_includeStage[1], row)
1104+ table.insert(main.t_includeStage[2], row)
1105+ elseif c:match('music[al]?[li]?[tf]?[e]?%s*=') then
1106+ local bgmvolume, bgmloopstart, bgmloopend = 100, 0, 0
1107+ c = c:gsub('%s+([0-9%s]+)$', function(m1)
1108+ for i, c in ipairs(main.f_strsplit('%s+', m1)) do --split using whitespace delimiter
1109+ if i == 1 then
1110+ bgmvolume = tonumber(c)
1111+ elseif i == 2 then
1112+ bgmloopstart = tonumber(c)
1113+ elseif i == 3 then
1114+ bgmloopend = tonumber(c)
1115+ else
1116+ break
1117+ end
1118+ end
1119+ return ''
1120+ end)
11881121 c = c:gsub('\\', '/')
1189- if not main.f_fileExists(c) or c:match('^stages/$') then
1190- break
1191- end
1192- addStage(c)
1193- tmp = getStageName(row):match('^["%s]*(.-)["%s]*$') --needed for s-size ikemen
1194- if tmp == '' then
1195- break
1196- end
1197- main.t_selStages[row] = {name = tmp, stage = c}
1198- local zoomout, zoomin, bgmusic, bgmvolume, bgmloopstart, bgmloopend = getStageInfo(row)
1199- if zoomout ~= '' then
1200- main.t_selStages[row].zoommin = tonumber(zoomout)
1201- end
1202- if zoomin ~= '' then
1203- main.t_selStages[row].zoommax = tonumber(zoomin)
1204- end
1205- if bgmusic ~= '' then
1206- bgmusic = bgmusic:gsub('\\', '/')
1207- main.t_selStages[row].music = {[1] = {bgmusic = bgmusic, bgmvolume = tonumber(bgmvolume), bgmloopstart = bgmloopstart, bgmloopend = bgmloopend}}
1208- end
1209- main.t_includeStage[#main.t_includeStage + 1] = row
1210- main.t_stageDef[c] = row
1211- elseif c:match('music%s*=%s*') then
1212- c = c:gsub('\\', '/')
1213- local bgmvolume = c:match('%s([0-9]+)$')
1214- if bgmvolume == nil then
1215- bgmvolume = 100
1216- else
1217- bgmvolume = tonumber(bgmvolume)
1218- c = c:gsub('%s*[0-9]+$','')
1219- end
1220- local bgmusic = c:match('^music%s*=%s*(.-)%s*$')
1221- if main.t_selStages[row].music == nil then
1222- main.t_selStages[row].music = {}
1223- end
1224- main.t_selStages[row].music[#main.t_selStages[row].music+1] = {bgmusic = bgmusic, bgmvolume = bgmvolume}
1122+ local bgtype, bgmusic = c:match('^(music[al]?[li]?[tf]?[e]?)%s*=%s*(.-)%s*$')
1123+ if main.t_selStages[row][bgtype] == nil then main.t_selStages[row][bgtype] = {} end
1124+ table.insert(main.t_selStages[row][bgtype], {bgmusic = bgmusic, bgmvolume = bgmvolume, bgmloopstart = bgmloopstart, bgmloopend = bgmloopend})
12251125 else
12261126 local param, value = c:match('^(.-)%s*=%s*(.-)$')
1227- main.t_selStages[row][param] = tonumber(value)
1127+ if param ~= nil and value ~= nil and param ~= '' and value ~= '' then
1128+ main.t_selStages[row][param] = tonumber(value)
1129+ if param:match('order') then
1130+ if main.t_orderStages[main.t_selStages[row].order] == nil then
1131+ main.t_orderStages[main.t_selStages[row].order] = {}
1132+ end
1133+ table.insert(main.t_orderStages[main.t_selStages[row].order], row)
1134+ end
1135+ end
12281136 end
12291137 end
12301138 elseif section == 3 then --[Options]
1231- if line:match('^%s*.-%.maxmatches%s*=%s*') then
1232- local rowName, line = line:match('^%s*(.-)%.maxmatches%s*=%s*(.+)')
1139+ if lineCase:match('%.maxmatches%s*=') then
1140+ local rowName, line = lineCase:match('^%s*(.-)%.maxmatches%s*=%s*(.+)')
1141+ rowName = rowName:gsub('%.', '_')
12331142 main.t_selOptions[rowName .. 'maxmatches'] = {}
1234- for i, c in ipairs(main.f_strsplit(',', line:gsub('%s*(.-)%s*', '%1'))) do
1143+ for i, c in ipairs(main.f_strsplit(',', line:gsub('%s*(.-)%s*', '%1'))) do --split using "," delimiter
12351144 main.t_selOptions[rowName .. 'maxmatches'][i] = tonumber(c)
12361145 end
1237- elseif line:match('^%s*.-%.airamp%..-%s*=%s*') then
1238- local rowName, rowName2, wins, offset = line:match('^%s*(.-)%.airamp%.(.-)%s*=%s*([0-9]+)%s*,%s*([0-9-]+)')
1146+ elseif lineCase:match('%.airamp%.') then
1147+ local rowName, rowName2, wins, offset = lineCase:match('^%s*(.-)%.airamp%.(.-)%s*=%s*([0-9]+)%s*,%s*([0-9-]+)')
12391148 main.t_selOptions[rowName .. rowName2] = {wins = tonumber(wins), offset = tonumber(offset)}
12401149 end
12411150 end
12421151 end
1243---main.f_printVar(os.difftime(os.time(), start_time))
1152+
1153+--add default maxmatches values if config is missing in select.def
1154+if main.t_selOptions.arcademaxmatches == nil then main.t_selOptions.arcademaxmatches = {6, 1, 1, 0, 0, 0, 0, 0, 0, 0} end
1155+if main.t_selOptions.teammaxmatches == nil then main.t_selOptions.teammaxmatches = {4, 1, 1, 0, 0, 0, 0, 0, 0, 0} end
1156+if main.t_selOptions.survivalmaxmatches == nil then main.t_selOptions.survivalmaxmatches = {-1, 0, 0, 0, 0, 0, 0, 0, 0, 0} end
12441157
12451158 --add excluded characters once all slots are filled
12461159 for i = chars, (motif.select_info.rows + motif.select_info.rows_scrolling) * motif.select_info.columns - 1 do
@@ -1248,14 +1161,15 @@ for i = chars, (motif.select_info.rows + motif.select_info.rows_scrolling) * mot
12481161 main.t_selChars[chars] = {}
12491162 addChar('dummyChar')
12501163 end
1251-for i = 1, #t_exlude do
1164+for i = 1, #t_addExluded do
12521165 chars = chars + 1
1253- main.f_addChar(t_exlude[i], chars)
1166+ main.f_addChar(t_addExluded[i], chars, true)
12541167 end
1168+
12551169 --add Training by stupa if not included in select.def
12561170 if main.t_charDef.training == nil and main.f_fileExists('chars/training/training.def') then
12571171 chars = chars + 1
1258- main.f_addChar('training, exclude = 1, order = 0', chars)
1172+ main.f_addChar('training, exclude = 1', chars, false)
12591173 end
12601174
12611175 --add remaining character parameters
@@ -1264,35 +1178,48 @@ main.t_bonusChars = {}
12641178 main.t_randomChars = {}
12651179 --for each character loaded
12661180 for i = 1, #main.t_selChars do
1267- if main.t_selChars[i].stage ~= nil then
1268- for j = 1, #main.t_selChars[i].stage do
1269- if main.t_stageDef[main.t_selChars[i].stage[j]] == nil and main.file_exists(main.t_selChars[i].stage[j]) then
1270- row = #main.t_selStages + 1
1271- addStage(main.t_selChars[i].stage[j])
1272- tmp = getStageName(row):match('^["%s]*(.-)["%s]*$') --needed for s-size ikemen
1273- if tmp == '' then
1274- break
1275- end
1276- main.t_selStages[row] = {name = tmp, stage = main.t_selChars[i].stage[j]}
1277- local zoomout, zoomin, bgmusic, bgmvolume, bgmloopstart, bgmloopend = getStageInfo(row)
1278- if zoomout ~= '' then
1279- main.t_selStages[row].zoommin = tonumber(zoomout)
1280- end
1281- if zoomin ~= '' then
1282- main.t_selStages[row].zoommax = tonumber(zoomin)
1181+ --add char_ref entry
1182+ if main.t_selChars[i].char ~= nil then
1183+ main.t_selChars[i].char_ref = main.t_charDef[main.t_selChars[i].char:lower()]
1184+ end
1185+ --change character 'rivals' param char and stage string file paths to reference values
1186+ if main.t_selChars[i].rivals ~= nil then
1187+ for j = 1, #main.t_selChars[i].rivals do
1188+ --add 'rivals' param character if needed or reference existing one
1189+ if main.t_selChars[i].rivals[j].char ~= nil then
1190+ if main.t_charDef[main.t_selChars[i].rivals[j].char:lower()] == nil then --new char
1191+ chars = chars + 1
1192+ main.f_addChar(main.t_selChars[i].rivals[j].char .. ', exclude = 1', chars, false)
1193+ main.t_selChars[i].rivals[j].char_ref = chars
1194+ else --already added
1195+ main.t_selChars[i].rivals[j].char_ref = main.t_charDef[main.t_selChars[i].rivals[j].char:lower()]
12831196 end
1284- if bgmusic ~= '' then
1285- bgmusic = bgmusic:gsub('\\', '/')
1286- main.t_selStages[row].music = {}
1287- main.t_selStages[row].music[1] = {bgmusic = bgmusic, bgmvolume = tonumber(bgmvolume), bgmloopstart = bgmloopstart, bgmloopend = bgmloopend}
1197+ end
1198+ --add 'rivals' param stages if needed or reference existing ones
1199+ if main.t_selChars[i].rivals[j].stage ~= nil then
1200+ for k = 1, #main.t_selChars[i].rivals[j].stage do
1201+ if main.t_stageDef[main.t_selChars[i].rivals[j].stage[k]:lower()] == nil then
1202+ main.t_selChars[i].rivals[j].stage[k] = main.f_addStage(main.t_selChars[i].rivals[j].stage[k])
1203+ else --already added
1204+ main.t_selChars[i].rivals[j].stage[k] = main.t_stageDef[main.t_selChars[i].rivals[j].stage[k]:lower()]
1205+ end
12881206 end
1289- if main.t_selChars[i].includestage == nil or main.t_selChars[i].includestage == 1 then
1290- main.t_includeStage[#main.t_includeStage + 1] = row
1207+ end
1208+ end
1209+ end
1210+ --character stage param
1211+ if main.t_selChars[i].stage ~= nil then
1212+ for j = 1, #main.t_selChars[i].stage do
1213+ --add 'stage' param stages if needed or reference existing ones
1214+ if main.t_stageDef[main.t_selChars[i].stage[j]:lower()] == nil then
1215+ main.t_selChars[i].stage[j] = main.f_addStage(main.t_selChars[i].stage[j])
1216+ if main.t_selChars[i].includestage == nil or main.t_selChars[i].includestage == 1 then --stage available all the time
1217+ table.insert(main.t_includeStage[1], main.t_selChars[i].stage[j])
1218+ elseif main.t_selChars[i].includestage == -1 then --excluded stage that can be still manually selected
1219+ table.insert(main.t_includeStage[2], main.t_selChars[i].stage[j])
12911220 end
1292- main.t_selChars[i].stage[j] = row
1293- --main.t_stageDef[main.t_selChars[i].stage[j]] = row
1294- else
1295- main.t_selChars[i].stage[j] = main.t_stageDef[main.t_selChars[i].stage[j]]
1221+ else --already added
1222+ main.t_selChars[i].stage[j] = main.t_stageDef[main.t_selChars[i].stage[j]:lower()]
12961223 end
12971224 end
12981225 end
@@ -1300,15 +1227,15 @@ for i = 1, #main.t_selChars do
13001227 if main.t_selChars[i].displayname ~= nil then
13011228 --generate table for boss rush mode
13021229 if main.t_selChars[i].boss ~= nil and main.t_selChars[i].boss == 1 then
1303- main.t_bossChars[#main.t_bossChars + 1] = i - 1
1230+ table.insert(main.t_bossChars, i - 1)
13041231 end
13051232 --generate table for bonus games mode
13061233 if main.t_selChars[i].bonus ~= nil and main.t_selChars[i].bonus == 1 then
1307- main.t_bonusChars[#main.t_bonusChars + 1] = i - 1
1234+ table.insert(main.t_bonusChars, i - 1)
13081235 end
13091236 --generate table with characters allowed to be random selected
1310- if main.t_selChars[i].hidden ~= nil and main.t_selChars[i].hidden <= 1 then
1311- main.t_randomChars[#main.t_randomChars + 1] = i - 1
1237+ if main.t_selChars[i].playable and (main.t_selChars[i].hidden == nil or main.t_selChars[i].hidden <= 1) and (main.t_selChars[i].exclude == nil or main.t_selChars[i].exclude == 0) then
1238+ table.insert(main.t_randomChars, i - 1)
13121239 end
13131240 end
13141241 end
@@ -1318,12 +1245,15 @@ main.f_printTable(main.t_selChars, "debug/t_selChars.txt")
13181245 main.f_printTable(main.t_selStages, "debug/t_selStages.txt")
13191246 main.f_printTable(main.t_selOptions, "debug/t_selOptions.txt")
13201247 main.f_printTable(main.t_orderChars, "debug/t_orderChars.txt")
1248+main.f_printTable(main.t_orderStages, "debug/t_orderStages.txt")
1249+main.f_printTable(main.t_orderSurvival, "debug/t_orderSurvival.txt")
13211250 main.f_printTable(main.t_randomChars, "debug/t_randomChars.txt")
13221251 main.f_printTable(main.t_bossChars, "debug/t_bossChars.txt")
13231252 main.f_printTable(main.t_bonusChars, "debug/t_bonusChars.txt")
13241253 main.f_printTable(main.t_stageDef, "debug/t_stageDef.txt")
13251254 main.f_printTable(main.t_charDef, "debug/t_charDef.txt")
13261255 main.f_printTable(main.t_includeStage, "debug/t_includeStage.txt")
1256+main.f_printTable(config, "debug/config.txt")
13271257
13281258 --Debug stuff
13291259 loadDebugFont(motif.files.debug_font)
@@ -1333,31 +1263,39 @@ setDebugScript(motif.files.debug_script)
13331263 textImgDraw(txt_loading)
13341264 refresh()
13351265 loadLifebar(motif.files.fight)
1266+main.currentLifebar = motif.files.fight
13361267 main.loadingRefresh(txt_loading)
13371268
1338---warnings
1269+--print warning if training character is missing
13391270 if main.t_charDef.training == nil then
13401271 main.f_warning(main.f_extractText(motif.warning_info.text_training), motif.title_info, motif.titlebgdef)
13411272 os.exit()
13421273 end
13431274
1344-if #main.t_includeStage == 0 then
1275+--print warning if no stages have been added
1276+if #main.t_includeStage[1] == 0 then
13451277 main.f_warning(main.f_extractText(motif.warning_info.text_stages), motif.title_info, motif.titlebgdef)
13461278 os.exit()
13471279 end
13481280
1349-local t = {'arcademaxmatches', 'teammaxmatches'}
1350-for i = 1, #t do
1351- local orderOK = false
1352- for j = 1, #main.t_selOptions[t[i]] do
1353- if main.t_selOptions[t[i]][j] > 0 and main.t_orderChars[j] ~= nil and #main.t_orderChars[j] > 0 then
1354- orderOK = true
1355- break
1281+--print warning if at least 1 match is not possible with the current maxmatches settings
1282+for k, v in pairs(main.t_selOptions) do
1283+ local mode = k:match('^(.+)maxmatches$')
1284+ if mode ~= nil then
1285+ local orderOK = false
1286+ for i = 1, #main.t_selOptions[k] do
1287+ if mode == 'survival' and (main.t_selOptions[k][i] > 0 or main.t_selOptions[k][i] == -1) and main.t_orderSurvival[i] ~= nil and #main.t_orderSurvival[i] > 0 then
1288+ orderOK = true
1289+ break
1290+ elseif main.t_selOptions[k][i] > 0 and main.t_orderChars[i] ~= nil and #main.t_orderChars[i] > 0 then
1291+ orderOK = true
1292+ break
1293+ end
1294+ end
1295+ if not orderOK then
1296+ main.f_warning(main.f_extractText(motif.warning_info.text_order), motif.title_info, motif.titlebgdef)
1297+ os.exit()
13561298 end
1357- end
1358- if not orderOK then
1359- main.f_warning(main.f_extractText(motif.warning_info.text_order), motif.title_info, motif.titlebgdef)
1360- os.exit()
13611299 end
13621300 end
13631301
@@ -1385,7 +1323,9 @@ local txt_titleFooter1 = main.f_createTextImg(
13851323 motif.title_info.footer1_font_scale[2],
13861324 motif.title_info.footer1_font[4],
13871325 motif.title_info.footer1_font[5],
1388- motif.title_info.footer1_font[6]
1326+ motif.title_info.footer1_font[6],
1327+ motif.title_info.footer1_font[7],
1328+ motif.title_info.footer1_font[8]
13891329 )
13901330 local txt_titleFooter2 = main.f_createTextImg(
13911331 motif.font_data[motif.title_info.footer2_font[1]],
@@ -1398,7 +1338,9 @@ local txt_titleFooter2 = main.f_createTextImg(
13981338 motif.title_info.footer2_font_scale[2],
13991339 motif.title_info.footer2_font[4],
14001340 motif.title_info.footer2_font[5],
1401- motif.title_info.footer2_font[6]
1341+ motif.title_info.footer2_font[6],
1342+ motif.title_info.footer2_font[7],
1343+ motif.title_info.footer2_font[8]
14021344 )
14031345 local txt_titleFooter3 = main.f_createTextImg(
14041346 motif.font_data[motif.title_info.footer3_font[1]],
@@ -1411,7 +1353,9 @@ local txt_titleFooter3 = main.f_createTextImg(
14111353 motif.title_info.footer3_font_scale[2],
14121354 motif.title_info.footer3_font[4],
14131355 motif.title_info.footer3_font[5],
1414- motif.title_info.footer3_font[6]
1356+ motif.title_info.footer3_font[6],
1357+ motif.title_info.footer3_font[7],
1358+ motif.title_info.footer3_font[8]
14151359 )
14161360 local txt_infoboxTitle = main.f_createTextImg(
14171361 motif.font_data[motif.infobox.title_font[1]],
@@ -1424,7 +1368,9 @@ local txt_infoboxTitle = main.f_createTextImg(
14241368 motif.infobox.title_font_scale[2],
14251369 motif.infobox.title_font[4],
14261370 motif.infobox.title_font[5],
1427- motif.infobox.title_font[6]
1371+ motif.infobox.title_font[6],
1372+ motif.infobox.title_font[7],
1373+ motif.infobox.title_font[8]
14281374 )
14291375
14301376 --Enable screenpack scale again.
@@ -1441,7 +1387,9 @@ main.txt_mainSelect = main.f_createTextImg(
14411387 motif.select_info.title_font_scale[2],
14421388 motif.select_info.title_font[4],
14431389 motif.select_info.title_font[5],
1444- motif.select_info.title_font[6]
1390+ motif.select_info.title_font[6],
1391+ motif.select_info.title_font[7],
1392+ motif.select_info.title_font[8]
14451393 )
14461394
14471395 --itemname: names used to distinguish modes in lua code (keep it as it is)
@@ -1450,6 +1398,8 @@ main.txt_mainSelect = main.f_createTextImg(
14501398 local t_mainMenu = {
14511399 {data = textImgNew(), itemname = 'arcade', displayname = motif.title_info.menu_itemname_arcade, selectname = motif.select_info.title_text_arcade},
14521400 {data = textImgNew(), itemname = 'versus', displayname = motif.title_info.menu_itemname_versus, selectname = motif.select_info.title_text_versus},
1401+ {data = textImgNew(), itemname = 'teamarcade', displayname = motif.title_info.menu_itemname_teamarcade, selectname = motif.select_info.title_text_teamarcade},
1402+ {data = textImgNew(), itemname = 'teamversus', displayname = motif.title_info.menu_itemname_teamversus, selectname = motif.select_info.title_text_teamversus},
14531403 {data = textImgNew(), itemname = 'online', displayname = motif.title_info.menu_itemname_online},
14541404 {data = textImgNew(), itemname = 'teamcoop', displayname = motif.title_info.menu_itemname_teamcoop, selectname = motif.select_info.title_text_teamcoop},
14551405 {data = textImgNew(), itemname = 'survival', displayname = motif.title_info.menu_itemname_survival, selectname = motif.select_info.title_text_survival},
@@ -1463,22 +1413,26 @@ local t_mainMenu = {
14631413 {data = textImgNew(), itemname = 'options', displayname = motif.title_info.menu_itemname_options},
14641414 {data = textImgNew(), itemname = 'exit', displayname = motif.title_info.menu_itemname_exit},
14651415 }
1466-t_mainMenu = main.f_cleanTable(t_mainMenu)
1416+t_mainMenu = main.f_cleanTable(t_mainMenu, main.t_sort.title_info)
14671417
1418+local demoFrameCounter = 0
1419+local introWaitCycles = 0
14681420 function main.f_default()
1421+ demoFrameCounter = 0
14691422 setAutoLevel(false) --generate autolevel.txt in game dir
14701423 setHomeTeam(2) --P2 side considered the home team: http://mugenguild.com/forum/topics/ishometeam-triggers-169132.0.html
1471- resetRemapInput()
14721424 --settings adjustable via options
14731425 setAutoguard(1, config.AutoGuard)
14741426 setAutoguard(2, config.AutoGuard)
14751427 setPowerShare(1, config.TeamPowerShare)
14761428 setPowerShare(2, config.TeamPowerShare)
14771429 setLifeShare(config.TeamLifeShare)
1478- setRoundTime(config.RoundTime * options.framespercount)
1430+ setRoundTime(math.max(-1, config.RoundTime * getFramesPerCount()))
1431+ setDemoTime(motif.demo_mode.fight_endtime / 60 * getFramesPerCount())
14791432 setLifeMul(config.LifeMul / 100)
14801433 setTeam1VS2Life(config.Team1VS2Life / 100)
1481- setTurnsRecoveryRate(1.0 / config.TurnsRecoveryRate)
1434+ setTurnsRecoveryRate(config.TurnsRecoveryBase / 100, config.TurnsRecoveryBonus / 100)
1435+ setGameMode('')
14821436 --default values for all modes
14831437 main.p1Char = nil --no predefined P1 character (assigned via table: {X, Y, (...)})
14841438 main.p2Char = nil --no predefined P2 character (assigned via table: {X, Y, (...)})
@@ -1490,18 +1444,86 @@ function main.f_default()
14901444 main.coop = false --P2 fighting on P1 side disabled
14911445 main.p2SelectMenu = true --P2 character selection enabled
14921446 main.versusScreen = true --versus screen enabled
1447+ main.f_resetCharparam()
14931448 main.p1In = 1 --P1 controls P1 side of the select screen
14941449 main.p2In = 2 --P2 controls P2 side of the select screen
1495- main.gameMode = '' --additional variable used to distinguish modes in select screen
1450+ resetRemapInput()
1451+end
1452+
1453+function main.f_resetCharparam()
1454+ main.t_charparam = { --default character parameters support
1455+ stage = false,
1456+ music = false,
1457+ zoom = false,
1458+ ai = false,
1459+ winscreen = true,
1460+ rounds = false,
1461+ time = false,
1462+ lifebar = true,
1463+ onlyme = false,
1464+ rivals = false,
1465+ }
1466+end
1467+
1468+function main.f_demo(cursorPosY, moveTxt, item, t, fadeType)
1469+ if motif.demo_mode.enabled == 0 then
1470+ return
1471+ end
1472+ demoFrameCounter = demoFrameCounter + 1
1473+ if demoFrameCounter < motif.demo_mode.title_waittime then
1474+ return
1475+ end
1476+ main.f_default()
1477+ main.f_menuFade('demo_mode', 'fadeout', cursorPosY, moveTxt, item, t)
1478+ clearColor(motif.titlebgdef.bgclearcolor[1], motif.titlebgdef.bgclearcolor[2], motif.titlebgdef.bgclearcolor[3])
1479+ if motif.demo_mode.fight_playbgm == 1 or motif.demo_mode.fight_stopbgm == 1 then
1480+ setStopTitleBGM(true)
1481+ else
1482+ setStopTitleBGM(false)
1483+ end
1484+ if motif.demo_mode.fight_bars_display == 1 then
1485+ setBarsDisplay(true)
1486+ else
1487+ setBarsDisplay(false)
1488+ end
1489+ if motif.demo_mode.debuginfo == 0 and config.AllowDebugKeys then
1490+ setAllowDebugKeys(false)
1491+ end
1492+ setGameMode('demo')
1493+ randomtest.run()
1494+ setBarsDisplay(true)
1495+ setStopTitleBGM(true)
1496+ setAllowDebugKeys(config.AllowDebugKeys)
1497+ refresh()
1498+ --intro
1499+ if introWaitCycles >= motif.demo_mode.intro_waitcycles then
1500+ if motif.files.intro_storyboard ~= '' then
1501+ storyboard.f_storyboard(motif.files.intro_storyboard)
1502+ end
1503+ introWaitCycles = 0
1504+ else
1505+ introWaitCycles = introWaitCycles + 1
1506+ end
1507+ --start title BGM only if it has been interrupted
1508+ if motif.demo_mode.fight_stopbgm == 1 or motif.demo_mode.fight_playbgm == 1 or (introWaitCycles == 0 and motif.files.intro_storyboard ~= '') then
1509+ main.f_menuReset(motif.titlebgdef.bg, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
1510+ else
1511+ main.f_menuReset(motif.titlebgdef.bg)
1512+ end
1513+ main.f_menuFade('demo_mode', 'fadein', cursorPosY, moveTxt, item, t)
14961514 end
14971515
1498-function main.f_menuCommon1(cursorPosY, moveTxt, item, t)
1516+function main.f_menuCommonCalc(cursorPosY, moveTxt, item, t)
14991517 if commandGetState(main.p1Cmd, 'u') or commandGetState(main.p2Cmd, 'u') then
15001518 sndPlay(motif.files.snd_data, motif.title_info.cursor_move_snd[1], motif.title_info.cursor_move_snd[2])
15011519 item = item - 1
1520+ demoFrameCounter = 0
1521+ introWaitCycles = 0
15021522 elseif commandGetState(main.p1Cmd, 'd') or commandGetState(main.p2Cmd, 'd') then
15031523 sndPlay(motif.files.snd_data, motif.title_info.cursor_move_snd[1], motif.title_info.cursor_move_snd[2])
15041524 item = item + 1
1525+ demoFrameCounter = 0
1526+ introWaitCycles = 0
15051527 end
15061528 --cursor position calculation
15071529 if item < 1 then
@@ -1514,9 +1536,9 @@ function main.f_menuCommon1(cursorPosY, moveTxt, item, t)
15141536 elseif item > #t then
15151537 item = 1
15161538 cursorPosY = 1
1517- elseif (commandGetState(main.p1Cmd, 'u') or commandGetState(main.p2Cmd, 'u') ) and cursorPosY > 1 then
1539+ elseif (commandGetState(main.p1Cmd, 'u') or commandGetState(main.p2Cmd, 'u')) and cursorPosY > 1 then
15181540 cursorPosY = cursorPosY - 1
1519- elseif (commandGetState(main.p1Cmd, 'd') or commandGetState(main.p2Cmd, 'd') ) and cursorPosY < motif.title_info.menu_window_visibleitems then
1541+ elseif (commandGetState(main.p1Cmd, 'd') or commandGetState(main.p2Cmd, 'd')) and cursorPosY < motif.title_info.menu_window_visibleitems then
15201542 cursorPosY = cursorPosY + 1
15211543 end
15221544 if cursorPosY == motif.title_info.menu_window_visibleitems then
@@ -1527,14 +1549,16 @@ function main.f_menuCommon1(cursorPosY, moveTxt, item, t)
15271549 return cursorPosY, moveTxt, item
15281550 end
15291551
1530-function main.f_menuCommon2(cursorPosY, moveTxt, item, t)
1552+function main.f_menuCommonDraw(cursorPosY, moveTxt, item, t, fadeType, fadeData)
1553+ fadeType = fadeType or 'fadein'
1554+ fadeData = fadeData or 'title_info'
15311555 --draw clearcolor
1532- animDraw(motif.titlebgdef.bgclearcolor_data)
1556+ clearColor(motif.titlebgdef.bgclearcolor[1], motif.titlebgdef.bgclearcolor[2], motif.titlebgdef.bgclearcolor[3])
15331557 --draw layerno = 0 backgrounds
1534- main.f_drawBG(motif.titlebgdef.bg_data, motif.titlebgdef.bg, 0, motif.titlebgdef.timer, {320,240})
1558+ bgDraw(motif.titlebgdef.bg, false)
15351559 --draw menu items
15361560 local items_shown = item + motif.title_info.menu_window_visibleitems - cursorPosY
1537- if motif.title_info.menu_window_margins_y[2] ~= 0 and items_shown < #t then
1561+ if motif.title_info.menu_window_visibleitems > 1 and motif.title_info.menu_window_margins_y[2] ~= 0 and items_shown < #t then
15381562 items_shown = items_shown + 1
15391563 end
15401564 if items_shown > #t then
@@ -1555,7 +1579,9 @@ function main.f_menuCommon2(cursorPosY, moveTxt, item, t)
15551579 motif.title_info.menu_item_active_font_scale[2],
15561580 motif.title_info.menu_item_active_font[4],
15571581 motif.title_info.menu_item_active_font[5],
1558- motif.title_info.menu_item_active_font[6]
1582+ motif.title_info.menu_item_active_font[6],
1583+ motif.title_info.menu_item_active_font[7],
1584+ motif.title_info.menu_item_active_font[8]
15591585 ))
15601586 else
15611587 textImgDraw(main.f_updateTextImg(
@@ -1570,48 +1596,103 @@ function main.f_menuCommon2(cursorPosY, moveTxt, item, t)
15701596 motif.title_info.menu_item_font_scale[2],
15711597 motif.title_info.menu_item_font[4],
15721598 motif.title_info.menu_item_font[5],
1573- motif.title_info.menu_item_font[6]
1599+ motif.title_info.menu_item_font[6],
1600+ motif.title_info.menu_item_font[7],
1601+ motif.title_info.menu_item_font[8]
15741602 ))
15751603 end
15761604 end
15771605 end
15781606 --draw menu cursor
1579- if motif.title_info.menu_boxcursor_visible == 1 then
1580- animSetWindow(
1581- main.cursorBox,
1607+ if motif.title_info.menu_boxcursor_visible == 1 and not main.fadeActive then
1608+ local src, dst = main.f_boxcursorAlpha(
1609+ motif.title_info.menu_boxcursor_alpharange[1],
1610+ motif.title_info.menu_boxcursor_alpharange[2],
1611+ motif.title_info.menu_boxcursor_alpharange[3],
1612+ motif.title_info.menu_boxcursor_alpharange[4],
1613+ motif.title_info.menu_boxcursor_alpharange[5],
1614+ motif.title_info.menu_boxcursor_alpharange[6]
1615+ )
1616+ fillRect(
15821617 motif.title_info.menu_pos[1] + motif.title_info.menu_boxcursor_coords[1],
15831618 motif.title_info.menu_pos[2] + motif.title_info.menu_boxcursor_coords[2] + (cursorPosY - 1) * motif.title_info.menu_item_spacing[2],
15841619 motif.title_info.menu_boxcursor_coords[3] - motif.title_info.menu_boxcursor_coords[1] + 1,
1585- motif.title_info.menu_boxcursor_coords[4] - motif.title_info.menu_boxcursor_coords[2] + 1
1620+ motif.title_info.menu_boxcursor_coords[4] - motif.title_info.menu_boxcursor_coords[2] + 1 + main.f_oddRounding(motif.title_info.menu_boxcursor_coords[2]),
1621+ motif.title_info.menu_boxcursor_col[1],
1622+ motif.title_info.menu_boxcursor_col[2],
1623+ motif.title_info.menu_boxcursor_col[3],
1624+ src,
1625+ dst
15861626 )
1587- main.f_dynamicAlpha(main.cursorBox, 10,40,2, 255,255,0)
1588- animDraw(main.cursorBox)
15891627 end
15901628 --draw layerno = 1 backgrounds
1591- main.f_drawBG(motif.titlebgdef.bg_data, motif.titlebgdef.bg, 1, motif.titlebgdef.timer, {320,240})
1629+ bgDraw(motif.titlebgdef.bg, true)
15921630 --footer draw
1593- if motif.title_info.footer_boxbackground_visible == 1 then
1594- animDraw(footerBox)
1631+ if motif.title_info.footer_boxbg_visible == 1 then
1632+ fillRect(
1633+ motif.title_info.footer_boxbg_coords[1],
1634+ motif.title_info.footer_boxbg_coords[2],
1635+ motif.title_info.footer_boxbg_coords[3] - motif.title_info.footer_boxbg_coords[1] + 1,
1636+ motif.title_info.footer_boxbg_coords[4] - motif.title_info.footer_boxbg_coords[2] + 1,
1637+ motif.title_info.footer_boxbg_col[1],
1638+ motif.title_info.footer_boxbg_col[2],
1639+ motif.title_info.footer_boxbg_col[3],
1640+ motif.title_info.footer_boxbg_alpha[1],
1641+ motif.title_info.footer_boxbg_alpha[2]
1642+ )
15951643 end
15961644 textImgDraw(txt_titleFooter1)
15971645 textImgDraw(txt_titleFooter2)
15981646 textImgDraw(txt_titleFooter3)
1599- --draw fadein
1600- animDraw(motif.title_info.fadein_data)
1601- animUpdate(motif.title_info.fadein_data)
1602- --update timer
1603- motif.titlebgdef.timer = motif.titlebgdef.timer + 1
1604- --end loop
1605- main.f_cmdInput()
1647+ --draw fadein / fadeout
1648+ main.fadeActive = fadeScreen(
1649+ fadeType,
1650+ main.fadeStart,
1651+ motif[fadeData][fadeType .. '_time'],
1652+ motif[fadeData][fadeType .. '_col'][1],
1653+ motif[fadeData][fadeType .. '_col'][2],
1654+ motif[fadeData][fadeType .. '_col'][3]
1655+ )
1656+ --frame transition
1657+ if main.fadeActive then
1658+ commandBufReset(main.p1Cmd)
1659+ elseif fadeType == 'fadeout' then
1660+ commandBufReset(main.p1Cmd)
1661+ return --skip last frame rendering
1662+ else
1663+ main.f_cmdInput()
1664+ end
16061665 refresh()
16071666 end
16081667
1609-function main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
1610- --[[for i = 1, motif.title_info.fadeout_time do
1611- main.f_menuCommon2(cursorPosY, moveTxt, item, t)
1612- animDraw(motif.title_info.fadeout_data)
1613- animUpdate(motif.title_info.fadeout_data)
1614- end]]
1668+main.fadeActive = false
1669+function main.f_menuFade(screen, fadeType, cursorPosY, moveTxt, item, t)
1670+ main.fadeStart = getFrameCount()
1671+ while true do
1672+ if screen == 'title_info' then
1673+ main.f_menuCommonDraw(cursorPosY, moveTxt, item, t, fadeType)
1674+ elseif screen == 'option_info' then
1675+ options.f_menuCommonDraw(cursorPosY, moveTxt, item, t, fadeType)
1676+ elseif screen == 'demo_mode' then
1677+ main.f_menuCommonDraw(cursorPosY, moveTxt, item, t, fadeType, 'demo_mode')
1678+ end
1679+ if not main.fadeActive then
1680+ break
1681+ end
1682+ end
1683+end
1684+
1685+function main.f_menuReset(bgNum, bgm, bgmLoop, bgmVolume, bgmLoopstart, bgmLoopend)
1686+ alpha1cur = 0
1687+ alpha2cur = 0
1688+ alpha1add = true
1689+ alpha2add = true
1690+ bgm = bgm or nil
1691+ bgReset(bgNum)
1692+ if bgm ~= nil then
1693+ playBGM(bgm, true, bgmLoop, bgmVolume, bgmLoopstart, bgmLoopend)
1694+ end
1695+ main.fadeStart = getFrameCount()
16151696 end
16161697
16171698 function main.f_mainMenu()
@@ -1626,37 +1707,64 @@ function main.f_mainMenu()
16261707 if motif.files.intro_storyboard ~= '' then
16271708 storyboard.f_storyboard(motif.files.intro_storyboard)
16281709 end
1629- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
1710+ main.f_menuReset(motif.titlebgdef.bg, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
16301711 while true do
1631- cursorPosY, moveTxt, item = main.f_menuCommon1(cursorPosY, moveTxt, item, t)
1712+ cursorPosY, moveTxt, item = main.f_menuCommonCalc(cursorPosY, moveTxt, item, t)
16321713 if esc() then
16331714 break
16341715 elseif getKey() == 'F1' then
16351716 main.SetDefaultScale()
1636- main.f_warning(main.f_extractText(motif.infobox.text), motif.title_info, motif.titlebgdef, motif.infobox, txt_infoboxTitle, main.infoBox)
1717+ main.f_warning(
1718+ main.f_extractText(motif.infobox.text),
1719+ motif.title_info,
1720+ motif.titlebgdef,
1721+ motif.infobox,
1722+ txt_infoboxTitle,
1723+ motif.infobox.boxbg_coords,
1724+ motif.infobox.boxbg_col,
1725+ motif.infobox.boxbg_alpha
1726+ )
16371727 main.SetScaleValues()
16381728 elseif main.f_btnPalNo(main.p1Cmd) > 0 then
16391729 main.f_default()
16401730 --ARCADE
1641- if t[item].itemname == 'arcade' then
1731+ if t[item].itemname == 'arcade' or t[item].itemname == 'teamarcade' then
16421732 sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
16431733 main.p2In = 1 --P1 controls P2 side of the select screen
16441734 main.p2SelectMenu = false --P2 character selection disabled
1735+ main.t_charparam.stage = true
1736+ main.t_charparam.music = true
1737+ main.t_charparam.zoom = true
1738+ main.t_charparam.ai = true
1739+ main.t_charparam.rounds = true
1740+ main.t_charparam.time = true
1741+ main.t_charparam.onlyme = true
1742+ main.t_charparam.rivals = true
16451743 main.credits = config.Credits - 1 --amount of continues
1646- main.gameMode = t[item].itemname --mode recognized in select screen as 'arcade'
16471744 textImgSetText(main.txt_mainSelect, t[item].selectname) --message displayed on top of select screen
1648- main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
1649- select.f_selectAdvance() --start f_selectAdvance() function from script/select.lua
1745+ if t[item].itemname == 'arcade' then
1746+ main.p1TeamMenu = {mode = 0, chars = 1} --predefined P1 team mode as Single, 1 Character
1747+ main.p2TeamMenu = {mode = 0, chars = 1} --predefined P2 team mode as Single, 1 Character
1748+ end
1749+ main.f_menuFade('title_info', 'fadeout', cursorPosY, moveTxt, item, t)
1750+ setGameMode('arcade')
1751+ select.f_selectArcade() --start f_selectArcade() function from script/select.lua
16501752 end
16511753 --VS MODE
1652- if t[item].itemname == 'versus' then
1754+ if t[item].itemname == 'versus' or t[item].itemname == 'teamversus' then
16531755 sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
16541756 setHomeTeam(1) --P1 side considered the home team
16551757 main.p2In = 2 --P2 controls P2 side of the select screen
16561758 main.stageMenu = true --stage selection enabled
16571759 main.p2Faces = true --additional window with P2 select screen small portraits (faces) enabled
1760+ --uses default main.t_charparam assignment
16581761 textImgSetText(main.txt_mainSelect, t[item].selectname)
1659- main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
1762+ if t[item].itemname == 'versus' then
1763+ main.p1TeamMenu = {mode = 0, chars = 1} --predefined P1 team mode as Single, 1 Character
1764+ main.p2TeamMenu = {mode = 0, chars = 1} --predefined P2 team mode as Single, 1 Character
1765+ end
1766+ main.f_menuFade('title_info', 'fadeout', cursorPosY, moveTxt, item, t)
1767+ setGameMode('versus')
16601768 select.f_selectSimple() --start f_selectSimple() function from script/select.lua
16611769 end
16621770 --ONLINE
@@ -1670,22 +1778,35 @@ function main.f_mainMenu()
16701778 main.p2In = 2
16711779 main.p2Faces = true
16721780 main.coop = true --P2 fighting on P1 side enabled
1781+ main.t_charparam.stage = true
1782+ main.t_charparam.music = true
1783+ main.t_charparam.zoom = true
1784+ main.t_charparam.ai = true
1785+ main.t_charparam.rounds = true
1786+ main.t_charparam.time = true
1787+ main.t_charparam.onlyme = true
1788+ main.t_charparam.rivals = true
16731789 main.credits = config.Credits - 1
1674- main.gameMode = t[item].itemname
16751790 textImgSetText(main.txt_mainSelect, t[item].selectname)
1676- main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
1677- select.f_selectAdvance()
1791+ main.f_menuFade('title_info', 'fadeout', cursorPosY, moveTxt, item, t)
1792+ setGameMode('teamcoop')
1793+ select.f_selectArcade()
16781794 end
16791795 --SURVIVAL
16801796 if t[item].itemname == 'survival' then
16811797 sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
16821798 main.p2In = 1
16831799 main.p2SelectMenu = false
1684- main.credits = 0
1685- main.gameMode = t[item].itemname
1800+ main.t_charparam.stage = true
1801+ main.t_charparam.music = true
1802+ main.t_charparam.zoom = true
1803+ main.t_charparam.ai = true
1804+ main.t_charparam.time = true
1805+ main.t_charparam.onlyme = true
16861806 textImgSetText(main.txt_mainSelect, t[item].selectname)
1687- main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
1688- select.f_selectAdvance()
1807+ main.f_menuFade('title_info', 'fadeout', cursorPosY, moveTxt, item, t)
1808+ setGameMode('survival')
1809+ select.f_selectArranged()
16891810 end
16901811 --SURVIVAL CO-OP
16911812 if t[item].itemname == 'survivalcoop' then
@@ -1693,11 +1814,16 @@ function main.f_mainMenu()
16931814 main.p2In = 2
16941815 main.p2Faces = true
16951816 main.coop = true
1696- main.credits = 0
1697- main.gameMode = t[item].itemname
1817+ main.t_charparam.stage = true
1818+ main.t_charparam.music = true
1819+ main.t_charparam.zoom = true
1820+ main.t_charparam.ai = true
1821+ main.t_charparam.time = true
1822+ main.t_charparam.onlyme = true
16981823 textImgSetText(main.txt_mainSelect, t[item].selectname)
1699- main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
1700- select.f_selectAdvance()
1824+ main.f_menuFade('title_info', 'fadeout', cursorPosY, moveTxt, item, t)
1825+ setGameMode('survivalcoop')
1826+ select.f_selectArranged()
17011827 end
17021828 --TOURNAMENT
17031829 if t[item].itemname == 'tournament' then
@@ -1707,15 +1833,15 @@ function main.f_mainMenu()
17071833 --TRAINING
17081834 if t[item].itemname == 'training' then
17091835 sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
1710- setRoundTime(-1) --round time disabled
17111836 main.p2In = 2
17121837 main.stageMenu = true
17131838 main.versusScreen = false --versus screen disabled
1839+ --uses default main.t_charparam assignment
17141840 main.p2TeamMenu = {mode = 0, chars = 1} --predefined P2 team mode as Single, 1 Character
17151841 main.p2Char = {main.t_charDef.training} --predefined P2 character as Training by stupa
1716- main.gameMode = t[item].itemname
17171842 textImgSetText(main.txt_mainSelect, t[item].selectname)
1718- main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
1843+ main.f_menuFade('title_info', 'fadeout', cursorPosY, moveTxt, item, t)
1844+ setGameMode('training')
17191845 select.f_selectSimple()
17201846 end
17211847 --WATCH
@@ -1725,8 +1851,10 @@ function main.f_mainMenu()
17251851 main.aiFight = true --AI = config.Difficulty for all characters enabled
17261852 main.stageMenu = true
17271853 main.p2Faces = true
1854+ --uses default main.t_charparam assignment
17281855 textImgSetText(main.txt_mainSelect, t[item].selectname)
1729- main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
1856+ main.f_menuFade('title_info', 'fadeout', cursorPosY, moveTxt, item, t)
1857+ setGameMode('watch')
17301858 select.f_selectSimple()
17311859 end
17321860 --EXTRAS
@@ -1737,7 +1865,7 @@ function main.f_mainMenu()
17371865 --OPTIONS
17381866 if t[item].itemname == 'options' then
17391867 sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
1740- main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
1868+ main.f_menuFade('title_info', 'fadeout', cursorPosY, moveTxt, item, t)
17411869 --Disable screenpack scale on the menu text for showing the menu corectly.
17421870 main.SetDefaultScale()
17431871 options.f_mainCfg() --start f_mainCfg() function from script/options.lua
@@ -1749,7 +1877,8 @@ function main.f_mainMenu()
17491877 break
17501878 end
17511879 end
1752- main.f_menuCommon2(cursorPosY, moveTxt, item, t)
1880+ main.f_menuCommonDraw(cursorPosY, moveTxt, item, t)
1881+ main.f_demo(cursorPosY, moveTxt, item, t)
17531882 end
17541883 end
17551884
@@ -1767,7 +1896,9 @@ local txt_connection = main.f_createTextImg(
17671896 motif.title_info.connecting_font_scale[2],
17681897 motif.title_info.connecting_font[4],
17691898 motif.title_info.connecting_font[5],
1770- motif.title_info.connecting_font[6]
1899+ motif.title_info.connecting_font[6],
1900+ motif.title_info.connecting_font[7],
1901+ motif.title_info.connecting_font[8]
17711902 )
17721903 function main.f_connect(server, t)
17731904 local cancel = false
@@ -1779,20 +1910,28 @@ function main.f_connect(server, t)
17791910 break
17801911 end
17811912 --draw clearcolor
1782- animDraw(motif.titlebgdef.bgclearcolor_data)
1913+ clearColor(motif.titlebgdef.bgclearcolor[1], motif.titlebgdef.bgclearcolor[2], motif.titlebgdef.bgclearcolor[3])
17831914 --draw layerno = 0 backgrounds
1784- main.f_drawBG(motif.titlebgdef.bg_data, motif.titlebgdef.bg, 0, motif.titlebgdef.timer, {320,240})
1915+ bgDraw(motif.titlebgdef.bg, false)
17851916 --draw layerno = 1 backgrounds
1786- main.f_drawBG(motif.titlebgdef.bg_data, motif.titlebgdef.bg, 1, motif.titlebgdef.timer, {320,240})
1917+ bgDraw(motif.titlebgdef.bg, true)
17871918 --draw menu box
1788- animDraw(main.warningBox)
1919+ fillRect(
1920+ motif.title_info.connecting_boxbg_coords[1],
1921+ motif.title_info.connecting_boxbg_coords[2],
1922+ motif.title_info.connecting_boxbg_coords[3] - motif.title_info.connecting_boxbg_coords[1] + 1,
1923+ motif.title_info.connecting_boxbg_coords[4] - motif.title_info.connecting_boxbg_coords[2] + 1,
1924+ motif.title_info.connecting_boxbg_col[1],
1925+ motif.title_info.connecting_boxbg_col[2],
1926+ motif.title_info.connecting_boxbg_col[3],
1927+ motif.title_info.connecting_boxbg_alpha[1],
1928+ motif.title_info.connecting_boxbg_alpha[2]
1929+ )
17891930 --draw text
17901931 for i = 1, #t do
17911932 textImgSetText(txt_connection, t[i])
17921933 textImgDraw(txt_connection)
17931934 end
1794- --update timer
1795- motif.titlebgdef.timer = motif.titlebgdef.timer + 1
17961935 --end loop
17971936 refresh()
17981937 end
@@ -1809,7 +1948,7 @@ local t_mainNetplay = {
18091948 {data = textImgNew(), itemname = 'serverjoin', displayname = motif.title_info.menu_itemname_serverjoin},
18101949 {data = textImgNew(), itemname = 'serverback', displayname = motif.title_info.menu_itemname_serverback},
18111950 }
1812-t_mainNetplay = main.f_cleanTable(t_mainNetplay)
1951+t_mainNetplay = main.f_cleanTable(t_mainNetplay, main.t_sort.title_info)
18131952
18141953 function main.f_mainNetplay()
18151954 main.f_cmdInput()
@@ -1818,7 +1957,7 @@ function main.f_mainNetplay()
18181957 local item = 1
18191958 local t = t_mainNetplay
18201959 while true do
1821- cursorPosY, moveTxt, item = main.f_menuCommon1(cursorPosY, moveTxt, item, t)
1960+ cursorPosY, moveTxt, item = main.f_menuCommonCalc(cursorPosY, moveTxt, item, t)
18221961 if esc() then
18231962 sndPlay(motif.files.snd_data, motif.title_info.cancel_snd[1], motif.title_info.cancel_snd[2])
18241963 break
@@ -1827,19 +1966,16 @@ function main.f_mainNetplay()
18271966 --HOST
18281967 if t[item].itemname == 'serverhost' then
18291968 sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
1830- main.f_connect("", main.f_extractText(motif.title_info.connecting_host, getListenPort()))
1969+ main.f_connect("", main.f_extractText(motif.title_info.connecting_host_text, getListenPort()))
18311970 exitNetPlay()
18321971 exitReplay()
1833-
1834- -- Save replay with a new name
1835- tpmFileRpl1 = io.open("save/replays/netplay.replay","r")
1836- tpmFileRpl1C = tpmFileRpl1:read("*all")
1837- io.close(tpmFileRpl1)
1838-
1839- tpmFileRpl2name = os.date("%Y-%m(%b)-%d %I-%M%p-%Ss")
1840- tpmFileRpl2 = io.open("save/replays/" .. tpmFileRpl2name .. ".replay","w+")
1841- tpmFileRpl2:write(tpmFileRpl1C)
1842- io.close(tpmFileRpl2)
1972+ --save replay with a new name
1973+ local file = io.open("save/replays/netplay.replay", "r")
1974+ local tpmFile = file:read("*all")
1975+ io.close(file)
1976+ file = io.open("save/replays/" .. os.date("%Y-%m(%b)-%d %I-%M%p-%Ss") .. ".replay", "w+")
1977+ file:write(tpmFile)
1978+ io.close(file)
18431979 end
18441980 --JOIN
18451981 if t[item].itemname == 'serverjoin' then
@@ -1852,7 +1988,7 @@ function main.f_mainNetplay()
18521988 break
18531989 end
18541990 end
1855- main.f_menuCommon2(cursorPosY, moveTxt, item, t)
1991+ main.f_menuCommonDraw(cursorPosY, moveTxt, item, t)
18561992 end
18571993 end
18581994
@@ -1860,16 +1996,11 @@ end
18601996 --; NETPLAY JOIN
18611997 --;===========================================================
18621998 local t_netplayJoin = {}
1863-t_netplayJoin[#t_netplayJoin + 1] = {data = textImgNew(), itemname = 'joinadd', displayname = motif.title_info.menu_itemname_joinadd}
1999+table.insert(t_netplayJoin, {data = textImgNew(), itemname = 'joinadd', displayname = motif.title_info.menu_itemname_joinadd})
18642000 for k, v in pairs(config.IP) do
1865- t_netplayJoin[#t_netplayJoin + 1] = {
1866- data = textImgNew(),
1867- itemname = k,
1868- displayname = k,
1869- address = v
1870- }
2001+ table.insert(t_netplayJoin, {data = textImgNew(), itemname = k, displayname = k, address = v})
18712002 end
1872-t_netplayJoin[#t_netplayJoin + 1] = {data = textImgNew(), itemname = 'joinback', displayname = motif.title_info.menu_itemname_joinback}
2003+table.insert(t_netplayJoin, {data = textImgNew(), itemname = 'joinback', displayname = motif.title_info.menu_itemname_joinback})
18732004
18742005 function main.f_netplayJoin()
18752006 main.f_cmdInput()
@@ -1879,7 +2010,7 @@ function main.f_netplayJoin()
18792010 local t = t_netplayJoin
18802011 local t_tmp = {}
18812012 while true do
1882- cursorPosY, moveTxt, item = main.f_menuCommon1(cursorPosY, moveTxt, item, t)
2013+ cursorPosY, moveTxt, item = main.f_menuCommonCalc(cursorPosY, moveTxt, item, t)
18832014 if esc() then
18842015 sndPlay(motif.files.snd_data, motif.title_info.cancel_snd[1], motif.title_info.cancel_snd[2])
18852016 break
@@ -1891,7 +2022,7 @@ function main.f_netplayJoin()
18912022 t_tmp = {}
18922023 for i = 1, #t do
18932024 if i ~= item then
1894- t_tmp[#t_tmp + 1] = t[i]
2025+ table.insert(t_tmp, t[i])
18952026 end
18962027 end
18972028 t_netplayJoin = t_tmp
@@ -1904,10 +2035,10 @@ function main.f_netplayJoin()
19042035 --NEW ADDRESS
19052036 if t[item].itemname == 'joinadd' then
19062037 sndPlay(motif.files.snd_data, motif.title_info.cursor_move_snd[1], motif.title_info.cursor_move_snd[2])
1907- local name = main.f_input(main.f_extractText(motif.title_info.input_ip_name), motif.title_info, motif.titlebgdef, 'string')
2038+ local name = main.f_input(main.f_extractText(motif.title_info.input_ip_name_text), motif.title_info, motif.titlebgdef, 'string')
19082039 if name ~= '' then
19092040 sndPlay(motif.files.snd_data, motif.title_info.cursor_move_snd[1], motif.title_info.cursor_move_snd[2])
1910- local address = main.f_input(main.f_extractText(motif.title_info.input_ip_address), motif.title_info, motif.titlebgdef, 'string')
2041+ local address = main.f_input(main.f_extractText(motif.title_info.input_ip_address_text), motif.title_info, motif.titlebgdef, 'string')
19112042 if address:match('^[0-9%.]+$') then
19122043 sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
19132044 config.IP[name] = address
@@ -1938,12 +2069,12 @@ function main.f_netplayJoin()
19382069 --CONNECTION
19392070 else
19402071 sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
1941- main.f_connect(t[item].address, main.f_extractText(motif.title_info.connecting_join, t[item].name, t[item].address))
2072+ main.f_connect(t[item].address, main.f_extractText(motif.title_info.connecting_join_text, t[item].name, t[item].address))
19422073 exitNetPlay()
19432074 exitReplay()
19442075 end
19452076 end
1946- main.f_menuCommon2(cursorPosY, moveTxt, item, t)
2077+ main.f_menuCommonDraw(cursorPosY, moveTxt, item, t)
19472078 end
19482079 end
19492080
@@ -1956,7 +2087,7 @@ local t_netplayMode = {
19562087 {data = textImgNew(), itemname = 'netplaysurvivalcoop', displayname = motif.title_info.menu_itemname_netplaysurvivalcoop, selectname = motif.select_info.title_text_netplaysurvivalcoop},
19572088 {data = textImgNew(), itemname = 'netplayback', displayname = motif.title_info.menu_itemname_netplayback},
19582089 }
1959-t_netplayMode = main.f_cleanTable(t_netplayMode)
2090+t_netplayMode = main.f_cleanTable(t_netplayMode, main.t_sort.title_info)
19602091
19612092 function main.f_netplayMode()
19622093 main.f_cmdInput()
@@ -1965,7 +2096,7 @@ function main.f_netplayMode()
19652096 local item = 1
19662097 local t = t_netplayMode
19672098 while true do
1968- cursorPosY, moveTxt, item = main.f_menuCommon1(cursorPosY, moveTxt, item, t)
2099+ cursorPosY, moveTxt, item = main.f_menuCommonCalc(cursorPosY, moveTxt, item, t)
19692100 if esc() then
19702101 sndPlay(motif.files.snd_data, motif.title_info.cancel_snd[1], motif.title_info.cancel_snd[2])
19712102 break
@@ -1978,7 +2109,9 @@ function main.f_netplayMode()
19782109 main.p2In = 2
19792110 main.stageMenu = true
19802111 main.p2Faces = true
2112+ --uses default main.t_charparam assignment
19812113 textImgSetText(main.txt_mainSelect, t[item].selectname)
2114+ setGameMode('netplayversus')
19822115 select.f_selectSimple()
19832116 end
19842117 --TEAM CO-OP
@@ -1987,10 +2120,18 @@ function main.f_netplayMode()
19872120 main.p2In = 2
19882121 main.p2Faces = true
19892122 main.coop = true
2123+ main.t_charparam.stage = true
2124+ main.t_charparam.music = true
2125+ main.t_charparam.zoom = true
2126+ main.t_charparam.ai = true
2127+ main.t_charparam.rounds = true
2128+ main.t_charparam.time = true
2129+ main.t_charparam.onlyme = true
2130+ main.t_charparam.rivals = true
19902131 main.credits = config.Credits - 1
1991- main.gameMode = t[item].itemname
19922132 textImgSetText(main.txt_mainSelect, t[item].selectname)
1993- select.f_selectAdvance()
2133+ setGameMode('netplayteamcoop')
2134+ select.f_selectArcade()
19942135 end
19952136 --SURVIVAL CO-OP
19962137 if t[item].itemname == 'netplaysurvivalcoop' then
@@ -1998,10 +2139,15 @@ function main.f_netplayMode()
19982139 main.p2In = 2
19992140 main.p2Faces = true
20002141 main.coop = true
2001- main.credits = 0
2002- main.gameMode = t[item].itemname
2142+ main.t_charparam.stage = true
2143+ main.t_charparam.music = true
2144+ main.t_charparam.zoom = true
2145+ main.t_charparam.ai = true
2146+ main.t_charparam.time = true
2147+ main.t_charparam.onlyme = true
20032148 textImgSetText(main.txt_mainSelect, t[item].selectname)
2004- select.f_selectAdvance()
2149+ setGameMode('netplaysurvivalcoop')
2150+ select.f_selectArranged()
20052151 end
20062152 --BACK
20072153 if t[item].itemname == 'netplayback' then
@@ -2009,7 +2155,7 @@ function main.f_netplayMode()
20092155 break
20102156 end
20112157 end
2012- main.f_menuCommon2(cursorPosY, moveTxt, item, t)
2158+ main.f_menuCommonDraw(cursorPosY, moveTxt, item, t)
20132159 end
20142160 end
20152161
@@ -2025,7 +2171,7 @@ local t_mainExtras = {
20252171 {data = textImgNew(), itemname = 'bonusgames', displayname = motif.title_info.menu_itemname_bonusgames},
20262172 --{data = textImgNew(), itemname = 'scoreranking', displayname = motif.title_info.menu_itemname_scoreranking},
20272173 {data = textImgNew(), itemname = 'replay', displayname = motif.title_info.menu_itemname_replay, selectname = motif.select_info.title_text_replay},
2028- {data = textImgNew(), itemname = 'demo', displayname = motif.title_info.menu_itemname_demo},
2174+ {data = textImgNew(), itemname = 'randomtest', displayname = motif.title_info.menu_itemname_randomtest},
20292175 {data = textImgNew(), itemname = 'extrasback', displayname = motif.title_info.menu_itemname_extrasback},
20302176 }
20312177 for i = 1, #t_mainExtras do
@@ -2033,11 +2179,11 @@ for i = 1, #t_mainExtras do
20332179 t_mainExtras[i].displayname = ''
20342180 elseif t_mainExtras[i].itemname == 'bonusgames' and #main.t_bonusChars == 0 then
20352181 t_mainExtras[i].displayname = ''
2036- elseif t_mainExtras[i].itemname == 'demo' and #main.t_randomChars < 2 then
2182+ elseif t_mainExtras[i].itemname == 'randomtest' and #main.t_randomChars < 2 then
20372183 t_mainExtras[i].displayname = ''
20382184 end
20392185 end
2040-t_mainExtras = main.f_cleanTable(t_mainExtras)
2186+t_mainExtras = main.f_cleanTable(t_mainExtras, main.t_sort.title_info)
20412187
20422188 function main.f_mainExtras()
20432189 main.f_cmdInput()
@@ -2046,7 +2192,7 @@ function main.f_mainExtras()
20462192 local item = 1
20472193 local t = t_mainExtras
20482194 while true do
2049- cursorPosY, moveTxt, item = main.f_menuCommon1(cursorPosY, moveTxt, item, t)
2195+ cursorPosY, moveTxt, item = main.f_menuCommonCalc(cursorPosY, moveTxt, item, t)
20502196 if esc() then
20512197 sndPlay(motif.files.snd_data, motif.title_info.cancel_snd[1], motif.title_info.cancel_snd[2])
20522198 break
@@ -2058,8 +2204,10 @@ function main.f_mainExtras()
20582204 main.p2In = 1
20592205 main.stageMenu = true
20602206 main.p2Faces = true
2207+ --uses default main.t_charparam assignment
20612208 textImgSetText(main.txt_mainSelect, t[item].selectname)
2062- main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
2209+ main.f_menuFade('title_info', 'fadeout', cursorPosY, moveTxt, item, t)
2210+ setGameMode('freebattle')
20632211 select.f_selectSimple()
20642212 end
20652213 --VS 100 KUMITE
@@ -2067,21 +2215,32 @@ function main.f_mainExtras()
20672215 sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
20682216 main.p2In = 1
20692217 main.p2SelectMenu = false
2070- main.gameMode = t[item].itemname
2218+ main.t_charparam.stage = true
2219+ main.t_charparam.music = true
2220+ main.t_charparam.zoom = true
2221+ main.t_charparam.ai = true
2222+ main.t_charparam.time = true
2223+ main.t_charparam.onlyme = true
20712224 textImgSetText(main.txt_mainSelect, t[item].selectname)
2072- main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
2073- select.f_selectAdvance()
2225+ main.f_menuFade('title_info', 'fadeout', cursorPosY, moveTxt, item, t)
2226+ setGameMode('100kumite')
2227+ select.f_selectArranged()
20742228 end
20752229 --BOSS RUSH
20762230 if t[item].itemname == 'bossrush' then
20772231 sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
20782232 main.p2In = 1
20792233 main.p2SelectMenu = false
2080- main.credits = 0
2081- main.gameMode = t[item].itemname
2234+ main.t_charparam.stage = true
2235+ main.t_charparam.music = true
2236+ main.t_charparam.zoom = true
2237+ main.t_charparam.ai = true
2238+ main.t_charparam.time = true
2239+ main.t_charparam.onlyme = true
20822240 textImgSetText(main.txt_mainSelect, t[item].selectname)
2083- main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
2084- select.f_selectAdvance()
2241+ main.f_menuFade('title_info', 'fadeout', cursorPosY, moveTxt, item, t)
2242+ setGameMode('bossrush')
2243+ select.f_selectArranged()
20852244 end
20862245 --BONUS GAMES
20872246 if t[item].itemname == 'bonusgames' then
@@ -2101,10 +2260,13 @@ function main.f_mainExtras()
21012260 end
21022261 end
21032262 --DEMO
2104- if t[item].itemname == 'demo' then
2263+ if t[item].itemname == 'randomtest' then
21052264 sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
2106- main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
2265+ main.f_menuFade('title_info', 'fadeout', cursorPosY, moveTxt, item, t)
2266+ clearColor(motif.titlebgdef.bgclearcolor[1], motif.titlebgdef.bgclearcolor[2], motif.titlebgdef.bgclearcolor[3])
2267+ setGameMode('randomtest')
21072268 randomtest.run()
2269+ main.f_menuReset(motif.titlebgdef.bg, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
21082270 end
21092271 --BACK
21102272 if t[item].itemname == 'extrasback' then
@@ -2112,7 +2274,7 @@ function main.f_mainExtras()
21122274 break
21132275 end
21142276 end
2115- main.f_menuCommon2(cursorPosY, moveTxt, item, t)
2277+ main.f_menuCommonDraw(cursorPosY, moveTxt, item, t)
21162278 end
21172279 end
21182280
@@ -2130,7 +2292,7 @@ for i = 1, #main.t_bonusChars do
21302292 }
21312293 end
21322294 if motif.title_info.menu_itemname_bonusback ~= '' then
2133- t_bonusExtras[#t_bonusExtras + 1] = {data = textImgNew(), itemname = 'bonusback', displayname = motif.title_info.menu_itemname_bonusback}
2295+ table.insert(t_bonusExtras, {data = textImgNew(), itemname = 'bonusback', displayname = motif.title_info.menu_itemname_bonusback})
21342296 end
21352297
21362298 function main.f_bonusExtras()
@@ -2140,7 +2302,7 @@ function main.f_bonusExtras()
21402302 local item = 1
21412303 local t = t_bonusExtras
21422304 while true do
2143- cursorPosY, moveTxt, item = main.f_menuCommon1(cursorPosY, moveTxt, item, t)
2305+ cursorPosY, moveTxt, item = main.f_menuCommonCalc(cursorPosY, moveTxt, item, t)
21442306 if esc() then
21452307 sndPlay(motif.files.snd_data, motif.title_info.cancel_snd[1], motif.title_info.cancel_snd[2])
21462308 break
@@ -2153,17 +2315,25 @@ function main.f_bonusExtras()
21532315 --BONUS CHAR NAME
21542316 else
21552317 sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
2156- main.versusScreen = false
21572318 main.p2In = 1
2319+ main.versusScreen = false
2320+ main.t_charparam.stage = true
2321+ main.t_charparam.music = true
2322+ main.t_charparam.zoom = true
2323+ main.t_charparam.ai = true
2324+ main.t_charparam.rounds = true
2325+ main.t_charparam.time = true
2326+ main.t_charparam.onlyme = true
21582327 main.p1TeamMenu = {mode = 0, chars = 1}
21592328 main.p2TeamMenu = {mode = 0, chars = 1}
21602329 main.p2Char = {main.t_bonusChars[item]}
21612330 textImgSetText(main.txt_mainSelect, t[item].selectname)
2162- main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
2331+ main.f_menuFade('title_info', 'fadeout', cursorPosY, moveTxt, item, t)
2332+ setGameMode('bonus')
21632333 select.f_selectSimple()
21642334 end
21652335 end
2166- main.f_menuCommon2(cursorPosY, moveTxt, item, t)
2336+ main.f_menuCommonDraw(cursorPosY, moveTxt, item, t)
21672337 end
21682338 end
21692339
@@ -2177,7 +2347,7 @@ local t_mainTournament = {
21772347 {data = textImgNew(), itemname = 'tourney4', displayname = motif.title_info.menu_itemname_tourney4, selectname = motif.select_info.title_text_tourney4},
21782348 {data = textImgNew(), itemname = 'tourneyback', displayname = motif.title_info.menu_itemname_tourneyback},
21792349 }
2180-t_mainTournament = main.f_cleanTable(t_mainTournament)
2350+t_mainTournament = main.f_cleanTable(t_mainTournament, main.t_sort.title_info)
21812351
21822352 function main.f_mainTournament()
21832353 main.f_cmdInput()
@@ -2186,7 +2356,7 @@ function main.f_mainTournament()
21862356 local item = 1
21872357 local t = t_mainTournament
21882358 while true do
2189- cursorPosY, moveTxt, item = main.f_menuCommon1(cursorPosY, moveTxt, item, t)
2359+ cursorPosY, moveTxt, item = main.f_menuCommonCalc(cursorPosY, moveTxt, item, t)
21902360 if esc() then
21912361 sndPlay(motif.files.snd_data, motif.title_info.cancel_snd[1], motif.title_info.cancel_snd[2])
21922362 break
@@ -2195,34 +2365,62 @@ function main.f_mainTournament()
21952365 --ROUND OF 32
21962366 if t[item].itemname == 'tourney32' then
21972367 sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
2198- main.gameMode = t[item].itemname
2368+ main.t_charparam.stage = true
2369+ main.t_charparam.music = true
2370+ main.t_charparam.zoom = true
2371+ main.t_charparam.ai = true
2372+ main.t_charparam.rounds = true
2373+ main.t_charparam.time = true
2374+ main.t_charparam.onlyme = true
21992375 textImgSetText(main.txt_mainSelect, t[item].selectname)
2200- main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
2201- select.f_selectTournament()
2376+ main.f_menuFade('title_info', 'fadeout', cursorPosY, moveTxt, item, t)
2377+ setGameMode('tournament')
2378+ select.f_selectTournament(32)
22022379 end
22032380 --ROUND OF 16
22042381 if t[item].itemname == 'tourney16' then
22052382 sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
2206- main.gameMode = t[item].itemname
2383+ main.t_charparam.stage = true
2384+ main.t_charparam.music = true
2385+ main.t_charparam.zoom = true
2386+ main.t_charparam.ai = true
2387+ main.t_charparam.rounds = true
2388+ main.t_charparam.time = true
2389+ main.t_charparam.onlyme = true
22072390 textImgSetText(main.txt_mainSelect, t[item].selectname)
2208- main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
2209- select.f_selectTournament()
2391+ main.f_menuFade('title_info', 'fadeout', cursorPosY, moveTxt, item, t)
2392+ setGameMode('tournament')
2393+ select.f_selectTournament(16)
22102394 end
22112395 --QUARTERFINALS
22122396 if t[item].itemname == 'tourney8' then
22132397 sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
2214- main.gameMode = t[item].itemname
2398+ main.t_charparam.stage = true
2399+ main.t_charparam.music = true
2400+ main.t_charparam.zoom = true
2401+ main.t_charparam.ai = true
2402+ main.t_charparam.rounds = true
2403+ main.t_charparam.time = true
2404+ main.t_charparam.onlyme = true
22152405 textImgSetText(main.txt_mainSelect, t[item].selectname)
2216- main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
2217- select.f_selectTournament()
2406+ main.f_menuFade('title_info', 'fadeout', cursorPosY, moveTxt, item, t)
2407+ setGameMode('tournament')
2408+ select.f_selectTournament(8)
22182409 end
22192410 --SEMIFINALS
22202411 if t[item].itemname == 'tourney4' then
22212412 sndPlay(motif.files.snd_data, motif.title_info.cursor_done_snd[1], motif.title_info.cursor_done_snd[2])
2222- main.gameMode = t[item].itemname
2413+ main.t_charparam.stage = true
2414+ main.t_charparam.music = true
2415+ main.t_charparam.zoom = true
2416+ main.t_charparam.ai = true
2417+ main.t_charparam.rounds = true
2418+ main.t_charparam.time = true
2419+ main.t_charparam.onlyme = true
22232420 textImgSetText(main.txt_mainSelect, t[item].selectname)
2224- main.f_menuFadeOut(cursorPosY, moveTxt, item, t)
2225- select.f_selectTournament()
2421+ main.f_menuFade('title_info', 'fadeout', cursorPosY, moveTxt, item, t)
2422+ setGameMode('tournament')
2423+ select.f_selectTournament(4)
22262424 end
22272425 --BACK
22282426 if t[item].itemname == 'tourneyback' then
@@ -2230,20 +2428,17 @@ function main.f_mainTournament()
22302428 break
22312429 end
22322430 end
2233- main.f_menuCommon2(cursorPosY, moveTxt, item, t)
2431+ main.f_menuCommonDraw(cursorPosY, moveTxt, item, t)
22342432 end
22352433 end
22362434
22372435 --;===========================================================
22382436 --; INITIALIZE LOOPS
22392437 --;===========================================================
2240-
22412438 -- Now that everithig is loaded we can enable GC back.
22422439 SetGCPercent(100)
2243--------------------------------------------------------------
22442440
22452441 main.f_mainMenu()
22462442
2247-
22482443 -- Debug Info
2249-main.f_printTable(main, "debug/t_main.txt")
2444+--main.f_printTable(main, "debug/t_main.txt")
--- a/script/motif.lua
+++ b/script/motif.lua
@@ -1,10 +1,50 @@
11 --;===========================================================
2+--; LOCALCOORD VALUES
3+--;===========================================================
4+
5+local def = config.Motif
6+if main.flags['-r'] ~= nil then
7+ local case = main.flags['-r']:lower()
8+ if case:match('^data[/\\]') and main.f_fileExists(main.flags['-r']) then
9+ def = main.flags['-r']
10+ elseif case:match('%.def$') and main.f_fileExists('data/' .. main.flags['-r']) then
11+ def = 'data/' .. main.flags['-r']
12+ elseif main.f_fileExists('data/' .. main.flags['-r'] .. '/system.def') then
13+ def = 'data/' .. main.flags['-r'] .. '/system.def'
14+ end
15+end
16+
17+local file = io.open(def, 'r')
18+local s_file = file:read("*all")
19+file:close()
20+local localX, localY = s_file:match('localcoord%s*=%s*(%d+)%s*,%s*(%d+)')
21+--local scaleX = 1
22+--local scaleY = 1
23+if localX ~= nil then
24+ localX = tonumber(localX)
25+ --scaleX = localX / 320
26+else
27+ localX = 320
28+end
29+if localY ~= nil then
30+ localY = tonumber(localY)
31+ --scaleY = localY / 240
32+else
33+ localY = 240
34+end
35+--local coords_fix = 0
36+--if scaleY > 1 then
37+-- coords_fix = math.floor(scaleY - 1)
38+--end
39+
40+--;===========================================================
241 --; DEFAULT VALUES
342 --;===========================================================
443 --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.
544 --This is important because there are more params available in Ikemen. Whole screenpack code refers to these values.
645 local motif =
746 {
47+ def = def,
848 info =
949 {
1050 name = 'Default',
@@ -22,20 +62,15 @@ local motif =
2262 intro_storyboard = '',
2363 select = 'data/select.def',
2464 fight = 'data/fight.def',
25- debug_font = 'font/f-6x9.fnt', --Ikemen feature
65+ debug_font = 'f-6x9.def', --Ikemen feature
2666 debug_script = 'script/debug.lua', --Ikemen feature
27- font = --FNT v2 fonts not supported yet
67+ font =
2868 {
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,
69+ [1] = 'f-4x6.def',
70+ [2] = 'f-6x9.def',
71+ [3] = 'jg.fnt',
3872 },
73+ font_height = {}
3974 },
4075 ja_files = {}, --not used in Ikemen
4176 music =
@@ -43,43 +78,48 @@ local motif =
4378 title_bgm = '',
4479 title_bgm_volume = 100,
4580 title_bgm_loop = 1,
46- title_bgm_loopstart = nil,
47- title_bgm_loopend = nil,
81+ title_bgm_loopstart = 0,
82+ title_bgm_loopend = 0,
4883 select_bgm = '',
4984 select_bgm_volume = 100,
5085 select_bgm_loop = 1,
51- select_bgm_loopstart = nil,
52- select_bgm_loopend = nil,
86+ select_bgm_loopstart = 0,
87+ select_bgm_loopend = 0,
5388 vs_bgm = '',
5489 vs_bgm_volume = 100,
5590 vs_bgm_loop = 1,
56- vs_bgm_loopstart = nil,
57- vs_bgm_loopend = nil,
91+ vs_bgm_loopstart = 0,
92+ vs_bgm_loopend = 0,
5893 victory_bgm = '',
5994 victory_bgm_volume = 100,
6095 victory_bgm_loop = 1,
61- victory_bgm_loopstart = nil,
62- victory_bgm_loopend = nil,
96+ victory_bgm_loopstart = 0,
97+ victory_bgm_loopend = 0,
98+ option_bgm = '', --Ikemen feature
99+ option_bgm_volume = 100, --Ikemen feature
100+ option_bgm_loop = 1, --Ikemen feature
101+ option_bgm_loopstart = 0, --Ikemen feature
102+ option_bgm_loopend = 0, --Ikemen feature
63103 continue_bgm = 'sound/CONTINUE.ogg', --Ikemen feature
64104 continue_bgm_volume = 100, --Ikemen feature
65105 continue_bgm_loop = 1, --Ikemen feature
66- continue_bgm_loopstart = nil, --Ikemen feature
67- continue_bgm_loopend = nil, --Ikemen feature
106+ continue_bgm_loopstart = 0, --Ikemen feature
107+ continue_bgm_loopend = 0, --Ikemen feature
68108 continue_end_bgm = 'sound/GAME_OVER.ogg', --Ikemen feature
69109 continue_end_bgm_volume = 100, --Ikemen feature
70110 continue_end_bgm_loop = 0, --Ikemen feature
71- continue_end_bgm_loopstart = nil, --Ikemen feature
72- continue_end_bgm_loopend = nil, --Ikemen feature
111+ continue_end_bgm_loopstart = 0, --Ikemen feature
112+ continue_end_bgm_loopend = 0, --Ikemen feature
73113 results_bgm = '', --Ikemen feature
74114 results_bgm_volume = 100, --Ikemen feature
75115 results_bgm_loop = 1, --Ikemen feature
76- results_bgm_loopstart = nil, --Ikemen feature
77- results_bgm_loopend = nil, --Ikemen feature
116+ results_bgm_loopstart = 0, --Ikemen feature
117+ results_bgm_loopend = 0, --Ikemen feature
78118 tournament_bgm = '', --Ikemen feature
79119 tournament_bgm_volume = 100, --Ikemen feature
80120 tournament_bgm_loop = 1, --Ikemen feature
81- tournament_bgm_loopstart = nil, --Ikemen feature
82- tournament_bgm_loopend = nil, --Ikemen feature
121+ tournament_bgm_loopstart = 0, --Ikemen feature
122+ tournament_bgm_loopend = 0, --Ikemen feature
83123 },
84124 title_info =
85125 {
@@ -87,52 +127,56 @@ local motif =
87127 fadein_col = {0, 0, 0}, --Ikemen feature
88128 fadeout_time = 10,
89129 fadeout_col = {0, 0, 0}, --Ikemen feature
90- loading_offset = {310, 230}, --Ikemen feature
91- loading_font = {'font/f-4x6.fnt', 7, -1, nil, nil, nil}, --Ikemen feature
130+ loading_offset = {localX - 10, localY - 10}, --Ikemen feature (310, 230)
131+ loading_font = {'f-4x6.def', 7, -1, 255, 255, 255, 255, 0}, --Ikemen feature
92132 loading_font_scale = {1.0, 1.0}, --Ikemen feature
93133 loading_text = 'LOADING...', --Ikemen feature
94- footer1_offset = {2, 240}, --Ikemen feature
95- footer1_font = {'font/f-4x6.fnt', 7, 1, nil, nil, nil}, --Ikemen feature
134+ footer1_offset = {2, localY}, --Ikemen feature (2, 240)
135+ footer1_font = {'f-4x6.def', 7, 1, 255, 255, 255, 255, 0}, --Ikemen feature
96136 footer1_font_scale = {1.0, 1.0}, --Ikemen feature
97- footer1_text = 'I.K.E.M.E.N. by SUEHIRO', --Ikemen feature
98- footer2_offset = {160, 240}, --Ikemen feature
99- footer2_font = {'font/f-4x6.fnt', 7, 0, nil, nil, nil}, --Ikemen feature
137+ footer1_text = 'I.K.E.M.E.N. GO', --Ikemen feature
138+ footer2_offset = {localX / 2, localY}, --Ikemen feature (160, 240)
139+ footer2_font = {'f-4x6.def', 7, 0, 255, 255, 255, 255, 0}, --Ikemen feature
100140 footer2_font_scale = {1.0, 1.0}, --Ikemen feature
101- footer2_text = '', --Ikemen feature
102- footer3_offset = {319, 240}, --Ikemen feature
103- footer3_font = {'font/f-4x6.fnt', 7, -1, nil, nil, nil}, --Ikemen feature
141+ footer2_text = 'Press F1 for info', --Ikemen feature
142+ footer3_offset = {localX - 1, localY}, --Ikemen feature (319, 240)
143+ footer3_font = {'f-4x6.def', 7, -1, 255, 255, 255, 255, 0}, --Ikemen feature
104144 footer3_font_scale = {1.0, 1.0}, --Ikemen feature
105- footer3_text = 'https://osdn.net/users/supersuehiro/', --Ikemen feature
106- footer_boxbackground_visible = 1, --Ikemen feature
107- footer_boxbackground_coords = {0, 233, 319, 239}, --Ikemen feature
108- footer_boxbackground_alpha = {255, 100}, --Ikemen feature
145+ footer3_text = 'Plus v0.9', --Ikemen feature
146+ footer_boxbg_visible = 1, --Ikemen feature
147+ footer_boxbg_coords = {0, localY - 7, localX - 1, localY - 1}, --Ikemen feature (0, 233, 319, 239)
148+ footer_boxbg_col = {0, 0, 64}, --Ikemen feature
149+ footer_boxbg_alpha = {255, 100}, --Ikemen feature
109150 connecting_offset = {10, 40}, --Ikemen feature
110- connecting_font = {'font/f-6x9.fnt', 0, 1, nil, nil, nil}, --Ikemen feature
151+ connecting_font = {'f-6x9.def', 0, 1, 255, 255, 255, 255, 0}, --Ikemen feature
111152 connecting_font_scale = {1.0, 1.0}, --Ikemen feature
112- connecting_host = 'Waiting for player 2... (%s)', --Ikemen feature
113- connecting_join = 'Now connecting... (%s)', --Ikemen feature
114- input_ip_name = 'Enter Host display name, e.g. John.\nExisting entries can be removed with DELETE button.', --Ikemen feature
115- input_ip_address = 'Enter Host IP address, e.g. 127.0.0.1\nCopied text can be pasted with INSERT button.', --Ikemen feature
153+ connecting_host_text = 'Waiting for player 2... (%s)', --Ikemen feature
154+ connecting_join_text = 'Now connecting... (%s)', --Ikemen feature
155+ connecting_boxbg_coords = {0, 0, localX, localY}, --Ikemen feature (0, 0, 320, 240)
156+ connecting_boxbg_col = {0, 0, 0}, --Ikemen feature
157+ connecting_boxbg_alpha = {20, 100}, --Ikemen feature
158+ input_ip_name_text = 'Enter Host display name, e.g. John.\nExisting entries can be removed with DELETE button.', --Ikemen feature
159+ input_ip_address_text = 'Enter Host IP address, e.g. 127.0.0.1\nCopied text can be pasted with INSERT button.', --Ikemen feature
116160 menu_pos = {159, 158},
117- menu_item_font = {'font/f-6x9.fnt', 7, 0, nil, nil, nil},
118- menu_item_font_scale = {1.0, 1.0},
119- menu_item_active_font = {'font/f-6x9.fnt', 0, 0, nil, nil, nil},
120- menu_item_active_font_scale = {1.0, 1.0},
161+ menu_item_font = {'f-6x9.def', 7, 0, 255, 255, 255, 255, 0},
162+ menu_item_font_scale = {1.0, 1.0}, --broken parameter in mugen 1.1: http://mugenguild.com/forum/msg.1905756
163+ menu_item_active_font = {'f-6x9.def', 0, 0, 255, 255, 255, 255, 0},
164+ menu_item_active_font_scale = {1.0, 1.0}, --broken parameter in mugen 1.1: http://mugenguild.com/forum/msg.1905756
121165 menu_item_spacing = {0, 13},
122166 menu_itemname_arcade = 'ARCADE',
123167 menu_itemname_versus = 'VS MODE',
124- menu_itemname_online = 'NETWORK', --Ikemen feature
125- menu_itemname_teamarcade = 'TEAM ARCADE', --not used in Ikemen (same as ARCADE)
126- menu_itemname_teamversus = 'TEAM VS', --not used in Ikemen (same as VS MODE)
168+ menu_itemname_teamarcade = 'TEAM ARCADE',
169+ menu_itemname_teamversus = 'TEAM VERSUS',
170+ menu_itemname_online = '', --Ikemen feature (NETWORK)
127171 menu_itemname_teamcoop = 'TEAM CO-OP',
128172 menu_itemname_survival = 'SURVIVAL',
129173 menu_itemname_survivalcoop = 'SURVIVAL CO-OP',
130- menu_itemname_storymode = 'STORY MODE', --Ikemen feature (not implemented yet)
131- menu_itemname_timeattack = 'TIME ATTACK', --Ikemen feature (not implemented yet)
132- menu_itemname_tournament = 'TOURNAMENT', --Ikemen feature
174+ menu_itemname_storymode = '', --Ikemen feature (STORY MODE, not implemented yet)
175+ menu_itemname_timeattack = '', --Ikemen feature (TIME ATTACK, not implemented yet)
176+ menu_itemname_tournament = '', --Ikemen feature (TOURNAMENT, not implemented yet)
133177 menu_itemname_training = 'TRAINING',
134178 menu_itemname_watch = 'WATCH',
135- menu_itemname_extras = 'EXTRAS', --Ikemen feature
179+ menu_itemname_extras = '', --Ikemen feature (EXTRAS)
136180 menu_itemname_options = 'OPTIONS',
137181 menu_itemname_exit = 'EXIT',
138182 menu_itemname_netplayversus = 'VS MODE', --Ikemen feature
@@ -147,7 +191,7 @@ local motif =
147191 menu_itemname_bonusgames = 'BONUS GAMES', --Ikemen feature
148192 menu_itemname_scoreranking = 'SCORE RANKING', --Ikemen feature (not implemented yet)
149193 menu_itemname_replay = 'REPLAY', --Ikemen feature
150- menu_itemname_demo = 'DEMO', --Ikemen feature
194+ menu_itemname_randomtest = 'DEMO', --Ikemen feature
151195 menu_itemname_extrasback = 'BACK', --Ikemen feature
152196 menu_itemname_bonusback = 'BACK', --Ikemen feature
153197 menu_itemname_tourney32 = 'ROUND OF 32', --Ikemen feature
@@ -164,6 +208,8 @@ local motif =
164208 menu_window_visibleitems = 5,
165209 menu_boxcursor_visible = 1,
166210 menu_boxcursor_coords = {-40, -10, 39, 2},
211+ menu_boxcursor_col = {255, 255, 255}, --Ikemen feature
212+ menu_boxcursor_alpharange = {10, 40, 2, 255, 255, 0}, --Ikemen feature
167213 cursor_move_snd = {100, 0},
168214 cursor_done_snd = {100, 1},
169215 cancel_snd = {100, 2},
@@ -172,21 +218,21 @@ local motif =
172218 {
173219 spr = '',
174220 bgclearcolor = {0, 0, 0},
175- bg = {},
176- timer = 0, --Ikemen feature
177221 },
178222 infobox =
179223 {
180- title = 'I.K.E.M.E.N', --Ikemen feature
224+ title = '', --Ikemen feature
181225 title_pos = {159, 13}, --Ikemen feature
182- title_font = {'font/f-6x9.fnt', 0, 0, nil, nil, nil}, --Ikemen feature
226+ title_font = {'f-6x9.def', 0, 0, 255, 255, 255, 255, 0}, --Ikemen feature
183227 title_font_scale = {1.0, 1.0}, --Ikemen feature
184- 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)
228+ text = "Welcome to SUEHIRO's I.K.E.M.E.N GO engine!\n\n* This is a public development release, for testing purposes.\n* This build may contain bugs and incomplete features.\n* Your help and cooperation are appreciated!\n* I.K.E.M.E.N GO source code: https://osdn.net/users/supersuehiro/\n* Ikemen GO Plus source code: https://github.com/K4thos/Ikemen-GO-Plus", --Ikemen feature (requires new 'text = ' entry under [Infobox] section)
185229 text_pos = {25, 30}, --Ikemen feature
186- text_font = {'font/f-4x6.fnt', 7, 1, nil, nil, nil}, --Ikemen feature
230+ text_font = {'f-4x6.def', 7, 1, 255, 255, 255, 255, 0}, --Ikemen feature
187231 text_font_scale = {1.0, 1.0}, --Ikemen feature
188232 text_spacing = {0, 10}, --Ikemen feature
189- background_alpha = {20, 100}, --Ikemen feature
233+ boxbg_coords = {0, 0, localX, localY}, --Ikemen feature (0, 0, 320, 240)
234+ boxbg_col = {0, 0, 0}, --Ikemen feature
235+ boxbg_alpha = {20, 100}, --Ikemen feature
190236 },
191237 infobox_text = '', --not used in Ikemen
192238 ja_infobox_text = '', --not used in Ikemen
@@ -211,19 +257,17 @@ local motif =
211257 searchemptyboxesup = 0, --Ikemen feature
212258 searchemptyboxesdown = 0, --Ikemen feature
213259 cell_size = {27, 27},
214- cell_spacing = 2,
260+ cell_spacing = {2, 2}, --Ikemen feature (optionally accepts x, y values instead of a single one for both coordinates)
215261 --cell_bg_anim = nil,
216262 cell_bg_spr = {},
217263 cell_bg_offset = {0, 0},
218264 cell_bg_facing = 1,
219265 cell_bg_scale = {1.0, 1.0},
220- --cell_bg_alpha = {}, --Ikemen feature (not implemented yet)
221266 --cell_random_anim = nil,
222267 cell_random_spr = {},
223268 cell_random_offset = {0, 0},
224269 cell_random_facing = 1,
225270 cell_random_scale = {1.0, 1.0},
226- --cell_random_alpha = {}, --Ikemen feature (not implemented yet)
227271 cell_random_switchtime = 4,
228272 p1_cursor_startcell = {0, 0},
229273 --p1_cursor_active_anim = nil,
@@ -262,10 +306,12 @@ local motif =
262306 portrait_offset = {0, 0}, --not supported yet
263307 portrait_scale = {1.0, 1.0},
264308 title_offset = {0, 0},
265- title_font = {'font/jg.fnt', 0, 0, nil, nil, nil},
309+ title_font = {'jg.fnt', 0, 0, 255, 255, 255, 255, 0},
266310 title_font_scale = {1.0, 1.0},
267311 title_text_arcade = 'Arcade', --Ikemen feature
268312 title_text_versus = 'Versus Mode', --Ikemen feature
313+ title_text_teamarcade = 'Team Arcade', --Ikemen feature
314+ title_text_teamversus = 'Team Versus', --Ikemen feature
269315 title_text_teamcoop = 'Team Cooperative', --Ikemen feature
270316 title_text_survival = 'Survival', --Ikemen feature
271317 title_text_survivalcoop = 'Survival Cooperative', --Ikemen feature
@@ -291,37 +337,61 @@ local motif =
291337 p1_face_facing = 1,
292338 p1_face_scale = {1.0, 1.0},
293339 p1_face_window = {0, 0, 0, 0},
294- p1_face_spacing = {0, 0}, --Ikemen feature
295340 p1_face_num = 1, --Ikemen feature
341+ p1_face_spacing = {0, 0}, --Ikemen feature
342+ p1_c1_face_offset = {0, 0}, --Ikemen feature
343+ p1_c1_face_scale = {1.0, 1.0}, --Ikemen feature
344+ p1_c2_face_offset = {0, 0}, --Ikemen feature
345+ p1_c2_face_scale = {1.0, 1.0}, --Ikemen feature
346+ p1_c3_face_offset = {0, 0}, --Ikemen feature
347+ p1_c3_face_scale = {1.0, 1.0}, --Ikemen feature
348+ p1_c4_face_offset = {0, 0}, --Ikemen feature
349+ p1_c4_face_scale = {1.0, 1.0}, --Ikemen feature
296350 p2_face_spr = {9000, 1},
297351 p2_face_offset = {0, 0},
298352 p2_face_facing = -1,
299353 p2_face_scale = {1.0, 1.0},
300354 p2_face_window = {0, 0, 0, 0},
301- p2_face_spacing = {0, 0}, --Ikemen feature
302355 p2_face_num = 1, --Ikemen feature
356+ p2_face_spacing = {0, 0}, --Ikemen feature
357+ p2_c1_face_offset = {0, 0}, --Ikemen feature
358+ p2_c1_face_scale = {1.0, 1.0}, --Ikemen feature
359+ p2_c2_face_offset = {0, 0}, --Ikemen feature
360+ p1_c2_face_scale = {1.0, 1.0}, --Ikemen feature
361+ p2_c3_face_offset = {0, 0}, --Ikemen feature
362+ p2_c3_face_scale = {1.0, 1.0}, --Ikemen feature
363+ p2_c4_face_offset = {0, 0}, --Ikemen feature
364+ p2_c4_face_scale = {1.0, 1.0}, --Ikemen feature
303365 p1_name_offset = {0, 0},
304- p1_name_font = {'font/jg.fnt', 4, 1, nil, nil, nil},
366+ p1_name_font = {'jg.fnt', 4, 1, 255, 255, 255, 255, 0},
305367 p1_name_font_scale = {1.0, 1.0},
306368 p1_name_spacing = {0, 14},
307369 p2_name_offset = {0, 0},
308- p2_name_font = {'font/jg.fnt', 1, -1, nil, nil, nil},
370+ p2_name_font = {'jg.fnt', 1, -1, 255, 255, 255, 255, 0},
309371 p2_name_font_scale = {1.0, 1.0},
310372 p2_name_spacing = {0, 14},
311373 stage_pos = {0, 0},
312- stage_active_font = {'font/f-4x6.fnt', 0, 0, nil, nil, nil},
374+ stage_active_font = {'f-4x6.def', 0, 0, 255, 255, 255, 255, 0},
313375 stage_active_font_scale = {1.0, 1.0},
314- stage_active2_font = {'font/f-4x6.fnt', 0, 0, nil, nil, nil},
376+ stage_active2_font = {'f-4x6.def', 0, 0, 255, 255, 255, 255, 0},
315377 stage_active2_font_scale = {1.0, 1.0},
316- stage_done_font = {'font/f-4x6.fnt', 0, 0, nil, nil, nil},
378+ stage_done_font = {'f-4x6.def', 0, 0, 255, 255, 255, 255, 0},
317379 stage_done_font_scale = {1.0, 1.0},
318380 stage_text = 'Stage %i: %s', --Ikemen feature
381+ stage_random_text = 'Stage: Random', --Ikemen feature
319382 stage_text_spacing = {0, 14}, --Ikemen feature
383+ stage_portrait_spr = {9000, 0}, --Ikemen feature
384+ stage_portrait_offset = {0, 0}, --Ikemen feature
385+ stage_portrait_scale = {1.0, 1.0}, --Ikemen feature
386+ stage_portrait_random_spr = {}, --Ikemen feature
387+ --stage_portrait_random_anim = nil, --Ikemen feature
388+ stage_portrait_random_offset = {0, 0}, --Ikemen feature
389+ stage_portrait_random_scale = {1.0, 1.0}, --Ikemen feature
320390 teammenu_move_wrapping = 1,
321391 teammenu_itemname_single = 'Single', --Ikemen feature
322392 teammenu_itemname_simul = 'Simul', --Ikemen feature
323393 teammenu_itemname_turns = 'Turns', --Ikemen feature
324- teammenu_itemname_tag = 'Tag', --Ikemen feature
394+ teammenu_itemname_tag = '', --Ikemen feature (Tag)
325395 p1_teammenu_pos = {0, 0},
326396 --p1_teammenu_bg_anim = nil,
327397 p1_teammenu_bg_spr = {},
@@ -333,7 +403,7 @@ local motif =
333403 p1_teammenu_selftitle_offset = {0, 0},
334404 p1_teammenu_selftitle_facing = 1,
335405 p1_teammenu_selftitle_scale = {1.0, 1.0},
336- p1_teammenu_selftitle_font = {'font/jg.fnt', 0, 1, nil, nil, nil},
406+ p1_teammenu_selftitle_font = {'jg.fnt', 0, 1, 255, 255, 255, 255, 0},
337407 p1_teammenu_selftitle_font_scale = {1.0, 1.0},
338408 p1_teammenu_selftitle_text = '',
339409 --p1_teammenu_enemytitle_anim = nil,
@@ -341,7 +411,7 @@ local motif =
341411 p1_teammenu_enemytitle_offset = {0, 0},
342412 p1_teammenu_enemytitle_facing = 1,
343413 p1_teammenu_enemytitle_scale = {1.0, 1.0},
344- p1_teammenu_enemytitle_font = {'font/jg.fnt', 0, 1, nil, nil, nil},
414+ p1_teammenu_enemytitle_font = {'jg.fnt', 0, 1, 255, 255, 255, 255, 0},
345415 p1_teammenu_enemytitle_font_scale = {1.0, 1.0},
346416 p1_teammenu_enemytitle_text = '',
347417 p1_teammenu_move_snd = {100, 0},
@@ -350,11 +420,11 @@ local motif =
350420 p1_teammenu_item_offset = {0, 0},
351421 p1_teammenu_item_spacing = {0, 15},
352422 p1_teammenu_item_font_offset = {0, 0}, --Ikemen feature
353- p1_teammenu_item_font = {'font/jg.fnt', 0, 1, nil, nil, nil},
423+ p1_teammenu_item_font = {'jg.fnt', 0, 1, 255, 255, 255, 255, 0},
354424 p1_teammenu_item_font_scale = {1.0, 1.0},
355- p1_teammenu_item_active_font = {'font/jg.fnt', 3, 1, nil, nil, nil},
425+ p1_teammenu_item_active_font = {'jg.fnt', 3, 1, 255, 255, 255, 255, 0},
356426 p1_teammenu_item_active_font_scale = {1.0, 1.0},
357- p1_teammenu_item_active2_font = {'font/jg.fnt', 0, 1, nil, nil, nil},
427+ p1_teammenu_item_active2_font = {'jg.fnt', 0, 1, 255, 255, 255, 255, 0},
358428 p1_teammenu_item_active2_font_scale = {1.0, 1.0},
359429 --p1_teammenu_item_cursor_anim = nil,
360430 p1_teammenu_item_cursor_spr = {},
@@ -383,7 +453,7 @@ local motif =
383453 p2_teammenu_selftitle_offset = {0, 0},
384454 p2_teammenu_selftitle_facing = 1,
385455 p2_teammenu_selftitle_scale = {1.0, 1.0},
386- p2_teammenu_selftitle_font = {'font/jg.fnt', 0, -1, nil, nil, nil},
456+ p2_teammenu_selftitle_font = {'jg.fnt', 0, -1, 255, 255, 255, 255, 0},
387457 p2_teammenu_selftitle_font_scale = {1.0, 1.0},
388458 p2_teammenu_selftitle_text = '',
389459 --p2_teammenu_enemytitle_anim = nil,
@@ -391,7 +461,7 @@ local motif =
391461 p2_teammenu_enemytitle_offset = {0, 0},
392462 p2_teammenu_enemytitle_facing = 1,
393463 p2_teammenu_enemytitle_scale = {1.0, 1.0},
394- p2_teammenu_enemytitle_font = {'font/jg.fnt', 0, -1, nil, nil, nil},
464+ p2_teammenu_enemytitle_font = {'jg.fnt', 0, -1, 255, 255, 255, 255, 0},
395465 p2_teammenu_enemytitle_font_scale = {1.0, 1.0},
396466 p2_teammenu_enemytitle_text = '',
397467 p2_teammenu_move_snd = {100, 0},
@@ -400,11 +470,11 @@ local motif =
400470 p2_teammenu_item_offset = {0, 0},
401471 p2_teammenu_item_spacing = {0, 15},
402472 p2_teammenu_item_font_offset = {0, 0}, --Ikemen feature
403- p2_teammenu_item_font = {'font/jg.fnt', 0, -1, nil, nil, nil},
473+ p2_teammenu_item_font = {'jg.fnt', 0, -1, 255, 255, 255, 255, 0},
404474 p2_teammenu_item_font_scale = {1.0, 1.0},
405- p2_teammenu_item_active_font = {'font/jg.fnt', 1, -1, nil, nil, nil},
475+ p2_teammenu_item_active_font = {'jg.fnt', 1, -1, 255, 255, 255, 255, 0},
406476 p2_teammenu_item_active_font_scale = {1.0, 1.0},
407- p2_teammenu_item_active2_font = {'font/jg.fnt', 0, -1, nil, nil, nil},
477+ p2_teammenu_item_active2_font = {'jg.fnt', 0, -1, 255, 255, 255, 255, 0},
408478 p2_teammenu_item_active2_font_scale = {1.0, 1.0},
409479 --p2_teammenu_item_cursor_anim = nil,
410480 p2_teammenu_item_cursor_spr = {},
@@ -427,8 +497,6 @@ local motif =
427497 {
428498 spr = '',
429499 bgclearcolor = {0, 0, 0},
430- bg = {},
431- timer = 0, --Ikemen feature
432500 },
433501 vs_screen =
434502 {
@@ -440,37 +508,53 @@ local motif =
440508 time_order = 60, --Ikemen feature
441509 match_text = 'Match %i',
442510 match_offset = {159, 12},
443- match_font = {'font/jg.fnt', 0, 0, nil, nil, nil},
511+ match_font = {'jg.fnt', 0, 0, 255, 255, 255, 255, 0},
444512 match_font_scale = {1.0, 1.0},
445513 p1_pos = {0, 0},
446514 p1_spr = {9000, 1},
447515 p1_offset = {0, 0},
448516 p1_facing = 1,
449517 p1_scale = {1.0, 1.0},
450- p1_window = {0, 0, 0, 0},
451- p1_spacing = {0, 0}, --Ikemen feature
518+ --p1_window = {0, 0, 0, 0}, --not implemented yet
452519 p1_num = 1, --Ikemen feature
520+ p1_spacing = {0, 0}, --Ikemen feature
521+ p1_c1_offset = {0, 0}, --Ikemen feature
522+ p1_c1_scale = {1.0, 1.0}, --Ikemen feature
523+ p1_c2_offset = {0, 0}, --Ikemen feature
524+ p1_c2_scale = {1.0, 1.0}, --Ikemen feature
525+ p1_c3_offset = {0, 0}, --Ikemen feature
526+ p1_c3_scale = {1.0, 1.0}, --Ikemen feature
527+ p1_c4_offset = {0, 0}, --Ikemen feature
528+ p1_c4_scale = {1.0, 1.0}, --Ikemen feature
453529 p2_pos = {0, 0},
454- p2_spr = {9000, 1},
530+ p2_spr = {9000, 1}, --not used in Ikemen (same as p1_spr)
455531 p2_offset = {0, 0},
456532 p2_facing = -1,
457533 p2_scale = {1.0, 1.0},
458- p2_window = {0, 0, 0, 0},
459- p2_spacing = {0, 0}, --Ikemen feature
534+ --p2_window = {0, 0, 0, 0}, --not implemented yet
460535 p2_num = 1, --Ikemen feature
536+ p2_spacing = {0, 0}, --Ikemen feature
537+ p2_c1_offset = {0, 0}, --Ikemen feature
538+ p2_c1_scale = {1.0, 1.0}, --Ikemen feature
539+ p2_c2_offset = {0, 0}, --Ikemen feature
540+ p2_c2_scale = {1.0, 1.0}, --Ikemen feature
541+ p2_c3_offset = {0, 0}, --Ikemen feature
542+ p2_c3_scale = {1.0, 1.0}, --Ikemen feature
543+ p2_c4_offset = {0, 0}, --Ikemen feature
544+ p2_c4_scale = {1.0, 1.0}, --Ikemen feature
461545 p1_name_pos = {0, 0},
462546 p1_name_offset = {0, 0},
463- p1_name_font = {'font/jg.fnt', 0, 0, nil, nil, nil},
547+ p1_name_font = {'jg.fnt', 0, 0, 255, 255, 255, 255, 0},
464548 p1_name_font_scale = {1.0, 1.0},
465549 p1_name_spacing = {0, 14},
466550 p2_name_pos = {0, 0},
467551 p2_name_offset = {0, 0},
468- p2_name_font = {'font/jg.fnt', 0, 0, nil, nil, nil},
552+ p2_name_font = {'jg.fnt', 0, 0, 255, 255, 255, 255, 0},
469553 p2_name_font_scale = {1.0, 1.0},
470554 p2_name_spacing = {0, 14},
471- --p1_name_active_font = {'font/jg.fnt', 0, 0, nil, nil, nil}, --Ikemen feature
555+ --p1_name_active_font = {'jg.fnt', 0, 0, 255, 255, 255, 255, 0}, --Ikemen feature
472556 --p1_name_active_font_scale = {1.0, 1.0}, --Ikemen feature
473- --p2_name_active_font = {'font/jg.fnt', 0, 0, nil, nil, nil}, --Ikemen feature
557+ --p2_name_active_font = {'jg.fnt', 0, 0, 255, 255, 255, 255, 0}, --Ikemen feature
474558 --p2_name_active_font_scale = {1.0, 1.0}, --Ikemen feature
475559 p1_cursor_move_snd = {100, 0}, --Ikemen feature
476560 p1_cursor_done_snd = {100, 1}, --Ikemen feature
@@ -481,21 +565,23 @@ local motif =
481565 {
482566 spr = '',
483567 bgclearcolor = {0, 0, 0},
484- bg = {},
485- timer = 0, --Ikemen feature
486568 },
487569 demo_mode =
488570 {
489- enabled = 1, --not supported yet
571+ enabled = 1,
490572 select_enabled = 0, --not supported yet
491573 vsscreen_enabled = 0, --not supported yet
492- title_waittime = 600, --not supported yet
493- fight_endtime = 1500, --not supported yet
494- fight_playbgm = 0, --not supported yet
495- fight_stopbgm = 1, --not supported yet
496- fight_bars_display = 0, --not supported yet
497- intro_waitcycles = 1, --not supported yet
498- debuginfo = 0, --not supported yet
574+ title_waittime = 600,
575+ fight_endtime = 1500,
576+ fight_playbgm = 0,
577+ fight_stopbgm = 0,
578+ fight_bars_display = 0,
579+ intro_waitcycles = 1,
580+ debuginfo = 0,
581+ fadein_time = 50, --Ikemen feature
582+ fadein_col = {0, 0, 0}, --Ikemen feature
583+ fadeout_time = 50, --Ikemen feature
584+ fadeout_col = {0, 0, 0}, --Ikemen feature
499585 },
500586 continue_screen =
501587 {
@@ -534,28 +620,28 @@ local motif =
534620 continue_end_snd = {1, 0}, --Ikemen feature
535621 credits_text = 'Credits: %i', --Ikemen feature
536622 credits_offset = {20, 30}, --Ikemen feature
537- credits_font = {'font/jg.fnt', 0, 1, nil, nil, nil}, --Ikemen feature
623+ credits_font = {'jg.fnt', 0, 1, 255, 255, 255, 255, 0}, --Ikemen feature
538624 credits_font_scale = {1.0, 1.0}, --Ikemen feature
539625 --enabled = 1, --not used in Ikemen
540626 --pos = {160, 240}, --not used in Ikemen
541627 --continue_text = 'CONTINUE?', --not used in Ikemen
542- --continue_font = {'font/f-4x6.fnt', 0, 0, nil, nil, nil}, --not used in Ikemen
628+ --continue_font = {'f-4x6.def', 0, 0, 255, 255, 255, 255, 0}, --not used in Ikemen
543629 --continue_font_scale = {1.0, 1.0}, --not used in Ikemen
544630 --continue_offset = {0, 0}, --not used in Ikemen
545631 --yes_text = 'YES', --not used in Ikemen
546- --yes_font = {'font/f-4x6.fnt', 0, 0, 128, 128, 128}, --not used in Ikemen
632+ --yes_font = {'f-4x6.def', 0, 0, 128, 128, 128}, --not used in Ikemen
547633 --yes_font_scale = {1.0, 1.0}, --not used in Ikemen
548634 --yes_offset = {-80, 60}, --not used in Ikemen
549635 --yes_active_text = 'YES', --not used in Ikemen
550- --yes_active_font = {'font/f-4x6.fnt', 3, 0, nil, nil, nil}, --not used in Ikemen
636+ --yes_active_font = {'f-4x6.def', 3, 0, 255, 255, 255, 255, 0}, --not used in Ikemen
551637 --yes_active_font_scale = {1.0, 1.0}, --not used in Ikemen
552638 --yes_active_offset = {-80, 60}, --not used in Ikemen
553639 --no_text = 'NO', --not used in Ikemen
554- --no_font = {'font/f-4x6.fnt', 0, 0, 128, 128, 128}, --not used in Ikemen
640+ --no_font = {'f-4x6.def', 0, 0, 128, 128, 128}, --not used in Ikemen
555641 --no_font_scale = {1.0, 1.0}, --not used in Ikemen
556642 --no_offset = {80, 60}, --not used in Ikemen
557643 --no_active_text = 'NO', --not used in Ikemen
558- --no_active_font = {'font/f-4x6.fnt', 3, 0, nil, nil, nil}, --not used in Ikemen
644+ --no_active_font = {'f-4x6.def', 3, 0, 255, 255, 255, 255, 0}, --not used in Ikemen
559645 --no_active_font_scale = {1.0, 1.0}, --not used in Ikemen
560646 --no_active_offset = {80, 60}, --not used in Ikemen
561647 },
@@ -563,8 +649,6 @@ local motif =
563649 {
564650 spr = 'data/continue.sff', --Ikemen feature
565651 bgclearcolor = {0, 0, 0}, --Ikemen feature
566- bg = {},
567- timer = 0, --Ikemen feature
568652 },
569653 game_over_screen =
570654 {
@@ -573,32 +657,54 @@ local motif =
573657 },
574658 victory_screen =
575659 {
576- enabled = 1,
660+ enabled = 0,
661+ cpu_enabled = 1, --Ikemen feature
662+ vs_enabled = 1, --Ikemen feature
663+ looser_name_enabled = 0, --Ikemen feature
664+ winner_teamko_enabled = 0, --Ikemen feature
577665 time = 300,
578666 fadein_time = 8,
579667 fadein_col = {0, 0, 0}, --Ikemen feature
580668 fadeout_time = 15,
581669 fadeout_col = {0, 0, 0}, --Ikemen feature
670+ p1_pos = {0, 0},
582671 p1_spr = {9000, 2},
583672 p1_offset = {100, 20},
584673 p1_facing = 1,
585674 p1_scale = {1.0, 1.0},
586- p1_window = {0, 0, 319, 160},
675+ --p1_window = {0, 0, 319, 160}, --not implemented yet
676+ p1_num = 1, --Ikemen feature
677+ p1_c1_offset = {0, 0}, --Ikemen feature
678+ p1_c1_scale = {1.0, 1.0}, --Ikemen feature
679+ p1_c2_offset = {0, 0}, --Ikemen feature
680+ p1_c2_scale = {1.0, 1.0}, --Ikemen feature
681+ p1_c3_offset = {0, 0}, --Ikemen feature
682+ p1_c3_scale = {1.0, 1.0}, --Ikemen feature
683+ p1_c4_offset = {0, 0}, --Ikemen feature
684+ p1_c4_scale = {1.0, 1.0}, --Ikemen feature
587685 p1_name_offset = {20, 180},
588- p1_name_font = {'font/jg.fnt', 0, 1, nil, nil, nil},
686+ p1_name_font = {'jg.fnt', 0, 1, 255, 255, 255, 255, 0},
589687 p1_name_font_scale = {1.0, 1.0},
590- p2_display = 0, --Ikemen feature
591- p2_spr = {9000, 2}, --Ikemen feature
688+ p2_pos = {0, 0}, --Ikemen feature
592689 p2_offset = {100, 20}, --Ikemen feature
593- p2_facing = -1, --Ikemen feature
690+ p2_facing = 1, --Ikemen feature
594691 p2_scale = {1.0, 1.0}, --Ikemen feature
595- p2_window = {0, 0, 319, 160}, --Ikemen feature
692+ --p2_window = {0, 0, 319, 160}, --Ikemen feature (not implemented yet)
693+ p2_num = 0, --Ikemen feature
694+ p2_c1_offset = {0, 0}, --Ikemen feature
695+ p2_c1_scale = {1.0, 1.0}, --Ikemen feature
696+ p2_c2_offset = {0, 0}, --Ikemen feature
697+ p2_c2_scale = {1.0, 1.0}, --Ikemen feature
698+ p2_c3_offset = {0, 0}, --Ikemen feature
699+ p2_c3_scale = {1.0, 1.0}, --Ikemen feature
700+ p2_c4_offset = {0, 0}, --Ikemen feature
701+ p2_c4_scale = {1.0, 1.0}, --Ikemen feature
596702 p2_name_offset = {20, 180}, --Ikemen feature
597- p2_name_font = {'font/jg.fnt', 0, 1, nil, nil, nil}, --Ikemen feature
598- p2_name_font_scale = {1.0, 1.0},
703+ p2_name_font = {'jg.fnt', 0, 1, 255, 255, 255, 255, 0}, --Ikemen feature
704+ p2_name_font_scale = {1.0, 1.0}, --Ikemen feature
599705 winquote_text = 'Winner!',
600706 winquote_offset = {20, 192},
601- winquote_font = {'font/f-6x9.fnt', 0, 1, nil, nil, nil},
707+ winquote_font = {'f-6x9.def', 0, 1, 255, 255, 255, 255, 0},
602708 winquote_font_scale = {1.0, 1.0},
603709 winquote_spacing = {0, 15}, --Ikemen feature
604710 winquote_delay = 2, --Ikemen feature
@@ -610,8 +716,6 @@ local motif =
610716 {
611717 spr = '',
612718 bgclearcolor = {0, 0, 0},
613- bg = {},
614- timer = 0, --Ikemen feature
615719 },
616720 win_screen =
617721 {
@@ -623,7 +727,7 @@ local motif =
623727 pose_time = 300,
624728 wintext_text = 'Congratulations!',
625729 wintext_offset = {159, 70},
626- wintext_font = {'font/f-6x9.fnt', 0, 0, nil, nil, nil},
730+ wintext_font = {'f-6x9.def', 0, 0, 255, 255, 255, 255, 0},
627731 wintext_font_scale = {1.0, 1.0},
628732 wintext_displaytime = -1,
629733 wintext_layerno = 2,
@@ -648,7 +752,7 @@ local motif =
648752 show_time = 300,
649753 winstext_text = 'Rounds survived: %i',
650754 winstext_offset = {159, 70},
651- winstext_font = {'font/jg.fnt', 0, 0, nil, nil, nil},
755+ winstext_font = {'jg.fnt', 0, 0, 255, 255, 255, 255, 0},
652756 winstext_font_scale = {1.0, 1.0},
653757 winstext_spacing = {0, 15}, --Ikemen feature
654758 winstext_displaytime = -1,
@@ -665,7 +769,7 @@ local motif =
665769 show_time = 300, --Ikemen feature
666770 winstext_text = 'Wins: %i\nLoses: %i', --Ikemen feature
667771 winstext_offset = {159, 70}, --Ikemen feature
668- winstext_font = {'font/jg.fnt', 0, 0, nil, nil, nil}, --Ikemen feature
772+ winstext_font = {'jg.fnt', 0, 0, 255, 255, 255, 255, 0}, --Ikemen feature
669773 winstext_font_scale = {1.0, 1.0}, --Ikemen feature
670774 winstext_spacing = {0, 15}, --Ikemen feature
671775 winstext_displaytime = -1, --Ikemen feature
@@ -676,8 +780,6 @@ local motif =
676780 {
677781 spr = '', --Ikemen feature
678782 bgclearcolor = {0, 0, 0}, --Ikemen feature (disabled to not cover game screen)
679- bg = {},
680- timer = 0, --Ikemen feature
681783 },
682784 option_info =
683785 {
@@ -686,92 +788,77 @@ local motif =
686788 fadeout_time = 10, --check winmugen values
687789 fadeout_col = {0, 0, 0}, --Ikemen feature
688790 title_offset = {159, 19},
689- title_font = {'font/f-6x9.fnt', 0, 0, nil, nil, nil},
791+ title_font = {'f-6x9.def', 0, 0, 255, 255, 255, 255, 0},
690792 title_font_scale = {1.0, 1.0},
691793 title_text_main = 'OPTIONS', --Ikemen feature
692794 title_text_arcade = 'ARCADE SETTINGS', --Ikemen feature
693795 title_text_gameplay = 'GAMEPLAY SETTINGS', --Ikemen feature
694- title_text_advgameplay = 'ADVANCED GAMEPLAY SETTINGS', --Ikemen feature
796+ title_text_advgameplay = 'ADVANCED SETTINGS', --Ikemen feature
695797 title_text_video = 'VIDEO SETTINGS', --Ikemen feature
798+ title_text_res = 'RESOLUTION SETTINGS', --Ikemen feature
696799 title_text_audio = 'AUDIO SETTINGS', --Ikemen feature
697800 title_text_engine = 'ENGINE SETTINGS', --Ikemen feature
698- title_text_res = 'RESOLUTION SETTINGS', --Ikemen feature
699801 title_text_input = 'INPUT SETTINGS', --Ikemen feature
700802 title_text_key = 'KEY SETTINGS', --Ikemen feature
803+ title_text_controller = 'CONTROLLER SETTINGS', --Ikemen feature
701804 menu_pos = {85, 33}, --Ikemen feature
702- menu_item_font = {'font/f-6x9.fnt', 7, 1, nil, nil, nil}, --Ikemen feature
805+ menu_item_font = {'f-6x9.def', 7, 1, 255, 255, 255, 255, 0}, --Ikemen feature
703806 menu_item_font_scale = {1.0, 1.0}, --Ikemen feature
704- menu_item_active_font = {'font/f-6x9.fnt', 0, 1, nil, nil, nil}, --Ikemen feature
807+ menu_item_active_font = {'f-6x9.def', 0, 1, 255, 255, 255, 255, 0}, --Ikemen feature
705808 menu_item_active_font_scale = {1.0, 1.0}, --Ikemen feature
706- menu_item_value_font = {'font/f-6x9.fnt', 7, -1, nil, nil, nil}, --Ikemen feature
809+ menu_item_value_font = {'f-6x9.def', 7, -1, 255, 255, 255, 255, 0}, --Ikemen feature
707810 menu_item_value_font_scale = {1.0, 1.0}, --Ikemen feature
708- menu_item_value_active_font = {'font/f-6x9.fnt', 0, -1, nil, nil, nil}, --Ikemen feature
811+ menu_item_value_active_font = {'f-6x9.def', 0, -1, 255, 255, 255, 255, 0}, --Ikemen feature
709812 menu_item_value_active_font_scale = {1.0, 1.0}, --Ikemen feature
710- menu_item_value_conflict_font = {'font/f-6x9.fnt', 1, -1, nil, nil, nil}, --Ikemen feature
813+ menu_item_value_conflict_font = {'f-6x9.def', 1, -1, 255, 255, 255, 255, 0}, --Ikemen feature
711814 menu_item_value_conflict_font_scale = {1.0, 1.0}, --Ikemen feature
712815 menu_item_spacing = {150, 13}, --Ikemen feature
713816 menu_window_visibleitems = 16, --Ikemen feature
714817 menu_boxcursor_visible = 1, --Ikemen feature
715- menu_boxcursor_coords = {-5, -9, 154, 3}, --Ikemen feature
716- menu_boxbackground_visible = 1, --Ikemen feature
717- menu_boxbackground_alpha = {20, 100}, --Ikemen feature
818+ menu_boxcursor_coords = {-5, -10, 154, 2}, --Ikemen feature
819+ menu_boxcursor_col = {255, 255, 255}, --Ikemen feature
820+ menu_boxcursor_alpharange = {10, 40, 2, 255, 255, 0}, --Ikemen feature
821+ menu_boxbg_visible = 1, --Ikemen feature
822+ menu_boxbg_col = {0, 0, 0}, --Ikemen feature
823+ menu_boxbg_alpha = {20, 100}, --Ikemen feature
718824 menu_itemname_main_arcade = 'Arcade Settings', --Ikemen feature
719825 menu_itemname_main_gameplay = 'Gameplay Settings', --Ikemen feature
720- menu_itemname_main_engine = "Engine Settings", --Ikemen feature
826+ menu_itemname_main_engine = 'Engine Settings', --Ikemen feature
721827 menu_itemname_main_video = 'Video Settings', --Ikemen feature
722828 menu_itemname_main_audio = 'Audio Settings', --Ikemen feature
723829 menu_itemname_main_input = 'Input Settings', --Ikemen feature
830+ menu_itemname_main_quicklaunch = 'Quick Launch', --Ikemen feature
724831 menu_itemname_main_port = 'Port Change', --Ikemen feature
725832 menu_itemname_main_default = 'Default Values', --Ikemen feature
833+ menu_itemname_main_save = 'Save and Return', --Ikemen feature
726834 menu_itemname_main_back = 'Return Without Saving', --Ikemen feature
727- menu_itemname_arcade_roundstowin = 'Rounds to Win', --Ikemen feature
728- menu_itemname_arcade_roundtime = 'Round Time', --Ikemen feature
835+ menu_itemname_arcade_roundtime = 'Time Limit', --Ikemen feature
836+ menu_itemname_arcade_roundtime_none = 'None', --Ikemen feature
837+ menu_itemname_arcade_roundsnumsingle = 'Rounds to Win Single', --Ikemen feature
838+ menu_itemname_arcade_roundsnumteam = 'Rounds to Win Simul/Tag', --Ikemen feature
839+ menu_itemname_arcade_maxdrawgames = 'Max Draw Games', --Ikemen feature
729840 menu_itemname_arcade_difficulty = 'Difficulty level', --Ikemen feature
730841 menu_itemname_arcade_credits = 'Credits', --Ikemen feature
731842 menu_itemname_arcade_charchange = 'Char change at Continue', --Ikemen feature
732- menu_itemname_arcade_airamping = 'AI ramping', --Ikemen feature
843+ menu_itemname_arcade_airamping = 'AI Ramping', --Ikemen feature
844+ menu_itemname_arcade_aipalette = 'AI Palette', --Ikemen feature
845+ menu_itemname_arcade_aipalette_random = 'Random', --Ikemen feature
846+ menu_itemname_arcade_aipalette_default = 'Default', --Ikemen feature
733847 menu_itemname_arcade_back = 'Back', --Ikemen feature
734- menu_itemname_gameplay_lifemul = 'Life', --Ikemen feature
735- menu_itemname_gameplay_autoguard = 'Auto-Guard', --Ikemen feature
736- menu_itemname_gameplay_attackpowermul = 'Attack.LifeToPowerMul', --Ikemen feature
737- menu_itemname_gameplay_gethitpowermul = 'GetHit.LifeToPowerMul', --Ikemen feature
738- menu_itemname_gameplay_superdefencemul = 'Super.TargetDefenceMul', --Ikemen feature
739- menu_itemname_gameplay_team1vs2life = '1P Vs Team Life', --Ikemen feature
740- menu_itemname_gameplay_turnsrecoveryrate = 'Turns HP Recovery', --Ikemen feature
741- menu_itemname_gameplay_teampowershare = 'Team Power Share', --Ikemen feature
742- menu_itemname_gameplay_teamlifeshare = 'Team Life Share', --Ikemen feature
743- menu_itemname_gameplay_singlemode = 'Single Mode', --Ikemen feature
744- menu_itemname_gameplay_numturns = 'Turns Limit', --Ikemen feature
745- menu_itemname_gameplay_numsimul = 'Simul Limit', --Ikemen feature
746- menu_itemname_gameplay_numtag = 'Tag Limit', --Ikemen features
747- menu_itemname_gameplay_simulmode = 'Legacy Tag Mode', --Ikemen feature
748- menu_itemname_gameplay_simulmode_simul = 'Disabled', --Ikemen feature
749- menu_itemname_gameplay_simulmode_tag = 'Enabled', --Ikemen feature
750- menu_itemname_gameplay_advanced = 'Advanced Settings', --Ikemen feature
751- menu_itemname_gameplay_back = 'Back', --Ikemen feature
752848 menu_itemname_video_resolution = 'Resolution', --Ikemen feature
753849 menu_itemname_video_fullscreen = 'Fullscreen', --Ikemen feature
754850 menu_itemname_video_msaa = 'MSAA', --Ikemen feature
755- menu_itemname_video_helpermax = 'HelperMax', --Ikemen feature
756- menu_itemname_video_playerprojectilemax = 'PlayerProjectileMax', --Ikemen feature
757- menu_itemname_video_explodmax = 'ExplodMax', --Ikemen feature
758- menu_itemname_video_afterimagemax = 'AfterImageMax', --Ikemen feature
759- menu_itemname_video_zoomactive = 'Zoom Active', --Ikemen feature
760- menu_itemname_video_maxzoomout = 'Default Max Zoom Out', --Ikemen feature
761- menu_itemname_video_maxzoomin = 'Default Max Zoom In', --Ikemen feature
762- menu_itemname_video_zoomspeed = 'Default Zoom Speed', --Ikemen feature
763- menu_itemname_video_lifebarfontscale = 'Default Lifebar Font Scale', --Ikemen feature
764- menu_itemname_video_aipalette = 'AI Palette', --Ikemen feature
765- menu_itemname_video_aipalette_random = 'Random', --Ikemen feature
766- menu_itemname_video_aipalette_default = 'Default', --Ikemen feature
851+ menu_itemname_video_shader = 'Shader', --Ikemen feature
852+ menu_itemname_video_shader_none = 'None', --Ikemen feature
853+ menu_itemname_video_shader_hqx2 = 'hq2x', --Ikemen feature
854+ menu_itemname_video_shader_hqx4 = 'hqx4', --Ikemen feature
855+ menu_itemname_video_shader_scanlines = 'scanlines', --Ikemen feature
767856 menu_itemname_video_back = 'Back', --Ikemen feature
768857 menu_itemname_res_320x240 = '320x240 (4:3 QVGA)', --Ikemen feature
769858 menu_itemname_res_640x480 = '640x480 (4:3 VGA)', --Ikemen feature
770859 menu_itemname_res_1280x960 = '1280x960 (4:3 Quad-VGA)', --Ikemen feature
771860 menu_itemname_res_1600x1200 = '1600x1200 (4:3 UXGA)', --Ikemen feature
772861 menu_itemname_res_960x720 = '960x720 (4:3 HD)', --Ikemen feature
773- menu_itemname_res_1200x900 = '1200x900 (4:3 HD+)', --Ikemen feature
774- menu_itemname_res_1440x1080 = '1440x1080 (4:3 FHD)', --Ikemen feature
775862 menu_itemname_res_1280x720 = '1280x720 (16:9 HD)', --Ikemen feature
776863 menu_itemname_res_1600x900 = '1600x900 (16:9 HD+)', --Ikemen feature
777864 menu_itemname_res_1920x1080 = '1920x1080 (16:9 FHD)', --Ikemen feature
@@ -779,12 +866,46 @@ local motif =
779866 menu_itemname_res_3840x2160 = '3840x2160 (16:9 4K)', --Ikemen feature
780867 menu_itemname_res_custom = 'Custom', --Ikemen feature
781868 menu_itemname_res_back = 'Back', --Ikemen feature
782- menu_itemname_input_p1keyboard = 'P1 Keyboard', --Ikemen feature
783- menu_itemname_input_p1gamepad = 'P1 Gamepad', --Ikemen feature
784- menu_itemname_input_p2keyboard = 'P2 Keyboard', --Ikemen feature
785- menu_itemname_input_p2gamepad = 'P2 Gamepad', --Ikemen feature
869+ menu_itemname_audio_mastervolume = 'Master Volume', --Ikemen feature
870+ menu_itemname_audio_bgmvolume = 'BGM Volume', --Ikemen feature
871+ menu_itemname_audio_sfxvolume = 'SFX Volume', --Ikemen feature
872+ menu_itemname_audio_audioducking = 'Audio Ducking', --Ikemen feature
873+ menu_itemname_audio_back = 'Back', --Ikemen feature
874+ menu_itemname_gameplay_lifemul = 'Life', --Ikemen feature
875+ menu_itemname_gameplay_autoguard = 'Auto-Guard', --Ikemen feature
876+ menu_itemname_gameplay_attackpowermul = 'Attack.LifeToPowerMul', --Ikemen feature
877+ menu_itemname_gameplay_gethitpowermul = 'GetHit.LifeToPowerMul', --Ikemen feature
878+ menu_itemname_gameplay_superdefencemul = 'Super.TargetDefenceMul', --Ikemen feature
879+ menu_itemname_gameplay_team1vs2life = '1P Vs Team Life', --Ikemen feature
880+ menu_itemname_gameplay_turnsrecoverybase = 'Turns Recovery Base', --Ikemen feature
881+ menu_itemname_gameplay_turnsrecoverybonus = 'Turns Recovery Bonus', --Ikemen feature
882+ menu_itemname_gameplay_teampowershare = 'Team Power Share', --Ikemen feature
883+ menu_itemname_gameplay_teamlifeshare = 'Team Life Share', --Ikemen feature
884+ menu_itemname_gameplay_singlemode = 'Single Mode', --Ikemen feature
885+ menu_itemname_gameplay_numturns = 'Turns Limit', --Ikemen feature
886+ menu_itemname_gameplay_numsimul = 'Simul Limit', --Ikemen feature
887+ menu_itemname_gameplay_numtag = 'Tag Limit', --Ikemen features
888+ menu_itemname_gameplay_advanced = 'Advanced Settings', --Ikemen feature
889+ menu_itemname_gameplay_back = 'Back', --Ikemen feature
890+ menu_itemname_engine_allowdebugkeys = 'Debug Keys', --Ikemen feature
891+ menu_itemname_engine_simulmode = 'Legacy Tag Mode', --Ikemen feature
892+ menu_itemname_engine_helpermax = 'HelperMax', --Ikemen feature
893+ menu_itemname_engine_playerprojectilemax = 'PlayerProjectileMax', --Ikemen feature
894+ menu_itemname_engine_explodmax = 'ExplodMax', --Ikemen feature
895+ menu_itemname_engine_afterimagemax = 'AfterImageMax', --Ikemen feature
896+ menu_itemname_engine_zoomactive = 'Zoom Active', --Ikemen feature
897+ menu_itemname_engine_maxzoomout = 'Default Max Zoom Out', --Ikemen feature
898+ menu_itemname_engine_maxzoomin = 'Default Max Zoom In', --Ikemen feature
899+ menu_itemname_engine_zoomspeed = 'Default Zoom Speed', --Ikemen feature
900+ menu_itemname_engine_lifebarfontscale = 'Lifebar Font Scale', --Ikemen feature
901+ menu_itemname_input_keyboard = 'Key Config', --Ikemen feature
902+ menu_itemname_input_gamepad = 'Joystick Config', --Ikemen feature
903+ menu_itemname_input_system = 'System Keys', --Ikemen feature (not used yet)
786904 menu_itemname_input_default = 'Default Values', --Ikemen feature
787905 menu_itemname_input_back = 'Back', --Ikemen feature
906+ menu_itemname_key_p1 = 'PLAYER 1', --Ikemen feature
907+ menu_itemname_key_p2 = 'PLAYER 2', --Ikemen feature
908+ menu_itemname_key_all = 'Config all', --Ikemen feature
788909 menu_itemname_key_up = 'Up', --Ikemen feature
789910 menu_itemname_key_down = 'Down', --Ikemen feature
790911 menu_itemname_key_left = 'Left', --Ikemen feature
@@ -796,24 +917,35 @@ local motif =
796917 menu_itemname_key_y = 'Y', --Ikemen feature
797918 menu_itemname_key_z = 'Z', --Ikemen feature
798919 menu_itemname_key_start = 'Start', --Ikemen feature
799- menu_itemname_key_v = 'D', --Ikemen feature
920+ menu_itemname_key_d = 'D', --Ikemen feature
800921 menu_itemname_key_w = 'W', --Ikemen feature
801922 menu_itemname_key_back = 'Back', --Ikemen feature
923+ menu_item_key_p1_font = {'f-6x9.def', 4, 0, 255, 255, 255, 255, 0}, --Ikemen feature
924+ menu_item_key_p1_font_scale = {1.0, 1.0}, --Ikemen feature
925+ menu_item_key_p2_font = {'f-6x9.def', 1, 0, 255, 255, 255, 255, 0}, --Ikemen feature
926+ menu_item_key_p2_font_scale = {1.0, 1.0}, --Ikemen feature
927+ menu_item_info_font = {'f-6x9.def', 5, -1, 255, 255, 255, 255, 0}, --Ikemen feature
928+ menu_item_info_font_scale = {1.0, 1.0}, --Ikemen feature
929+ menu_item_info_active_font = {'f-6x9.def', 5, -1, 255, 255, 255, 255, 0}, --Ikemen feature
930+ menu_item_info_active_font_scale = {1.0, 1.0}, --Ikemen feature
931+ menu_itemname_info_f1 = '(F1)', --Ikemen feature
932+ menu_itemname_info_f2 = '(F2)', --Ikemen feature
933+ menu_itemname_info_esc = '(Esc)', --Ikemen feature
934+ menu_itemname_info_disable = 'Not used', --Ikemen feature
935+ menu_item_p1_pos = {91, 33}, --Ikemen feature
936+ menu_item_p2_pos = {230, 33}, --Ikemen feature
937+ menu_key_p1_pos = {39, 33}, --Ikemen feature
938+ menu_key_p2_pos = {178, 33}, --Ikemen feature
939+ menu_key_item_spacing = {101, 13}, --Ikemen feature
940+ menu_key_boxcursor_coords = {-5, -10, 106, 2}, --Ikemen feature
802941 menu_itemname_yes = 'Yes', --Ikemen feature
803942 menu_itemname_no = 'No', --Ikemen feature
804- menu_itemname_main_save = 'Save and Return', --Ikemen feature
805943 menu_itemname_enabled = 'Enabled', --Ikemen feature
806944 menu_itemname_disabled = 'Disabled', --Ikemen feature
807- menu_itemname_audio_mastervolume = 'Master Volume', --Ikemen feature
808- menu_itemname_audio_sfxvolume = 'SFX Volume', --Ikemen feature
809- menu_itemname_audio_bgmvolume = 'BGM Volume', --Ikemen feature
810- menu_itemname_audio_audioducking = 'Audio Ducking', --Ikemen feature
811- menu_itemname_engine_quicklaunch = 'Quick Launch', --Ikemen feature
812- menu_itemname_engine_allowdebugkeys = 'Debug Keys', --Ikemen feature
813945 input_text_port = 'Type in Host Port, e.g. 7500.\nPress ENTER to accept.\nPress ESC to cancel.', --Ikemen feature
814946 input_text_reswidth = 'Type in screen width.\nPress ENTER to accept.\nPress ESC to cancel.', --Ikemen feature
815947 input_text_resheight = 'Type in screen height.\nPress ENTER to accept.\nPress ESC to cancel.', --Ikemen feature
816- input_text_key = 'Press a key to assign to entry.\nPress ESC to cancel.', --Ikemen feature
948+ input_text_key = 'Press a key to assign to entry.\nPress SPACE to disable key.\nPress ESC to cancel.', --Ikemen feature
817949 cursor_move_snd = {100, 0},
818950 cursor_done_snd = {100, 1},
819951 cancel_snd = {100, 2},
@@ -822,8 +954,6 @@ local motif =
822954 {
823955 spr = '',
824956 bgclearcolor = {0, 0, 0},
825- bg = {},
826- timer = 0, --Ikemen feature
827957 },
828958 tournament_info =
829959 {
@@ -836,25 +966,28 @@ local motif =
836966 {
837967 spr = 'data/tournament.sff', --Ikemen feature
838968 bgclearcolor = {0, 0, 0}, --Ikemen feature
839- bg = {}, --Ikemen feature
840- timer = 0, --Ikemen feature
841969 },
842970 warning_info =
843971 {
844972 title = 'WARNING', --Ikemen feature
845973 title_pos = {159, 19}, --Ikemen feature
846- title_font = {'font/f-6x9.fnt', 0, 0, nil, nil, nil}, --Ikemen feature
974+ title_font = {'f-6x9.def', 0, 0, 255, 255, 255, 255, 0}, --Ikemen feature
847975 title_font_scale = {1.0, 1.0}, --Ikemen feature
848976 text_stages = 'No stages in select.def available for random selection.\nPress any key to exit the program.', --Ikemen feature
849- 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
977+ text_order = "Incorrect 'maxmatches' settings detected.\nCheck orders in [Characters] and [Options] sections\nto ensure that at least one battle is possible.\nPress any key to exit the program.", --Ikemen feature
850978 text_training = "Training character ('chars/Training/Training.def') not found.\nPress any key to exit the program.", --Ikemen feature
851979 text_reload = 'Some selected options require Ikemen to be restarted.\nPress any key to exit the program.', --Ikemen feature
852980 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
981+ text_keys = 'Conflict between button keys detected.\nAll keys should have unique assignment.\nFix the problem before exitting key settings.', --Ikemen feature
982+ text_pad = 'Controller not detected.\nCheck if your controller is plugged in.', --Ikemen feature
983+ text_simul = 'This is a legacy option that works only if screenpack \nhas not been updated to support both Tag and Simul \nmode selection in select screen.', --Ikemen feature
853984 text_pos = {25, 33}, --Ikemen feature
854- text_font = {'font/f-6x9.fnt', 0, 1, nil, nil, nil}, --Ikemen feature
985+ text_font = {'f-6x9.def', 0, 1, 255, 255, 255, 255, 0}, --Ikemen feature
855986 text_font_scale = {1.0, 1.0}, --Ikemen feature
856987 text_spacing = {0, 13}, --Ikemen feature
857- background_alpha = {20, 100}, --Ikemen feature
988+ boxbg_coords = {0, 0, localX, localY}, --Ikemen feature (0, 0, 320, 240)
989+ boxbg_col = {0, 0, 0}, --Ikemen feature
990+ boxbg_alpha = {20, 100}, --Ikemen feature
858991 },
859992 anim =
860993 {
@@ -1288,120 +1421,39 @@ local motif =
12881421 '101,75, -32,8, -1', --1593+
12891422 },
12901423 },
1291- ctrldef = {
1292- titlebgdef = {},
1293- selectbgdef = {},
1294- versusbgdef = {},
1295- optionbgdef = {},
1296- continuebgdef = {},
1297- victorybgdef = {},
1298- resultsbgdef = {},
1299- tournamentbgdef = {},
1300- }
13011424 }
13021425
13031426 --;===========================================================
13041427 --; PARSE SCREENPACK
13051428 --;===========================================================
13061429 --here starts proper screenpack DEF file parsing
1307-local sp = config.Motif
1308-if main.flags['-r'] ~= nil then
1309- if main.f_fileExists(main.flags['-r']) then
1310- sp = main.flags['-r']
1311- elseif main.f_fileExists('data/' .. main.flags['-r'] .. '/system.def') then
1312- sp = 'data/' .. main.flags['-r'] .. '/system.def'
1313- end
1314-end
1315-local file = io.open(sp, 'r')
1316-local fileDir, fileName = sp:match('^(.-)([^/\\]+)$')
1430+main.t_sort = {}
13171431 local t = {}
13181432 local pos = t
1433+local pos_sort = main.t_sort
13191434 local def_pos = motif
13201435 t.anim = {}
1321-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')}
1322-t.ctrldef = {}
1436+t.font_data = {['f-4x6.def'] = fontNew('f-4x6.def'), ['f-6x9.def'] = fontNew('f-6x9.def'), ['jg.fnt'] = fontNew('jg.fnt')}
1437+local fileDir, fileName = motif.def:match('^(.-)([^/\\]+)$')
13231438 t.fileDir = fileDir
13241439 t.fileName = fileName
1325-local bgdef = 'dummyUntilSet'
1326-local bgctrl = ''
1327-local bgctrl_match = 'dummyUntilSet'
13281440 local tmp = ''
1441+file = io.open(motif.def, 'r')
13291442 for line in file:lines() do
13301443 line = line:gsub('%s*;.*$', '')
13311444 if line:match('^%s*%[.-%s*%]%s*$') then --matched [] group
13321445 line = line:match('^%s*%[(.-)%s*%]%s*$') --match text between []
13331446 line = line:gsub('[%. ]', '_') --change . and space to _
1334- line = line:lower() --lowercase line
1335- local row = tostring(line:lower()) --just in case it's a number (not really needed)
1336- if row:match('.+ctrldef') then --matched ctrldef start
1337- bgctrl = row
1338- bgctrl_match = bgctrl:match('^(.-ctrl)def')
1339- t.ctrldef[bgdef .. 'def'][bgctrl] = {}
1340- t.ctrldef[bgdef .. 'def'][bgctrl].ctrl = {}
1341- pos = t.ctrldef[bgdef .. 'def'][bgctrl]
1342- motif.ctrldef[bgdef .. 'def'][bgctrl] = {
1343- looptime = -1,
1344- ctrlid = {0},
1345- ctrl = {}
1346- }
1347- elseif row:match('^' .. bgctrl_match) then --matched ctrldef content
1348- tmp = t.ctrldef[bgdef .. 'def'][bgctrl].ctrl
1349- tmp[#tmp + 1] = {}
1350- pos = tmp[#tmp]
1351- motif.ctrldef[bgdef .. 'def'][bgctrl].ctrl[#tmp] = {
1352- type = 'null',
1353- time = {0, -1, -1},
1354- ctrlid = {}
1355- }
1356- elseif row:match('.+bgdef$') then --matched bgdef start
1357- t[row] = {}
1358- pos = t[row]
1359- t[row].bg = {}
1360- bgdef = row:match('(.+)def$')
1361- t.ctrldef[bgdef .. 'def'] = {}
1362- elseif row:match('^' .. bgdef) then --matched bgdef content
1363- tmp = t[bgdef .. 'def']
1364- tmp.bg[#tmp.bg + 1] = {}
1365- pos = tmp.bg[#tmp.bg]
1366- motif[bgdef .. 'def'].bg[#tmp.bg] =
1367- {
1368- type = 'normal',
1369- spriteno = {0, 0},
1370- id = 0,
1371- layerno = 0,
1372- start = {0, 0},
1373- delta = {1, 1},
1374- trans = '',
1375- mask = 0,
1376- tile = {0, 0},
1377- tilespacing = {0, nil},
1378- --window = {0, 0, 0, 0},
1379- --windowdelta = {0, 0}, --not supported yet
1380- --width = {0, 0}, --not supported yet (parallax)
1381- --xscale = {1.0, 1.0}, --not supported yet (parallax)
1382- --yscalestart = 100, --not supported yet (parallax)
1383- --yscaledelta = 1, --not supported yet (parallax)
1384- positionlink = 0,
1385- velocity = {0, 0},
1386- --sin_x = {0, 0, 0}, --not supported yet
1387- --sin_y = {0, 0, 0}, --not supported yet
1388- ctrl = {},
1389- ctrl_flags = {
1390- visible = 1,
1391- enabled = 1,
1392- velx = 0,
1393- vely = 0,
1394- x = 0,
1395- y = 0
1396- }
1397- }
1398- elseif row:match('^begin_action_[0-9]+$') then --matched anim
1447+ local row = tostring(line:lower())
1448+ if row:match('^begin_action_[0-9]+$') then --matched anim
13991449 row = tonumber(row:match('^begin_action_([0-9]+)$'))
14001450 t.anim[row] = {}
14011451 pos = t.anim[row]
14021452 else --matched other []
14031453 t[row] = {}
1454+ main.t_sort[row] = {}
14041455 pos = t[row]
1456+ pos_sort = main.t_sort[row]
14051457 def_pos = motif[row]
14061458 end
14071459 else --matched non [] line
@@ -1409,7 +1461,7 @@ for line in file:lines() do
14091461 if param ~= nil then
14101462 param = param:gsub('[%. ]', '_') --change param . and space to _
14111463 param = param:lower() --lowercase param
1412- if value ~= nil and def_pos ~= nil then -- Let's chech if it's even a valid param
1464+ if value ~= nil and def_pos ~= nil then --let's check if it's even a valid param
14131465 if value == '' and (type(def_pos[param]) == 'number' or type(def_pos[param]) == 'table') then --text should remain empty
14141466 value = '0'
14151467 end
@@ -1419,7 +1471,7 @@ for line in file:lines() do
14191471 value = value:gsub('"', '') --remove brackets from value
14201472 value = value:gsub('^(%.[0-9])', '0%1') --add 0 before dot if missing at the beginning of matched string
14211473 value = value:gsub('([^0-9])(%.[0-9])', '%10%2') --add 0 before dot if missing anywhere else
1422- if param:match('^font[0-9]+$') then --font declaration param matched
1474+ if param:match('^font[0-9]+') then --font declaration param matched
14231475 local num = tonumber(param:match('font([0-9]+)'))
14241476 if param:match('_height$') then
14251477 if pos.font_height == nil then
@@ -1427,21 +1479,7 @@ for line in file:lines() do
14271479 end
14281480 pos.font_height[num] = main.f_dataType(value)
14291481 else
1430- value = value:lower()
14311482 value = value:gsub('\\', '/')
1432- if t.font_data[value] == nil then
1433- if not value:match('^data/') then
1434- if main.f_fileExists(fileDir .. value) then
1435- value = fileDir .. value
1436- elseif main.f_fileExists('font/' .. value) then
1437- value = 'font/' .. value
1438- elseif main.f_fileExists(t.files.fight:match('^(.-)[^/\\]+$') .. value) then
1439- value = t.files.fight:match('^(.-)[^/\\]+$') .. value
1440- end
1441- end
1442- t.font_data[value] = fontNew(value)
1443- wait = true
1444- end
14451483 if pos.font == nil then
14461484 pos.font = {}
14471485 end
@@ -1456,26 +1494,33 @@ for line in file:lines() do
14561494 elseif i == 1 then
14571495 pos[param] = {}
14581496 if param:match('_font$') then
1459- c = t.files.font[tonumber(c)]
1497+ if t.files ~= nil and t.files.font ~= nil and t.files.font[tonumber(c)] ~= nil then --in case font is used before it's declared in DEF file
1498+ c = t.files.font[tonumber(c)]
1499+ else
1500+ break --use default font values
1501+ end
14601502 end
14611503 end
14621504 if c == nil or c == '' then
1463- pos[param][#pos[param] + 1] = 0
1505+ table.insert(pos[param], 0)
14641506 else
1465- pos[param][#pos[param] + 1] = main.f_dataType(c)
1507+ table.insert(pos[param], main.f_dataType(c))
14661508 end
14671509 end
14681510 else --single value
1511+ if param:match('_itemname_') then
1512+ table.insert(pos_sort, param:match('_itemname_(.+)$'))
1513+ end
14691514 pos[param] = main.f_dataType(value)
14701515 end
14711516 end
14721517 else --only valid lines left are animations
14731518 line = line:lower()
1474- 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') or line:match('^%s*interpolate offset') or line:match('^%s*interpolate angle') or line:match('^%s*interpolate scale') or line:match('^%s*interpolate blend')
1519+ 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') or line:match('%s*interpolate [oasb][fncl][fgae][sln][ed]t?')
14751520 if value ~= nil then
14761521 value = value:gsub(',%s*,', ',0,') --add missing values
14771522 value = value:gsub(',%s*$', '')
1478- pos[#pos + 1] = value
1523+ table.insert(pos, value)
14791524 end
14801525 end
14811526 end
@@ -1486,8 +1531,15 @@ file:close()
14861531 --;===========================================================
14871532 --; FIX REFERENCES, LOAD DATA
14881533 --;===========================================================
1489-local anim = ''
1490-local facing = ''
1534+--adopt old DEF code to Ikemen features
1535+if type(motif.select_info.cell_spacing) ~= "table" then
1536+ motif.select_info.cell_spacing = {motif.select_info.cell_spacing[1], motif.select_info.cell_spacing[1]}
1537+end
1538+
1539+if motif.victory_screen.enabled == 0 then
1540+ motif.victory_screen.cpu_enabled = 0
1541+ motif.victory_screen.vs_enabled = 0
1542+end
14911543
14921544 --merge tables
14931545 motif = main.f_tableMerge(motif, t)
@@ -1534,40 +1586,11 @@ main.loadingRefresh()
15341586 motif.files.continue_snd_data = sndNew(motif.files.continue_snd)
15351587 main.loadingRefresh()
15361588
1537---fadein / fadeout data
1538-t_dir = {'title_info', 'select_info', 'vs_screen', 'victory_screen', 'win_screen', 'survival_results_screen', 'vs100kumite_results_screen', 'option_info', 'tournament_info', 'continue_screen'}
1539-for i = 1, #t_dir do
1540- 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])
1541- animSetWindow(motif[t_dir[i]].fadein_data, main.screenOverscan, 0, motif.info.localcoord[1], motif.info.localcoord[2])
1542- 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])
1543- animSetWindow(motif[t_dir[i]].fadeout_data, main.screenOverscan, 0, motif.info.localcoord[1], motif.info.localcoord[2])
1544-end
1545-
1546---other entries
1589+--data
1590+local anim = ''
1591+local facing = ''
15471592 t_dir = {'titlebgdef', 'selectbgdef', 'versusbgdef', 'optionbgdef', 'continuebgdef', 'victorybgdef', 'resultsbgdef', 'tournamentbgdef'}
15481593 for i = 1, #t_dir do
1549- --ctrldef table adjustment
1550- for k, v in pairs(motif.ctrldef[t_dir[i]]) do
1551- tmp = motif.ctrldef[t_dir[i]][k].ctrl
1552- for j = 1, #tmp do
1553- --if END_TIME is omitted it should default to the same value as START_TIME
1554- if tmp[j].time[2] == -1 then
1555- tmp[j].time[2] = tmp[j].time[1]
1556- end
1557- --if LOOPTIME is omitted or set to -1, the background controller will not reset its own timer. In such case use GLOBAL_LOOPTIME
1558- if tmp[j].time[3] == -1 then
1559- tmp[j].time[3] = motif.ctrldef[t_dir[i]][k].looptime
1560- end
1561- --lowercase type name
1562- tmp[j].type = tmp[j].type:lower()
1563- --this list, if specified, overrides the default list specified in the BGCtrlDef
1564- if #tmp[j].ctrlid == 0 then
1565- for z = 1, #motif.ctrldef[t_dir[i]][k].ctrlid do
1566- tmp[j].ctrlid[#tmp[j].ctrlid + 1] = motif.ctrldef[t_dir[i]][k].ctrlid[z]
1567- end
1568- end
1569- end
1570- end
15711594 --optional sff paths and data
15721595 if motif[t_dir[i]].spr ~= '' then
15731596 if not motif[t_dir[i]].spr:match('^data/') then
@@ -1577,81 +1600,26 @@ for i = 1, #t_dir do
15771600 motif[t_dir[i]].spr = 'data/' .. motif[t_dir[i]].spr
15781601 end
15791602 end
1580- motif[t_dir[i]].spr_data = sffNew(motif[t_dir[i]].spr)
1603+ motif[t_dir[i]].spr_data = sffNew(motif[t_dir[i]].spr) --does sff work with all data or just backgrounds? If the latter then it's not needed
15811604 main.loadingRefresh()
15821605 elseif motif[t_dir[i]].spr ~= 'continuebgdef' and motif[t_dir[i]].spr ~= 'tournamentbgdef' then
15831606 motif[t_dir[i]].spr = motif.files.spr
15841607 motif[t_dir[i]].spr_data = motif.files.spr_data
15851608 end
1586- --clearcolor data
1587- 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])
1588- animSetWindow(motif[t_dir[i]].bgclearcolor_data, main.screenOverscan, 0, motif.info.localcoord[1], motif.info.localcoord[2])
1589- --background data
1590- motif[t_dir[i]].bg_data = {}
1591- local t_bgdef = motif[t_dir[i]].bg
1592- local prev_k = ''
1593- for k, v in pairs(t_bgdef) do --loop through table keys
1594- t_bgdef[k].type = t_bgdef[k].type:lower()
1595- --mugen ignores delta = 0 (defaults to 1)
1596- if t_bgdef[k].delta[1] == 0 then t_bgdef[k].delta[1] = 1 end
1597- if t_bgdef[k].delta[2] == 0 then t_bgdef[k].delta[2] = 1 end
1598- --add ctrl data
1599- motif[t_dir[i]].bg[k].ctrl = main.f_ctrlBG(t_bgdef[k], motif.ctrldef[t_dir[i]])
1600- --positionlink adjustment
1601- if t_bgdef[k].positionlink == 1 and prev_k ~= '' then
1602- t_bgdef[k].start[1] = t_bgdef[prev_k].start[1]
1603- t_bgdef[k].start[2] = t_bgdef[prev_k].start[2]
1604- t_bgdef[k].delta[1] = t_bgdef[prev_k].delta[1]
1605- t_bgdef[k].delta[2] = t_bgdef[prev_k].delta[2]
1606- end
1607- prev_k = k
1608- --generate anim data
1609- local sizeX, sizeY, offsetX, offsetY = 0, 0, 0, 0
1610- if t_bgdef[k].type == 'anim' then
1611- 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])
1612- else --normal, parallax
1613- anim = t_bgdef[k].spriteno[1] .. ', ' .. t_bgdef[k].spriteno[2] .. ', ' .. (t_bgdef[k].start[1] + main.normalSpriteCenter) .. ', ' .. t_bgdef[k].start[2] .. ', ' .. -1
1614- anim = animNew(motif[t_dir[i]].spr_data, anim)
1615- sizeX, sizeY, offsetX, offsetY = getSpriteInfo(motif[t_dir[i]].spr, t_bgdef[k].spriteno[1], t_bgdef[k].spriteno[2])
1616- end
1617- if t_bgdef[k].trans == 'add1' then
1618- animSetAlpha(anim, 255, 128)
1619- elseif t_bgdef[k].trans == 'add' then
1620- animSetAlpha(anim, 255, 255)
1621- elseif t_bgdef[k].trans == 'sub' then
1622- animSetAlpha(anim, 1, 255)
1623- end
1624- animAddPos(anim, 160, 0) --for some reason needed in ikemen
1625- if t_bgdef[k].window ~= nil and t_bgdef[k].window[1] ~= nil and t_bgdef[k].window[2] ~= nil and t_bgdef[k].window[3] ~= nil and t_bgdef[k].window[4] ~= nil then
1626- animSetWindow(
1627- anim,
1628- t_bgdef[k].window[1],
1629- t_bgdef[k].window[2],
1630- t_bgdef[k].window[3] - t_bgdef[k].window[1] + 1,
1631- t_bgdef[k].window[4] - t_bgdef[k].window[2] + 1
1632- )
1633- else
1634- animSetWindow(anim, main.screenOverscan, 0, motif.info.localcoord[1], motif.info.localcoord[2])
1635- end
1636- if t_bgdef[k].tilespacing[2] == nil then t_bgdef[k].tilespacing[2] = t_bgdef[k].tilespacing[1] end
1637- if t_bgdef[k].type == 'parallax' then
1638- animSetTile(anim, t_bgdef[k].tile[1], 0, t_bgdef[k].tilespacing[1] + sizeX, t_bgdef[k].tilespacing[2] + sizeY)
1639- else
1640- animSetTile(anim, t_bgdef[k].tile[1], t_bgdef[k].tile[2], t_bgdef[k].tilespacing[1] + sizeX, t_bgdef[k].tilespacing[2] + sizeY)
1641- end
1642- if t_bgdef[k].mask == 1 or t_bgdef[k].type ~= 'normal' or (t_bgdef[k].trans ~= '' and t_bgdef[k].trans ~= 'none') then
1643- animSetColorKey(anim, 0)
1609+ --backgrounds
1610+ motif[t_dir[i]].bg = bgNew(motif.def, t_dir[i]:match('^(.+)def$'), motif[t_dir[i]].spr)
1611+ main.loadingRefresh()
1612+end
1613+
1614+for k, v in pairs(motif.files.font) do --loop through table keys
1615+ if v ~= '' and motif.font_data[v] == nil then
1616+ if motif.files.font_height[k] ~= nil then
1617+ motif.font_data[v] = fontNew(v, motif.files.font_height[k])
16441618 else
1645- animSetColorKey(anim, -1)
1619+ motif.font_data[v] = fontNew(v)
16461620 end
1647-
1648- -- Scale non animated sprites
1649- animUpdate(anim)
1650- animSetScale(anim, 1 ,1)
1651-
1652- motif[t_dir[i]].bg_data[k] = anim
1653- main.loadingRefresh()
16541621 end
1622+ main.loadingRefresh()
16551623 end
16561624
16571625 local function f_facing(var)
@@ -1662,27 +1630,6 @@ local function f_facing(var)
16621630 end
16631631 end
16641632
1665-local function f_alphaToTable(var) --not used yet
1666- var = var:match('^%s*(.-)%s*$')
1667- var = var:lower()
1668- if var:match('^a$') then
1669- return {255, 255} --AS256D256
1670- elseif var:match('^a1$') then
1671- return {255, 128} --AS256D128
1672- elseif var:match('^s$') then
1673- return {1, 255} --AS0D256
1674- elseif var:match('^s1$') then
1675- return {1, 128} --are these values correct for S1?
1676- elseif var:match('^as[0-9]+d[0-9]+$') then
1677- local tabl = {}
1678- tabl[1] = tonumber(var:match('^as([0-9]+)'))
1679- tabl[2] = tonumber(var:match('d([0-9]+)$'))
1680- return tabl
1681- else
1682- return nil
1683- end
1684-end
1685-
16861633 t = motif.select_info
16871634 t_dir = {
16881635 {s = 'cell_bg_', x = 0, y = 0},
@@ -1703,21 +1650,12 @@ t_dir = {
17031650 {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]},
17041651 {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]},
17051652 {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]},
1653+ {s = 'stage_portrait_random_', x = t.stage_pos[1] + t.stage_portrait_offset[1], y = t.stage_pos[2] + t.stage_portrait_offset[2]},
1654+
17061655 }
17071656 for i = 1, #t_dir do
1708- --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_
1709- -- for j = 1, #motif.anim[t[t_dir[i].s .. 'anim']] do
1710- -- for k, c in ipairs(main.f_strsplit(',', motif.anim[t[t_dir[i].s .. 'anim']][j])) do
1711- -- if c:match('loopstart') then
1712- -- break
1713- -- elseif k <= 2 then
1714- -- t[t_dir[i].s .. 'spr'][k] = tonumber(c)
1715- -- elseif k == 7 and type(c) == 'string' then
1716- -- t[t_dir[i].s .. 'alpha'] = f_alphaToTable(c)
1717- -- end
1718- -- end
1719- -- end
1720- --end
1657+ --if t[t_dir[i].s .. 'offset'] == nil then t[t_dir[i].s .. 'offset'] = {0, 0} end
1658+ --if t[t_dir[i].s .. 'scale'] == nil then t[t_dir[i].s .. 'scale'] = {1.0, 1.0} end
17211659 if #t[t_dir[i].s .. 'spr'] > 0 then --create sprite data
17221660 if #t[t_dir[i].s .. 'spr'] == 1 then --fix values
17231661 if type(t[t_dir[i].s .. 'spr'][1]) == 'string' then
@@ -1746,7 +1684,6 @@ for i = 1, #t_dir do
17461684 animUpdate(t[t_dir[i].s .. 'data'])
17471685 end
17481686 animSetWindow(t[t_dir[i].s .. 'data'], main.screenOverscan, 0, motif.info.localcoord[1], motif.info.localcoord[2])
1749- --animAddPos(t[t_dir[i].s .. 'data'], 160, 0) --for some reason needed in ikemen (but not in this case)
17501687 main.loadingRefresh()
17511688 end
17521689
@@ -1764,15 +1701,32 @@ if motif.anim[t.continue_anim] ~= nil then
17641701 end
17651702
17661703 if motif.vs_screen.p1_name_active_font == nil then
1767- 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]}
1704+ motif.vs_screen.p1_name_active_font = {
1705+ motif.vs_screen.p1_name_font[1],
1706+ motif.vs_screen.p1_name_font[2],
1707+ motif.vs_screen.p1_name_font[3],
1708+ motif.vs_screen.p1_name_font[4],
1709+ motif.vs_screen.p1_name_font[5],
1710+ motif.vs_screen.p1_name_font[6],
1711+ motif.vs_screen.p1_name_font[7],
1712+ motif.vs_screen.p1_name_font[8]
1713+ }
17681714 motif.vs_screen.p1_name_active_font_scale = {motif.vs_screen.p1_name_font_scale[1], motif.vs_screen.p1_name_font_scale[2]}
17691715 end
17701716 if motif.vs_screen.p2_name_active_font == nil then
1771- 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]}
1717+ motif.vs_screen.p2_name_active_font = {
1718+ motif.vs_screen.p2_name_font[1],
1719+ motif.vs_screen.p2_name_font[2],
1720+ motif.vs_screen.p2_name_font[3],
1721+ motif.vs_screen.p2_name_font[4],
1722+ motif.vs_screen.p2_name_font[5],
1723+ motif.vs_screen.p2_name_font[6],
1724+ motif.vs_screen.p2_name_font[7],
1725+ motif.vs_screen.p2_name_font[8]
1726+ }
17721727 motif.vs_screen.p2_name_active_font_scale = {motif.vs_screen.p2_name_font_scale[1], motif.vs_screen.p2_name_font_scale[2]}
17731728 end
17741729
1775---motif.ctrldef = nil
17761730 main.f_printTable(motif, "debug/t_motif.txt")
17771731
17781732 return motif
--- a/script/options.lua
+++ b/script/options.lua
@@ -2,29 +2,26 @@
22 local options = {}
33
44 --;===========================================================
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---;===========================================================
185 --; COMMON
196 --;===========================================================
207 local modified = 0
21-local modifiedlifebar = 0
228 local needReload = 0
239
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)
10+if config.RoundsNumSingle == -1 then
11+ options.roundsNumSingle = getMatchWins()
12+else
13+ options.roundsNumSingle = config.RoundsNumSingle
14+end
15+if config.RoundsNumTeam == -1 then
16+ options.roundsNumTeam = getMatchWins()
17+else
18+ options.roundsNumTeam = config.RoundsNumTeam
19+end
20+if config.MaxDrawGames == -2 then
21+ options.maxDrawGames = getMatchMaxDrawGames()
22+else
23+ options.maxDrawGames = config.MaxDrawGames
24+end
2825
2926 --return string depending on bool
3027 function options.f_boolDisplay(bool, t, f)
@@ -37,15 +34,12 @@ function options.f_boolDisplay(bool, t, f)
3734 end
3835 end
3936
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
37+--return table entry if provided key exists there, otherwise return default argument
38+function options.f_definedDisplay(key, t, default)
39+ if t[key] ~= nil then
40+ return t[key]
4841 end
42+ return default
4943 end
5044
5145 --return correct precision
@@ -53,20 +47,12 @@ function options.f_precision(v, decimal)
5347 return tonumber(string.format(decimal, v))
5448 end
5549
50+--save configuration
5651 function options.f_saveCfg()
5752 --Data saving to config.json
5853 local file = io.open("save/config.json","w+")
5954 file:write(json.encode(config, {indent = true}))
6055 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
7056 --Reload game if needed
7157 if needReload == 1 then
7258 main.f_warning(main.f_extractText(motif.warning_info.text_reload), motif.option_info, motif.optionbgdef)
@@ -74,62 +60,134 @@ function options.f_saveCfg()
7460 end
7561 end
7662
63+--reset key settings
7764 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'
65+ for i = 1, #config.KeyConfig do
66+ if i == 1 then
67+ config.KeyConfig[i].Buttons[1] = 'UP'
68+ config.KeyConfig[i].Buttons[2] = 'DOWN'
69+ config.KeyConfig[i].Buttons[3] = 'LEFT'
70+ config.KeyConfig[i].Buttons[4] = 'RIGHT'
71+ config.KeyConfig[i].Buttons[5] = 'z'
72+ config.KeyConfig[i].Buttons[6] = 'x'
73+ config.KeyConfig[i].Buttons[7] = 'c'
74+ config.KeyConfig[i].Buttons[8] = 'a'
75+ config.KeyConfig[i].Buttons[9] = 's'
76+ config.KeyConfig[i].Buttons[10] = 'd'
77+ config.KeyConfig[i].Buttons[11] = 'RETURN'
78+ config.KeyConfig[i].Buttons[12] = 'q'
79+ config.KeyConfig[i].Buttons[13] = 'w'
80+ elseif i == 2 then
81+ config.KeyConfig[i].Buttons[1] = 't'
82+ config.KeyConfig[i].Buttons[2] = 'g'
83+ config.KeyConfig[i].Buttons[3] = 'f'
84+ config.KeyConfig[i].Buttons[4] = 'h'
85+ config.KeyConfig[i].Buttons[5] = 'j'
86+ config.KeyConfig[i].Buttons[6] = 'k'
87+ config.KeyConfig[i].Buttons[7] = 'l'
88+ config.KeyConfig[i].Buttons[8] = 'u'
89+ config.KeyConfig[i].Buttons[9] = 'i'
90+ config.KeyConfig[i].Buttons[10] = 'o'
91+ config.KeyConfig[i].Buttons[11] = 'RSHIFT'
92+ config.KeyConfig[i].Buttons[12] = 'LEFTBRACKET'
93+ config.KeyConfig[i].Buttons[13] = 'RIGHTBRACKET'
94+ else
95+ for j = 1, #config.KeyConfig[i].Buttons do
96+ config.KeyConfig[i].Buttons[j] = tostring(motif.option_info.menu_itemname_info_disable)
97+ end
98+ end
99+ end
100+ for i = 1, #config.JoystickConfig do
101+ config.JoystickConfig[i].Buttons[1] = '-3'
102+ config.JoystickConfig[i].Buttons[2] = '-4'
103+ config.JoystickConfig[i].Buttons[3] = '-1'
104+ config.JoystickConfig[i].Buttons[4] = '-2'
105+ config.JoystickConfig[i].Buttons[5] = '0'
106+ config.JoystickConfig[i].Buttons[6] = '1'
107+ config.JoystickConfig[i].Buttons[7] = '4'
108+ config.JoystickConfig[i].Buttons[8] = '2'
109+ config.JoystickConfig[i].Buttons[9] = '3'
110+ config.JoystickConfig[i].Buttons[10] = '5'
111+ config.JoystickConfig[i].Buttons[11] = '7'
112+ config.JoystickConfig[i].Buttons[12] = '-10'
113+ config.JoystickConfig[i].Buttons[13] = '-12'
114+ end
115+ resetRemapInput()
116+end
117+
118+--reset vardisplay in tables
119+function options.f_resetTables()
120+ local t_displaynameReset = {
121+ t_mainCfg = {
122+ portchange = getListenPort(),
123+ },
124+ t_arcadeCfg = {
125+ roundtime = options.f_definedDisplay(config.RoundTime, {[-1] = motif.option_info.menu_itemname_arcade_roundtime_none}, config.RoundTime),
126+ roundsnumsingle = options.roundsNumSingle,
127+ roundsnumteam = options.roundsNumTeam,
128+ maxdrawgames = options.maxDrawGames,
129+ difficulty = config.Difficulty,
130+ credits = config.Credits,
131+ charchange = options.f_boolDisplay(config.ContSelection),
132+ airamping = options.f_boolDisplay(config.AIRamping),
133+ airandomcolor = options.f_boolDisplay(config.AIRandomColor, motif.option_info.menu_itemname_arcade_aipalette_random, motif.option_info.menu_itemname_arcade_aipalette_default),
134+ },
135+ t_videoCfg = {
136+ resolution = config.Width .. 'x' .. config.Height,
137+ fullscreen = options.f_boolDisplay(config.Fullscreen),
138+ msaa = options.f_boolDisplay(config.MSAA, motif.option_info.menu_itemname_enabled, motif.option_info.menu_itemname_disabled),
139+ postprocessingshader = options.t_shaderNames[config.PostProcessingShader],
140+ },
141+ t_audioCfg = {
142+ mastervolume = config.MasterVolume .. '%',
143+ bgmvolume = config.BgmVolume .. '%',
144+ sfxvolume = config.WavVolume .. '%',
145+ audioducking = options.f_boolDisplay(config.AudioDucking, motif.option_info.menu_itemname_enabled, motif.option_info.menu_itemname_disabled),
146+ },
147+ t_gameplayCfg = {
148+ lifemul = config.LifeMul .. '%',
149+ autoguard = options.f_boolDisplay(config.AutoGuard),
150+ team1vs2life = config.Team1VS2Life .. '%',
151+ turnsrecoverybase = config.TurnsRecoveryBase .. '%',
152+ turnsrecoverybonus = config.TurnsRecoveryBonus .. '%',
153+ teampowershare = options.f_boolDisplay(config.TeamPowerShare),
154+ teamlifeshare = options.f_boolDisplay(config.TeamLifeShare),
155+ },
156+ t_advGameplayCfg = {
157+ attackpowermul = config['Attack.LifeToPowerMul'],
158+ gethitpowermul = config['GetHit.LifeToPowerMul'],
159+ superdefencemul = config['Super.TargetDefenceMul'],
160+ singlemode = options.f_boolDisplay(config.SingleTeamMode, motif.option_info.menu_itemname_enabled, motif.option_info.menu_itemname_disabled),
161+ numturns = options.f_checkTeamAmount(config.NumTurns, 1, motif.option_info.menu_itemname_disabled),
162+ numsimul = options.f_checkTeamAmount(config.NumSimul, 1, motif.option_info.menu_itemname_disabled),
163+ numtag = options.f_checkTeamAmount(config.NumTag, 1, motif.option_info.menu_itemname_disabled),
164+ },
165+ t_engineCfg = {
166+ allowdebugkeys = options.f_boolDisplay(config.AllowDebugKeys, motif.option_info.menu_itemname_enabled, motif.option_info.menu_itemname_disabled),
167+ simulmode = options.f_boolDisplay(config.SimulMode, motif.option_info.menu_itemname_disabled, motif.option_info.menu_itemname_enabled),
168+ lifebarfontscale = config.LifebarFontScale,
169+ helpermax = config.HelperMax,
170+ playerprojectilemax = config.PlayerProjectileMax,
171+ explodmax = config.ExplodMax,
172+ afterimagemax = config.AfterImageMax,
173+ zoomactive = options.f_boolDisplay(config.ZoomActive),
174+ maxzoomout = config.ZoomMin,
175+ maxzoomin = config.ZoomMax,
176+ zoomspeed = config.ZoomSpeed,
177+ },
178+ }
179+ for k1, v1 in pairs(t_displaynameReset) do
180+ for k2, v2 in pairs(t_displaynameReset[k1]) do
181+ for i = 1, #options[k1] do
182+ if options[k1][i].itemname == k2 then
183+ options[k1][i].vardisplay = v2
184+ end
185+ end
186+ end
187+ end
130188 end
131189
132-function options.f_menuCommon1(cursorPosY, moveTxt, item, t)
190+function options.f_menuCommonCalc(cursorPosY, moveTxt, item, t)
133191 if commandGetState(main.p1Cmd, 'u') then
134192 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
135193 item = item - 1
@@ -184,33 +242,35 @@ local txt_title = main.f_createTextImg(
184242 motif.option_info.title_font_scale[2],
185243 motif.option_info.title_font[4],
186244 motif.option_info.title_font[5],
187- motif.option_info.title_font[6]
245+ motif.option_info.title_font[6],
246+ motif.option_info.title_font[7],
247+ motif.option_info.title_font[8]
188248 )
189-function options.f_menuCommon2(cursorPosY, moveTxt, item, t)
249+function options.f_menuCommonDraw(cursorPosY, moveTxt, item, t, fadeType)
250+ fadeType = fadeType or 'fadein'
190251 --draw clearcolor
191- animDraw(motif.optionbgdef.bgclearcolor_data)
252+ clearColor(motif.optionbgdef.bgclearcolor[1], motif.optionbgdef.bgclearcolor[2], motif.optionbgdef.bgclearcolor[3])
192253 --draw layerno = 0 backgrounds
193- main.f_drawBG(motif.optionbgdef.bg_data, motif.optionbgdef.bg, 0, motif.optionbgdef.timer, {320,240})
254+ bgDraw(motif.optionbgdef.bg, false)
194255 --draw menu box
195- if motif.option_info.menu_boxbackground_visible == 1 then
256+ if motif.option_info.menu_boxbg_visible == 1 then
257+ local coord4 = 0
196258 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- )
259+ coord4 = motif.option_info.menu_window_visibleitems * (motif.option_info.menu_boxcursor_coords[4] - motif.option_info.menu_boxcursor_coords[2] + 1) + main.f_oddRounding(motif.option_info.menu_boxcursor_coords[2])
204260 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- )
261+ coord4 = #t * (motif.option_info.menu_boxcursor_coords[4] - motif.option_info.menu_boxcursor_coords[2] + 1) + main.f_oddRounding(motif.option_info.menu_boxcursor_coords[2])
212262 end
213- animDraw(windowBox)
263+ fillRect(
264+ motif.option_info.menu_pos[1] + motif.option_info.menu_boxcursor_coords[1],
265+ motif.option_info.menu_pos[2] + motif.option_info.menu_boxcursor_coords[2],
266+ motif.option_info.menu_boxcursor_coords[3] - motif.option_info.menu_boxcursor_coords[1] + 1,
267+ coord4,
268+ motif.option_info.menu_boxbg_col[1],
269+ motif.option_info.menu_boxbg_col[2],
270+ motif.option_info.menu_boxbg_col[3],
271+ motif.option_info.menu_boxbg_alpha[1],
272+ motif.option_info.menu_boxbg_alpha[2]
273+ )
214274 end
215275 --draw title
216276 textImgDraw(txt_title)
@@ -230,7 +290,9 @@ function options.f_menuCommon2(cursorPosY, moveTxt, item, t)
230290 motif.option_info.menu_item_active_font_scale[2],
231291 motif.option_info.menu_item_active_font[4],
232292 motif.option_info.menu_item_active_font[5],
233- motif.option_info.menu_item_active_font[6]
293+ motif.option_info.menu_item_active_font[6],
294+ motif.option_info.menu_item_active_font[7],
295+ motif.option_info.menu_item_active_font[8]
234296 ))
235297 if t[i].vardata ~= nil then
236298 textImgDraw(main.f_updateTextImg(
@@ -245,7 +307,9 @@ function options.f_menuCommon2(cursorPosY, moveTxt, item, t)
245307 motif.option_info.menu_item_value_active_font_scale[2],
246308 motif.option_info.menu_item_value_active_font[4],
247309 motif.option_info.menu_item_value_active_font[5],
248- motif.option_info.menu_item_value_active_font[6]
310+ motif.option_info.menu_item_value_active_font[6],
311+ motif.option_info.menu_item_value_active_font[7],
312+ motif.option_info.menu_item_value_active_font[8]
249313 ))
250314 end
251315 else
@@ -261,7 +325,9 @@ function options.f_menuCommon2(cursorPosY, moveTxt, item, t)
261325 motif.option_info.menu_item_font_scale[2],
262326 motif.option_info.menu_item_font[4],
263327 motif.option_info.menu_item_font[5],
264- motif.option_info.menu_item_font[6]
328+ motif.option_info.menu_item_font[6],
329+ motif.option_info.menu_item_font[7],
330+ motif.option_info.menu_item_font[8]
265331 ))
266332 if t[i].vardata ~= nil then
267333 textImgDraw(main.f_updateTextImg(
@@ -276,45 +342,63 @@ function options.f_menuCommon2(cursorPosY, moveTxt, item, t)
276342 motif.option_info.menu_item_value_font_scale[2],
277343 motif.option_info.menu_item_value_font[4],
278344 motif.option_info.menu_item_value_font[5],
279- motif.option_info.menu_item_value_font[6]
345+ motif.option_info.menu_item_value_font[6],
346+ motif.option_info.menu_item_value_font[7],
347+ motif.option_info.menu_item_value_font[8]
280348 ))
281349 end
282350 end
283351 end
284352 end
285353 --draw menu cursor
286- if motif.option_info.menu_boxcursor_visible == 1 then
287- animSetWindow(
288- main.cursorBox,
354+ if motif.option_info.menu_boxcursor_visible == 1 and not main.fadeActive then
355+ local src, dst = main.f_boxcursorAlpha(
356+ motif.option_info.menu_boxcursor_alpharange[1],
357+ motif.option_info.menu_boxcursor_alpharange[2],
358+ motif.option_info.menu_boxcursor_alpharange[3],
359+ motif.option_info.menu_boxcursor_alpharange[4],
360+ motif.option_info.menu_boxcursor_alpharange[5],
361+ motif.option_info.menu_boxcursor_alpharange[6]
362+ )
363+ fillRect(
289364 motif.option_info.menu_pos[1] + motif.option_info.menu_boxcursor_coords[1],
290365 motif.option_info.menu_pos[2] + motif.option_info.menu_boxcursor_coords[2] + (cursorPosY - 1) * motif.option_info.menu_item_spacing[2],
291366 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
367+ motif.option_info.menu_boxcursor_coords[4] - motif.option_info.menu_boxcursor_coords[2] + 1 + main.f_oddRounding(motif.option_info.menu_boxcursor_coords[2]),
368+ motif.option_info.menu_boxcursor_col[1],
369+ motif.option_info.menu_boxcursor_col[2],
370+ motif.option_info.menu_boxcursor_col[3],
371+ src,
372+ dst
293373 )
294- main.f_dynamicAlpha(main.cursorBox, 10,40,2, 255,255,0)
295- animDraw(main.cursorBox)
296374 end
297375 --draw layerno = 1 backgrounds
298- main.f_drawBG(motif.optionbgdef.bg_data, motif.optionbgdef.bg, 1, motif.optionbgdef.timer, {320,240})
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()
376+ bgDraw(motif.optionbgdef.bg, true)
377+ --draw fadein / fadeout
378+ main.fadeActive = fadeScreen(
379+ fadeType,
380+ main.fadeStart,
381+ motif.option_info[fadeType .. '_time'],
382+ motif.option_info[fadeType .. '_col'][1],
383+ motif.option_info[fadeType .. '_col'][2],
384+ motif.option_info[fadeType .. '_col'][3]
385+ )
386+ --frame transition
387+ if main.fadeActive then
388+ commandBufReset(main.p1Cmd)
389+ elseif fadeType == 'fadeout' then
390+ commandBufReset(main.p1Cmd)
391+ return --skip last frame rendering
392+ else
393+ main.f_cmdInput()
394+ end
306395 refresh()
307396 end
308397
309398 --;===========================================================
310399 --; MAIN LOOP
311400 --;===========================================================
312-local t_quicklaunchNames = {}
313-t_quicklaunchNames[0] = "Disabled"
314-t_quicklaunchNames[1] = "Level1"
315-t_quicklaunchNames[2] = "Level2"
316-
317-local t_mainCfg = {
401+options.t_mainCfg = {
318402 {data = textImgNew(), itemname = 'arcadesettings', displayname = motif.option_info.menu_itemname_main_arcade},
319403 {data = textImgNew(), itemname = 'videosettings', displayname = motif.option_info.menu_itemname_main_video},
320404 {data = textImgNew(), itemname = 'audiosettings', displayname = motif.option_info.menu_itemname_main_audio},
@@ -322,28 +406,39 @@ local t_mainCfg = {
322406 {data = textImgNew(), itemname = 'gameplaysettings', displayname = motif.option_info.menu_itemname_main_gameplay},
323407 {data = textImgNew(), itemname = 'enginesettings', displayname = motif.option_info.menu_itemname_main_engine},
324408 {data = textImgNew(), itemname = 'empty', displayname = ' '},
325- {data = textImgNew(), itemname = 'quicklaunch', displayname = motif.option_info.menu_itemname_engine_quicklaunch, vardata = textImgNew(), vardisplay = t_quicklaunchNames[config.QuickLaunch]},
326409 {data = textImgNew(), itemname = 'portchange', displayname = motif.option_info.menu_itemname_main_port, vardata = textImgNew(), vardisplay = getListenPort()},
327410 {data = textImgNew(), itemname = 'defaultvalues', displayname = motif.option_info.menu_itemname_main_default},
328411 {data = textImgNew(), itemname = 'empty', displayname = ' '},
329412 {data = textImgNew(), itemname = 'save', displayname = motif.option_info.menu_itemname_main_save},
330413 {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_main_back},
331414 }
332-t_mainCfg = main.f_cleanTable(t_mainCfg)
415+options.t_mainCfg = main.f_cleanTable(options.t_mainCfg, main.t_sort.option_info)
333416
334417 function options.f_mainCfg()
335418 main.f_cmdInput()
336419 local cursorPosY = 1
337420 local moveTxt = 0
338421 local item = 1
339- local t = t_mainCfg
422+ local t = options.t_mainCfg
340423 textImgSetText(txt_title, motif.option_info.title_text_main)
341- main.f_resetBG(motif.option_info, motif.optionbgdef)
424+ if motif.music.option_bgm == '' then
425+ main.f_menuReset(motif.optionbgdef.bg)
426+ else
427+ main.f_menuReset(motif.optionbgdef.bg, motif.music.option_bgm, motif.music.option_bgm_loop, motif.music.option_bgm_volume, motif.music.option_bgm_loopstart, motif.music.option_bgm_loopend)
428+ end
342429 while true do
343- cursorPosY, moveTxt, item = options.f_menuCommon1(cursorPosY, moveTxt, item, t)
430+ cursorPosY, moveTxt, item = options.f_menuCommonCalc(cursorPosY, moveTxt, item, t)
344431 if esc() then
345432 sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
346- main.f_resetBG(motif.title_info, motif.titlebgdef)
433+ if modified == 1 then
434+ options.f_saveCfg()
435+ end
436+ main.f_menuFade('option_info', 'fadeout', cursorPosY, moveTxt, item, t)
437+ if motif.music.option_bgm == '' then
438+ main.f_menuReset(motif.titlebgdef.bg)
439+ else
440+ main.f_menuReset(motif.titlebgdef.bg, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
441+ end
347442 break
348443 --Port Change
349444 elseif t[item].itemname == 'portchange' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
@@ -357,42 +452,31 @@ function options.f_mainCfg()
357452 end
358453 t[item].vardisplay = getListenPort()
359454 modified = 1
360- -- Quick Launch
361- elseif t[item].itemname == 'quicklaunch' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
362- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
363- if commandGetState(main.p1Cmd, 'r') and config.QuickLaunch < #t_quicklaunchNames then
364- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
365- config.QuickLaunch = config.QuickLaunch + 1
366- elseif commandGetState(main.p1Cmd, 'l') and config.QuickLaunch > 0 then
367- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
368- config.QuickLaunch = config.QuickLaunch - 1
369- end
370- t[item].vardisplay = t_quicklaunchNames[config.QuickLaunch]
371- modified = 1
372455 elseif main.f_btnPalNo(main.p1Cmd) > 0 then
373456 --Arcade Settings
374457 if t[item].itemname == 'arcadesettings' then
375458 sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
376459 options.f_arcadeCfg()
377- --Gameplay Settings
378- elseif t[item].itemname == 'gameplaysettings' then
379- sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
380- options.f_gameplayCfg()
381460 --Video Settings
382461 elseif t[item].itemname == 'videosettings' then
383462 sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
384463 options.f_videoCfg()
464+ --Audio Settings
385465 elseif t[item].itemname == 'audiosettings' then
386466 sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
387467 options.f_audioCfg()
388- --Engine Settings
389- elseif t[item].itemname == 'enginesettings' then
390- sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
391- options.f_engineCfg()
392468 --Input Settings
393469 elseif t[item].itemname == 'inputsettings' then
394470 sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
395471 options.f_inputCfg()
472+ --Gameplay Settings
473+ elseif t[item].itemname == 'gameplaysettings' then
474+ sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
475+ options.f_gameplayCfg()
476+ --Engine Settings
477+ elseif t[item].itemname == 'enginesettings' then
478+ sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
479+ options.f_engineCfg()
396480 --Default Values
397481 elseif t[item].itemname == 'defaultvalues' then
398482 sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
@@ -400,6 +484,9 @@ function options.f_mainCfg()
400484 config.PlayerProjectileMax = 256
401485 config.ExplodMax = 512
402486 config.AfterImageMax = 128
487+ config.MasterVolume = 80
488+ config.WavVolume = 80
489+ config.BgmVolume = 80
403490 config['Attack.LifeToPowerMul'] = 0.7
404491 config['GetHit.LifeToPowerMul'] = 0.6
405492 config.Width = 640
@@ -408,17 +495,24 @@ function options.f_mainCfg()
408495 config.LifebarFontScale = 1
409496 --config.System = 'script/main.lua'
410497 options.f_keyDefault()
498+ --config.ControllerStickSensitivity = 0.4
499+ --config.XinputTriggerSensitivity = 0
411500 --config.Motif = 'data/system.def'
501+ --config.CommonAir = 'data/common.air'
502+ --config.CommonCmd = 'data/common.cmd'
412503 config.SimulMode = true
413504 config.LifeMul = 100
414- config.Team1VS2Life = 120
415- config.TurnsRecoveryRate = 300
505+ config.Team1VS2Life = 100
506+ config.TurnsRecoveryBase = 12.5
507+ config.TurnsRecoveryBonus = 27.5
416508 config.ZoomActive = false
417509 config.ZoomMin = 0.75
418510 config.ZoomMax = 1.1
419511 config.ZoomSpeed = 1.0
420- config.AIRandomColor = true
421512 config.RoundTime = 99
513+ config.RoundsNumSingle = -1
514+ config.RoundsNumTeam = -1
515+ config.MaxDrawGames = -2
422516 config.SingleTeamMode = true
423517 config.NumTurns = 4
424518 config.NumSimul = 4
@@ -427,88 +521,142 @@ function options.f_mainCfg()
427521 config.Credits = 10
428522 setListenPort(7500)
429523 config.ContSelection = true
524+ config.AIRandomColor = true
430525 config.AIRamping = true
431526 config.AutoGuard = false
432527 config.TeamPowerShare = false
433528 config.TeamLifeShare = false
434529 config.Fullscreen = false
435- --lifebar
436- roundsNum = 2
530+ config.AudioDucking = false
531+ config.QuickLaunch = 0
532+ config.AllowDebugKeys = true
533+ config.ComboExtraFrameWindow = 1
534+ config.PostProcessingShader = 0
535+ config.LocalcoordScalingType = 1
536+ config.MSAA = false
537+ loadLifebar(motif.files.fight)
538+ options.roundsNumSingle = getMatchWins()
539+ options.roundsNumTeam = getMatchWins()
540+ options.maxDrawGames = getMatchMaxDrawGames()
541+ options.f_resetTables()
437542 modified = 1
438543 needReload = 1
439- -- Save
544+ --Save
440545 elseif t[item].itemname == 'save' then
441546 sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
442547 if modified == 1 then
443548 options.f_saveCfg()
444549 end
445- main.f_resetBG(motif.title_info, motif.titlebgdef)
550+ main.f_menuFade('option_info', 'fadeout', cursorPosY, moveTxt, item, t)
551+ if motif.music.option_bgm == '' then
552+ main.f_menuReset(motif.titlebgdef.bg)
553+ else
554+ main.f_menuReset(motif.titlebgdef.bg, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
555+ end
446556 break
447- -- Back
557+ --Back
448558 elseif t[item].itemname == 'back' then
449559 sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
450- main.f_resetBG(motif.title_info, motif.titlebgdef)
560+ main.f_menuFade('option_info', 'fadeout', cursorPosY, moveTxt, item, t)
561+ if motif.music.option_bgm == '' then
562+ main.f_menuReset(motif.titlebgdef.bg)
563+ else
564+ main.f_menuReset(motif.titlebgdef.bg, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
565+ end
451566 break
452567 end
453568 end
454- options.f_menuCommon2(cursorPosY, moveTxt, item, t)
569+ options.f_menuCommonDraw(cursorPosY, moveTxt, item, t)
455570 end
456571 end
457572
458573 --;===========================================================
459574 --; ARCADE SETTINGS
460575 --;===========================================================
461-local t_arcadeCfg = {
462- {data = textImgNew(), itemname = 'roundstowin', displayname = motif.option_info.menu_itemname_arcade_roundstowin, vardata = textImgNew(), vardisplay = roundsNum},
463- {data = textImgNew(), itemname = 'roundtime', displayname = motif.option_info.menu_itemname_arcade_roundtime, vardata = textImgNew(), vardisplay = config.RoundTime},
576+options.t_arcadeCfg = {
577+ {data = textImgNew(), itemname = 'roundtime', displayname = motif.option_info.menu_itemname_arcade_roundtime, vardata = textImgNew(), vardisplay = options.f_definedDisplay(config.RoundTime, {[-1] = motif.option_info.menu_itemname_arcade_roundtime_none}, config.RoundTime)},
578+ {data = textImgNew(), itemname = 'roundsnumsingle', displayname = motif.option_info.menu_itemname_arcade_roundsnumsingle, vardata = textImgNew(), vardisplay = options.roundsNumSingle},
579+ {data = textImgNew(), itemname = 'roundsnumteam', displayname = motif.option_info.menu_itemname_arcade_roundsnumteam, vardata = textImgNew(), vardisplay = options.roundsNumTeam},
580+ {data = textImgNew(), itemname = 'maxdrawgames', displayname = motif.option_info.menu_itemname_arcade_maxdrawgames, vardata = textImgNew(), vardisplay = options.maxDrawGames},
464581 {data = textImgNew(), itemname = 'difficulty', displayname = motif.option_info.menu_itemname_arcade_difficulty, vardata = textImgNew(), vardisplay = config.Difficulty},
465582 {data = textImgNew(), itemname = 'credits', displayname = motif.option_info.menu_itemname_arcade_credits, vardata = textImgNew(), vardisplay = config.Credits},
466583 {data = textImgNew(), itemname = 'charchange', displayname = motif.option_info.menu_itemname_arcade_charchange, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.ContSelection)},
467584 {data = textImgNew(), itemname = 'airamping', displayname = motif.option_info.menu_itemname_arcade_airamping, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.AIRamping)},
585+ {data = textImgNew(), itemname = 'airandomcolor', displayname = motif.option_info.menu_itemname_arcade_aipalette, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.AIRandomColor, motif.option_info.menu_itemname_arcade_aipalette_random, motif.option_info.menu_itemname_arcade_aipalette_default)},
468586 {data = textImgNew(), itemname = 'empty', displayname = ' '},
469587 {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_arcade_back},
470588 }
471-t_arcadeCfg = main.f_cleanTable(t_arcadeCfg)
589+options.t_arcadeCfg = main.f_cleanTable(options.t_arcadeCfg, main.t_sort.option_info)
472590
473591 function options.f_arcadeCfg()
474592 main.f_cmdInput()
475593 local cursorPosY = 1
476594 local moveTxt = 0
477595 local item = 1
478- local t = t_arcadeCfg
596+ local t = options.t_arcadeCfg
479597 textImgSetText(txt_title, motif.option_info.title_text_arcade)
480598 while true do
481- cursorPosY, moveTxt, item = options.f_menuCommon1(cursorPosY, moveTxt, item, t)
599+ cursorPosY, moveTxt, item = options.f_menuCommonCalc(cursorPosY, moveTxt, item, t)
482600 if esc() then
483601 sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
484602 textImgSetText(txt_title, motif.option_info.title_text_main)
485603 break
486- --Rounds to Win
487- elseif t[item].itemname == 'roundstowin' then
488- if commandGetState(main.p1Cmd, 'r') and roundsNum < 10 then
489- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
490- roundsNum = roundsNum + 1
491- t[item].vardisplay = roundsNum
492- modifiedlifebar = 1
493- modified = 1
494- elseif commandGetState(main.p1Cmd, 'l') and roundsNum > 1 then
495- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
496- roundsNum = roundsNum - 1
497- t[item].vardisplay = roundsNum
498- modifiedlifebar = 1
499- modified = 1
500- end
501- --Round Time
604+ --Time Limit
502605 elseif t[item].itemname == 'roundtime' then
503606 if commandGetState(main.p1Cmd, 'r') and config.RoundTime < 1000 then
504607 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
505608 config.RoundTime = config.RoundTime + 1
506609 t[item].vardisplay = config.RoundTime
507610 modified = 1
508- elseif commandGetState(main.p1Cmd, 'l') and config.RoundTime > -2 then
611+ elseif commandGetState(main.p1Cmd, 'l') and config.RoundTime > -1 then
509612 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
510613 config.RoundTime = config.RoundTime - 1
511- t[item].vardisplay = config.RoundTime
614+ t[item].vardisplay = options.f_definedDisplay(config.RoundTime, {[-1] = motif.option_info.menu_itemname_arcade_roundtime_none}, config.RoundTime)
615+ modified = 1
616+ end
617+ --Rounds to Win Single
618+ elseif t[item].itemname == 'roundsnumsingle' then
619+ if commandGetState(main.p1Cmd, 'r') and options.roundsNumSingle < 10 then
620+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
621+ options.roundsNumSingle = options.roundsNumSingle + 1
622+ t[item].vardisplay = options.roundsNumSingle
623+ config.RoundsNumSingle = options.roundsNumSingle
624+ modified = 1
625+ elseif commandGetState(main.p1Cmd, 'l') and options.roundsNumSingle > 1 then
626+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
627+ options.roundsNumSingle = options.roundsNumSingle - 1
628+ t[item].vardisplay = options.roundsNumSingle
629+ config.RoundsNumSingle = options.roundsNumSingle
630+ modified = 1
631+ end
632+ --Rounds to Win Simul/Tag
633+ elseif t[item].itemname == 'roundsnumteam' then
634+ if commandGetState(main.p1Cmd, 'r') and options.roundsNumTeam < 10 then
635+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
636+ options.roundsNumTeam = options.roundsNumTeam + 1
637+ t[item].vardisplay = options.roundsNumTeam
638+ config.RoundsNumTeam = options.roundsNumTeam
639+ modified = 1
640+ elseif commandGetState(main.p1Cmd, 'l') and options.roundsNumTeam > 1 then
641+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
642+ options.roundsNumTeam = options.roundsNumTeam - 1
643+ t[item].vardisplay = options.roundsNumTeam
644+ config.RoundsNumTeam = options.roundsNumTeam
645+ modified = 1
646+ end
647+ --Max Draw Games
648+ elseif t[item].itemname == 'maxdrawgames' then
649+ if commandGetState(main.p1Cmd, 'r') and options.maxDrawGames < 10 then
650+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
651+ options.maxDrawGames = options.maxDrawGames + 1
652+ t[item].vardisplay = options.maxDrawGames
653+ config.MaxDrawGames = options.maxDrawGames
654+ modified = 1
655+ elseif commandGetState(main.p1Cmd, 'l') and options.maxDrawGames > -1 then
656+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
657+ options.maxDrawGames = options.maxDrawGames - 1
658+ t[item].vardisplay = options.maxDrawGames
659+ config.MaxDrawGames = options.maxDrawGames
512660 modified = 1
513661 end
514662 --Difficulty level
@@ -547,7 +695,7 @@ function options.f_arcadeCfg()
547695 end
548696 t[item].vardisplay = options.f_boolDisplay(config.ContSelection)
549697 modified = 1
550- --AI ramping
698+ --AI Ramping
551699 elseif t[item].itemname == 'airamping' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
552700 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
553701 if config.AIRamping then
@@ -557,260 +705,373 @@ function options.f_arcadeCfg()
557705 end
558706 t[item].vardisplay = options.f_boolDisplay(config.AIRamping)
559707 modified = 1
708+ --AI Palette
709+ elseif t[item].itemname == 'airandomcolor' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
710+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
711+ if config.AIRandomColor then
712+ config.AIRandomColor = false
713+ else
714+ config.AIRandomColor = true
715+ end
716+ t[item].vardisplay = options.f_boolDisplay(config.AIRandomColor, motif.option_info.menu_itemname_arcade_aipalette_random, motif.option_info.menu_itemname_arcade_aipalette_default)
717+ modified = 1
560718 --Back
561719 elseif t[item].itemname == 'back' and main.f_btnPalNo(main.p1Cmd) > 0 then
562720 sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
563721 textImgSetText(txt_title, motif.option_info.title_text_main)
564722 break
565723 end
566- options.f_menuCommon2(cursorPosY, moveTxt, item, t)
724+ options.f_menuCommonDraw(cursorPosY, moveTxt, item, t)
567725 end
568726 end
569727
570728 --;===========================================================
571---; GAMEPLAY SETTINGS
729+--; VIDEO SETTINGS
572730 --;===========================================================
573-local t_gameplayCfg = {
574- {data = textImgNew(), itemname = 'lifemul', displayname = motif.option_info.menu_itemname_gameplay_lifemul, vardata = textImgNew(), vardisplay = config.LifeMul .. '%'},
575- {data = textImgNew(), itemname = 'autoguard', displayname = motif.option_info.menu_itemname_gameplay_autoguard, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.AutoGuard)},
576- {data = textImgNew(), itemname = 'team1vs2life', displayname = motif.option_info.menu_itemname_gameplay_team1vs2life, vardata = textImgNew(), vardisplay = config.Team1VS2Life},
577- {data = textImgNew(), itemname = 'turnsrecoveryrate', displayname = motif.option_info.menu_itemname_gameplay_turnsrecoveryrate, vardata = textImgNew(), vardisplay = config.TurnsRecoveryRate},
578- {data = textImgNew(), itemname = 'teampowershare', displayname = motif.option_info.menu_itemname_gameplay_teampowershare, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.TeamPowerShare)},
579- {data = textImgNew(), itemname = 'teamlifeshare', displayname = motif.option_info.menu_itemname_gameplay_teamlifeshare, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.TeamLifeShare)},
731+options.t_shaderNames = {
732+ [0] = motif.option_info.menu_itemname_video_shader_none,
733+ [1] = motif.option_info.menu_itemname_video_shader_hqx2,
734+ [2] = motif.option_info.menu_itemname_video_shader_hqx4,
735+ [3] = motif.option_info.menu_itemname_video_shader_scanlines,
736+}
737+
738+options.t_videoCfg = {
739+ {data = textImgNew(), itemname = 'resolution', displayname = motif.option_info.menu_itemname_video_resolution, vardata = textImgNew(), vardisplay = config.Width .. 'x' .. config.Height},
740+ {data = textImgNew(), itemname = 'fullscreen', displayname = motif.option_info.menu_itemname_video_fullscreen, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.Fullscreen)},
741+ {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)},
742+ {data = textImgNew(), itemname = 'postprocessingshader', displayname = motif.option_info.menu_itemname_video_shader, vardata = textImgNew(), vardisplay = options.t_shaderNames[config.PostProcessingShader]},
580743 {data = textImgNew(), itemname = 'empty', displayname = ' '},
581- {data = textImgNew(), itemname = 'advancedGameplaySettings', displayname = motif.option_info.menu_itemname_gameplay_advanced},
582- {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_gameplay_back},
744+ {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_video_back},
583745 }
584-t_gameplayCfg = main.f_cleanTable(t_gameplayCfg)
746+options.t_videoCfg = main.f_cleanTable(options.t_videoCfg, main.t_sort.option_info)
585747
586-function options.f_gameplayCfg()
748+function options.f_videoCfg()
587749 main.f_cmdInput()
588750 local cursorPosY = 1
589751 local moveTxt = 0
590752 local item = 1
591- local t = t_gameplayCfg
592- textImgSetText(txt_title, motif.option_info.title_text_gameplay)
753+ local t = options.t_videoCfg
754+ textImgSetText(txt_title, motif.option_info.title_text_video)
593755 while true do
594- cursorPosY, moveTxt, item = options.f_menuCommon1(cursorPosY, moveTxt, item, t)
756+ cursorPosY, moveTxt, item = options.f_menuCommonCalc(cursorPosY, moveTxt, item, t)
595757 if esc() then
596758 sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
597759 textImgSetText(txt_title, motif.option_info.title_text_main)
598760 break
599- --Life
600- elseif t[item].itemname == 'lifemul' then
601- if commandGetState(main.p1Cmd, 'r') and config.LifeMul < 300 then
602- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
603- config.LifeMul = config.LifeMul + 10
604- t[item].vardisplay = config.LifeMul .. '%'
605- modified = 1
606- elseif commandGetState(main.p1Cmd, 'l') and config.LifeMul > 10 then
607- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
608- config.LifeMul = config.LifeMul - 10
609- t[item].vardisplay = config.LifeMul .. '%'
610- modified = 1
611- end
612- --Auto-Guard
613- elseif t[item].itemname == 'autoguard' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
761+ --Resolution
762+ elseif t[item].itemname == 'resolution' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
614763 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
615- if config.AutoGuard then
616- config.AutoGuard = false
764+ options.f_resCfg()
765+ t[item].vardisplay = config.Width .. 'x' .. config.Height
766+ --Fullscreen
767+ elseif t[item].itemname == 'fullscreen' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
768+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
769+ if config.Fullscreen then
770+ config.Fullscreen = false
617771 else
618- config.AutoGuard = true
772+ config.Fullscreen = true
619773 end
620- t[item].vardisplay = options.f_boolDisplay(config.AutoGuard)
774+ t[item].vardisplay = options.f_boolDisplay(config.Fullscreen)
621775 modified = 1
622- --1P Vs Team Life
623- elseif t[item].itemname == 'team1vs2life' then
624- if commandGetState(main.p1Cmd, 'r') and config.Team1VS2Life < 3000 then
625- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
626- config.Team1VS2Life = config.Team1VS2Life + 10
627- t[item].vardisplay = config.Team1VS2Life
628- modified = 1
629- elseif commandGetState(main.p1Cmd, 'l') and config.Team1VS2Life > 10 then
630- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
631- config.Team1VS2Life = config.Team1VS2Life - 10
632- t[item].vardisplay = config.Team1VS2Life
633- modified = 1
776+ needReload = 1
777+ --MSAA
778+ elseif t[item].itemname == 'msaa' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
779+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
780+ if config.MSAA then
781+ config.MSAA = false
782+ else
783+ config.MSAA = true
634784 end
635- --Turns HP Recovery
636- elseif t[item].itemname == 'turnsrecoveryrate' then
637- if commandGetState(main.p1Cmd, 'r') and config.TurnsRecoveryRate < 3000 then
785+ t[item].vardisplay = options.f_boolDisplay(config.MSAA, motif.option_info.menu_itemname_enabled, motif.option_info.menu_itemname_disabled)
786+ modified = 1
787+ needReload = 1
788+ --Shader
789+ elseif t[item].itemname == 'postprocessingshader' then
790+ if commandGetState(main.p1Cmd, 'r') and config.PostProcessingShader < #options.t_shaderNames then
638791 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
639- config.TurnsRecoveryRate = config.TurnsRecoveryRate + 10
640- t[item].vardisplay = config.TurnsRecoveryRate
792+ config.PostProcessingShader = config.PostProcessingShader + 1
641793 modified = 1
642- elseif commandGetState(main.p1Cmd, 'l') and config.TurnsRecoveryRate > 10 then
794+ needReload = 1
795+ elseif commandGetState(main.p1Cmd, 'l') and config.PostProcessingShader > 0 then
643796 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
644- config.TurnsRecoveryRate = config.TurnsRecoveryRate - 10
645- t[item].vardisplay = config.TurnsRecoveryRate
797+ config.PostProcessingShader = config.PostProcessingShader - 1
646798 modified = 1
799+ needReload = 1
647800 end
648- --Team Power Share
649- elseif t[item].itemname == 'teampowershare' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
650- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
651- if config.TeamPowerShare then
652- config.TeamPowerShare = false
653- else
654- config.TeamPowerShare = true
655- end
656- t[item].vardisplay = options.f_boolDisplay(config.TeamPowerShare)
657- modified = 1
658- --Team Life Share
659- elseif t[item].itemname == 'teamlifeshare' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
660- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
661- if config.TeamLifeShare then
662- config.TeamLifeShare = false
663- else
664- config.TeamLifeShare = true
665- end
666- t[item].vardisplay = options.f_boolDisplay(config.TeamLifeShare)
667- modified = 1
668- -- Advanced settings
669- elseif t[item].itemname == 'advancedGameplaySettings' and main.f_btnPalNo(main.p1Cmd) > 0 then
670- sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
671- options.f_advGameplayCfg()
801+ t[item].vardisplay = options.t_shaderNames[config.PostProcessingShader]
672802 --Back
673803 elseif t[item].itemname == 'back' and main.f_btnPalNo(main.p1Cmd) > 0 then
674804 sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
675805 textImgSetText(txt_title, motif.option_info.title_text_main)
676806 break
677807 end
678- options.f_menuCommon2(cursorPosY, moveTxt, item, t)
808+ options.f_menuCommonDraw(cursorPosY, moveTxt, item, t)
679809 end
680810 end
681811
682-
683812 --;===========================================================
684---; ADVANCED GAMEPLAY SETTINGS
813+--; RESOLUTION SETTINGS
685814 --;===========================================================
686-function options.f_checkTeamAmount(arg1, arg2, arg3)
687- ret = arg1
688- if arg1 <= arg2 then
689- ret = arg3
690- end
691-
692- return ret
693-end
694-
695-local t_advGameplayCfg = {
696- {data = textImgNew(), itemname = 'attackpowermul', displayname = motif.option_info.menu_itemname_gameplay_attackpowermul, vardata = textImgNew(), vardisplay = config['Attack.LifeToPowerMul']},
697- {data = textImgNew(), itemname = 'gethitpowermul', displayname = motif.option_info.menu_itemname_gameplay_gethitpowermul, vardata = textImgNew(), vardisplay = config['GetHit.LifeToPowerMul']},
698- {data = textImgNew(), itemname = 'superdefencemul', displayname = motif.option_info.menu_itemname_gameplay_superdefencemul, vardata = textImgNew(), vardisplay = config['Super.TargetDefenceMul']},
699- {data = textImgNew(), itemname = 'empty', displayname = ' '},
700- {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)},
701- {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)},
702- {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)},
703- {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)},
815+local t_resCfg = {
816+ {data = textImgNew(), x = 320, y = 240, displayname = motif.option_info.menu_itemname_res_320x240},
817+ {data = textImgNew(), x = 640, y = 480, displayname = motif.option_info.menu_itemname_res_640x480},
818+ {data = textImgNew(), x = 1280, y = 960, displayname = motif.option_info.menu_itemname_res_1280x960},
819+ {data = textImgNew(), x = 1600, y = 1200, displayname = motif.option_info.menu_itemname_res_1600x1200},
820+ {data = textImgNew(), x = 960, y = 720, displayname = motif.option_info.menu_itemname_res_960x720},
821+ {data = textImgNew(), x = 1280, y = 720, displayname = motif.option_info.menu_itemname_res_1280x720},
822+ {data = textImgNew(), x = 1600, y = 900, displayname = motif.option_info.menu_itemname_res_1600x900},
823+ {data = textImgNew(), x = 1920, y = 1080, displayname = motif.option_info.menu_itemname_res_1920x1080},
824+ {data = textImgNew(), x = 2560, y = 1440, displayname = motif.option_info.menu_itemname_res_2560x1440},
825+ {data = textImgNew(), x = 3840, y = 2160, displayname = motif.option_info.menu_itemname_res_3840x2160},
704826 {data = textImgNew(), itemname = 'empty', displayname = ' '},
705- {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_gameplay_back},
827+ {data = textImgNew(), itemname = 'custom', displayname = motif.option_info.menu_itemname_res_custom},
828+ {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_res_back},
706829 }
707-t_advGameplayCfg = main.f_cleanTable(t_advGameplayCfg)
830+t_resCfg = main.f_cleanTable(t_resCfg, main.t_sort.option_info)
708831
709-function options.f_advGameplayCfg()
832+function options.f_resCfg()
710833 main.f_cmdInput()
711834 local cursorPosY = 1
712835 local moveTxt = 0
713836 local item = 1
714- local t = t_advGameplayCfg
715- textImgSetText(txt_title, motif.option_info.title_text_advgameplay)
837+ local t = t_resCfg
838+ textImgSetText(txt_title, motif.option_info.title_text_res)
716839 while true do
717- cursorPosY, moveTxt, item = options.f_menuCommon1(cursorPosY, moveTxt, item, t)
840+ cursorPosY, moveTxt, item = options.f_menuCommonCalc(cursorPosY, moveTxt, item, t)
718841 if esc() then
719842 sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
720- textImgSetText(txt_title, motif.option_info.title_text_gameplay)
843+ textImgSetText(txt_title, motif.option_info.title_text_video)
721844 break
722- --Life
723- elseif t[item].itemname == 'lifemul' then
724- if commandGetState(main.p1Cmd, 'r') and config.LifeMul < 300 then
725- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
726- config.LifeMul = config.LifeMul + 10
727- t[item].vardisplay = config.LifeMul .. '%'
728- modified = 1
729- elseif commandGetState(main.p1Cmd, 'l') and config.LifeMul > 10 then
845+ elseif main.f_btnPalNo(main.p1Cmd) > 0 then
846+ --Back
847+ if t[item].itemname == 'back' then
848+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
849+ textImgSetText(txt_title, motif.option_info.title_text_video)
850+ break
851+ --Custom
852+ elseif t[item].itemname == 'custom' then
730853 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
731- config.LifeMul = config.LifeMul - 10
732- t[item].vardisplay = config.LifeMul .. '%'
733- modified = 1
734- end
735- --Auto-Guard
736- elseif t[item].itemname == 'autoguard' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
737- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
738- if config.AutoGuard then
739- config.AutoGuard = false
854+ local width = tonumber(main.f_input(main.f_extractText(motif.option_info.input_text_reswidth), motif.option_info, motif.optionbgdef, 'string'))
855+ if width ~= nil then
856+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
857+ local height = tonumber(main.f_input(main.f_extractText(motif.option_info.input_text_resheight), motif.option_info, motif.optionbgdef, 'string'))
858+ if height ~= nil then
859+ config.Width = width
860+ config.Height = height
861+ sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
862+ if (height / 3 * 4) ~= width then
863+ main.f_warning(main.f_extractText(motif.warning_info.text_res), motif.option_info, motif.optionbgdef)
864+ end
865+ modified = 1
866+ needReload = 1
867+ else
868+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
869+ end
870+ else
871+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
872+ end
873+ textImgSetText(txt_title, motif.option_info.title_text_video)
874+ break
875+ --Resolution
740876 else
741- config.AutoGuard = true
877+ sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
878+ config.Width = t[item].x
879+ config.Height = t[item].y
880+ if (config.Height / 3 * 4) ~= config.Width then
881+ main.f_warning(main.f_extractText(motif.warning_info.text_res), motif.option_info, motif.optionbgdef)
882+ end
883+ modified = 1
884+ needReload = 1
885+ textImgSetText(txt_title, motif.option_info.title_text_video)
886+ break
742887 end
743- t[item].vardisplay = options.f_boolDisplay(config.AutoGuard)
744- modified = 1
745- --Attack.LifeToPowerMul
746- elseif t[item].itemname == 'attackpowermul' then
747- if commandGetState(main.p1Cmd, 'r') then
888+ end
889+ options.f_menuCommonDraw(cursorPosY, moveTxt, item, t)
890+ end
891+end
892+
893+--;===========================================================
894+--; AUDIO SETTINGS
895+--;===========================================================
896+options.t_audioCfg = {
897+ {data = textImgNew(), itemname = 'mastervolume', displayname = motif.option_info.menu_itemname_audio_mastervolume, vardata = textImgNew(), vardisplay = config.MasterVolume .. '%'},
898+ {data = textImgNew(), itemname = 'bgmvolume', displayname = motif.option_info.menu_itemname_audio_bgmvolume, vardata = textImgNew(), vardisplay = config.BgmVolume .. '%'},
899+ {data = textImgNew(), itemname = 'sfxvolume', displayname = motif.option_info.menu_itemname_audio_sfxvolume, vardata = textImgNew(), vardisplay = config.WavVolume .. '%'},
900+ {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)},
901+ {data = textImgNew(), itemname = 'empty', displayname = ' '},
902+ {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_audio_back},
903+}
904+options.t_audioCfg = main.f_cleanTable(options.t_audioCfg, main.t_sort.option_info)
905+
906+function options.f_audioCfg()
907+ main.f_cmdInput()
908+ local cursorPosY = 1
909+ local moveTxt = 0
910+ local item = 1
911+ local t = options.t_audioCfg
912+ textImgSetText(txt_title, motif.option_info.title_text_audio)
913+ while true do
914+ cursorPosY, moveTxt, item = options.f_menuCommonCalc(cursorPosY, moveTxt, item, t)
915+ if esc() then
916+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
917+ textImgSetText(txt_title, motif.option_info.title_text_main)
918+ break
919+ --Master Volume
920+ elseif t[item].itemname == 'mastervolume' then
921+ if commandGetState(main.p1Cmd, 'r') and config.MasterVolume < 200 then
748922 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
749- config['Attack.LifeToPowerMul'] = options.f_precision(config['Attack.LifeToPowerMul'] + 0.1, '%.01f')
750- t[item].vardisplay = config['Attack.LifeToPowerMul']
923+ config.MasterVolume = config.MasterVolume + 1
924+ t[item].vardisplay = config.MasterVolume
925+ setMasterVolume(config.MasterVolume)
751926 modified = 1
752- needReload = 1
753- elseif commandGetState(main.p1Cmd, 'l') and config['Attack.LifeToPowerMul'] > 0.1 then
927+ elseif commandGetState(main.p1Cmd, 'l') and config.MasterVolume > 0 then
754928 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
755- config['Attack.LifeToPowerMul'] = options.f_precision(config['Attack.LifeToPowerMul'] - 0.1, '%.01f')
756- t[item].vardisplay = config['Attack.LifeToPowerMul']
929+ config.MasterVolume = config.MasterVolume - 1
930+ t[item].vardisplay = config.MasterVolume
931+ setMasterVolume(config.MasterVolume)
757932 modified = 1
758- needReload = 1
759933 end
760- --GetHit.LifeToPowerMul
761- elseif t[item].itemname == 'gethitpowermul' then
762- if commandGetState(main.p1Cmd, 'r') then
934+ --BGM Volume
935+ elseif t[item].itemname == 'bgmvolume' then
936+ if commandGetState(main.p1Cmd, 'r') and config.BgmVolume < 100 then
763937 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
764- config['GetHit.LifeToPowerMul'] = options.f_precision(config['GetHit.LifeToPowerMul'] + 0.1, '%.01f')
765- t[item].vardisplay = config['GetHit.LifeToPowerMul']
938+ config.BgmVolume = config.BgmVolume + 1
939+ t[item].vardisplay = config.BgmVolume
940+ setBgmVolume(config.BgmVolume)
766941 modified = 1
767- needReload = 1
768- elseif commandGetState(main.p1Cmd, 'l') and config['GetHit.LifeToPowerMul'] > 0.1 then
942+ elseif commandGetState(main.p1Cmd, 'l') and config.BgmVolume > 0 then
769943 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
770- config['GetHit.LifeToPowerMul'] = options.f_precision(config['GetHit.LifeToPowerMul'] - 0.1, '%.01f')
771- t[item].vardisplay = config['GetHit.LifeToPowerMul']
944+ config.BgmVolume = config.BgmVolume - 1
945+ t[item].vardisplay = config.BgmVolume
946+ setBgmVolume(config.BgmVolume)
772947 modified = 1
773- needReload = 1
774948 end
775- --Super.TargetDefenceMul
776- elseif t[item].itemname == 'superdefencemul' then
777- if commandGetState(main.p1Cmd, 'r') then
949+ --SFX Volume
950+ elseif t[item].itemname == 'wavvolume' then
951+ if commandGetState(main.p1Cmd, 'r') and config.WavVolume < 100 then
778952 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
779- config['Super.TargetDefenceMul'] = options.f_precision(config['Super.TargetDefenceMul'] + 0.1, '%.01f')
780- t[item].vardisplay = config['Super.TargetDefenceMul']
953+ config.WavVolume = config.WavVolume + 1
954+ t[item].vardisplay = config.WavVolume
955+ setWavVolume(config.WavVolume)
781956 modified = 1
782- needReload = 1
783- elseif commandGetState(main.p1Cmd, 'l') and config['Super.TargetDefenceMul'] > 0.1 then
957+ elseif commandGetState(main.p1Cmd, 'l') and config.WavVolume > 0 then
784958 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
785- config['Super.TargetDefenceMul'] = options.f_precision(config['Super.TargetDefenceMul'] - 0.1, '%.01f')
786- t[item].vardisplay = config['Super.TargetDefenceMul']
959+ config.WavVolume = config.WavVolume - 1
960+ t[item].vardisplay = config.WavVolume
961+ setWavVolume(config.WavVolume)
962+ modified = 1
963+ end
964+ --Audio Ducking
965+ elseif t[item].itemname == 'audioducking' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
966+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
967+ if config.AudioDucking then
968+ config.AudioDucking = false
969+ else
970+ config.AudioDucking = true
971+ end
972+ t[item].vardisplay = options.f_boolDisplay(config.AudioDucking, motif.option_info.menu_itemname_enabled, motif.option_info.menu_itemname_disabled)
973+ setAudioDucking(config.AudioDucking)
974+ modified = 1
975+ --Back
976+ elseif t[item].itemname == 'back' and main.f_btnPalNo(main.p1Cmd) > 0 then
977+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
978+ textImgSetText(txt_title, motif.option_info.title_text_main)
979+ break
980+ end
981+ options.f_menuCommonDraw(cursorPosY, moveTxt, item, t)
982+ end
983+end
984+
985+--;===========================================================
986+--; GAMEPLAY SETTINGS
987+--;===========================================================
988+options.t_gameplayCfg = {
989+ {data = textImgNew(), itemname = 'lifemul', displayname = motif.option_info.menu_itemname_gameplay_lifemul, vardata = textImgNew(), vardisplay = config.LifeMul .. '%'},
990+ {data = textImgNew(), itemname = 'autoguard', displayname = motif.option_info.menu_itemname_gameplay_autoguard, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.AutoGuard)},
991+ {data = textImgNew(), itemname = 'team1vs2life', displayname = motif.option_info.menu_itemname_gameplay_team1vs2life, vardata = textImgNew(), vardisplay = config.Team1VS2Life .. '%'},
992+ {data = textImgNew(), itemname = 'turnsrecoverybase', displayname = motif.option_info.menu_itemname_gameplay_turnsrecoverybase, vardata = textImgNew(), vardisplay = config.TurnsRecoveryBase .. '%'},
993+ {data = textImgNew(), itemname = 'turnsrecoverybonus', displayname = motif.option_info.menu_itemname_gameplay_turnsrecoverybonus, vardata = textImgNew(), vardisplay = config.TurnsRecoveryBonus .. '%'},
994+ {data = textImgNew(), itemname = 'teampowershare', displayname = motif.option_info.menu_itemname_gameplay_teampowershare, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.TeamPowerShare)},
995+ {data = textImgNew(), itemname = 'teamlifeshare', displayname = motif.option_info.menu_itemname_gameplay_teamlifeshare, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.TeamLifeShare)},
996+ {data = textImgNew(), itemname = 'empty', displayname = ' '},
997+ {data = textImgNew(), itemname = 'advancedGameplaySettings', displayname = motif.option_info.menu_itemname_gameplay_advanced},
998+ {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_gameplay_back},
999+}
1000+options.t_gameplayCfg = main.f_cleanTable(options.t_gameplayCfg, main.t_sort.option_info)
1001+
1002+function options.f_gameplayCfg()
1003+ main.f_cmdInput()
1004+ local cursorPosY = 1
1005+ local moveTxt = 0
1006+ local item = 1
1007+ local t = options.t_gameplayCfg
1008+ textImgSetText(txt_title, motif.option_info.title_text_gameplay)
1009+ while true do
1010+ cursorPosY, moveTxt, item = options.f_menuCommonCalc(cursorPosY, moveTxt, item, t)
1011+ if esc() then
1012+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1013+ textImgSetText(txt_title, motif.option_info.title_text_main)
1014+ break
1015+ --Life
1016+ elseif t[item].itemname == 'lifemul' then
1017+ if commandGetState(main.p1Cmd, 'r') and config.LifeMul < 300 then
1018+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1019+ config.LifeMul = config.LifeMul + 10
1020+ t[item].vardisplay = config.LifeMul .. '%'
1021+ modified = 1
1022+ elseif commandGetState(main.p1Cmd, 'l') and config.LifeMul > 10 then
1023+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1024+ config.LifeMul = config.LifeMul - 10
1025+ t[item].vardisplay = config.LifeMul .. '%'
7871026 modified = 1
788- needReload = 1
7891027 end
1028+ --Auto-Guard
1029+ elseif t[item].itemname == 'autoguard' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
1030+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1031+ if config.AutoGuard then
1032+ config.AutoGuard = false
1033+ else
1034+ config.AutoGuard = true
1035+ end
1036+ t[item].vardisplay = options.f_boolDisplay(config.AutoGuard)
1037+ modified = 1
7901038 --1P Vs Team Life
7911039 elseif t[item].itemname == 'team1vs2life' then
792- if commandGetState(main.p1Cmd, 'r') and config.Team1VS2Life < 3000 then
1040+ if commandGetState(main.p1Cmd, 'r') and config.Team1VS2Life < 300 then
7931041 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
7941042 config.Team1VS2Life = config.Team1VS2Life + 10
795- t[item].vardisplay = config.Team1VS2Life
1043+ t[item].vardisplay = config.Team1VS2Life .. '%'
7961044 modified = 1
7971045 elseif commandGetState(main.p1Cmd, 'l') and config.Team1VS2Life > 10 then
7981046 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
7991047 config.Team1VS2Life = config.Team1VS2Life - 10
800- t[item].vardisplay = config.Team1VS2Life
1048+ t[item].vardisplay = config.Team1VS2Life .. '%'
1049+ modified = 1
1050+ end
1051+ --Turns Recovery Base
1052+ elseif t[item].itemname == 'turnsrecoverybase' then
1053+ if commandGetState(main.p1Cmd, 'r') and config.TurnsRecoveryBase < 100 then
1054+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1055+ config.TurnsRecoveryBase = config.TurnsRecoveryBase + 0.5
1056+ t[item].vardisplay = config.TurnsRecoveryBase .. '%'
1057+ modified = 1
1058+ elseif commandGetState(main.p1Cmd, 'l') and config.TurnsRecoveryBase > 0 then
1059+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1060+ config.TurnsRecoveryBase = config.TurnsRecoveryBase - 0.5
1061+ t[item].vardisplay = config.TurnsRecoveryBase .. '%'
8011062 modified = 1
8021063 end
803- --Turns HP Recovery
804- elseif t[item].itemname == 'turnsrecoveryrate' then
805- if commandGetState(main.p1Cmd, 'r') and config.TurnsRecoveryRate < 3000 then
1064+ --Turns Recovery Bonus
1065+ elseif t[item].itemname == 'turnsrecoverybonus' then
1066+ if commandGetState(main.p1Cmd, 'r') and config.TurnsRecoveryBonus < 100 then
8061067 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
807- config.TurnsRecoveryRate = config.TurnsRecoveryRate + 10
808- t[item].vardisplay = config.TurnsRecoveryRate
1068+ config.TurnsRecoveryBonus = config.TurnsRecoveryBonus + 0.5
1069+ t[item].vardisplay = config.TurnsRecoveryBonus .. '%'
8091070 modified = 1
810- elseif commandGetState(main.p1Cmd, 'l') and config.TurnsRecoveryRate > 10 then
1071+ elseif commandGetState(main.p1Cmd, 'l') and config.TurnsRecoveryBonus > 0 then
8111072 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
812- config.TurnsRecoveryRate = config.TurnsRecoveryRate - 10
813- t[item].vardisplay = config.TurnsRecoveryRate
1073+ config.TurnsRecoveryBonus = config.TurnsRecoveryBonus - 0.5
1074+ t[item].vardisplay = config.TurnsRecoveryBonus .. '%'
8141075 modified = 1
8151076 end
8161077 --Team Power Share
@@ -833,286 +1094,252 @@ function options.f_advGameplayCfg()
8331094 end
8341095 t[item].vardisplay = options.f_boolDisplay(config.TeamLifeShare)
8351096 modified = 1
836- -- Singke mode
837- elseif t[item].itemname == 'singlemode' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
838- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
839- if config.SingleTeamMode then
840- config.SingleTeamMode = false
841- else
842- config.SingleTeamMode = true
843- end
844- t[item].vardisplay = options.f_boolDisplay(config.SingleTeamMode, motif.option_info.menu_itemname_enabled, motif.option_info.menu_itemname_disabled)
845- modified = 1
846- needReload = 1
847- --Turns Limit
848- elseif t[item].itemname == 'numturns' then
849- if commandGetState(main.p1Cmd, 'r') and config.NumTurns < 8 then
850- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
851- config.NumTurns = config.NumTurns + 1
852- t[item].vardisplay = config.NumTurns
853- modified = 1
854- elseif commandGetState(main.p1Cmd, 'l') and config.NumTurns > 1 then
855- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
856- config.NumTurns = config.NumTurns - 1
857- t[item].vardisplay = options.f_checkTeamAmount(config.NumTurns, 1, motif.option_info.menu_itemname_disabled)
858- modified = 1
859- end
860- -- Disable check
861- if config.NumTurns < 2 then
862- needReload = 1
863- end
864- --Simul Limit
865- elseif t[item].itemname == 'numsimul' then
866- if commandGetState(main.p1Cmd, 'r') and config.NumSimul < 8 then
867- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
868- config.NumSimul = config.NumSimul + 1
869- t[item].vardisplay = config.NumSimul
870- modified = 1
871- elseif commandGetState(main.p1Cmd, 'l') and config.NumSimul > 1 then
872- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
873- config.NumSimul = config.NumSimul - 1
874- t[item].vardisplay = options.f_checkTeamAmount(config.NumSimul, 1, motif.option_info.menu_itemname_disabled)
875- modified = 1
876- end
877- -- Disable check
878- if config.NumSimul < 2 then
879- needReload = 1
880- end
881- --Tag Limit
882- elseif t[item].itemname == 'numtag' then
883- if commandGetState(main.p1Cmd, 'r') and config.NumTag < 8 then
884- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
885- config.NumTag = config.NumTag + 1
886- t[item].vardisplay = config.NumTag
887- modified = 1
888- elseif commandGetState(main.p1Cmd, 'l') and config.NumTag > 1 then
889- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
890- config.NumTag = config.NumTag - 1
891- t[item].vardisplay = options.f_checkTeamAmount(config.NumTag, 1, motif.option_info.menu_itemname_disabled)
892- modified = 1
893- end
894- -- Disable check
895- if config.NumTag < 2 then
896- needReload = 1
897- end
1097+ --Advanced Settings
1098+ elseif t[item].itemname == 'advancedGameplaySettings' and main.f_btnPalNo(main.p1Cmd) > 0 then
1099+ sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
1100+ options.f_advGameplayCfg()
8981101 --Back
8991102 elseif t[item].itemname == 'back' and main.f_btnPalNo(main.p1Cmd) > 0 then
9001103 sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
901- textImgSetText(txt_title, motif.option_info.title_text_gameplay)
1104+ textImgSetText(txt_title, motif.option_info.title_text_main)
9021105 break
9031106 end
904- options.f_menuCommon2(cursorPosY, moveTxt, item, t)
1107+ options.f_menuCommonDraw(cursorPosY, moveTxt, item, t)
9051108 end
9061109 end
9071110
9081111 --;===========================================================
909---; VIDEO SETTINGS
1112+--; ADVANCED GAMEPLAY SETTINGS
9101113 --;===========================================================
911-local t_shaderNames = {}
912-t_shaderNames[0] = "No shader"
913-t_shaderNames[1] = "hqx2"
914-t_shaderNames[2] = "hqx4"
915-t_shaderNames[3] = "scanline"
1114+function options.f_checkTeamAmount(arg1, arg2, arg3)
1115+ ret = arg1
1116+ if arg1 <= arg2 then
1117+ ret = arg3
1118+ end
1119+ return ret
1120+end
9161121
917-local t_videoCfg = {
918- {data = textImgNew(), itemname = 'resolution', displayname = motif.option_info.menu_itemname_video_resolution, vardata = textImgNew(), vardisplay = config.Width .. 'x' .. config.Height},
919- {data = textImgNew(), itemname = 'fullscreen', displayname = motif.option_info.menu_itemname_video_fullscreen, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.Fullscreen)},
920- {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)},
921- {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)},
922- {data = textImgNew(), itemname = 'postprocessingshader', displayname = "Shader", vardata = textImgNew(), vardisplay = t_shaderNames[config.PostProcessingShader]},
1122+options.t_advGameplayCfg = {
1123+ {data = textImgNew(), itemname = 'attackpowermul', displayname = motif.option_info.menu_itemname_gameplay_attackpowermul, vardata = textImgNew(), vardisplay = config['Attack.LifeToPowerMul']},
1124+ {data = textImgNew(), itemname = 'gethitpowermul', displayname = motif.option_info.menu_itemname_gameplay_gethitpowermul, vardata = textImgNew(), vardisplay = config['GetHit.LifeToPowerMul']},
1125+ {data = textImgNew(), itemname = 'superdefencemul', displayname = motif.option_info.menu_itemname_gameplay_superdefencemul, vardata = textImgNew(), vardisplay = config['Super.TargetDefenceMul']},
9231126 {data = textImgNew(), itemname = 'empty', displayname = ' '},
924- {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_video_back},
1127+ {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)},
1128+ {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)},
1129+ {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)},
1130+ {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)},
1131+ {data = textImgNew(), itemname = 'empty', displayname = ' '},
1132+ {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_gameplay_back},
9251133 }
926-t_videoCfg = main.f_cleanTable(t_videoCfg)
1134+options.t_advGameplayCfg = main.f_cleanTable(options.t_advGameplayCfg, main.t_sort.option_info)
9271135
928-function options.f_videoCfg()
1136+function options.f_advGameplayCfg()
9291137 main.f_cmdInput()
9301138 local cursorPosY = 1
9311139 local moveTxt = 0
9321140 local item = 1
933- local t = t_videoCfg
934- textImgSetText(txt_title, motif.option_info.title_text_video)
1141+ local t = options.t_advGameplayCfg
1142+ textImgSetText(txt_title, motif.option_info.title_text_advgameplay)
9351143 while true do
936- cursorPosY, moveTxt, item = options.f_menuCommon1(cursorPosY, moveTxt, item, t)
1144+ cursorPosY, moveTxt, item = options.f_menuCommonCalc(cursorPosY, moveTxt, item, t)
9371145 if esc() then
9381146 sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
939- textImgSetText(txt_title, motif.option_info.title_text_main)
1147+ textImgSetText(txt_title, motif.option_info.title_text_gameplay)
9401148 break
941- --Resolution
942- elseif t[item].itemname == 'resolution' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
943- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
944- options.f_resCfg()
945- t[item].vardisplay = config.Width .. 'x' .. config.Height
946- --Fullscreen
947- elseif t[item].itemname == 'fullscreen' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
948- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
949- if config.Fullscreen then
950- config.Fullscreen = false
951- else
952- config.Fullscreen = true
1149+ --Attack.LifeToPowerMul
1150+ elseif t[item].itemname == 'attackpowermul' then
1151+ if commandGetState(main.p1Cmd, 'r') then
1152+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1153+ config['Attack.LifeToPowerMul'] = options.f_precision(config['Attack.LifeToPowerMul'] + 0.1, '%.01f')
1154+ t[item].vardisplay = config['Attack.LifeToPowerMul']
1155+ setAttackLifeToPowerMul(config['Attack.LifeToPowerMul'])
1156+ modified = 1
1157+ elseif commandGetState(main.p1Cmd, 'l') and config['Attack.LifeToPowerMul'] > 0.1 then
1158+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1159+ config['Attack.LifeToPowerMul'] = options.f_precision(config['Attack.LifeToPowerMul'] - 0.1, '%.01f')
1160+ t[item].vardisplay = config['Attack.LifeToPowerMul']
1161+ setAttackLifeToPowerMul(config['Attack.LifeToPowerMul'])
1162+ modified = 1
9531163 end
954- t[item].vardisplay = options.f_boolDisplay(config.Fullscreen)
955- modified = 1
956- needReload = 1
957- elseif t[item].itemname == 'msaa' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
958- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
959- if config.MSAA then
960- config.MSAA = false
961- else
962- config.MSAA = true
1164+ --GetHit.LifeToPowerMul
1165+ elseif t[item].itemname == 'gethitpowermul' then
1166+ if commandGetState(main.p1Cmd, 'r') then
1167+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1168+ config['GetHit.LifeToPowerMul'] = options.f_precision(config['GetHit.LifeToPowerMul'] + 0.1, '%.01f')
1169+ t[item].vardisplay = config['GetHit.LifeToPowerMul']
1170+ setGetHitLifeToPowerMul(config['GetHit.LifeToPowerMul'])
1171+ modified = 1
1172+ elseif commandGetState(main.p1Cmd, 'l') and config['GetHit.LifeToPowerMul'] > 0.1 then
1173+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1174+ config['GetHit.LifeToPowerMul'] = options.f_precision(config['GetHit.LifeToPowerMul'] - 0.1, '%.01f')
1175+ t[item].vardisplay = config['GetHit.LifeToPowerMul']
1176+ setGetHitLifeToPowerMul(config['GetHit.LifeToPowerMul'])
1177+ modified = 1
9631178 end
964- t[item].vardisplay = options.f_boolDisplay(config.MSAA, motif.option_info.menu_itemname_enabled, motif.option_info.menu_itemname_disabled)
965- modified = 1
966- needReload = 1
967- --AI Palette
968- elseif t[item].itemname == 'airandomcolor' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
1179+ --Super.TargetDefenceMul
1180+ elseif t[item].itemname == 'superdefencemul' then
1181+ if commandGetState(main.p1Cmd, 'r') then
1182+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1183+ config['Super.TargetDefenceMul'] = options.f_precision(config['Super.TargetDefenceMul'] + 0.1, '%.01f')
1184+ t[item].vardisplay = config['Super.TargetDefenceMul']
1185+ setSuperTargetDefenceMul(config['Super.TargetDefenceMul'])
1186+ modified = 1
1187+ elseif commandGetState(main.p1Cmd, 'l') and config['Super.TargetDefenceMul'] > 0.1 then
1188+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1189+ config['Super.TargetDefenceMul'] = options.f_precision(config['Super.TargetDefenceMul'] - 0.1, '%.01f')
1190+ t[item].vardisplay = config['Super.TargetDefenceMul']
1191+ setSuperTargetDefenceMul(config['Super.TargetDefenceMul'])
1192+ modified = 1
1193+ end
1194+ --Single Mode
1195+ elseif t[item].itemname == 'singlemode' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
9691196 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
970- if config.AIRandomColor then
971- config.AIRandomColor = false
1197+ if config.SingleTeamMode then
1198+ config.SingleTeamMode = false
9721199 else
973- config.AIRandomColor = true
1200+ config.SingleTeamMode = true
9741201 end
975- t[item].vardisplay = options.f_boolDisplay(config.AIRandomColor, motif.option_info.menu_itemname_video_aipalette_random, motif.option_info.menu_itemname_video_aipalette_default)
1202+ t[item].vardisplay = options.f_boolDisplay(config.SingleTeamMode, motif.option_info.menu_itemname_enabled, motif.option_info.menu_itemname_disabled)
9761203 modified = 1
977- -- Postprocessing
978- elseif t[item].itemname == 'postprocessingshader' then
979- if commandGetState(main.p1Cmd, 'r') and config.PostProcessingShader < #t_shaderNames then
1204+ --Turns Limit
1205+ elseif t[item].itemname == 'numturns' then
1206+ if commandGetState(main.p1Cmd, 'r') and config.NumTurns < 8 then
9801207 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
981- config.PostProcessingShader = config.PostProcessingShader + 1
1208+ config.NumTurns = config.NumTurns + 1
1209+ t[item].vardisplay = config.NumTurns
9821210 modified = 1
983- needReload = 1
984- elseif commandGetState(main.p1Cmd, 'l') and config.PostProcessingShader > 0 then
1211+ elseif commandGetState(main.p1Cmd, 'l') and config.NumTurns > 1 then
9851212 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
986- config.PostProcessingShader = config.PostProcessingShader - 1
987- modified = 1
988- needReload = 1
989- end
990- t[item].vardisplay = t_shaderNames[config.PostProcessingShader]
991- -- Back
992- elseif t[item].itemname == 'back' and main.f_btnPalNo(main.p1Cmd) > 0 then
993- sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
994- textImgSetText(txt_title, motif.option_info.title_text_main)
995- break
996- end
997- options.f_menuCommon2(cursorPosY, moveTxt, item, t)
998- end
999-end
1000-
1001---;===========================================================
1002---; RESOLUTION SETTINGS
1003---;===========================================================
1004-local t_resCfg = {
1005- {data = textImgNew(), x = 320, y = 240, displayname = motif.option_info.menu_itemname_res_320x240},
1006- {data = textImgNew(), x = 640, y = 480, displayname = motif.option_info.menu_itemname_res_640x480},
1007- {data = textImgNew(), x = 1280, y = 960, displayname = motif.option_info.menu_itemname_res_1280x960},
1008- {data = textImgNew(), x = 1600, y = 1200, displayname = motif.option_info.menu_itemname_res_1600x1200},
1009- {data = textImgNew(), x = 960, y = 720, displayname = motif.option_info.menu_itemname_res_960x720},
1010- {data = textImgNew(), x = 1200, y = 900, displayname = motif.option_info.menu_itemname_res_1200x900},
1011- {data = textImgNew(), x = 1440, y = 1080, displayname = motif.option_info.menu_itemname_res_1440x1080},
1012- {data = textImgNew(), x = 1280, y = 720, displayname = motif.option_info.menu_itemname_res_1280x720},
1013- {data = textImgNew(), x = 1600, y = 900, displayname = motif.option_info.menu_itemname_res_1600x900},
1014- {data = textImgNew(), x = 1920, y = 1080, displayname = motif.option_info.menu_itemname_res_1920x1080},
1015- {data = textImgNew(), x = 2560, y = 1440, displayname = motif.option_info.menu_itemname_res_2560x1440},
1016- {data = textImgNew(), x = 3840, y = 2160, displayname = motif.option_info.menu_itemname_res_3840x2160},
1017- {data = textImgNew(), itemname = 'empty', displayname = ' '},
1018- {data = textImgNew(), itemname = 'custom', displayname = motif.option_info.menu_itemname_res_custom},
1019- {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_res_back},
1020-}
1021-t_resCfg = main.f_cleanTable(t_resCfg)
1022-
1023-function options.f_resCfg()
1024- main.f_cmdInput()
1025- local cursorPosY = 1
1026- local moveTxt = 0
1027- local item = 1
1028- local t = t_resCfg
1029- textImgSetText(txt_title, motif.option_info.title_text_res)
1030- while true do
1031- cursorPosY, moveTxt, item = options.f_menuCommon1(cursorPosY, moveTxt, item, t)
1032- if esc() then
1033- sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1034- textImgSetText(txt_title, motif.option_info.title_text_video)
1035- break
1036- elseif main.f_btnPalNo(main.p1Cmd) > 0 then
1037- --Back
1038- if t[item].itemname == 'back' then
1039- sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1040- textImgSetText(txt_title, motif.option_info.title_text_video)
1041- break
1042- --Custom
1043- elseif t[item].itemname == 'custom' then
1213+ config.NumTurns = config.NumTurns - 1
1214+ t[item].vardisplay = options.f_checkTeamAmount(config.NumTurns, 1, motif.option_info.menu_itemname_disabled)
1215+ if config.NumTurns < 2 then
1216+ select.t_p1TeamMenu = select.f_getTeamMenu()
1217+ select.t_p1TeamMenu = main.f_cleanTable(select.t_p1TeamMenu, main.t_sort.select_info)
1218+ select.t_p2TeamMenu = select.f_getTeamMenu()
1219+ select.t_p2TeamMenu = main.f_cleanTable(select.t_p2TeamMenu, main.t_sort.select_info)
1220+ end
1221+ modified = 1
1222+ end
1223+ --Simul Limit
1224+ elseif t[item].itemname == 'numsimul' then
1225+ if commandGetState(main.p1Cmd, 'r') and config.NumSimul < 8 then
10441226 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1045- local width = tonumber(main.f_input(main.f_extractText(motif.option_info.input_text_reswidth), motif.option_info, motif.optionbgdef, 'string'))
1046- if width ~= nil then
1047- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1048- local height = tonumber(main.f_input(main.f_extractText(motif.option_info.input_text_resheight), motif.option_info, motif.optionbgdef, 'string'))
1049- if height ~= nil then
1050- config.Width = width
1051- config.Height = height
1052- sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
1053- if (height / 3 * 4) ~= width then
1054- main.f_warning(main.f_extractText(motif.warning_info.text_res), motif.option_info, motif.optionbgdef)
1055- end
1056- modified = 1
1057- needReload = 1
1058- else
1059- sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1060- end
1061- else
1062- sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1227+ config.NumSimul = config.NumSimul + 1
1228+ t[item].vardisplay = config.NumSimul
1229+ modified = 1
1230+ elseif commandGetState(main.p1Cmd, 'l') and config.NumSimul > 1 then
1231+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1232+ config.NumSimul = config.NumSimul - 1
1233+ t[item].vardisplay = options.f_checkTeamAmount(config.NumSimul, 1, motif.option_info.menu_itemname_disabled)
1234+ if config.NumSimul < 2 then
1235+ select.t_p1TeamMenu = select.f_getTeamMenu()
1236+ select.t_p1TeamMenu = main.f_cleanTable(select.t_p1TeamMenu, main.t_sort.select_info)
1237+ select.t_p2TeamMenu = select.f_getTeamMenu()
1238+ select.t_p2TeamMenu = main.f_cleanTable(select.t_p2TeamMenu, main.t_sort.select_info)
10631239 end
1064- break
1065- --Resolution
1066- else
1067- sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
1068- config.Width = t[item].x
1069- config.Height = t[item].y
1070- if (config.Height / 3 * 4) ~= config.Width then
1071- main.f_warning(main.f_extractText(motif.warning_info.text_res), motif.option_info, motif.optionbgdef)
1240+ modified = 1
1241+ end
1242+ --Tag Limit
1243+ elseif t[item].itemname == 'numtag' then
1244+ if commandGetState(main.p1Cmd, 'r') and config.NumTag < 4 then
1245+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1246+ config.NumTag = config.NumTag + 1
1247+ t[item].vardisplay = config.NumTag
1248+ modified = 1
1249+ elseif commandGetState(main.p1Cmd, 'l') and config.NumTag > 1 then
1250+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1251+ config.NumTag = config.NumTag - 1
1252+ t[item].vardisplay = options.f_checkTeamAmount(config.NumTag, 1, motif.option_info.menu_itemname_disabled)
1253+ if config.NumTag < 2 then
1254+ select.t_p1TeamMenu = select.f_getTeamMenu()
1255+ select.t_p1TeamMenu = main.f_cleanTable(select.t_p1TeamMenu, main.t_sort.select_info)
1256+ select.t_p2TeamMenu = select.f_getTeamMenu()
1257+ select.t_p2TeamMenu = main.f_cleanTable(select.t_p2TeamMenu, main.t_sort.select_info)
10721258 end
10731259 modified = 1
1074- needReload = 1
1075- break
10761260 end
1261+ --Back
1262+ elseif t[item].itemname == 'back' and main.f_btnPalNo(main.p1Cmd) > 0 then
1263+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1264+ textImgSetText(txt_title, motif.option_info.title_text_gameplay)
1265+ break
10771266 end
1078- options.f_menuCommon2(cursorPosY, moveTxt, item, t)
1267+ options.f_menuCommonDraw(cursorPosY, moveTxt, item, t)
10791268 end
10801269 end
10811270
10821271 --;===========================================================
10831272 --; ENGINE SETTINGS
10841273 --;===========================================================
1085-local t_engineCfg = {
1274+options.t_engineCfg = {
10861275 {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)},
1087- {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)},
1276+ {data = textImgNew(), itemname = 'simulmode', displayname = motif.option_info.menu_itemname_engine_simulmode, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.SimulMode, motif.option_info.menu_itemname_disabled, motif.option_info.menu_itemname_enabled)},
1277+ {data = textImgNew(), itemname = 'lifebarfontscale', displayname = motif.option_info.menu_itemname_engine_lifebarfontscale, vardata = textImgNew(), vardisplay = config.LifebarFontScale},
10881278 {data = textImgNew(), itemname = 'empty', displayname = ' '},
1089- {data = textImgNew(), itemname = 'helpermax', displayname = motif.option_info.menu_itemname_video_helpermax, vardata = textImgNew(), vardisplay = config.HelperMax},
1090- {data = textImgNew(), itemname = 'playerprojectilemax', displayname = motif.option_info.menu_itemname_video_playerprojectilemax, vardata = textImgNew(), vardisplay = config.PlayerProjectileMax},
1091- {data = textImgNew(), itemname = 'explodmax', displayname = motif.option_info.menu_itemname_video_explodmax, vardata = textImgNew(), vardisplay = config.ExplodMax},
1092- {data = textImgNew(), itemname = 'afterimagemax', displayname = motif.option_info.menu_itemname_video_afterimagemax, vardata = textImgNew(), vardisplay = config.AfterImageMax},
1279+ {data = textImgNew(), itemname = 'helpermax', displayname = motif.option_info.menu_itemname_engine_helpermax, vardata = textImgNew(), vardisplay = config.HelperMax},
1280+ {data = textImgNew(), itemname = 'playerprojectilemax', displayname = motif.option_info.menu_itemname_engine_playerprojectilemax, vardata = textImgNew(), vardisplay = config.PlayerProjectileMax},
1281+ {data = textImgNew(), itemname = 'explodmax', displayname = motif.option_info.menu_itemname_engine_explodmax, vardata = textImgNew(), vardisplay = config.ExplodMax},
1282+ {data = textImgNew(), itemname = 'afterimagemax', displayname = motif.option_info.menu_itemname_engine_afterimagemax, vardata = textImgNew(), vardisplay = config.AfterImageMax},
10931283 {data = textImgNew(), itemname = 'empty', displayname = ' '},
1094- {data = textImgNew(), itemname = 'zoomactive', displayname = motif.option_info.menu_itemname_video_zoomactive, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.ZoomActive)},
1095- {data = textImgNew(), itemname = 'maxzoomout', displayname = motif.option_info.menu_itemname_video_maxzoomout, vardata = textImgNew(), vardisplay = config.ZoomMin},
1096- {data = textImgNew(), itemname = 'maxzoomin', displayname = motif.option_info.menu_itemname_video_maxzoomin, vardata = textImgNew(), vardisplay = config.ZoomMax},
1097- {data = textImgNew(), itemname = 'zoomspeed', displayname = motif.option_info.menu_itemname_video_zoomspeed, vardata = textImgNew(), vardisplay = config.ZoomSpeed},
1284+ {data = textImgNew(), itemname = 'zoomactive', displayname = motif.option_info.menu_itemname_engine_zoomactive, vardata = textImgNew(), vardisplay = options.f_boolDisplay(config.ZoomActive)},
1285+ {data = textImgNew(), itemname = 'maxzoomout', displayname = motif.option_info.menu_itemname_engine_maxzoomout, vardata = textImgNew(), vardisplay = config.ZoomMin},
1286+ {data = textImgNew(), itemname = 'maxzoomin', displayname = motif.option_info.menu_itemname_engine_maxzoomin, vardata = textImgNew(), vardisplay = config.ZoomMax},
1287+ {data = textImgNew(), itemname = 'zoomspeed', displayname = motif.option_info.menu_itemname_engine_zoomspeed, vardata = textImgNew(), vardisplay = config.ZoomSpeed},
10981288 {data = textImgNew(), itemname = 'empty', displayname = ' '},
10991289 {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_video_back},
11001290 }
1101-t_engineCfg = main.f_cleanTable(t_engineCfg)
1291+options.t_engineCfg = main.f_cleanTable(options.t_engineCfg, main.t_sort.option_info)
11021292
11031293 function options.f_engineCfg()
11041294 main.f_cmdInput()
11051295 local cursorPosY = 1
11061296 local moveTxt = 0
11071297 local item = 1
1108- local t = t_engineCfg
1298+ local t = options.t_engineCfg
11091299 textImgSetText(txt_title, motif.option_info.title_text_engine)
11101300 while true do
1111- cursorPosY, moveTxt, item = options.f_menuCommon1(cursorPosY, moveTxt, item, t)
1301+ cursorPosY, moveTxt, item = options.f_menuCommonCalc(cursorPosY, moveTxt, item, t)
11121302 if esc() then
11131303 sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
11141304 textImgSetText(txt_title, motif.option_info.title_text_main)
11151305 break
1306+ --Allow Debug Keys
1307+ elseif t[item].itemname == 'allowdebugkeys' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
1308+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1309+ if config.AllowDebugKeys then
1310+ config.AllowDebugKeys = false
1311+ else
1312+ config.AllowDebugKeys = true
1313+ end
1314+ t[item].vardisplay = options.f_boolDisplay(config.AllowDebugKeys, motif.option_info.menu_itemname_enabled, motif.option_info.menu_itemname_disabled)
1315+ setAllowDebugKeys(config.AllowDebugKeys)
1316+ modified = 1
1317+ --Legacy Tag Mode
1318+ elseif t[item].itemname == 'simulmode' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
1319+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1320+ if config.SimulMode then
1321+ config.SimulMode = false
1322+ else
1323+ config.SimulMode = true
1324+ end
1325+ t[item].vardisplay = options.f_boolDisplay(config.SimulMode, motif.option_info.menu_itemname_disabled, motif.option_info.menu_itemname_enabled)
1326+ main.f_warning(main.f_extractText(motif.warning_info.text_simul), motif.option_info, motif.optionbgdef)
1327+ modified = 1
1328+ --Lifebar Font Scale
1329+ elseif t[item].itemname == 'lifebarfontscale' then
1330+ if commandGetState(main.p1Cmd, 'r') then
1331+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1332+ config.LifebarFontScale = options.f_precision(config.LifebarFontScale + 0.1, '%.01f')
1333+ t[item].vardisplay = config.LifebarFontScale
1334+ modified = 1
1335+ needReload = 1
1336+ elseif commandGetState(main.p1Cmd, 'l') and config.LifebarFontScale > 0.1 then
1337+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1338+ config.LifebarFontScale = options.f_precision(config.LifebarFontScale - 0.1, '%.01f')
1339+ t[item].vardisplay = config.LifebarFontScale
1340+ modified = 1
1341+ needReload = 1
1342+ end
11161343 --HelperMax
11171344 elseif t[item].itemname == 'helpermax' then
11181345 if commandGetState(main.p1Cmd, 'r') then
@@ -1222,82 +1449,54 @@ function options.f_engineCfg()
12221449 t[item].vardisplay = config.ZoomSpeed
12231450 modified = 1
12241451 end
1225- -- Leagcy TAG Mode
1226- elseif t[item].itemname == 'simulmode' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
1227- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1228- if config.SimulMode then
1229- config.SimulMode = false
1230- else
1231- config.SimulMode = true
1232- end
1233- t[item].vardisplay = options.f_boolDisplay(config.SimulMode, motif.option_info.menu_itemname_disabled, motif.option_info.menu_itemname_enabled)
1234- modified = 1
1235- needReload = 1
1236- -- Allow Debug Keys
1237- elseif t[item].itemname == 'allowdebugkeys' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
1238- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1239- if config.AllowDebugKeys then
1240- config.AllowDebugKeys = false
1241- else
1242- config.AllowDebugKeys = true
1243- end
1244- t[item].vardisplay = options.f_boolDisplay(config.AllowDebugKeys, motif.option_info.menu_itemname_enabled, motif.option_info.menu_itemname_disabled)
1245- modified = 1
1246- needReload = 1
12471452 --Back
12481453 elseif t[item].itemname == 'back' and main.f_btnPalNo(main.p1Cmd) > 0 then
12491454 sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
12501455 textImgSetText(txt_title, motif.option_info.title_text_main)
12511456 break
12521457 end
1253- options.f_menuCommon2(cursorPosY, moveTxt, item, t)
1458+ options.f_menuCommonDraw(cursorPosY, moveTxt, item, t)
12541459 end
12551460 end
12561461
12571462 --;===========================================================
12581463 --; INPUT SETTINGS
12591464 --;===========================================================
1260-local t_inputCfg = {
1261- {data = textImgNew(), itemname = 'p1keyboard', displayname = motif.option_info.menu_itemname_input_p1keyboard},
1262- {data = textImgNew(), itemname = 'p1gamepad', displayname = motif.option_info.menu_itemname_input_p1gamepad},
1263- {data = textImgNew(), itemname = 'p2keyboard', displayname = motif.option_info.menu_itemname_input_p2keyboard},
1264- {data = textImgNew(), itemname = 'p2gamepad', displayname = motif.option_info.menu_itemname_input_p2gamepad},
1465+options.t_inputCfg = {
1466+ {data = textImgNew(), itemname = 'keyboard', displayname = motif.option_info.menu_itemname_input_keyboard},
1467+ {data = textImgNew(), itemname = 'gamepad', displayname = motif.option_info.menu_itemname_input_gamepad},
1468+ --{data = textImgNew(), itemname = 'system', displayname = motif.option_info.menu_itemname_input_system},
12651469 {data = textImgNew(), itemname = 'empty', displayname = ' '},
12661470 {data = textImgNew(), itemname = 'defaultvalues', displayname = motif.option_info.menu_itemname_input_default},
12671471 {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_input_back},
12681472 }
1269-t_inputCfg = main.f_cleanTable(t_inputCfg)
1473+options.t_inputCfg = main.f_cleanTable(options.t_inputCfg, main.t_sort.option_info)
12701474
12711475 function options.f_inputCfg()
12721476 main.f_cmdInput()
12731477 local cursorPosY = 1
12741478 local moveTxt = 0
12751479 local item = 1
1276- local t = t_inputCfg
1480+ local t = options.t_inputCfg
12771481 textImgSetText(txt_title, motif.option_info.title_text_input)
12781482 while true do
1279- cursorPosY, moveTxt, item = options.f_menuCommon1(cursorPosY, moveTxt, item, t)
1483+ cursorPosY, moveTxt, item = options.f_menuCommonCalc(cursorPosY, moveTxt, item, t)
12801484 if esc() then
12811485 sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
12821486 textImgSetText(txt_title, motif.option_info.title_text_main)
12831487 break
12841488 elseif main.f_btnPalNo(main.p1Cmd) > 0 then
1285- --P1 Keyboard
1286- if t[item].itemname == 'p1keyboard' then
1489+ --Key Config
1490+ if t[item].itemname == 'keyboard' then
12871491 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1288- options.f_keyCfg(1, -1)
1289- --P1 Gamepad
1290- elseif t[item].itemname == 'p1gamepad' then
1492+ options.f_keyCfg('KeyConfig', t[item].itemname)
1493+ --Joystick Config
1494+ elseif t[item].itemname == 'gamepad' then
12911495 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1292- options.f_keyCfg(1, 0)
1293- --P2 Keyboard
1294- elseif t[item].itemname == 'p2keyboard' then
1496+ options.f_keyCfg('JoystickConfig', t[item].itemname)
1497+ --System Keys (not implemented yet)
1498+ elseif t[item].itemname == 'system' then
12951499 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1296- options.f_keyCfg(2, -1)
1297- --P2 Gamepad
1298- elseif t[item].itemname == 'p2gamepad' then
1299- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1300- options.f_keyCfg(2, 1)
13011500 --Default Values
13021501 elseif t[item].itemname == 'defaultvalues' then
13031502 sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
@@ -1311,7 +1510,7 @@ function options.f_inputCfg()
13111510 break
13121511 end
13131512 end
1314- options.f_menuCommon2(cursorPosY, moveTxt, item, t)
1513+ options.f_menuCommonDraw(cursorPosY, moveTxt, item, t)
13151514 end
13161515 end
13171516
@@ -1319,162 +1518,505 @@ end
13191518 --; KEY SETTINGS
13201519 --;===========================================================
13211520 local t_keyCfg = {
1322- {data = textImgNew(), itemname = 'up', displayname = motif.option_info.menu_itemname_key_up, vardata = textImgNew(), vardisplay = ''},
1323- {data = textImgNew(), itemname = 'down', displayname = motif.option_info.menu_itemname_key_down, vardata = textImgNew(), vardisplay = ''},
1324- {data = textImgNew(), itemname = 'left', displayname = motif.option_info.menu_itemname_key_left, vardata = textImgNew(), vardisplay = ''},
1325- {data = textImgNew(), itemname = 'right', displayname = motif.option_info.menu_itemname_key_right, vardata = textImgNew(), vardisplay = ''},
1326- {data = textImgNew(), itemname = 'a', displayname = motif.option_info.menu_itemname_key_a, vardata = textImgNew(), vardisplay = ''},
1327- {data = textImgNew(), itemname = 'b', displayname = motif.option_info.menu_itemname_key_b, vardata = textImgNew(), vardisplay = ''},
1328- {data = textImgNew(), itemname = 'c', displayname = motif.option_info.menu_itemname_key_c, vardata = textImgNew(), vardisplay = ''},
1329- {data = textImgNew(), itemname = 'x', displayname = motif.option_info.menu_itemname_key_x, vardata = textImgNew(), vardisplay = ''},
1330- {data = textImgNew(), itemname = 'y', displayname = motif.option_info.menu_itemname_key_y, vardata = textImgNew(), vardisplay = ''},
1331- {data = textImgNew(), itemname = 'z', displayname = motif.option_info.menu_itemname_key_z, vardata = textImgNew(), vardisplay = ''},
1332- {data = textImgNew(), itemname = 'start', displayname = motif.option_info.menu_itemname_key_start, vardata = textImgNew(), vardisplay = ''},
1333- {data = textImgNew(), itemname = 'v', displayname = motif.option_info.menu_itemname_key_v, vardata = textImgNew(), vardisplay = ''},
1334- {data = textImgNew(), itemname = 'w', displayname = motif.option_info.menu_itemname_key_w, vardata = textImgNew(), vardisplay = ''},
1335- {data = textImgNew(), itemname = 'empty', displayname = ' '},
1336- {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_key_back},
1521+ {data = textImgNew(), itemname = 'dummy', displayname = ''},
1522+ {data = textImgNew(), itemname = 'configall', displayname = motif.option_info.menu_itemname_key_all, infodata = textImgNew(), infodisplay = ''},
1523+ {data = textImgNew(), itemname = 'up', displayname = motif.option_info.menu_itemname_key_up, vardata = textImgNew()},
1524+ {data = textImgNew(), itemname = 'down', displayname = motif.option_info.menu_itemname_key_down, vardata = textImgNew()},
1525+ {data = textImgNew(), itemname = 'left', displayname = motif.option_info.menu_itemname_key_left, vardata = textImgNew()},
1526+ {data = textImgNew(), itemname = 'right', displayname = motif.option_info.menu_itemname_key_right, vardata = textImgNew()},
1527+ {data = textImgNew(), itemname = 'a', displayname = motif.option_info.menu_itemname_key_a, vardata = textImgNew()},
1528+ {data = textImgNew(), itemname = 'b', displayname = motif.option_info.menu_itemname_key_b, vardata = textImgNew()},
1529+ {data = textImgNew(), itemname = 'c', displayname = motif.option_info.menu_itemname_key_c, vardata = textImgNew()},
1530+ {data = textImgNew(), itemname = 'x', displayname = motif.option_info.menu_itemname_key_x, vardata = textImgNew()},
1531+ {data = textImgNew(), itemname = 'y', displayname = motif.option_info.menu_itemname_key_y, vardata = textImgNew()},
1532+ {data = textImgNew(), itemname = 'z', displayname = motif.option_info.menu_itemname_key_z, vardata = textImgNew()},
1533+ {data = textImgNew(), itemname = 'start', displayname = motif.option_info.menu_itemname_key_start, vardata = textImgNew()},
1534+ {data = textImgNew(), itemname = 'd', displayname = motif.option_info.menu_itemname_key_d, vardata = textImgNew()},
1535+ {data = textImgNew(), itemname = 'w', displayname = motif.option_info.menu_itemname_key_w, vardata = textImgNew()},
1536+ {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_key_back, infodata = textImgNew(), infodisplay = motif.option_info.menu_itemname_info_esc},
13371537 }
1338-t_keyCfg = main.f_cleanTable(t_keyCfg)
1538+--t_keyCfg = main.f_cleanTable(t_keyCfg, main.t_sort.option_info)
13391539
1340-function options.f_keyCfg(playerNo, controller)
1540+local txt_keyController = textImgNew()
1541+function options.f_keyCfg(cfgType, controller)
13411542 main.f_cmdInput()
1342- local cursorPosY = 1
1543+ local cursorPosY = 2
13431544 local moveTxt = 0
1344- local item = 1
1545+ local item = 2
1546+ local item_start = 2
13451547 local t = t_keyCfg
1548+ local t_pos = {motif.option_info.menu_key_p1_pos, motif.option_info.menu_key_p2_pos}
1549+ local configall = false
1550+ local key = ''
1551+ local t_keyList = {}
1552+ local t_conflict = {}
1553+ local btnReleased = 0
1554+ local player = 1
1555+ local btn = tostring(config[cfgType][player].Buttons[item - item_start])
1556+ local joyNum = 0
13461557 textImgSetText(txt_title, motif.option_info.title_text_key)
1347- for i = 1, #t_keyCfg do
1348- if controller == -1 then
1349- t_keyCfg[i].vardisplay = config.KeyConfig[playerNo].Buttons[i]
1350- else
1351- t_keyCfg[i].vardisplay = config.JoystickConfig[playerNo].Buttons[i]
1558+ --count all button assignments on the same controller
1559+ for i = 1, #config[cfgType] do
1560+ joyNum = config[cfgType][i].Joystick
1561+ if t_keyList[joyNum] == nil then
1562+ t_keyList[joyNum] = {} --creates subtable for each controller (1 for keyboard or at least 2 for gamepads)
1563+ t_conflict[joyNum] = false --set default conflict flag for each controller
1564+ end
1565+ for k, v in pairs(config[cfgType][i].Buttons) do
1566+ v = tostring(v)
1567+ t_keyCfg[k + item_start]['vardisplay' .. i] = v --assign vardisplay entry (assigned button name) in t_keyCfg table
1568+ if v ~= tostring(motif.option_info.menu_itemname_info_disable) then --if button is not disabled
1569+ if t_keyList[joyNum][v] == nil then
1570+ t_keyList[joyNum][v] = 1
1571+ else
1572+ t_keyList[joyNum][v] = t_keyList[joyNum][v] + 1
1573+ end
1574+ end
13521575 end
13531576 end
1577+ joyNum = config[cfgType][player].Joystick
13541578 while true do
1355- cursorPosY, moveTxt, item = options.f_menuCommon1(cursorPosY, moveTxt, item, t)
1356- if esc() then
1357- sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1358- textImgSetText(txt_title, motif.option_info.title_text_input)
1359- break
1360- elseif main.f_btnPalNo(main.p1Cmd) > 0 then
1361- --Back
1362- if t[item].itemname == 'back' then
1579+ --Config all
1580+ if configall then
1581+ if cfgType == 'KeyConfig' then --detect keyboard key
1582+ key = getKey()
1583+ elseif getJoystickPresent(joyNum) == false then --ensure that gamepad is connected
1584+ main.f_warning(main.f_extractText(motif.warning_info.text_pad), motif.option_info, motif.optionbgdef)
1585+ configall = false
1586+ commandBufReset(main.p1Cmd)
1587+ else --detect gamepad key
1588+ local tmp = getKey()
1589+ if tonumber(tmp) == nil then --button released
1590+ btnReleased = 1
1591+ elseif btnReleased == 1 then --button pressed after releasing button once
1592+ key = tmp
1593+ btnReleased = 0
1594+ end
1595+ end
1596+ key = tostring(key)
1597+ if esc() then
13631598 sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1364- textImgSetText(txt_title, motif.option_info.title_text_input)
1365- break
1366- --Buttons
1367- else
1368- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1369- local key = main.f_input(main.f_extractText(motif.option_info.input_text_key), motif.option_info, motif.optionbgdef, 'key')
1370- if (controller == -1 and key ~= '') or (controller ~= -1 and tonumber(key) ~= nil) then
1371- sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
1372- t[item].vardisplay = key
1373- if controller == -1 then
1374- config.KeyConfig[playerNo].Buttons[item] = key
1599+ configall = false
1600+ commandBufReset(main.p1Cmd)
1601+ --some key detected
1602+ elseif key ~= '' then
1603+ --spacebar (disable key)
1604+ if key == 'SPACE' then
1605+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1606+ --decrease old button count
1607+ if t_keyList[joyNum][btn] ~= nil and t_keyList[joyNum][btn] > 1 then
1608+ t_keyList[joyNum][btn] = t_keyList[joyNum][btn] - 1
1609+ else
1610+ t_keyList[joyNum][btn] = nil
1611+ end
1612+ --update vardisplay / config data
1613+ t[item]['vardisplay' .. player] = motif.option_info.menu_itemname_info_disable
1614+ config[cfgType][player].Buttons[item - item_start] = tostring(motif.option_info.menu_itemname_info_disable)
1615+ modified = 1
1616+ needReload = 1
1617+ --other keyboard or gamepad key
1618+ elseif cfgType == 'KeyConfig' or (cfgType == 'JoystickConfig' and tonumber(key) ~= nil) then
1619+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1620+ --decrease old button count
1621+ if t_keyList[joyNum][btn] ~= nil and t_keyList[joyNum][btn] > 1 then
1622+ t_keyList[joyNum][btn] = t_keyList[joyNum][btn] - 1
1623+ else
1624+ t_keyList[joyNum][btn] = nil
1625+ end
1626+ --increase new button count
1627+ if t_keyList[joyNum][key] == nil then
1628+ t_keyList[joyNum][key] = 1
13751629 else
1376- config.JoystickConfig[playerNo].Buttons[item] = key
1630+ t_keyList[joyNum][key] = t_keyList[joyNum][key] + 1
13771631 end
1632+ --update vardisplay / config data
1633+ t[item]['vardisplay' .. player] = key
1634+ config[cfgType][player].Buttons[item - item_start] = tostring(key)
1635+ modified = 1
1636+ needReload = 1
1637+ --non gamepad key on gamepad controller
13781638 else
13791639 sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
13801640 end
1641+ --move to the next position
1642+ item = item + 1
1643+ if cursorPosY < motif.option_info.menu_window_visibleitems then
1644+ cursorPosY = cursorPosY + 1
1645+ end
1646+ if item > 15 then
1647+ item = item_start
1648+ cursorPosY = item_start
1649+ configall = false
1650+ commandBufReset(main.p1Cmd)
1651+ end
13811652 end
1382- modified = 1
1383- needReload = 1
1653+ resetKey()
1654+ key = ''
1655+ --move up / down / left / right
1656+ elseif commandGetState(main.p1Cmd, 'u') then
1657+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1658+ item = item - 1
1659+ elseif commandGetState(main.p1Cmd, 'd') then
1660+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1661+ item = item + 1
1662+ elseif commandGetState(main.p1Cmd, 'l') or commandGetState(main.p1Cmd, 'r') then
1663+ sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1664+ if player == 1 then
1665+ player = 2
1666+ else
1667+ player = 1
1668+ end
1669+ joyNum = config[cfgType][player].Joystick
13841670 end
1385- options.f_menuCommon2(cursorPosY, moveTxt, item, t)
1386- end
1387-end
1388-
1389---;===========================================================
1390---; AUDIO SETTINGS
1391---;===========================================================
1392-local t_audioCfg = {
1393- {data = textImgNew(), itemname = 'mastervolume', displayname = motif.option_info.menu_itemname_audio_mastervolume, vardata = textImgNew(), vardisplay = config.MasterVolume .. '%'},
1394- {data = textImgNew(), itemname = 'bgmvolume', displayname = motif.option_info.menu_itemname_audio_bgmvolume, vardata = textImgNew(), vardisplay = config.BgmVolume .. '%'},
1395- {data = textImgNew(), itemname = 'sfxvolume', displayname = motif.option_info.menu_itemname_audio_sfxvolume, vardata = textImgNew(), vardisplay = config.WavVolume .. '%'},
1396- {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)},
1397- {data = textImgNew(), itemname = 'empty', displayname = ' '},
1398- {data = textImgNew(), itemname = 'back', displayname = motif.option_info.menu_itemname_video_back},
1399-}
1400-t_audioCfg = main.f_cleanTable(t_audioCfg)
1401-
1402-function options.f_audioCfg()
1403- main.f_cmdInput()
1404- local cursorPosY = 1
1405- local moveTxt = 0
1406- local item = 1
1407- local t = t_audioCfg
1408- textImgSetText(txt_title, motif.option_info.title_text_audio)
1409- while true do
1410- cursorPosY, moveTxt, item = options.f_menuCommon1(cursorPosY, moveTxt, item, t)
1411- if esc() then
1412- sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1413- textImgSetText(txt_title, motif.option_info.title_text_main)
1414- break
1415- -- Master Volume
1416- elseif t[item].itemname == 'mastervolume' then
1417- if commandGetState(main.p1Cmd, 'r') and config.MasterVolume < 200 then
1418- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1419- config.MasterVolume = config.MasterVolume + 1
1420- t[item].vardisplay = config.MasterVolume .. '%'
1421- modified = 1
1422- needReload = 1
1423- elseif commandGetState(main.p1Cmd, 'l') and config.MasterVolume > 0 then
1424- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1425- config.MasterVolume = config.MasterVolume - 1
1426- t[item].vardisplay = config.MasterVolume .. '%'
1427- modified = 1
1428- needReload = 1
1671+ --cursor position calculation
1672+ if item < item_start then
1673+ item = #t
1674+ if #t > motif.option_info.menu_window_visibleitems then
1675+ cursorPosY = motif.option_info.menu_window_visibleitems
1676+ else
1677+ cursorPosY = #t
14291678 end
1430- -- BGM Volume
1431- elseif t[item].itemname == 'bgmvolume' then
1432- if commandGetState(main.p1Cmd, 'r') and config.BgmVolume < 100 then
1433- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1434- config.BgmVolume = config.BgmVolume + 1
1435- t[item].vardisplay = config.BgmVolume .. '%'
1436- modified = 1
1437- needReload = 1
1438- elseif commandGetState(main.p1Cmd, 'l') and config.BgmVolume > 0 then
1439- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1440- config.BgmVolume = config.BgmVolume - 1
1441- t[item].vardisplay = config.BgmVolume .. '%'
1442- modified = 1
1443- needReload = 1
1679+ elseif item > #t then
1680+ item = item_start
1681+ cursorPosY = item_start
1682+ elseif configall == false then
1683+ if commandGetState(main.p1Cmd, 'u') and cursorPosY > item_start then
1684+ cursorPosY = cursorPosY - 1
1685+ elseif commandGetState(main.p1Cmd, 'd') and cursorPosY < motif.option_info.menu_window_visibleitems then
1686+ cursorPosY = cursorPosY + 1
14441687 end
1445- -- SFX Volume
1446- elseif t[item].itemname == 'sfxvolume' then
1447- if commandGetState(main.p1Cmd, 'r') and config.WavVolume < 100 then
1448- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1449- config.WavVolume = config.WavVolume + 1
1450- t[item].vardisplay = config.WavVolume .. '%'
1451- modified = 1
1452- needReload = 1
1453- elseif commandGetState(main.p1Cmd, 'l') and config.WavVolume > 0 then
1688+ end
1689+ if cursorPosY == motif.option_info.menu_window_visibleitems then
1690+ moveTxt = (item - motif.option_info.menu_window_visibleitems) * motif.option_info.menu_item_spacing[2]
1691+ elseif cursorPosY == item_start then
1692+ moveTxt = (item - item_start) * motif.option_info.menu_item_spacing[2]
1693+ end
1694+ btn = tostring(config[cfgType][player].Buttons[item - item_start])
1695+ if configall == false then
1696+ if esc() and not t_conflict[joyNum] then
1697+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1698+ textImgSetText(txt_title, motif.option_info.title_text_input)
1699+ break
1700+ --Config all
1701+ elseif (t[item].itemname == 'configall' and main.f_btnPalNo(main.p1Cmd) > 0) or getKey() == 'F1' or getKey() == 'F2' then
1702+ sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
1703+ if getKey() == 'F1' then
1704+ player = 1
1705+ elseif getKey() == 'F2' then
1706+ player = 2
1707+ end
1708+ if cfgType == 'JoystickConfig' and getJoystickPresent(joyNum) == false then
1709+ main.f_warning(main.f_extractText(motif.warning_info.text_pad), motif.option_info, motif.optionbgdef)
1710+ item = item_start
1711+ cursorPosY = item_start
1712+ else
1713+ resetKey()
1714+ item = item_start + 1
1715+ cursorPosY = item_start + 1
1716+ btnReleased = 0
1717+ configall = true
1718+ end
1719+ --Back
1720+ elseif (t[item].itemname == 'back' and main.f_btnPalNo(main.p1Cmd) > 0) then
1721+ if t_conflict[joyNum] then
1722+ main.f_warning(main.f_extractText(motif.warning_info.text_keys), motif.option_info, motif.optionbgdef)
1723+ else
1724+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1725+ textImgSetText(txt_title, motif.option_info.title_text_input)
1726+ break
1727+ end
1728+ --individual buttons
1729+ elseif main.f_btnPalNo(main.p1Cmd) > 0 then
14541730 sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1455- config.WavVolume = config.WavVolume - 1
1456- t[item].vardisplay = config.WavVolume .. '%'
1457- modified = 1
1458- needReload = 1
1731+ if cfgType == 'JoystickConfig' and getJoystickPresent(joyNum) == false then
1732+ main.f_warning(main.f_extractText(motif.warning_info.text_pad), motif.option_info, motif.optionbgdef)
1733+ else
1734+ key = main.f_input(main.f_extractText(motif.option_info.input_text_key), motif.option_info, motif.optionbgdef, controller, joyNum, 'SPACE')
1735+ --spacebar (disable key)
1736+ if key == 'SPACE' then
1737+ sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
1738+ --decrease old button count
1739+ if t_keyList[joyNum][btn] ~= nil and t_keyList[joyNum][btn] > 1 then
1740+ t_keyList[joyNum][btn] = t_keyList[joyNum][btn] - 1
1741+ else
1742+ t_keyList[joyNum][btn] = nil
1743+ end
1744+ --update vardisplay / config data
1745+ t[item]['vardisplay' .. player] = motif.option_info.menu_itemname_info_disable
1746+ config[cfgType][player].Buttons[item - item_start] = motif.option_info.menu_itemname_info_disable
1747+ modified = 1
1748+ needReload = 1
1749+ --other keyboard or gamepad key
1750+ elseif (cfgType == 'KeyConfig' and key ~= '') or (cfgType == 'JoystickConfig' and tonumber(key) ~= nil) then
1751+ sndPlay(motif.files.snd_data, motif.option_info.cursor_done_snd[1], motif.option_info.cursor_done_snd[2])
1752+ --decrease old button count
1753+ if t_keyList[joyNum][btn] ~= nil and t_keyList[joyNum][btn] > 1 then
1754+ t_keyList[joyNum][btn] = t_keyList[joyNum][btn] - 1
1755+ else
1756+ t_keyList[joyNum][btn] = nil
1757+ end
1758+ --increase new button count
1759+ if t_keyList[joyNum][key] == nil then
1760+ t_keyList[joyNum][key] = 1
1761+ else
1762+ t_keyList[joyNum][key] = t_keyList[joyNum][key] + 1
1763+ end
1764+ --update vardisplay / config data
1765+ t[item]['vardisplay' .. player] = key
1766+ config[cfgType][player].Buttons[item - item_start] = tostring(key)
1767+ modified = 1
1768+ needReload = 1
1769+ else
1770+ sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1771+ end
1772+ resetKey()
1773+ key = ''
1774+ end
14591775 end
1460- -- Audio Ducking
1461- elseif t[item].itemname == 'audioducking' and (commandGetState(main.p1Cmd, 'r') or commandGetState(main.p1Cmd, 'l') or main.f_btnPalNo(main.p1Cmd) > 0) then
1462- sndPlay(motif.files.snd_data, motif.option_info.cursor_move_snd[1], motif.option_info.cursor_move_snd[2])
1463- if config.AudioDucking then
1464- config.AudioDucking = false
1465- else
1466- config.AudioDucking = true
1776+ end
1777+ t_conflict[joyNum] = false
1778+ --draw clearcolor
1779+ clearColor(motif.optionbgdef.bgclearcolor[1], motif.optionbgdef.bgclearcolor[2], motif.optionbgdef.bgclearcolor[3])
1780+ --draw layerno = 0 backgrounds
1781+ bgDraw(motif.optionbgdef.bg, false)
1782+ --draw player num
1783+ for i = 1, 2 do
1784+ textImgDraw(main.f_updateTextImg(
1785+ txt_keyController,
1786+ motif.font_data[motif.option_info['menu_item_key_p' .. i .. '_font'][1]],
1787+ motif.option_info['menu_item_key_p' .. i .. '_font'][2],
1788+ motif.option_info['menu_item_key_p' .. i .. '_font'][3],
1789+ motif.option_info['menu_itemname_key_p' .. i],
1790+ motif.option_info['menu_item_p' .. i .. '_pos'][1],
1791+ motif.option_info['menu_item_p' .. i .. '_pos'][2],
1792+ motif.option_info['menu_item_key_p' .. i .. '_font_scale'][1],
1793+ motif.option_info['menu_item_key_p' .. i .. '_font_scale'][2],
1794+ motif.option_info['menu_item_key_p' .. i .. '_font'][4],
1795+ motif.option_info['menu_item_key_p' .. i .. '_font'][5],
1796+ motif.option_info['menu_item_key_p' .. i .. '_font'][6],
1797+ motif.option_info['menu_item_key_p' .. i .. '_font'][7],
1798+ motif.option_info['menu_item_key_p' .. i .. '_font'][8]
1799+ ))
1800+ end
1801+ --draw menu box
1802+ if motif.option_info.menu_boxbg_visible == 1 then
1803+ local coord4 = 0
1804+ for i = 1, 2 do
1805+ if #t > motif.option_info.menu_window_visibleitems and moveTxt == (#t - motif.option_info.menu_window_visibleitems) * motif.option_info.menu_key_item_spacing[2] then
1806+ coord4 = motif.option_info.menu_window_visibleitems * (motif.option_info.menu_key_boxcursor_coords[4] - motif.option_info.menu_key_boxcursor_coords[2] + 1) + main.f_oddRounding(motif.option_info.menu_key_boxcursor_coords[2])
1807+ else
1808+ coord4 = #t * (motif.option_info.menu_key_boxcursor_coords[4] - motif.option_info.menu_key_boxcursor_coords[2] + 1) + main.f_oddRounding(motif.option_info.menu_key_boxcursor_coords[2])
1809+ end
1810+ fillRect(
1811+ t_pos[i][1] + motif.option_info.menu_key_boxcursor_coords[1],
1812+ t_pos[i][2] + motif.option_info.menu_key_boxcursor_coords[2],
1813+ motif.option_info.menu_key_boxcursor_coords[3] - motif.option_info.menu_key_boxcursor_coords[1] + 1,
1814+ coord4,
1815+ motif.option_info.menu_boxbg_col[1],
1816+ motif.option_info.menu_boxbg_col[2],
1817+ motif.option_info.menu_boxbg_col[3],
1818+ motif.option_info.menu_boxbg_alpha[1],
1819+ motif.option_info.menu_boxbg_alpha[2]
1820+ )
1821+ end
1822+ end
1823+ --draw title
1824+ textImgDraw(txt_title)
1825+ --draw menu items
1826+ for i = 1, #t do
1827+ for j = 1, 2 do
1828+ if i > item - cursorPosY then
1829+ if t[i].itemname == 'configall' then
1830+ if j == 1 then --player1 side (left)
1831+ t[i].infodisplay = motif.option_info.menu_itemname_info_f1
1832+ else --player2 side (right)
1833+ t[i].infodisplay = motif.option_info.menu_itemname_info_f2
1834+ end
1835+ end
1836+ if i == item and j == player then --active item
1837+ --draw displayname
1838+ textImgDraw(main.f_updateTextImg(
1839+ t[i].data,
1840+ motif.font_data[motif.option_info.menu_item_active_font[1]],
1841+ motif.option_info.menu_item_active_font[2],
1842+ motif.option_info.menu_item_active_font[3],
1843+ t[i].displayname,
1844+ t_pos[j][1],
1845+ t_pos[j][2] + (i - 1) * motif.option_info.menu_key_item_spacing[2] - moveTxt,
1846+ motif.option_info.menu_item_active_font_scale[1],
1847+ motif.option_info.menu_item_active_font_scale[2],
1848+ motif.option_info.menu_item_active_font[4],
1849+ motif.option_info.menu_item_active_font[5],
1850+ motif.option_info.menu_item_active_font[6],
1851+ motif.option_info.menu_item_active_font[7],
1852+ motif.option_info.menu_item_active_font[8]
1853+ ))
1854+ --draw vardata
1855+ if t[i].vardata ~= nil then
1856+ if t_keyList[joyNum][tostring(t[i]['vardisplay' .. j])] ~= nil and t_keyList[joyNum][tostring(t[i]['vardisplay' .. j])] > 1 then
1857+ textImgDraw(main.f_updateTextImg(
1858+ t[i].vardata,
1859+ motif.font_data[motif.option_info.menu_item_value_conflict_font[1]],
1860+ motif.option_info.menu_item_value_conflict_font[2],
1861+ motif.option_info.menu_item_value_conflict_font[3],
1862+ t[i]['vardisplay' .. j],
1863+ t_pos[j][1] + motif.option_info.menu_key_item_spacing[1],
1864+ t_pos[j][2] + (i - 1) * motif.option_info.menu_key_item_spacing[2] - moveTxt,
1865+ motif.option_info.menu_item_value_conflict_font_scale[1],
1866+ motif.option_info.menu_item_value_conflict_font_scale[2],
1867+ motif.option_info.menu_item_value_conflict_font[4],
1868+ motif.option_info.menu_item_value_conflict_font[5],
1869+ motif.option_info.menu_item_value_conflict_font[6],
1870+ motif.option_info.menu_item_value_conflict_font[7],
1871+ motif.option_info.menu_item_value_conflict_font[8]
1872+ ))
1873+ t_conflict[joyNum] = true
1874+ else
1875+ textImgDraw(main.f_updateTextImg(
1876+ t[i].vardata,
1877+ motif.font_data[motif.option_info.menu_item_value_active_font[1]],
1878+ motif.option_info.menu_item_value_active_font[2],
1879+ motif.option_info.menu_item_value_active_font[3],
1880+ t[i]['vardisplay' .. j],
1881+ t_pos[j][1] + motif.option_info.menu_key_item_spacing[1],
1882+ t_pos[j][2] + (i - 1) * motif.option_info.menu_key_item_spacing[2] - moveTxt,
1883+ motif.option_info.menu_item_value_active_font_scale[1],
1884+ motif.option_info.menu_item_value_active_font_scale[2],
1885+ motif.option_info.menu_item_value_active_font[4],
1886+ motif.option_info.menu_item_value_active_font[5],
1887+ motif.option_info.menu_item_value_active_font[6],
1888+ motif.option_info.menu_item_value_active_font[7],
1889+ motif.option_info.menu_item_value_active_font[8]
1890+ ))
1891+ end
1892+ --draw infodata
1893+ elseif t[i].infodata ~= nil then
1894+ textImgDraw(main.f_updateTextImg(
1895+ t[i].infodata,
1896+ motif.font_data[motif.option_info.menu_item_info_active_font[1]],
1897+ motif.option_info.menu_item_info_active_font[2],
1898+ motif.option_info.menu_item_info_active_font[3],
1899+ t[i].infodisplay,
1900+ t_pos[j][1] + motif.option_info.menu_key_item_spacing[1],
1901+ t_pos[j][2] + (i - 1) * motif.option_info.menu_key_item_spacing[2] - moveTxt,
1902+ motif.option_info.menu_item_value_active_font_scale[1],
1903+ motif.option_info.menu_item_value_active_font_scale[2],
1904+ motif.option_info.menu_item_info_active_font[4],
1905+ motif.option_info.menu_item_info_active_font[5],
1906+ motif.option_info.menu_item_info_active_font[6],
1907+ motif.option_info.menu_item_info_active_font[7],
1908+ motif.option_info.menu_item_info_active_font[8]
1909+ ))
1910+ end
1911+ else --inactive item
1912+ --draw displayname
1913+ textImgDraw(main.f_updateTextImg(
1914+ t[i].data,
1915+ motif.font_data[motif.option_info.menu_item_font[1]],
1916+ motif.option_info.menu_item_font[2],
1917+ motif.option_info.menu_item_font[3],
1918+ t[i].displayname,
1919+ t_pos[j][1],
1920+ t_pos[j][2] + (i - 1) * motif.option_info.menu_key_item_spacing[2] - moveTxt,
1921+ motif.option_info.menu_item_font_scale[1],
1922+ motif.option_info.menu_item_font_scale[2],
1923+ motif.option_info.menu_item_font[4],
1924+ motif.option_info.menu_item_font[5],
1925+ motif.option_info.menu_item_font[6],
1926+ motif.option_info.menu_item_font[7],
1927+ motif.option_info.menu_item_font[8]
1928+ ))
1929+ --draw vardata
1930+ if t[i].vardata ~= nil then
1931+ if t_keyList[joyNum][tostring(t[i]['vardisplay' .. j])] ~= nil and t_keyList[joyNum][tostring(t[i]['vardisplay' .. j])] > 1 then
1932+ textImgDraw(main.f_updateTextImg(
1933+ t[i].vardata,
1934+ motif.font_data[motif.option_info.menu_item_value_conflict_font[1]],
1935+ motif.option_info.menu_item_value_conflict_font[2],
1936+ motif.option_info.menu_item_value_conflict_font[3],
1937+ t[i]['vardisplay' .. j],
1938+ t_pos[j][1] + motif.option_info.menu_key_item_spacing[1],
1939+ t_pos[j][2] + (i - 1) * motif.option_info.menu_key_item_spacing[2] - moveTxt,
1940+ motif.option_info.menu_item_value_conflict_font_scale[1],
1941+ motif.option_info.menu_item_value_conflict_font_scale[2],
1942+ motif.option_info.menu_item_value_conflict_font[4],
1943+ motif.option_info.menu_item_value_conflict_font[5],
1944+ motif.option_info.menu_item_value_conflict_font[6],
1945+ motif.option_info.menu_item_value_conflict_font[7],
1946+ motif.option_info.menu_item_value_conflict_font[8]
1947+ ))
1948+ t_conflict[joyNum] = true
1949+ else
1950+ textImgDraw(main.f_updateTextImg(
1951+ t[i].vardata,
1952+ motif.font_data[motif.option_info.menu_item_value_font[1]],
1953+ motif.option_info.menu_item_value_font[2],
1954+ motif.option_info.menu_item_value_font[3],
1955+ t[i]['vardisplay' .. j],
1956+ t_pos[j][1] + motif.option_info.menu_key_item_spacing[1],
1957+ t_pos[j][2] + (i - 1) * motif.option_info.menu_key_item_spacing[2] - moveTxt,
1958+ motif.option_info.menu_item_value_font_scale[1],
1959+ motif.option_info.menu_item_value_font_scale[2],
1960+ motif.option_info.menu_item_value_font[4],
1961+ motif.option_info.menu_item_value_font[5],
1962+ motif.option_info.menu_item_value_font[6],
1963+ motif.option_info.menu_item_value_font[7],
1964+ motif.option_info.menu_item_value_font[8]
1965+ ))
1966+ end
1967+ --draw infodata
1968+ elseif t[i].infodata ~= nil then
1969+ textImgDraw(main.f_updateTextImg(
1970+ t[i].infodata,
1971+ motif.font_data[motif.option_info.menu_item_info_font[1]],
1972+ motif.option_info.menu_item_info_font[2],
1973+ motif.option_info.menu_item_info_font[3],
1974+ t[i].infodisplay,
1975+ t_pos[j][1] + motif.option_info.menu_key_item_spacing[1],
1976+ t_pos[j][2] + (i - 1) * motif.option_info.menu_key_item_spacing[2] - moveTxt,
1977+ motif.option_info.menu_item_value_active_font_scale[1],
1978+ motif.option_info.menu_item_value_active_font_scale[2],
1979+ motif.option_info.menu_item_info_font[4],
1980+ motif.option_info.menu_item_info_font[5],
1981+ motif.option_info.menu_item_info_font[6],
1982+ motif.option_info.menu_item_info_font[7],
1983+ motif.option_info.menu_item_info_font[8]
1984+ ))
1985+ end
1986+ end
1987+ end
1988+ end
1989+ end
1990+ --draw menu cursor
1991+ if motif.option_info.menu_boxcursor_visible == 1 then
1992+ local src, dst = main.f_boxcursorAlpha(
1993+ motif.option_info.menu_boxcursor_alpharange[1],
1994+ motif.option_info.menu_boxcursor_alpharange[2],
1995+ motif.option_info.menu_boxcursor_alpharange[3],
1996+ motif.option_info.menu_boxcursor_alpharange[4],
1997+ motif.option_info.menu_boxcursor_alpharange[5],
1998+ motif.option_info.menu_boxcursor_alpharange[6]
1999+ )
2000+ for i = 1, 2 do
2001+ if i == player then
2002+ fillRect(
2003+ t_pos[i][1] + motif.option_info.menu_key_boxcursor_coords[1],
2004+ t_pos[i][2] + motif.option_info.menu_key_boxcursor_coords[2] + (cursorPosY - 1) * motif.option_info.menu_key_item_spacing[2],
2005+ motif.option_info.menu_key_boxcursor_coords[3] - motif.option_info.menu_key_boxcursor_coords[1] + 1,
2006+ motif.option_info.menu_key_boxcursor_coords[4] - motif.option_info.menu_key_boxcursor_coords[2] + 1 + main.f_oddRounding(motif.option_info.menu_key_boxcursor_coords[2]),
2007+ motif.option_info.menu_boxcursor_col[1],
2008+ motif.option_info.menu_boxcursor_col[2],
2009+ motif.option_info.menu_boxcursor_col[3],
2010+ src,
2011+ dst
2012+ )
2013+ end
14672014 end
1468- t[item].vardisplay = options.f_boolDisplay(config.AudioDucking, motif.option_info.menu_itemname_enabled, motif.option_info.menu_itemname_disabled)
1469- modified = 1
1470- needReload = 1
1471- --Back
1472- elseif t[item].itemname == 'back' and main.f_btnPalNo(main.p1Cmd) > 0 then
1473- sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
1474- textImgSetText(txt_title, motif.option_info.title_text_main)
1475- break
14762015 end
1477- options.f_menuCommon2(cursorPosY, moveTxt, item, t)
2016+ --draw layerno = 1 backgrounds
2017+ bgDraw(motif.optionbgdef.bg, true)
2018+ main.f_cmdInput()
2019+ refresh()
14782020 end
14792021 end
14802022
--- a/script/randomtest.lua
+++ b/script/randomtest.lua
@@ -1,6 +1,6 @@
11 -- Used for demo mode and generates AI rank data
22 -- 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
3+-- AutoLevel is palette dependent so if a char has a 12th palette OP mode that mode can have more rank than his normal one
44
55 local randomtest = {}
66
@@ -236,7 +236,6 @@ function randomtest.init()
236236 end
237237 setAutoLevel(true)
238238 setMatchNo(1)
239- selectStage(0)
240239 randomtest.rakuBenry()
241240 winner = 0
242241 wins = 0
@@ -252,6 +251,7 @@ function randomtest.run()
252251 while not esc() do
253252 randomtest.randSel(1, winner)
254253 randomtest.randSel(2, winner)
254+ select.f_setStage()
255255 loadStart()
256256 local oldwinner = winner
257257 winner = game()
--- a/script/screenpack.lua
+++ b/script/screenpack.lua
@@ -26,7 +26,16 @@ end
2626 function main.CalculateLocalcoordValues()
2727 -- We load the libar localcoord from the motif file
2828 main.SP_Localcoord = main.ParseDefFileValue(config.Motif, "info", "localcoord", true)
29-
29+ local spOriginTemp = main.ParseDefFileValue(config.Motif, "info", "localcoord_origin", true)
30+ local spCenterTemp = main.ParseDefFileValue(config.Motif, "info", "localcoord_center", false)
31+
32+ -- We check if we got a valid value
33+ if spCenterTemp == nil then
34+ spCenterTemp = "default"
35+ else
36+ spCenterTemp = spCenterTemp:lower()
37+ end
38+
3039 -- We check if what we got is valid
3140 if main.SP_Localcoord == nil then
3241 main.SP_Localcoord = {320, 240}
@@ -46,11 +55,11 @@ function main.CalculateLocalcoordValues()
4655 tempMFF = nil
4756
4857 -- We seach for the file
49- if main.file_exists(motifFileFolder .. lbFileName) then
58+ if main.f_fileExists(motifFileFolder .. lbFileName) then
5059 main.LB_Localcoord = main.ParseDefFileValue(motifFileFolder .. lbFileName, "info", "localcoord", true)
51- elseif main.file_exists("data/" .. lbFileName) then
60+ elseif main.f_fileExists("data/" .. lbFileName) then
5261 main.LB_Localcoord = main.ParseDefFileValue("data/" .. lbFileName, "info", "localcoord", true)
53- elseif main.file_exists(lbFileName) then
62+ elseif main.f_fileExists(lbFileName) then
5463 main.LB_Localcoord = main.ParseDefFileValue(lbFileName, "info", "localcoord", true)
5564 else
5665 main.LB_Localcoord = main.SP_Localcoord
@@ -80,8 +89,20 @@ function main.CalculateLocalcoordValues()
8089 main.LB_ScreenDiference = (main.LB_ScreenWidth - 320) / (main.LB_ScreenWidth / 320)
8190 --setLifebarPortaitScale(main.SP_Localcoord[1] / main.SP_Localcoord43[1])
8291
83- -- TODO: Check if this calculation of 'main.SP_Center' is rigth.
84- main.SP_Center = main.SP_Localcoord[1] - main.SP_Localcoord43[1]
92+ -- Now we load posible values of main.SP_Center
93+ if spOriginTemp == nil then
94+ if spCenterTemp == "center" then
95+ main.SP_Center = main.SP_Localcoord[1] / 2
96+ elseif spCenterTemp == "left" then
97+ main.SP_Center = 0
98+ elseif spCenterTemp == "right" then
99+ main.SP_Center = main.SP_Localcoord[1]
100+ else
101+ main.SP_Center = main.SP_Localcoord[1] - main.SP_Localcoord43[1]
102+ end
103+ else
104+ main.SP_Center = spOriginTemp
105+ end
85106 end
86107
87108 function main.IntLifebarScale()
@@ -142,7 +163,7 @@ function main.ParseDefFileValue(argFile, searchBlock, searchParam, isNumber)
142163 param = param:gsub('[%. ]', '_') -- change param . and space to _
143164 param = param:lower() -- lowercase param
144165 end
145- if param ~= nil and value ~= nil and param:match(searchParam) then -- param = value pattern matched
166+ if param ~= nil and value ~= nil and param == searchParam then -- param = value pattern matched
146167 value = value:gsub('"', '') -- remove brackets from value
147168 if value:match('.+,.+') then -- multiple values
148169 for i, c in ipairs(main.f_strsplit(',', value)) do -- split value using "," delimiter
--- a/script/select.lua
+++ b/script/select.lua
@@ -8,13 +8,7 @@ setSelColRow(motif.select_info.columns, motif.select_info.rows)
88 --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])
99 --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])
1010
11--- cell.size type check
12-if type(motif.select_info.cell_spacing) == "table" then
13- setSelCellSize(motif.select_info.cell_size[1] + motif.select_info.cell_spacing[1], motif.select_info.cell_size[2] + motif.select_info.cell_spacing[2])
14-else
15- setSelCellSize(motif.select_info.cell_size[1] + motif.select_info.cell_spacing, motif.select_info.cell_size[2] + motif.select_info.cell_spacing)
16-end
17-
11+setSelCellSize(motif.select_info.cell_size[1] + motif.select_info.cell_spacing[1], motif.select_info.cell_size[2] + motif.select_info.cell_spacing[2])
1812 setSelCellScale(motif.select_info.portrait_scale[1], motif.select_info.portrait_scale[2])
1913
2014 --default team count after starting the game
@@ -43,7 +37,6 @@ local t_p1Selected = {}
4337 local t_p2Selected = {}
4438 local t_roster = {}
4539 local t_aiRamp = {}
46-local continue = false
4740 local p1Cell = false
4841 local p2Cell = false
4942 local p1TeamEnd = false
@@ -55,6 +48,7 @@ local stageEnd = false
5548 local coopEnd = false
5649 local restoreTeam = false
5750 local resetgrid = false
51+local continueStage = false
5852 local teamMode = 0
5953 local numChars = 0
6054 local p1NumChars = 0
@@ -79,9 +73,13 @@ local p2FaceY = 0
7973 local p1TeamMode = 0
8074 local p2TeamMode = 0
8175 local lastMatch = 0
76+local currentOrder = 0
77+local currentRosterIndex = 0
8278 local stageNo = 0
8379 local stageList = 0
84-
80+local fadeType = 'fadein'
81+local continue = false
82+local challenger = false
8583 local cnt = motif.select_info.columns + 1
8684 local row = 1
8785 local col = 0
@@ -94,14 +92,7 @@ for i = 1, (motif.select_info.rows + motif.select_info.rows_scrolling) * motif.s
9492 t_grid[row] = {}
9593 end
9694 col = #t_grid[row] + 1
97-
98- -- cell.spacing type check
99- if type(motif.select_info.cell_spacing) == "table" then
100- t_grid[row][col] = {num = i - 1, x = (col - 1) * (motif.select_info.cell_size[1] + motif.select_info.cell_spacing[1]), y = (row - 1) * (motif.select_info.cell_size[2] + motif.select_info.cell_spacing[2])}
101- else
102- 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)}
103- end
104-
95+ t_grid[row][col] = {num = i - 1, x = (col - 1) * (motif.select_info.cell_size[1] + motif.select_info.cell_spacing[1]), y = (row - 1) * (motif.select_info.cell_size[2] + motif.select_info.cell_spacing[2])}
10596 if main.t_selChars[i].char ~= nil then
10697 t_grid[row][col].char = main.t_selChars[i].char
10798 t_grid[row][col].hidden = main.t_selChars[i].hidden
@@ -113,76 +104,81 @@ end
113104 --;===========================================================
114105 --; COMMON FUNCTIONS
115106 --;===========================================================
116-function select.f_setZoom()
117- local zoom = config.ZoomActive
118- if main.t_selChars[t_p2Selected[1].cel + 1].zoom ~= nil then
119- if main.t_selChars[t_p2Selected[1].cel + 1].zoom == 1 then
120- zoom = true
121- else
122- zoom = false
123- end
124- elseif main.t_selStages[stageNo] ~= nil and main.t_selStages[stageNo].zoom ~= nil then
125- if main.t_selChars[stageNo].zoom == 1 then
126- zoom = true
127- else
128- zoom = false
129- end
130- end
131- setZoom(zoom)
132- local zoomMin = config.ZoomMin
133- if main.t_selStages[stageNo].zoommin ~= nil then
134- zoomMin = main.t_selStages[stageNo].zoommin
135- end
136- setZoomMin(zoomMin)
137- local zoomMax = config.ZoomMax
138- if main.t_selStages[stageNo].zoommax ~= nil then
139- zoomMax = main.t_selStages[stageNo].zoommax
140- end
141- setZoomMax(zoomMax)
142- local zoomSpeed = config.ZoomSpeed
143- if main.t_selStages[stageNo].zoomspeed ~= nil then
144- zoomSpeed = main.t_selStages[stageNo].zoomspeed
145- end
146- setZoomSpeed(zoomSpeed)
147-end
148-
149107 function select.f_makeRoster()
150108 t_roster = {}
151109 local t = {}
152110 local cnt = 0
111+ local orderCnt = 0
153112 --Arcade
154- if main.gameMode == 'arcade' or main.gameMode == 'teamcoop' or main.gameMode == 'netplayteamcoop' then
155- if p2TeamMode == 0 then --Single
113+ if gameMode('arcade') or gameMode('teamcoop') or gameMode('netplayteamcoop') then
114+ if main.t_selChars[t_p1Selected[1].cel + 1].maxmatches ~= nil then
115+ if p2TeamMode == 0 then --Single
116+ t = main.t_selOptions[main.t_selChars[t_p1Selected[1].cel + 1].maxmatches .. "_arcademaxmatches"]
117+ else --Team
118+ t = main.t_selOptions[main.t_selChars[t_p1Selected[1].cel + 1].maxmatches .. "_teammaxmatches"]
119+ end
120+ elseif p2TeamMode == 0 then
156121 t = main.t_selOptions.arcademaxmatches
157- else --Team
122+ else
158123 t = main.t_selOptions.teammaxmatches
159124 end
160125 for i = 1, #t do --for each order number
126+ table.insert(t_roster, {})
161127 cnt = t[i] * p2NumChars --set amount of matches to get from the table
162- if cnt > 0 and main.t_orderChars[i] ~= nil then --if it's more than 0 and there are characters with such order
163- while cnt > 0 do --do the following until amount of matches for particular order is reached
128+ if cnt > 0 and main.t_orderChars[i] ~= nil then --if matches > 0 and there are characters with such order
129+ if t[i] > #main.t_orderChars[i] then --if there is not enough chars with particular order reduce amount of matches
130+ orderCnt = #main.t_orderChars[i] * p2NumChars
131+ else
132+ orderCnt = cnt
133+ end
134+ while orderCnt > 0 do --do the following until amount of matches for particular order is reached
164135 main.f_shuffleTable(main.t_orderChars[i]) --randomize characters table
165- for j = 1, #main.t_orderChars[i] do --loop through chars associated with that particular order
166- t_roster[#t_roster + 1] = main.t_orderChars[i][j] --and add such character into new table
167- cnt = cnt - 1
168- if cnt == 0 then --but only if amount of matches for particular order has not been reached yet
136+ for j = 1, #main.t_orderChars[i] do --loop through chars associated with this particular order
137+ table.insert(t_roster[i], main.t_orderChars[i][j]) --and add such character into new table
138+ orderCnt = orderCnt - 1
139+ if orderCnt == 0 then --but only if amount of matches for particular order has not been reached yet
169140 break
170141 end
171142 end
172143 end
173144 end
174145 end
175- --Survival / Boss Rush / VS 100 Kumite
176- else
177- if main.gameMode == 'survival' or main.gameMode == 'survivalcoop' or main.gameMode == 'netplaysurvivalcoop' then
178- t = main.t_randomChars
179- cnt = #t
180- local i = 0
181- while cnt / p2NumChars ~= math.ceil(cnt / p2NumChars) do --not integer
182- i = i + 1
183- cnt = #t + i
146+ --Survival
147+ elseif gameMode('survival') or gameMode('survivalcoop') or gameMode('netplaysurvivalcoop') then
148+ t = main.t_selOptions.survivalmaxmatches
149+ for i = 1, #t do --for each order number
150+ table.insert(t_roster, {})
151+ --set amount of matches to get from the table
152+ if t[i] == -1 and main.t_orderSurvival[i] ~= nil then --infinite matches
153+ cnt = #main.t_orderSurvival[i] * p2NumChars --get value equal all characters with this order
154+ else --finite matches
155+ cnt = t[i] * p2NumChars --amount of matches as specified in survival.maxmatches column
156+ end
157+ if cnt > 0 and main.t_orderSurvival[i] ~= nil then --if matches > 0 and there are characters with such order
158+ if t[i] > #main.t_orderSurvival[i] or t[i] < 0 then --if there is not enough chars with particular order reduce amount of matches
159+ orderCnt = #main.t_orderSurvival[i] * p2NumChars
160+ else
161+ orderCnt = cnt
162+ end
163+ while orderCnt > 0 do --do the following until amount of matches for particular order is reached
164+ main.f_shuffleTable(main.t_orderSurvival[i]) --randomize characters table
165+ for j = 1, #main.t_orderSurvival[i] do --loop through chars associated with this particular order
166+ table.insert(t_roster[i], main.t_orderSurvival[i][j]) --and add such character into new table
167+ orderCnt = orderCnt - 1
168+ if orderCnt == 0 then --but only if amount of matches for particular order has not been reached yet
169+ break
170+ end
171+ end
172+ end
173+ if t[i] == -1 then --infinity matches against characters with order i, skip the rest
174+ break
175+ end
184176 end
185- elseif main.gameMode == 'bossrush' then
177+ end
178+ --Boss Rush / VS 100 Kumite
179+ else
180+ table.insert(t_roster, {})
181+ if gameMode('bossrush') then
186182 t = main.t_bossChars
187183 cnt = #t
188184 local i = 0
@@ -190,14 +186,14 @@ function select.f_makeRoster()
190186 i = i + 1
191187 cnt = #t + i
192188 end
193- elseif main.gameMode == '100kumite' then
189+ elseif gameMode('100kumite') then
194190 t = main.t_randomChars
195191 cnt = 100 * p2NumChars
196192 end
197193 while cnt > 0 do
198194 main.f_shuffleTable(t)
199195 for i = 1, #t do
200- t_roster[#t_roster + 1] = t[i]
196+ table.insert(t_roster[1], t[i])
201197 cnt = cnt - 1
202198 if cnt == 0 then
203199 break
@@ -208,14 +204,16 @@ function select.f_makeRoster()
208204 main.f_printTable(t_roster, 'debug/t_roster.txt')
209205 end
210206
211-function select.f_aiRamp()
207+function select.f_aiRamp(currentMatch)
212208 local start_match = 0
213209 local start_diff = 0
214210 local end_match = 0
215211 local end_diff = 0
216- t_aiRamp = {}
212+ if currentMatch == 1 then
213+ t_aiRamp = {}
214+ end
217215 --Arcade
218- if main.gameMode == 'arcade' or main.gameMode == 'teamcoop' or main.gameMode == 'netplayteamcoop' then
216+ if gameMode('arcade') or gameMode('teamcoop') or gameMode('netplayteamcoop') then
219217 if p2TeamMode == 0 then --Single
220218 start_match = main.t_selOptions.arcadestart.wins
221219 start_diff = main.t_selOptions.arcadestart.offset
@@ -227,7 +225,7 @@ function select.f_aiRamp()
227225 end_match = main.t_selOptions.teamend.wins
228226 end_diff = main.t_selOptions.teamend.offset
229227 end
230- elseif main.gameMode == 'survival' or main.gameMode == 'survivalcoop' or main.gameMode == 'netplaysurvivalcoop' then
228+ elseif gameMode('survival') or gameMode('survivalcoop') or gameMode('netplaysurvivalcoop') then
231229 start_match = main.t_selOptions.survivalstart.wins
232230 start_diff = main.t_selOptions.survivalstart.offset
233231 end_match = main.t_selOptions.survivalend.wins
@@ -245,27 +243,42 @@ function select.f_aiRamp()
245243 elseif endAI < 1 then
246244 endAI = 1
247245 end
248- for i = 1, lastMatch do
246+ for i = currentMatch, lastMatch do
249247 if i - 1 <= start_match then
250- t_aiRamp[#t_aiRamp + 1] = startAI
248+ table.insert(t_aiRamp, startAI)
251249 elseif i - 1 <= end_match then
252250 local curMatch = i - (start_match + 1)
253- t_aiRamp[#t_aiRamp + 1] = math.floor(curMatch * (endAI - startAI) / (end_match - start_match) + startAI)
251+ table.insert(t_aiRamp, math.floor(curMatch * (endAI - startAI) / (end_match - start_match) + startAI))
254252 else
255- t_aiRamp[#t_aiRamp + 1] = endAI
253+ table.insert(t_aiRamp, endAI)
256254 end
257255 end
258256 main.f_printTable(t_aiRamp, 'debug/t_aiRamp.txt')
259257 end
260258
259+function select.f_rivalsMatch(param)
260+ if main.t_selChars[t_p1Selected[1].cel + 1].rivals ~= nil and main.t_selChars[t_p1Selected[1].cel + 1].rivals[matchNo] ~= nil then
261+ if param == nil then
262+ return true
263+ else
264+ return main.t_selChars[t_p1Selected[1].cel + 1].rivals[matchNo][param] ~= nil
265+ end
266+ end
267+ return false
268+end
269+
261270 function select.f_difficulty(player, offset)
262271 local t = {}
263- if player % 2 ~= 0 then --odd value
272+ if player % 2 ~= 0 then --odd value (Player1 side)
264273 local pos = math.floor(player / 2 + 0.5)
265274 t = main.t_selChars[t_p1Selected[pos].cel + 1]
266- else --even value
275+ else --even value (Player2 side)
267276 local pos = math.floor(player / 2)
268- t = main.t_selChars[t_p2Selected[pos].cel + 1]
277+ if pos == 1 and select.f_rivalsMatch('ai') then --player2 team leader and arcade mode and ai rivals param exists
278+ t = main.t_selChars[t_p1Selected[1].cel + 1].rivals[matchNo]
279+ else
280+ t = main.t_selChars[t_p2Selected[pos].cel + 1]
281+ end
269282 end
270283 if t.ai ~= nil then
271284 return t.ai
@@ -274,14 +287,15 @@ function select.f_difficulty(player, offset)
274287 end
275288 end
276289
277-function select.f_aiLevel()
290+function select.f_remapAI()
278291 --Offset
279292 local offset = 0
280- 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
293+ if config.AIRamping and (gameMode('arcade') or gameMode('teamcoop') or gameMode('netplayteamcoop') or gameMode('survival') or gameMode('survivalcoop') or gameMode('netplaysurvivalcoop')) then
281294 offset = t_aiRamp[matchNo] - config.Difficulty
282295 end
283296 --Player 1
284297 if main.coop then
298+ remapInput(3, 2) --P3 character uses P2 controls
285299 setCom(1, 0)
286300 setCom(3, 0)
287301 elseif p1TeamMode == 0 then --Single
@@ -298,34 +312,26 @@ function select.f_aiLevel()
298312 end
299313 for i = 3, p1NumChars * 2 do
300314 if i % 2 ~= 0 then --odd value
315+ remapInput(i, 1) --P3/5/7 character uses P1 controls
301316 setCom(i, select.f_difficulty(i, offset))
302317 end
303318 end
304- -- Legcy TAG
305- elseif p1TeamMode == 1 and config.SimulMode == false then
306- for i = 1, p1NumChars * 2 do
307- if i % 2 ~= 0 then --odd value
308- if main.p1In == 1 and not main.aiFight then
309- setCom(i, 0)
310- else
311- setCom(i, select.f_difficulty(i, offset))
312- end
313- end
314- end
315319 elseif p1TeamMode == 2 then --Turns
316320 for i = 1, p1NumChars * 2 do
317- if i % 2 ~= 0 then
321+ if i % 2 ~= 0 then --odd value
318322 if main.p1In == 1 and not main.aiFight then
323+ remapInput(i, 1) --P1/3/5/7 character uses P1 controls
319324 setCom(i, 0)
320325 else
321326 setCom(i, select.f_difficulty(i, offset))
322327 end
323328 end
324329 end
325- else --Tag
330+ else --p1TeamMode == 3 or (p1TeamMode == 1 and not config.SimulMode) --Tag
326331 for i = 1, p1NumChars * 2 do
327332 if i % 2 ~= 0 then --odd value
328333 if main.p1In == 1 and not main.aiFight then
334+ remapInput(i, 1) --P1/3/5/7 character uses P1 controls
329335 setCom(i, 0)
330336 else
331337 setCom(i, select.f_difficulty(i, offset))
@@ -348,34 +354,26 @@ function select.f_aiLevel()
348354 end
349355 for i = 4, p2NumChars * 2 do
350356 if i % 2 == 0 then --even value
357+ remapInput(i, 2) --P4/6/8 character uses P2 controls
351358 setCom(i, select.f_difficulty(i, offset))
352359 end
353360 end
354- -- Legcy TAG
355- elseif p2TeamMode == 1 and config.SimulMode == false then --Tag
356- for i = 2, p2NumChars * 2 do
357- if i % 2 == 0 then --even value
358- if main.p2In == 2 and not main.aiFight and not main.coop then
359- setCom(i, 0)
360- else
361- setCom(i, select.f_difficulty(i, offset))
362- end
363- end
364- end
365361 elseif p2TeamMode == 2 then --Turns
366362 for i = 2, p2NumChars * 2 do
367- if i % 2 == 0 then
363+ if i % 2 == 0 then --even value
368364 if main.p2In == 2 and not main.aiFight and not main.coop then
365+ remapInput(i, 2) --P2/4/6/8 character uses P2 controls
369366 setCom(i, 0)
370367 else
371368 setCom(i, select.f_difficulty(i, offset))
372369 end
373370 end
374371 end
375- else --Tag
372+ else --p2TeamMode == 3 or (p2TeamMode == 1 and not config.SimulMode) --Tag
376373 for i = 2, p2NumChars * 2 do
377374 if i % 2 == 0 then --even value
378375 if main.p2In == 2 and not main.aiFight and not main.coop then
376+ remapInput(i, 2) --P2/4/6/8 character uses P2 controls
379377 setCom(i, 0)
380378 else
381379 setCom(i, select.f_difficulty(i, offset))
@@ -385,75 +383,277 @@ function select.f_aiLevel()
385383 end
386384 end
387385
388-function select.f_assignMusic()
389- local track = ''
390- local trackVolume = 100
391- local tracloopstart,tracloopend = nil
392- if main.stageMenu then
393- if main.t_selStages[stageNo].music ~= nil then
394- track = math.random(1, #main.t_selStages[stageNo].music)
395- trackVolume = main.t_selStages[stageNo].music[track].bgmvolume
396- trackloopstart = main.t_selStages[stageNo].music[track].bgmloopstart
397- trackloopend = main.t_selStages[stageNo].music[track].bgmloopend
398- track = main.t_selStages[stageNo].music[track].bgmusic
399- end
386+local lifebar = motif.files.fight
387+function select.f_setRounds()
388+ --lifebar
389+ if main.t_charparam.lifebar and main.t_charparam.rivals and select.f_rivalsMatch('lifebar') then --lifebar assigned as rivals param
390+ lifebar = main.t_selChars[t_p1Selected[1].cel + 1].rivals[matchNo].lifebar:gsub('\\', '/')
391+ elseif main.t_charparam.lifebar and main.t_selChars[t_p2Selected[1].cel + 1].lifebar ~= nil then --lifebar assigned as character param
392+ lifebar = main.t_selChars[t_p2Selected[1].cel + 1].lifebar:gsub('\\', '/')
393+ else --default lifebar
394+ lifebar = motif.files.fight
395+ end
396+ if lifebar:lower() ~= main.currentLifebar:lower() then
397+ main.currentLifebar = lifebar
398+ loadLifebar(lifebar)
399+ end
400+ --round time
401+ if gameMode('training') then
402+ setRoundTime(-1)
403+ elseif main.t_charparam.time and main.t_charparam.rivals and select.f_rivalsMatch('time') then --round time assigned as rivals param
404+ setRoundTime(math.max(-1, main.t_selChars[t_p1Selected[1].cel + 1].rivals[matchNo].time * getFramesPerCount()))
405+ elseif main.t_charparam.time and main.t_selChars[t_p2Selected[1].cel + 1].time ~= nil then --round time assigned as character param
406+ setRoundTime(math.max(-1, main.t_selChars[t_p2Selected[1].cel + 1].time * getFramesPerCount()))
407+ else --default round time
408+ setRoundTime(math.max(-1, config.RoundTime * getFramesPerCount()))
409+ end
410+ --rounds to win
411+ if gameMode('survival') or gameMode('survivalcoop') or gameMode('netplaysurvivalcoop') or gameMode('100kumite') then --always 1 round to win in these modes
412+ setMatchWins(1)
413+ setMatchMaxDrawGames(0)
400414 else
401- if main.t_selChars[t_p2Selected[1].cel + 1].music ~= nil then
402- track = math.random(1, #main.t_selChars[t_p2Selected[1].cel + 1].music)
403- trackVolume = main.t_selChars[t_p2Selected[1].cel + 1].music[track].bgmvolume
404- trackloopstart = main.t_selChars[t_p2Selected[1].cel + 1].music[track].bgmloopstart
405- trackloopend = main.t_selChars[t_p2Selected[1].cel + 1].music[track].bgmloopend
406- track = main.t_selChars[t_p2Selected[1].cel + 1].music[track].bgmusic
407- elseif main.t_selStages[stageNo].music ~= nil then
408- track = math.random(1, #main.t_selStages[stageNo].music)
409- trackVolume = main.t_selStages[stageNo].music[track].bgmvolume
410- trackloopstart = main.t_selStages[stageNo].music[track].bgmloopstart
411- trackloopend = main.t_selStages[stageNo].music[track].bgmloopend
412- track = main.t_selStages[stageNo].music[track].bgmusic
415+ if main.t_charparam.rounds and main.t_charparam.rivals and select.f_rivalsMatch('rounds') then --round num assigned as rivals param
416+ setMatchWins(main.t_selChars[t_p1Selected[1].cel + 1].rivals[matchNo].rounds)
417+ elseif main.t_charparam.rounds and main.t_selChars[t_p2Selected[1].cel + 1].rounds ~= nil then --round num assigned as character param
418+ setMatchWins(main.t_selChars[t_p2Selected[1].cel + 1].rounds)
419+ elseif p2TeamMode == 0 then --default rounds num (Single mode)
420+ setMatchWins(options.roundsNumSingle)
421+ else --default rounds num (Team mode)
422+ setMatchWins(options.roundsNumTeam)
413423 end
414- stageEnd = true
424+ setMatchMaxDrawGames(options.maxDrawGames)
415425 end
416- playBGM(track, true, 1, trackVolume, trackloopstart or "0", trackloopend or "0")
417426 end
418427
419-function select.f_selectStage()
420- if t_p2Selected[1].stageno ~= nil then
421- stageNo = t_p2Selected[1].stageno
422- elseif main.t_selChars[t_p2Selected[1].cel + 1].stage ~= nil then
423- stageNo = math.random(1, #main.t_selChars[t_p2Selected[1].cel + 1].stage)
424- stageNo = main.t_selChars[t_p2Selected[1].cel + 1].stage[stageNo]
425- else
426- stageNo = main.t_includeStage[math.random(1, #main.t_includeStage)]
428+function select.f_setStage(num)
429+ num = num or 0
430+ --stage
431+ if not main.stageMenu and not continueStage then
432+ if main.t_charparam.stage and main.t_charparam.rivals and select.f_rivalsMatch('stage') then --stage assigned as rivals param
433+ num = math.random(1, #main.t_selChars[t_p1Selected[1].cel + 1].rivals[matchNo].stage)
434+ num = main.t_selChars[t_p1Selected[1].cel + 1].rivals[matchNo].stage[num]
435+ elseif main.t_charparam.stage and main.t_selChars[t_p2Selected[1].cel + 1].stage ~= nil then --stage assigned as character param
436+ num = math.random(1, #main.t_selChars[t_p2Selected[1].cel + 1].stage)
437+ num = main.t_selChars[t_p2Selected[1].cel + 1].stage[num]
438+ elseif (gameMode('arcade') or gameMode('teamcoop') or gameMode('netplayteamcoop')) and main.t_orderStages[main.t_selChars[t_p2Selected[1].cel + 1].order] ~= nil then --stage assigned as stage order param
439+ num = math.random(1, #main.t_orderStages[main.t_selChars[t_p2Selected[1].cel + 1].order])
440+ num = main.t_orderStages[main.t_selChars[t_p2Selected[1].cel + 1].order][num]
441+ else --stage randomly selected
442+ num = main.t_includeStage[1][math.random(1, #main.t_includeStage[1])]
443+ end
444+ end
445+ setStage(num)
446+ selectStage(num)
447+ --zoom
448+ local zoom = config.ZoomActive
449+ local zoomMin = config.ZoomMin
450+ local zoomMax = config.ZoomMax
451+ local zoomSpeed = config.ZoomSpeed
452+ if main.t_charparam.zoom and main.t_charparam.rivals and select.f_rivalsMatch('zoom') then --zoom assigned as rivals param
453+ if main.t_selChars[t_p1Selected[1].cel + 1].rivals[matchNo].zoom == 1 then
454+ zoom = true
455+ else
456+ zoom = false
457+ end
458+ elseif main.t_charparam.zoom and main.t_selChars[t_p2Selected[1].cel + 1].zoom ~= nil then --zoom assigned as character param
459+ if main.t_selChars[t_p2Selected[1].cel + 1].zoom == 1 then
460+ zoom = true
461+ else
462+ zoom = false
463+ end
464+ elseif main.t_selStages[num] ~= nil and main.t_selStages[num].zoom ~= nil then --zoom assigned as stage param
465+ if main.t_selStages[num].zoom == 1 then
466+ zoom = true
467+ else
468+ zoom = false
469+ end
470+ end
471+ if main.t_selStages[num] ~= nil then
472+ if main.t_selStages[num].zoommin ~= nil then
473+ zoomMin = main.t_selStages[num].zoommin
474+ end
475+ if main.t_selStages[num].zoommax ~= nil then
476+ zoomMax = main.t_selStages[num].zoommax
477+ end
478+ if main.t_selStages[num].zoomspeed ~= nil then
479+ zoomSpeed = main.t_selStages[num].zoomspeed
480+ end
427481 end
428- if stageNo == 0 then
429- stageNo = main.t_includeStage[math.random(1, #main.t_includeStage)]
482+ setZoom(zoom)
483+ setZoomMin(zoomMin)
484+ setZoomMax(zoomMax)
485+ setZoomSpeed(zoomSpeed)
486+ --music
487+ local t = {'music', 'musicalt', 'musiclife'}
488+ for i = 1, #t do
489+ local track = 0
490+ local music = ''
491+ local volume = 100
492+ local loopstart = 0
493+ local loopend = 0
494+ if main.stageMenu then --game modes with stage selection screen
495+ if main.t_selStages[num] ~= nil and main.t_selStages[num][t[i]] ~= nil then --music assigned as stage param
496+ track = math.random(1, #main.t_selStages[num][t[i]])
497+ music = main.t_selStages[num][t[i]][track].bgmusic
498+ volume = main.t_selStages[num][t[i]][track].bgmvolume
499+ loopstart = main.t_selStages[num][t[i]][track].bgmloopstart
500+ loopend = main.t_selStages[num][t[i]][track].bgmloopend
501+ end
502+ elseif not gameMode('demo') or motif.demo_mode.fight_playbgm == 1 then --game modes other than demo (or demo with stage BGM param enabled)
503+ if main.t_charparam.music and main.t_charparam.rivals and select.f_rivalsMatch(t[i]) then --music assigned as rivals param
504+ track = math.random(1, #main.t_selChars[t_p1Selected[1].cel + 1].rivals[matchNo][t[i]])
505+ music = main.t_selChars[t_p1Selected[1].cel + 1].rivals[matchNo][t[i]][track].bgmusic
506+ volume = main.t_selChars[t_p1Selected[1].cel + 1].rivals[matchNo][t[i]][track].bgmvolume
507+ loopstart = main.t_selChars[t_p1Selected[1].cel + 1].rivals[matchNo][t[i]][track].bgmloopstart
508+ loopend = main.t_selChars[t_p1Selected[1].cel + 1].rivals[matchNo][t[i]][track].bgmloopend
509+ elseif main.t_charparam.music and main.t_selChars[t_p2Selected[1].cel + 1][t[i]] ~= nil then --music assigned as character param
510+ track = math.random(1, #main.t_selChars[t_p2Selected[1].cel + 1][t[i]])
511+ music = main.t_selChars[t_p2Selected[1].cel + 1][t[i]][track].bgmusic
512+ volume = main.t_selChars[t_p2Selected[1].cel + 1][t[i]][track].bgmvolume
513+ loopstart = main.t_selChars[t_p2Selected[1].cel + 1][t[i]][track].bgmloopstart
514+ loopend = main.t_selChars[t_p2Selected[1].cel + 1][t[i]][track].bgmloopend
515+ elseif main.t_selStages[num] ~= nil and main.t_selStages[num][t[i]] ~= nil then --music assigned as stage param
516+ track = math.random(1, #main.t_selStages[num][t[i]])
517+ music = main.t_selStages[num][t[i]][track].bgmusic
518+ volume = main.t_selStages[num][t[i]][track].bgmvolume
519+ loopstart = main.t_selStages[num][t[i]][track].bgmloopstart
520+ loopend = main.t_selStages[num][t[i]][track].bgmloopend
521+ end
522+ end
523+ if music ~= '' then
524+ setStageBGM(i - 1, music, volume, loopstart, loopend)
525+ end
526+ end
527+ return num
528+end
529+
530+function select.f_reampPal(cell, num)
531+ if main.t_selChars[cell + 1].pal_keymap[num] ~= nil then
532+ return main.t_selChars[cell + 1].pal_keymap[num]
430533 end
431- t_p2Selected[1].stageno = stageNo
432- setStage(stageNo)
433- selectStage(stageNo)
534+ return num
434535 end
435536
436-function select.f_randomPal(cell)
437- --table with pal numbers already assigned
438- local t = {}
537+function select.f_selectPal(cell)
538+ --prepare palette tables
539+ local t_assignedVals = {} --values = pal numbers already assigned
540+ local t_assignedKeys = {} --keys = pal numbers already assigned
439541 for i = 1, #t_p1Selected do
440542 if t_p1Selected[i].cel == cell then
441- t[#t + 1] = t_p1Selected[i].pal
543+ table.insert(t_assignedVals, select.f_reampPal(cell, t_p1Selected[i].pal))
544+ t_assignedKeys[t_assignedVals[#t_assignedVals]] = ''
442545 end
443546 end
444547 for i = 1, #t_p2Selected do
445548 if t_p2Selected[i].cel == cell then
446- t[#t + 1] = t_p2Selected[i].pal
549+ table.insert(t_assignedVals, select.f_reampPal(cell, t_p2Selected[i].pal))
550+ t_assignedKeys[t_assignedVals[#t_assignedVals]] = ''
447551 end
448552 end
449- --table with pal numbers not assigned yet (or all if there are not enough pals for unique appearance of all characters)
450- local t2 = {}
451- for i = 1, #main.t_selChars[cell + 1].pal do
452- if t[main.t_selChars[cell + 1].pal[i]] == nil or #t >= #main.t_selChars[cell + 1].pal then
453- t2[#t2 + 1] = main.t_selChars[cell + 1].pal[i]
553+ --return random palette
554+ if config.AIRandomColor then
555+ local t_uniqueVals = {} --values = pal numbers not assigned yet (or all if there are not enough pals for unique appearance of all characters)
556+ for i = 1, #main.t_selChars[cell + 1].pal do
557+ if t_assignedKeys[main.t_selChars[cell + 1].pal[i]] == nil or #t_assignedVals >= #main.t_selChars[cell + 1].pal then
558+ table.insert(t_uniqueVals, main.t_selChars[cell + 1].pal[i])
559+ end
560+ end
561+ return t_uniqueVals[math.random(1, #t_uniqueVals)]
562+ end
563+ --return first available default palette
564+ for i = 1, #main.t_selChars[cell + 1].pal_defaults do
565+ local d = main.t_selChars[cell + 1].pal_defaults[i]
566+ if t_assignedKeys[d] == nil then
567+ return select.f_reampPal(cell, d)
568+ end
569+ end
570+ --no free default palettes available, force first default palette
571+ return select.f_reampPal(cell, main.t_selChars[cell + 1].pal_defaults[1])
572+end
573+
574+--Team modes enabling (also called from withing options screen)
575+function select.f_getTeamMenu()
576+ local t = {}
577+ --Single mode check
578+ if config.SingleTeamMode == true then
579+ table.insert(t, {data = textImgNew(), itemname = 'single', displayname = motif.select_info.teammenu_itemname_single})
580+ end
581+ if config.SimulMode then --Simul mode enabled
582+ --Simul mode check
583+ if config.NumSimul > 1 then
584+ table.insert(t, {data = textImgNew(), itemname = 'simul', displayname = motif.select_info.teammenu_itemname_simul})
585+ end
586+ --Tag mode check
587+ if config.NumTag > 1 then
588+ table.insert(t, {data = textImgNew(), itemname = 'tag', displayname = motif.select_info.teammenu_itemname_tag})
589+ end
590+ elseif config.NumTag > 1 then --Legacy Tag mode enabled
591+ table.insert(t, {data = textImgNew(), itemname = 'simul', displayname = motif.select_info.teammenu_itemname_tag})
592+ end
593+ --Turns mode check
594+ if config.NumTurns > 1 then
595+ table.insert(t, {data = textImgNew(), itemname = 'turns', displayname = motif.select_info.teammenu_itemname_turns})
596+ end
597+ return t
598+end
599+
600+function select.f_overwriteCharData()
601+ --for now only survival mode uses this function
602+ if not gameMode('survival') and not gameMode('survivalcoop') and not gameMode('netplaysurvivalcoop') then
603+ return
604+ end
605+ --and it's skipped at first match
606+ if matchNo <= 1 then
607+ return
608+ end
609+ local lastRound = #t_gameStats.chars
610+ local removedNum = 0
611+ local p1Count = 0
612+ --Turns
613+ if p1TeamMode == 2 then
614+ local t_p1Keys = {}
615+ --for each round in the last match
616+ for round = 1, #t_gameStats.chars do
617+ --remove character from team if he/she has been defeated
618+ if not t_gameStats.chars[round][1].win or t_gameStats.chars[round][1].ko then
619+ table.remove(t_p1Selected, t_gameStats.chars[round][1].memberNo + 1 - removedNum)
620+ removedNum = removedNum + 1
621+ p1NumChars = p1NumChars - 1
622+ --otherwise overwrite character's next match life (done after all rounds have been checked)
623+ else
624+ t_p1Keys[t_gameStats.chars[round][1].memberNo] = t_gameStats.chars[round][1].life
625+ end
626+ end
627+ for k, v in pairs(t_p1Keys) do
628+ p1Count = p1Count + 1
629+ overwriteCharData(p1Count, {['life'] = v})
454630 end
631+ --Single / Simul / Tag
632+ else
633+ --for each player data in the last round
634+ for player = 1, #t_gameStats.chars[lastRound] do
635+ --only check P1 side characters
636+ if player % 2 ~= 0 and player <= (p1NumChars + removedNum) * 2 then --odd value, team size check just in case
637+ --remove character from team if he/she has been defeated
638+ if not t_gameStats.chars[lastRound][player].win or t_gameStats.chars[lastRound][player].ko then
639+ table.remove(t_p1Selected, t_gameStats.chars[lastRound][player].memberNo + 1 - removedNum)
640+ removedNum = removedNum + 1
641+ p1NumChars = p1NumChars - 1
642+ --otherwise overwrite character's next match life
643+ else
644+ if p1Count == 0 then
645+ p1Count = 1
646+ else
647+ p1Count = p1Count + 2
648+ end
649+ overwriteCharData(p1Count, {['life'] = t_gameStats.chars[lastRound][player].life})
650+ end
651+ end
652+ end
653+ end
654+ if removedNum > 0 then
655+ setTeamMode(1, p1TeamMode, p1NumChars)
455656 end
456- return t2[math.random(1, #t2)]
457657 end
458658
459659 function select.f_drawName(t, data, font, offsetX, offsetY, scaleX, scaleY, spacingX, spacingY, active_font, active_row)
@@ -480,28 +680,15 @@ function select.f_drawName(t, data, font, offsetX, offsetY, scaleX, scaleY, spac
480680 scaleY,
481681 f[4],
482682 f[5],
483- f[6]
683+ f[6],
684+ f[7],
685+ f[8]
484686 )
485687 textImgDraw(data)
486688 end
487689 end
488690 end
489691
490-function select.f_drawPortrait(t, offsetX, offsetY, facing, scaleX, scaleY, spacingX, spacingY, limit, func)
491- if facing == -1 then offsetX = offsetX + 1 end --fix for wrong offset after flipping sprites
492- for i = #t, 1, -1 do
493- if i <= limit then
494- if func == 'select' then
495- drawPortrait(t[i].cel, offsetX + (i - 1) * spacingX, offsetY + (i - 1) * spacingY, facing * scaleX, scaleY)
496- elseif func == 'versus' then
497- drawVersusPortrait(t[i].cel, offsetX + (i - 1) * spacingX, offsetY + (i - 1) * spacingY, facing * scaleX, scaleY)
498- elseif func == 'victory' then
499- drawVictoryPortrait(t[i].cel, offsetX + (i - 1) * spacingX, offsetY + (i - 1) * spacingY, facing * scaleX, scaleY)
500- end
501- end
502- end
503-end
504-
505692 function select.f_cellMovement(selX, selY, cmd, faceOffset, rowOffset, snd)
506693 local tmpX = selX
507694 local tmpY = selY
@@ -525,8 +712,7 @@ function select.f_cellMovement(selX, selY, cmd, faceOffset, rowOffset, snd)
525712 faceOffset = faceOffset - motif.select_info.columns
526713 rowOffset = rowOffset - 1
527714 end
528- if (t_grid[selY + 1][selX + 1].char ~= nil and t_grid[selY + 1][selX + 1].hidden ~= 2)
529- or motif.select_info.moveoveremptyboxes == 1 then
715+ if (t_grid[selY + 1][selX + 1].char ~= nil and t_grid[selY + 1][selX + 1].hidden ~= 2) or motif.select_info.moveoveremptyboxes == 1 then
530716 break
531717 elseif motif.select_info.searchemptyboxesup ~= 0 then
532718 found, selX = select.f_searchEmptyBoxes(motif.select_info.searchemptyboxesup, selX, selY)
@@ -552,8 +738,7 @@ function select.f_cellMovement(selX, selY, cmd, faceOffset, rowOffset, snd)
552738 faceOffset = faceOffset + motif.select_info.columns
553739 rowOffset = rowOffset + 1
554740 end
555- if (t_grid[selY + 1][selX + 1].char ~= nil and t_grid[selY + 1][selX + 1].hidden ~= 2)
556- or motif.select_info.moveoveremptyboxes == 1 then
741+ if (t_grid[selY + 1][selX + 1].char ~= nil and t_grid[selY + 1][selX + 1].hidden ~= 2) or motif.select_info.moveoveremptyboxes == 1 then
557742 break
558743 elseif motif.select_info.searchemptyboxesdown ~= 0 then
559744 found, selX = select.f_searchEmptyBoxes(motif.select_info.searchemptyboxesdown, selX, selY)
@@ -572,8 +757,7 @@ function select.f_cellMovement(selX, selY, cmd, faceOffset, rowOffset, snd)
572757 selX = tmpX
573758 end
574759 end
575- if (t_grid[selY + 1][selX + 1].char ~= nil and t_grid[selY + 1][selX + 1].hidden ~= 2)
576- or motif.select_info.moveoveremptyboxes == 1 then
760+ if (t_grid[selY + 1][selX + 1].char ~= nil and t_grid[selY + 1][selX + 1].hidden ~= 2) or motif.select_info.moveoveremptyboxes == 1 then
577761 break
578762 end
579763 end
@@ -587,8 +771,7 @@ function select.f_cellMovement(selX, selY, cmd, faceOffset, rowOffset, snd)
587771 selX = tmpX
588772 end
589773 end
590- if (t_grid[selY + 1][selX + 1].char ~= nil and t_grid[selY + 1][selX + 1].hidden ~= 2)
591- or motif.select_info.moveoveremptyboxes == 1 then
774+ if (t_grid[selY + 1][selX + 1].char ~= nil and t_grid[selY + 1][selX + 1].hidden ~= 2) or motif.select_info.moveoveremptyboxes == 1 then
592775 break
593776 end
594777 end
@@ -650,27 +833,28 @@ function select.f_resetGrid()
650833
651834 --1Pのランダムセル表示位置 / 1P random cell display position
652835 if t_grid[row + p1RowOffset][col].char == 'randomselect' or t_grid[row + p1RowOffset][col].hidden == 3 then
653- 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}
836+ table.insert(select.t_drawFace, {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})
654837 --1Pのキャラ表示位置 / 1P character display position
655838 elseif t_grid[row + p1RowOffset][col].char ~= nil and t_grid[row + p1RowOffset][col].hidden == 0 then
656- 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}
839+ table.insert(select.t_drawFace, {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})
840+ --Empty boxes display position
657841 elseif motif.select_info.showemptyboxes == 1 then
658- 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}
842+ table.insert(select.t_drawFace, {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})
659843 end
660844
661845 --2Pのランダムセル表示位置 / 2P random cell display position
662846 if t_grid[row + p2RowOffset][col].char == 'randomselect' or t_grid[row + p2RowOffset][col].hidden == 3 then
663- 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}
847+ table.insert(select.t_drawFace, {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} )
664848 --2Pのキャラ表示位置 / 2P character display position
665849 elseif t_grid[row + p2RowOffset][col].char ~= nil and t_grid[row + p2RowOffset][col].hidden == 0 then
666- 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}
667- -- Empty boxes display position
850+ table.insert(select.t_drawFace, {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})
851+ --Empty boxes display position
668852 elseif motif.select_info.showemptyboxes == 1 then
669- select.t_drawFace[#select.t_drawFace + 1] = {d = 10, 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}
853+ table.insert(select.t_drawFace, {d = 10, 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})
670854 end
671855 end
672856 end
673- main.f_printTable(select.t_drawFace, "debug/t_drawFace.txt")
857+ main.f_printTable(select.t_drawFace, 'debug/t_drawFace.txt')
674858 end
675859
676860 function select.f_selectReset()
@@ -686,7 +870,7 @@ function select.f_selectReset()
686870 p2FaceY = motif.select_info.pos[2]
687871 end
688872 select.f_resetGrid()
689- if main.gameMode == 'netplayversus' or main.gameMode == 'netplayteamcoop' or main.gameMode == 'netplaysurvivalcoop' then
873+ if gameMode('netplayversus') or gameMode('netplayteamcoop') or gameMode('netplaysurvivalcoop') then
690874 p1TeamMode = 0
691875 p2TeamMode = 0
692876 stageNo = 0
@@ -714,14 +898,17 @@ function select.f_selectReset()
714898 stageEnd = false
715899 coopEnd = false
716900 restoreTeam = false
901+ continueStage = false
717902 p1NumChars = 1
718903 p2NumChars = 1
904+ winner = 0
719905 matchNo = 0
720906 setMatchNo(matchNo)
907+ resetRemapInput()
721908 end
722909
723910 --;===========================================================
724---; SIMPLE LOOP (VS MODE, TRAINING, WATCH, BONUS GAMES)
911+--; SIMPLE LOOP (VS MODE, TEAM VERSUS, TRAINING, WATCH, BONUS GAMES)
725912 --;===========================================================
726913 function select.f_selectSimple()
727914 p1SelX = motif.select_info.p1_cursor_startcell[2]
@@ -735,37 +922,44 @@ function select.f_selectSimple()
735922 stageList = 0
736923 main.f_cmdInput()
737924 while true do
738- main.f_resetBG(motif.select_info, motif.selectbgdef, motif.music.select_bgm, motif.music.select_bgm_loop, motif.music.select_bgm_volume, motif.music.select_bgm_loopstart, motif.music.select_bgm_loopend)
925+ main.f_menuReset(motif.selectbgdef.bg, motif.music.select_bgm, motif.music.select_bgm_loop, motif.music.select_bgm_volume, motif.music.select_bgm_loopstart, motif.music.select_bgm_loopend)
926+ fadeType = 'fadein'
739927 select.f_selectReset()
740928 selectStart()
741929 while not selScreenEnd do
742930 if esc() then
743931 sndPlay(motif.files.snd_data, motif.select_info.cancel_snd[1], motif.select_info.cancel_snd[2])
744- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
932+ main.f_menuReset(motif.titlebgdef.bg, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
933+ resetRemapInput()
745934 return
746935 end
747936 select.f_selectScreen()
748937 end
749- select.f_aiLevel()
750- if not main.stageMenu then
751- select.f_selectStage()
752- end
938+ --fight initialization
939+ select.f_remapAI()
940+ select.f_setRounds()
941+ stageNo = select.f_setStage(stageNo)
753942 select.f_selectVersus()
754943 if esc() then break end
755- select.f_setZoom()
756- select.f_assignMusic()
757944 loadStart()
758945 winner, t_gameStats = game()
946+ main.f_printTable(t_gameStats, 'debug/t_gameStats.txt')
947+ --victory screen
948+ if motif.victory_screen.vs_enabled == 1 and winner >= 1 and (gameMode('versus') or gameMode('netplayversus')) then
949+ select.f_selectVictory()
950+ end
951+ if challenger then
952+ break
953+ end
759954 main.f_cmdInput()
760955 refresh()
761956 end
762957 end
763958
764959 --;===========================================================
765---; ADVANCE LOOP (ARCADE, TEAM CO-OP, SURVIVAL, SURVIVAL CO-OP, VS 100 KUMITE, BOSS RUSH)
960+--; ARRANGED LOOP (SURVIVAL, SURVIVAL CO-OP, VS 100 KUMITE, BOSS RUSH)
766961 --;===========================================================
767-function select.f_selectAdvance()
768-getSpriteInfo('chars/kfm/kfm.sff', 0, 1)
962+function select.f_selectArranged()
769963 p1SelX = motif.select_info.p1_cursor_startcell[2]
770964 p1SelY = motif.select_info.p1_cursor_startcell[1]
771965 p2SelX = motif.select_info.p2_cursor_startcell[2]
@@ -774,21 +968,21 @@ getSpriteInfo('chars/kfm/kfm.sff', 0, 1)
774968 p2FaceOffset = 0
775969 p1RowOffset = 0
776970 p2RowOffset = 0
777- winner = 0
778971 winCnt = 0
779972 looseCnt = 0
973+ stageList = 0
780974 main.f_cmdInput()
781975 select.f_selectReset()
782- t_p2Selected = {}
783- stageEnd = true
784976 local t_enemySelected = {}
785977 while true do
786- main.f_resetBG(motif.select_info, motif.selectbgdef, motif.music.select_bgm, motif.music.select_bgm_loop, motif.music.select_bgm_volume, motif.music.select_bgm_loopstart, motif.music.select_bgm_loopend)
978+ main.f_menuReset(motif.selectbgdef.bg, motif.music.select_bgm, motif.music.select_bgm_loop, motif.music.select_bgm_volume, motif.music.select_bgm_loopstart, motif.music.select_bgm_loopend)
979+ fadeType = 'fadein'
787980 selectStart()
788981 while not selScreenEnd do
789982 if esc() then
790983 sndPlay(motif.files.snd_data, motif.select_info.cancel_snd[1], motif.select_info.cancel_snd[2])
791- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
984+ main.f_menuReset(motif.titlebgdef.bg, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
985+ resetRemapInput()
792986 return
793987 end
794988 select.f_selectScreen()
@@ -805,23 +999,27 @@ getSpriteInfo('chars/kfm/kfm.sff', 0, 1)
805999 end
8061000 --generate roster
8071001 select.f_makeRoster()
808- lastMatch = #t_roster / p2NumChars
809- matchNo = 1
810- --generate AI ramping table
811- select.f_aiRamp()
812- --intro
813- if main.gameMode == 'arcade' or main.gameMode == 'teamcoop' or main.gameMode == 'netplayteamcoop' then
814- local tPos = main.t_selChars[t_p1Selected[1].cel + 1]
815- if tPos.intro ~= nil and main.f_fileExists(tPos.intro) then
816- storyboard.f_storyboard(tPos.intro)
1002+ --sum all upcoming matches and set starting order group
1003+ currentOrder = 0
1004+ currentRosterIndex = 1
1005+ lastMatch = 0
1006+ for i = 1, #t_roster do
1007+ if #t_roster[i] > 0 then
1008+ if currentOrder == 0 then
1009+ currentOrder = i
1010+ end
1011+ lastMatch = lastMatch + #t_roster[i] / p2NumChars
8171012 end
8181013 end
1014+ matchNo = 1
1015+ --generate AI ramping table
1016+ select.f_aiRamp(1)
8191017 --player exit the match via ESC in VS 100 Kumite mode
820- elseif winner == -1 and main.gameMode == '100kumite' then
1018+ elseif winner == -1 and gameMode('100kumite') then
8211019 --counter
8221020 looseCnt = looseCnt + 1
8231021 --result
824- select.f_result('lost')
1022+ select.f_result()
8251023 --game over
8261024 if motif.game_over_screen.enabled == 1 and motif.game_over_screen.storyboard ~= '' then
8271025 storyboard.f_storyboard(motif.game_over_screen.storyboard)
@@ -830,36 +1028,48 @@ getSpriteInfo('chars/kfm/kfm.sff', 0, 1)
8301028 if motif.files.intro_storyboard ~= '' then
8311029 storyboard.f_storyboard(motif.files.intro_storyboard)
8321030 end
833- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
1031+ main.f_menuReset(motif.titlebgdef.bg, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
1032+ resetRemapInput()
8341033 return
835- --player won (also if lost in VS 100 Kumite)
836- elseif winner == 1 or main.gameMode == '100kumite' then
1034+ --player won
1035+ elseif winner == 1 then
8371036 --counter
838- if winner == 1 then
839- winCnt = winCnt + 1
840- else --only true in VS 100 Kumite mode
841- looseCnt = looseCnt + 1
842- end
843- --victory screen
844- if main.gameMode == 'arcade' or main.gameMode == 'teamcoop' or main.gameMode == 'netplayteamcoop' then
845- if motif.victory_screen.enabled == 1 and (main.t_selChars[t_p2Selected[1].cel + 1].winscreen == nil or main.t_selChars[t_p2Selected[1].cel + 1].winscreen == 1) then
846- select.f_selectVictory()
1037+ winCnt = winCnt + 1
1038+ --last match in the current order group
1039+ if currentRosterIndex == #t_roster[currentOrder] / p2NumChars then
1040+ if (gameMode('survival') or gameMode('survivalcoop') or gameMode('netplaysurvivalcoop')) and main.t_selOptions.survivalmaxmatches[currentOrder] == -1 then --survival mode infinite fights
1041+ --randomly rearrange array entries positions of the current order group
1042+ main.f_shuffleTable(t_roster[currentOrder])
1043+ --ensure that the next fight won't be against team members we've just fought
1044+ local t_lastRefs = {}
1045+ for i = 1, #t_p2Selected do
1046+ t_lastRefs[t_p2Selected[i].cel] = '' --store last enemy team refs as keys
1047+ end
1048+ for i = 1, #t_p2Selected do
1049+ if t_lastRefs[t_roster[currentOrder][i]] ~= nil then
1050+ table.remove(t_roster[currentOrder], i) --remove char ref from the given position of an array
1051+ table.insert(t_roster[currentOrder], t_p2Selected[i].cel) --and inserts it in the last position of the array
1052+ end
1053+ end
1054+ --update variables
1055+ local lastMatchRamp = lastMatch + 1
1056+ lastMatch = lastMatch + #t_roster[currentOrder] / p2NumChars --with this value the mode should go infinitely
1057+ --append new entries to existing AI ramping table
1058+ select.f_aiRamp(lastMatchRamp)
1059+ else --survival mode finite fights or other modes
1060+ for i = currentOrder + 1, #t_roster do --find next order group with assigned characters
1061+ if #t_roster[i] > 0 then
1062+ currentOrder = i
1063+ break
1064+ end
1065+ end
8471066 end
1067+ currentRosterIndex = 0
8481068 end
849- t_p2Selected = {}
8501069 --no more matches left
8511070 if matchNo == lastMatch then
852- --ending
853- if main.gameMode == 'arcade' or main.gameMode == 'teamcoop' or main.gameMode == 'netplayteamcoop' then
854- local tPos = main.t_selChars[t_p1Selected[1].cel + 1]
855- if tPos.ending ~= nil and main.f_fileExists(tPos.ending) then
856- storyboard.f_storyboard(tPos.ending)
857- elseif motif.default_ending.enabled == 1 and motif.default_ending.storyboard ~= '' then
858- storyboard.f_storyboard(motif.default_ending.storyboard)
859- end
860- end
8611071 --result
862- select.f_result(true)
1072+ select.f_result()
8631073 --credits
8641074 if motif.end_credits.enabled == 1 and motif.end_credits.storyboard ~= '' then
8651075 storyboard.f_storyboard(motif.end_credits.storyboard)
@@ -872,24 +1082,21 @@ getSpriteInfo('chars/kfm/kfm.sff', 0, 1)
8721082 if motif.files.intro_storyboard ~= '' then
8731083 storyboard.f_storyboard(motif.files.intro_storyboard)
8741084 end
875- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
1085+ main.f_menuReset(motif.titlebgdef.bg, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
1086+ resetRemapInput()
8761087 return
8771088 --next match available
8781089 else
8791090 matchNo = matchNo + 1
1091+ currentRosterIndex = currentRosterIndex + 1
1092+ t_p2Selected = {}
8801093 end
881- --player lost and doesn't have any credits left
882- elseif main.credits == 0 then
1094+ --player lost
1095+ else
8831096 --counter
8841097 looseCnt = looseCnt + 1
885- --victory screen
886- if main.gameMode == 'arcade' or main.gameMode == 'teamcoop' or main.gameMode == 'netplayteamcoop' then
887- if motif.victory_screen.enabled == 1 and 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
888- select.f_selectVictory()
889- end
890- end
8911098 --result
892- select.f_result(false)
1099+ select.f_result()
8931100 --game over
8941101 if motif.game_over_screen.enabled == 1 and motif.game_over_screen.storyboard ~= '' then
8951102 storyboard.f_storyboard(motif.game_over_screen.storyboard)
@@ -898,58 +1105,12 @@ getSpriteInfo('chars/kfm/kfm.sff', 0, 1)
8981105 if motif.files.intro_storyboard ~= '' then
8991106 storyboard.f_storyboard(motif.files.intro_storyboard)
9001107 end
901- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
1108+ main.f_menuReset(motif.titlebgdef.bg, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
1109+ resetRemapInput()
9021110 return
903- --player lost but can continue
904- else
905- --counter
906- looseCnt = looseCnt + 1
907- --victory screen
908- if motif.victory_screen.enabled == 1 and 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
909- select.f_selectVictory()
910- end
911- --continue screen
912- select.f_continue()
913- if not continue then
914- --game over
915- if motif.continue_screen.external_gameover == 1 and motif.game_over_screen.storyboard ~= '' then
916- storyboard.f_storyboard(motif.game_over_screen.storyboard)
917- end
918- --intro
919- if motif.files.intro_storyboard ~= '' then
920- storyboard.f_storyboard(motif.files.intro_storyboard)
921- end
922- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
923- return
924- end
925- if config.ContSelection then --true if 'Char change at Continue' option is enabled
926- t_p1Selected = {}
927- p1SelEnd = false
928- if main.coop then
929- p1NumChars = 1
930- numChars = p2NumChars
931- p2NumChars = 1
932- t_p2Selected = {}
933- p2SelEnd = false
934- end
935- selScreenEnd = false
936- while not selScreenEnd do
937- if esc() then
938- sndPlay(motif.files.snd_data, motif.select_info.cancel_snd[1], motif.select_info.cancel_snd[2])
939- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
940- return
941- end
942- select.f_selectScreen()
943- end
944- elseif esc() then
945- sndPlay(motif.files.snd_data, motif.select_info.cancel_snd[1], motif.select_info.cancel_snd[2])
946- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
947- return
948- end
9491111 end
9501112 --coop swap
9511113 if main.coop then
952- remapInput(3,2) --P2 controls assigned to P3 character
9531114 if winner == -1 or winner == 2 then
9541115 p1NumChars = 2
9551116 p2NumChars = numChars
@@ -962,53 +1123,333 @@ getSpriteInfo('chars/kfm/kfm.sff', 0, 1)
9621123 if #t_p2Selected == 0 then
9631124 local shuffle = true
9641125 for i = 1, p2NumChars do
965- 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
966- p2Cell = main.t_charDef[main.t_selChars[t_p1Selected[1].cel + 1][matchNo]]
967- shuffle = false
968- else
969- p2Cell = t_roster[matchNo * p2NumChars - i + 1]
970- end
971- local updateAnim = true
972- for j = 1, #t_p2Selected do
973- if t_p2Selected[j].cel == p2Cell then
974- updateAnim = false
975- end
976- end
977- t_p2Selected[#t_p2Selected + 1] = {cel = p2Cell, pal = select.f_randomPal(p2Cell), up = updateAnim}
1126+ p2Cell = t_roster[currentOrder][currentRosterIndex * p2NumChars - i + 1]
1127+ table.insert(t_p2Selected, {cel = p2Cell, pal = select.f_selectPal(p2Cell)})
9781128 if shuffle then
9791129 main.f_shuffleTable(t_p2Selected)
9801130 end
9811131 end
9821132 t_enemySelected = t_p2Selected
9831133 end
984- --Team conversion to Single match if bonus paramvalue on any opponents is detected
985- if p2NumChars > 1 then
986- for i = 1, #t_p2Selected do
987- if main.t_selChars[t_p2Selected[i].cel + 1].bonus ~= nil and main.t_selChars[t_p2Selected[i].cel + 1].bonus == 1 then
988- teamMode = p2TeamMode
989- numChars = p2NumChars
990- p2TeamMode = 0
991- p2NumChars = 1
992- setTeamMode(2, 0, 1)
993- p2Cell = main.t_charDef[main.t_selChars[t_p2Selected[i].cel + 1].char]
1134+ --fight initialization
1135+ setMatchNo(matchNo)
1136+ select.f_overwriteCharData()
1137+ select.f_remapAI()
1138+ select.f_setRounds()
1139+ stageNo = select.f_setStage(stageNo)
1140+ select.f_selectVersus()
1141+ --if esc() then break end
1142+ loadStart()
1143+ winner, t_gameStats = game()
1144+ main.f_printTable(t_gameStats, 'debug/t_gameStats.txt')
1145+ resetRemapInput()
1146+ main.f_cmdInput()
1147+ refresh()
1148+ end
1149+end
1150+
1151+--;===========================================================
1152+--; ARCADE LOOP (ARCADE, TEAM ARCADE, TEAM CO-OP)
1153+--;===========================================================
1154+function select.f_selectArcade()
1155+ p1SelX = motif.select_info.p1_cursor_startcell[2]
1156+ p1SelY = motif.select_info.p1_cursor_startcell[1]
1157+ p2SelX = motif.select_info.p2_cursor_startcell[2]
1158+ p2SelY = motif.select_info.p2_cursor_startcell[1]
1159+ p1FaceOffset = 0
1160+ p2FaceOffset = 0
1161+ p1RowOffset = 0
1162+ p2RowOffset = 0
1163+ winCnt = 0
1164+ looseCnt = 0
1165+ main.f_cmdInput()
1166+ select.f_selectReset()
1167+ stageEnd = true
1168+ local t_enemySelected = {}
1169+ while true do
1170+ main.f_menuReset(motif.selectbgdef.bg, motif.music.select_bgm, motif.music.select_bgm_loop, motif.music.select_bgm_volume, motif.music.select_bgm_loopstart, motif.music.select_bgm_loopend)
1171+ fadeType = 'fadein'
1172+ selectStart()
1173+ while not selScreenEnd do
1174+ if esc() then
1175+ sndPlay(motif.files.snd_data, motif.select_info.cancel_snd[1], motif.select_info.cancel_snd[2])
1176+ main.f_menuReset(motif.titlebgdef.bg, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
1177+ resetRemapInput()
1178+ return
1179+ end
1180+ select.f_selectScreen()
1181+ end
1182+ --if last match was not against a challenger
1183+ if not challenger then
1184+ --first match
1185+ if matchNo == 0 then
1186+ --coop swap
1187+ if main.coop then
1188+ p1TeamMode = 1
1189+ p1NumChars = 2
1190+ setTeamMode(1, p1TeamMode, p1NumChars)
1191+ t_p1Selected[2] = {cel = t_p2Selected[1].cel, pal = t_p2Selected[1].pal}
1192+ t_p2Selected = t_enemySelected
1193+ end
1194+ --generate roster
1195+ select.f_makeRoster()
1196+ --sum all upcoming matches and set starting order group
1197+ currentOrder = 0
1198+ currentRosterIndex = 1
1199+ lastMatch = 0
1200+ for i = 1, #t_roster do
1201+ if #t_roster[i] > 0 then
1202+ if currentOrder == 0 then
1203+ currentOrder = i
1204+ end
1205+ lastMatch = lastMatch + #t_roster[i] / p2NumChars
1206+ end
1207+ end
1208+ matchNo = 1
1209+ --generate AI ramping table
1210+ select.f_aiRamp(1)
1211+ --intro
1212+ local tPos = main.t_selChars[t_p1Selected[1].cel + 1]
1213+ if tPos.intro ~= nil and main.f_fileExists(tPos.intro) then
1214+ storyboard.f_storyboard(tPos.intro)
1215+ end
1216+ --player won
1217+ elseif winner == 1 then
1218+ --counter
1219+ winCnt = winCnt + 1
1220+ --last match in the current order group
1221+ if currentRosterIndex == #t_roster[currentOrder] / p2NumChars then
1222+ for i = currentOrder + 1, #t_roster do --find next order group with assigned characters
1223+ if #t_roster[i] > 0 then
1224+ currentOrder = i
1225+ break
1226+ end
1227+ end
1228+ currentRosterIndex = 0
1229+ end
1230+ --victory screen
1231+ if motif.victory_screen.enabled == 1 then
1232+ select.f_selectVictory()
1233+ end
1234+ --no more matches left
1235+ if matchNo == lastMatch then
1236+ --ending
1237+ local tPos = main.t_selChars[t_p1Selected[1].cel + 1]
1238+ if tPos.ending ~= nil and main.f_fileExists(tPos.ending) then
1239+ storyboard.f_storyboard(tPos.ending)
1240+ elseif motif.default_ending.enabled == 1 and motif.default_ending.storyboard ~= '' then
1241+ storyboard.f_storyboard(motif.default_ending.storyboard)
1242+ end
1243+ --credits
1244+ if motif.end_credits.enabled == 1 and motif.end_credits.storyboard ~= '' then
1245+ storyboard.f_storyboard(motif.end_credits.storyboard)
1246+ end
1247+ --game over
1248+ if motif.game_over_screen.enabled == 1 and motif.game_over_screen.storyboard ~= '' then
1249+ storyboard.f_storyboard(motif.game_over_screen.storyboard)
1250+ end
1251+ --intro
1252+ if motif.files.intro_storyboard ~= '' then
1253+ storyboard.f_storyboard(motif.files.intro_storyboard)
1254+ end
1255+ main.f_menuReset(motif.titlebgdef.bg, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
1256+ resetRemapInput()
1257+ return
1258+ --next match available
1259+ else
1260+ matchNo = matchNo + 1
1261+ currentRosterIndex = currentRosterIndex + 1
1262+ continueStage = false
9941263 t_p2Selected = {}
995- t_p2Selected[1] = {cel = p2Cell, pal = select.f_randomPal(p2Cell), up = true}
996- restoreTeam = true
997- break
1264+ end
1265+ --player lost and doesn't have any credits left
1266+ elseif main.credits == 0 then
1267+ --counter
1268+ looseCnt = looseCnt + 1
1269+ --victory screen
1270+ if motif.victory_screen.cpu_enabled == 1 and winner >= 2 then
1271+ select.f_selectVictory()
1272+ end
1273+ --game over
1274+ if motif.game_over_screen.enabled == 1 and motif.game_over_screen.storyboard ~= '' then
1275+ storyboard.f_storyboard(motif.game_over_screen.storyboard)
1276+ end
1277+ --intro
1278+ if motif.files.intro_storyboard ~= '' then
1279+ storyboard.f_storyboard(motif.files.intro_storyboard)
1280+ end
1281+ main.f_menuReset(motif.titlebgdef.bg, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
1282+ resetRemapInput()
1283+ return
1284+ --player lost but can continue
1285+ else
1286+ --counter
1287+ looseCnt = looseCnt + 1
1288+ --victory screen
1289+ if motif.victory_screen.cpu_enabled == 1 and winner >= 2 then
1290+ select.f_selectVictory()
1291+ end
1292+ --continue screen
1293+ select.f_continue()
1294+ if not continue then
1295+ --game over
1296+ if motif.continue_screen.external_gameover == 1 and motif.game_over_screen.storyboard ~= '' then
1297+ storyboard.f_storyboard(motif.game_over_screen.storyboard)
1298+ end
1299+ --intro
1300+ if motif.files.intro_storyboard ~= '' then
1301+ storyboard.f_storyboard(motif.files.intro_storyboard)
1302+ end
1303+ main.f_menuReset(motif.titlebgdef.bg, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
1304+ resetRemapInput()
1305+ return
1306+ end
1307+ if config.ContSelection then --true if 'Char change at Continue' option is enabled
1308+ t_p1Selected = {}
1309+ p1SelEnd = false
1310+ if main.coop then
1311+ p1NumChars = 1
1312+ numChars = p2NumChars
1313+ p2NumChars = 1
1314+ t_p2Selected = {}
1315+ p2SelEnd = false
1316+ end
1317+ fadeType = 'fadein'
1318+ --selectStart()
1319+ selScreenEnd = false
1320+ while not selScreenEnd do
1321+ if esc() then
1322+ sndPlay(motif.files.snd_data, motif.select_info.cancel_snd[1], motif.select_info.cancel_snd[2])
1323+ main.f_menuReset(motif.titlebgdef.bg, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
1324+ resetRemapInput()
1325+ return
1326+ end
1327+ select.f_selectScreen()
1328+ end
1329+ elseif esc() then
1330+ sndPlay(motif.files.snd_data, motif.select_info.cancel_snd[1], motif.select_info.cancel_snd[2])
1331+ main.f_menuReset(motif.titlebgdef.bg, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
1332+ resetRemapInput()
1333+ return
1334+ end
1335+ continueStage = true
1336+ end
1337+ --coop swap
1338+ if main.coop then
1339+ if winner == -1 or winner == 2 then
1340+ p1NumChars = 2
1341+ p2NumChars = numChars
1342+ t_p1Selected[2] = {cel = t_p2Selected[1].cel, pal = t_p2Selected[1].pal}
1343+ t_p2Selected = t_enemySelected
1344+ end
1345+ end
1346+ --assign enemy team
1347+ --t_p2Selected = {}
1348+ if #t_p2Selected == 0 then
1349+ local shuffle = true
1350+ for i = 1, p2NumChars do
1351+ if i == 1 and select.f_rivalsMatch('char_ref') then --enemy assigned as rivals param
1352+ p2Cell = main.t_selChars[t_p1Selected[1].cel + 1].rivals[matchNo].char_ref
1353+ shuffle = false
1354+ else
1355+ p2Cell = t_roster[currentOrder][currentRosterIndex * p2NumChars - i + 1]
1356+ end
1357+ table.insert(t_p2Selected, {cel = p2Cell, pal = select.f_selectPal(p2Cell)})
1358+ if shuffle then
1359+ main.f_shuffleTable(t_p2Selected)
1360+ end
1361+ end
1362+ t_enemySelected = t_p2Selected
1363+ end
1364+ --Team conversion to Single match if onlyme paramvalue on any opponents is detected
1365+ if p2NumChars > 1 then
1366+ for i = 1, #t_p2Selected do
1367+ local onlyme = false
1368+ if select.f_rivalsMatch('char_ref') and main.t_selChars[t_p1Selected[1].cel + 1].rivals[matchNo].onlyme == 1 then --team conversion assigned as rivals param
1369+ p2Cell = main.t_selChars[t_p1Selected[1].cel + 1].rivals[matchNo].char_ref
1370+ onlyme = true
1371+ elseif main.t_selChars[t_p2Selected[i].cel + 1].onlyme == 1 then --team conversion assigned as character param
1372+ p2Cell = main.t_selChars[t_p2Selected[i].cel + 1].char_ref
1373+ onlyme = true
1374+ end
1375+ if onlyme then
1376+ teamMode = p2TeamMode
1377+ numChars = p2NumChars
1378+ p2TeamMode = 0
1379+ p2NumChars = 1
1380+ setTeamMode(2, p2TeamMode, p2NumChars)
1381+ t_p2Selected = {}
1382+ t_p2Selected[1] = {cel = p2Cell, pal = select.f_selectPal(p2Cell), up = true}
1383+ restoreTeam = true
1384+ break
1385+ end
9981386 end
9991387 end
10001388 end
1389+ --fight initialization
10011390 setMatchNo(matchNo)
1002- select.f_aiLevel()
1003- if not main.stageMenu then
1004- select.f_selectStage()
1005- end
1391+ select.f_remapAI()
1392+ select.f_setRounds()
1393+ stageNo = select.f_setStage(stageNo)
10061394 select.f_selectVersus()
10071395 if esc() then break end
1008- select.f_setZoom()
1009- select.f_assignMusic()
10101396 loadStart()
10111397 winner, t_gameStats = game()
1398+ main.f_printTable(t_gameStats, 'debug/t_gameStats.txt')
1399+ --here comes a new challenger
1400+ challenger = false
1401+ if t_gameStats.challenger > 0 then
1402+ refresh() --needed to clean inputs
1403+ challenger = true
1404+ --save values
1405+ local p2TeamMenu_sav = main.f_copyTable(main.p2TeamMenu)
1406+ local t_p2Selected_sav = main.f_copyTable(t_p2Selected)
1407+ local t_charparam_sav = main.f_copyTable(main.t_charparam)
1408+ local p1Cell_sav = p1Cell
1409+ local p2Cell_sav = p2Cell
1410+ local matchNo_sav = matchNo
1411+ local stageNo_sav = stageNo
1412+ local p2TeamMode_sav = p2TeamMode
1413+ local p2NumChars_sav = p2NumChars
1414+ local gameMode = gameMode()
1415+ main.f_resetCharparam()
1416+ --temp values
1417+ textImgSetText(main.txt_mainSelect, motif.select_info.title_text_teamversus)
1418+ setHomeTeam(1)
1419+ main.p2In = 2
1420+ main.p2SelectMenu = true
1421+ main.stageMenu = true
1422+ main.p2Faces = true
1423+ main.p1TeamMenu = nil
1424+ main.p2TeamMenu = nil
1425+ setGameMode('teamversus')
1426+ --start challenger match
1427+ select.f_selectSimple()
1428+ --reload values
1429+ textImgSetText(main.txt_mainSelect, motif.select_info.title_text_arcade)
1430+ setHomeTeam(2)
1431+ main.p2In = 1
1432+ main.p2SelectMenu = false
1433+ main.stageMenu = false
1434+ main.p2Faces = false
1435+ --move player2 characters into player1 side and remap buttons if needed
1436+ if winner == 2 then
1437+ --TODO: when player1 team loose continue playing the arcade mode as player2 team
1438+ end
1439+ --restore values
1440+ main.p2TeamMenu = main.f_copyTable(p2TeamMenu_sav)
1441+ t_p2Selected = main.f_copyTable(t_p2Selected_sav)
1442+ main.t_charparam = main.f_copyTable(t_charparam_sav)
1443+ p1Cell = p1Cell_sav
1444+ p2Cell = p2Cell_sav
1445+ matchNo = matchNo_sav
1446+ stageNo = stageNo_sav
1447+ p2TeamMode = p2TeamMode_sav
1448+ p2NumChars = p2NumChars_sav
1449+ setTeamMode(2, p2TeamMode, p2NumChars)
1450+ setGameMode(gameMode)
1451+ continueStage = true
1452+ end
10121453 --restore P2 Team settings if needed
10131454 if restoreTeam then
10141455 p2TeamMode = teamMode
@@ -1018,7 +1459,6 @@ getSpriteInfo('chars/kfm/kfm.sff', 0, 1)
10181459 end
10191460 resetRemapInput()
10201461 main.f_cmdInput()
1021- --main.f_printTable(_G)
10221462 refresh()
10231463 end
10241464 end
@@ -1026,7 +1466,7 @@ end
10261466 --;===========================================================
10271467 --; TOURNAMENT LOOP
10281468 --;===========================================================
1029-function select.f_selectTournament()
1469+function select.f_selectTournament(size)
10301470 p1SelX = motif.select_info.p1_cursor_startcell[2]
10311471 p1SelY = motif.select_info.p1_cursor_startcell[1]
10321472 p2SelX = motif.select_info.p2_cursor_startcell[2]
@@ -1038,20 +1478,23 @@ function select.f_selectTournament()
10381478 stageList = 0
10391479 main.f_cmdInput()
10401480 while true do
1041- main.f_resetBG(motif.tournament_info, motif.tournamentbgdef, motif.music.tournament_bgm, motif.music.tournament_bgm_loop, motif.music.tournament_bgm_volume, motif.music.tournament_bgm_loopstart, motif.music.tournament_bgm_loopend)
1481+ main.f_menuReset(motif.tournamentbgdef.bg, motif.music.tournament_bgm, motif.music.tournament_bgm_loop, motif.music.tournament_bgm_volume, motif.music.tournament_bgm_loopstart, motif.music.tournament_bgm_loopend)
1482+ fadeType = 'fadein'
10421483 select.f_selectReset()
10431484 while not selScreenEnd do
10441485 if esc() then
10451486 sndPlay(motif.files.snd_data, motif.select_info.cancel_snd[1], motif.select_info.cancel_snd[2])
1046- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
1487+ main.f_menuReset(motif.titlebgdef.bg, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
1488+ resetRemapInput()
10471489 return
10481490 end
1049- select.f_selectTournamentScreen()
1491+ select.f_selectTournamentScreen(size)
10501492 end
1051- select.f_aiLevel()
1493+ --fight initialization
1494+ select.f_remapAI()
1495+ select.f_setRounds()
1496+ stageNo = select.f_setStage(stageNo)
10521497 select.f_selectVersus()
1053- select.f_setZoom()
1054- select.f_assignMusic()
10551498 loadStart()
10561499 winner, t_gameStats = game()
10571500 main.f_cmdInput()
@@ -1062,21 +1505,32 @@ end
10621505 --;===========================================================
10631506 --; TOURNAMENT SCREEN
10641507 --;===========================================================
1065-function select.f_selectTournamentScreen()
1508+function select.f_selectTournamentScreen(size)
10661509 --draw clearcolor
1067- animDraw(motif.tournamentbgdef.bgclearcolor_data)
1510+ clearColor(motif.tournamentbgdef.bgclearcolor[1], motif.tournamentbgdef.bgclearcolor[2], motif.tournamentbgdef.bgclearcolor[3])
10681511 --draw layerno = 0 backgrounds
1069- main.f_drawBG(motif.tournamentbgdef.bg_data, motif.tournamentbgdef.bg, 0, motif.tournamentbgdef.timer, {320,240})
1512+ bgDraw(motif.tournamentbgdef.bg, false)
10701513
10711514 --draw layerno = 1 backgrounds
1072- main.f_drawBG(motif.tournamentbgdef.bg_data, motif.tournamentbgdef.bg, 1, motif.tournamentbgdef.timer, {320,240})
1073- --draw fadein
1074- animDraw(motif.tournament_info.fadein_data)
1075- animUpdate(motif.tournament_info.fadein_data)
1076- --update timer
1077- motif.tournamentbgdef.timer = motif.tournamentbgdef.timer + 1
1078- --end loop
1079- main.f_cmdInput()
1515+ bgDraw(motif.tournamentbgdef.bg, true)
1516+ --draw fadein / fadeout
1517+ main.fadeActive = fadeScreen(
1518+ fadeType,
1519+ main.fadeStart,
1520+ motif.vs_screen[fadeType .. '_time'],
1521+ motif.vs_screen[fadeType .. '_col'][1],
1522+ motif.vs_screen[fadeType .. '_col'][2],
1523+ motif.vs_screen[fadeType .. '_col'][3]
1524+ )
1525+ --frame transition
1526+ if main.fadeActive then
1527+ commandBufReset(main.p1Cmd)
1528+ elseif fadeType == 'fadeout' then
1529+ commandBufReset(main.p1Cmd)
1530+ return --skip last frame rendering
1531+ else
1532+ main.f_cmdInput()
1533+ end
10801534 refresh()
10811535 end
10821536
@@ -1094,34 +1548,44 @@ local txt_p1Name = main.f_createTextImg(
10941548 motif.select_info.p1_name_font_scale[2],
10951549 motif.select_info.p1_name_font[4],
10961550 motif.select_info.p1_name_font[5],
1097- motif.select_info.p1_name_font[6]
1551+ motif.select_info.p1_name_font[6],
1552+ motif.select_info.p1_name_font[7],
1553+ motif.select_info.p1_name_font[8]
10981554 )
1099-
11001555 local p1RandomCount = 0
11011556 local p1RandomPortrait = 0
11021557 if #main.t_randomChars > 0 then p1RandomPortrait = main.t_randomChars[math.random(1, #main.t_randomChars)] end
11031558 local txt_p2Name = main.f_createTextImg(
1104- motif.font_data[motif.select_info.p2_name_font[1]],
1105- motif.select_info.p2_name_font[2],
1106- motif.select_info.p2_name_font[3],
1107- '',
1108- 0,
1109- 0,
1559+ motif.font_data[motif.select_info.p2_name_font[1]],
1560+ motif.select_info.p2_name_font[2],
1561+ motif.select_info.p2_name_font[3],
1562+ '',
1563+ 0,
1564+ 0,
11101565 motif.select_info.p2_name_font_scale[1],
11111566 motif.select_info.p2_name_font_scale[2],
11121567 motif.select_info.p2_name_font[4],
11131568 motif.select_info.p2_name_font[5],
1114- motif.select_info.p2_name_font[6]
1569+ motif.select_info.p2_name_font[6],
1570+ motif.select_info.p2_name_font[7],
1571+ motif.select_info.p2_name_font[8]
11151572 )
11161573 local p2RandomCount = 0
11171574 local p2RandomPortrait = 0
11181575 if #main.t_randomChars > 0 then p2RandomPortrait = main.t_randomChars[math.random(1, #main.t_randomChars)] end
11191576
1577+function select.f_alignOffset(align)
1578+ if align == -1 then
1579+ return 1 --fix for wrong offset after flipping sprites
1580+ end
1581+ return 0
1582+end
1583+
11201584 function select.f_selectScreen()
11211585 --draw clearcolor
1122- animDraw(motif.selectbgdef.bgclearcolor_data)
1586+ clearColor(motif.selectbgdef.bgclearcolor[1], motif.selectbgdef.bgclearcolor[2], motif.selectbgdef.bgclearcolor[3])
11231587 --draw layerno = 0 backgrounds
1124- main.f_drawBG(motif.selectbgdef.bg_data, motif.selectbgdef.bg, 0, motif.selectbgdef.timer, {320,240})
1588+ bgDraw(motif.selectbgdef.bg, false)
11251589 --draw title
11261590 textImgDraw(main.txt_mainSelect)
11271591 if p1Cell then
@@ -1136,28 +1600,26 @@ function select.f_selectScreen()
11361600 p1RandomCount = 0
11371601 end
11381602 sndPlay(motif.files.snd_data, motif.select_info.p1_random_move_snd[1], motif.select_info.p1_random_move_snd[2])
1139- t_portrait[1] = {cel = p1RandomPortrait}
1603+ t_portrait[1] = p1RandomPortrait
11401604 elseif main.t_selChars[p1Cell + 1].hidden ~= 2 then
1141- t_portrait[1] = {cel = p1Cell}
1605+ t_portrait[1] = p1Cell
11421606 end
11431607 end
11441608 for i = #t_p1Selected, 1, -1 do
1145- if motif.select_info.p1_face_num > #t_portrait then
1146- t_portrait[#t_portrait + 1] = {cel = t_p1Selected[i].cel}
1147- end
1148- end
1149- select.f_drawPortrait(
1150- main.f_reversedTable(t_portrait),
1151- motif.select_info.p1_face_offset[1],
1152- motif.select_info.p1_face_offset[2],
1153- motif.select_info.p1_face_facing,
1154- motif.select_info.p1_face_scale[1],
1155- motif.select_info.p1_face_scale[2],
1156- motif.select_info.p1_face_spacing[1],
1157- motif.select_info.p1_face_spacing[2],
1158- #t_portrait,
1159- 'select'
1160- )
1609+ if #t_portrait < motif.select_info.p1_face_num then
1610+ table.insert(t_portrait, t_p1Selected[i].cel)
1611+ end
1612+ end
1613+ t_portrait = main.f_reversedTable(t_portrait)
1614+ for n = #t_portrait, 1, -1 do
1615+ drawPortrait(
1616+ t_portrait[n],
1617+ motif.select_info.p1_face_offset[1] + motif.select_info['p1_c' .. n .. '_face_offset'][1] + (n - 1) * motif.select_info.p1_face_spacing[1] + select.f_alignOffset(motif.select_info.p1_face_facing),
1618+ motif.select_info.p1_face_offset[2] + motif.select_info['p1_c' .. n .. '_face_offset'][2] + (n - 1) * motif.select_info.p1_face_spacing[2],
1619+ motif.select_info.p1_face_facing * motif.select_info.p1_face_scale[1] * motif.select_info['p1_c' .. n .. '_face_scale'][1],
1620+ motif.select_info.p1_face_scale[2] * motif.select_info['p1_c' .. n .. '_face_scale'][2]
1621+ )
1622+ end
11611623 end
11621624 if p2Cell then
11631625 --draw p2 portrait
@@ -1171,28 +1633,26 @@ function select.f_selectScreen()
11711633 p2RandomCount = 0
11721634 end
11731635 sndPlay(motif.files.snd_data, motif.select_info.p2_random_move_snd[1], motif.select_info.p2_random_move_snd[2])
1174- t_portrait[1] = {cel = p2RandomPortrait}
1636+ t_portrait[1] = p2RandomPortrait
11751637 elseif main.t_selChars[p2Cell + 1].hidden ~= 2 then
1176- t_portrait[1] = {cel = p2Cell}
1638+ t_portrait[1] = p2Cell
11771639 end
11781640 end
11791641 for i = #t_p2Selected, 1, -1 do
1180- if motif.select_info.p2_face_num > #t_portrait then
1181- t_portrait[#t_portrait + 1] = {cel = t_p2Selected[i].cel}
1182- end
1183- end
1184- select.f_drawPortrait(
1185- main.f_reversedTable(t_portrait),
1186- motif.select_info.p2_face_offset[1],
1187- motif.select_info.p2_face_offset[2],
1188- motif.select_info.p2_face_facing,
1189- motif.select_info.p2_face_scale[1],
1190- motif.select_info.p2_face_scale[2],
1191- motif.select_info.p2_face_spacing[1],
1192- motif.select_info.p2_face_spacing[2],
1193- #t_portrait,
1194- 'select'
1195- )
1642+ if #t_portrait < motif.select_info.p2_face_num then
1643+ table.insert(t_portrait, t_p2Selected[i].cel)
1644+ end
1645+ end
1646+ t_portrait = main.f_reversedTable(t_portrait)
1647+ for n = #t_portrait, 1, -1 do
1648+ drawPortrait(
1649+ t_portrait[n],
1650+ motif.select_info.p2_face_offset[1] + motif.select_info['p2_c' .. n .. '_face_offset'][1] + (n - 1) * motif.select_info.p2_face_spacing[1] + select.f_alignOffset(motif.select_info.p2_face_facing),
1651+ motif.select_info.p2_face_offset[2] + motif.select_info['p2_c' .. n .. '_face_offset'][2] + (n - 1) * motif.select_info.p2_face_spacing[2],
1652+ motif.select_info.p2_face_facing * motif.select_info.p2_face_scale[1] * motif.select_info['p2_c' .. n .. '_face_scale'][1],
1653+ motif.select_info.p2_face_scale[2] * motif.select_info['p2_c' .. n .. '_face_scale'][2]
1654+ )
1655+ end
11961656 end
11971657 --draw cell art (slow for large rosters, this will be likely moved to 'drawFace' function in future)
11981658 for i = 1, #select.t_drawFace do
@@ -1302,19 +1762,33 @@ function select.f_selectScreen()
13021762 elseif main.coop and not coopEnd then
13031763 coopEnd = true
13041764 p2TeamEnd = false
1305- else
1765+ elseif fadeType == 'fadein' then
1766+ main.fadeStart = getFrameCount()
1767+ fadeType = 'fadeout'
1768+ elseif not main.fadeActive then
13061769 selScreenEnd = true
13071770 end
13081771 end
13091772 --draw layerno = 1 backgrounds
1310- main.f_drawBG(motif.selectbgdef.bg_data, motif.selectbgdef.bg, 1, motif.selectbgdef.timer, {320,240})
1311- --draw fadein
1312- animDraw(motif.select_info.fadein_data)
1313- animUpdate(motif.select_info.fadein_data)
1314- --update timer
1315- motif.selectbgdef.timer = motif.selectbgdef.timer + 1
1316- --end loop
1317- main.f_cmdInput()
1773+ bgDraw(motif.selectbgdef.bg, true)
1774+ --draw fadein / fadeout
1775+ main.fadeActive = fadeScreen(
1776+ fadeType,
1777+ main.fadeStart,
1778+ motif.select_info[fadeType .. '_time'],
1779+ motif.select_info[fadeType .. '_col'][1],
1780+ motif.select_info[fadeType .. '_col'][2],
1781+ motif.select_info[fadeType .. '_col'][3]
1782+ )
1783+ --frame transition
1784+ if main.fadeActive then
1785+ commandBufReset(main.p1Cmd)
1786+ elseif fadeType == 'fadeout' then
1787+ commandBufReset(main.p1Cmd)
1788+ return --skip last frame rendering
1789+ else
1790+ main.f_cmdInput()
1791+ end
13181792 refresh()
13191793 end
13201794
@@ -1332,7 +1806,9 @@ local txt_p1TeamSelfTitle = main.f_createTextImg(
13321806 motif.select_info.p1_teammenu_selftitle_font_scale[2],
13331807 motif.select_info.p1_teammenu_selftitle_font[4],
13341808 motif.select_info.p1_teammenu_selftitle_font[5],
1335- motif.select_info.p1_teammenu_selftitle_font[6]
1809+ motif.select_info.p1_teammenu_selftitle_font[6],
1810+ motif.select_info.p1_teammenu_selftitle_font[7],
1811+ motif.select_info.p1_teammenu_selftitle_font[8]
13361812 )
13371813 local txt_p1TeamEnemyTitle = main.f_createTextImg(
13381814 motif.font_data[motif.select_info.p1_teammenu_enemytitle_font[1]],
@@ -1345,56 +1821,21 @@ local txt_p1TeamEnemyTitle = main.f_createTextImg(
13451821 motif.select_info.p1_teammenu_enemytitle_font_scale[2],
13461822 motif.select_info.p1_teammenu_enemytitle_font[4],
13471823 motif.select_info.p1_teammenu_enemytitle_font[5],
1348- motif.select_info.p1_teammenu_enemytitle_font[6]
1824+ motif.select_info.p1_teammenu_enemytitle_font[6],
1825+ motif.select_info.p1_teammenu_enemytitle_font[7],
1826+ motif.select_info.p1_teammenu_enemytitle_font[8]
13491827 )
13501828
1351--- Legacy TAG check and mode enabing
1352-function main.GetTeamMenu()
1353- local temptag789TeamMenu = {}
1354- local tempPos = 1
1355-
1356- -- Single mode check
1357- if config.SingleTeamMode == true then
1358- temptag789TeamMenu[1] = {data = textImgNew(), itemname = 'single', displayname = motif.select_info.teammenu_itemname_single}
1359- tempPos = tempPos + 1
1360- end
1361-
1362- if config.SimulMode then
1363- -- Simul mode check
1364- if config.NumSimul > 1 then
1365- temptag789TeamMenu[tempPos] = {data = textImgNew(), itemname = 'simul', displayname = motif.select_info.teammenu_itemname_simul}
1366- tempPos = tempPos + 1
1367- end
1368- -- Tag mode check
1369- if config.NumTag > 1 then
1370- temptag789TeamMenu[tempPos] = {data = textImgNew(), itemname = 'tag', displayname = motif.select_info.teammenu_itemname_tag}
1371- tempPos = tempPos + 1
1372- end
1373- else
1374- -- Legacy Tag mode enable
1375- temptag789TeamMenu[tempPos] = {data = textImgNew(), itemname = 'simul', displayname = motif.select_info.teammenu_itemname_tag}
1376- tempPos = tempPos + 1
1377- end
1378-
1379- -- Turns mode check
1380- if config.NumTurns > 1 then
1381- temptag789TeamMenu[tempPos] = {data = textImgNew(), itemname = 'turns', displayname = motif.select_info.teammenu_itemname_turns}
1382- end
1383-
1384- return temptag789TeamMenu
1385-end
1386-
1387--- Set tag mode
1388-local t_p1TeamMenu = main.GetTeamMenu()
1389-t_p1TeamMenu = main.f_cleanTable(t_p1TeamMenu)
1829+select.t_p1TeamMenu = select.f_getTeamMenu()
1830+select.t_p1TeamMenu = main.f_cleanTable(select.t_p1TeamMenu, main.t_sort.select_info)
13901831
13911832 local p1TeamActiveCount = 0
13921833 local p1TeamActiveFont = 'p1_teammenu_item_active_font'
13931834
13941835 function select.f_p1TeamMenu()
13951836 if main.p1TeamMenu ~= nil then --Predefined team
1396- p1NumChars = main.p1TeamMenu.chars
13971837 p1TeamMode = main.p1TeamMenu.mode
1838+ p1NumChars = main.p1TeamMenu.chars
13981839 setTeamMode(1, p1TeamMode, p1NumChars)
13991840 p1TeamEnd = true
14001841 else
@@ -1405,17 +1846,17 @@ function select.f_p1TeamMenu()
14051846 p1TeamMenu = p1TeamMenu - 1
14061847 elseif motif.select_info.teammenu_move_wrapping == 1 then
14071848 sndPlay(motif.files.snd_data, motif.select_info.p1_teammenu_move_snd[1], motif.select_info.p1_teammenu_move_snd[2])
1408- p1TeamMenu = #t_p1TeamMenu
1849+ p1TeamMenu = #select.t_p1TeamMenu
14091850 end
14101851 elseif commandGetState(main.p1Cmd, 'd') then
1411- if p1TeamMenu + 1 <= #t_p1TeamMenu then
1852+ if p1TeamMenu + 1 <= #select.t_p1TeamMenu then
14121853 sndPlay(motif.files.snd_data, motif.select_info.p1_teammenu_move_snd[1], motif.select_info.p1_teammenu_move_snd[2])
14131854 p1TeamMenu = p1TeamMenu + 1
14141855 elseif motif.select_info.teammenu_move_wrapping == 1 then
14151856 sndPlay(motif.files.snd_data, motif.select_info.p1_teammenu_move_snd[1], motif.select_info.p1_teammenu_move_snd[2])
14161857 p1TeamMenu = 1
14171858 end
1418- elseif t_p1TeamMenu[p1TeamMenu].itemname == 'simul' then
1859+ elseif select.t_p1TeamMenu[p1TeamMenu].itemname == 'simul' then
14191860 if commandGetState(main.p1Cmd, 'l') then
14201861 if p1NumSimul - 1 >= 2 then
14211862 sndPlay(motif.files.snd_data, motif.select_info.p1_teammenu_value_snd[1], motif.select_info.p1_teammenu_value_snd[2])
@@ -1427,9 +1868,9 @@ function select.f_p1TeamMenu()
14271868 p1NumSimul = p1NumSimul + 1
14281869 end
14291870 end
1430- elseif t_p1TeamMenu[p1TeamMenu].itemname == 'turns' then
1871+ elseif select.t_p1TeamMenu[p1TeamMenu].itemname == 'turns' then
14311872 if commandGetState(main.p1Cmd, 'l') then
1432- if p1NumTurns - 1 >= 2 then
1873+ if p1NumTurns - 1 >= 1 then
14331874 sndPlay(motif.files.snd_data, motif.select_info.p1_teammenu_value_snd[1], motif.select_info.p1_teammenu_value_snd[2])
14341875 p1NumTurns = p1NumTurns - 1
14351876 end
@@ -1439,7 +1880,7 @@ function select.f_p1TeamMenu()
14391880 p1NumTurns = p1NumTurns + 1
14401881 end
14411882 end
1442- elseif t_p1TeamMenu[p1TeamMenu].itemname == 'tag' then
1883+ elseif select.t_p1TeamMenu[p1TeamMenu].itemname == 'tag' then
14431884 if commandGetState(main.p1Cmd, 'l') then
14441885 if p1NumTag - 1 >= 2 then
14451886 sndPlay(motif.files.snd_data, motif.select_info.p1_teammenu_value_snd[1], motif.select_info.p1_teammenu_value_snd[2])
@@ -1465,7 +1906,7 @@ function select.f_p1TeamMenu()
14651906 animUpdate(motif.select_info.p1_teammenu_selftitle_data)
14661907 animDraw(motif.select_info.p1_teammenu_selftitle_data)
14671908 textImgDraw(txt_p1TeamSelfTitle)
1468- for i = 1, #t_p1TeamMenu do
1909+ for i = 1, #select.t_p1TeamMenu do
14691910 if i == p1TeamMenu then
14701911 if p1TeamActiveCount < 2 then --delay change
14711912 p1TeamActiveCount = p1TeamActiveCount + 1
@@ -1478,38 +1919,42 @@ function select.f_p1TeamMenu()
14781919 end
14791920 --Draw team active font
14801921 textImgDraw(main.f_updateTextImg(
1481- t_p1TeamMenu[i].data,
1922+ select.t_p1TeamMenu[i].data,
14821923 motif.font_data[motif.select_info[p1TeamActiveFont][1]],
14831924 motif.select_info[p1TeamActiveFont][2],
1484- motif.select_info.p1_teammenu_item_font[3], --mugen ignores active font facing
1485- t_p1TeamMenu[i].displayname,
1925+ motif.select_info[p1TeamActiveFont][3], --p1_teammenu_item_font (winmugen ignores active font facing? Fixed in mugen 1.0)
1926+ select.t_p1TeamMenu[i].displayname,
14861927 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],
14871928 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],
14881929 motif.select_info[p1TeamActiveFont .. '_scale'][1],
14891930 motif.select_info[p1TeamActiveFont .. '_scale'][2],
14901931 motif.select_info[p1TeamActiveFont][4],
14911932 motif.select_info[p1TeamActiveFont][5],
1492- motif.select_info[p1TeamActiveFont][6]
1933+ motif.select_info[p1TeamActiveFont][6],
1934+ motif.select_info[p1TeamActiveFont][7],
1935+ motif.select_info[p1TeamActiveFont][8]
14931936 ))
14941937 else
14951938 --Draw team not active font
14961939 textImgDraw(main.f_updateTextImg(
1497- t_p1TeamMenu[i].data,
1940+ select.t_p1TeamMenu[i].data,
14981941 motif.font_data[motif.select_info.p1_teammenu_item_font[1]],
14991942 motif.select_info.p1_teammenu_item_font[2],
15001943 motif.select_info.p1_teammenu_item_font[3],
1501- t_p1TeamMenu[i].displayname,
1944+ select.t_p1TeamMenu[i].displayname,
15021945 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],
15031946 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],
15041947 motif.select_info.p1_teammenu_item_font_scale[1],
15051948 motif.select_info.p1_teammenu_item_font_scale[2],
15061949 motif.select_info.p1_teammenu_item_font[4],
15071950 motif.select_info.p1_teammenu_item_font[5],
1508- motif.select_info.p1_teammenu_item_font[6]
1951+ motif.select_info.p1_teammenu_item_font[6],
1952+ motif.select_info.p1_teammenu_item_font[7],
1953+ motif.select_info.p1_teammenu_item_font[8]
15091954 ))
15101955 end
15111956 --Draw team icons
1512- if t_p1TeamMenu[i].itemname == 'simul' then
1957+ if select.t_p1TeamMenu[i].itemname == 'simul' then
15131958 for j = 1, config.NumSimul do
15141959 if j <= p1NumSimul then
15151960 main.f_animPosDraw(
@@ -1525,7 +1970,7 @@ function select.f_p1TeamMenu()
15251970 )
15261971 end
15271972 end
1528- elseif t_p1TeamMenu[i].itemname == 'turns' then
1973+ elseif select.t_p1TeamMenu[i].itemname == 'turns' then
15291974 for j = 1, config.NumTurns do
15301975 if j <= p1NumTurns then
15311976 main.f_animPosDraw(
@@ -1541,7 +1986,7 @@ function select.f_p1TeamMenu()
15411986 )
15421987 end
15431988 end
1544- elseif t_p1TeamMenu[i].itemname == 'tag' then
1989+ elseif select.t_p1TeamMenu[i].itemname == 'tag' then
15451990 for j = 1, config.NumTag do
15461991 if j <= p1NumTag then
15471992 main.f_animPosDraw(
@@ -1562,16 +2007,16 @@ function select.f_p1TeamMenu()
15622007 --Confirmed team selection
15632008 if main.f_btnPalNo(main.p1Cmd) > 0 then
15642009 sndPlay(motif.files.snd_data, motif.select_info.p1_teammenu_done_snd[1], motif.select_info.p1_teammenu_done_snd[2])
1565- if t_p1TeamMenu[p1TeamMenu].itemname == 'single' then
2010+ if select.t_p1TeamMenu[p1TeamMenu].itemname == 'single' then
15662011 p1TeamMode = 0
15672012 p1NumChars = 1
1568- elseif t_p1TeamMenu[p1TeamMenu].itemname == 'simul' then
2013+ elseif select.t_p1TeamMenu[p1TeamMenu].itemname == 'simul' then
15692014 p1TeamMode = 1
15702015 p1NumChars = p1NumSimul
1571- elseif t_p1TeamMenu[p1TeamMenu].itemname == 'turns' then
2016+ elseif select.t_p1TeamMenu[p1TeamMenu].itemname == 'turns' then
15722017 p1TeamMode = 2
15732018 p1NumChars = p1NumTurns
1574- elseif t_p1TeamMenu[p1TeamMenu].itemname == 'tag' then
2019+ elseif select.t_p1TeamMenu[p1TeamMenu].itemname == 'tag' then
15752020 p1TeamMode = 3
15762021 p1NumChars = p1NumTag
15772022 end
@@ -1596,7 +2041,9 @@ local txt_p2TeamSelfTitle = main.f_createTextImg(
15962041 motif.select_info.p2_teammenu_selftitle_font_scale[2],
15972042 motif.select_info.p2_teammenu_selftitle_font[4],
15982043 motif.select_info.p2_teammenu_selftitle_font[5],
1599- motif.select_info.p2_teammenu_selftitle_font[6]
2044+ motif.select_info.p2_teammenu_selftitle_font[6],
2045+ motif.select_info.p2_teammenu_selftitle_font[7],
2046+ motif.select_info.p2_teammenu_selftitle_font[8]
16002047 )
16012048 local txt_p2TeamEnemyTitle = main.f_createTextImg(
16022049 motif.font_data[motif.select_info.p2_teammenu_enemytitle_font[1]],
@@ -1609,20 +2056,21 @@ local txt_p2TeamEnemyTitle = main.f_createTextImg(
16092056 motif.select_info.p2_teammenu_enemytitle_font_scale[2],
16102057 motif.select_info.p2_teammenu_enemytitle_font[4],
16112058 motif.select_info.p2_teammenu_enemytitle_font[5],
1612- motif.select_info.p2_teammenu_enemytitle_font[6]
2059+ motif.select_info.p2_teammenu_enemytitle_font[6],
2060+ motif.select_info.p2_teammenu_enemytitle_font[7],
2061+ motif.select_info.p2_teammenu_enemytitle_font[8]
16132062 )
16142063
1615--- Set tag mode
1616-local t_p2TeamMenu = main.GetTeamMenu()
1617-t_p2TeamMenu = main.f_cleanTable(t_p2TeamMenu)
2064+select.t_p2TeamMenu = select.f_getTeamMenu()
2065+select.t_p2TeamMenu = main.f_cleanTable(select.t_p2TeamMenu, main.t_sort.select_info)
16182066
16192067 local p2TeamActiveCount = 0
16202068 local p2TeamActiveFont = 'p2_teammenu_item_active_font'
16212069
16222070 function select.f_p2TeamMenu()
16232071 if main.p2TeamMenu ~= nil then --Predefined team
1624- p2NumChars = main.p2TeamMenu.chars
16252072 p2TeamMode = main.p2TeamMenu.mode
2073+ p2NumChars = main.p2TeamMenu.chars
16262074 setTeamMode(2, p2TeamMode, p2NumChars)
16272075 p2TeamEnd = true
16282076 else
@@ -1638,17 +2086,17 @@ function select.f_p2TeamMenu()
16382086 p2TeamMenu = p2TeamMenu - 1
16392087 elseif motif.select_info.teammenu_move_wrapping == 1 then
16402088 sndPlay(motif.files.snd_data, motif.select_info.p2_teammenu_move_snd[1], motif.select_info.p2_teammenu_move_snd[2])
1641- p2TeamMenu = #t_p2TeamMenu
2089+ p2TeamMenu = #select.t_p2TeamMenu
16422090 end
16432091 elseif commandGetState(cmd, 'd') then
1644- if p2TeamMenu + 1 <= #t_p2TeamMenu then
2092+ if p2TeamMenu + 1 <= #select.t_p2TeamMenu then
16452093 sndPlay(motif.files.snd_data, motif.select_info.p2_teammenu_move_snd[1], motif.select_info.p2_teammenu_move_snd[2])
16462094 p2TeamMenu = p2TeamMenu + 1
16472095 elseif motif.select_info.teammenu_move_wrapping == 1 then
16482096 sndPlay(motif.files.snd_data, motif.select_info.p2_teammenu_move_snd[1], motif.select_info.p2_teammenu_move_snd[2])
16492097 p2TeamMenu = 1
16502098 end
1651- elseif t_p2TeamMenu[p2TeamMenu].itemname == 'simul' then
2099+ elseif select.t_p2TeamMenu[p2TeamMenu].itemname == 'simul' then
16522100 if commandGetState(cmd, 'r') then
16532101 if p2NumSimul - 1 >= 2 then
16542102 sndPlay(motif.files.snd_data, motif.select_info.p2_teammenu_value_snd[1], motif.select_info.p2_teammenu_value_snd[2])
@@ -1660,9 +2108,9 @@ function select.f_p2TeamMenu()
16602108 p2NumSimul = p2NumSimul + 1
16612109 end
16622110 end
1663- elseif t_p2TeamMenu[p2TeamMenu].itemname == 'turns' then
2111+ elseif select.t_p2TeamMenu[p2TeamMenu].itemname == 'turns' then
16642112 if commandGetState(cmd, 'r') then
1665- if p2NumTurns - 1 >= 2 then
2113+ if p2NumTurns - 1 >= 1 then
16662114 sndPlay(motif.files.snd_data, motif.select_info.p2_teammenu_value_snd[1], motif.select_info.p2_teammenu_value_snd[2])
16672115 p2NumTurns = p2NumTurns - 1
16682116 end
@@ -1672,7 +2120,7 @@ function select.f_p2TeamMenu()
16722120 p2NumTurns = p2NumTurns + 1
16732121 end
16742122 end
1675- elseif t_p2TeamMenu[p2TeamMenu].itemname == 'tag' then
2123+ elseif select.t_p2TeamMenu[p2TeamMenu].itemname == 'tag' then
16762124 if commandGetState(cmd, 'r') then
16772125 if p2NumTag - 1 >= 2 then
16782126 sndPlay(motif.files.snd_data, motif.select_info.p2_teammenu_value_snd[1], motif.select_info.p2_teammenu_value_snd[2])
@@ -1704,7 +2152,7 @@ function select.f_p2TeamMenu()
17042152 animDraw(motif.select_info.p2_teammenu_selftitle_data)
17052153 textImgDraw(txt_p2TeamSelfTitle)
17062154 end
1707- for i = 1, #t_p2TeamMenu do
2155+ for i = 1, #select.t_p2TeamMenu do
17082156 if i == p2TeamMenu then
17092157 if p2TeamActiveCount < 2 then --delay change
17102158 p2TeamActiveCount = p2TeamActiveCount + 1
@@ -1717,38 +2165,42 @@ function select.f_p2TeamMenu()
17172165 end
17182166 --Draw team active font
17192167 textImgDraw(main.f_updateTextImg(
1720- t_p2TeamMenu[i].data,
2168+ select.t_p2TeamMenu[i].data,
17212169 motif.font_data[motif.select_info[p2TeamActiveFont][1]],
17222170 motif.select_info[p2TeamActiveFont][2],
1723- motif.select_info.p2_teammenu_item_font[3], --mugen ignores active font facing
1724- t_p2TeamMenu[i].displayname,
2171+ motif.select_info[p2TeamActiveFont][3], --p2_teammenu_item_font (winmugen ignores active font facing? Fixed in mugen 1.0)
2172+ select.t_p2TeamMenu[i].displayname,
17252173 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],
17262174 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],
17272175 motif.select_info[p2TeamActiveFont .. '_scale'][1],
17282176 motif.select_info[p2TeamActiveFont .. '_scale'][2],
17292177 motif.select_info[p2TeamActiveFont][4],
17302178 motif.select_info[p2TeamActiveFont][5],
1731- motif.select_info[p2TeamActiveFont][6]
2179+ motif.select_info[p2TeamActiveFont][6],
2180+ motif.select_info[p2TeamActiveFont][7],
2181+ motif.select_info[p2TeamActiveFont][8]
17322182 ))
17332183 else
17342184 --Draw team not active font
17352185 textImgDraw(main.f_updateTextImg(
1736- t_p2TeamMenu[i].data,
2186+ select.t_p2TeamMenu[i].data,
17372187 motif.font_data[motif.select_info.p2_teammenu_item_font[1]],
17382188 motif.select_info.p2_teammenu_item_font[2],
17392189 motif.select_info.p2_teammenu_item_font[3],
1740- t_p2TeamMenu[i].displayname,
2190+ select.t_p2TeamMenu[i].displayname,
17412191 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],
17422192 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],
17432193 motif.select_info.p2_teammenu_item_font_scale[1],
17442194 motif.select_info.p2_teammenu_item_font_scale[2],
17452195 motif.select_info.p2_teammenu_item_font[4],
17462196 motif.select_info.p2_teammenu_item_font[5],
1747- motif.select_info.p2_teammenu_item_font[6]
2197+ motif.select_info.p2_teammenu_item_font[6],
2198+ motif.select_info.p2_teammenu_item_font[7],
2199+ motif.select_info.p2_teammenu_item_font[8]
17482200 ))
17492201 end
17502202 --Draw team icons
1751- if t_p2TeamMenu[i].itemname == 'simul' then
2203+ if select.t_p2TeamMenu[i].itemname == 'simul' then
17522204 for j = 1, config.NumSimul do
17532205 if j <= p2NumSimul then
17542206 main.f_animPosDraw(
@@ -1764,7 +2216,7 @@ function select.f_p2TeamMenu()
17642216 )
17652217 end
17662218 end
1767- elseif t_p2TeamMenu[i].itemname == 'turns' then
2219+ elseif select.t_p2TeamMenu[i].itemname == 'turns' then
17682220 for j = 1, config.NumTurns do
17692221 if j <= p2NumTurns then
17702222 main.f_animPosDraw(
@@ -1780,7 +2232,7 @@ function select.f_p2TeamMenu()
17802232 )
17812233 end
17822234 end
1783- elseif t_p2TeamMenu[i].itemname == 'tag' then
2235+ elseif select.t_p2TeamMenu[i].itemname == 'tag' then
17842236 for j = 1, config.NumTag do
17852237 if j <= p2NumTag then
17862238 main.f_animPosDraw(
@@ -1801,16 +2253,16 @@ function select.f_p2TeamMenu()
18012253 --Confirmed team selection
18022254 if main.f_btnPalNo(cmd) > 0 then
18032255 sndPlay(motif.files.snd_data, motif.select_info.p2_teammenu_done_snd[1], motif.select_info.p2_teammenu_done_snd[2])
1804- if t_p2TeamMenu[p2TeamMenu].itemname == 'single' then
2256+ if select.t_p2TeamMenu[p2TeamMenu].itemname == 'single' then
18052257 p2TeamMode = 0
18062258 p2NumChars = 1
1807- elseif t_p2TeamMenu[p2TeamMenu].itemname == 'simul' then
2259+ elseif select.t_p2TeamMenu[p2TeamMenu].itemname == 'simul' then
18082260 p2TeamMode = 1
18092261 p2NumChars = p2NumSimul
1810- elseif t_p2TeamMenu[p2TeamMenu].itemname == 'turns' then
2262+ elseif select.t_p2TeamMenu[p2TeamMenu].itemname == 'turns' then
18112263 p2TeamMode = 2
18122264 p2NumChars = p2NumTurns
1813- elseif t_p2TeamMenu[p2TeamMenu].itemname == 'tag' then
2265+ elseif select.t_p2TeamMenu[p2TeamMenu].itemname == 'tag' then
18142266 p2TeamMode = 3
18152267 p2NumChars = p2NumTag
18162268 end
@@ -1832,7 +2284,7 @@ function select.f_p1SelectMenu()
18322284 if t[main.p1Char[i]] == nil then
18332285 t[main.p1Char[i]] = ''
18342286 end
1835- t_p1Selected[i] = {cel = main.p1Char[i], pal = select.f_randomPal(main.p1Char[i])}
2287+ t_p1Selected[i] = {cel = main.p1Char[i], pal = select.f_selectPal(main.p1Char[i])}
18362288 end
18372289 p1SelEnd = true
18382290 return
@@ -1843,17 +2295,8 @@ function select.f_p1SelectMenu()
18432295 p1SelX, p1SelY, p1FaceOffset, p1RowOffset = select.f_cellMovement(p1SelX, p1SelY, main.p1Cmd, p1FaceOffset, p1RowOffset, motif.select_info.p1_cursor_move_snd)
18442296 p1Cell = p1SelX + motif.select_info.columns * p1SelY
18452297 --draw active cursor
1846- -- cell.spacing type check
1847- local cursorX = 0
1848- local cursorY = 0
1849- if type(motif.select_info.cell_spacing) == "table" then
1850- cursorX = p1FaceX + p1SelX * (motif.select_info.cell_size[1] + motif.select_info.cell_spacing[1])
1851- cursorY = p1FaceY + (p1SelY - p1RowOffset) * (motif.select_info.cell_size[2] + motif.select_info.cell_spacing[2])
1852- else
1853- cursorX = p1FaceX + p1SelX * (motif.select_info.cell_size[1] + motif.select_info.cell_spacing)
1854- cursorY = p1FaceY + (p1SelY - p1RowOffset) * (motif.select_info.cell_size[2] + motif.select_info.cell_spacing)
1855- end
1856-
2298+ local cursorX = p1FaceX + p1SelX * (motif.select_info.cell_size[1] + motif.select_info.cell_spacing[1])
2299+ local cursorY = p1FaceY + (p1SelY - p1RowOffset) * (motif.select_info.cell_size[2] + motif.select_info.cell_spacing[2])
18572300 if resetgrid == true then
18582301 select.f_resetGrid()
18592302 end
@@ -1867,7 +2310,7 @@ function select.f_p1SelectMenu()
18672310 if main.t_selChars[selected + 1].char == 'randomselect' or main.t_selChars[selected + 1].hidden == 3 then
18682311 selected = main.t_randomChars[math.random(1, #main.t_randomChars)]
18692312 end
1870- t_p1Selected[#t_p1Selected + 1] = {cel = selected, pal = main.f_btnPalNo(main.p1Cmd), cursor = {cursorX, cursorY, p1RowOffset}}
2313+ table.insert(t_p1Selected, {cel = selected, pal = main.f_btnPalNo(main.p1Cmd), cursor = {cursorX, cursorY, p1RowOffset}})
18712314 if #t_p1Selected == p1NumChars then
18722315 if main.p2In == 1 and matchNo == 0 then
18732316 p2TeamEnd = false
@@ -1892,7 +2335,7 @@ function select.f_p2SelectMenu()
18922335 if t[main.p2Char[i]] == nil then
18932336 t[main.p2Char[i]] = ''
18942337 end
1895- t_p2Selected[i] = {cel = main.p2Char[i], pal = select.f_randomPal(main.p2Char[i])}
2338+ t_p2Selected[i] = {cel = main.p2Char[i], pal = select.f_selectPal(main.p2Char[i])}
18962339 end
18972340 p2SelEnd = true
18982341 return
@@ -1907,16 +2350,8 @@ function select.f_p2SelectMenu()
19072350 p2SelX, p2SelY, p2FaceOffset, p2RowOffset = select.f_cellMovement(p2SelX, p2SelY, main.p2Cmd, p2FaceOffset, p2RowOffset, motif.select_info.p2_cursor_move_snd)
19082351 p2Cell = p2SelX + motif.select_info.columns * p2SelY
19092352 --draw active cursor
1910- -- cell.spacing type check
1911- local cursorX = 0
1912- local cursorY = 0
1913- if type(motif.select_info.cell_spacing) == "table" then
1914- cursorX = p2FaceX + p2SelX * (motif.select_info.cell_size[1] + motif.select_info.cell_spacing[1])
1915- cursorY = p2FaceY + (p2SelY - p2RowOffset) * (motif.select_info.cell_size[2] + motif.select_info.cell_spacing[2])
1916- else
1917- cursorX = p2FaceX + p2SelX * (motif.select_info.cell_size[1] + motif.select_info.cell_spacing)
1918- cursorY = p2FaceY + (p2SelY - p2RowOffset) * (motif.select_info.cell_size[2] + motif.select_info.cell_spacing)
1919- end
2353+ local cursorX = p2FaceX + p2SelX * (motif.select_info.cell_size[1] + motif.select_info.cell_spacing[1])
2354+ local cursorY = p2FaceY + (p2SelY - p2RowOffset) * (motif.select_info.cell_size[2] + motif.select_info.cell_spacing[2])
19202355 if resetgrid == true then
19212356 select.f_resetGrid()
19222357 end
@@ -1928,7 +2363,7 @@ function select.f_p2SelectMenu()
19282363 if main.t_selChars[selected + 1].char == 'randomselect' or main.t_selChars[selected + 1].hidden == 3 then
19292364 selected = main.t_randomChars[math.random(1, #main.t_randomChars)]
19302365 end
1931- t_p2Selected[#t_p2Selected + 1] = {cel = selected, pal = main.f_btnPalNo(main.p2Cmd), cursor = {cursorX, cursorY, p2RowOffset}}
2366+ table.insert(t_p2Selected, {cel = selected, pal = main.f_btnPalNo(main.p2Cmd), cursor = {cursorX, cursorY, p2RowOffset}})
19322367 if #t_p2Selected == p2NumChars then
19332368 p2SelEnd = true
19342369 end
@@ -1949,34 +2384,42 @@ function select.f_stageMenu()
19492384 if commandGetState(main.p1Cmd, 'l') then
19502385 sndPlay(motif.files.snd_data, motif.select_info.stage_move_snd[1], motif.select_info.stage_move_snd[2])
19512386 stageList = stageList - 1
1952- if stageList < 0 then stageList = #main.t_includeStage end
2387+ if stageList < 0 then stageList = #main.t_includeStage[2] end
19532388 elseif commandGetState(main.p1Cmd, 'r') then
19542389 sndPlay(motif.files.snd_data, motif.select_info.stage_move_snd[1], motif.select_info.stage_move_snd[2])
19552390 stageList = stageList + 1
1956- if stageList > #main.t_includeStage then stageList = 0 end
2391+ if stageList > #main.t_includeStage[2] then stageList = 0 end
19572392 elseif commandGetState(main.p1Cmd, 'u') then
19582393 sndPlay(motif.files.snd_data, motif.select_info.stage_move_snd[1], motif.select_info.stage_move_snd[2])
19592394 for i = 1, 10 do
19602395 stageList = stageList - 1
1961- if stageList < 0 then stageList = #main.t_includeStage end
2396+ if stageList < 0 then stageList = #main.t_includeStage[2] end
19622397 end
19632398 elseif commandGetState(main.p1Cmd, 'd') then
19642399 sndPlay(motif.files.snd_data, motif.select_info.stage_move_snd[1], motif.select_info.stage_move_snd[2])
19652400 for i = 1, 10 do
19662401 stageList = stageList + 1
1967- if stageList > #main.t_includeStage then stageList = 0 end
1968- end
2402+ if stageList > #main.t_includeStage[2] then stageList = 0 end
2403+ end
2404+ end
2405+ if stageList == 0 then --draw random stage portrait loaded from screenpack SFF
2406+ animUpdate(motif.select_info.stage_portrait_random_data)
2407+ animDraw(motif.select_info.stage_portrait_random_data)
2408+ else --draw stage portrait loaded from stage SFF
2409+ drawStagePortrait(
2410+ stageList,
2411+ motif.select_info.stage_pos[1] + motif.select_info.stage_portrait_offset[1],
2412+ motif.select_info.stage_pos[2] + motif.select_info.stage_portrait_offset[2],
2413+ --[[motif.select_info.stage_portrait_facing * ]]motif.select_info.stage_portrait_scale[1],
2414+ motif.select_info.stage_portrait_scale[2]
2415+ )
19692416 end
19702417 if main.f_btnPalNo(main.p1Cmd) > 0 then
19712418 sndPlay(motif.files.snd_data, motif.select_info.stage_done_snd[1], motif.select_info.stage_done_snd[2])
19722419 if stageList == 0 then
1973- stageNo = main.t_includeStage[math.random(1, #main.t_includeStage)]
1974- setStage(stageNo)
1975- selectStage(stageNo)
2420+ stageNo = main.t_includeStage[2][math.random(1, #main.t_includeStage[2])]
19762421 else
1977- stageNo = main.t_includeStage[stageList]
1978- setStage(stageNo)
1979- selectStage(stageNo)
2422+ stageNo = main.t_includeStage[2][stageList]
19802423 end
19812424 stageActiveFont = 'stage_done_font'
19822425 stageEnd = true
@@ -1994,9 +2437,9 @@ function select.f_stageMenu()
19942437 end
19952438 local t_txt = {}
19962439 if stageList == 0 then
1997- t_txt = main.f_extractText(motif.select_info.stage_text, '', 'Random')
2440+ t_txt[1] = motif.select_info.stage_random_text
19982441 else
1999- t_txt = main.f_extractText(motif.select_info.stage_text, stageList, getStageName(main.t_includeStage[stageList]):match('^["%s]*(.-)["%s]*$'))
2442+ t_txt = main.f_extractText(motif.select_info.stage_text, stageList, getStageName(main.t_includeStage[2][stageList]))
20002443 end
20012444 for i = 1, #t_txt do
20022445 textImgDraw(main.f_updateTextImg(
@@ -2011,7 +2454,9 @@ function select.f_stageMenu()
20112454 motif.select_info[stageActiveFont .. '_scale'][2],
20122455 motif.select_info[stageActiveFont][4],
20132456 motif.select_info[stageActiveFont][5],
2014- motif.select_info[stageActiveFont][6]
2457+ motif.select_info[stageActiveFont][6],
2458+ motif.select_info[stageActiveFont][7],
2459+ motif.select_info[stageActiveFont][8]
20152460 ))
20162461 end
20172462 end
@@ -2020,74 +2465,75 @@ end
20202465 --; VERSUS SCREEN
20212466 --;===========================================================
20222467 local txt_p1NameVS = main.f_createTextImg(
2023- motif.font_data[motif.vs_screen.p1_name_font[1]],
2024- motif.vs_screen.p1_name_font[2],
2025- motif.vs_screen.p1_name_font[3],
2026- '',
2027- 0,
2028- 0,
2029- motif.vs_screen.p1_name_font_scale[1],
2468+ motif.font_data[motif.vs_screen.p1_name_font[1]],
2469+ motif.vs_screen.p1_name_font[2],
2470+ motif.vs_screen.p1_name_font[3],
2471+ '',
2472+ 0,
2473+ 0,
2474+ motif.vs_screen.p1_name_font_scale[1],
20302475 motif.vs_screen.p1_name_font_scale[2],
2031- motif.vs_screen.p1_name_font[4],
2032- motif.vs_screen.p1_name_font[5],
2033- motif.vs_screen.p1_name_font[6]
2476+ motif.vs_screen.p1_name_font[4],
2477+ motif.vs_screen.p1_name_font[5],
2478+ motif.vs_screen.p1_name_font[6],
2479+ motif.vs_screen.p1_name_font[7],
2480+ motif.vs_screen.p1_name_font[8]
2481+
20342482 )
20352483 local txt_p2NameVS = main.f_createTextImg(
2036- motif.font_data[motif.vs_screen.p2_name_font[1]],
2037- motif.vs_screen.p2_name_font[2],
2038- motif.vs_screen.p2_name_font[3],
2039- '',
2040- 0,
2041- 0,
2042- motif.vs_screen.p2_name_font_scale[1],
2484+ motif.font_data[motif.vs_screen.p2_name_font[1]],
2485+ motif.vs_screen.p2_name_font[2],
2486+ motif.vs_screen.p2_name_font[3],
2487+ '',
2488+ 0,
2489+ 0,
2490+ motif.vs_screen.p2_name_font_scale[1],
20432491 motif.vs_screen.p2_name_font_scale[2],
2044- motif.vs_screen.p2_name_font[4],
2045- motif.vs_screen.p2_name_font[5],
2046- motif.vs_screen.p2_name_font[6]
2492+ motif.vs_screen.p2_name_font[4],
2493+ motif.vs_screen.p2_name_font[5],
2494+ motif.vs_screen.p2_name_font[6],
2495+ motif.vs_screen.p2_name_font[7],
2496+ motif.vs_screen.p2_name_font[8]
20472497 )
20482498 local txt_matchNo = main.f_createTextImg(
2049- motif.font_data[motif.vs_screen.match_font[1]],
2050- motif.vs_screen.match_font[2],
2051- motif.vs_screen.match_font[3],
2052- '',
2053- motif.vs_screen.match_offset[1],
2054- motif.vs_screen.match_offset[2],
2055- motif.vs_screen.match_font_scale[1],
2499+ motif.font_data[motif.vs_screen.match_font[1]],
2500+ motif.vs_screen.match_font[2],
2501+ motif.vs_screen.match_font[3],
2502+ '',
2503+ motif.vs_screen.match_offset[1],
2504+ motif.vs_screen.match_offset[2],
2505+ motif.vs_screen.match_font_scale[1],
20562506 motif.vs_screen.match_font_scale[2],
2057- motif.vs_screen.match_font[4],
2058- motif.vs_screen.match_font[5],
2059- motif.vs_screen.match_font[6]
2507+ motif.vs_screen.match_font[4],
2508+ motif.vs_screen.match_font[5],
2509+ motif.vs_screen.match_font[6],
2510+ motif.vs_screen.match_font[7],
2511+ motif.vs_screen.match_font[8]
20602512 )
20612513
2514+function select.f_selectChar(player, t)
2515+ for i = 1, #t do
2516+ selectChar(player, t[i].cel, t[i].pal)
2517+ end
2518+end
2519+
20622520 function select.f_selectVersus()
2063- local text = main.f_extractText(motif.vs_screen.match_text, matchNo)
2064- textImgSetText(txt_matchNo, text[1])
2065- local delay = 0
2066- local minTime = 15 --let's reserve few extra ticks in case selectChar function needs time to load data, also prevents sound from being interrupted
2067- main.f_resetBG(motif.vs_screen, motif.versusbgdef, motif.music.vs_bgm, motif.music.vs_bgm_loop, motif.music.vs_bgm_volume, motif.music.vs_bgm_loopstart, motif.music.vs_bgm_loopend)
20682521 if not main.versusScreen then
2069- delay = minTime
20702522 select.f_selectChar(1, t_p1Selected)
20712523 select.f_selectChar(2, t_p2Selected)
2072- while true do
2073- if delay > 0 then
2074- delay = delay - 1
2075- else
2076- main.f_cmdInput()
2077- break
2078- end
2079- main.f_cmdInput()
2080- refresh()
2081- end
2524+ return
20822525 else
2526+ local text = main.f_extractText(motif.vs_screen.match_text, matchNo)
2527+ textImgSetText(txt_matchNo, text[1])
2528+ main.f_menuReset(motif.versusbgdef.bg, motif.music.vs_bgm, motif.music.vs_bgm_loop, motif.music.vs_bgm_volume, motif.music.vs_bgm_loopstart, motif.music.vs_bgm_loopend)
20832529 local p1Confirmed = false
20842530 local p2Confirmed = false
20852531 local p1Row = 1
20862532 local p2Row = 1
20872533 local t_tmp = {}
2088- local orderTime = motif.vs_screen.time
2534+ local orderTime = 0
20892535 if main.p1In == 1 and main.p2In == 2 and (#t_p1Selected > 1 or #t_p2Selected > 1) and not main.coop then
2090- orderTime = orderTime + (math.max(#t_p1Selected, #t_p2Selected) - 1) * motif.vs_screen.time_order
2536+ orderTime = math.max(#t_p1Selected, #t_p2Selected) - 1 * motif.vs_screen.time_order
20912537 if #t_p1Selected == 1 then
20922538 select.f_selectChar(1, t_p1Selected)
20932539 p1Confirmed = true
@@ -2097,45 +2543,43 @@ function select.f_selectVersus()
20972543 p2Confirmed = true
20982544 end
20992545 elseif #t_p1Selected > 1 and not main.coop then
2100- orderTime = orderTime + (#t_p1Selected - 1) * motif.vs_screen.time_order
2546+ orderTime = #t_p1Selected - 1 * motif.vs_screen.time_order
21012547 else
21022548 select.f_selectChar(1, t_p1Selected)
21032549 p1Confirmed = true
21042550 select.f_selectChar(2, t_p2Selected)
21052551 p2Confirmed = true
2106- delay = motif.vs_screen.time
2107- orderTime = -1
21082552 end
21092553 main.f_cmdInput()
2554+ main.fadeStart = getFrameCount()
2555+ local counter = 0 - motif.vs_screen.fadein_time
2556+ fadeType = 'fadein'
21102557 while true do
21112558 if esc() then
21122559 sndPlay(motif.files.snd_data, motif.select_info.cancel_snd[1], motif.select_info.cancel_snd[2])
2113- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
2560+ main.f_menuReset(motif.titlebgdef.bg, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
2561+ resetRemapInput()
21142562 break
21152563 elseif p1Confirmed and p2Confirmed then
2116- if orderTime == -1 and main.f_btnPalNo(main.p1Cmd) > 0 and delay > motif.versusbgdef.timer + minTime then
2117- delay = motif.versusbgdef.timer + minTime
2118- elseif delay < motif.versusbgdef.timer then
2119- break
2564+ if fadeType == 'fadein' and (counter >= motif.vs_screen.time or main.f_btnPalNo(main.p1Cmd) > 0) then
2565+ main.fadeStart = getFrameCount()
2566+ fadeType = 'fadeout'
21202567 end
2121- elseif orderTime <= motif.versusbgdef.timer then
2568+ elseif counter >= motif.vs_screen.time + orderTime then
21222569 if not p1Confirmed then
21232570 select.f_selectChar(1, t_p1Selected)
21242571 p1Confirmed = true
2125- delay = motif.versusbgdef.timer + minTime
21262572 end
21272573 if not p2Confirmed then
21282574 select.f_selectChar(2, t_p2Selected)
21292575 p2Confirmed = true
2130- delay = motif.versusbgdef.timer + minTime
21312576 end
21322577 else
2133- local sndRef = ''
21342578 --if Player1 has not confirmed the order yet
21352579 if not p1Confirmed then
21362580 if main.f_btnPalNo(main.p1Cmd) > 0 then
21372581 if not p1Confirmed then
2138- sndRef = 'p1_cursor_done_snd'
2582+ sndPlay(motif.files.snd_data, motif.vs_screen.p1_cursor_done_snd[1], motif.vs_screen.p1_cursor_done_snd[2])
21392583 select.f_selectChar(1, t_p1Selected)
21402584 p1Confirmed = true
21412585 end
@@ -2147,19 +2591,19 @@ function select.f_selectVersus()
21472591 end
21482592 elseif commandGetState(main.p1Cmd, 'u') then
21492593 if #t_p1Selected > 1 then
2150- sndRef = 'p1_cursor_move_snd'
2594+ sndPlay(motif.files.snd_data, motif.vs_screen.p1_cursor_move_snd[1], motif.vs_screen.p1_cursor_move_snd[2])
21512595 p1Row = p1Row - 1
21522596 if p1Row == 0 then p1Row = #t_p1Selected end
21532597 end
21542598 elseif commandGetState(main.p1Cmd, 'd') then
21552599 if #t_p1Selected > 1 then
2156- sndRef = 'p1_cursor_move_snd'
2600+ sndPlay(motif.files.snd_data, motif.vs_screen.p1_cursor_move_snd[1], motif.vs_screen.p1_cursor_move_snd[2])
21572601 p1Row = p1Row + 1
21582602 if p1Row > #t_p1Selected then p1Row = 1 end
21592603 end
21602604 elseif commandGetState(main.p1Cmd, 'l') then
21612605 if p1Row - 1 > 0 then
2162- sndRef = 'p1_cursor_move_snd'
2606+ sndPlay(motif.files.snd_data, motif.vs_screen.p1_cursor_move_snd[1], motif.vs_screen.p1_cursor_move_snd[2])
21632607 p1Row = p1Row - 1
21642608 t_tmp = {}
21652609 t_tmp[p1Row] = t_p1Selected[p1Row + 1]
@@ -2175,7 +2619,7 @@ function select.f_selectVersus()
21752619 end
21762620 elseif commandGetState(main.p1Cmd, 'r') then
21772621 if p1Row + 1 <= #t_p1Selected then
2178- sndRef = 'p1_cursor_move_snd'
2622+ sndPlay(motif.files.snd_data, motif.vs_screen.p1_cursor_move_snd[1], motif.vs_screen.p1_cursor_move_snd[2])
21792623 p1Row = p1Row + 1
21802624 t_tmp = {}
21812625 t_tmp[p1Row] = t_p1Selected[p1Row - 1]
@@ -2195,25 +2639,25 @@ function select.f_selectVersus()
21952639 if not p2Confirmed and main.p2In ~= 1 then
21962640 if main.f_btnPalNo(main.p2Cmd) > 0 then
21972641 if not p2Confirmed then
2198- sndRef = 'p2_cursor_done_snd'
2642+ sndPlay(motif.files.snd_data, motif.vs_screen.p2_cursor_done_snd[1], motif.vs_screen.p2_cursor_done_snd[2])
21992643 select.f_selectChar(2, t_p2Selected)
22002644 p2Confirmed = true
22012645 end
22022646 elseif commandGetState(main.p2Cmd, 'u') then
22032647 if #t_p2Selected > 1 then
2204- sndRef = 'p2_cursor_move_snd'
2648+ sndPlay(motif.files.snd_data, motif.vs_screen.p2_cursor_move_snd[1], motif.vs_screen.p2_cursor_move_snd[2])
22052649 p2Row = p2Row - 1
22062650 if p2Row == 0 then p2Row = #t_p2Selected end
22072651 end
22082652 elseif commandGetState(main.p2Cmd, 'd') then
22092653 if #t_p2Selected > 1 then
2210- sndRef = 'p2_cursor_move_snd'
2654+ sndPlay(motif.files.snd_data, motif.vs_screen.p2_cursor_move_snd[1], motif.vs_screen.p2_cursor_move_snd[2])
22112655 p2Row = p2Row + 1
22122656 if p2Row > #t_p2Selected then p2Row = 1 end
22132657 end
22142658 elseif commandGetState(main.p2Cmd, 'l') then
22152659 if p2Row + 1 <= #t_p2Selected then
2216- sndRef = 'p2_cursor_move_snd'
2660+ sndPlay(motif.files.snd_data, motif.vs_screen.p2_cursor_move_snd[1], motif.vs_screen.p2_cursor_move_snd[2])
22172661 p2Row = p2Row + 1
22182662 t_tmp = {}
22192663 t_tmp[p2Row] = t_p2Selected[p2Row - 1]
@@ -2229,7 +2673,7 @@ function select.f_selectVersus()
22292673 end
22302674 elseif commandGetState(main.p2Cmd, 'r') then
22312675 if p2Row - 1 > 0 then
2232- sndRef = 'p2_cursor_move_snd'
2676+ sndPlay(motif.files.snd_data, motif.vs_screen.p2_cursor_move_snd[1], motif.vs_screen.p2_cursor_move_snd[2])
22332677 p2Row = p2Row - 1
22342678 t_tmp = {}
22352679 t_tmp[p2Row] = t_p2Selected[p2Row + 1]
@@ -2245,43 +2689,46 @@ function select.f_selectVersus()
22452689 end
22462690 end
22472691 end
2248- --sndPlay separated to not play more than 1 sound at once
2249- if sndRef ~= '' then
2250- sndPlay(motif.files.snd_data, motif.vs_screen[sndRef][1], motif.vs_screen[sndRef][2])
2251- delay = motif.versusbgdef.timer + minTime
2252- end
22532692 end
2693+ counter = counter + 1
22542694 --draw clearcolor
2255- animDraw(motif.versusbgdef.bgclearcolor_data)
2256- --draw clearcolor
2257- animDraw(motif.versusbgdef.bgclearcolor_data)
2695+ clearColor(motif.versusbgdef.bgclearcolor[1], motif.versusbgdef.bgclearcolor[2], motif.versusbgdef.bgclearcolor[3])
22582696 --draw layerno = 0 backgrounds
2259- main.f_drawBG(motif.versusbgdef.bg_data, motif.versusbgdef.bg, 0, motif.versusbgdef.timer, {320,240})
2260- --draw portraits
2261- select.f_drawPortrait(
2262- t_p1Selected,
2263- motif.vs_screen.p1_pos[1] + motif.vs_screen.p1_offset[1],
2264- motif.vs_screen.p1_pos[2] + motif.vs_screen.p1_offset[2],
2265- motif.vs_screen.p1_facing,
2266- motif.vs_screen.p1_scale[1],
2267- motif.vs_screen.p1_scale[2],
2268- motif.vs_screen.p1_spacing[1],
2269- motif.vs_screen.p1_spacing[2],
2270- motif.vs_screen.p1_num,
2271- 'versus'
2272- )
2273- select.f_drawPortrait(
2274- t_p2Selected,
2275- motif.vs_screen.p2_pos[1] + motif.vs_screen.p2_offset[1],
2276- motif.vs_screen.p2_pos[2] + motif.vs_screen.p2_offset[2],
2277- motif.vs_screen.p2_facing,
2278- motif.vs_screen.p2_scale[1],
2279- motif.vs_screen.p2_scale[2],
2280- motif.vs_screen.p2_spacing[1],
2281- motif.vs_screen.p2_spacing[2],
2282- motif.vs_screen.p2_num,
2283- 'versus'
2284- )
2697+ bgDraw(motif.versusbgdef.bg, false)
2698+ --draw p1 portraits
2699+ local t_portrait = {}
2700+ for i = #t_p1Selected, 1, -1 do
2701+ if #t_portrait < motif.vs_screen.p1_num then
2702+ table.insert(t_portrait, t_p1Selected[i].cel)
2703+ end
2704+ end
2705+ t_portrait = main.f_reversedTable(t_portrait)
2706+ for n = #t_portrait, 1, -1 do
2707+ drawPortrait(
2708+ t_portrait[n],
2709+ motif.vs_screen.p1_pos[1] + motif.vs_screen.p1_offset[1] + motif.vs_screen['p1_c' .. n .. '_offset'][1] + (n - 1) * motif.vs_screen.p1_spacing[1] + select.f_alignOffset(motif.vs_screen.p1_facing),
2710+ motif.vs_screen.p1_pos[2] + motif.vs_screen.p1_offset[2] + motif.vs_screen['p1_c' .. n .. '_offset'][2] + (n - 1) * motif.vs_screen.p1_spacing[2],
2711+ motif.vs_screen.p1_facing * motif.vs_screen.p1_scale[1] * motif.vs_screen['p1_c' .. n .. '_scale'][1],
2712+ motif.vs_screen.p1_scale[2] * motif.vs_screen['p1_c' .. n .. '_scale'][2]
2713+ )
2714+ end
2715+ --draw p2 portraits
2716+ t_portrait = {}
2717+ for i = #t_p2Selected, 1, -1 do
2718+ if #t_portrait < motif.vs_screen.p2_num then
2719+ table.insert(t_portrait, t_p2Selected[i].cel)
2720+ end
2721+ end
2722+ t_portrait = main.f_reversedTable(t_portrait)
2723+ for n = #t_portrait, 1, -1 do
2724+ drawPortrait(
2725+ t_portrait[n],
2726+ motif.vs_screen.p2_pos[1] + motif.vs_screen.p2_offset[1] + motif.vs_screen['p2_c' .. n .. '_offset'][1] + (n - 1) * motif.vs_screen.p2_spacing[1] + select.f_alignOffset(motif.vs_screen.p2_facing),
2727+ motif.vs_screen.p2_pos[2] + motif.vs_screen.p2_offset[2] + motif.vs_screen['p2_c' .. n .. '_offset'][2] + (n - 1) * motif.vs_screen.p2_spacing[2],
2728+ motif.vs_screen.p2_facing * motif.vs_screen.p2_scale[1] * motif.vs_screen['p2_c' .. n .. '_scale'][1],
2729+ motif.vs_screen.p2_scale[2] * motif.vs_screen['p2_c' .. n .. '_scale'][2]
2730+ )
2731+ end
22852732 --draw names
22862733 select.f_drawName(
22872734 t_p1Selected,
@@ -2314,25 +2761,33 @@ function select.f_selectVersus()
23142761 textImgDraw(txt_matchNo)
23152762 end
23162763 --draw layerno = 1 backgrounds
2317- main.f_drawBG(motif.versusbgdef.bg_data, motif.versusbgdef.bg, 1, motif.versusbgdef.timer, {320,240})
2318- --draw fadein
2319- animDraw(motif.vs_screen.fadein_data)
2320- animUpdate(motif.vs_screen.fadein_data)
2321- --update timer
2322- motif.versusbgdef.timer = motif.versusbgdef.timer + 1
2323- --end loop
2324- main.f_cmdInput()
2764+ bgDraw(motif.versusbgdef.bg, true)
2765+ --draw fadein / fadeout
2766+ main.fadeActive = fadeScreen(
2767+ fadeType,
2768+ main.fadeStart,
2769+ motif.vs_screen[fadeType .. '_time'],
2770+ motif.vs_screen[fadeType .. '_col'][1],
2771+ motif.vs_screen[fadeType .. '_col'][2],
2772+ motif.vs_screen[fadeType .. '_col'][3]
2773+ )
2774+ --frame transition
2775+ if main.fadeActive then
2776+ commandBufReset(main.p1Cmd)
2777+ commandBufReset(main.p2Cmd)
2778+ elseif fadeType == 'fadeout' then
2779+ commandBufReset(main.p1Cmd)
2780+ commandBufReset(main.p2Cmd)
2781+ clearColor(motif.versusbgdef.bgclearcolor[1], motif.versusbgdef.bgclearcolor[2], motif.versusbgdef.bgclearcolor[3]) --skip last frame rendering
2782+ break
2783+ else
2784+ main.f_cmdInput()
2785+ end
23252786 refresh()
23262787 end
23272788 end
23282789 end
23292790
2330-function select.f_selectChar(player, t)
2331- for i = 1, #t do
2332- selectChar(player, t[i].cel, t[i].pal)
2333- end
2334-end
2335-
23362791 --;===========================================================
23372792 --; RESULT SCREEN
23382793 --;===========================================================
@@ -2347,7 +2802,9 @@ local txt_resultSurvival = main.f_createTextImg(
23472802 motif.survival_results_screen.winstext_font_scale[2],
23482803 motif.survival_results_screen.winstext_font[4],
23492804 motif.survival_results_screen.winstext_font[5],
2350- motif.survival_results_screen.winstext_font[6]
2805+ motif.survival_results_screen.winstext_font[6],
2806+ motif.survival_results_screen.winstext_font[7],
2807+ motif.survival_results_screen.winstext_font[8]
23512808 )
23522809 local txt_resultVS100 = main.f_createTextImg(
23532810 motif.font_data[motif.vs100kumite_results_screen.winstext_font[1]],
@@ -2358,44 +2815,47 @@ local txt_resultVS100 = main.f_createTextImg(
23582815 motif.vs100kumite_results_screen.winstext_offset[2],
23592816 motif.vs100kumite_results_screen.winstext_font_scale[1],
23602817 motif.vs100kumite_results_screen.winstext_font_scale[2],
2361- motif.survival_results_screen.winstext_font[4],
2362- motif.survival_results_screen.winstext_font[5],
2363- motif.survival_results_screen.winstext_font[6]
2818+ motif.vs100kumite_results_screen.winstext_font[4],
2819+ motif.vs100kumite_results_screen.winstext_font[5],
2820+ motif.vs100kumite_results_screen.winstext_font[6],
2821+ motif.vs100kumite_results_screen.winstext_font[7],
2822+ motif.vs100kumite_results_screen.winstext_font[8]
23642823 )
23652824
2366-function select.f_result(state)
2367- --if state == true then --win
2368- --elseif state == false then --loose
2369- --end
2825+function select.f_result()
23702826 local t = {}
23712827 local t_resultText = {}
23722828 local txt = ''
2373- if main.gameMode == 'survival' or main.gameMode == 'survivalcoop' or main.gameMode == 'netplaysurvivalcoop' then
2829+ if gameMode('bossrush') then
2830+ return
2831+ elseif gameMode('survival') or gameMode('survivalcoop') or gameMode('netplaysurvivalcoop') then
23742832 t = motif.survival_results_screen
23752833 t_resultText = main.f_extractText(t.winstext_text, winCnt)
23762834 txt = txt_resultSurvival
2377- elseif main.gameMode == '100kumite' then
2835+ elseif gameMode('100kumite') then
23782836 t = motif.vs100kumite_results_screen
23792837 t_resultText = main.f_extractText(t.winstext_text, winCnt, looseCnt)
23802838 txt = txt_resultVS100
2381- else
2382- return
23832839 end
2384- main.f_resetBG(t, motif.resultsbgdef, motif.music.results_bgm, motif.music.results_bgm_loop, motif.music.results_bgm_volume, motif.music.results_bgm_loopstart, motif.music.results_bgm_loopend)
2840+ main.f_menuReset(motif.resultsbgdef.bg, motif.music.results_bgm, motif.music.results_bgm_loop, motif.music.results_bgm_volume, motif.music.results_bgm_loopstart, motif.music.results_bgm_loopend)
23852841 main.f_cmdInput()
2842+ main.fadeStart = getFrameCount()
2843+ local counter = 0 - t.fadein_time
2844+ fadeType = 'fadein'
23862845 while true do
2387- if esc() or main.f_btnPalNo(main.p1Cmd) > 0 then
2388- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
2389- break
2390- elseif motif.resultsbgdef.timer >= t.show_time then
2391- --add fadeout code here
2392- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
2846+ if esc() then
2847+ main.f_menuReset(motif.titlebgdef.bg, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
2848+ resetRemapInput()
23932849 break
2850+ elseif fadeType == 'fadein' and (counter >= t.show_time or main.f_btnPalNo(main.p1Cmd) > 0) then
2851+ main.fadeStart = getFrameCount()
2852+ fadeType = 'fadeout'
23942853 end
2395- --draw clearcolor
2396- --animDraw(motif.resultsbgdef.bgclearcolor_data) --disabled to not cover game screen
2854+ counter = counter + 1
2855+ --draw clearcolor (disabled to not cover game screen)
2856+ --clearColor(motif.resultsbgdef.bgclearcolor[1], motif.resultsbgdef.bgclearcolor[2], motif.resultsbgdef.bgclearcolor[3])
23972857 --draw layerno = 0 backgrounds
2398- main.f_drawBG(motif.resultsbgdef.bg_data, motif.resultsbgdef.bg, 0, motif.resultsbgdef.timer, {320,240})
2858+ bgDraw(motif.resultsbgdef.bg, false)
23992859 --draw text
24002860 for i = 1, #t_resultText do
24012861 textImgSetText(txt, t_resultText[i])
@@ -2407,14 +2867,26 @@ function select.f_result(state)
24072867 textImgDraw(txt)
24082868 end
24092869 --draw layerno = 1 backgrounds
2410- main.f_drawBG(motif.resultsbgdef.bg_data, motif.resultsbgdef.bg, 1, motif.resultsbgdef.timer, {320,240})
2411- --draw fadein
2412- animDraw(t.fadein_data)
2413- animUpdate(t.fadein_data)
2414- --update timer
2415- motif.resultsbgdef.timer = motif.resultsbgdef.timer + 1
2416- --end loop
2417- main.f_cmdInput()
2870+ bgDraw(motif.resultsbgdef.bg, true)
2871+ --draw fadein / fadeout
2872+ main.fadeActive = fadeScreen(
2873+ fadeType,
2874+ main.fadeStart,
2875+ t[fadeType .. '_time'],
2876+ t[fadeType .. '_col'][1],
2877+ t[fadeType .. '_col'][2],
2878+ t[fadeType .. '_col'][3]
2879+ )
2880+ --frame transition
2881+ if main.fadeActive then
2882+ commandBufReset(main.p1Cmd)
2883+ elseif fadeType == 'fadeout' then
2884+ commandBufReset(main.p1Cmd)
2885+ clearColor(motif.resultsbgdef.bgclearcolor[1], motif.resultsbgdef.bgclearcolor[2], motif.resultsbgdef.bgclearcolor[3]) --skip last frame rendering
2886+ break
2887+ else
2888+ main.f_cmdInput()
2889+ end
24182890 refresh()
24192891 end
24202892 end
@@ -2423,17 +2895,19 @@ end
24232895 --; VICTORY SCREEN
24242896 --;===========================================================
24252897 local txt_winquote = main.f_createTextImg(
2426- motif.font_data[motif.victory_screen.winquote_font[1]],
2427- motif.victory_screen.winquote_font[2],
2428- motif.victory_screen.winquote_font[3],
2429- '',
2430- 0,
2431- 0,
2432- motif.victory_screen.winquote_font_scale[1],
2898+ motif.font_data[motif.victory_screen.winquote_font[1]],
2899+ motif.victory_screen.winquote_font[2],
2900+ motif.victory_screen.winquote_font[3],
2901+ '',
2902+ 0,
2903+ 0,
2904+ motif.victory_screen.winquote_font_scale[1],
24332905 motif.victory_screen.winquote_font_scale[2],
24342906 motif.victory_screen.winquote_font[4],
24352907 motif.victory_screen.winquote_font[5],
2436- motif.victory_screen.winquote_font[6]
2908+ motif.victory_screen.winquote_font[6],
2909+ motif.victory_screen.winquote_font[7],
2910+ motif.victory_screen.winquote_font[8]
24372911 )
24382912 local txt_p1_winquoteName = main.f_createTextImg(
24392913 motif.font_data[motif.victory_screen.p1_name_font[1]],
@@ -2446,7 +2920,9 @@ local txt_p1_winquoteName = main.f_createTextImg(
24462920 motif.victory_screen.p1_name_font_scale[2],
24472921 motif.victory_screen.p1_name_font[4],
24482922 motif.victory_screen.p1_name_font[5],
2449- motif.victory_screen.p1_name_font[6]
2923+ motif.victory_screen.p1_name_font[6],
2924+ motif.victory_screen.p1_name_font[7],
2925+ motif.victory_screen.p1_name_font[8]
24502926 )
24512927 local txt_p2_winquoteName = main.f_createTextImg(
24522928 motif.font_data[motif.victory_screen.p2_name_font[1]],
@@ -2459,76 +2935,144 @@ local txt_p2_winquoteName = main.f_createTextImg(
24592935 motif.victory_screen.p2_name_font_scale[2],
24602936 motif.victory_screen.p2_name_font[4],
24612937 motif.victory_screen.p2_name_font[5],
2462- motif.victory_screen.p2_name_font[6]
2938+ motif.victory_screen.p2_name_font[6],
2939+ motif.victory_screen.p2_name_font[7],
2940+ motif.victory_screen.p2_name_font[8]
24632941 )
24642942
2943+function select.f_teamOrder(teamNo, allow_ko)
2944+ local allow_ko = allow_ko or 0
2945+ local playerNo = -1
2946+ local selectNo = -1
2947+ local t = {}
2948+ local done = false
2949+ for k, v in pairs(t_gameStats.chars[t_gameStats.lastRound]) do --loop through all last round participants
2950+ if k % 2 ~= teamNo then --only if character belongs to selected team
2951+ if v.win then --win team
2952+ if not v.ko and not done then --first not KOed win team member
2953+ playerNo = k
2954+ selectNo = v.selectNo
2955+ done = true
2956+ elseif not v.ko or allow_ko == 1 then --other win team members
2957+ table.insert(t, v.selectNo)
2958+ end
2959+ elseif not done then --first loose team member
2960+ playerNo = k
2961+ selectNo = v.selectNo
2962+ done = true
2963+ else --other loose team members
2964+ table.insert(t, v.selectNo)
2965+ end
2966+ end
2967+ end
2968+ return playerNo, selectNo, t
2969+end
2970+
24652971 function select.f_selectVictory()
2972+ local wpn = -1
2973+ local wsn = -1
2974+ local lpn = -1
2975+ local lsn = -1
2976+ local t = {}
2977+ local t2 = {}
2978+ for i = 0, 1 do
2979+ if i == t_gameStats.winTeam then
2980+ wpn, wsn, t = select.f_teamOrder(i, motif.victory_screen.winner_teamko_enabled)
2981+ else
2982+ lpn, lsn, t2 = select.f_teamOrder(i, true)
2983+ end
2984+ end
2985+ if wpn == -1 or wsn == -1 then
2986+ return
2987+ elseif not main.t_charparam.winscreen then
2988+ return
2989+ elseif main.t_charparam.rivals and select.f_rivalsMatch('winscreen') then --winscreen assigned as rivals param
2990+ if main.t_selChars[t_p1Selected[1].cel + 1].rivals[matchNo].winscreen == 0 then
2991+ return
2992+ end
2993+ elseif main.t_selChars[wsn + 1].winscreen == 0 then --winscreen assigned as character param
2994+ return
2995+ end
24662996 if motif.music.victory_bgm == '' then
2467- main.f_resetBG(motif.victory_screen, motif.victorybgdef)
2997+ main.f_menuReset(motif.victorybgdef.bg)
24682998 else
2469- main.f_resetBG(motif.victory_screen, motif.victorybgdef, motif.music.victory_bgm, motif.music.victory_bgm_loop, motif.music.victory_bgm_volume, motif.music.victory_bgm_loopstart, motif.music.victory_bgm_loopend)
2470- end
2471- local winquote = ''
2472- local winnerNum = 0
2473- local p1Num = t_gameStats.chars[t_gameStats.lastRound][1].selectNo
2474- local p2Num = t_gameStats.chars[t_gameStats.lastRound][2].selectNo
2475- local txt_winquoteName = ''
2476- if winner == 1 then
2477- winquote = getCharVictoryQuote(1)
2478- txt_winquoteName = txt_p1_winquoteName
2479- winnerNum = p1Num
2480- else
2481- winquote = getCharVictoryQuote(2)
2482- txt_winquoteName = txt_p2_winquoteName
2483- winnerNum = p2Num
2999+ main.f_menuReset(motif.victorybgdef.bg, motif.music.victory_bgm, motif.music.victory_bgm_loop, motif.music.victory_bgm_volume, motif.music.victory_bgm_loopstart, motif.music.victory_bgm_loopend)
24843000 end
2485- if winquote == nil or winquote == '' then
3001+ local winquote = getCharVictoryQuote(wpn)
3002+ if winquote == '' then
24863003 winquote = motif.victory_screen.winquote_text
24873004 end
2488- textImgSetText(txt_p1_winquoteName, main.f_getName(p1Num))
2489- textImgSetText(txt_p2_winquoteName, main.f_getName(p2Num))
3005+ textImgSetText(txt_p1_winquoteName, main.f_getName(wsn))
3006+ textImgSetText(txt_p2_winquoteName, main.f_getName(lsn))
24903007 local i = 0
24913008 main.f_cmdInput()
3009+ main.fadeStart = getFrameCount()
3010+ local counter = 0 - motif.victory_screen.fadein_time
3011+ fadeType = 'fadein'
24923012 while true do
2493- if esc() or main.f_btnPalNo(main.p1Cmd) > 0 then
2494- main.f_cmdInput()
2495- break
2496- elseif motif.victorybgdef.timer >= motif.victory_screen.time then
2497- --add fadeout code here
3013+ if esc() then
24983014 main.f_cmdInput()
24993015 break
3016+ elseif fadeType == 'fadein' and (counter >= motif.victory_screen.time or main.f_btnPalNo(main.p1Cmd) > 0) then
3017+ main.fadeStart = getFrameCount()
3018+ fadeType = 'fadeout'
25003019 end
3020+ counter = counter + 1
25013021 --draw clearcolor
2502- animDraw(motif.victorybgdef.bgclearcolor_data)
3022+ clearColor(motif.victorybgdef.bgclearcolor[1], motif.victorybgdef.bgclearcolor[2], motif.victorybgdef.bgclearcolor[3])
25033023 --draw layerno = 0 backgrounds
2504- main.f_drawBG(motif.victorybgdef.bg_data, motif.victorybgdef.bg, 0, motif.victorybgdef.timer, {320,240})
3024+ bgDraw(motif.victorybgdef.bg, false)
25053025 --draw portraits
2506- if motif.victory_screen.p2_display == 0 then
3026+ -- looser team portraits
3027+ for n = 1, #t2 do
3028+ if n > motif.victory_screen.p2_num then
3029+ break
3030+ end
25073031 drawVictoryPortrait(
2508- winnerNum,
2509- motif.victory_screen.p1_offset[1],
2510- motif.victory_screen.p1_offset[2],
2511- motif.victory_screen.p1_facing * motif.victory_screen.p1_scale[1],
2512- motif.victory_screen.p1_scale[2]
3032+ t[n],
3033+ motif.victory_screen.p2_pos[1] + motif.victory_screen.p2_offset[1] + motif.victory_screen['p2_c' .. n + 1 .. '_offset'][1] + select.f_alignOffset(motif.victory_screen.p2_facing),
3034+ motif.victory_screen.p2_pos[2] + motif.victory_screen.p2_offset[2] + motif.victory_screen['p2_c' .. n + 1 .. '_offset'][2],
3035+ motif.victory_screen.p2_facing * motif.victory_screen.p2_scale[1] * motif.victory_screen['p2_c' .. n + 1 .. '_scale'][1],
3036+ motif.victory_screen.p2_scale[2] * motif.victory_screen['p2_c' .. n + 1 .. '_scale'][2]
25133037 )
2514- else
3038+ end
3039+ -- looser portrait
3040+ if motif.victory_screen.p2_num > 0 then
25153041 drawVictoryPortrait(
2516- p1Num,
2517- motif.victory_screen.p1_offset[1],
2518- motif.victory_screen.p1_offset[2],
2519- motif.victory_screen.p1_facing * motif.victory_screen.p1_scale[1],
2520- motif.victory_screen.p1_scale[2]
3042+ lsn,
3043+ motif.victory_screen.p2_pos[1] + motif.victory_screen.p2_offset[1] + motif.victory_screen.p2_c1_offset[1] + select.f_alignOffset(motif.victory_screen.p2_facing),
3044+ motif.victory_screen.p2_pos[2] + motif.victory_screen.p2_offset[2] + motif.victory_screen.p2_c1_offset[2],
3045+ motif.victory_screen.p2_facing * motif.victory_screen.p2_scale[1] * motif.victory_screen.p2_c1_scale[1],
3046+ motif.victory_screen.p2_scale[2] * motif.victory_screen.p2_c1_scale[2]
25213047 )
3048+ end
3049+ -- winner team portraits
3050+ for n = 1, #t do
3051+ if n > motif.victory_screen.p1_num then
3052+ break
3053+ end
25223054 drawVictoryPortrait(
2523- p2Num,
2524- motif.victory_screen.p2_offset[1],
2525- motif.victory_screen.p2_offset[2],
2526- motif.victory_screen.p2_facing * motif.victory_screen.p2_scale[1],
2527- motif.victory_screen.p2_scale[2]
3055+ t[n],
3056+ motif.victory_screen.p1_pos[1] + motif.victory_screen.p1_offset[1] + motif.victory_screen['p1_c' .. n + 1 .. '_offset'][1] + select.f_alignOffset(motif.victory_screen.p1_facing),
3057+ motif.victory_screen.p1_pos[2] + motif.victory_screen.p1_offset[2] + motif.victory_screen['p1_c' .. n + 1 .. '_offset'][2],
3058+ motif.victory_screen.p1_facing * motif.victory_screen.p1_scale[1] * motif.victory_screen['p1_c' .. n + 1 .. '_scale'][1],
3059+ motif.victory_screen.p1_scale[2] * motif.victory_screen['p1_c' .. n + 1 .. '_scale'][2]
25283060 )
25293061 end
2530- --draw winner's name
2531- textImgDraw(txt_winquoteName)
3062+ -- winner portrait
3063+ drawVictoryPortrait(
3064+ wsn,
3065+ motif.victory_screen.p1_pos[1] + motif.victory_screen.p1_offset[1] + motif.victory_screen.p1_c1_offset[1] + select.f_alignOffset(motif.victory_screen.p1_facing),
3066+ motif.victory_screen.p1_pos[2] + motif.victory_screen.p1_offset[2] + motif.victory_screen.p1_c1_offset[2],
3067+ motif.victory_screen.p1_facing * motif.victory_screen.p1_scale[1] * motif.victory_screen.p1_c1_scale[1],
3068+ motif.victory_screen.p1_scale[2] * motif.victory_screen.p1_c1_scale[2]
3069+ )
3070+ --draw winner name
3071+ textImgDraw(txt_p1_winquoteName)
3072+ --draw looser name
3073+ if motif.victory_screen.looser_name_enabled == 1 then
3074+ textImgDraw(txt_p2_winquoteName)
3075+ end
25323076 --draw winquote
25333077 i = i + 1
25343078 main.f_textRender(
@@ -2542,14 +3086,26 @@ function select.f_selectVictory()
25423086 motif.victory_screen.winquote_length
25433087 )
25443088 --draw layerno = 1 backgrounds
2545- main.f_drawBG(motif.victorybgdef.bg_data, motif.victorybgdef.bg, 1, motif.victorybgdef.timer, {320,240})
2546- --draw fadein
2547- animDraw(motif.victory_screen.fadein_data)
2548- animUpdate(motif.victory_screen.fadein_data)
2549- --update timer
2550- motif.victorybgdef.timer = motif.victorybgdef.timer + 1
2551- --end loop
2552- main.f_cmdInput()
3089+ bgDraw(motif.victorybgdef.bg, true)
3090+ --draw fadein / fadeout
3091+ main.fadeActive = fadeScreen(
3092+ fadeType,
3093+ main.fadeStart,
3094+ motif.victory_screen[fadeType .. '_time'],
3095+ motif.victory_screen[fadeType .. '_col'][1],
3096+ motif.victory_screen[fadeType .. '_col'][2],
3097+ motif.victory_screen[fadeType .. '_col'][3]
3098+ )
3099+ --frame transition
3100+ if main.fadeActive then
3101+ commandBufReset(main.p1Cmd)
3102+ elseif fadeType == 'fadeout' then
3103+ commandBufReset(main.p1Cmd)
3104+ clearColor(motif.victorybgdef.bgclearcolor[1], motif.victorybgdef.bgclearcolor[2], motif.victorybgdef.bgclearcolor[3]) --skip last frame rendering
3105+ break
3106+ else
3107+ main.f_cmdInput()
3108+ end
25533109 refresh()
25543110 end
25553111 end
@@ -2567,102 +3123,126 @@ local txt_credits = main.f_createTextImg(
25673123 motif.continue_screen.credits_font_scale[1],
25683124 motif.continue_screen.credits_font_scale[2],
25693125 motif.continue_screen.credits_font[4],
2570- motif.continue_screen.credits_font[5],
2571- motif.continue_screen.credits_font[6]
3126+ motif.continue_screen.credits_font[5],
3127+ motif.continue_screen.credits_font[6],
3128+ motif.continue_screen.credits_font[7],
3129+ motif.continue_screen.credits_font[8]
25723130 )
25733131
25743132 function select.f_continue()
3133+ main.f_menuReset(motif.continuebgdef.bg, motif.music.continue_bgm, motif.music.continue_bgm_loop, motif.music.continue_bgm_volume, motif.music.continue_bgm_loopstart, motif.music.continue_bgm_loopend)
3134+ animReset(motif.continue_screen.continue_anim_data)
3135+ animUpdate(motif.continue_screen.continue_anim_data)
25753136 continue = false
2576- playBGM(motif.music.continue_bgm, true, motif.music.continue_bgm_loop, motif.music.continue_bgm_volume, motif.music.continue_bgm_loopstart or "0", motif.music.continue_bgm_loopend or "0")
2577- --textImgSetText(txt_credits, text[1])
3137+ local text = main.f_extractText(motif.continue_screen.credits_text, main.credits)
3138+ textImgSetText(txt_credits, text[1])
25783139 main.f_cmdInput()
3140+ main.fadeStart = getFrameCount()
3141+ local counter = 0-- - motif.victory_screen.fadein_time
3142+ fadeType = 'fadein'
25793143 while true do
25803144 --draw clearcolor (disabled to not cover area)
2581- --animDraw(motif.continuebgdef.bgclearcolor_data)
3145+ --clearColor(motif.continuebgdef.bgclearcolor[1], motif.continuebgdef.bgclearcolor[2], motif.continuebgdef.bgclearcolor[3])
25823146 --draw layerno = 0 backgrounds
2583- main.f_drawBG(motif.continuebgdef.bg_data, motif.continuebgdef.bg, 0, motif.continuebgdef.timer, {320,240})
3147+ bgDraw(motif.continuebgdef.bg, false)
25843148 --continue screen state
2585- if esc() or motif.continuebgdef.timer > motif.continue_screen.endtime then
3149+ if esc() then
25863150 main.f_cmdInput()
25873151 break
2588- elseif motif.continuebgdef.timer < motif.continue_screen.continue_end_skiptime then
3152+ elseif fadeType == 'fadein' and (counter > motif.continue_screen.endtime or continue) then
3153+ main.fadeStart = getFrameCount()
3154+ fadeType = 'fadeout'
3155+ elseif counter < motif.continue_screen.continue_end_skiptime then
25893156 if commandGetState(main.p1Cmd, 'holds') then
25903157 continue = true
25913158 main.credits = main.credits - 1
25923159 text = main.f_extractText(motif.continue_screen.credits_text, main.credits)
25933160 textImgSetText(txt_credits, text[1])
2594- main.f_cmdInput()
2595- main.f_resetBG(motif.select_info, motif.selectbgdef, motif.music.select_bgm, motif.music.select_bgm_loop, motif.music.select_bgm_volume, motif.music.select_bgm_loopstart, motif.music.select_bgm_loopend)
2596- break
2597- elseif main.f_btnPalNo(main.p1Cmd) > 0 and motif.continuebgdef.timer >= motif.continue_screen.continue_starttime + motif.continue_screen.continue_skipstart then
3161+ elseif main.f_btnPalNo(main.p1Cmd) > 0 and counter >= motif.continue_screen.continue_starttime + motif.continue_screen.continue_skipstart then
25983162 local cnt = 0
2599- if motif.continuebgdef.timer < motif.continue_screen.continue_9_skiptime then
3163+ if counter < motif.continue_screen.continue_9_skiptime then
26003164 cnt = motif.continue_screen.continue_9_skiptime
2601- elseif motif.continuebgdef.timer <= motif.continue_screen.continue_8_skiptime then
3165+ elseif counter <= motif.continue_screen.continue_8_skiptime then
26023166 cnt = motif.continue_screen.continue_8_skiptime
2603- elseif motif.continuebgdef.timer < motif.continue_screen.continue_7_skiptime then
3167+ elseif counter < motif.continue_screen.continue_7_skiptime then
26043168 cnt = motif.continue_screen.continue_7_skiptime
2605- elseif motif.continuebgdef.timer < motif.continue_screen.continue_6_skiptime then
3169+ elseif counter < motif.continue_screen.continue_6_skiptime then
26063170 cnt = motif.continue_screen.continue_6_skiptime
2607- elseif motif.continuebgdef.timer < motif.continue_screen.continue_5_skiptime then
3171+ elseif counter < motif.continue_screen.continue_5_skiptime then
26083172 cnt = motif.continue_screen.continue_5_skiptime
2609- elseif motif.continuebgdef.timer < motif.continue_screen.continue_4_skiptime then
3173+ elseif counter < motif.continue_screen.continue_4_skiptime then
26103174 cnt = motif.continue_screen.continue_4_skiptime
2611- elseif motif.continuebgdef.timer < motif.continue_screen.continue_3_skiptime then
3175+ elseif counter < motif.continue_screen.continue_3_skiptime then
26123176 cnt = motif.continue_screen.continue_3_skiptime
2613- elseif motif.continuebgdef.timer < motif.continue_screen.continue_2_skiptime then
3177+ elseif counter < motif.continue_screen.continue_2_skiptime then
26143178 cnt = motif.continue_screen.continue_2_skiptime
2615- elseif motif.continuebgdef.timer < motif.continue_screen.continue_1_skiptime then
3179+ elseif counter < motif.continue_screen.continue_1_skiptime then
26163180 cnt = motif.continue_screen.continue_1_skiptime
2617- elseif motif.continuebgdef.timer < motif.continue_screen.continue_0_skiptime then
3181+ elseif counter < motif.continue_screen.continue_0_skiptime then
26183182 cnt = motif.continue_screen.continue_0_skiptime
26193183 end
2620- while motif.continuebgdef.timer < cnt do
2621- motif.continuebgdef.timer = motif.continuebgdef.timer + 1
3184+ while counter < cnt do
3185+ counter = counter + 1
26223186 animUpdate(motif.continue_screen.continue_anim_data)
26233187 end
26243188 end
2625- if motif.continuebgdef.timer == motif.continue_screen.continue_9_skiptime then
3189+ if counter == motif.continue_screen.continue_9_skiptime then
26263190 sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_9_snd[1], motif.continue_screen.continue_9_snd[2])
2627- elseif motif.continuebgdef.timer == motif.continue_screen.continue_8_skiptime then
3191+ elseif counter == motif.continue_screen.continue_8_skiptime then
26283192 sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_8_snd[1], motif.continue_screen.continue_8_snd[2])
2629- elseif motif.continuebgdef.timer == motif.continue_screen.continue_7_skiptime then
3193+ elseif counter == motif.continue_screen.continue_7_skiptime then
26303194 sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_7_snd[1], motif.continue_screen.continue_7_snd[2])
2631- elseif motif.continuebgdef.timer == motif.continue_screen.continue_6_skiptime then
3195+ elseif counter == motif.continue_screen.continue_6_skiptime then
26323196 sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_6_snd[1], motif.continue_screen.continue_6_snd[2])
2633- elseif motif.continuebgdef.timer == motif.continue_screen.continue_5_skiptime then
3197+ elseif counter == motif.continue_screen.continue_5_skiptime then
26343198 sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_5_snd[1], motif.continue_screen.continue_5_snd[2])
2635- elseif motif.continuebgdef.timer == motif.continue_screen.continue_4_skiptime then
3199+ elseif counter == motif.continue_screen.continue_4_skiptime then
26363200 sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_4_snd[1], motif.continue_screen.continue_4_snd[2])
2637- elseif motif.continuebgdef.timer == motif.continue_screen.continue_3_skiptime then
3201+ elseif counter == motif.continue_screen.continue_3_skiptime then
26383202 sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_3_snd[1], motif.continue_screen.continue_3_snd[2])
2639- elseif motif.continuebgdef.timer == motif.continue_screen.continue_2_skiptime then
3203+ elseif counter == motif.continue_screen.continue_2_skiptime then
26403204 sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_2_snd[1], motif.continue_screen.continue_2_snd[2])
2641- elseif motif.continuebgdef.timer == motif.continue_screen.continue_1_skiptime then
3205+ elseif counter == motif.continue_screen.continue_1_skiptime then
26423206 sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_1_snd[1], motif.continue_screen.continue_1_snd[2])
2643- elseif motif.continuebgdef.timer == motif.continue_screen.continue_0_skiptime then
3207+ elseif counter == motif.continue_screen.continue_0_skiptime then
26443208 sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_0_snd[1], motif.continue_screen.continue_0_snd[2])
26453209 end
2646- elseif motif.continuebgdef.timer == motif.continue_screen.continue_end_skiptime then
2647- playBGM(motif.music.continue_end_bgm, true, motif.music.continue_end_bgm_loop, motif.music.continue_end_bgm_volume, motif.music.continue_end_bgm_loopstart or "0", motif.music.continue_end_bgm_loopend or "0")
3210+ elseif counter == motif.continue_screen.continue_end_skiptime then
3211+ playBGM(motif.music.continue_end_bgm, true, motif.music.continue_end_bgm_loop, motif.music.continue_end_bgm_volume, motif.music.continue_end_bgm_loopstart, motif.music.continue_end_bgm_loopend)
26483212 sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_end_snd[1], motif.continue_screen.continue_end_snd[2])
26493213 end
26503214 --draw credits text
2651- if motif.continuebgdef.timer >= motif.continue_screen.continue_skipstart then --show when counter starts counting down
3215+ if counter >= motif.continue_screen.continue_skipstart then --show when counter starts counting down
26523216 textImgDraw(txt_credits)
26533217 end
3218+ counter = counter + 1
26543219 --draw counter
26553220 animUpdate(motif.continue_screen.continue_anim_data)
26563221 animDraw(motif.continue_screen.continue_anim_data)
26573222 --draw layerno = 1 backgrounds
2658- main.f_drawBG(motif.continuebgdef.bg_data, motif.continuebgdef.bg, 1, motif.continuebgdef.timer, {320,240})
2659- --draw fadein
2660- animDraw(motif.continue_screen.fadein_data)
2661- animUpdate(motif.continue_screen.fadein_data)
2662- --update timer
2663- motif.continuebgdef.timer = motif.continuebgdef.timer + 1
2664- --end loop
2665- main.f_cmdInput()
3223+ bgDraw(motif.continuebgdef.bg, true)
3224+ --draw fadein / fadeout
3225+ main.fadeActive = fadeScreen(
3226+ fadeType,
3227+ main.fadeStart,
3228+ motif.continue_screen[fadeType .. '_time'],
3229+ motif.continue_screen[fadeType .. '_col'][1],
3230+ motif.continue_screen[fadeType .. '_col'][2],
3231+ motif.continue_screen[fadeType .. '_col'][3]
3232+ )
3233+ --frame transition
3234+ if main.fadeActive then
3235+ commandBufReset(main.p1Cmd)
3236+ elseif fadeType == 'fadeout' then
3237+ commandBufReset(main.p1Cmd)
3238+ clearColor(motif.continuebgdef.bgclearcolor[1], motif.continuebgdef.bgclearcolor[2], motif.continuebgdef.bgclearcolor[3]) --skip last frame rendering
3239+ if continue then
3240+ main.f_menuReset(motif.selectbgdef.bg, motif.music.select_bgm, motif.music.select_bgm_loop, motif.music.select_bgm_volume, motif.music.select_bgm_loopstart, motif.music.select_bgm_loopend)
3241+ end
3242+ break
3243+ else
3244+ main.f_cmdInput()
3245+ end
26663246 refresh()
26673247 end
26683248 end
--- a/script/storyboard.lua
+++ b/script/storyboard.lua
@@ -7,35 +7,10 @@ storyboard.t_storyboard = {} --stores all parsed storyboards (we parse each of t
77
88 local function f_reset(t)
99 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
1810 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
11+ bgReset(t.scene[k].bg)
3812 end
13+
3914 for k2, v2 in pairs(t.scene[k].layer) do
4015 if t.scene[k].layer[k2].anim_data ~= nil then
4116 animReset(t.scene[k].layer[k2].anim_data)
@@ -47,21 +22,24 @@ local function f_reset(t)
4722 end
4823
4924 local function f_play(t)
25+ playBGM('')
5026 main.f_printTable(t, 'debug/t_storyboard.txt')
5127 --loop through scenes in order
5228 for k, v in main.f_sortKeys(t.scene) do
5329 --scene >= startscene
5430 if k >= t.scenedef.startscene then
31+ local fadeType = 'fadein'
32+ local fadeStart = getFrameCount()
5533 for i = 0, t.scene[k].end_time do
5634 --end storyboard
57- if esc() or main.f_btnPalNo(main.p1Cmd) > 0 and t.scenedef.skipbutton > 0 then
35+ if (esc() or main.f_btnPalNo(main.p1Cmd) > 0) and t.scenedef.skipbutton > 0 then
5836 main.f_cmdInput()
5937 refresh()
6038 return
6139 end
6240 --play bgm
6341 if i == 0 and t.scene[k].bgm ~= nil then
64- playBGM(t.scene[k].bgm, true, t.scene[k].bgm_loop, t.scene[k].bgm_volume, t.scene[k].bgm_loopstart or "0", t.scene[k].bgm_loopend or "0")
42+ playBGM(t.scene[k].bgm, true, t.scene[k].bgm_loop, t.scene[k].bgm_volume, t.scene[k].bgm_loopstart, t.scene[k].bgm_loopend)
6543 end
6644 --play snd
6745 if t.scenedef.snd_data ~= nil then
@@ -71,11 +49,11 @@ local function f_play(t)
7149 end
7250 end
7351 end
74- --clearcolor
75- animDraw(t.scene[k].clearcolor_data)
52+ --draw clearcolor
53+ clearColor(t.scene[k].clearcolor[1], t.scene[k].clearcolor[2], t.scene[k].clearcolor[3])
7654 --draw layerno = 0 backgrounds
7755 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, t.info.localcoord)
56+ bgDraw(t.scene[k].bg, false)
7957 end
8058 --loop through layers in order
8159 for k2, v2 in main.f_sortKeys(t.scene[k].layer) do
@@ -95,7 +73,7 @@ local function f_play(t)
9573 t.scene[k].layerall_pos[1] + t.scene[k].layer[k2].offset[1],
9674 t.scene[k].layerall_pos[2] + t.scene[k].layer[k2].offset[2],
9775 t.scene[k].layer[k2].text_spacing[2],
98- t.scene[k].layer[k2].textdelay,
76+ t.scene[k].layer[k2].text_delay,
9977 t.scene[k].layer[k2].text_length
10078 )
10179 end
@@ -103,38 +81,38 @@ local function f_play(t)
10381 end
10482 --draw layerno = 1 backgrounds
10583 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, t.info.localcoord)
84+ bgDraw(t.scene[k].bg, true)
10785 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- if main.f_btnPalNo(main.p1Cmd) > 0 and t.scenedef.skipbutton <= 0 then
119- main.f_cmdInput()
120- refresh()
121- do
122- break
123- end
86+ --draw fadein / fadeout
87+ if i == t.scene[k].end_time - t.scene[k].fadeout_time then
88+ fadeType = 'fadeout'
89+ fadeStart = getFrameCount()
12490 end
91+ main.fadeActive = fadeScreen(
92+ fadeType,
93+ fadeStart,
94+ t.scene[k][fadeType .. '_time'],
95+ t.scene[k][fadeType .. '_col'][1],
96+ t.scene[k][fadeType .. '_col'][2],
97+ t.scene[k][fadeType .. '_col'][3]
98+ )
99+ --if main.f_btnPalNo(main.p1Cmd) > 0 and t.scenedef.skipbutton <= 0 then
100+ -- main.f_cmdInput()
101+ -- refresh()
102+ -- do
103+ -- break
104+ -- end
105+ --end
125106 main.f_cmdInput()
126107 refresh()
127108 end
128109 end
129110 end
130- playBGM('', true, 1, 100, "0", "0")
131111 end
132112
133113 local function f_parse(path)
134- -- Intro haves his own localcoord function
135- -- So we disable it
114+ --storyboards use their own localcoord function, so we disable it
136115 main.SetDefaultScale()
137-
138116 local file = io.open(path, 'r')
139117 local fileDir, fileName = path:match('^(.-)([^/\\]+)$')
140118 local t = {}
@@ -142,95 +120,32 @@ local function f_parse(path)
142120 local pos_default = {}
143121 local pos_val = {}
144122 t.anim = {}
145- t.ctrldef = {}
146123 t.scene = {}
124+ t.def = fileDir .. fileName
147125 t.fileDir = fileDir
148126 t.fileName = fileName
149- local bgdef = 'dummyUntilSet'
150- local bgctrl = ''
151- local bgctrl_match = 'dummyUntilSet'
152127 local tmp = ''
153128 local t_default =
154129 {
155130 info = {localcoord = {320, 240}},
156- scenedef = {spr = '', snd = '', font = {[1] = 'font/f-6x9.fnt'}, font_height = {}, startscene = 0, skipbutton = 1, font_data = {}},
131+ scenedef = {
132+ spr = '',
133+ snd = '',
134+ font = {[1] = 'f-6x9.fnt'},
135+ font_height = {},
136+ startscene = 0,
137+ skipbutton = 1, --Ikemen feature
138+ font_data = {}
139+ },
157140 scene = {},
158- ctrldef = {}
159141 }
160142 for line in file:lines() do
161143 line = line:gsub('%s*;.*$', '')
162144 if line:match('^%s*%[.-%s*%]%s*$') then --matched [] group
163145 line = line:match('^%s*%[(.-)%s*%]%s*$') --match text between []
164146 line = line:gsub('[%. ]', '_') --change . and space to _
165- line = line:lower() --lowercase line
166- local row = tostring(line:lower()) --just in case it's a number (not really needed)
167- if row:match('.+ctrldef') then --matched ctrldef start
168- bgctrl = row
169- bgctrl_match = bgctrl:match('^(.-ctrl)def')
170- if t.ctrldef[bgdef .. 'def'][bgctrl] ~= nil then --Ctrldef名の重複を避ける
171- bgctrl = bgctrl..tostring(os.clock())
172- end
173- t.ctrldef[bgdef .. 'def'][bgctrl] = {}
174- t.ctrldef[bgdef .. 'def'][bgctrl].ctrl = {}
175- pos = t.ctrldef[bgdef .. 'def'][bgctrl]
176- t_default.ctrldef[bgdef .. 'def'][bgctrl] = {
177- looptime = -1,
178- ctrlid = {0},
179- ctrl = {}
180- }
181- elseif row:match('^' .. bgctrl_match) then --matched ctrldef content
182- tmp = t.ctrldef[bgdef .. 'def'][bgctrl].ctrl
183- tmp[#tmp + 1] = {}
184- pos = tmp[#tmp]
185- t_default.ctrldef[bgdef .. 'def'][bgctrl].ctrl[#tmp] = {
186- type = 'null',
187- time = {0, -1, -1},
188- ctrlid = {}
189- }
190- elseif row:match('.+def$') and not row:match('^scenedef$') --[[and not row:match('^' .. bgdef .. '.*$')]] then --matched bgdef start
191- t[row] = {}
192- pos = t[row]
193- bgdef = row:match('(.+)def$')
194- t_default[row] = {}
195- t.ctrldef[bgdef .. 'def'] = {}
196- t_default.ctrldef[bgdef .. 'def'] = {}
197- elseif row:match('^' .. bgdef) then --matched bgdef content
198- tmp = t[bgdef .. 'def']
199- tmp[#tmp + 1] = {}
200- pos = tmp[#tmp]
201- t_default[bgdef .. 'def'][#tmp] =
202- {
203- type = 'normal',
204- spriteno = {0, 0},
205- id = 0,
206- layerno = 0,
207- start = {0, 0},
208- delta = {1, 1},
209- trans = '',
210- mask = 0,
211- tile = {0, 0},
212- tilespacing = {0, nil},
213- --window = {0, 0, 0, 0},
214- --windowdelta = {0, 0}, --not supported yet
215- --width = {0, 0}, --not supported yet (parallax)
216- --xscale = {1.0, 1.0}, --not supported yet (parallax)
217- --yscalestart = 100, --not supported yet (parallax)
218- --yscaledelta = 1, --not supported yet (parallax)
219- positionlink = 0,
220- velocity = {0, 0},
221- --sin_x = {0, 0, 0}, --not supported yet
222- --sin_y = {0, 0, 0}, --not supported yet
223- ctrl = {},
224- ctrl_flags = {
225- visible = 1,
226- enabled = 1,
227- velx = 0,
228- vely = 0,
229- x = 0,
230- y = 0
231- }
232- }
233- elseif row:match('^scene_[0-9]+$') then --matched scene
147+ local row = tostring(line:lower())
148+ if row:match('^scene_[0-9]+$') then --matched scene
234149 row = tonumber(row:match('^scene_([0-9]+)$'))
235150 t.scene[row] = {}
236151 pos = t.scene[row]
@@ -249,9 +164,9 @@ local function f_parse(path)
249164 sound = {},
250165 --bgm = '',
251166 bgm_loop = 0,
252- bgm_volume = 100,
253- bgm_loopstart = nil,
254- bgm_loopend = nil,
167+ bgm_volume = 100, --Ikemen feature
168+ bgm_loopstart = 0, --Ikemen feature
169+ bgm_loopend = 0, --Ikemen feature
255170 --window = {0, 0, 0, 0},
256171 bg_name = ''
257172 }
@@ -272,7 +187,7 @@ local function f_parse(path)
272187 value = value:gsub('"', '') --remove brackets from value
273188 value = value:gsub('^(%.[0-9])', '0%1') --add 0 before dot if missing at the beginning of matched string
274189 value = value:gsub('([^0-9])(%.[0-9])', '%10%2') --add 0 before dot if missing anywhere else
275- if param:match('^font[0-9]+$') then --font param matched
190+ if param:match('^font[0-9]+') then --font param matched
276191 local num = tonumber(param:match('font([0-9]+)'))
277192 if param:match('_height$') then
278193 if pos.font_height == nil then
@@ -280,6 +195,7 @@ local function f_parse(path)
280195 end
281196 pos.font_height[num] = main.f_dataType(value)
282197 else
198+ value = value:gsub('\\', '/')
283199 if pos.font == nil then
284200 pos.font = {}
285201 end
@@ -295,9 +211,9 @@ local function f_parse(path)
295211 {
296212 anim = -1,
297213 text = '',
298- font = {1, 0, 0, nil, nil, nil},
214+ font = {1, 0, 0, 255, 255, 255, 255, 0},
299215 text_spacing = {0, 15}, --Ikemen feature
300- textdelay = 2,
216+ text_delay = 2, --Ikemen feature
301217 text_length = 50, --Ikemen feature
302218 text_timer = 0, --Ikemen feature
303219 offset = {0, 0},
@@ -330,9 +246,9 @@ local function f_parse(path)
330246 pos_val[param] = {}
331247 end
332248 if c == '' then
333- pos_val[param][#pos_val[param] + 1] = 0
249+ table.insert(pos_val[param], 0)
334250 else
335- pos_val[param][#pos_val[param] + 1] = main.f_dataType(c)
251+ table.insert(pos_val[param], main.f_dataType(c))
336252 end
337253 end
338254 else --single value
@@ -342,11 +258,11 @@ local function f_parse(path)
342258 end
343259 else --only valid lines left are animations
344260 line = line:lower()
345- 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') or line:match('^%s*interpolate offset') or line:match('^%s*interpolate angle') or line:match('^%s*interpolate scale') or line:match('^%s*interpolate blend')
261+ 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') or line:match('^%s*interpolate [oasb][fncl][fgae][sln][ed]t?')
346262 if value ~= nil then
347263 value = value:gsub(',%s*,', ',0,') --add missing values
348264 value = value:gsub(',%s*$', '')
349- pos[#pos + 1] = value
265+ table.insert(pos, value)
350266 end
351267 end
352268 end
@@ -357,30 +273,6 @@ local function f_parse(path)
357273 --;===========================================================
358274 --merge tables
359275 t = main.f_tableMerge(t_default, t)
360- --ctrldef table adjustment
361- for k, v in pairs(t.ctrldef) do
362- for k2, v2 in pairs(t.ctrldef[k]) do
363- tmp = t.ctrldef[k][k2].ctrl
364- for i = 1, #tmp do
365- --if END_TIME is omitted it should default to the same value as START_TIME
366- if tmp[i].time[2] == -1 then
367- tmp[i].time[2] = tmp[i].time[1]
368- end
369- --if LOOPTIME is omitted or set to -1, the background controller will not reset its own timer. In such case use GLOBAL_LOOPTIME
370- if tmp[i].time[3] == -1 then
371- tmp[i].time[3] = t.ctrldef[k][k2].looptime
372- end
373- --lowercase type name
374- tmp[i].type = tmp[i].type:lower()
375- --this list, if specified, overrides the default list specified in the BGCtrlDef
376- if #tmp[i].ctrlid == 0 then
377- for j = 1, #t.ctrldef[k][k2].ctrlid do
378- tmp[i].ctrlid[#tmp[i].ctrlid + 1] = t.ctrldef[k][k2].ctrlid[j]
379- end
380- end
381- end
382- end
383- end
384276 --scenedef spr
385277 if not t.scenedef.spr:match('^data/') then
386278 if main.f_fileExists(t.fileDir .. t.scenedef.spr) then
@@ -403,18 +295,11 @@ local function f_parse(path)
403295 end
404296 --scenedef fonts
405297 for k, v in pairs(t.scenedef.font) do --loop through table keys
406- if t.scenedef.font[k] ~= '' then
407- if not t.scenedef.font[k]:match('^data/') then
408- if main.f_fileExists(t.fileDir .. t.scenedef.font[k]) then
409- t.scenedef.font[k] = t.fileDir .. t.scenedef.font[k]
410- elseif main.f_fileExists('font/' .. t.scenedef.font[k]) then
411- t.scenedef.font[k] = 'font/' .. t.scenedef.font[k]
412- end
413- t.scenedef.font_data[k] = fontNew(t.scenedef.font[k])
414- t.scenedef.font[k] = {}
415- t.scenedef.font[k][1] = k
416- t.scenedef.font[k][2] = 0
417- t.scenedef.font[k][3] = 0
298+ if v ~= '' and t.scenedef.font_data[v] == nil then
299+ if t.scenedef.font_height[k] ~= nil then
300+ t.scenedef.font_data[v] = fontNew(v, t.scenedef.font_height[k])
301+ else
302+ t.scenedef.font_data[v] = fontNew(v)
418303 end
419304 end
420305 end
@@ -422,8 +307,9 @@ local function f_parse(path)
422307 local prev_k = ''
423308 for k, v in main.f_sortKeys(t.scene) do
424309 --bgm
425- if t.scene[k].bgm ~= nil and not t.scene[k].bgm:match('^data/') then
426- if main.f_fileExists(t.fileDir .. t.scene[k].bgm) then
310+ if t.scene[k].bgm ~= nil then
311+ if t.scene[k].bgm:match('^data/') then
312+ elseif main.f_fileExists(t.fileDir .. t.scene[k].bgm) then
427313 t.scene[k].bgm = t.fileDir .. t.scene[k].bgm
428314 elseif main.f_fileExists('music/' .. t.scene[k].bgm) then
429315 t.scene[k].bgm = 'music/' .. t.scene[k].bgm
@@ -445,83 +331,11 @@ local function f_parse(path)
445331 end
446332 end
447333 prev_k = k
448- --backgrounds data
449- local anim = ''
334+ --backgrounds
450335 if t.scene[k].bg_name ~= '' then
451- t.scene[k].bg_data = {}
452- t.scene[k].bg_name = t.scene[k].bg_name:lower()
453- local t_bgdef = t[t.scene[k].bg_name .. 'def']
454- local prev_k2 = ''
455- for k2, v2 in pairs(t_bgdef) do --loop through table keys
456- if type(k2) == "number" and t_bgdef[k2].type ~= nil then
457- t_bgdef[k2].type = t_bgdef[k2].type:lower()
458- --mugen ignores delta = 0 (defaults to 1)
459- if t_bgdef[k2].delta[1] == 0 then t_bgdef[k2].delta[1] = 1 end
460- if t_bgdef[k2].delta[2] == 0 then t_bgdef[k2].delta[2] = 1 end
461- --add ctrl data
462- t[t.scene[k].bg_name .. 'def'][k2].ctrl = main.f_ctrlBG(t_bgdef[k2], t.ctrldef[t.scene[k].bg_name .. 'def'])
463- --positionlink adjustment
464- if t_bgdef[k2].positionlink == 1 and prev_k2 ~= '' then
465- t_bgdef[k2].start[1] = t_bgdef[prev_k2].start[1]
466- t_bgdef[k2].start[2] = t_bgdef[prev_k2].start[2]
467- t_bgdef[k2].delta[1] = t_bgdef[prev_k2].delta[1]
468- t_bgdef[k2].delta[2] = t_bgdef[prev_k2].delta[2]
469- end
470- prev_k2 = k2
471- --generate anim data
472- local sizeX, sizeY, offsetX, offsetY = 0, 0, 0, 0
473- if t_bgdef[k2].type == 'anim' then
474- anim = main.f_animFromTable(t.anim[t_bgdef[k2].actionno], t.scenedef.spr_data, t_bgdef[k2].start[1], t_bgdef[k2].start[2])
475- else --normal, parallax
476- anim = t_bgdef[k2].spriteno[1] .. ', ' .. t_bgdef[k2].spriteno[2] .. ', ' .. t_bgdef[k2].start[1] .. ', ' .. t_bgdef[k2].start[2] .. ', ' .. -1
477- anim = animNew(t.scenedef.spr_data, anim)
478- sizeX, sizeY, offsetX, offsetY = getSpriteInfo(t.scenedef.spr, t_bgdef[k2].spriteno[1], t_bgdef[k2].spriteno[2])
479- end
480- if t_bgdef[k2].trans == 'add1' then
481- animSetAlpha(anim, 255, 128)
482- elseif t_bgdef[k2].trans == 'add' then
483- animSetAlpha(anim, 255, 255)
484- elseif t_bgdef[k2].trans == 'sub' then
485- animSetAlpha(anim, 1, 255)
486- end
487- animAddPos(anim, 160, 0) --for some reason needed in ikemen
488- if t_bgdef[k2].window ~= nil then
489- animSetWindow(
490- anim,
491- t_bgdef[k2].window[1] * 320/t.info.localcoord[1],
492- t_bgdef[k2].window[2] * 240/t.info.localcoord[2],
493- (t_bgdef[k2].window[3] - t_bgdef[k2].window[1] + 1)* 320/t.info.localcoord[1],
494- (t_bgdef[k2].window[4] - t_bgdef[k2].window[2] + 1) * 240/t.info.localcoord[2]
495- )
496- else
497- animSetWindow(anim, 0, 0, t.info.localcoord[1], t.info.localcoord[2])
498- end
499- if t_bgdef[k2].tilespacing[2] == nil then t_bgdef[k2].tilespacing[2] = t_bgdef[k2].tilespacing[1] end
500- if t_bgdef[k2].type == 'parallax' then
501- animSetTile(anim, t_bgdef[k2].tile[1], 0, t_bgdef[k2].tilespacing[1] + sizeX, t_bgdef[k2].tilespacing[2] + sizeY)
502- else
503- animSetTile(anim, t_bgdef[k2].tile[1], t_bgdef[k2].tile[2], t_bgdef[k2].tilespacing[1] + sizeX, t_bgdef[k2].tilespacing[2] + sizeY)
504- end
505- animSetScale(anim, 320/t.info.localcoord[1], 240/t.info.localcoord[2])
506- if t_bgdef[k2].mask == 1 or t_bgdef[k2].type ~= 'normal' or (t_bgdef[k2].trans ~= '' and t_bgdef[k2].trans ~= 'none') then
507- animSetColorKey(anim, 0)
508- else
509- animSetColorKey(anim, -1)
510- end
511- --animUpdate(anim)
512- t.scene[k].bg_data[k2] = anim
513- end
514- end
336+ t.scene[k].bg = bgNew(t.def, t.scene[k].bg_name:lower(), t.scenedef.spr)
337+ bgReset(t.scene[k].bg)
515338 end
516- --clearcolor data
517- t.scene[k].clearcolor_data = main.f_clearColor(t.scene[k].clearcolor[1], t.scene[k].clearcolor[2], t.scene[k].clearcolor[3])
518- animSetWindow(t.scene[k].clearcolor_data, 0, 0, t.info.localcoord[1], t.info.localcoord[2])
519- --fadein data
520- 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])
521- animSetWindow(t.scene[k].fadein_data, 0, 0, t.info.localcoord[1], t.info.localcoord[2])
522- --fadeout data
523- 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])
524- animSetWindow(t.scene[k].fadeout_data, 0, 0, t.info.localcoord[1], t.info.localcoord[2])
525339 --loop through scene layers
526340 local t_layer = t.scene[k].layer
527341 for k2, v2 in pairs(t_layer) do
@@ -533,12 +347,12 @@ local function f_parse(path)
533347 t.scene[k].layerall_pos[1] + t_layer[k2].offset[1],
534348 t.scene[k].layerall_pos[2] + t_layer[k2].offset[2]
535349 )
536- animSetScale(t.scene[k].layer[k2].anim_data, 320/t.info.localcoord[1], 240/t.info.localcoord[2])
350+ --animSetScale(t.scene[k].layer[k2].anim_data, 320/t.info.localcoord[1], 240/t.info.localcoord[2])
537351 end
538352 --text
539353 if t_layer[k2].text ~= '' then
540354 t.scene[k].layer[k2].text_data = main.f_createTextImg(
541- t.scenedef.font_data[t.scenedef.font[t_layer[k2].font[1]][1]],
355+ t.scenedef.font_data[t_layer[k2].font[1]],
542356 t_layer[k2].font[2],
543357 t_layer[k2].font[3],
544358 t_layer[k2].text,
@@ -548,7 +362,9 @@ local function f_parse(path)
548362 240/t.info.localcoord[2],
549363 t_layer[k2].font[4],
550364 t_layer[k2].font[5],
551- t_layer[k2].font[6]
365+ t_layer[k2].font[6],
366+ t_layer[k2].font[7],
367+ t_layer[k2].font[8]
552368 )
553369 end
554370 --endtime
@@ -557,12 +373,8 @@ local function f_parse(path)
557373 end
558374 end
559375 end
560- --t.ctrldef = nil
561-
562- -- Finished loading intro
563- -- Re-enabled custom scaling
376+ --finished loading storyboard, re-enable custom scaling
564377 main.SetScaleValues()
565-
566378 return t
567379 end
568380
--- /dev/null
+++ b/src/bgdef.go
@@ -0,0 +1,342 @@
1+package main
2+
3+import (
4+ "strings"
5+)
6+
7+func (bgct *bgcTimeLine) stepBGDef(s *BGDef) {
8+ if len(bgct.line) > 0 && bgct.line[0].waitTime <= 0 {
9+ for _, b := range bgct.line[0].bgc {
10+ for i, a := range bgct.al {
11+ if b.idx < a.idx {
12+ bgct.al = append(bgct.al, nil)
13+ copy(bgct.al[i+1:], bgct.al[i:])
14+ bgct.al[i] = b
15+ b = nil
16+ break
17+ }
18+ }
19+ if b != nil {
20+ bgct.al = append(bgct.al, b)
21+ }
22+ }
23+ bgct.line = bgct.line[1:]
24+ }
25+ if len(bgct.line) > 0 {
26+ bgct.line[0].waitTime--
27+ }
28+ var el []*bgCtrl
29+ for i := 0; i < len(bgct.al); {
30+ s.runBgCtrl(bgct.al[i])
31+ if bgct.al[i].currenttime > bgct.al[i].endtime {
32+ el = append(el, bgct.al[i])
33+ bgct.al = append(bgct.al[:i], bgct.al[i+1:]...)
34+ continue
35+ }
36+ i++
37+ }
38+ for _, b := range el {
39+ bgct.add(b)
40+ }
41+}
42+
43+type BGDef struct {
44+ def string
45+ localcoord [2]float32
46+ sffloc string
47+ sff *Sff
48+ at AnimationTable
49+ bg []*backGround
50+ bgc []bgCtrl
51+ bgct bgcTimeLine
52+ bga bgAction
53+ resetbg bool
54+ localscl float32
55+ scale [2]float32
56+}
57+
58+func newBGDef(def string) *BGDef {
59+ s := &BGDef{def: def, localcoord: [...]float32{320, 240}, resetbg: true, localscl: 1, scale: [...]float32{1, 1}}
60+ return s
61+}
62+
63+func loadBGDef(def string, bgname string, sffloc string) (int, error) {
64+ s := newBGDef(def)
65+ str, err := LoadText(def)
66+ if err != nil {
67+ return -1, err
68+ }
69+ s.sff = &Sff{}
70+ lines, i := SplitAndTrim(str, "\n"), 0
71+ defmap := make(map[string][]IniSection)
72+ for i < len(lines) {
73+ is, name, _ := ReadIniSection(lines, &i)
74+ if i := strings.IndexAny(name, " \t"); i >= 0 {
75+ if name[:i] == bgname {
76+ defmap[bgname] = append(defmap[bgname], is)
77+ }
78+ } else {
79+ defmap[name] = append(defmap[name], is)
80+ }
81+ }
82+ i = 0
83+ if sec := defmap["info"]; len(sec) > 0 {
84+ sec[0].readF32ForStage("localcoord", &s.localcoord[0], &s.localcoord[1])
85+ }
86+ var ok, skipat bool
87+ var filename string
88+ bgnum := -1
89+ if sffloc != "" {
90+ filename = sffloc
91+ } else if sec := defmap["files"]; len(sec) > 0 {
92+ if sec[0].LoadFile("spr", def, func(filename string) error {
93+ filename = strings.Replace(filename, "\\", "/", -1)
94+ return nil
95+ }); err != nil {
96+ return -1, err
97+ }
98+ }
99+ for j := 0; j < len(sys.bgdef); j++ {
100+ if !ok && sys.bgdef[j].sffloc == filename {
101+ *s.sff = *sys.bgdef[j].sff
102+ bgnum = j
103+ ok = true
104+ }
105+ if sys.bgdef[j].def == def && ok {
106+ skipat = true
107+ break
108+ }
109+ }
110+ if !ok { //skip loadSFF if already loaded
111+ sff, err := loadSff(filename, false)
112+ if err != nil {
113+ return -1, err
114+ }
115+ *s.sff = *sff
116+ }
117+ s.sffloc = filename
118+ if skipat { //skip ReadAnimationTable if already parsed
119+ s.at = sys.bgdef[bgnum].at
120+ } else {
121+ s.at = ReadAnimationTable(s.sff, lines, &i)
122+ }
123+ var bglink *backGround
124+ for _, bgsec := range defmap[bgname] {
125+ if len(s.bg) > 0 && s.bg[len(s.bg)-1].positionlink {
126+ bglink = s.bg[len(s.bg)-1]
127+ }
128+ s.bg = append(s.bg, readBackGround(bgsec, bglink,
129+ s.sff, s.at, 0))
130+ }
131+ bgcdef := *newBgCtrl()
132+ i = 0
133+ for i < len(lines) {
134+ is, name, _ := ReadIniSection(lines, &i)
135+ if len(name) > 0 && name[len(name)-1] == ' ' {
136+ name = name[:len(name)-1]
137+ }
138+ switch name {
139+ case bgname + "ctrldef":
140+ bgcdef.bg, bgcdef.looptime = nil, -1
141+ if ids := is.readI32CsvForStage("ctrlid"); len(ids) > 0 &&
142+ (len(ids) > 1 || ids[0] != -1) {
143+ kishutu := make(map[int32]bool)
144+ for _, id := range ids {
145+ if kishutu[id] {
146+ continue
147+ }
148+ bgcdef.bg = append(bgcdef.bg, s.getBg(id)...)
149+ kishutu[id] = true
150+ }
151+ } else {
152+ bgcdef.bg = append(bgcdef.bg, s.bg...)
153+ }
154+ is.ReadI32("looptime", &bgcdef.looptime)
155+ case bgname + "ctrl":
156+ bgc := newBgCtrl()
157+ *bgc = bgcdef
158+ if ids := is.readI32CsvForStage("ctrlid"); len(ids) > 0 {
159+ bgc.bg = nil
160+ if len(ids) > 1 || ids[0] != -1 {
161+ kishutu := make(map[int32]bool)
162+ for _, id := range ids {
163+ if kishutu[id] {
164+ continue
165+ }
166+ bgc.bg = append(bgc.bg, s.getBg(id)...)
167+ kishutu[id] = true
168+ }
169+ } else {
170+ bgc.bg = append(bgc.bg, s.bg...)
171+ }
172+ }
173+ bgc.read(is, len(s.bgc))
174+ s.bgc = append(s.bgc, *bgc)
175+ }
176+ }
177+ //s.localscl = float32(sys.gameWidth) / float32(sys.cam.localcoord[0])
178+ sys.bgdef = append(sys.bgdef, s)
179+ return len(sys.bgdef)-1, nil
180+}
181+func (s *BGDef) getBg(id int32) (bg []*backGround) {
182+ if id >= 0 {
183+ for _, b := range s.bg {
184+ if b.id == id {
185+ bg = append(bg, b)
186+ }
187+ }
188+ }
189+ return
190+}
191+func (s *BGDef) runBgCtrl(bgc *bgCtrl) {
192+ bgc.currenttime++
193+ switch bgc._type {
194+ case BT_Anim:
195+ a := s.at.get(bgc.v[0])
196+ if a != nil {
197+ for i := range bgc.bg {
198+ bgc.bg[i].actionno = bgc.v[0]
199+ bgc.bg[i].anim = *a
200+ }
201+ }
202+ case BT_Visible:
203+ for i := range bgc.bg {
204+ bgc.bg[i].visible = bgc.v[0] != 0
205+ }
206+ case BT_Enable:
207+ for i := range bgc.bg {
208+ bgc.bg[i].visible, bgc.bg[i].active = bgc.v[0] != 0, bgc.v[0] != 0
209+ }
210+ case BT_PosSet:
211+ for i := range bgc.bg {
212+ if bgc.xEnable() {
213+ bgc.bg[i].bga.pos[0] = bgc.x
214+ }
215+ if bgc.yEnable() {
216+ bgc.bg[i].bga.pos[1] = bgc.y
217+ }
218+ }
219+ if bgc.positionlink {
220+ if bgc.xEnable() {
221+ s.bga.pos[0] = bgc.x
222+ }
223+ if bgc.yEnable() {
224+ s.bga.pos[1] = bgc.y
225+ }
226+ }
227+ case BT_PosAdd:
228+ for i := range bgc.bg {
229+ if bgc.xEnable() {
230+ bgc.bg[i].bga.pos[0] += bgc.x
231+ }
232+ if bgc.yEnable() {
233+ bgc.bg[i].bga.pos[1] += bgc.y
234+ }
235+ }
236+ if bgc.positionlink {
237+ if bgc.xEnable() {
238+ s.bga.pos[0] += bgc.x
239+ }
240+ if bgc.yEnable() {
241+ s.bga.pos[1] += bgc.y
242+ }
243+ }
244+ case BT_SinX, BT_SinY:
245+ ii := Btoi(bgc._type == BT_SinY)
246+ if bgc.v[0] == 0 {
247+ bgc.v[1] = 0
248+ }
249+ a := float32(bgc.v[2]) / 360
250+ st := int32((a - float32(int32(a))) * float32(bgc.v[1]))
251+ if st < 0 {
252+ st += Abs(bgc.v[1])
253+ }
254+ for i := range bgc.bg {
255+ bgc.bg[i].bga.radius[ii] = bgc.x
256+ bgc.bg[i].bga.sinlooptime[ii] = bgc.v[1]
257+ bgc.bg[i].bga.sintime[ii] = st
258+ }
259+ if bgc.positionlink {
260+ s.bga.radius[ii] = bgc.x
261+ s.bga.sinlooptime[ii] = bgc.v[1]
262+ s.bga.sintime[ii] = st
263+ }
264+ case BT_VelSet:
265+ for i := range bgc.bg {
266+ if bgc.xEnable() {
267+ bgc.bg[i].bga.vel[0] = bgc.x
268+ }
269+ if bgc.yEnable() {
270+ bgc.bg[i].bga.vel[1] = bgc.y
271+ }
272+ }
273+ if bgc.positionlink {
274+ if bgc.xEnable() {
275+ s.bga.vel[0] = bgc.x
276+ }
277+ if bgc.yEnable() {
278+ s.bga.vel[1] = bgc.y
279+ }
280+ }
281+ case BT_VelAdd:
282+ for i := range bgc.bg {
283+ if bgc.xEnable() {
284+ bgc.bg[i].bga.vel[0] += bgc.x
285+ }
286+ if bgc.yEnable() {
287+ bgc.bg[i].bga.vel[1] += bgc.y
288+ }
289+ }
290+ if bgc.positionlink {
291+ if bgc.xEnable() {
292+ s.bga.vel[0] += bgc.x
293+ }
294+ if bgc.yEnable() {
295+ s.bga.vel[1] += bgc.y
296+ }
297+ }
298+ }
299+}
300+func (s *BGDef) action() {
301+ s.bgct.stepBGDef(s)
302+ s.bga.action()
303+ link := 0
304+ for i, b := range s.bg {
305+ s.bg[i].bga.action()
306+ if i > 0 && b.positionlink {
307+ s.bg[i].bga.offset[0] += s.bg[link].bga.sinoffset[0]
308+ s.bg[i].bga.offset[1] += s.bg[link].bga.sinoffset[1]
309+ } else {
310+ link = i
311+ }
312+ if b.active {
313+ s.bg[i].anim.Action()
314+ }
315+ }
316+}
317+func (s *BGDef) draw(top bool, x, y, scl float32) {
318+ if !top {
319+ s.action()
320+ }
321+ x, y = x/s.localscl, y/s.localscl
322+ bgscl := float32(1)
323+ pos := [...]float32{x, y}
324+ for _, b := range s.bg {
325+ if b.visible && b.toplayer == top && b.anim.spr != nil {
326+ b.draw(pos, scl, bgscl, s.localscl, s.scale, 0)
327+ }
328+ }
329+}
330+func (s *BGDef) reset() {
331+ s.bga.clear()
332+ for i := range s.bg {
333+ s.bg[i].reset()
334+ }
335+ for i := range s.bgc {
336+ s.bgc[i].currenttime = 0
337+ }
338+ s.bgct.clear()
339+ for i := len(s.bgc) - 1; i >= 0; i-- {
340+ s.bgct.add(&s.bgc[i])
341+ }
342+}
--- a/src/bytecode.go
+++ b/src/bytecode.go
@@ -319,6 +319,7 @@ const (
319319 OC_const_stagevar_info_author
320320 OC_const_stagevar_info_displayname
321321 OC_const_stagevar_info_name
322+ OC_const_gamemode
322323 )
323324 const (
324325 OC_st_var OpCode = iota + OC_var*2
@@ -1455,6 +1456,11 @@ func (be BytecodeExp) run_const(c *Char, i *int, oc *Char) {
14551456 sys.stringPool[sys.workingState.playerNo].List[*(*int32)(
14561457 unsafe.Pointer(&be[*i]))])
14571458 *i += 4
1459+ case OC_const_gamemode:
1460+ sys.bcStack.PushB(sys.gameMode ==
1461+ sys.stringPool[sys.workingState.playerNo].List[*(*int32)(
1462+ unsafe.Pointer(&be[*i]))])
1463+ *i += 4
14581464 default:
14591465 sys.errLog.Printf("%v\n", be[*i-1])
14601466 c.panic()
@@ -5141,7 +5147,7 @@ func (sc attackMulSet) Run(c *Char, _ []int32) bool {
51415147 StateControllerBase(sc).run(c, func(id byte, exp []BytecodeExp) bool {
51425148 switch id {
51435149 case attackMulSet_value:
5144- crun.attackMul = float32(crun.gi().data.attack) / 100 * exp[0].evalF(c)
5150+ crun.attackMul = float32(crun.gi().data.attack) * crun.ocd().attackRatio / 100 * exp[0].evalF(c)
51455151 case attackMulSet_redirectid:
51465152 if rid := sys.playerID(exp[0].evalI(c)); rid != nil {
51475153 crun = rid
@@ -5166,7 +5172,7 @@ func (sc defenceMulSet) Run(c *Char, _ []int32) bool {
51665172 StateControllerBase(sc).run(c, func(id byte, exp []BytecodeExp) bool {
51675173 switch id {
51685174 case defenceMulSet_value:
5169- crun.defenceMul = float32(crun.gi().data.defence) / (exp[0].evalF(c) * 100)
5175+ crun.defenceMul = float32(crun.gi().data.defence) * crun.ocd().defenceRatio / (exp[0].evalF(c) * 100)
51705176 case defenceMulSet_redirectid:
51715177 if rid := sys.playerID(exp[0].evalI(c)); rid != nil {
51725178 crun = rid
--- a/src/char.go
+++ b/src/char.go
@@ -1366,6 +1366,7 @@ const (
13661366 type CharGlobalInfo struct {
13671367 def string
13681368 displayname string
1369+ lifebarname string
13691370 author string
13701371 nameLow string
13711372 authorLow string
@@ -1633,8 +1634,8 @@ func (c *Char) clear2() {
16331634 c.CharSystemVar = CharSystemVar{bindToId: -1,
16341635 angleScalse: [...]float32{1, 1}, alpha: [...]int32{255, 0},
16351636 width: [...]float32{c.defFW(), c.defBW()},
1636- attackMul: float32(c.gi().data.attack) / 100,
1637- defenceMul: float32(c.gi().data.defence) / 100}
1637+ attackMul: float32(c.gi().data.attack) * c.ocd().attackRatio / 100,
1638+ defenceMul: float32(c.gi().data.defence) * c.ocd().defenceRatio / 100}
16381639 c.oldPos, c.drawPos = c.pos, c.pos
16391640 if c.helperIndex == 0 {
16401641 if sys.roundsExisted[c.playerNo&1] > 0 {
@@ -1656,9 +1657,18 @@ func (c *Char) gi() *CharGlobalInfo {
16561657 func (c *Char) stCgi() *CharGlobalInfo {
16571658 return &sys.cgi[c.ss.sb.playerNo]
16581659 }
1660+func (c *Char) ocd() *OverwriteCharData {
1661+ if sys.tmode[c.playerNo&1] == TM_Turns {
1662+ if c.playerNo&1 == 0 {
1663+ return &sys.ocd[c.memberNo * 2]
1664+ }
1665+ return &sys.ocd[c.memberNo * 2 + 1]
1666+ }
1667+ return &sys.ocd[c.playerNo]
1668+}
16591669 func (c *Char) load(def string) error {
16601670 gi := &sys.cgi[c.playerNo]
1661- gi.def, gi.displayname, gi.author, gi.sff, gi.snd, gi.quotes = def, "", "", nil, nil, [MaxQuotes]string{}
1671+ gi.def, gi.displayname, gi.lifebarname, gi.author, gi.sff, gi.snd, gi.quotes = def, "", "", "", nil, nil, [MaxQuotes]string{}
16621672 gi.anim = NewAnimationTable()
16631673 for i := range gi.palkeymap {
16641674 gi.palkeymap[i] = int32(i)
@@ -1686,6 +1696,10 @@ func (c *Char) load(def string) error {
16861696 if !ok {
16871697 gi.displayname = c.name
16881698 }
1699+ gi.lifebarname, ok, _ = is.getText("lifebarname")
1700+ if !ok {
1701+ gi.lifebarname = gi.displayname
1702+ }
16891703 gi.author, _, _ = is.getText("author")
16901704 gi.authorLow = strings.ToLower(gi.author)
16911705 gi.nameLow = strings.ToLower(c.name)
@@ -1805,20 +1819,9 @@ func (c *Char) load(def string) error {
18051819 case "data":
18061820 if data {
18071821 data = false
1808- var tmp int32
1809- tmp = Atoi(sys.cmdFlags[fmt.Sprintf("-p%v.life", c.playerNo+1)])
1810- if tmp != 0 {
1811- gi.data.life = tmp
1812- } else {
1813- is.ReadI32("life", &gi.data.life)
1814- }
1822+ is.ReadI32("life", &gi.data.life)
18151823 c.lifeMax = gi.data.life
1816- tmp = Atoi(sys.cmdFlags[fmt.Sprintf("-p%v.power", c.playerNo+1)])
1817- if tmp != 0 {
1818- gi.data.power = tmp
1819- } else {
1820- is.ReadI32("power", &gi.data.power)
1821- }
1824+ is.ReadI32("power", &gi.data.power)
18221825 c.powerMax = gi.data.power
18231826 is.ReadI32("attack", &gi.data.attack)
18241827 is.ReadI32("defence", &gi.data.defence)
@@ -4528,7 +4531,7 @@ func (c *Char) update(cvmin, cvmax,
45284531 if c.hittmp > 0 {
45294532 c.hittmp = 0
45304533 }
4531- c.defenceMul = float32(c.gi().data.defence) / 100
4534+ c.defenceMul = float32(c.gi().data.defence) * c.ocd().defenceRatio / 100
45324535 c.ghv.hittime = -1
45334536 c.ghv.hitshaketime = 0
45344537 c.ghv.fallf = false
--- a/src/common.go
+++ b/src/common.go
@@ -265,7 +265,10 @@ func SearchFile(file string, deffile string) string {
265265 if defdir != "data" {
266266 fp = "data/" + file
267267 if fp = FileExist(fp); len(fp) == 0 {
268- _else = true
268+ fp = sys.motifDir + file
269+ if fp = FileExist(fp); len(fp) == 0 {
270+ _else = true
271+ }
269272 }
270273 } else {
271274 _else = true
--- a/src/compiler.go
+++ b/src/compiler.go
@@ -1421,6 +1421,10 @@ func (c *Compiler) expValue(out *BytecodeExp, in *string,
14211421 out.append(OC_frontedgedist)
14221422 case "gameheight":
14231423 out.append(OC_gameheight)
1424+ case "gamemode":
1425+ if err := nameSub(OC_const_gamemode); err != nil {
1426+ return bvNone(), err
1427+ }
14241428 case "gametime":
14251429 out.append(OC_gametime)
14261430 case "gamewidth":
--- a/src/font.go
+++ b/src/font.go
@@ -51,17 +51,13 @@ func loadFnt(filename string) (*Fnt, error) {
5151
5252 func loadFntV1(filename string) (*Fnt, error) {
5353 f := newFnt()
54- fp, err := os.Open("font/" + filename)
5554
56- f.PalName = filename
55+ filename = SearchFile(filename, "font/")
5756
58- //Check file in "font/"" directory
59- if err != nil {
60- err = nil
61- fp, err = os.Open(filename)
62- }
57+ fp, err := os.Open(filename)
58+
59+ f.PalName = filename
6360
64- //Error opening file
6561 if err != nil {
6662 return nil, err
6763 }
@@ -256,15 +252,11 @@ func loadFntV1(filename string) (*Fnt, error) {
256252 func loadFntV2(filename string) (*Fnt, error) {
257253 f := newFnt()
258254
259- content, err := LoadText("font/" + filename)
255+ filename = SearchFile(filename, "font/")
260256
261- f.PalName = filename
257+ content, err := LoadText(filename)
262258
263- //Check file in "font/"" directory
264- if err != nil {
265- err = nil
266- content, err = LoadText(filename)
267- }
259+ f.PalName = filename
268260
269261 if err != nil {
270262 return nil, err
@@ -361,7 +353,7 @@ func loadFntTtf(f *Fnt, fontfile string, filename string) {
361353
362354 func loadFntSff(f *Fnt, fontfile string, filename string) {
363355 fileDir := SearchFile(filename, fontfile)
364- sff, err := loadSff("font/"+fileDir, false)
356+ sff, err := loadSff(fileDir, false)
365357
366358 if err != nil {
367359 err = nil
--- a/src/image.go
+++ b/src/image.go
@@ -13,6 +13,7 @@ import (
1313 "unsafe"
1414
1515 "github.com/go-gl/gl/v2.1/gl"
16+ "github.com/kbinani/screenshot"
1617 )
1718
1819 type TransType int32
@@ -1216,3 +1217,35 @@ func (s *Sff) getOwnPalSprite(g, n int16) *Sprite {
12161217 copy(osp.Pal, pal)
12171218 return &osp
12181219 }
1220+func captureScreen() {
1221+ var err error
1222+ var img *image.RGBA
1223+ if sys.fullscreen {
1224+ img, err = screenshot.CaptureDisplay(0)
1225+ } else {
1226+ xpos, ypos := sys.window.GetPos()
1227+ width, height := sys.window.GetSize()
1228+ bounds := image.Rect(xpos, ypos, xpos + width, ypos + height)
1229+ img, err = screenshot.CaptureRect(bounds)
1230+ }
1231+ if err != nil {
1232+ panic(err)
1233+ }
1234+ var filename string
1235+ for i := sys.captureNum; i < 999; i++ {
1236+ if i < 10 {
1237+ filename = fmt.Sprintf("ikemen00%d.png", i)
1238+ } else if i < 100 {
1239+ filename = fmt.Sprintf("ikemen0%d.png", i)
1240+ } else {
1241+ filename = fmt.Sprintf("ikemen%d.png", i)
1242+ }
1243+ if _, err := os.Stat(filename); os.IsNotExist(err) {
1244+ file, _ := os.Create(filename)
1245+ defer file.Close()
1246+ png.Encode(file, img)
1247+ sys.captureNum = i
1248+ break
1249+ }
1250+ }
1251+}
--- a/src/input.go
+++ b/src/input.go
@@ -599,6 +599,9 @@ func keyCallback(_ *glfw.Window, key glfw.Key, _ int,
599599 for k, v := range sys.shortcutScripts {
600600 v.Activate = v.Activate || k.Test(key, mk)
601601 }
602+ if key == glfw.KeyF12 {
603+ captureScreen()
604+ }
602605 }
603606 }
604607 func charCallback(_ *glfw.Window, char rune, mk glfw.ModifierKey) {
@@ -628,12 +631,12 @@ func JoystickState(joy, button int) bool {
628631 }
629632
630633 //Xbox360コントローラーのLRトリガー判定
631- if (button == 9 || button == 11) && (joystick[joy].GetGamepadName() == "Xbox 360 Controller" || strings.Contains(joystick[joy].GetGamepadName(), "XInput")) {
634+ if (button == 9 || button == 11) && strings.Contains(joystick[joy].GetGamepadName(), "XInput") {
632635 return axes[button/2] > sys.xinputTriggerSensitivity
633636 }
634637
635638 // Ignore trigger axis on PS4 (We already have buttons)
636- if (button >= 6 && button <= 9) && joystick[joy].GetGamepadName() == "Wireless Controller" {
639+ if (button >= 6 && button <= 9) && joystick[joy].GetGamepadName() == "PS4 Controller" {
637640 return false
638641 }
639642
--- a/src/lifebar.go
+++ b/src/lifebar.go
@@ -39,6 +39,14 @@ const (
3939 WT_PTeammate
4040 )
4141
42+type RoundType int32
43+
44+const (
45+ RT_Normal RoundType = iota
46+ RT_Deciding
47+ RT_Final
48+)
49+
4250 func (wt *WinType) SetPerfect() {
4351 if *wt >= WT_N && *wt <= WT_Teammate {
4452 *wt += WT_PN - WT_N
@@ -183,8 +191,11 @@ func readPowerBar(pre string, is IniSection,
183191 &pb.counter_font[2])
184192 pb.counter_lay = *ReadLayout(pre+"counter.", is, 0)
185193 for i := range pb.level_snd {
186- is.ReadI32(fmt.Sprintf("%vlevel%v.snd", pre, i+1), &pb.level_snd[i][0],
187- &pb.level_snd[i][1])
194+ if !is.ReadI32(fmt.Sprintf("%vlevel%v.snd", pre, i+1), &pb.level_snd[i][0],
195+ &pb.level_snd[i][1]) {
196+ is.ReadI32(fmt.Sprintf("level%v.snd", i+1), &pb.level_snd[i][0],
197+ &pb.level_snd[i][1])
198+ }
188199 }
189200 return pb
190201 }
@@ -721,6 +732,9 @@ type LifeBarRound struct {
721732 ko_time int32
722733 ko_sndtime int32
723734 ko, dko, to AnimTextSnd
735+ n, s, h, throw, c AnimTextSnd
736+ t, suicide AnimTextSnd
737+ teammate, perfect AnimTextSnd
724738 slow_time int32
725739 over_waittime int32
726740 over_hittime int32
@@ -746,12 +760,7 @@ func readLifeBarRound(is IniSection,
746760 r := newLifeBarRound(snd, fnt)
747761 var tmp int32
748762 is.ReadI32("pos", &r.pos[0], &r.pos[1])
749- tmp = Atoi(sys.cmdFlags["-rounds"])
750- if tmp > 0 {
751- r.match_wins = tmp
752- } else {
753- is.ReadI32("match.wins", &r.match_wins)
754- }
763+ is.ReadI32("match.wins", &r.match_wins)
755764 is.ReadI32("match.maxdrawgames", &r.match_maxdrawgames)
756765 if is.ReadI32("start.waittime", &tmp) {
757766 r.start_waittime = Max(1, tmp)
@@ -774,6 +783,15 @@ func readLifeBarRound(is IniSection,
774783 r.ko = *ReadAnimTextSnd("ko.", is, sff, at, 1)
775784 r.dko = *ReadAnimTextSnd("dko.", is, sff, at, 1)
776785 r.to = *ReadAnimTextSnd("to.", is, sff, at, 1)
786+ r.n = *ReadAnimTextSnd("n.", is, sff, at, 1)
787+ r.s = *ReadAnimTextSnd("s.", is, sff, at, 1)
788+ r.h = *ReadAnimTextSnd("h.", is, sff, at, 1)
789+ r.throw = *ReadAnimTextSnd("throw.", is, sff, at, 1)
790+ r.c = *ReadAnimTextSnd("c.", is, sff, at, 1)
791+ r.t = *ReadAnimTextSnd("t.", is, sff, at, 1)
792+ r.suicide = *ReadAnimTextSnd("suicide.", is, sff, at, 1)
793+ r.teammate = *ReadAnimTextSnd("teammate.", is, sff, at, 1)
794+ r.perfect = *ReadAnimTextSnd("perfect.", is, sff, at, 1)
777795 is.ReadI32("slow.time", &r.slow_time)
778796 if is.ReadI32("over.hittime", &tmp) {
779797 r.over_hittime = Max(0, tmp)
@@ -884,6 +902,29 @@ func (r *LifeBarRound) act() bool {
884902 default:
885903 f(&r.to, 0)
886904 }
905+ if sys.winTeam >= 0 {
906+ switch sys.winType[sys.winTeam] {
907+ case WT_N, WT_PN:
908+ f(&r.n, 0)
909+ case WT_S, WT_PS:
910+ f(&r.s, 0)
911+ case WT_H, WT_PH:
912+ f(&r.h, 0)
913+ case WT_C, WT_PC:
914+ f(&r.c, 0)
915+ case WT_T, WT_PT:
916+ f(&r.t, 0)
917+ case WT_Throw, WT_PThrow:
918+ f(&r.throw, 0)
919+ case WT_Suicide, WT_PSuicide:
920+ f(&r.suicide, 0)
921+ case WT_Teammate, WT_PTeammate:
922+ f(&r.teammate, 0)
923+ }
924+ if sys.winType[sys.winTeam] >= WT_Perfect {
925+ f(&r.perfect, 0)
926+ }
927+ }
887928 if sys.intro < -(r.over_hittime + r.over_waittime + r.over_wintime) {
888929 if sys.finish == FT_DKO || sys.finish == FT_TODraw {
889930 f(&r.drawn, 1)
@@ -905,6 +946,15 @@ func (r *LifeBarRound) reset() {
905946 r.ko.Reset()
906947 r.dko.Reset()
907948 r.to.Reset()
949+ r.n.Reset()
950+ r.s.Reset()
951+ r.h.Reset()
952+ r.throw.Reset()
953+ r.c.Reset()
954+ r.t.Reset()
955+ r.suicide.Reset()
956+ r.teammate.Reset()
957+ r.perfect.Reset()
908958 r.win.Reset()
909959 r.win2.Reset()
910960 r.drawn.Reset()
@@ -965,23 +1015,111 @@ func (r *LifeBarRound) draw(layerno int16) {
9651015 r.win.text = tmp
9661016 }
9671017 }
1018+
1019+
1020+ if (sys.finish != FT_NotYet || sys.time == 0) && sys.winTeam >= 0 {
1021+ switch sys.winType[sys.winTeam] {
1022+ case WT_N, WT_PN:
1023+ r.n.DrawScaled(float32(r.pos[0])+sys.lifebarOffsetX, float32(r.pos[1]), layerno, r.fnt, sys.lifebarScale)
1024+ case WT_S, WT_PS:
1025+ r.s.DrawScaled(float32(r.pos[0])+sys.lifebarOffsetX, float32(r.pos[1]), layerno, r.fnt, sys.lifebarScale)
1026+ case WT_H, WT_PH:
1027+ r.h.DrawScaled(float32(r.pos[0])+sys.lifebarOffsetX, float32(r.pos[1]), layerno, r.fnt, sys.lifebarScale)
1028+ case WT_C, WT_PC:
1029+ r.c.DrawScaled(float32(r.pos[0])+sys.lifebarOffsetX, float32(r.pos[1]), layerno, r.fnt, sys.lifebarScale)
1030+ case WT_T, WT_PT:
1031+ r.t.DrawScaled(float32(r.pos[0])+sys.lifebarOffsetX, float32(r.pos[1]), layerno, r.fnt, sys.lifebarScale)
1032+ case WT_Throw, WT_PThrow:
1033+ r.throw.DrawScaled(float32(r.pos[0])+sys.lifebarOffsetX, float32(r.pos[1]), layerno, r.fnt, sys.lifebarScale)
1034+ case WT_Suicide, WT_PSuicide:
1035+ r.suicide.DrawScaled(float32(r.pos[0])+sys.lifebarOffsetX, float32(r.pos[1]), layerno, r.fnt, sys.lifebarScale)
1036+ case WT_Teammate, WT_PTeammate:
1037+ r.teammate.DrawScaled(float32(r.pos[0])+sys.lifebarOffsetX, float32(r.pos[1]), layerno, r.fnt, sys.lifebarScale)
1038+ }
1039+ if sys.winType[sys.winTeam] >= WT_Perfect {
1040+ r.perfect.DrawScaled(float32(r.pos[0])+sys.lifebarOffsetX, float32(r.pos[1]), layerno, r.fnt, sys.lifebarScale)
1041+ }
1042+ }
1043+
1044+
9681045 }
9691046 sys.brightness = ob
9701047 }
9711048
1049+type LifeBarChallenger struct {
1050+ cnt int32
1051+ snd *Snd
1052+ pos [2]int32
1053+ challenger AnimTextSnd
1054+ sndtime int32
1055+ over_pause int32
1056+ over_time int32
1057+ bg AnimLayout
1058+ fnt []*Fnt
1059+}
1060+
1061+func newLifeBarChallenger(snd *Snd, fnt []*Fnt) *LifeBarChallenger {
1062+ return &LifeBarChallenger{snd: snd, fnt: fnt}
1063+}
1064+func readLifeBarChallenger(is IniSection,
1065+ sff *Sff, at AnimationTable, snd *Snd, fnt []*Fnt) *LifeBarChallenger {
1066+ ch := newLifeBarChallenger(snd, fnt)
1067+ is.ReadI32("pos", &ch.pos[0], &ch.pos[1])
1068+ ch.challenger = *ReadAnimTextSnd("", is, sff, at, 1)
1069+ is.ReadI32("sndtime", &ch.sndtime)
1070+ var tmp int32
1071+ if is.ReadI32("over.pause", &tmp) {
1072+ ch.over_pause = Max(1, tmp)
1073+ }
1074+ if is.ReadI32("over.time", &tmp) {
1075+ ch.over_time = Max(ch.over_pause+1, tmp)
1076+ }
1077+ ch.bg = *ReadAnimLayout("bg.", is, sff, at, 0)
1078+ return ch
1079+}
1080+func (ch *LifeBarChallenger) step() {
1081+ if sys.challenger > 0 {
1082+ if ch.cnt == ch.sndtime {
1083+ ch.snd.play(ch.challenger.snd)
1084+ }
1085+ if ch.cnt == ch.over_pause {
1086+ sys.paused = true
1087+ }
1088+ if ch.challenger.displaytime > ch.cnt {
1089+ ch.challenger.Action()
1090+ ch.bg.Action()
1091+ }
1092+ ch.cnt += 1
1093+ }
1094+}
1095+func (ch *LifeBarChallenger) reset() {
1096+ ch.cnt = 0
1097+ ch.challenger.Reset()
1098+ ch.bg.Reset()
1099+}
1100+func (ch *LifeBarChallenger) bgDraw(layerno int16) {
1101+ ch.bg.Draw(float32(ch.pos[0]), float32(ch.pos[1]), layerno)
1102+}
1103+func (ch *LifeBarChallenger) draw(layerno int16, f []*Fnt) {
1104+ ch.challenger.Draw(float32(ch.pos[0]), float32(ch.pos[1]), layerno, ch.fnt)
1105+}
1106+
9721107 type Lifebar struct {
9731108 fat AnimationTable
9741109 fsff *Sff
9751110 snd, fsnd *Snd
9761111 fnt [10]*Fnt
977- hb [4][]*HealthBar
978- pb [2]*PowerBar
1112+ ref [4][2]int
1113+ num [4][2]int
1114+ hb [8][]*HealthBar
1115+ pb [6][]*PowerBar
9791116 fa [4][]*LifeBarFace
9801117 nm [4][]*LifeBarName
9811118 wi [2]*LifeBarWinIcon
9821119 ti *LifeBarTime
9831120 co *LifeBarCombo
9841121 ro *LifeBarRound
1122+ ch *LifeBarChallenger
9851123 }
9861124
9871125 func loadLifebar(deffile string) (*Lifebar, error) {
@@ -991,11 +1129,29 @@ func loadLifebar(deffile string) (*Lifebar, error) {
9911129 }
9921130 l := &Lifebar{fsff: &Sff{}, snd: &Snd{},
9931131 hb: [...][]*HealthBar{make([]*HealthBar, 2), make([]*HealthBar, 4),
994- make([]*HealthBar, 2), make([]*HealthBar, 4)},
995- fa: [...][]*LifeBarFace{make([]*LifeBarFace, 2), make([]*LifeBarFace, 4),
996- make([]*LifeBarFace, 2), make([]*LifeBarFace, 4)},
997- nm: [...][]*LifeBarName{make([]*LifeBarName, 2), make([]*LifeBarName, 4),
998- make([]*LifeBarName, 2), make([]*LifeBarName, 4)}}
1132+ make([]*HealthBar, 2), make([]*HealthBar, 4), make([]*HealthBar, 6),
1133+ make([]*HealthBar, 8), make([]*HealthBar, 6), make([]*HealthBar, 8)},
1134+ pb: [...][]*PowerBar{make([]*PowerBar, 2), make([]*PowerBar, 4),
1135+ make([]*PowerBar, 2), make([]*PowerBar, 2), make([]*PowerBar, 6),
1136+ make([]*PowerBar, 8)},
1137+ fa: [...][]*LifeBarFace{make([]*LifeBarFace, 2), make([]*LifeBarFace, 8),
1138+ make([]*LifeBarFace, 2), make([]*LifeBarFace, 8)},
1139+ nm: [...][]*LifeBarName{make([]*LifeBarName, 2), make([]*LifeBarName, 8),
1140+ make([]*LifeBarName, 2), make([]*LifeBarName, 8)}}
1141+ missing := map[string]int{"[simul_3p lifebar]": 3, "[simul_4p lifebar]": 4,
1142+ "[tag lifebar]": 5, "[tag_3p lifebar]": 6, "[tag_4p lifebar]": 7,
1143+ "[simul powerbar]": 1, "[turns powerbar]": 2, "[simul_3p powerbar]": 3,
1144+ "[simul_4p powerbar]": 4, "[tag powerbar]": 5, "[tag face]": -1,
1145+ "[tag name]": -1, "[challenger]": -1}
1146+ strc := strings.ToLower(strings.TrimSpace(str))
1147+ for k, _ := range missing {
1148+ strc = strings.Replace(strc, ";" + k, "", -1)
1149+ if strings.Contains(strc, k) {
1150+ delete(missing, k)
1151+ } else {
1152+ str += "\n" + k
1153+ }
1154+ }
9991155 sff, lines, i := &Sff{}, SplitAndTrim(str, "\n"), 0
10001156 at := ReadAnimationTable(sff, lines, &i)
10011157 i = 0
@@ -1056,6 +1212,11 @@ func loadLifebar(deffile string) (*Lifebar, error) {
10561212 for i := range l.fnt {
10571213 if is.LoadFile(fmt.Sprintf("font%v", i), deffile,
10581214 func(filename string) error {
1215+ //h := int32(0)
1216+ //if len(is[fmt.Sprintf("font%v.height", i)]) > 0 {
1217+ // h = Atoi(is[fmt.Sprintf("font%v.height", i)])
1218+ //}
1219+ //l.fnt[i], err = loadFnt(filename, h)
10591220 l.fnt[i], err = loadFnt(filename)
10601221 return err
10611222 }); err != nil {
@@ -1073,11 +1234,11 @@ func loadLifebar(deffile string) (*Lifebar, error) {
10731234 l.hb[0][1] = readHealthBar("p2.", is, sff, at)
10741235 }
10751236 case "powerbar":
1076- if l.pb[0] == nil {
1077- l.pb[0] = readPowerBar("p1.", is, sff, at, l.snd)
1237+ if l.pb[0][0] == nil {
1238+ l.pb[0][0] = readPowerBar("p1.", is, sff, at, l.snd)
10781239 }
1079- if l.pb[1] == nil {
1080- l.pb[1] = readPowerBar("p2.", is, sff, at, l.snd)
1240+ if l.pb[0][1] == nil {
1241+ l.pb[0][1] = readPowerBar("p2.", is, sff, at, l.snd)
10811242 }
10821243 case "face":
10831244 if l.fa[0][0] == nil {
@@ -1093,49 +1254,6 @@ func loadLifebar(deffile string) (*Lifebar, error) {
10931254 if l.nm[0][1] == nil {
10941255 l.nm[0][1] = readLifeBarName("p2.", is, sff, at)
10951256 }
1096- case "tag ":
1097- subname = strings.ToLower(subname)
1098- switch {
1099- case len(subname) >= 7 && subname[:7] == "lifebar":
1100- if l.hb[3][0] == nil {
1101- l.hb[3][0] = readHealthBar("p1.", is, sff, at)
1102- }
1103- if l.hb[3][1] == nil {
1104- l.hb[3][1] = readHealthBar("p2.", is, sff, at)
1105- }
1106- if l.hb[3][2] == nil {
1107- l.hb[3][2] = readHealthBar("p3.", is, sff, at)
1108- }
1109- if l.hb[3][3] == nil {
1110- l.hb[3][3] = readHealthBar("p4.", is, sff, at)
1111- }
1112- case len(subname) >= 4 && subname[:4] == "face":
1113- if l.fa[3][0] == nil {
1114- l.fa[3][0] = readLifeBarFace("p1.", is, sff, at)
1115- }
1116- if l.fa[3][1] == nil {
1117- l.fa[3][1] = readLifeBarFace("p2.", is, sff, at)
1118- }
1119- if l.fa[3][2] == nil {
1120- l.fa[3][2] = readLifeBarFace("p3.", is, sff, at)
1121- }
1122- if l.fa[3][3] == nil {
1123- l.fa[3][3] = readLifeBarFace("p4.", is, sff, at)
1124- }
1125- case len(subname) >= 4 && subname[:4] == "name":
1126- if l.nm[3][0] == nil {
1127- l.nm[3][0] = readLifeBarName("p1.", is, sff, at)
1128- }
1129- if l.nm[3][1] == nil {
1130- l.nm[3][1] = readLifeBarName("p2.", is, sff, at)
1131- }
1132- if l.nm[3][2] == nil {
1133- l.nm[3][2] = readLifeBarName("p3.", is, sff, at)
1134- }
1135- if l.nm[3][3] == nil {
1136- l.nm[3][3] = readLifeBarName("p4.", is, sff, at)
1137- }
1138- }
11391257 case "simul ":
11401258 subname = strings.ToLower(subname)
11411259 switch {
@@ -1152,6 +1270,19 @@ func loadLifebar(deffile string) (*Lifebar, error) {
11521270 if l.hb[1][3] == nil {
11531271 l.hb[1][3] = readHealthBar("p4.", is, sff, at)
11541272 }
1273+ case len(subname) >= 8 && subname[:8] == "powerbar":
1274+ if l.pb[1][0] == nil {
1275+ l.pb[1][0] = readPowerBar("p1.", is, sff, at, l.snd)
1276+ }
1277+ if l.pb[1][1] == nil {
1278+ l.pb[1][1] = readPowerBar("p2.", is, sff, at, l.snd)
1279+ }
1280+ if l.pb[1][2] == nil {
1281+ l.pb[1][2] = readPowerBar("p3.", is, sff, at, l.snd)
1282+ }
1283+ if l.pb[1][3] == nil {
1284+ l.pb[1][3] = readPowerBar("p4.", is, sff, at, l.snd)
1285+ }
11551286 case len(subname) >= 4 && subname[:4] == "face":
11561287 if l.fa[1][0] == nil {
11571288 l.fa[1][0] = readLifeBarFace("p1.", is, sff, at)
@@ -1165,6 +1296,18 @@ func loadLifebar(deffile string) (*Lifebar, error) {
11651296 if l.fa[1][3] == nil {
11661297 l.fa[1][3] = readLifeBarFace("p4.", is, sff, at)
11671298 }
1299+ if l.fa[1][4] == nil {
1300+ l.fa[1][4] = readLifeBarFace("p5.", is, sff, at)
1301+ }
1302+ if l.fa[1][5] == nil {
1303+ l.fa[1][5] = readLifeBarFace("p6.", is, sff, at)
1304+ }
1305+ if l.fa[1][6] == nil {
1306+ l.fa[1][6] = readLifeBarFace("p7.", is, sff, at)
1307+ }
1308+ if l.fa[1][7] == nil {
1309+ l.fa[1][7] = readLifeBarFace("p8.", is, sff, at)
1310+ }
11681311 case len(subname) >= 4 && subname[:4] == "name":
11691312 if l.nm[1][0] == nil {
11701313 l.nm[1][0] = readLifeBarName("p1.", is, sff, at)
@@ -1178,6 +1321,18 @@ func loadLifebar(deffile string) (*Lifebar, error) {
11781321 if l.nm[1][3] == nil {
11791322 l.nm[1][3] = readLifeBarName("p4.", is, sff, at)
11801323 }
1324+ if l.nm[1][4] == nil {
1325+ l.nm[1][4] = readLifeBarName("p5.", is, sff, at)
1326+ }
1327+ if l.nm[1][5] == nil {
1328+ l.nm[1][5] = readLifeBarName("p6.", is, sff, at)
1329+ }
1330+ if l.nm[1][6] == nil {
1331+ l.nm[1][6] = readLifeBarName("p7.", is, sff, at)
1332+ }
1333+ if l.nm[1][7] == nil {
1334+ l.nm[1][7] = readLifeBarName("p8.", is, sff, at)
1335+ }
11811336 }
11821337 case "turns ":
11831338 subname = strings.ToLower(subname)
@@ -1189,6 +1344,13 @@ func loadLifebar(deffile string) (*Lifebar, error) {
11891344 if l.hb[2][1] == nil {
11901345 l.hb[2][1] = readHealthBar("p2.", is, sff, at)
11911346 }
1347+ case len(subname) >= 8 && subname[:8] == "powerbar":
1348+ if l.pb[2][0] == nil {
1349+ l.pb[2][0] = readPowerBar("p1.", is, sff, at, l.snd)
1350+ }
1351+ if l.pb[2][1] == nil {
1352+ l.pb[2][1] = readPowerBar("p2.", is, sff, at, l.snd)
1353+ }
11921354 case len(subname) >= 4 && subname[:4] == "face":
11931355 if l.fa[2][0] == nil {
11941356 l.fa[2][0] = readLifeBarFace("p1.", is, sff, at)
@@ -1204,33 +1366,7 @@ func loadLifebar(deffile string) (*Lifebar, error) {
12041366 l.nm[2][1] = readLifeBarName("p2.", is, sff, at)
12051367 }
12061368 }
1207- case "winicon":
1208- if l.wi[0] == nil {
1209- l.wi[0] = readLifeBarWinIcon("p1.", is, sff, at)
1210- }
1211- if l.wi[1] == nil {
1212- l.wi[1] = readLifeBarWinIcon("p2.", is, sff, at)
1213- }
1214- case "time":
1215- if l.ti == nil {
1216- l.ti = readLifeBarTime(is, sff, at)
1217- }
1218- case "combo":
1219- if l.co == nil {
1220- l.co = readLifeBarCombo(is)
1221- }
1222- case "round":
1223- if l.ro == nil {
1224- l.ro = readLifeBarRound(is, sff, at, l.snd, l.fnt[:])
1225- }
1226- }
1227- }
1228- i = 0
1229- //Load again to fill empty spaces of TAG (For retrocompatibility)
1230- for i < len(lines) {
1231- is, name, subname := ReadIniSection(lines, &i)
1232- switch name {
1233- case "simul ":
1369+ case "tag ":
12341370 subname = strings.ToLower(subname)
12351371 switch {
12361372 case len(subname) >= 7 && subname[:7] == "lifebar":
@@ -1246,6 +1382,13 @@ func loadLifebar(deffile string) (*Lifebar, error) {
12461382 if l.hb[3][3] == nil {
12471383 l.hb[3][3] = readHealthBar("p4.", is, sff, at)
12481384 }
1385+ case len(subname) >= 8 && subname[:8] == "powerbar":
1386+ if l.pb[3][0] == nil {
1387+ l.pb[3][0] = readPowerBar("p1.", is, sff, at, l.snd)
1388+ }
1389+ if l.pb[3][1] == nil {
1390+ l.pb[3][1] = readPowerBar("p2.", is, sff, at, l.snd)
1391+ }
12491392 case len(subname) >= 4 && subname[:4] == "face":
12501393 if l.fa[3][0] == nil {
12511394 l.fa[3][0] = readLifeBarFace("p1.", is, sff, at)
@@ -1259,6 +1402,18 @@ func loadLifebar(deffile string) (*Lifebar, error) {
12591402 if l.fa[3][3] == nil {
12601403 l.fa[3][3] = readLifeBarFace("p4.", is, sff, at)
12611404 }
1405+ if l.fa[3][4] == nil {
1406+ l.fa[3][4] = readLifeBarFace("p5.", is, sff, at)
1407+ }
1408+ if l.fa[3][5] == nil {
1409+ l.fa[3][5] = readLifeBarFace("p6.", is, sff, at)
1410+ }
1411+ if l.fa[3][6] == nil {
1412+ l.fa[3][6] = readLifeBarFace("p7.", is, sff, at)
1413+ }
1414+ if l.fa[3][7] == nil {
1415+ l.fa[3][7] = readLifeBarFace("p8.", is, sff, at)
1416+ }
12621417 case len(subname) >= 4 && subname[:4] == "name":
12631418 if l.nm[3][0] == nil {
12641419 l.nm[3][0] = readLifeBarName("p1.", is, sff, at)
@@ -1272,36 +1427,163 @@ func loadLifebar(deffile string) (*Lifebar, error) {
12721427 if l.nm[3][3] == nil {
12731428 l.nm[3][3] = readLifeBarName("p4.", is, sff, at)
12741429 }
1430+ if l.nm[3][4] == nil {
1431+ l.nm[3][4] = readLifeBarName("p5.", is, sff, at)
1432+ }
1433+ if l.nm[3][5] == nil {
1434+ l.nm[3][5] = readLifeBarName("p6.", is, sff, at)
1435+ }
1436+ if l.nm[3][6] == nil {
1437+ l.nm[3][6] = readLifeBarName("p7.", is, sff, at)
1438+ }
1439+ if l.nm[3][7] == nil {
1440+ l.nm[3][7] = readLifeBarName("p8.", is, sff, at)
1441+ }
1442+ }
1443+ case "simul_3p ", "simul_4p ", "tag_3p ", "tag_4p ":
1444+ i := 4
1445+ switch name {
1446+ case "simul_4p ":
1447+ i = 5
1448+ case "tag_3p ":
1449+ i = 6
1450+ case "tag_4p ":
1451+ i = 7
1452+ }
1453+ subname = strings.ToLower(subname)
1454+ switch {
1455+ case len(subname) >= 7 && subname[:7] == "lifebar":
1456+ if l.hb[i][0] == nil {
1457+ l.hb[i][0] = readHealthBar("p1.", is, sff, at)
1458+ }
1459+ if l.hb[i][1] == nil {
1460+ l.hb[i][1] = readHealthBar("p2.", is, sff, at)
1461+ }
1462+ if l.hb[i][2] == nil {
1463+ l.hb[i][2] = readHealthBar("p3.", is, sff, at)
1464+ }
1465+ if l.hb[i][3] == nil {
1466+ l.hb[i][3] = readHealthBar("p4.", is, sff, at)
1467+ }
1468+ if l.hb[i][4] == nil {
1469+ l.hb[i][4] = readHealthBar("p5.", is, sff, at)
1470+ }
1471+ if l.hb[i][5] == nil {
1472+ l.hb[i][5] = readHealthBar("p6.", is, sff, at)
1473+ }
1474+ if i == 5 || i == 7 {
1475+ if l.hb[i][6] == nil {
1476+ l.hb[i][6] = readHealthBar("p7.", is, sff, at)
1477+ }
1478+ if l.hb[i][7] == nil {
1479+ l.hb[i][7] = readHealthBar("p8.", is, sff, at)
1480+ }
1481+ }
1482+ case len(subname) >= 8 && subname[:8] == "powerbar":
1483+ if l.pb[i][0] == nil {
1484+ l.pb[i][0] = readPowerBar("p1.", is, sff, at, l.snd)
1485+ }
1486+ if l.pb[i][1] == nil {
1487+ l.pb[i][1] = readPowerBar("p2.", is, sff, at, l.snd)
1488+ }
1489+ if l.pb[i][2] == nil {
1490+ l.pb[i][2] = readPowerBar("p3.", is, sff, at, l.snd)
1491+ }
1492+ if l.pb[i][3] == nil {
1493+ l.pb[i][3] = readPowerBar("p4.", is, sff, at, l.snd)
1494+ }
1495+ if l.pb[i][4] == nil {
1496+ l.pb[i][4] = readPowerBar("p5.", is, sff, at, l.snd)
1497+ }
1498+ if l.pb[i][5] == nil {
1499+ l.pb[i][5] = readPowerBar("p6.", is, sff, at, l.snd)
1500+ }
1501+ if i == 5 || i == 7 {
1502+ if l.pb[i][6] == nil {
1503+ l.pb[i][6] = readPowerBar("p7.", is, sff, at, l.snd)
1504+ }
1505+ if l.pb[i][7] == nil {
1506+ l.pb[i][7] = readPowerBar("p8.", is, sff, at, l.snd)
1507+ }
1508+ }
1509+ }
1510+ case "winicon":
1511+ if l.wi[0] == nil {
1512+ l.wi[0] = readLifeBarWinIcon("p1.", is, sff, at)
1513+ }
1514+ if l.wi[1] == nil {
1515+ l.wi[1] = readLifeBarWinIcon("p2.", is, sff, at)
1516+ }
1517+ case "time":
1518+ if l.ti == nil {
1519+ l.ti = readLifeBarTime(is, sff, at)
1520+ }
1521+ case "combo":
1522+ if l.co == nil {
1523+ l.co = readLifeBarCombo(is)
1524+ }
1525+ case "round":
1526+ if l.ro == nil {
1527+ l.ro = readLifeBarRound(is, sff, at, l.snd, l.fnt[:])
1528+ }
1529+ case "challenger":
1530+ if l.ch == nil {
1531+ l.ch = readLifeBarChallenger(is, sff, at, l.snd, l.fnt[:])
1532+ }
1533+ }
1534+ }
1535+ for k, v := range missing {
1536+ if strings.Contains(k, "lifebar") {
1537+ for i := 3; i < len(l.hb); i++ {
1538+ if i == v {
1539+ for j, d := range l.hb[1] {
1540+ l.hb[i][j] = d
1541+ }
1542+ }
1543+ }
1544+ } else if strings.Contains(k, "powerbar") {
1545+ for i := 1; i < len(l.pb); i++ {
1546+ if i == v {
1547+ for j, d := range l.pb[0] {
1548+ l.pb[i][j] = d
1549+ }
1550+ }
1551+ }
1552+ } else if strings.Contains(k, "tag face") {
1553+ for j, d := range l.fa[1] {
1554+ l.fa[3][j] = d
1555+ }
1556+ } else if strings.Contains(k, "tag name") {
1557+ for j, d := range l.nm[1] {
1558+ l.nm[3][j] = d
12751559 }
12761560 }
12771561 }
12781562 return l, nil
12791563 }
12801564 func (l *Lifebar) step() {
1281- for ti, tm := range sys.tmode {
1282- for i := ti; i < len(l.hb[tm]); i += 2 {
1283- l.hb[tm][i].step(float32(sys.chars[i][0].life)/
1565+ for ti, _ := range sys.tmode {
1566+ for i := ti; i < l.num[0][ti]; i += 2 {
1567+ l.hb[l.ref[0][ti]][i].step(float32(sys.chars[i][0].life)/
12841568 float32(sys.chars[i][0].lifeMax), (sys.chars[i][0].getcombo != 0 ||
12851569 sys.chars[i][0].ss.moveType == MT_H) &&
12861570 !sys.chars[i][0].scf(SCF_over))
12871571 }
12881572 }
1289- for i := range l.pb {
1290- lvi := i
1291- if sys.tmode[i] == TM_Simul || sys.tmode[i] == TM_Tag {
1292- lvi += 2
1573+ for ti, _ := range sys.tmode {
1574+ for i := ti; i < l.num[1][ti]; i += 2 {
1575+ l.pb[l.ref[1][ti]][i].step(float32(sys.chars[i][0].power)/
1576+ float32(sys.chars[i][0].powerMax), sys.chars[i][0].power/1000)
12931577 }
1294- l.pb[i].step(float32(sys.chars[i][0].power)/
1295- float32(sys.chars[i][0].powerMax), sys.chars[lvi][0].power/1000)
12961578 }
1297- for ti, tm := range sys.tmode {
1298- for i := ti; i < len(l.fa[tm]); i += 2 {
1299- l.fa[tm][i].step()
1579+ for ti, _ := range sys.tmode {
1580+ for i := ti; i < l.num[2][ti]; i += 2 {
1581+ l.fa[l.ref[2][ti]][i].step()
13001582 }
13011583 }
1302- for ti, tm := range sys.tmode {
1303- for i := ti; i < len(l.nm[tm]); i += 2 {
1304- l.nm[tm][i].step()
1584+ for ti, _ := range sys.tmode {
1585+ for i := ti; i < l.num[3][ti]; i += 2 {
1586+ l.nm[l.ref[3][ti]][i].step()
13051587 }
13061588 }
13071589 for i := range l.wi {
@@ -1315,15 +1597,54 @@ func (l *Lifebar) step() {
13151597 }
13161598 }
13171599 l.co.step(cb)
1600+ l.ch.step()
13181601 }
13191602 func (l *Lifebar) reset() {
1603+ for ti, tm := range sys.tmode {
1604+ l.ref[0][ti] = int(tm)
1605+ l.ref[1][ti] = int(tm)
1606+ l.ref[2][ti] = int(tm)
1607+ l.ref[3][ti] = int(tm)
1608+ if tm == TM_Tag {
1609+ if sys.numSimul[ti] == 2 { //Tag 2P
1610+ l.ref[0][ti] = 3
1611+ l.ref[1][ti] = 3
1612+ l.ref[2][ti] = 3
1613+ l.ref[3][ti] = 3
1614+ } else { //Tag 3P/4P
1615+ l.ref[0][ti] = int(sys.numSimul[ti]) + 3
1616+ l.ref[1][ti] = 3
1617+ l.ref[2][ti] = 3
1618+ l.ref[3][ti] = 3
1619+ }
1620+ } else if tm == TM_Simul && sys.numSimul[ti] > 2 { //Simul 3P/4P
1621+ l.ref[0][ti] = int(sys.numSimul[ti]) + 1
1622+ l.ref[1][ti] = int(sys.numSimul[ti]) + 1
1623+ }
1624+ l.num[0][ti] = len(l.hb[l.ref[0][ti]])
1625+ l.num[1][ti] = len(l.pb[l.ref[1][ti]])
1626+ l.num[2][ti] = len(l.fa[l.ref[2][ti]])
1627+ l.num[3][ti] = len(l.nm[l.ref[3][ti]])
1628+ if tm == TM_Simul || tm == TM_Tag {
1629+ l.num[0][ti] = int(sys.numSimul[ti]) * 2
1630+ if sys.powerShare[ti] {
1631+ l.num[1][ti] = 2
1632+ } else if tm == TM_Simul {
1633+ l.num[1][ti] = int(sys.numSimul[ti]) * 2
1634+ }
1635+ l.num[2][ti] = int(sys.numSimul[ti]) * 2
1636+ l.num[3][ti] = int(sys.numSimul[ti]) * 2
1637+ }
1638+ }
13201639 for _, hb := range l.hb {
13211640 for i := range hb {
13221641 hb[i].reset()
13231642 }
13241643 }
1325- for i := range l.pb {
1326- l.pb[i].reset()
1644+ for _, pb := range l.pb {
1645+ for i := range pb {
1646+ pb[i].reset()
1647+ }
13271648 }
13281649 for _, fa := range l.fa {
13291650 for i := range fa {
@@ -1341,56 +1662,61 @@ func (l *Lifebar) reset() {
13411662 l.ti.reset()
13421663 l.co.reset()
13431664 l.ro.reset()
1665+ l.ch.reset()
13441666 }
13451667 func (l *Lifebar) draw(layerno int16) {
13461668 if !sys.statusDraw {
13471669 return
13481670 }
1349- if !sys.sf(GSF_nobardisplay) {
1350- for ti, tm := range sys.tmode {
1351- for i := ti; i < len(l.hb[tm]); i += 2 {
1352- l.hb[tm][i].bgDraw(layerno)
1671+ if !sys.sf(GSF_nobardisplay) && sys.barsDisplay {
1672+ for ti, _ := range sys.tmode {
1673+ for i := ti; i < l.num[0][ti]; i += 2 {
1674+ l.hb[l.ref[0][ti]][i].bgDraw(layerno)
13531675 }
13541676 }
1355- for ti, tm := range sys.tmode {
1356- for i := ti; i < len(l.hb[tm]); i += 2 {
1357- l.hb[tm][i].draw(layerno, float32(sys.chars[i][0].life)/
1677+ for ti, _ := range sys.tmode {
1678+ for i := ti; i < l.num[0][ti]; i += 2 {
1679+ l.hb[l.ref[0][ti]][i].draw(layerno, float32(sys.chars[i][0].life)/
13581680 float32(sys.chars[i][0].lifeMax))
13591681 }
13601682 }
1361- for i := range l.pb {
1362- l.pb[i].bgDraw(layerno)
1683+ for ti, _ := range sys.tmode {
1684+ for i := ti; i < l.num[1][ti]; i += 2 {
1685+ l.pb[l.ref[1][ti]][i].bgDraw(layerno)
1686+ }
13631687 }
1364- for i := range l.pb {
1365- l.pb[i].draw(layerno, float32(sys.chars[i][0].power)/
1366- float32(sys.chars[i][0].powerMax), sys.chars[i][0].power/1000,
1367- l.fnt[:])
1688+ for ti, _ := range sys.tmode {
1689+ for i := ti; i < l.num[1][ti]; i += 2 {
1690+ l.pb[l.ref[1][ti]][i].draw(layerno, float32(sys.chars[i][0].power)/
1691+ float32(sys.chars[i][0].powerMax), sys.chars[i][0].power/1000,
1692+ l.fnt[:])
1693+ }
13681694 }
1369- for ti, tm := range sys.tmode {
1370- for i := ti; i < len(l.fa[tm]); i += 2 {
1371- l.fa[tm][i].bgDraw(layerno)
1695+ for ti, _ := range sys.tmode {
1696+ for i := ti; i < l.num[2][ti]; i += 2 {
1697+ l.fa[l.ref[2][ti]][i].bgDraw(layerno)
13721698 }
13731699 }
1374- for ti, tm := range sys.tmode {
1375- for i := ti; i < len(l.fa[tm]); i += 2 {
1376- if fspr := l.fa[tm][i].face; fspr != nil {
1700+ for ti, _ := range sys.tmode {
1701+ for i := ti; i < l.num[2][ti]; i += 2 {
1702+ if fspr := l.fa[l.ref[2][ti]][i].face; fspr != nil {
13771703 pfx := sys.chars[i][0].getPalfx()
13781704 sys.cgi[i].sff.palList.SwapPalMap(&pfx.remap)
13791705 fspr.Pal = nil
13801706 fspr.Pal = fspr.GetPal(&sys.cgi[i].sff.palList)
13811707 sys.cgi[i].sff.palList.SwapPalMap(&pfx.remap)
1382- l.fa[tm][i].draw(layerno, pfx, i == sys.superplayer)
1708+ l.fa[l.ref[2][ti]][i].draw(layerno, pfx, i == sys.superplayer)
13831709 }
13841710 }
13851711 }
1386- for ti, tm := range sys.tmode {
1387- for i := ti; i < len(l.nm[tm]); i += 2 {
1388- l.nm[tm][i].bgDraw(layerno)
1712+ for ti, _ := range sys.tmode {
1713+ for i := ti; i < l.num[3][ti]; i += 2 {
1714+ l.nm[l.ref[3][ti]][i].bgDraw(layerno)
13891715 }
13901716 }
1391- for ti, tm := range sys.tmode {
1392- for i := ti; i < len(l.nm[tm]); i += 2 {
1393- l.nm[tm][i].draw(layerno, l.fnt[:], sys.cgi[i].displayname)
1717+ for ti, _ := range sys.tmode {
1718+ for i := ti; i < l.num[3][ti]; i += 2 {
1719+ l.nm[l.ref[3][ti]][i].draw(layerno, l.fnt[:], sys.cgi[i].lifebarname)
13941720 }
13951721 }
13961722 l.ti.bgDraw(layerno)
@@ -1400,4 +1726,8 @@ func (l *Lifebar) draw(layerno int16) {
14001726 }
14011727 }
14021728 l.co.draw(layerno, l.fnt[:])
1729+ if sys.challenger > 0 && l.ch.challenger.displaytime > l.ch.cnt {
1730+ l.ch.bgDraw(layerno)
1731+ l.ch.draw(layerno, l.fnt[:])
1732+ }
14031733 }
--- a/src/main.go
+++ b/src/main.go
@@ -12,6 +12,7 @@ import (
1212
1313 "github.com/go-gl/glfw/v3.3/glfw"
1414 lua "github.com/yuin/gopher-lua"
15+ "github.com/sqweek/dialog"
1516 )
1617
1718 func init() {
@@ -47,17 +48,21 @@ func main() {
4748 help, _ := regexp.MatchString("^-[h%?]", a)
4849 if help {
4950 fmt.Println("I.K.E.M.E.N\nOptions (case sensitive):")
50- fmt.Println(" -h -? Help")
51- fmt.Println(" -log <logfile> Records match data to <logfile>")
52- fmt.Println(" -r <sysfile> Loads motif <sysfile>. eg. -r motifdir or -r motifdir/system.def")
51+ fmt.Println(" -h -? Help")
52+ fmt.Println(" -log <logfile> Records match data to <logfile>")
53+ fmt.Println(" -r <sysfile> Loads motif <sysfile>. eg. -r motifdir or -r motifdir/system.def")
5354 fmt.Println("\nQuick VS Options:")
54- fmt.Println(" -p<n> <playername> Loads player n, eg. -p3 kfm")
55- fmt.Println(" -p<n>.ai <level> Set player n's AI to <level>, eg. -p1.ai 8")
56- fmt.Println(" -p<n>.color <col> Set player n's color to <col>")
57- fmt.Println(" -p<n>.life <life> Sets player n's life to <life>")
58- fmt.Println(" -p<n>.power <power> Sets player n's power to <power>")
59- fmt.Println(" -rounds <num> Plays for <num> rounds, and then quits")
60- fmt.Println(" -s <stagename> Loads stage <stagename>")
55+ fmt.Println(" -p<n> <playername> Loads player n, eg. -p3 kfm")
56+ fmt.Println(" -p<n>.ai <level> Set player n's AI to <level>, eg. -p1.ai 8")
57+ fmt.Println(" -p<n>.color <col> Set player n's color to <col>")
58+ fmt.Println(" -p<n>.power <power> Sets player n's power to <power>")
59+ fmt.Println(" -p<n>.life <life> Sets player n's life to <life>")
60+ fmt.Println(" -p<n>.lifeMax <life> Sets player n's max life to <life>")
61+ fmt.Println(" -p<n>.lifeRatio <ratio> Sets player n's life ratio to <ratio>")
62+ fmt.Println(" -p<n>.attackRatio <ratio> Sets player n's attack ratio to <ratio>")
63+ fmt.Println(" -p<n>.defenceRatio <ratio> Sets player n's defence ratio to <ratio>")
64+ fmt.Println(" -rounds <num> Plays for <num> rounds, and then quits")
65+ fmt.Println(" -s <stagename> Loads stage <stagename>")
6166 fmt.Println("\nPress ENTER to exit.")
6267 var s string
6368 fmt.Scanln(&s)
@@ -120,13 +125,17 @@ func main() {
120125 "CommonCmd": "data/common.cmd",
121126 "SimulMode": true,
122127 "LifeMul": 100,
123- "Team1VS2Life": 120,
124- "TurnsRecoveryRate": 300,
128+ "Team1VS2Life": 100,
129+ "TurnsRecoveryBase": 12.5,
130+ "TurnsRecoveryBonus": 27.5,
125131 "ZoomActive": false,
126132 "ZoomMin": 0.75,
127133 "ZoomMax": 1.1,
128134 "ZoomSpeed": 1,
129135 "RoundTime": 99,
136+ "RoundsNumSingle": -1,
137+ "RoundsNumTeam": -1,
138+ "MaxDrawGames": -2,
130139 "SingleTeamMode": true,
131140 "NumTurns": 4,
132141 "NumSimul": 4,
@@ -175,10 +184,11 @@ func main() {
175184 Joystick int
176185 Buttons []interface{}
177186 }
178- JoystickConfig []struct {
187+ JoystickConfig []struct {
179188 Joystick int
180189 Buttons []interface{}
181190 }
191+ NumSimul int
182192 NumTag int
183193 TeamLifeShare bool
184194 AIRandomColor bool
@@ -239,7 +249,13 @@ func main() {
239249 i, _ = strconv.Atoi(key)
240250 return i
241251 }
242- for a := 0; a < tmp.NumTag; a++ {
252+ Max := func(x, y int) int {
253+ if x < y {
254+ return y
255+ }
256+ return x
257+ }
258+ for a := 0; a < Max(tmp.NumSimul, tmp.NumTag); a++ {
243259 for _, kc := range tmp.KeyConfig {
244260 b := kc.Buttons
245261 if kc.Joystick < 0 {
@@ -269,7 +285,6 @@ func main() {
269285 sys.PostProcessingShader = tmp.PostProcessingShader
270286 sys.MultisampleAntialiasing = tmp.MSAA
271287 sys.LocalcoordScalingType = tmp.LocalcoordScalingType
272- sys.aiRandomColor = tmp.AIRandomColor
273288 sys.allowDebugKeys = tmp.AllowDebugKeys
274289 air, err := ioutil.ReadFile(tmp.CommonAir)
275290 if err != nil {
@@ -282,7 +297,7 @@ func main() {
282297 }
283298 sys.commonCmd = string("\n") + string(cmd)
284299 //os.Mkdir("debug", os.ModeSticky|0755)
285- log := createLog("Ikemen.txt")
300+ log := createLog("Ikemen.log")
286301 defer closeLog(log)
287302 l := sys.init(tmp.Width, tmp.Height)
288303 if err := l.DoFile(tmp.System); err != nil {
@@ -291,9 +306,11 @@ func main() {
291306 case *lua.ApiError:
292307 errstr := strings.Split(err.Error(), "\n")[0]
293308 if len(errstr) < 10 || errstr[len(errstr)-10:] != "<game end>" {
309+ dialog.Message("%s\n\nError saved to Ikemen.log logfile.", err).Title("I.K.E.M.E.N Error").Error()
294310 panic(err)
295311 }
296312 default:
313+ dialog.Message("%s\n\nError saved to Ikemen.log logfile.", err).Title("I.K.E.M.E.N Error").Error()
297314 panic(err)
298315 }
299316 }
--- a/src/render.go
+++ b/src/render.go
@@ -697,25 +697,31 @@ func FillRect(rect [4]int32, color uint32, trans int32) {
697697 gl.Translated(0, float64(sys.scrrect[3]), 0)
698698 if trans == -1 {
699699 gl.BlendFunc(gl.SRC_ALPHA, gl.ONE)
700+ gl.BlendEquation(gl.FUNC_ADD)
700701 fill(1)
701702 } else if trans == -2 {
702703 gl.BlendFunc(gl.ZERO, gl.ONE_MINUS_SRC_COLOR)
704+ gl.BlendEquation(gl.FUNC_REVERSE_SUBTRACT)
703705 fill(1)
704706 } else if trans <= 0 {
705707 } else if trans < 255 {
706708 gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
709+ gl.BlendEquation(gl.FUNC_ADD)
707710 fill(float32(trans) / 256)
708711 } else if trans < 512 {
709712 gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
713+ gl.BlendEquation(gl.FUNC_ADD)
710714 fill(1)
711715 } else {
712716 src, dst := trans&0xff, trans>>10&0xff
713717 if dst < 255 {
714718 gl.BlendFunc(gl.ZERO, gl.ONE_MINUS_SRC_ALPHA)
719+ gl.BlendEquation(gl.FUNC_ADD)
715720 fill(float32(dst) / 255)
716721 }
717722 if src > 0 {
718723 gl.BlendFunc(gl.SRC_ALPHA, gl.ONE)
724+ gl.BlendEquation(gl.FUNC_ADD)
719725 fill(float32(src) / 255)
720726 }
721727 }
--- a/src/script.go
+++ b/src/script.go
@@ -2,6 +2,7 @@ package main
22
33 import (
44 "fmt"
5+ "math"
56 "math/rand"
67 "runtime"
78 "runtime/debug"
@@ -31,6 +32,9 @@ func numArg(l *lua.LState, argi int) float64 {
3132 func boolArg(l *lua.LState, argi int) bool {
3233 return l.ToBool(argi)
3334 }
35+func tableArg(l *lua.LState, argi int) *lua.LTable {
36+ return l.ToTable(argi)
37+}
3438 func newUserData(l *lua.LState, value interface{}) *lua.LUserData {
3539 ud := l.NewUserData()
3640 ud.Value = value
@@ -98,6 +102,61 @@ func scriptCommonInit(l *lua.LState) {
98102 return 1
99103 })
100104 //----------------------------------------------------------------
105+ luaRegister(l, "getFrameCount", func(l *lua.LState) int {
106+ l.Push(lua.LNumber(sys.frameCounter))
107+ return 1
108+ })
109+
110+ luaRegister(l, "clearColor", func(l *lua.LState) int {
111+ a := int32(255)
112+ if l.GetTop() >= 4 {
113+ a = int32(numArg(l, 4))
114+ }
115+ col := uint32(int32(numArg(l, 3))&0xff | int32(numArg(l, 2))&0xff<<8 |
116+ int32(numArg(l, 1))&0xff<<16)
117+ FillRect(sys.scrrect, col, a)
118+ return 0
119+ })
120+ luaRegister(l, "fillRect", func(l *lua.LState) int {
121+ rect := [4]int32{
122+ int32(float32(numArg(l, 1)) * sys.widthScale),
123+ int32(float32(numArg(l, 2)) * sys.heightScale),
124+ int32(float32(numArg(l, 3)) * sys.widthScale),
125+ int32(float32(numArg(l, 4)) * sys.heightScale),
126+ }
127+ col := uint32(int32(numArg(l, 7))&0xff | int32(numArg(l, 6))&0xff<<8 | int32(numArg(l, 5))&0xff<<16)
128+ a := int32(int32(numArg(l, 8))&0xff | int32(numArg(l, 9))&0xff<<10)
129+ FillRect(rect, col, a)
130+ return 0
131+ })
132+ luaRegister(l, "fadeScreen", func(l *lua.LState) int {
133+ frame := float64(sys.frameCounter - int32(numArg(l, 2)))
134+ length := float64(numArg(l, 3))
135+ if frame > length || length <= 0 {
136+ l.Push(lua.LBool(false))
137+ return 1
138+ }
139+ r, g, b, a := int32(0), int32(0), int32(0), float64(0)
140+ if strArg(l, 1) == "fadeout" {
141+ a = math.Floor(float64(255) / length * frame)
142+ } else if strArg(l, 1) == "fadein" {
143+ a = math.Floor(255 - 255 * (frame - 1) / length)
144+ }
145+ if a < 0 {
146+ a = 0
147+ } else if a > 255 {
148+ a = 255
149+ }
150+ if l.GetTop() >= 6 {
151+ r = int32(numArg(l, 4))
152+ g = int32(numArg(l, 5))
153+ b = int32(numArg(l, 6))
154+ }
155+ col := uint32(int32(b)&0xff | int32(g)&0xff<<8 | int32(r)&0xff<<16)
156+ FillRect(sys.scrrect, col, int32(a))
157+ l.Push(lua.LBool(true))
158+ return 1
159+ })
101160 luaRegister(l, "sffNew", func(l *lua.LState) int {
102161 sff, err := loadSff(strArg(l, 1), false)
103162 if err != nil {
@@ -201,7 +260,24 @@ func scriptCommonInit(l *lua.LState) {
201260 return 0
202261 })
203262 luaRegister(l, "playBGM", func(l *lua.LState) int {
204- sys.bgm.Open(strArg(l, 1), boolArg(l, 2), int(numArg(l, 3)), int(numArg(l, 4)), int(Atoi(strArg(l, 5))), int(Atoi(strArg(l, 6))))
263+ isdefault := true
264+ var loop, volume, loopstart, loopend int = 1, 100, 0, 0
265+ if l.GetTop() >= 2 {
266+ isdefault = boolArg(l, 2)
267+ }
268+ if l.GetTop() >= 3 {
269+ loop = int(numArg(l, 3))
270+ }
271+ if l.GetTop() >= 4 {
272+ volume = int(numArg(l, 4))
273+ }
274+ if l.GetTop() >= 5 {
275+ loopstart = int(numArg(l, 5))
276+ }
277+ if l.GetTop() >= 6 {
278+ loopend = int(numArg(l, 6))
279+ }
280+ sys.bgm.Open(strArg(l, 1), isdefault, loop, volume, loopstart, loopend)
205281 return 0
206282 })
207283 luaRegister(l, "esc", func(l *lua.LState) int {
@@ -252,6 +328,67 @@ func scriptCommonInit(l *lua.LState) {
252328 sys.teamLifeShare = boolArg(l, 1)
253329 return 0
254330 })
331+ luaRegister(l, "setMatchWins", func(l *lua.LState) int {
332+ sys.lifebar.ro.match_wins = int32(numArg(l, 1))
333+ return 0
334+ })
335+ luaRegister(l, "getMatchWins", func(l *lua.LState) int {
336+ l.Push(lua.LNumber(sys.lifebar.ro.match_wins))
337+ return 1
338+ })
339+ luaRegister(l, "setMatchMaxDrawGames", func(l *lua.LState) int {
340+ sys.lifebar.ro.match_maxdrawgames = int32(numArg(l, 1))
341+ return 0
342+ })
343+ luaRegister(l, "getMatchMaxDrawGames", func(l *lua.LState) int {
344+ l.Push(lua.LNumber(sys.lifebar.ro.match_maxdrawgames))
345+ return 1
346+ })
347+ luaRegister(l, "getFramesPerCount", func(l *lua.LState) int {
348+ l.Push(lua.LNumber(sys.lifebar.ti.framespercount))
349+ return 1
350+ })
351+ luaRegister(l, "setMasterVolume", func(l *lua.LState) int {
352+ sys.masterVolume = int(numArg(l, 1))
353+ return 0
354+ })
355+ luaRegister(l, "setBgmVolume", func(l *lua.LState) int {
356+ sys.bgmVolume = int(numArg(l, 1))
357+ return 0
358+ })
359+ luaRegister(l, "setWavVolume", func(l *lua.LState) int {
360+ sys.wavVolume = int(numArg(l, 1))
361+ return 0
362+ })
363+ luaRegister(l, "setAudioDucking", func(l *lua.LState) int {
364+ sys.AudioDucking = boolArg(l, 1)
365+ return 0
366+ })
367+ luaRegister(l, "setAttackLifeToPowerMul", func(l *lua.LState) int {
368+ sys.attack_LifeToPowerMul = float32(numArg(l, 1))
369+ return 0
370+ })
371+ luaRegister(l, "setGetHitLifeToPowerMul", func(l *lua.LState) int {
372+ sys.getHit_LifeToPowerMul = float32(numArg(l, 1))
373+ return 0
374+ })
375+ luaRegister(l, "setSuperTargetDefenceMul", func(l *lua.LState) int {
376+ sys.super_TargetDefenceMul = float32(numArg(l, 1))
377+ return 0
378+ })
379+ luaRegister(l, "setAllowDebugKeys", func(l *lua.LState) int {
380+ d := boolArg(l, 1)
381+ if !d {
382+ if sys.clsnDraw {
383+ sys.clsnDraw = false
384+ }
385+ if sys.debugDraw {
386+ sys.debugDraw = false
387+ }
388+ }
389+ sys.allowDebugKeys = d
390+ return 0
391+ })
255392
256393 // All the lua sprites will be caled by this value
257394 luaRegister(l, "setLuaSpriteScale", func(l *lua.LState) int {
@@ -297,6 +434,40 @@ func scriptCommonInit(l *lua.LState) {
297434
298435 func systemScriptInit(l *lua.LState) {
299436 scriptCommonInit(l)
437+ luaRegister(l, "bgNew", func(*lua.LState) int {
438+ sff := ""
439+ if l.GetTop() >= 3 {
440+ sff = strArg(l, 3)
441+ }
442+ num, err := loadBGDef(strArg(l, 1), strArg(l, 2), sff)
443+ if err != nil {
444+ l.RaiseError(err.Error())
445+ }
446+ l.Push(lua.LNumber(num))
447+ return 1
448+ })
449+ luaRegister(l, "bgDraw", func(*lua.LState) int {
450+ top := false
451+ var x, y, scl float32 = 0, 0, 1
452+ if l.GetTop() >= 2 {
453+ top = boolArg(l, 2)
454+ }
455+ if l.GetTop() >= 3 {
456+ x = float32(numArg(l, 3))
457+ }
458+ if l.GetTop() >= 4 {
459+ y = float32(numArg(l, 4))
460+ }
461+ if l.GetTop() >= 5 {
462+ scl = float32(numArg(l, 5))
463+ }
464+ sys.bgdef[int(numArg(l, 1))].draw(top, x, y, scl)
465+ return 0
466+ })
467+ luaRegister(l, "bgReset", func(*lua.LState) int {
468+ sys.bgdef[int(numArg(l, 1))].reset()
469+ return 0
470+ })
300471 luaRegister(l, "textImgNew", func(*lua.LState) int {
301472 l.Push(newUserData(l, NewTextSprite()))
302473 return 1
@@ -772,7 +943,8 @@ func systemScriptInit(l *lua.LState) {
772943 return 0
773944 })
774945 luaRegister(l, "setTurnsRecoveryRate", func(l *lua.LState) int {
775- sys.turnsRecoveryRate = float32(numArg(l, 1))
946+ sys.turnsRecoveryBase = float32(numArg(l, 1))
947+ sys.turnsRecoveryBonus = float32(numArg(l, 2))
776948 return 0
777949 })
778950 luaRegister(l, "setZoom", func(l *lua.LState) int {
@@ -813,6 +985,37 @@ func systemScriptInit(l *lua.LState) {
813985 sys.loadStart()
814986 return 0
815987 })
988+ luaRegister(l, "overwriteCharData", func(l *lua.LState) int {
989+ pn := int(numArg(l, 1))
990+ if pn < 1 || pn > MaxSimul*2+MaxAttachedChar {
991+ l.RaiseError("The player number (%v) is invalid.", pn)
992+ }
993+ tbl := tableArg(l, 2)
994+ tbl.ForEach(func(key, value lua.LValue) {
995+ switch k := key.(type) {
996+ case lua.LString:
997+ switch string(k) {
998+ case "power":
999+ sys.ocd[pn-1].power = int32(lua.LVAsNumber(value))
1000+ case "life":
1001+ sys.ocd[pn-1].life = int32(lua.LVAsNumber(value))
1002+ case "lifeMax":
1003+ sys.ocd[pn-1].lifeMax = int32(lua.LVAsNumber(value))
1004+ case "lifeRatio":
1005+ sys.ocd[pn-1].lifeRatio = float32(lua.LVAsNumber(value))
1006+ case "attackRatio":
1007+ sys.ocd[pn-1].attackRatio = float32(lua.LVAsNumber(value))
1008+ case "defenceRatio":
1009+ sys.ocd[pn-1].defenceRatio = float32(lua.LVAsNumber(value))
1010+ default:
1011+ l.RaiseError("The table key (%v) is invalid.", key)
1012+ }
1013+ default:
1014+ l.RaiseError("The table key type (%v) is invalid.", fmt.Sprintf("%T\n", key))
1015+ }
1016+ })
1017+ return 0
1018+ })
8161019 luaRegister(l, "game", func(l *lua.LState) int {
8171020 tbl := l.NewTable()
8181021 tbl_chars := l.NewTable()
@@ -827,14 +1030,17 @@ func systemScriptInit(l *lua.LState) {
8271030 sys.await(FPS)
8281031 }
8291032 for i := range sys.cgi {
830- if i < len(sys.lifebar.fa[sys.tmode[i&1]]) {
1033+ num := len(sys.lifebar.fa[sys.tmode[i&1]])
1034+ if (sys.tmode[i&1] == TM_Simul || sys.tmode[i&1] == TM_Tag) {
1035+ num = int(sys.numSimul[i&1]) * 2
1036+ }
1037+ if i < num {
8311038 fa := sys.lifebar.fa[sys.tmode[i&1]][i]
8321039 fa.face = sys.cgi[i].sff.getOwnPalSprite(
8331040 int16(fa.face_spr[0]), int16(fa.face_spr[1]))
8341041
8351042 fa.scale = sys.cgi[i].portraitscale
8361043 }
837-
8381044 }
8391045 runtime.GC()
8401046 return nil
@@ -923,6 +1129,7 @@ func systemScriptInit(l *lua.LState) {
9231129 if len(p) > 0 {
9241130 tmp := l.NewTable()
9251131 tmp.RawSetString("name", lua.LString(p[0].name))
1132+ tmp.RawSetString("id", lua.LNumber(p[0].id))
9261133 tmp.RawSetString("memberNo", lua.LNumber(p[0].memberNo))
9271134 tmp.RawSetString("selectNo", lua.LNumber(p[0].selectNo))
9281135 tmp.RawSetString("life", lua.LNumber(p[0].life))
@@ -984,60 +1191,58 @@ func systemScriptInit(l *lua.LState) {
9841191 tbl.RawSetString("P2wins", lua.LNumber(sys.wins[1]))
9851192 tbl.RawSetString("P1tmode", lua.LNumber(sys.tmode[0]))
9861193 tbl.RawSetString("P2tmode", lua.LNumber(sys.tmode[1]))
1194+ tbl.RawSetString("challenger", lua.LNumber(sys.challenger))
9871195 sys.timerCount = []int32{}
9881196 sys.sel.cdefOverwrite = [len(sys.sel.cdefOverwrite)]string{}
9891197 sys.sel.sdefOverwrite = ""
9901198 l.Push(lua.LNumber(winp))
9911199 l.Push(tbl)
1200+ sys.resetOverwriteCharData()
9921201 return 2
9931202 }
9941203 }
9951204 })
9961205 luaRegister(l, "getCharVar", func(*lua.LState) int {
997- for _, p := range sys.chars {
998- if len(p) > 0 && p[0].playerNo+1 == int(numArg(l, 1)) {
999- if strArg(l, 2) == "varGet" {
1000- l.Push(lua.LNumber(p[0].varGet(int32(numArg(l, 3))).ToI()))
1001- } else if strArg(l, 2) == "fvarGet" {
1002- l.Push(lua.LNumber(p[0].fvarGet(int32(numArg(l, 3))).ToI()))
1003- } else if strArg(l, 2) == "sysVarGet" {
1004- l.Push(lua.LNumber(p[0].sysVarGet(int32(numArg(l, 3))).ToI()))
1005- } else if strArg(l, 2) == "sysFvarGet" {
1006- l.Push(lua.LNumber(p[0].sysFvarGet(int32(numArg(l, 3))).ToI()))
1007- }
1008- break
1206+ pn := int(numArg(l, 1))
1207+ if pn >= 1 && pn <= len(sys.chars) && len(sys.chars[pn-1]) > 0 {
1208+ if strArg(l, 2) == "varGet" {
1209+ l.Push(lua.LNumber(sys.chars[pn-

差分はサイズ制限により省略されました。全ての差分を見るためにはローカルクライアントを利用してください。