package com.mygdx.game; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.ui.*; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.utils.Align; public class HelpUI { private final Stage stage; private final Table helpMenu; private Texture circleTexture; private Texture rectTexture; private Texture closeTexture; private final Label musicStatusLabel; public HelpUI(final Stage stage, BitmapFont font, final MyGdxGame game) { this.stage = stage; circleTexture = createCircleTexture(60, Color.WHITE); rectTexture = createRectTexture(1, 1, new Color(0, 0, 0, 0.85f)); closeTexture = createRectTexture(40, 40, Color.RED); float screenWidth = stage.getViewport().getWorldWidth(); float screenHeight = stage.getViewport().getWorldHeight(); // --- Кнопка Помощи (?) --- Stack helpBtn = new Stack(); Image bgHelp = new Image(circleTexture); Label symbolHelp = new Label("?", new Label.LabelStyle(font, Color.BLACK)); symbolHelp.setAlignment(Align.center); helpBtn.add(bgHelp); helpBtn.add(symbolHelp); helpBtn.setSize(60, 60); helpBtn.setPosition(screenWidth - 80, screenHeight - 80); // --- Кнопка Музыки --- Stack musicBtn = new Stack(); Image bgMusic = new Image(circleTexture); musicStatusLabel = new Label(game.audioManager.isMusicOn ? "ON" : "OFF", new Label.LabelStyle(font, Color.BLACK)); musicStatusLabel.setFontScale(0.6f); musicStatusLabel.setAlignment(Align.center); musicBtn.add(bgMusic); musicBtn.add(musicStatusLabel); musicBtn.setSize(60, 60); musicBtn.setPosition(screenWidth - 150, screenHeight - 80); // --- Окно помощи --- helpMenu = new Table(); helpMenu.setFillParent(true); helpMenu.setVisible(false); Image overlay = new Image(rectTexture); overlay.setFillParent(true); Table content = new Table(); // Устанавливаем темно-синий фон для контента content.setBackground(new Image(createRectTexture(1, 1, new Color(0.1f, 0.1f, 0.15f, 1f))).getDrawable()); content.pad(50); // Увеличены отступы Stack closeBtn = new Stack(); Image closeBg = new Image(closeTexture); Label closeX = new Label("X", new Label.LabelStyle(font, Color.WHITE)); closeX.setAlignment(Align.center); closeBtn.add(closeBg); closeBtn.add(closeX); Label title = new Label("КАК ИГРАТЬ", new Label.LabelStyle(font, Color.GOLD)); title.setFontScale(1.2f); // Увеличен заголовок // Текст с правилами Label description = new Label( "1. Нажимай на зеркала, чтобы вращать их.\n\n" + "2. Направляй лазер на все пирамиды-цели.\n\n" + "3. Когда все цели станут зелеными, уровень пройден!\n\n\n" + "[ СИСТЕМА ЗВЕЗД ]\n\n" + "Пройди уровень быстро, чтобы получить Золотой Статус.\n" + "Лимит времени = 2.0 сек + 0.1 сек за каждый уровень.\n" + "Золотые уровни подсвечиваются желтым в меню!", new Label.LabelStyle(font, Color.WHITE) ); description.setWrap(true); description.setAlignment(Align.left); description.setFontScale(0.95f); // Масштаб текста возвращен к комфортному размеру Table header = new Table(); header.add(title).expandX().left(); header.add(closeBtn).size(50, 50).right(); // Кнопка закрытия чуть больше content.add(header).fillX().row(); content.add(new Label("", new Label.LabelStyle(font, Color.WHITE))).pad(15).row(); // Увеличена ширина текстового блока до 600 пикселей content.add(description).width(600).padTop(10); helpMenu.stack(overlay, content).center(); // --- Слушатели --- helpBtn.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { helpMenu.setVisible(true); } }); closeBtn.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { helpMenu.setVisible(false); } }); musicBtn.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { game.audioManager.isMusicOn = !game.audioManager.isMusicOn; game.audioManager.updateMusicFlag(); musicStatusLabel.setText(game.audioManager.isMusicOn ? "ON" : "OFF"); } }); stage.addActor(helpBtn); stage.addActor(musicBtn); stage.addActor(helpMenu); } private Texture createCircleTexture(int size, Color color) { Pixmap pixmap = new Pixmap(size, size, Pixmap.Format.RGBA8888); pixmap.setColor(Color.BLACK); pixmap.fillCircle(size / 2, size / 2, size / 2 - 1); pixmap.setColor(color); pixmap.fillCircle(size / 2, size / 2, size / 2 - 4); Texture t = new Texture(pixmap); pixmap.dispose(); return t; } private Texture createRectTexture(int w, int h, Color color) { Pixmap pixmap = new Pixmap(w, h, Pixmap.Format.RGBA8888); pixmap.setColor(color); pixmap.fill(); Texture t = new Texture(pixmap); pixmap.dispose(); return t; } public void dispose() { if (circleTexture != null) circleTexture.dispose(); if (rectTexture != null) rectTexture.dispose(); if (closeTexture != null) closeTexture.dispose(); } }