-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added/changed: - Added utilities to viewer screens - Subtle design improvements to viewer screens - Copying screenshots works now - 9 billion other things
- Loading branch information
1 parent
2541608
commit e4b8850
Showing
9 changed files
with
245 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/client/java/dev/spiritstudios/snapper/gui/RenameScreenshotScreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package dev.spiritstudios.snapper.gui; | ||
|
||
import dev.spiritstudios.snapper.util.ScreenshotActions; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.font.TextRenderer; | ||
import net.minecraft.client.gui.DrawContext; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.client.gui.widget.*; | ||
import net.minecraft.screen.ScreenTexts; | ||
import net.minecraft.text.Text; | ||
|
||
import java.io.File; | ||
|
||
public class RenameScreenshotScreen extends Screen { | ||
|
||
private final File screenshot; | ||
private final TextFieldWidget renameInput; | ||
private final Text RENAME_INPUT_TEXT = Text.translatable("text.snapper.rename_input"); | ||
private final MinecraftClient client = MinecraftClient.getInstance(); | ||
private final TextRenderer textRenderer = client.textRenderer; | ||
private final Screen parent; | ||
|
||
protected RenameScreenshotScreen(File screenshot, Screen parent) { | ||
super(Text.translatable("text.snapper.rename")); | ||
this.screenshot = screenshot; | ||
this.renameInput = new TextFieldWidget(textRenderer, 200, 20, RENAME_INPUT_TEXT); | ||
this.parent = parent; | ||
} | ||
|
||
@Override | ||
protected void init() { | ||
this.addDrawableChild(new TextWidget(RENAME_INPUT_TEXT, textRenderer)).setPosition(this.width / 2 - textRenderer.getWidth(RENAME_INPUT_TEXT) / 2, this.height / 2 - 20); | ||
this.addDrawableChild(this.renameInput).setPosition(this.width / 2 - 100, this.height / 2); | ||
this.renameInput.setText(this.screenshot.getName()); | ||
this.addDrawableChild(ButtonWidget.builder(Text.translatable("button.snapper.rename"), button -> { | ||
this.renameScreenshot(this.renameInput.getText()); | ||
}) | ||
.dimensions(width / 2 - 150 - 4, height - 32, 150, 20) | ||
.build() | ||
); | ||
|
||
this.addDrawableChild(ButtonWidget.builder(ScreenTexts.CANCEL, button -> this.close()) | ||
.dimensions(width / 2 + 4, height - 32, 150, 20) | ||
.build() | ||
); | ||
} | ||
|
||
private void renameScreenshot(String newName) { | ||
if (newName == null || !newName.endsWith(".png")) { | ||
return; | ||
} | ||
ScreenshotActions.renameScreenshot(screenshot, newName); | ||
client.setScreen(this.parent); | ||
// Should I make this an if-else statement just to bug Echo? | ||
} | ||
|
||
@Override | ||
public void render(DrawContext context, int mouseX, int mouseY, float delta) { | ||
super.render(context, mouseX, mouseY, delta); | ||
context.drawCenteredTextWithShadow(this.textRenderer, this.title, this.width / 2, 15, 0xFFFFFF); | ||
} | ||
|
||
@Override | ||
public void close() { | ||
this.client.setScreen(this.parent); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.