Go で書き直した Ikemen
Révision | c280b2034f8c088f8b3e0691631a03d4132767a5 (tree) |
---|---|
l'heure | 2018-12-14 20:33:57 |
Auteur | neatunsou <sisiy4excite@gmai...> |
Commiter | neatunsou |
SFFのバージョンが2.0だとパレットのアルファ透明度を反映させないようにした
ポートレイトのサイズをlocalcoordに合わせるようにした
ついでにポートレイトのサイズを指定できるようにした
@@ -1367,6 +1367,7 @@ type CharGlobalInfo struct { | ||
1367 | 1367 | pctime, pcid int32 |
1368 | 1368 | unhittable int32 |
1369 | 1369 | quotes [MaxQuotes]string |
1370 | + portraitscale float32 | |
1370 | 1371 | } |
1371 | 1372 | |
1372 | 1373 | func (cgi *CharGlobalInfo) clearPCTime() { |
@@ -1657,6 +1658,8 @@ func (c *Char) load(def string) error { | ||
1657 | 1658 | gi.nameLow = strings.ToLower(c.name) |
1658 | 1659 | is.ReadI32("localcoord", &c.localcoord) |
1659 | 1660 | c.localscl = 320 / float32(c.localcoord) |
1661 | + gi.portraitscale = c.localscl | |
1662 | + is.ReadF32("portraitscale", &gi.portraitscale) | |
1660 | 1663 | } |
1661 | 1664 | case "files": |
1662 | 1665 | if files { |
@@ -562,7 +562,7 @@ func (l *Layout) Read(pre string, is IniSection) { | ||
562 | 562 | l.layerno = I32ToI16(Min(2, ln)) |
563 | 563 | is.ReadF32(pre+"scale", &l.scale[0], &l.scale[1]) |
564 | 564 | } |
565 | -func (l *Layout) DrawSprite(x, y float32, ln int16, s *Sprite, fx *PalFX) { | |
565 | +func (l *Layout) DrawSprite(x, y float32, ln int16, s *Sprite, fx *PalFX, fscale float32) { | |
566 | 566 | if l.layerno == ln && s != nil { |
567 | 567 | if l.facing < 0 { |
568 | 568 | x += sys.lifebarFontScale |
@@ -575,7 +575,7 @@ func (l *Layout) DrawSprite(x, y float32, ln int16, s *Sprite, fx *PalFX) { | ||
575 | 575 | pal = fx.getFxPal(pal, false) |
576 | 576 | } |
577 | 577 | s.Draw(x+l.offset[0], y+l.offset[1], |
578 | - l.scale[0]*float32(l.facing), l.scale[1]*float32(l.vfacing), pal) | |
578 | + l.scale[0]*float32(l.facing)*fscale, l.scale[1]*float32(l.vfacing)*fscale, pal) | |
579 | 579 | } |
580 | 580 | } |
581 | 581 | func (l *Layout) DrawAnim(r *[4]int32, x, y, scl float32, ln int16, |
@@ -1077,6 +1077,9 @@ func loadSff(filename string, char bool) (*Sff, error) { | ||
1077 | 1077 | if err := read(rgba[:]); err != nil { |
1078 | 1078 | return nil, err |
1079 | 1079 | } |
1080 | + if s.header.Ver2 == 0 { | |
1081 | + rgba[3] = 255 | |
1082 | + } | |
1080 | 1083 | pal[i] = uint32(rgba[3])<<24 | uint32(rgba[2])<<16 | uint32(rgba[1])<<8 | uint32(rgba[0]) |
1081 | 1084 | } |
1082 | 1085 | idx = i |
@@ -268,10 +268,12 @@ type LifeBarFace struct { | ||
268 | 268 | teammate_face []*Sprite |
269 | 269 | teammate_face_lay Layout |
270 | 270 | numko int32 |
271 | + scale float32 | |
272 | + teammate_scale []float32 | |
271 | 273 | } |
272 | 274 | |
273 | 275 | func newLifeBarFace() *LifeBarFace { |
274 | - return &LifeBarFace{face_spr: [2]int32{-1}, teammate_face_spr: [2]int32{-1}} | |
276 | + return &LifeBarFace{face_spr: [2]int32{-1}, teammate_face_spr: [2]int32{-1}, scale: 1} | |
275 | 277 | } |
276 | 278 | func readLifeBarFace(pre string, is IniSection, |
277 | 279 | sff *Sff, at AnimationTable) *LifeBarFace { |
@@ -309,7 +311,7 @@ func (f *LifeBarFace) draw(layerno int16, fx *PalFX, superplayer bool) { | ||
309 | 311 | sys.brightness = 256 |
310 | 312 | } |
311 | 313 | f.face_lay.DrawSprite(float32(f.pos[0]), float32(f.pos[1]), layerno, |
312 | - f.face, fx) | |
314 | + f.face, fx, f.scale) | |
313 | 315 | sys.brightness = ob |
314 | 316 | i := int32(len(f.teammate_face)) - 1 |
315 | 317 | x := float32(f.teammate_pos[0] + f.teammate_spacing[0]*(i-1)) |
@@ -317,7 +319,7 @@ func (f *LifeBarFace) draw(layerno int16, fx *PalFX, superplayer bool) { | ||
317 | 319 | for ; i >= 0; i-- { |
318 | 320 | if i != f.numko { |
319 | 321 | f.teammate_bg.Draw(x, y, layerno) |
320 | - f.teammate_face_lay.DrawSprite(x, y, layerno, f.teammate_face[i], nil) | |
322 | + f.teammate_face_lay.DrawSprite(x, y, layerno, f.teammate_face[i], nil, f.teammate_scale[i]) | |
321 | 323 | if i < f.numko { |
322 | 324 | f.teammate_ko.Draw(x, y, layerno) |
323 | 325 | } |
@@ -653,6 +655,7 @@ type LifeBarRound struct { | ||
653 | 655 | cur int32 |
654 | 656 | wt, swt, dt [2]int32 |
655 | 657 | fnt []*Fnt |
658 | + timerActive bool | |
656 | 659 | } |
657 | 660 | |
658 | 661 | func newLifeBarRound(snd *Snd, fnt []*Fnt) *LifeBarRound { |
@@ -666,7 +669,12 @@ func readLifeBarRound(is IniSection, | ||
666 | 669 | r := newLifeBarRound(snd, fnt) |
667 | 670 | var tmp int32 |
668 | 671 | is.ReadI32("pos", &r.pos[0], &r.pos[1]) |
669 | - is.ReadI32("match.wins", &r.match_wins) | |
672 | + tmp = Atoi(sys.cmdFlags["-rounds"]) | |
673 | + if tmp > 0 { | |
674 | + r.match_wins = tmp | |
675 | + } else { | |
676 | + is.ReadI32("match.wins", &r.match_wins) | |
677 | + } | |
670 | 678 | is.ReadI32("match.maxdrawgames", &r.match_maxdrawgames) |
671 | 679 | if is.ReadI32("start.waittime", &tmp) { |
672 | 680 | r.start_waittime = Max(1, tmp) |
@@ -712,6 +720,8 @@ func readLifeBarRound(is IniSection, | ||
712 | 720 | func (r *LifeBarRound) callFight() { |
713 | 721 | r.fight.Reset() |
714 | 722 | r.cur, r.wt[0], r.swt[0], r.dt[0] = 1, r.fight_time, r.fight_sndtime, 0 |
723 | + sys.timerCount = append(sys.timerCount, sys.gameTime) | |
724 | + r.timerActive = true | |
715 | 725 | } |
716 | 726 | func (r *LifeBarRound) act() bool { |
717 | 727 | if sys.intro > r.ctrl_time { |
@@ -764,6 +774,14 @@ func (r *LifeBarRound) act() bool { | ||
764 | 774 | r.wt[0]-- |
765 | 775 | } |
766 | 776 | } else if r.cur == 2 && (sys.finish != FT_NotYet || sys.time == 0) { |
777 | + if r.timerActive { | |
778 | + if sys.gameTime-sys.timerCount[sys.round-1] > 0 { | |
779 | + sys.timerCount[sys.round-1] = sys.gameTime - sys.timerCount[sys.round-1] | |
780 | + } else { | |
781 | + sys.timerCount[sys.round-1] = 0 | |
782 | + } | |
783 | + r.timerActive = false | |
784 | + } | |
767 | 785 | f := func(ats *AnimTextSnd, t int) { |
768 | 786 | if r.swt[t] == 0 { |
769 | 787 | r.snd.play(ats.snd) |
@@ -965,6 +983,8 @@ func loadLifebar(deffile string) (*Lifebar, error) { | ||
965 | 983 | } |
966 | 984 | } |
967 | 985 | } |
986 | + case "fonts": | |
987 | + is.ReadF32("scale", &sys.lifebarFontScale) | |
968 | 988 | case "lifebar": |
969 | 989 | if l.hb[0][0] == nil { |
970 | 990 | l.hb[0][0] = readHealthBar("p1.", is, sff, at) |
@@ -5,6 +5,8 @@ import ( | ||
5 | 5 | "runtime" |
6 | 6 | "strings" |
7 | 7 | |
8 | + "math/rand" | |
9 | + | |
8 | 10 | "github.com/go-gl/glfw/v3.2/glfw" |
9 | 11 | "github.com/yuin/gopher-lua" |
10 | 12 | ) |
@@ -239,6 +241,10 @@ func scriptCommonInit(l *lua.LState) { | ||
239 | 241 | sys.match = int32(numArg(l, 1)) |
240 | 242 | return 0 |
241 | 243 | }) |
244 | + luaRegister(l, "setLifeShare", func(l *lua.LState) int { | |
245 | + sys.teamLifeShare = boolArg(l, 1) | |
246 | + return 0 | |
247 | + }) | |
242 | 248 | } |
243 | 249 | |
244 | 250 | // System Script |
@@ -343,7 +349,16 @@ func systemScriptInit(l *lua.LState) { | ||
343 | 349 | if !ok { |
344 | 350 | userDataError(l, 1, a) |
345 | 351 | } |
346 | - a.SetTile(int32(numArg(l, 2)), int32(numArg(l, 3))) | |
352 | + var sx, sy int32 = 0, 0 | |
353 | + if l.GetTop() >= 4 { | |
354 | + sx = int32(numArg(l, 4)) | |
355 | + if l.GetTop() >= 5 { | |
356 | + sy = int32(numArg(l, 5)) | |
357 | + } else { | |
358 | + sy = sx | |
359 | + } | |
360 | + } | |
361 | + a.SetTile(int32(numArg(l, 2)), int32(numArg(l, 3)), sx, sy) | |
347 | 362 | return 0 |
348 | 363 | }) |
349 | 364 | luaRegister(l, "animSetColorKey", func(*lua.LState) int { |
@@ -395,6 +410,14 @@ func systemScriptInit(l *lua.LState) { | ||
395 | 410 | a.Draw() |
396 | 411 | return 0 |
397 | 412 | }) |
413 | + luaRegister(l, "animReset", func(*lua.LState) int { | |
414 | + a, ok := toUserData(l, 1).(*Anim) | |
415 | + if !ok { | |
416 | + userDataError(l, 1, a) | |
417 | + } | |
418 | + a.ResetFrames() | |
419 | + return 0 | |
420 | + }) | |
398 | 421 | luaRegister(l, "enterNetPlay", func(*lua.LState) int { |
399 | 422 | if sys.netInput != nil { |
400 | 423 | l.RaiseError("すでに通信中です。") |
@@ -594,6 +617,10 @@ func systemScriptInit(l *lua.LState) { | ||
594 | 617 | if !sys.frameSkip { |
595 | 618 | c := sys.sel.GetChar(n) |
596 | 619 | if c != nil && c.lportrait != nil { |
620 | + if c.portrait_scale != 1 { | |
621 | + xscl *= c.portrait_scale | |
622 | + yscl *= c.portrait_scale | |
623 | + } | |
597 | 624 | c.lportrait.Draw(x, y, xscl, yscl, c.lportrait.Pal) |
598 | 625 | } |
599 | 626 | } |
@@ -613,8 +640,8 @@ func systemScriptInit(l *lua.LState) { | ||
613 | 640 | if c != nil { |
614 | 641 | if c.sportrait != nil { |
615 | 642 | c.sportrait.Draw(x+float32(i)*sys.sel.cellsize[0], |
616 | - y+float32(j)*sys.sel.cellsize[1], sys.sel.cellscale[0], | |
617 | - sys.sel.cellscale[1], c.sportrait.Pal) | |
643 | + y+float32(j)*sys.sel.cellsize[1], sys.sel.cellscale[0]*c.portrait_scale, | |
644 | + sys.sel.cellscale[1]*c.portrait_scale, c.sportrait.Pal) | |
618 | 645 | } else if c.def == "randomselect" && sys.sel.randomspr != nil { |
619 | 646 | sys.sel.randomspr.Draw(x+float32(i)*sys.sel.cellsize[0], |
620 | 647 | y+float32(j)*sys.sel.cellsize[1], sys.sel.randomscl[0], |
@@ -697,6 +724,8 @@ func systemScriptInit(l *lua.LState) { | ||
697 | 724 | return 0 |
698 | 725 | }) |
699 | 726 | luaRegister(l, "game", func(l *lua.LState) int { |
727 | + tbl := l.NewTable() | |
728 | + tbl_chars := l.NewTable() | |
700 | 729 | load := func() error { |
701 | 730 | sys.loader.runTread() |
702 | 731 | for sys.loader.state != LS_Complete { |
@@ -712,7 +741,10 @@ func systemScriptInit(l *lua.LState) { | ||
712 | 741 | fa := sys.lifebar.fa[sys.tmode[i&1]][i] |
713 | 742 | fa.face = sys.cgi[i].sff.getOwnPalSprite( |
714 | 743 | int16(fa.face_spr[0]), int16(fa.face_spr[1])) |
744 | + | |
745 | + fa.scale = sys.cgi[i].portraitscale | |
715 | 746 | } |
747 | + | |
716 | 748 | } |
717 | 749 | runtime.GC() |
718 | 750 | return nil |
@@ -791,6 +823,29 @@ func systemScriptInit(l *lua.LState) { | ||
791 | 823 | if w1 != w2 { |
792 | 824 | winp = Btoi(w1) + Btoi(w2)*2 |
793 | 825 | } |
826 | + tbl_roundNo := l.NewTable() | |
827 | + for _, p := range sys.chars { | |
828 | + if len(p) > 0 { | |
829 | + tmp := l.NewTable() | |
830 | + tmp.RawSetString("name", lua.LString(p[0].name)) | |
831 | + tmp.RawSetString("memberNo", lua.LNumber(p[0].memberNo)) | |
832 | + tmp.RawSetString("selectNo", lua.LNumber(p[0].selectNo)) | |
833 | + tmp.RawSetString("life", lua.LNumber(p[0].life)) | |
834 | + tmp.RawSetString("lifeMax", lua.LNumber(p[0].lifeMax)) | |
835 | + tmp.RawSetString("winquote", lua.LNumber(p[0].winquote)) | |
836 | + tmp.RawSetString("aiLevel", lua.LNumber(p[0].aiLevel())) | |
837 | + tmp.RawSetString("palno", lua.LNumber(p[0].palno())) | |
838 | + tmp.RawSetString("win", lua.LBool(p[0].win())) | |
839 | + tmp.RawSetString("winKO", lua.LBool(p[0].winKO())) | |
840 | + tmp.RawSetString("winTime", lua.LBool(p[0].winTime())) | |
841 | + tmp.RawSetString("winPerfect", lua.LBool(p[0].winPerfect())) | |
842 | + tmp.RawSetString("drawgame", lua.LBool(p[0].drawgame())) | |
843 | + tmp.RawSetString("ko", lua.LBool(p[0].scf(SCF_ko))) | |
844 | + tmp.RawSetString("ko_round_middle", lua.LBool(p[0].scf(SCF_ko_round_middle))) | |
845 | + tbl_roundNo.RawSetInt(p[0].playerNo+1, tmp) | |
846 | + } | |
847 | + } | |
848 | + tbl_chars.RawSetInt(int(sys.round-1), tbl_roundNo) | |
794 | 849 | } |
795 | 850 | return winp, nil |
796 | 851 | } |
@@ -817,10 +872,259 @@ func systemScriptInit(l *lua.LState) { | ||
817 | 872 | sys.loader.reset() |
818 | 873 | } |
819 | 874 | if winp != -2 { |
875 | + time := int32(0) | |
876 | + tbl_time := l.NewTable() | |
877 | + for k, v := range sys.timerCount { | |
878 | + tbl_time.RawSetInt(k+1, lua.LNumber(v)) | |
879 | + time = time + v | |
880 | + } | |
881 | + tbl.RawSetString("chars", tbl_chars) | |
882 | + tbl.RawSetString("time_rounds", tbl_time) | |
883 | + tbl.RawSetString("time", lua.LNumber(time)) | |
884 | + tbl.RawSetString("roundTime", lua.LNumber(sys.roundTime)) | |
885 | + tbl.RawSetString("winTeam", lua.LNumber(sys.winTeam)) | |
886 | + tbl.RawSetString("lastRound", lua.LNumber(sys.round-1)) | |
887 | + tbl.RawSetString("draws", lua.LNumber(sys.draws)) | |
888 | + tbl.RawSetString("P1wins", lua.LNumber(sys.wins[0])) | |
889 | + tbl.RawSetString("P2wins", lua.LNumber(sys.wins[1])) | |
890 | + tbl.RawSetString("P1tmode", lua.LNumber(sys.tmode[0])) | |
891 | + tbl.RawSetString("P2tmode", lua.LNumber(sys.tmode[1])) | |
892 | + sys.timerCount = []int32{} | |
820 | 893 | l.Push(lua.LNumber(winp)) |
821 | - return 1 | |
894 | + l.Push(tbl) | |
895 | + return 2 | |
896 | + } | |
897 | + } | |
898 | + }) | |
899 | + luaRegister(l, "getCharVar", func(*lua.LState) int { | |
900 | + for _, p := range sys.chars { | |
901 | + if len(p) > 0 && p[0].playerNo+1 == int(numArg(l, 1)) { | |
902 | + if strArg(l, 2) == "varGet" { | |
903 | + l.Push(lua.LNumber(p[0].varGet(int32(numArg(l, 3))).ToI())) | |
904 | + } else if strArg(l, 2) == "fvarGet" { | |
905 | + l.Push(lua.LNumber(p[0].fvarGet(int32(numArg(l, 3))).ToI())) | |
906 | + } else if strArg(l, 2) == "sysVarGet" { | |
907 | + l.Push(lua.LNumber(p[0].sysVarGet(int32(numArg(l, 3))).ToI())) | |
908 | + } else if strArg(l, 2) == "sysFvarGet" { | |
909 | + l.Push(lua.LNumber(p[0].sysFvarGet(int32(numArg(l, 3))).ToI())) | |
910 | + } | |
911 | + break | |
912 | + } | |
913 | + } | |
914 | + return 1 | |
915 | + }) | |
916 | + luaRegister(l, "getCharVictoryQuote", func(*lua.LState) int { | |
917 | + v := int(-1) | |
918 | + for _, p := range sys.chars { | |
919 | + if len(p) > 0 && p[0].playerNo+1 == int(numArg(l, 1)) { | |
920 | + if l.GetTop() >= 2 { | |
921 | + v = int(numArg(l, 2)) | |
922 | + } else { | |
923 | + v = int(p[0].winquote) | |
924 | + } | |
925 | + if v < 0 || v >= MaxQuotes { | |
926 | + t := []string{} | |
927 | + for i, q := range sys.cgi[p[0].playerNo].quotes { | |
928 | + if sys.cgi[p[0].playerNo].quotes[i] != "" { | |
929 | + t = append(t, q) | |
930 | + } | |
931 | + } | |
932 | + if len(t) > 0 { | |
933 | + v = rand.Int() % len(t) | |
934 | + } else { | |
935 | + v = -1 | |
936 | + } | |
937 | + } | |
938 | + if len(sys.cgi[p[0].playerNo].quotes) == MaxQuotes && v != -1 { | |
939 | + l.Push(lua.LString(sys.cgi[p[0].playerNo].quotes[v])) | |
940 | + } else { | |
941 | + l.Push(lua.LString("")) | |
942 | + } | |
943 | + break | |
944 | + } | |
945 | + } | |
946 | + return 1 | |
947 | + }) | |
948 | + luaRegister(l, "getCommandLineFlags", func(*lua.LState) int { | |
949 | + tbl := l.NewTable() | |
950 | + for k, v := range sys.cmdFlags { | |
951 | + tbl.RawSetString(k, lua.LString(v)) | |
952 | + } | |
953 | + l.Push(tbl) | |
954 | + return 1 | |
955 | + }) | |
956 | + luaRegister(l, "getCommandLineValue", func(*lua.LState) int { | |
957 | + l.Push(lua.LString(sys.cmdFlags[strArg(l, 1)])) | |
958 | + return 1 | |
959 | + }) | |
960 | + luaRegister(l, "setPortrait", func(*lua.LState) int { | |
961 | + p := int(numArg(l, 3)) | |
962 | + if p == 1 { | |
963 | + sys.sel.lportrait = [...]int16{int16(numArg(l, 1)), int16(numArg(l, 2))} | |
964 | + } else if p == 2 { | |
965 | + sys.sel.sportrait = [...]int16{int16(numArg(l, 1)), int16(numArg(l, 2))} | |
966 | + } else if p == 3 { | |
967 | + sys.sel.vsportrait = [...]int16{int16(numArg(l, 1)), int16(numArg(l, 2))} | |
968 | + } else if p == 4 { | |
969 | + sys.sel.vportrait = [...]int16{int16(numArg(l, 1)), int16(numArg(l, 2))} | |
970 | + } | |
971 | + return 0 | |
972 | + }) | |
973 | + luaRegister(l, "drawSmallPortrait", func(l *lua.LState) int { | |
974 | + n, x, y := int(numArg(l, 1)), float32(numArg(l, 2)), float32(numArg(l, 3)) | |
975 | + var xscl, yscl float32 = 1, 1 | |
976 | + if l.GetTop() >= 4 { | |
977 | + xscl = float32(numArg(l, 4)) | |
978 | + if l.GetTop() >= 5 { | |
979 | + yscl = float32(numArg(l, 5)) | |
980 | + } | |
981 | + } | |
982 | + if !sys.frameSkip { | |
983 | + c := sys.sel.GetChar(n) | |
984 | + if c != nil && c.sportrait != nil { | |
985 | + if c.portrait_scale != 1 { | |
986 | + xscl *= c.portrait_scale | |
987 | + yscl *= c.portrait_scale | |
988 | + } | |
989 | + c.sportrait.Draw(x, y, xscl, yscl, c.sportrait.Pal) | |
990 | + } | |
991 | + } | |
992 | + return 0 | |
993 | + }) | |
994 | + luaRegister(l, "drawVersusPortrait", func(l *lua.LState) int { | |
995 | + n, x, y := int(numArg(l, 1)), float32(numArg(l, 2)), float32(numArg(l, 3)) | |
996 | + var xscl, yscl float32 = 1, 1 | |
997 | + if l.GetTop() >= 4 { | |
998 | + xscl = float32(numArg(l, 4)) | |
999 | + if l.GetTop() >= 5 { | |
1000 | + yscl = float32(numArg(l, 5)) | |
1001 | + } | |
1002 | + } | |
1003 | + if !sys.frameSkip { | |
1004 | + c := sys.sel.GetChar(n) | |
1005 | + if c != nil && c.vsportrait != nil { | |
1006 | + if c.portrait_scale != 1 { | |
1007 | + xscl *= c.portrait_scale | |
1008 | + yscl *= c.portrait_scale | |
1009 | + } | |
1010 | + c.vsportrait.Draw(x, y, xscl, yscl, c.vsportrait.Pal) | |
1011 | + } | |
1012 | + } | |
1013 | + return 0 | |
1014 | + }) | |
1015 | + luaRegister(l, "drawVictoryPortrait", func(l *lua.LState) int { | |
1016 | + n, x, y := int(numArg(l, 1)), float32(numArg(l, 2)), float32(numArg(l, 3)) | |
1017 | + var xscl, yscl float32 = 1, 1 | |
1018 | + if l.GetTop() >= 4 { | |
1019 | + xscl = float32(numArg(l, 4)) | |
1020 | + if l.GetTop() >= 5 { | |
1021 | + yscl = float32(numArg(l, 5)) | |
1022 | + } | |
1023 | + } | |
1024 | + if !sys.frameSkip { | |
1025 | + c := sys.sel.GetChar(n) | |
1026 | + if c != nil && c.vportrait != nil { | |
1027 | + if c.portrait_scale != 1 { | |
1028 | + xscl *= c.portrait_scale | |
1029 | + yscl *= c.portrait_scale | |
1030 | + } | |
1031 | + c.vportrait.Draw(x, y, xscl, yscl, c.vportrait.Pal) | |
822 | 1032 | } |
823 | 1033 | } |
1034 | + return 0 | |
1035 | + }) | |
1036 | + luaRegister(l, "getCharIntro", func(*lua.LState) int { | |
1037 | + c := sys.sel.GetChar(int(numArg(l, 1))) | |
1038 | + l.Push(lua.LString(c.intro_storyboard)) | |
1039 | + return 1 | |
1040 | + }) | |
1041 | + luaRegister(l, "getCharEnding", func(*lua.LState) int { | |
1042 | + c := sys.sel.GetChar(int(numArg(l, 1))) | |
1043 | + l.Push(lua.LString(c.ending_storyboard)) | |
1044 | + return 1 | |
1045 | + }) | |
1046 | + luaRegister(l, "getCharPalettes", func(*lua.LState) int { | |
1047 | + c := sys.sel.GetChar(int(numArg(l, 1))) | |
1048 | + tbl := l.NewTable() | |
1049 | + var pal []int32 | |
1050 | + if sys.aiRandomColor { | |
1051 | + pal = c.pal | |
1052 | + } else { | |
1053 | + pal = c.pal_defaults | |
1054 | + } | |
1055 | + if len(pal) > 0 { | |
1056 | + for k, v := range pal { | |
1057 | + tbl.RawSetInt(k+1, lua.LNumber(v)) | |
1058 | + } | |
1059 | + } else { | |
1060 | + tbl.RawSetInt(1, lua.LNumber(1)) | |
1061 | + } | |
1062 | + l.Push(tbl) | |
1063 | + return 1 | |
1064 | + }) | |
1065 | + luaRegister(l, "getCharRandomPalette", func(*lua.LState) int { | |
1066 | + c := sys.sel.GetChar(int(numArg(l, 1))) | |
1067 | + if len(c.pal) > 0 { | |
1068 | + n := rand.Int() % len(c.pal) | |
1069 | + l.Push(lua.LNumber(c.pal[n])) | |
1070 | + } else { | |
1071 | + l.Push(lua.LNumber(1)) | |
1072 | + } | |
1073 | + return 1 | |
1074 | + }) | |
1075 | + luaRegister(l, "getStageInfo", func(*lua.LState) int { | |
1076 | + a, b, c, d := sys.sel.GetStageInfo(int(numArg(l, 1))) | |
1077 | + l.Push(lua.LString(a)) | |
1078 | + l.Push(lua.LString(b)) | |
1079 | + l.Push(lua.LString(c)) | |
1080 | + l.Push(lua.LString(d)) | |
1081 | + return 4 | |
1082 | + }) | |
1083 | + luaRegister(l, "getKey", func(*lua.LState) int { | |
1084 | + s := "" | |
1085 | + if sys.keyInput != glfw.KeyUnknown { | |
1086 | + s = KeyToString(sys.keyInput) | |
1087 | + } | |
1088 | + l.Push(lua.LString(s)) | |
1089 | + return 1 | |
1090 | + }) | |
1091 | + luaRegister(l, "getKeyText", func(*lua.LState) int { | |
1092 | + s := "" | |
1093 | + if sys.keyInput != glfw.KeyUnknown { | |
1094 | + if sys.keyInput == glfw.KeyInsert { | |
1095 | + s, _ = sys.window.GetClipboardString() | |
1096 | + } else { | |
1097 | + s = sys.keyString | |
1098 | + } | |
1099 | + } | |
1100 | + l.Push(lua.LString(s)) | |
1101 | + return 1 | |
1102 | + }) | |
1103 | + luaRegister(l, "resetKey", func(*lua.LState) int { | |
1104 | + sys.keyInput = glfw.KeyUnknown | |
1105 | + sys.keyString = "" | |
1106 | + return 0 | |
1107 | + }) | |
1108 | + luaRegister(l, "getSpriteInfo", func(*lua.LState) int { | |
1109 | + var s *Sprite | |
1110 | + var err error | |
1111 | + def := strArg(l, 1) | |
1112 | + err = LoadFile(&def, "", func(file string) error { | |
1113 | + s, err = loadFromSff(file, int16(numArg(l, 2)), int16(numArg(l, 3))) | |
1114 | + return err | |
1115 | + }) | |
1116 | + if err != nil { | |
1117 | + l.Push(lua.LNumber(0)) | |
1118 | + l.Push(lua.LNumber(0)) | |
1119 | + l.Push(lua.LNumber(0)) | |
1120 | + l.Push(lua.LNumber(0)) | |
1121 | + return 4 | |
1122 | + } | |
1123 | + l.Push(lua.LNumber(s.Size[0])) | |
1124 | + l.Push(lua.LNumber(s.Size[1])) | |
1125 | + l.Push(lua.LNumber(s.Offset[0])) | |
1126 | + l.Push(lua.LNumber(s.Offset[1])) | |
1127 | + return 4 | |
824 | 1128 | }) |
825 | 1129 | } |
826 | 1130 |
@@ -1806,5 +2110,9 @@ func debugScriptInit(l *lua.LState, file string) error { | ||
1806 | 2110 | } |
1807 | 2111 | return 0 |
1808 | 2112 | }) |
2113 | + luaRegister(l, "getAllowDebugKeys", func(*lua.LState) int { | |
2114 | + l.Push(lua.LBool(sys.allowDebugKeys)) | |
2115 | + return 1 | |
2116 | + }) | |
1809 | 2117 | return l.DoFile(file) |
1810 | 2118 | } |
@@ -1668,6 +1668,7 @@ type SelectChar struct { | ||
1668 | 1668 | def, name, sprite, intro_storyboard, ending_storyboard string |
1669 | 1669 | pal_defaults []int32 |
1670 | 1670 | pal []int32 |
1671 | + portrait_scale float32 | |
1671 | 1672 | sportrait, lportrait, vsportrait, vportrait *Sprite |
1672 | 1673 | } |
1673 | 1674 | type SelectStage struct { |
@@ -1781,6 +1782,13 @@ func (s *Select) addCahr(def string) { | ||
1781 | 1782 | sc.name, _, _ = is.getText("name") |
1782 | 1783 | } |
1783 | 1784 | sc.pal_defaults = is.readI32CsvForStage("pal.defaults") |
1785 | + ok = is.ReadF32("localcoord", &sc.portrait_scale) | |
1786 | + if !ok { | |
1787 | + sc.portrait_scale = 1 | |
1788 | + } else { | |
1789 | + sc.portrait_scale = (320 / sc.portrait_scale) | |
1790 | + } | |
1791 | + is.ReadF32("portraitscale", &sc.portrait_scale) | |
1784 | 1792 | } |
1785 | 1793 | case "files": |
1786 | 1794 | if files { |
@@ -1989,13 +1997,14 @@ func (l *Loader) loadChar(pn int) int { | ||
1989 | 1997 | if pn < len(sys.lifebar.fa[sys.tmode[pn&1]]) && |
1990 | 1998 | sys.tmode[pn&1] == TM_Turns && sys.round == 1 { |
1991 | 1999 | fa := sys.lifebar.fa[sys.tmode[pn&1]][pn] |
1992 | - fa.numko, fa.teammate_face = 0, make([]*Sprite, nsel) | |
2000 | + fa.numko, fa.teammate_face, fa.teammate_scale = 0, make([]*Sprite, nsel), make([]float32, nsel) | |
1993 | 2001 | for i, ci := range idx { |
1994 | 2002 | sprite := sys.sel.charlist[ci].sprite |
1995 | 2003 | LoadFile(&sprite, sys.sel.charlist[ci].def, func(file string) error { |
1996 | 2004 | var err error |
1997 | 2005 | fa.teammate_face[i], err = loadFromSff(file, |
1998 | 2006 | int16(fa.teammate_face_spr[0]), int16(fa.teammate_face_spr[1])) |
2007 | + fa.teammate_scale[i] = sys.sel.charlist[ci].portrait_scale | |
1999 | 2008 | return err |
2000 | 2009 | }) |
2001 | 2010 | } |