Display profile icons
This commit is contained in:
parent
bdbf727c67
commit
544c7e4f7c
6 changed files with 60 additions and 5 deletions
|
@ -1,4 +1,5 @@
|
|||
1.3.8:
|
||||
- Display profile icons
|
||||
- Allow muting individual sound effects
|
||||
- Play sound when bearing off checker
|
||||
|
||||
|
|
BIN
game/asset/image/profile_birthday_1.png
Normal file
BIN
game/asset/image/profile_birthday_1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.3 KiB |
|
@ -19,6 +19,7 @@ import (
|
|||
"code.rocket9labs.com/tslocum/gotext"
|
||||
"code.rocket9labs.com/tslocum/tabula"
|
||||
"github.com/hajimehoshi/ebiten/v2"
|
||||
"github.com/hajimehoshi/ebiten/v2/colorm"
|
||||
"github.com/hajimehoshi/ebiten/v2/inpututil"
|
||||
"github.com/hajimehoshi/ebiten/v2/text"
|
||||
"github.com/llgcode/draw2d/draw2dimg"
|
||||
|
@ -61,6 +62,8 @@ type board struct {
|
|||
lastDoubleValue int8
|
||||
lastDoublePlayer int8
|
||||
lastVariant int8
|
||||
lastIconPlayer int
|
||||
lastIconOpponent int
|
||||
|
||||
gameState *bgammon.GameState
|
||||
|
||||
|
@ -1691,6 +1694,51 @@ func (b *board) updateBackgroundImage() {
|
|||
}
|
||||
text.Draw(b.backgroundImage, sp, ff, x, y+(int(b.verticalBorderSize)-b.lineHeight)/2+b.lineOffset, spaceLabelColor)
|
||||
}
|
||||
|
||||
// Draw profile icons.
|
||||
var opponentIcon, playerIcon *ebiten.Image
|
||||
if b.gameState.Player2.Icon == 1 {
|
||||
opponentIcon = imgProfileBirthday1
|
||||
}
|
||||
if b.gameState.Player1.Icon == 1 {
|
||||
playerIcon = imgProfileBirthday1
|
||||
}
|
||||
if opponentIcon == nil && playerIcon == nil {
|
||||
return
|
||||
}
|
||||
drawProfileIcon := func(icon *ebiten.Image, x float64, y float64, scale float64, opacity float64, invert bool) {
|
||||
var c colorm.ColorM
|
||||
if invert {
|
||||
c.Scale(-1, -1, -1, opacity)
|
||||
c.Translate(1, 1, 1, 0)
|
||||
} else {
|
||||
c.Scale(1, 1, 1, opacity)
|
||||
}
|
||||
op := &colorm.DrawImageOptions{}
|
||||
op.GeoM.Scale(scale, scale)
|
||||
op.GeoM.Translate(x, y)
|
||||
colorm.DrawImage(b.backgroundImage, icon, c, op)
|
||||
}
|
||||
scale := b.spaceWidth / float64(232)
|
||||
baseOpacity := 0.1
|
||||
dividerHeight := float64(etk.Scale(15))
|
||||
checkerHeight := (b.spaceWidth + b.overlapSize*4 - dividerHeight*2) / 15
|
||||
if opponentIcon != nil {
|
||||
x, y := edge+b.horizontalBorderSize, float64(b.y)+b.verticalBorderSize+dividerHeight+checkerHeight*10+2-b.spaceWidth-1
|
||||
opacity := baseOpacity / 2
|
||||
if b.flipBoard {
|
||||
opacity = baseOpacity
|
||||
}
|
||||
drawProfileIcon(opponentIcon, x, y, scale, opacity, !b.flipBoard)
|
||||
}
|
||||
if playerIcon != nil {
|
||||
x, y := edge+b.horizontalBorderSize, float64(b.h)-b.verticalBorderSize-b.spaceWidth-dividerHeight-checkerHeight*5+2
|
||||
opacity := baseOpacity
|
||||
if b.flipBoard {
|
||||
opacity = baseOpacity / 2
|
||||
}
|
||||
drawProfileIcon(playerIcon, x, y, scale, opacity, b.flipBoard)
|
||||
}
|
||||
}
|
||||
|
||||
func (b *board) drawChecker(target *ebiten.Image, checker *ebiten.Image, x float64, y float64, white bool, side bool) {
|
||||
|
@ -2542,7 +2590,7 @@ func (b *board) processState() {
|
|||
if b.lastPlayerNumber != b.gameState.PlayerNumber || b.lastVariant != b.gameState.Variant {
|
||||
b.setSpaceRects()
|
||||
b.updateBackgroundImage()
|
||||
} else if b.lastPoints != b.gameState.Points || b.lastDoublePlayer != b.gameState.DoublePlayer || b.lastDoubleValue != b.gameState.DoubleValue {
|
||||
} else if b.lastPoints != b.gameState.Points || b.lastDoublePlayer != b.gameState.DoublePlayer || b.lastDoubleValue != b.gameState.DoubleValue || b.lastIconPlayer != b.gameState.Player1.Icon || b.lastIconOpponent != b.gameState.Player2.Icon {
|
||||
b.updateBackgroundImage()
|
||||
}
|
||||
b.lastPlayerNumber = b.gameState.PlayerNumber
|
||||
|
@ -2550,6 +2598,8 @@ func (b *board) processState() {
|
|||
b.lastPoints = b.gameState.Points
|
||||
b.lastDoublePlayer = b.gameState.DoublePlayer
|
||||
b.lastDoubleValue = b.gameState.DoubleValue
|
||||
b.lastIconPlayer = b.gameState.Player1.Icon
|
||||
b.lastIconOpponent = b.gameState.Player2.Icon
|
||||
|
||||
if b.flipBoard || b.gameState.PlayerNumber == 2 {
|
||||
if b.opponentLabel.activeColor != colorBlack {
|
||||
|
|
|
@ -38,7 +38,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
version = "v1.3.7p5"
|
||||
version = "v1.3.8"
|
||||
baseButtonHeight = 54
|
||||
MaxDebug = 2
|
||||
DefaultServerAddress = "wss://ws.bgammon.org"
|
||||
|
@ -78,6 +78,8 @@ var (
|
|||
imgCubes32 *ebiten.Image
|
||||
imgCubes64 *ebiten.Image
|
||||
|
||||
imgProfileBirthday1 *ebiten.Image
|
||||
|
||||
fontMutex = &sync.Mutex{}
|
||||
)
|
||||
|
||||
|
@ -240,6 +242,8 @@ func loadImageAssets(width int) {
|
|||
imgCubes16 = resizeDice(imgCubes.SubImage(image.Rect(0, size*1, size*1, size*2)), 0.6)
|
||||
imgCubes32 = resizeDice(imgCubes.SubImage(image.Rect(size*1, size*1, size*2, size*2)), 0.6)
|
||||
imgCubes64 = resizeDice(imgCubes.SubImage(image.Rect(size*2, size*1, size*3, size*2)), 0.6)
|
||||
|
||||
imgProfileBirthday1 = ebiten.NewImageFromImage(loadImage("asset/image/profile_birthday_1.png"))
|
||||
}
|
||||
|
||||
func loadAudioAssets() {
|
||||
|
|
2
go.mod
2
go.mod
|
@ -3,7 +3,7 @@ module code.rocket9labs.com/tslocum/boxcars
|
|||
go 1.19
|
||||
|
||||
require (
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240730214525-b8350930830d
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240801215517-64b10515b06d
|
||||
code.rocket9labs.com/tslocum/bgammon-bei-bot v0.0.0-20240721175208-e769215e74fc
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20240722214147-c1f1fe1adb37
|
||||
code.rocket9labs.com/tslocum/gotext v0.0.0-20240728181248-46f419ff143b
|
||||
|
|
4
go.sum
4
go.sum
|
@ -1,7 +1,7 @@
|
|||
code.rocket9labs.com/tslocum/bei v0.0.0-20240108012722-6db380cc190b h1:Y0a14Kf/hSYepSmp4ZfDeE4CZZGBGBS97CNjCbKJm0c=
|
||||
code.rocket9labs.com/tslocum/bei v0.0.0-20240108012722-6db380cc190b/go.mod h1:tS60/VNAJphKvDBkSLQhKALa15msIAuWWfEKNc4oFZc=
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240730214525-b8350930830d h1:y3LuMRil6F7gdT3uRQ2Ex7dfo59Xx21e46KIWHWJFYU=
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240730214525-b8350930830d/go.mod h1:1H0nfNCNy5ien/RnAeOUxMG0TTuv/2+9rOIgBZYdKx0=
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240801215517-64b10515b06d h1:q7w7wvO9M1YYqbLCYqdgAkIh+ns21uT2hL/29YeoqEQ=
|
||||
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240801215517-64b10515b06d/go.mod h1:1H0nfNCNy5ien/RnAeOUxMG0TTuv/2+9rOIgBZYdKx0=
|
||||
code.rocket9labs.com/tslocum/bgammon-bei-bot v0.0.0-20240721175208-e769215e74fc h1:zKspzJaha5v9qsfV1sy920JxCMgXNLRxux0DmQOPPlA=
|
||||
code.rocket9labs.com/tslocum/bgammon-bei-bot v0.0.0-20240721175208-e769215e74fc/go.mod h1:odKdJABSCpTEsL/AfUJ4FX3Lb1dn2bjiL0tc5qV15G8=
|
||||
code.rocket9labs.com/tslocum/etk v0.0.0-20240722214147-c1f1fe1adb37 h1:A40EvxTo0L/tA4D9DqQJmU8bbT4JzLZtmp5icnYu2yU=
|
||||
|
|
Loading…
Reference in a new issue