Skip to content

Commit

Permalink
added version iamge to title screen
Browse files Browse the repository at this point in the history
  • Loading branch information
sardap committed Mar 26, 2021
1 parent 42f9293 commit 1c3ca91
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 1 deletion.
Binary file modified assets/title_screen/tsTitleText.psd
Binary file not shown.
18 changes: 18 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ COPY ./tools/colour-agg/*.go ./

RUN go build -o main .

############################################

FROM golang:latest as builder-builder

WORKDIR /app
Expand All @@ -20,6 +22,18 @@ RUN go build -o main .

##################################################

FROM golang:latest as version-img-gen-builder

WORKDIR /app
COPY ./tools/version-img-gen/go.mod .
COPY ./tools/version-img-gen/go.sum .
RUN go mod download

COPY ./tools/version-img-gen/*.go ./

RUN go build -o main .

##################################################
#Devkit pro image is out of date also deabain is fucked here for some reason
FROM devkitpro/devkitarm:latest as GBA-builder

Expand All @@ -34,6 +48,10 @@ COPY --from=colour-agg-builder /app/main /bin/colour-agg.exe
COPY --from=builder-builder /app/main /bin/builder
RUN chmod +x /bin/builder

#Copy version-img-gen-builder
COPY --from=version-img-gen-builder /app/main /bin/version-img-gen
RUN chmod +x /bin/version-img-gen

RUN mkdir /app

WORKDIR /app
Expand Down
2 changes: 1 addition & 1 deletion make_assets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ gen_png "./assets/title_screen"

OBJECTS="$OBJECTS $PWD/assets/text/lifeTitle.png "

# colour-agg.exe ./assets/objects_out.png $OBJECTS
version-img-gen ./assets/title_screen/tsTitleText.png

colour-agg.exe ./assets/title_screen/tsBackgroundAgg.png \
./assets/title_screen/tsEmpty.png \
Expand Down
5 changes: 5 additions & 0 deletions tools/version-img-gen/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/sardap/walk-good-maybe/tools/version-img-gen

go 1.16

require github.com/pbnjay/pixfont v0.0.0-20200714042608-33b744692567 // indirect
2 changes: 2 additions & 0 deletions tools/version-img-gen/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/pbnjay/pixfont v0.0.0-20200714042608-33b744692567 h1:pKjmNHL7BCXhgsnSlN6Ov3WAN2jbJMCx6IvrMN9GNfc=
github.com/pbnjay/pixfont v0.0.0-20200714042608-33b744692567/go.mod h1:ytYavTmrpWG4s7UOfDhP6m4ASL5XA66nrOcUn1e2M78=
67 changes: 67 additions & 0 deletions tools/version-img-gen/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package main

import (
"fmt"
"image"
"image/color"
"image/draw"
"image/png"
"os"
"os/exec"
"strconv"
"strings"

"github.com/pbnjay/pixfont"
)

func getVersion() string {
descCmd := exec.Command("git", "describe", "--exact-match")
version, err := descCmd.CombinedOutput()
if err != nil {
cmd := exec.Command("git", "describe", "--tags", "--abbrev=0")
out, err := cmd.CombinedOutput()
if err != nil {
fmt.Printf("error running make %v\n", err)
fmt.Printf("out %s", out)
os.Exit(2)
}

splits := strings.Split(string(out), ".")

bumpNum, _ := strconv.ParseInt(splits[1], 10, 64)

bumpNum++

version = []byte(fmt.Sprintf("%s.%d.%s", splits[0], bumpNum, splits[2]))
}

return string(version)
}

func main() {
textImg := image.NewRGBA(image.Rect(0, 0, 64, 16))

pixfont.DrawString(textImg, 0, 0, getVersion(), color.White)

for y := 0; y < textImg.Rect.Max.Y; y++ {
for x := 0; x < textImg.Rect.Max.X; x++ {
if textImg.RGBAAt(x, y).A == 0 {
textImg.Set(x, y, color.RGBA{R: 255, G: 0, B: 246, A: 255})
}
}
}

inF, _ := os.Open(os.Args[1])
bgImg, _ := png.Decode(inF)
inF.Close()

b := bgImg.Bounds()
dst := image.NewRGBA(image.Rect(0, 0, b.Dx(), b.Dy()))
draw.Draw(dst, dst.Bounds(), bgImg, b.Min, draw.Src)
draw.Draw(dst, textImg.Bounds().Add(image.Point{X: 0, Y: 160 - 8}), textImg, image.Point{}, draw.Over)

os.Remove(os.Args[1])
f, _ := os.Create(os.Args[1])
defer f.Close()
png.Encode(f, dst)
}

0 comments on commit 1c3ca91

Please sign in to comment.