MCPcopy Create free account
hub / github.com/SolarLune/masterplan / DrawOnTop

Method DrawOnTop

gui.go:4388–4447  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4386}
4387
4388func (tt *Tooltip) DrawOnTop() {
4389
4390 if tt.Displaying {
4391
4392 fontSizeMult := float32(0.75)
4393
4394 textSize := globals.TextRenderer.MeasureText([]rune(tt.Text), fontSizeMult)
4395
4396 margin := float32(32)
4397
4398 if textSize.X < 16 {
4399 textSize.X = 16
4400 }
4401
4402 if textSize.Y < 16 {
4403 textSize.Y = 16
4404 }
4405
4406 menuColor := getThemeColor(GUIMenuColor)
4407 fontColor := getThemeColor(GUIFontColor)
4408
4409 midHeight := globals.ScreenSize.Y / 2
4410
4411 pos := tt.SpawnStart
4412
4413 if pos.Y > midHeight {
4414 pos.Y -= textSize.Y + 32
4415 } else {
4416 pos.Y += 64
4417 }
4418
4419 maxX := globals.ScreenSize.X - textSize.X
4420 if pos.X > maxX {
4421 pos.X = maxX
4422 }
4423
4424 maxY := globals.ScreenSize.Y - textSize.Y
4425 if pos.Y > maxY {
4426 pos.Y = maxY
4427 }
4428
4429 dst := &sdl.FRect{pos.X, pos.Y, textSize.X, textSize.Y}
4430
4431 dst.X -= margin
4432 dst.Y -= margin
4433 dst.W += margin
4434 dst.H += margin
4435
4436 shadow := NewColor(0, 0, 0, 150)
4437 FillRect(dst.X+16, dst.Y+16, dst.W, dst.H, shadow)
4438 FillRect(dst.X, dst.Y, dst.W, dst.H, fontColor)
4439 FillRect(dst.X+2, dst.Y+2, dst.W-4, dst.H-4, menuColor)
4440
4441 globals.TextRenderer.QuickRenderText(tt.Text, Vector{dst.X + (margin / 2), dst.Y + (margin / 2)}, fontSizeMult, getThemeColor(GUIFontColor), nil, AlignLeft)
4442
4443 } else if globals.DrawOnTop == tt {
4444 globals.DrawOnTop = nil
4445 }

Callers

nothing calls this directly

Calls 5

getThemeColorFunction · 0.85
NewColorFunction · 0.85
FillRectFunction · 0.85
MeasureTextMethod · 0.80
QuickRenderTextMethod · 0.80

Tested by

no test coverage detected