()
| 1390 | } |
| 1391 | |
| 1392 | func (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 | } |
nothing calls this directly
no test coverage detected