Consolodated config, added portals, etc.
This commit is contained in:
@@ -114,21 +114,24 @@ func (b Bar) Draw(screen *ebiten.Image, x, y int) (int, int) {
|
||||
fillWidth = maxWidth
|
||||
}
|
||||
|
||||
if b.ShowBorder {
|
||||
borderColor := b.BorderColor
|
||||
if borderColor == nil {
|
||||
borderColor = color.RGBA{R: 80, G: 80, B: 80, A: 255}
|
||||
}
|
||||
drawRect(screen, x, y, maxWidth, 1, borderColor)
|
||||
drawRect(screen, x, y+height-1, maxWidth, 1, borderColor)
|
||||
drawRect(screen, x, y, 1, height, borderColor)
|
||||
drawRect(screen, x+maxWidth-1, y, 1, height, borderColor)
|
||||
}
|
||||
// Draw dark background
|
||||
drawRect(screen, x, y, maxWidth, height, color.RGBA{R: 30, G: 30, B: 30, A: 255})
|
||||
|
||||
// Draw filled portion
|
||||
if fillWidth > 0 {
|
||||
drawRect(screen, x, y, fillWidth, height, b.Meter.Color)
|
||||
}
|
||||
|
||||
// Draw border
|
||||
borderColor := b.BorderColor
|
||||
if borderColor == nil {
|
||||
borderColor = color.RGBA{R: 180, G: 180, B: 180, A: 255}
|
||||
}
|
||||
drawRect(screen, x, y, maxWidth, 1, borderColor)
|
||||
drawRect(screen, x, y+height-1, maxWidth, 1, borderColor)
|
||||
drawRect(screen, x, y, 1, height, borderColor)
|
||||
drawRect(screen, x+maxWidth-1, y, 1, height, borderColor)
|
||||
|
||||
return maxWidth, height
|
||||
}
|
||||
|
||||
|
||||
@@ -4,14 +4,16 @@ import (
|
||||
"image/color"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2"
|
||||
"github.com/hajimehoshi/ebiten/v2/vector"
|
||||
|
||||
"github.com/atridad/LilGuy/internal/status"
|
||||
)
|
||||
|
||||
type Overlay struct {
|
||||
X int
|
||||
Y int
|
||||
Color color.Color
|
||||
X int
|
||||
Y int
|
||||
Color color.Color
|
||||
ScreenName string
|
||||
}
|
||||
|
||||
func (o Overlay) Draw(screen *ebiten.Image, meters []status.Meter) {
|
||||
@@ -19,35 +21,64 @@ func (o Overlay) Draw(screen *ebiten.Image, meters []status.Meter) {
|
||||
o.Color = color.White
|
||||
}
|
||||
|
||||
// Draw background box for instructions
|
||||
instrBoxWidth := float32(280)
|
||||
instrBoxHeight := float32(78)
|
||||
instrBoxPaddingX := float32(12)
|
||||
instrBoxPaddingY := float32(15)
|
||||
vector.FillRect(screen, 10, 10, instrBoxWidth, instrBoxHeight,
|
||||
color.NRGBA{R: 0, G: 0, B: 0, A: 180}, false)
|
||||
vector.StrokeRect(screen, 10, 10, instrBoxWidth, instrBoxHeight, 2,
|
||||
color.NRGBA{R: 200, G: 200, B: 200, A: 255}, false)
|
||||
|
||||
screenName := o.ScreenName
|
||||
if screenName == "" {
|
||||
screenName = "Lil Guy"
|
||||
}
|
||||
|
||||
instructions := Column{
|
||||
Elements: []Element{
|
||||
Label{Text: "Lil Guy", Color: o.Color},
|
||||
Label{Text: "Move with Arrow Keys / WASD", Color: o.Color},
|
||||
Label{Text: "Hold Shift to Sprint", Color: o.Color}},
|
||||
Label{Text: screenName, Color: color.NRGBA{R: 255, G: 255, B: 100, A: 255}},
|
||||
Label{Text: "Move with Arrow Keys / WASD", Color: color.NRGBA{R: 230, G: 230, B: 230, A: 255}},
|
||||
Label{Text: "Hold Shift to Sprint", Color: color.NRGBA{R: 230, G: 230, B: 230, A: 255}},
|
||||
},
|
||||
Spacing: 7,
|
||||
}
|
||||
instructions.Draw(screen, 16, 16)
|
||||
instructions.Draw(screen, int(10+instrBoxPaddingX), int(10+instrBoxPaddingY))
|
||||
|
||||
// Draw background box for meters
|
||||
meterBoxPaddingX := float32(12)
|
||||
meterBoxPaddingTop := float32(15)
|
||||
meterBoxPaddingBottom := float32(8)
|
||||
meterBoxWidth := float32(220)
|
||||
meterBoxHeight := float32(meterBoxPaddingTop + meterBoxPaddingBottom + float32(len(meters))*35 - 5)
|
||||
meterBoxX := float32(o.X) - meterBoxPaddingX
|
||||
meterBoxY := float32(o.Y) - meterBoxPaddingTop
|
||||
vector.FillRect(screen, meterBoxX, meterBoxY, meterBoxWidth, meterBoxHeight,
|
||||
color.NRGBA{R: 0, G: 0, B: 0, A: 180}, false)
|
||||
vector.StrokeRect(screen, meterBoxX, meterBoxY, meterBoxWidth, meterBoxHeight, 2,
|
||||
color.NRGBA{R: 200, G: 200, B: 200, A: 255}, false)
|
||||
|
||||
meterElements := make([]Element, 0, len(meters))
|
||||
for _, meter := range meters {
|
||||
if meter.Base < 0 {
|
||||
meterElements = append(meterElements,
|
||||
MeterLabel{Meter: meter, Color: o.Color},
|
||||
MeterLabel{Meter: meter, Color: color.NRGBA{R: 255, G: 255, B: 255, A: 255}},
|
||||
)
|
||||
} else {
|
||||
meterElements = append(meterElements, Column{
|
||||
Elements: []Element{
|
||||
MeterLabel{Meter: meter, Color: o.Color},
|
||||
Bar{Meter: meter, MaxWidth: 180, Height: 8, ShowBorder: false},
|
||||
MeterLabel{Meter: meter, Color: color.NRGBA{R: 255, G: 255, B: 255, A: 255}},
|
||||
Bar{Meter: meter, MaxWidth: 180, Height: 10, ShowBorder: true},
|
||||
},
|
||||
Spacing: 2,
|
||||
Spacing: 4,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
meterPanel := Column{
|
||||
Elements: meterElements,
|
||||
Spacing: 16,
|
||||
Spacing: 18,
|
||||
}
|
||||
meterPanel.Draw(screen, o.X, o.Y)
|
||||
}
|
||||
|
||||
@@ -84,6 +84,10 @@ func (m *PauseMenu) SetFPSCap(cap FPSCapSetting) {
|
||||
m.settingsScreen.SetFPSCap(cap)
|
||||
}
|
||||
|
||||
func (m *PauseMenu) SetPortalVisibility(enabled *bool) {
|
||||
m.settingsScreen.SetPortalVisibility(enabled)
|
||||
}
|
||||
|
||||
// Update logic
|
||||
|
||||
func (m *PauseMenu) Update() *MenuOption {
|
||||
@@ -140,7 +144,7 @@ func (m *PauseMenu) Draw(screen *ebiten.Image, screenWidth, screenHeight int) {
|
||||
menuX := (screenWidth - menuWidth) / 2
|
||||
menuY := (screenHeight - menuHeight) / 2
|
||||
|
||||
vector.DrawFilledRect(screen,
|
||||
vector.FillRect(screen,
|
||||
float32(menuX), float32(menuY),
|
||||
float32(menuWidth), float32(menuHeight),
|
||||
color.RGBA{R: 40, G: 40, B: 50, A: 255},
|
||||
@@ -192,7 +196,7 @@ func (m *PauseMenu) drawMain(screen *ebiten.Image, menuX, menuY, menuWidth, menu
|
||||
}
|
||||
|
||||
func (m *PauseMenu) drawSettings(screen *ebiten.Image, menuX, menuY, menuWidth, menuHeight int) {
|
||||
vector.DrawFilledRect(screen,
|
||||
vector.FillRect(screen,
|
||||
float32(menuX), float32(menuY),
|
||||
float32(menuWidth), float32(menuHeight),
|
||||
color.RGBA{R: 40, G: 40, B: 50, A: 255},
|
||||
|
||||
Reference in New Issue
Block a user