using DoomDeathmatch.Component.UI;
using DoomDeathmatch.Scene.Main;
using OpenTK.Mathematics;

namespace DoomDeathmatch.Scene.Rules;

public static class RulesScene
{
  public static Engine.Scene.Scene Create(Engine.Engine parEngine)
  {
    var scene = new Engine.Scene.Scene();

    var (cameraObject, camera) = UiUtil.CreateOrthographicCamera(scene);

    var (uiContainerObject, uiContainer) = UiUtil.CreateBackgroundUi(scene, new UiContainerComponent { Camera = camera });

    var (logoObject, logoUi) = UiUtil.CreateLogoUi(parEngine, scene, uiContainer);
    logoUi.Offset = new Vector2(0, 3f);

    var (backUiObject, backUi, _) = UiUtil.CreateTextUi(scene, uiContainer,
      UiUtil.GetDoomFont(parEngine), "Назад");
    backUi.OnClick += _ => parEngine.SceneManager.TransitionTo(() => MainScene.Create(parEngine));

    var (rulesObject, rulesUi, _) = UiUtil.CreateTextUi(scene, uiContainer,
      UiUtil.GetDoomFont(parEngine), "Правила");

    var (stackObject, stack) = UiUtil.CreateStackUi(scene,
      new StackComponent { Offset = new Vector2(0, -1f), Container = uiContainer, Children = { rulesUi, backUi } });
    stackObject.Transform.Size.Xy = new Vector2(1f, 6f);

    var (selectorObject, selector) = UiUtil.CreateSelectorUi(scene, new SelectorComponent { Children = { backUi } });

    scene.AddChild(uiContainerObject, selectorObject);

    scene.AddChild(uiContainerObject, logoObject);
    scene.AddChild(uiContainerObject, stackObject);

    scene.AddChild(stackObject, rulesObject);
    scene.AddChild(stackObject, backUiObject);

    return scene;
  }
}