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

Method Update

contents.go:1392–1454  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1390}
1391
1392func (ic *ImageContents) Update() {
1393
1394 if ic.Card.IsSelected() {
1395
1396 for _, button := range ic.Buttons {
1397 button.Update()
1398 }
1399
1400 }
1401
1402 resource := ic.Resource
1403
1404 if resource == nil {
1405 resource = ic.DefaultImage
1406 }
1407
1408 if ic.ValidResource() {
1409
1410 if !ic.LoadedImage {
1411
1412 zoom := ic.Card.Page.Project.Camera.Zoom
1413
1414 sizeMultiplier := globals.ScreenSize.X / 8.0 / zoom
1415
1416 if resource.IsTexture() {
1417
1418 asr := resource.AsImage().Size.Y / resource.AsImage().Size.X
1419 ic.Card.Recreate(sizeMultiplier, sizeMultiplier*asr)
1420 ic.LoadedImage = true
1421
1422 } else if resource.IsGIF() && resource.AsGIF().IsReady() {
1423
1424 asr := resource.AsGIF().Height / resource.AsGIF().Width
1425 ic.Card.Recreate(sizeMultiplier, sizeMultiplier*asr)
1426 ic.GifPlayer = NewGifPlayer(resource.AsGIF())
1427 ic.LoadedImage = true
1428
1429 }
1430
1431 } else if ic.Resource.IsGIF() && ic.Resource.AsGIF().LoadingProgress() >= 1 && ic.GifPlayer == nil {
1432 // Happens specifically when loading a project with an already existing GIF
1433 ic.GifPlayer = NewGifPlayer(ic.Resource.AsGIF())
1434 }
1435
1436 if resource.SaveFile {
1437 ic.Card.Properties.Get("saveimage").Set(true) // InUse = true now
1438 }
1439
1440 if ic.GifPlayer != nil {
1441 ic.GifPlayer.Update(globals.DeltaTime)
1442 }
1443
1444 if !globals.Keybindings.Pressed(KBUnlockImageASR) {
1445 if resource.IsTexture() {
1446 ic.Card.LockResizingAspectRatio = resource.AsImage().Size.Y / resource.AsImage().Size.X
1447 } else if resource.IsGIF() {
1448 ic.Card.LockResizingAspectRatio = resource.AsGIF().Height / resource.AsGIF().Width
1449 }

Callers

nothing calls this directly

Calls 14

ValidResourceMethod · 0.95
NewGifPlayerFunction · 0.85
IsSelectedMethod · 0.80
IsTextureMethod · 0.80
AsImageMethod · 0.80
IsGIFMethod · 0.80
IsReadyMethod · 0.80
AsGIFMethod · 0.80
LoadingProgressMethod · 0.80
UpdateMethod · 0.65
RecreateMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected