package cn.forevermc.launcher.view.pages;

import cn.forevermc.launcher.ForeverMC;
import cn.forevermc.launcher.bean.ComponentSize;
import cn.forevermc.launcher.util.Resources;
import cn.forevermc.launcher.view.components.AbstractPane;
import cn.forevermc.launcher.view.components.TimiVersionLabel;
import cn.forevermc.launcher.view.components.control.MCButton;
import cn.forevermc.launcher.view.components.control.MCLabel;
import cn.forevermc.launcher.view.components.control.MCLink;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.image.ImageView;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import com.imyeyu.fx.ui.TimiFXUI;
import com.imyeyu.fx.utils.BgImage;
import com.imyeyu.fx.utils.Column;

/**
 * 关于面板
 *
 * @author 夜雨
 * @since 2022-11-24 17:44
 */
public abstract class AboutPane extends AbstractPane {

	protected final MCButton close;
	protected final ImageView title;

	public AboutPane() {
		// 标题
		title = new ImageView(Resources.TITLE);

		// 说明
		MCLabel description = new MCLabel(TimiFXUI.MULTILINGUAL.text("fmc.launcher.about.description"));
		description.setPadding(new Insets(0, 140, 16, 140));
		description.setWrapText(true);

		// 关闭
		close = new MCButton(TimiFXUI.MULTILINGUAL.text("close"));
		close.setPrefWidth(ComponentSize.SMALL);

		setMargin(close, new Insets(0, 0, 30, 0));
		setAlignment(close, Pos.CENTER);
		setAlignment(title, Pos.CENTER);

		setPadding(new Insets(64, 0, 0, 0));
		setTop(title);
		setCenter(new VBox() {{
			setSpacing(12);
			setPadding(new Insets(16));
			getChildren().addAll(new TimiVersionLabel(ForeverMC.VERSION, ForeverMC.class.getSimpleName()), description, new GridPane() {{
				getColumnConstraints().add(Column.build(HPos.RIGHT));
				setHgap(6);
				setVgap(6);
				setAlignment(Pos.CENTER);

				int row = 0;
				addRow(row++, new MCLabel() {{
					setText(TimiFXUI.MULTILINGUAL.text("source"));
					setTextFill(Colorful.LIGHT_GRAY);
				}}, new MCLink("https://git.imyeyu.net/Timi/ForeverMC"));
				addRow(row++, new MCLabel() {{
					setText(TimiFXUI.MULTILINGUAL.text("developer"));
					setTextFill(Colorful.LIGHT_GRAY);
				}}, new MCLabel("夜雨"));
				addRow(row, new MCLabel() {{
					setText(TimiFXUI.MULTILINGUAL.text("blog"));
					setTextFill(Colorful.LIGHT_GRAY);
				}}, new MCLink("https://www.imyeyu.net"));

			}});
		}});
		setBottom(close);
	}
}
