package dev.photosync.mcapi.screen;

import dev.photosync.mcapi.render.RenderBridge;

/**
 * A PhotoSync screen, in terms that owe nothing to Minecraft.
 *
 * <p>Each platform module has exactly one class that extends Minecraft's
 * {@code Screen} and forwards its lifecycle and input here. That class is the
 * only thing about the mod's entire interface that a new Minecraft version can
 * break.
 *
 * <p>The input methods answer whether they consumed the event, matching what
 * vanilla screens expect, so the adapter can pass the result straight through.
 */
public interface ScreenModel {

    /** Shown in the window title and read by screen readers. Already translated. */
    String title();

    /**
     * Called when the screen opens and again on every resize, with the current
     * GUI dimensions. Everything laid out in pixels should be computed here.
     */
    void layout(int width, int height);

    void render(RenderBridge render, int mouseX, int mouseY);

    /** Once per client tick, for cursor blink and other time-based state. */
    default void tick() {
    }

    default boolean mouseClicked(double mouseX, double mouseY, int button) {
        return false;
    }

    default boolean mouseReleased(double mouseX, double mouseY, int button) {
        return false;
    }

    default boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
        return false;
    }

    /** {@code amount} is positive when scrolling up, as vanilla reports it. */
    default boolean mouseScrolled(double mouseX, double mouseY, double amount) {
        return false;
    }

    default boolean keyPressed(int key, int scanCode, int modifiers) {
        return false;
    }

    default boolean charTyped(char character, int modifiers) {
        return false;
    }

    /** The screen is going away, for any reason. Release textures here. */
    default void closed() {
    }

    /** Whether opening this screen should pause a singleplayer world. */
    default boolean pausesGame() {
        return true;
    }

    /**
     * Whether Escape closes the screen. False while a modal is up -- the quit
     * dialog in particular, which has to be answered rather than dismissed.
     */
    default boolean closeOnEscape() {
        return true;
    }
}
