• Ищем качественного (не новичок) разработчиков Xenforo для этого форума! В идеале, чтобы ты был фулл стек программистом. Если у тебя есть что показать, то свяжись с нами по контактным данным: https://t.me/DREDD

Визуальная часть Notifications | Exp 3.1

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
28 Авг 2022
Сообщения
3
Реакции
0
Выберите загрузчик игры
  1. Прочие моды
SS -
Пожалуйста, авторизуйтесь для просмотра ссылки.


NOTIFICATIONS:
Expand Collapse Copy
public class NotificationManager {
    private final CopyOnWriteArrayList<Notification> notifications = new CopyOnWriteArrayList<>();

    public void add(String title, String content, int time, ImageType imageType) {
        notifications.add(new Notification(title, content, time, imageType));
    }

    public void draw(MatrixStack stack) {
        float yOffset = 4;
        float screenWidth = IMinecraft.window.scaledWidth();
        float screenHeight = IMinecraft.window.scaledHeight();

        for (Notification notification : notifications) {
            if (System.currentTimeMillis() - notification.getTime() <= notification.time2 - 1000L) {
                notification.slideAnimation.setDirection(Direction.FORWARDS);
            }

            if (System.currentTimeMillis() - notification.getTime() > notification.time2 * 1000L) {
                notification.slideAnimation.setDirection(Direction.BACKWARDS);
            }

            if (notification.slideAnimation.finished(Direction.BACKWARDS)) {
                notifications.remove(notification);
                continue;
            }

            float targetX = screenWidth - notification.getWidth() - 10;
            float y = screenHeight - notification.getHeight() - yOffset - 10;

            notification.setY(y);
            notification.setX(screenWidth + (targetX - screenWidth) * (float)notification.slideAnimation.getOutput());
            notification.draw(stack);

            yOffset += notification.getHeight() + 6;
        }
    }

    private class Notification {
        private float x;
        private float y;
        private final String title;
        private final String content;
        private final long time = System.currentTimeMillis();
        private final Animation slideAnimation = new EaseInOutQuad(400, 1.0, Direction.FORWARDS);
        private final ImageType imageType;
        private final int time2;
        private static final float WIDTH = 160;
        private static final float HEIGHT = 45;

        public Notification(String title, String content, int time, ImageType imageType) {
            this.title = title;
            this.content = content;
            this.time2 = time;
            this.imageType = imageType;
        }



        public float draw(MatrixStack stack) {
            Style style = NeoWawe.getInstance().getStyleManager().getCurrentStyle();

            drawStyledRect(x, y, WIDTH, HEIGHT, 6, 120);

            DisplayUtils.drawRoundedRect(x + 8, y + 8, 28, 28, 4, ColorUtils.setAlpha(style.getFirstColor().getRGB(), 180));

            float iconScale = 12f;
            if (imageType == ImageType.FIRST_PHOTO) {
                Fonts.nuralphaicons.drawText(stack, "K", x + 16, y + 16, ColorUtils.rgba(255, 255, 255, 255), iconScale);
            } else {
                Fonts.nuralphaicons.drawText(stack, "J", x + 16, y + 16, ColorUtils.rgba(255, 255, 255, 255), iconScale);
            }

            Fonts.sfMedium.drawText(stack, title, x + 44, y + 10, ColorUtils.rgba(255, 255, 255, 255), 7f);

            Fonts.sfMedium.drawText(stack, content, x + 44, y + 24,
                    ColorUtils.rgba(180, 180, 180, 255), 6f);

            float progress = 1f - Math.min(1f, (System.currentTimeMillis() - time) / (float)(time2 * 1000L));
            DisplayUtils.drawRoundedRect(x + 4, y + HEIGHT - 4, (WIDTH - 8) * progress, 2, 1,
                    style.getFirstColor().getRGB());

            return HEIGHT;
        }

        private void drawStyledRect(float x, float y, float width, float height, float radius, int alpha) {
            Style style = NeoWawe.getInstance().getStyleManager().getCurrentStyle();

            DisplayUtils.drawRoundedRect(x - 0.5f, y - 0.5f, width + 1, height + 1, radius + 0.5f, ColorUtils.setAlpha(ColorUtils.getColor(0), alpha));


            DisplayUtils.drawRoundedRect(x, y, width, height, radius, ColorUtils.rgba(21, 21, 21, alpha));
        }

        public float getX() { return x; }
        public float getY() { return y; }
        public void setX(float x) { this.x = x; }
        public void setY(float y) { this.y = y; }
        public long getTime() { return time; }
        public float getWidth() { return WIDTH; }
        public float getHeight() { return HEIGHT; }
    }

    public enum ImageType {
        FIRST_PHOTO,
        SECOND_PHOTO
    }
}
под тему, не судите строго, и не строго тоже не надо.
 
это пиздец:NotLikeThis:
 
спасибо - глаза
 
МОИ ГЛАЗА...
 
Здравствуйте, не хотели бы вы стать одним из кодеров нурсултан клиента?
 
Назад
Сверху Снизу