click on stars to set rating

This commit is contained in:
Colin McMillen 2023-07-26 15:20:20 -04:00
parent 8ca4ff7cad
commit 247d6ac6f2

View File

@ -596,14 +596,21 @@ public class Game : GameWindow {
upTimer = Int64.MaxValue;
}
// Look for mouse clicks on thumbnails.
// Look for mouse clicks on thumbnails or stars.
//
// Note that we don't bounds-check photoIndex until after all the possible
// inputs that might affect it. That simplifies this logic significantly.
if (MouseState.IsButtonPressed(MouseButton.Button1)) {
Vector2i click = (Vector2i) MouseState.Position;
for (int i = 0; i < geometry.StarBoxes.Count; i++) {
if (geometry.StarBoxes[i].ContainsInclusive(click)) {
photos[photoIndex].Rating = i + 1;
}
}
for (int i = 0; i < geometry.ThumbnailBoxes.Count; i++) {
Box2i box = geometry.ThumbnailBoxes[i];
if (box.ContainsInclusive((Vector2i) MouseState.Position)) {
if (geometry.ThumbnailBoxes[i].ContainsInclusive(click)) {
photoIndex = ribbonIndex + i;
}
}