296 lines
8.6 KiB
Go
296 lines
8.6 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"git.entr0py.de/garionion/gstreamer-graphix/api"
|
|
"strconv"
|
|
)
|
|
|
|
const discardText = "——"
|
|
|
|
var defaultColor uint32
|
|
|
|
func rgba(rgba [4]uint32) uint32 {
|
|
r, g, b, a := rgba[0], rgba[1], rgba[2], rgba[3]
|
|
if a == 0 {
|
|
return defaultColor
|
|
}
|
|
return (a << 24) | (r << 16) | (g << 8) | b
|
|
}
|
|
|
|
func (d JumperInfo) convertToAPIOverlays(positions Positions) ([]*api.Overlay, error) {
|
|
o := []*api.Overlay{
|
|
{
|
|
Name: "jumperinfo_name",
|
|
X: int64(positions.Name["name"].X),
|
|
Y: int64(positions.Name["name"].Y),
|
|
Display: true,
|
|
BlendIn: 0,
|
|
BlendOut: 0,
|
|
OverlayData: &api.Overlay_TextOverlay{
|
|
TextOverlay: &api.TextOverlay{
|
|
Text: d.Name,
|
|
FontName: positions.Font,
|
|
FontSize: uint64(positions.Fontsize[positions.Name["name"].Size]),
|
|
FontWeight: positions.FontWeight,
|
|
FontColor: rgba(positions.Color[positions.Name["name"].Color]),
|
|
},
|
|
},
|
|
},
|
|
{
|
|
Name: "jumperinfo_nation",
|
|
X: int64(positions.Name["nation"].X),
|
|
Y: int64(positions.Name["nation"].Y),
|
|
Display: true,
|
|
BlendIn: 0,
|
|
BlendOut: 0,
|
|
OverlayData: &api.Overlay_TextOverlay{
|
|
TextOverlay: &api.TextOverlay{
|
|
Text: d.Nation,
|
|
FontName: positions.Font,
|
|
FontSize: uint64(positions.Fontsize[positions.Name["nation"].Size]),
|
|
FontWeight: positions.FontWeight,
|
|
FontColor: rgba(positions.Color[positions.Name["nation"].Color]),
|
|
},
|
|
},
|
|
},
|
|
{
|
|
Name: "jumperinfo_bib",
|
|
X: int64(positions.Name["bib"].X),
|
|
Y: int64(positions.Name["bib"].Y),
|
|
Display: true,
|
|
BlendIn: 0,
|
|
BlendOut: 0,
|
|
OverlayData: &api.Overlay_TextOverlay{
|
|
TextOverlay: &api.TextOverlay{
|
|
Text: d.Bib,
|
|
FontName: positions.Font,
|
|
FontSize: uint64(positions.Fontsize[positions.Name["bib"].Size]),
|
|
FontWeight: positions.FontWeight,
|
|
FontColor: rgba(positions.Color[positions.Name["bib"].Color]),
|
|
},
|
|
},
|
|
},
|
|
{
|
|
Name: "jumperinfo_image",
|
|
X: int64(positions.Name["image"].X),
|
|
Y: int64(positions.Name["image"].Y),
|
|
Display: false,
|
|
BlendIn: 0,
|
|
BlendOut: 0,
|
|
OverlayData: &api.Overlay_ImageOverlay{
|
|
ImageOverlay: &api.ImageOverlay{
|
|
Path: d.Image,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
return o, nil
|
|
}
|
|
|
|
func (d *JumperScore) convertToAPIOverlays(positions Positions) ([]*api.Overlay, error) {
|
|
o := []*api.Overlay{
|
|
{
|
|
Name: "jumperscore_name",
|
|
X: int64(positions.Score["name"].X),
|
|
Y: int64(positions.Score["name"].Y),
|
|
Display: true,
|
|
BlendIn: 0,
|
|
BlendOut: 0,
|
|
OverlayData: &api.Overlay_TextOverlay{
|
|
TextOverlay: &api.TextOverlay{
|
|
Text: d.Name,
|
|
FontName: positions.Font,
|
|
FontSize: uint64(positions.Fontsize[positions.Score["name"].Size]),
|
|
FontWeight: positions.FontWeight,
|
|
FontColor: rgba(positions.Color[positions.Score["name"].Color]),
|
|
},
|
|
},
|
|
},
|
|
{
|
|
Name: "jumperscore_bib",
|
|
X: int64(positions.Score["bib"].X),
|
|
Y: int64(positions.Score["bib"].Y),
|
|
Display: true,
|
|
BlendIn: 0,
|
|
BlendOut: 0,
|
|
OverlayData: &api.Overlay_TextOverlay{
|
|
TextOverlay: &api.TextOverlay{
|
|
Text: d.Bib,
|
|
FontName: positions.Font,
|
|
FontSize: uint64(positions.Fontsize[positions.Score["bib"].Size]),
|
|
FontWeight: positions.FontWeight,
|
|
FontColor: rgba(positions.Color[positions.Score["bib"].Color]),
|
|
},
|
|
},
|
|
},
|
|
{
|
|
Name: "jumperscore_nation",
|
|
X: int64(positions.Score["nation"].X),
|
|
Y: int64(positions.Score["nation"].Y),
|
|
Display: true,
|
|
BlendIn: 0,
|
|
BlendOut: 0,
|
|
OverlayData: &api.Overlay_TextOverlay{
|
|
TextOverlay: &api.TextOverlay{
|
|
Text: d.Nation,
|
|
FontName: positions.Font,
|
|
FontSize: uint64(positions.Fontsize[positions.Score["nation"].Size]),
|
|
FontWeight: positions.FontWeight,
|
|
FontColor: rgba(positions.Color[positions.Score["nation"].Color]),
|
|
},
|
|
},
|
|
},
|
|
{
|
|
Name: "jumperscore_length",
|
|
X: int64(positions.Score["length"].X),
|
|
Y: int64(positions.Score["length"].Y),
|
|
Display: true,
|
|
BlendIn: 0,
|
|
BlendOut: 0,
|
|
OverlayData: &api.Overlay_TextOverlay{
|
|
TextOverlay: &api.TextOverlay{
|
|
Text: d.Length,
|
|
FontName: positions.Font,
|
|
FontSize: uint64(positions.Fontsize[positions.Score["length"].Size]),
|
|
FontWeight: positions.FontWeight,
|
|
FontColor: rgba(positions.Color[positions.Score["length"].Color]),
|
|
},
|
|
},
|
|
},
|
|
{
|
|
Name: "jumperscore_rank",
|
|
X: int64(positions.Score["rank"].X),
|
|
Y: int64(positions.Score["rank"].Y),
|
|
Display: true,
|
|
BlendIn: 0,
|
|
BlendOut: 0,
|
|
OverlayData: &api.Overlay_TextOverlay{
|
|
TextOverlay: &api.TextOverlay{
|
|
Text: strconv.Itoa(d.Rank),
|
|
FontName: positions.Font,
|
|
FontSize: uint64(positions.Fontsize[positions.Score["rank"].Size]),
|
|
FontWeight: positions.FontWeight,
|
|
FontColor: rgba(positions.Color[positions.Score["rank"].Color]),
|
|
},
|
|
},
|
|
},
|
|
{
|
|
Name: "jumperscore_points",
|
|
X: int64(positions.Score["points"].X),
|
|
Y: int64(positions.Score["points"].Y),
|
|
Display: true,
|
|
BlendIn: 0,
|
|
BlendOut: 0,
|
|
OverlayData: &api.Overlay_TextOverlay{
|
|
TextOverlay: &api.TextOverlay{
|
|
Text: strconv.FormatFloat(d.Points, 'f', 2, 64),
|
|
FontName: positions.Font,
|
|
FontSize: uint64(positions.Fontsize[positions.Score["rank"].Size]),
|
|
FontWeight: positions.FontWeight,
|
|
FontColor: rgba(positions.Color[positions.Score["rank"].Color]),
|
|
},
|
|
},
|
|
},
|
|
{
|
|
Name: "jumperscore_wind",
|
|
X: int64(positions.Score["wind"].X),
|
|
Y: int64(positions.Score["wind"].Y),
|
|
Display: true,
|
|
BlendIn: 0,
|
|
BlendOut: 0,
|
|
OverlayData: &api.Overlay_TextOverlay{
|
|
TextOverlay: &api.TextOverlay{
|
|
Text: strconv.FormatFloat(d.Wind, 'f', 2, 64),
|
|
FontName: positions.Font,
|
|
FontSize: uint64(positions.Fontsize[positions.Score["wind"].Size]),
|
|
FontWeight: positions.FontWeight,
|
|
FontColor: rgba(positions.Color[positions.Score["wind"].Color]),
|
|
},
|
|
},
|
|
},
|
|
{
|
|
Name: "jumperscore_windtext",
|
|
X: int64(positions.Score["windtext"].X),
|
|
Y: int64(positions.Score["windtext"].Y),
|
|
Display: true,
|
|
BlendIn: 0,
|
|
BlendOut: 0,
|
|
OverlayData: &api.Overlay_TextOverlay{
|
|
TextOverlay: &api.TextOverlay{
|
|
Text: "Wind",
|
|
FontName: positions.Font,
|
|
FontSize: uint64(positions.Fontsize[positions.Score["windtext"].Size]),
|
|
FontWeight: positions.FontWeight,
|
|
FontColor: rgba(positions.Color[positions.Score["windtext"].Color]),
|
|
},
|
|
},
|
|
},
|
|
}
|
|
judgePositionY := positions.Score["judgeNationStart"].Y
|
|
for i, judge := range d.Judges {
|
|
y := judgePositionY - 40*i
|
|
o = append(o, &api.Overlay{
|
|
Name: fmt.Sprintf("jumperscore_judgenation_%v", i),
|
|
X: int64(positions.Score["judgeNationStart"].X),
|
|
Y: int64(y),
|
|
Display: true,
|
|
BlendIn: 0,
|
|
BlendOut: 0,
|
|
OverlayData: &api.Overlay_TextOverlay{
|
|
TextOverlay: &api.TextOverlay{
|
|
Text: judge.Nation,
|
|
FontName: positions.Font,
|
|
FontSize: uint64(positions.Fontsize[positions.Score["judgeNationStart"].Size]),
|
|
FontWeight: positions.FontWeight,
|
|
FontColor: rgba(positions.Color[positions.Score["judgeNationStart"].Color]),
|
|
},
|
|
},
|
|
})
|
|
discard := judge.Discard
|
|
if judge.Score == 0 {
|
|
discard = true
|
|
}
|
|
if judge.Score != 0 {
|
|
o = append(o, &api.Overlay{
|
|
Name: fmt.Sprintf("jumperscore_judgerating_%v", i),
|
|
X: int64(positions.Score["judgeRatingStart"].X),
|
|
Y: int64(y),
|
|
Display: true,
|
|
BlendIn: 0,
|
|
BlendOut: 0,
|
|
OverlayData: &api.Overlay_TextOverlay{
|
|
TextOverlay: &api.TextOverlay{
|
|
Text: strconv.FormatFloat(judge.Score, 'f', 1, 64),
|
|
FontName: positions.Font,
|
|
FontSize: uint64(positions.Fontsize[positions.Score["judgeRatingStart"].Size]),
|
|
FontWeight: positions.FontWeight,
|
|
FontColor: rgba(positions.Color[positions.Score["judgeRatingStart"].Color]),
|
|
},
|
|
},
|
|
})
|
|
}
|
|
if discard {
|
|
o = append(o, &api.Overlay{
|
|
Name: fmt.Sprintf("jumperscore_judgerating_%v", i),
|
|
X: int64(positions.Score["judgeRatingStart"].X),
|
|
Y: int64(y),
|
|
Display: true,
|
|
BlendIn: 0,
|
|
BlendOut: 0,
|
|
OverlayData: &api.Overlay_TextOverlay{
|
|
TextOverlay: &api.TextOverlay{
|
|
Text: discardText,
|
|
FontName: positions.Font,
|
|
FontSize: uint64(positions.Fontsize[positions.Score["judgeRatingStart"].Size]),
|
|
FontWeight: positions.FontWeight,
|
|
FontColor: rgba(positions.Color[positions.Score["judgeRatingStart"].Color]),
|
|
},
|
|
},
|
|
})
|
|
}
|
|
}
|
|
|
|
return o, nil
|
|
}
|