Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions HenLoader/src/org/bdj/InitXlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void run()
console = new PrintStream(new MessagesOutputStream(messages, scene));
//InputStream is = getClass().getResourceAsStream("/program.data.bin");
//CRunTime.init(is);

console.println("Hen Loader LP v1.0, based on:");
console.println("- GoldHEN 2.4b18.7 by SiSTR0");
console.println("- poops code by theflow0");
Expand Down Expand Up @@ -112,11 +112,39 @@ public void run()
} else {
console.println("* X = Poops");
}

console.println("(Auto-selecting in 1 second...)");

long startTime = System.currentTimeMillis();
long timeout = 1000; // 1 second
boolean autoSelected = false;

while ((c != BUTTON_O || !lapseSupported) && c != BUTTON_X)
{
c = pollInput();
long currentTime = System.currentTimeMillis();
if (currentTime - startTime >= timeout && c == 0)
{
c = BUTTON_X;
autoSelected = true;
break;
}
if (c == 0) {
try {
Thread.sleep(10); // Small sleep to avoid busy waiting
} catch (InterruptedException e) {
break;
}
}
}

if (autoSelected) {
if (lapseSupported) {
console.println("Auto-selected: Lapse");
} else {
console.println("Auto-selected: Poops");
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using this might be a little helpful

console.println("Auto-selected: " + (lapseSupported ? "Lapse" : "Poops"));

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about this becoming more complicated than two options in the future.
But for now I don't think the ternary would be an issue.
Please submit as code suggestion. Use this button:
image

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it would become simpler, one line

Okay mate I'll use "Add a suggestion" button from now on, thank you for your effort.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code quality is not measured by number of lines, there are other factors involved. But your suggestion was good.

}

if (c == BUTTON_X && lapseSupported)
{
int result = org.bdj.external.Lapse.main(console);
Expand Down