remove keyboard autorepeat and change IsKeyDown -> IsKeyPressed
This commit is contained in:
parent
42ea309794
commit
067b54a77d
55
Program.cs
55
Program.cs
@ -551,10 +551,6 @@ public class Game : GameWindow {
|
|||||||
UiGeometry geometry = new();
|
UiGeometry geometry = new();
|
||||||
FpsCounter fpsCounter = new();
|
FpsCounter fpsCounter = new();
|
||||||
|
|
||||||
// Input handling.
|
|
||||||
long downTimer = Int64.MaxValue;
|
|
||||||
long upTimer = Int64.MaxValue;
|
|
||||||
|
|
||||||
// Four points, each consisting of (x, y, z, tex_x, tex_y).
|
// Four points, each consisting of (x, y, z, tex_x, tex_y).
|
||||||
float[] vertices = new float[20];
|
float[] vertices = new float[20];
|
||||||
|
|
||||||
@ -577,25 +573,15 @@ public class Game : GameWindow {
|
|||||||
|
|
||||||
protected override void OnUpdateFrame(FrameEventArgs e) {
|
protected override void OnUpdateFrame(FrameEventArgs e) {
|
||||||
base.OnUpdateFrame(e);
|
base.OnUpdateFrame(e);
|
||||||
long now = DateTime.Now.Ticks;
|
|
||||||
|
|
||||||
KeyboardState input = KeyboardState;
|
KeyboardState input = KeyboardState;
|
||||||
|
|
||||||
// FIXME: add a confirm dialog before closing. (Also for the window-close button.)
|
// FIXME: add a confirm dialog before closing. (Also for the window-close button.)
|
||||||
// Close when Escape is pressed.
|
// Close when Escape is pressed.
|
||||||
if (input.IsKeyDown(Keys.Escape)) {
|
if (input.IsKeyPressed(Keys.Escape)) {
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Track keyboard repeat times for advancing up/down.
|
|
||||||
if (!input.IsKeyDown(Keys.Down)) {
|
|
||||||
downTimer = Int64.MaxValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!input.IsKeyDown(Keys.Up)) {
|
|
||||||
upTimer = Int64.MaxValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Look for mouse clicks on thumbnails or stars.
|
// Look for mouse clicks on thumbnails or stars.
|
||||||
//
|
//
|
||||||
// Note that we don't bounds-check photoIndex until after all the possible
|
// Note that we don't bounds-check photoIndex until after all the possible
|
||||||
@ -632,13 +618,10 @@ public class Game : GameWindow {
|
|||||||
photoIndex--;
|
photoIndex--;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: make a proper Model class for tracking the state of the controls?
|
if (input.IsKeyPressed(Keys.Down)) {
|
||||||
if (input.IsKeyPressed(Keys.Down) || now > downTimer) {
|
|
||||||
downTimer = now + 10000 * 200;
|
|
||||||
photoIndex++;
|
photoIndex++;
|
||||||
}
|
}
|
||||||
if (input.IsKeyPressed(Keys.Up) || now > upTimer) {
|
if (input.IsKeyPressed(Keys.Up)) {
|
||||||
upTimer = now + 10000 * 200;
|
|
||||||
photoIndex--;
|
photoIndex--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,61 +634,61 @@ public class Game : GameWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (input.IsKeyPressed(Keys.PageDown)) {
|
if (input.IsKeyPressed(Keys.PageDown)) {
|
||||||
photoIndex += 10;
|
photoIndex += 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.IsKeyPressed(Keys.PageUp)) {
|
if (input.IsKeyPressed(Keys.PageUp)) {
|
||||||
photoIndex -= 10;
|
photoIndex -= 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the photoIndex is actually valid.
|
// Make sure the photoIndex is actually valid.
|
||||||
photoIndex = Math.Clamp(photoIndex, 0, photos.Count - 1);
|
photoIndex = Math.Clamp(photoIndex, 0, photos.Count - 1);
|
||||||
|
|
||||||
if (input.IsKeyDown(Keys.D0) || input.IsKeyDown(Keys.GraveAccent)) {
|
if (input.IsKeyPressed(Keys.D0) || input.IsKeyPressed(Keys.GraveAccent)) {
|
||||||
photos[photoIndex].Rating = 0;
|
photos[photoIndex].Rating = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.IsKeyDown(Keys.D1)) {
|
if (input.IsKeyPressed(Keys.D1)) {
|
||||||
photos[photoIndex].Rating = 1;
|
photos[photoIndex].Rating = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.IsKeyDown(Keys.D2)) {
|
if (input.IsKeyPressed(Keys.D2)) {
|
||||||
photos[photoIndex].Rating = 2;
|
photos[photoIndex].Rating = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.IsKeyDown(Keys.D3)) {
|
if (input.IsKeyPressed(Keys.D3)) {
|
||||||
photos[photoIndex].Rating = 3;
|
photos[photoIndex].Rating = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.IsKeyDown(Keys.D4)) {
|
if (input.IsKeyPressed(Keys.D4)) {
|
||||||
photos[photoIndex].Rating = 4;
|
photos[photoIndex].Rating = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.IsKeyDown(Keys.D5)) {
|
if (input.IsKeyPressed(Keys.D5)) {
|
||||||
photos[photoIndex].Rating = 5;
|
photos[photoIndex].Rating = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.IsKeyDown(Keys.Q)) {
|
if (input.IsKeyPressed(Keys.Q)) {
|
||||||
zoomLevel = 0f;
|
zoomLevel = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.IsKeyDown(Keys.W)) {
|
if (input.IsKeyPressed(Keys.W)) {
|
||||||
zoomLevel = 1f;
|
zoomLevel = 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.IsKeyDown(Keys.E)) {
|
if (input.IsKeyPressed(Keys.E)) {
|
||||||
zoomLevel = 2f;
|
zoomLevel = 2f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.IsKeyDown(Keys.R)) {
|
if (input.IsKeyPressed(Keys.R)) {
|
||||||
zoomLevel = 4f;
|
zoomLevel = 4f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.IsKeyDown(Keys.T)) {
|
if (input.IsKeyPressed(Keys.T)) {
|
||||||
zoomLevel = 8f;
|
zoomLevel = 8f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.IsKeyDown(Keys.Y)) {
|
if (input.IsKeyPressed(Keys.Y)) {
|
||||||
zoomLevel = 16f;
|
zoomLevel = 16f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -749,10 +732,10 @@ public class Game : GameWindow {
|
|||||||
// Load photos from a directory.
|
// Load photos from a directory.
|
||||||
// string[] files = Directory.GetFiles(@"c:\users\colin\desktop\photos-test\");
|
// string[] files = Directory.GetFiles(@"c:\users\colin\desktop\photos-test\");
|
||||||
// string[] files = Directory.GetFiles(@"c:\users\colin\pictures\photos\2023\07\14\");
|
// string[] files = Directory.GetFiles(@"c:\users\colin\pictures\photos\2023\07\14\");
|
||||||
string[] files = Directory.GetFiles(@"G:\DCIM\100EOSR6\");
|
// string[] files = Directory.GetFiles(@"G:\DCIM\100EOSR6\");
|
||||||
// string[] files = Directory.GetFiles(@"C:\Users\colin\Pictures\photos\2018\06\23");
|
// string[] files = Directory.GetFiles(@"C:\Users\colin\Pictures\photos\2018\06\23");
|
||||||
// string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\Germany all\104D7000");
|
// string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\Germany all\104D7000");
|
||||||
// string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\many-birds\");
|
string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\many-birds\");
|
||||||
|
|
||||||
for (int i = 0; i < files.Count(); i++) {
|
for (int i = 0; i < files.Count(); i++) {
|
||||||
string file = files[i];
|
string file = files[i];
|
||||||
|
Loading…
Reference in New Issue
Block a user