import Locator from "../../services/Locator";
import {Container, Text} from "pixi.js";
import { tryToApplyFallbackFontFamily } from "../../utils/utils";
import AdvancedText from "../../utils/AdvancedText";

export default class WinText extends Container {
  constructor(options) {
    super();
    this._label = new AdvancedText({key: "total_bet"}, {
      fontFamily: "Oxanium, Opensans",
      fill: 0xffffff,
      fontWeight: 400,
      fontSize: 15,
      // stroke: 0,
      // strokeThickness: 2,
    });
    tryToApplyFallbackFontFamily(this._label);
    this._label.resolution = options?.resolution || Locator.renderer.resolution;

    this._value = new Text("", {
      fontFamily: "Oxanium, Opensans",
      fontWeight: "bold",
      fontSize: 15,
      fill: "#F8F303FF",
      // stroke: 0,
      // strokeThickness: 2,
    });
    tryToApplyFallbackFontFamily(this._value);
    this._value.resolution = options?.resolution || Locator.renderer.resolution;

    this.addChild(this._label, this._value);
  }

  set label(value) {
    this._label.content = [value, ":"];
    this._adjustPositions();
  }

  set value(value) {
    this._value.text = value;
    this._adjustPositions();
  }

  _adjustPositions() {
    this._value.x = this._label.width + 3;
  }
}
